From 916cd899f319666abf051c65295589a5cad30d87 Mon Sep 17 00:00:00 2001 From: ZYH Date: Thu, 21 Mar 2019 15:30:04 +0800 Subject: [PATCH 1/4] [BSP][K210]Add interface reboot --- bsp/k210/driver/board.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bsp/k210/driver/board.c b/bsp/k210/driver/board.c index 0cd78b8c79..4241cc306e 100644 --- a/bsp/k210/driver/board.c +++ b/bsp/k210/driver/board.c @@ -117,3 +117,10 @@ void rt_hw_board_init(void) rt_components_board_init(); #endif } +void rt_hw_cpu_reset(void) +{ + sysctl->soft_reset.soft_reset = 1; + while(1); +} + +MSH_CMD_EXPORT_ALIAS(rt_hw_cpu_reset, reboot, reset machine); From 3e7a245c4637670a120048897a194711b2c8d53f Mon Sep 17 00:00:00 2001 From: ZYH Date: Fri, 22 Mar 2019 09:52:02 +0800 Subject: [PATCH 2/4] [BSP][K210]utest support --- bsp/k210/link.lds | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/bsp/k210/link.lds b/bsp/k210/link.lds index 851861f19f..bcf7681595 100644 --- a/bsp/k210/link.lds +++ b/bsp/k210/link.lds @@ -33,7 +33,7 @@ SECTIONS *(.start); } > SRAM - . = ALIGN(4); + . = ALIGN(8); .text : { @@ -46,24 +46,28 @@ SECTIONS *(.gnu.linkonce.t*) /* section information for finsh shell */ - . = ALIGN(4); + . = ALIGN(8); __fsymtab_start = .; KEEP(*(FSymTab)) __fsymtab_end = .; - . = ALIGN(4); + . = ALIGN(8); __vsymtab_start = .; KEEP(*(VSymTab)) __vsymtab_end = .; - . = ALIGN(4); + . = ALIGN(8); /* section information for initial. */ - . = ALIGN(4); + . = ALIGN(8); __rt_init_start = .; KEEP(*(SORT(.rti_fn*))) __rt_init_end = .; - . = ALIGN(4); + . = ALIGN(8); - . = ALIGN(4); + __rt_utest_tc_tab_start = .; + KEEP(*(UtestTcTab)) + __rt_utest_tc_tab_end = .; + + . = ALIGN(8); _etext = .; } > SRAM @@ -74,7 +78,7 @@ SECTIONS } > SRAM .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } > SRAM - . = ALIGN(4); + . = ALIGN(8); .data : { From 12ec9db1985c315ce0681029ddcb1d32f1272fb0 Mon Sep 17 00:00:00 2001 From: ZYH Date: Fri, 22 Mar 2019 11:04:48 +0800 Subject: [PATCH 3/4] [BSP][K210]add io config print --- bsp/k210/driver/drv_io_config.c | 58 +++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/bsp/k210/driver/drv_io_config.c b/bsp/k210/driver/drv_io_config.c index 63a75a0790..cd0e8f27f6 100644 --- a/bsp/k210/driver/drv_io_config.c +++ b/bsp/k210/driver/drv_io_config.c @@ -15,53 +15,71 @@ #define HS_GPIO(n) (FUNC_GPIOHS0 + n) +#define IOCONFIG(pin,func) {pin, func, #func} + static struct io_config { int io_num; fpioa_function_t func; + const char * func_name; } io_config[] = { #ifdef BSP_USING_LCD - {BSP_LCD_CS_PIN, FUNC_SPI0_SS0}, /* LCD CS PIN */ - {BSP_LCD_WR_PIN, FUNC_SPI0_SCLK}, /* LCD WR PIN */ - {BSP_LCD_DC_PIN, HS_GPIO(LCD_DC_PIN)}, /* LCD DC PIN */ + IOCONFIG(BSP_LCD_CS_PIN, FUNC_SPI0_SS0), /* LCD CS PIN */ + IOCONFIG(BSP_LCD_WR_PIN, FUNC_SPI0_SCLK), /* LCD WR PIN */ + IOCONFIG(BSP_LCD_DC_PIN, HS_GPIO(LCD_DC_PIN)), /* LCD DC PIN */ #endif #ifdef BSP_USING_CAMERA - {BSP_CAMERA_SCCB_SDA_PIN, FUNC_SCCB_SDA}, - {BSP_CAMERA_SCCB_SCLK_PIN, FUNC_SCCB_SCLK}, - {BSP_CAMERA_CMOS_RST_PIN, FUNC_CMOS_RST}, - {BSP_CAMERA_CMOS_VSYNC_PIN, FUNC_CMOS_VSYNC}, - {BSP_CAMERA_CMOS_PWDN_PIN, FUNC_CMOS_PWDN}, - {BSP_CAMERA_CMOS_XCLK_PIN, FUNC_CMOS_XCLK}, - {BSP_CAMERA_CMOS_PCLK_PIN, FUNC_CMOS_PCLK}, - {BSP_CAMERA_CMOS_HREF_PIN, FUNC_CMOS_HREF}, + IOCONFIG(BSP_CAMERA_SCCB_SDA_PIN, FUNC_SCCB_SDA), + IOCONFIG(BSP_CAMERA_SCCB_SCLK_PIN, FUNC_SCCB_SCLK), + IOCONFIG(BSP_CAMERA_CMOS_RST_PIN, FUNC_CMOS_RST), + IOCONFIG(BSP_CAMERA_CMOS_VSYNC_PIN, FUNC_CMOS_VSYNC), + IOCONFIG(BSP_CAMERA_CMOS_PWDN_PIN, FUNC_CMOS_PWDN), + IOCONFIG(BSP_CAMERA_CMOS_XCLK_PIN, FUNC_CMOS_XCLK), + IOCONFIG(BSP_CAMERA_CMOS_PCLK_PIN, FUNC_CMOS_PCLK), + IOCONFIG(BSP_CAMERA_CMOS_HREF_PIN, FUNC_CMOS_HREF), #endif #ifdef BSP_USING_SPI1 - {BSP_SPI1_CLK_PIN, FUNC_SPI1_SCLK}, - {BSP_SPI1_D0_PIN, FUNC_SPI1_D0}, - {BSP_SPI1_D1_PIN, FUNC_SPI1_D1}, + IOCONFIG(BSP_SPI1_CLK_PIN, FUNC_SPI1_SCLK), + IOCONFIG(BSP_SPI1_D0_PIN, FUNC_SPI1_D0), + IOCONFIG(BSP_SPI1_D1_PIN, FUNC_SPI1_D1), #ifdef BSP_USING_SPI1_AS_QSPI - {BSP_SPI1_D2_PIN, FUNC_SPI1_D2}, - {BSP_SPI1_D3_PIN, FUNC_SPI1_D3}, + IOCONFIG(BSP_SPI1_D2_PIN, FUNC_SPI1_D2), + IOCONFIG(BSP_SPI1_D3_PIN, FUNC_SPI1_D3), #endif #ifdef BSP_SPI1_USING_SS0 - {BSP_SPI1_SS0_PIN, HS_GPIO(SPI1_CS0_PIN)}, + IOCONFIG(BSP_SPI1_SS0_PIN, HS_GPIO(SPI1_CS0_PIN)), #endif #ifdef BSP_SPI1_USING_SS1 - {BSP_SPI1_SS1_PIN, HS_GPIO(SPI1_CS1_PIN)}, + IOCONFIG(BSP_SPI1_SS1_PIN, HS_GPIO(SPI1_CS1_PIN)), #endif #ifdef BSP_SPI1_USING_SS2 - {BSP_SPI1_SS2_PIN, HS_GPIO(SPI1_CS2_PIN)}, + IOCONFIG(BSP_SPI1_SS2_PIN, HS_GPIO(SPI1_CS2_PIN)), #endif #ifdef BSP_SPI1_USING_SS3 - {BSP_SPI1_SS3_PIN, HS_GPIO(SPI1_CS3_PIN)}, + IOCONFIG(BSP_SPI1_SS3_PIN, HS_GPIO(SPI1_CS3_PIN)), #endif #endif }; +static int print_io_config() +{ + int i; + rt_kprintf("IO Configuration Table\n"); + rt_kprintf("┌───────┬────────────────────────┐\n"); + rt_kprintf("│Pin │Function │\n"); + rt_kprintf("├───────┼────────────────────────┤\n"); + for(i = 0; i < sizeof io_config / sizeof io_config[0]; i++) + { + rt_kprintf("│%-2d │%-24.24s│\n", io_config[i].io_num, io_config[i].func_name); + } + rt_kprintf("└───────┴────────────────────────┘\n"); + return 0; +} +MSH_CMD_EXPORT_ALIAS(print_io_config, io, print io config); int io_config_init(void) { From fcb88f70343f9e2dd8e3ba3ab7cba56497ad1415 Mon Sep 17 00:00:00 2001 From: ZYH Date: Thu, 28 Mar 2019 16:49:43 +0800 Subject: [PATCH 4/4] [libcpu][k210]fix stack frame print --- libcpu/risc-v/k210/interrupt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcpu/risc-v/k210/interrupt.c b/libcpu/risc-v/k210/interrupt.c index 45b437c099..b582599daf 100644 --- a/libcpu/risc-v/k210/interrupt.c +++ b/libcpu/risc-v/k210/interrupt.c @@ -270,7 +270,7 @@ struct exception_stack_frame void print_stack_frame(uintptr_t * sp) { - struct exception_stack_frame * esf = (struct exception_stack_frame *)sp; + struct exception_stack_frame * esf = (struct exception_stack_frame *)(sp+1); rt_kprintf("\n=================================================================\n"); rt_kprintf("x1 (ra : Return address ) ==> 0x%08x%08x\n", esf->x1 >> 32 , esf->x1 & UINT32_MAX);