From 064e9c91f796614257e1d33abd3ed33d0eedfc32 Mon Sep 17 00:00:00 2001 From: jzlv Date: Tue, 27 Apr 2021 12:35:37 +0800 Subject: [PATCH] [fix] fix cmake files --- CMakeLists.txt | 23 +- Makefile | 10 + common/CMakeLists.txt | 17 +- components/fatfs/CMakeLists.txt | 19 +- components/freertos/CMakeLists.txt | 25 +- components/shell/CMakeLists.txt | 12 +- components/usb_stack/CMakeLists.txt | 13 +- project.build | 2 +- tools/cmake/compiler_flags.cmake | 29 +- tools/cmake/tools.cmake | 6 +- tools/openocd/602.init | 30 +- tools/openocd/602.svd | 472 +++++++++++------------ tools/openocd/702.init | 30 +- tools/openocd/if_bflb_dbg.cfg | 32 +- tools/openocd/if_bflb_link.cfg | 32 +- tools/openocd/if_ft2232d.cfg | 30 +- tools/openocd/if_jlink.cfg | 14 +- tools/openocd/openocd-usb-sipeed-xip.cfg | 80 ++-- tools/openocd/openocd-usb-sipeed.cfg | 48 +-- tools/openocd/tgt_602.cfg | 90 ++--- tools/openocd/tgt_702.cfg | 90 ++--- 21 files changed, 563 insertions(+), 541 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b69b573..cd0dadc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,16 +7,33 @@ PROJECT(${BOARD} C CXX ASM) include_directories(${CMAKE_SOURCE_DIR}/common/misc) include_directories(${CMAKE_SOURCE_DIR}/bsp/bsp_common/platform) + +if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/bsp/board/${BOARD}) include_directories(${CMAKE_SOURCE_DIR}/bsp/board/${BOARD}) +else() +message(FATAL_ERROR "${CMAKE_SOURCE_DIR}/bsp/board/${BOARD} is not exist") +endif() add_subdirectory(common) add_subdirectory(components/fatfs) add_subdirectory(components/usb_stack) -add_subdirectory(drivers/${mcu}_driver) -if(${SUPPORT_SHELL} STREQUAL "ENABLE") +if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/drivers/${mcu}_driver) +add_subdirectory(drivers/${mcu}_driver) +else() +message(FATAL_ERROR "${CMAKE_SOURCE_DIR}/drivers/${mcu}_driver is not exist") +endif() + +if(${SUPPORT_SHELL} STREQUAL "y") add_subdirectory(components/shell) -else() +endif() + +if(${SUPPORT_FREERTOS} STREQUAL "y") +add_subdirectory(components/freertos) +endif() + +if(${SUPPORT_LVGL} STREQUAL "y") +add_subdirectory(components/lvgl) endif() search_application(${CMAKE_SOURCE_DIR}/examples) diff --git a/Makefile b/Makefile index 99bcf1eb..9acb2d18 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,18 @@ CHIP?=bl702 INTERFACE?=jlink BAUDRATE ?=12000 +SUPPORT_SHELL?=n +SUPPORT_FREERTOS?=n +SUPPORT_LVGL?=n +SUPPORT_FLOAT?=n + export BOARD export APP +export SUPPORT_SHELL +export SUPPORT_FREERTOS +export SUPPORT_LVGL +export SUPPORT_FLOAT + # The command to remove a file. RM = cmake -E rm -rf diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 8ca766d2..5696382d 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -31,34 +31,35 @@ file(GLOB_RECURSE sources #aux_source_directory(. sources) list(APPEND ADD_SRCS ${sources}) -list(REMOVE_ITEM ADD_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/libc/src/strtox.c" "${CMAKE_CURRENT_SOURCE_DIR}/libc/src/atox.c") +list(REMOVE_ITEM ADD_SRCS +"${CMAKE_CURRENT_SOURCE_DIR}/libc/src/strtox.c" +"${CMAKE_CURRENT_SOURCE_DIR}/libc/src/atox.c" +"${CMAKE_CURRENT_SOURCE_DIR}/libc/src/stdlib.c") ####################################################### ########### Add required/dependent components ######### -#list(APPEND ADD_REQUIREMENTS BSP_${BOARD}_Driver) +#list(APPEND ADD_REQUIREMENTS xxx) ####################################################### ############ Add static libs ########################## # if(CONFIG_COMPONENT1_INCLUDE_STATIC_LIB) -# list(APPEND ADD_STATIC_LIB "lib/libtest.a") +# list(APPEND ADD_STATIC_LIB "libxxx.a") # endif() ####################################################### ############ Add dynamic libs ######################### -# list(APPEND ADD_DYNAMIC_LIB "lib/arch/v831/libmaix_nn.so" -# "lib/arch/v831/libmaix_cam.so" +# list(APPEND ADD_DYNAMIC_LIB "libxxx.so" # ) ####################################################### ############ Add global compile option ################ #add components denpend on this component -# list(APPEND ADD_DEFINITIONS -D${BOARD} -DARCH_RISCV) +# list(APPEND ADD_DEFINITIONS -Dxxx) ####################################################### ############ Add private compile option ################ #add compile option for this component that won't affect other modules -#list(APPEND ADD_DEFINITIONS_PRIVATE -D${BOARD}_DRIVER) +# list(APPEND ADD_DEFINITIONS_PRIVATE -Dxxx) ####################################################### - generate_library() diff --git a/components/fatfs/CMakeLists.txt b/components/fatfs/CMakeLists.txt index 38a1a11a..9ac5dc84 100644 --- a/components/fatfs/CMakeLists.txt +++ b/components/fatfs/CMakeLists.txt @@ -6,12 +6,6 @@ list(APPEND ADD_INCLUDE ################# Add private include ################# # list(APPEND ADD_PRIVATE_INCLUDE -# "${CMAKE_SOURCE_DIR}/BSP_Common/ring_buffer" -# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/StdDriver/Inc" -# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/StdDriver/Inc" -# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/Peripherals" -# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/RISCV/Device/Bouffalo/${BOARD}/Startup" -# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/RISCV/Core/Include" # ) ####################################################### @@ -23,30 +17,27 @@ list(APPEND ADD_SRCS ${sources}) ####################################################### ########### Add required/dependent components ######### -#list(APPEND ADD_REQUIREMENTS BSP_${BOARD}_Driver BSP_Common) +#list(APPEND ADD_REQUIREMENTS xxx) ####################################################### ############ Add static libs ########################## # if(CONFIG_COMPONENT1_INCLUDE_STATIC_LIB) -# list(APPEND ADD_STATIC_LIB "lib/libtest.a") +# list(APPEND ADD_STATIC_LIB "libxxx.a") # endif() ####################################################### ############ Add dynamic libs ######################### -# list(APPEND ADD_DYNAMIC_LIB "lib/arch/v831/libmaix_nn.so" -# "lib/arch/v831/libmaix_cam.so" -# ) +# list(APPEND ADD_DYNAMIC_LIB "libxxx.so") ####################################################### ############ Add global compile option ################ #add components denpend on this component -# list(APPEND ADD_DEFINITIONS -DAAAAA222=1 -# -DAAAAA333=1) +# list(APPEND ADD_DEFINITIONS -Dxxx) ####################################################### ############ Add private compile option ################ #add compile option for this component that won't affect other modules -# list(APPEND ADD_DEFINITIONS_PRIVATE -DAAAAA=1) +# list(APPEND ADD_DEFINITIONS_PRIVATE -Dxxx) ####################################################### generate_library() diff --git a/components/freertos/CMakeLists.txt b/components/freertos/CMakeLists.txt index 69803553..9f2a738b 100644 --- a/components/freertos/CMakeLists.txt +++ b/components/freertos/CMakeLists.txt @@ -1,18 +1,13 @@ ################# Add global include ################# list(APPEND ADD_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}" -"${CMAKE_CURRENT_SOURCE_DIR}/include" +"${CMAKE_CURRENT_SOURCE_DIR}/include" +"${CMAKE_CURRENT_SOURCE_DIR}/portable/gcc/risc-v/${mcu}" ) ####################################################### ################# Add private include ################# # list(APPEND ADD_PRIVATE_INCLUDE -# "${CMAKE_SOURCE_DIR}/BSP_Common/ring_buffer" -# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/StdDriver/Inc" -# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/StdDriver/Inc" -# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/Peripherals" -# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/RISCV/Device/Bouffalo/${BOARD}/Startup" -# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/RISCV/Core/Include" # ) ####################################################### @@ -24,7 +19,9 @@ file(GLOB_RECURSE sources "${CMAKE_CURRENT_SOURCE_DIR}/croutine.c" "${CMAKE_CURRENT_SOURCE_DIR}/queue.c" "${CMAKE_CURRENT_SOURCE_DIR}/tasks.c" "${CMAKE_CURRENT_SOURCE_DIR}/timers.c" -"${CMAKE_CURRENT_SOURCE_DIR}/portable/MemMang/heap_5.c" +"${CMAKE_CURRENT_SOURCE_DIR}/portable/memmang/heap_5.c" +"${CMAKE_CURRENT_SOURCE_DIR}/portable/gcc/risc-v/${mcu}/port.c" +"${CMAKE_CURRENT_SOURCE_DIR}/portable/gcc/risc-v/${mcu}/portASM.S" ) list(APPEND ADD_SRCS ${sources}) # aux_source_directory(src ADD_SRCS) @@ -32,30 +29,28 @@ list(APPEND ADD_SRCS ${sources}) ####################################################### ########### Add required/dependent components ######### -#list(APPEND ADD_REQUIREMENTS BSP_${BOARD}_Driver) +#list(APPEND ADD_REQUIREMENTS xxx) ####################################################### ############ Add static libs ########################## # if(CONFIG_COMPONENT1_INCLUDE_STATIC_LIB) -# list(APPEND ADD_STATIC_LIB "lib/libtest.a") +# list(APPEND ADD_STATIC_LIB "libxxx.a") # endif() ####################################################### ############ Add dynamic libs ######################### -# list(APPEND ADD_DYNAMIC_LIB "lib/arch/v831/libmaix_nn.so" -# "lib/arch/v831/libmaix_cam.so" +# list(APPEND ADD_DYNAMIC_LIB "libxxx.so" # ) ####################################################### ############ Add global compile option ################ #add components denpend on this component -# list(APPEND ADD_DEFINITIONS -DAAAAA222=1 -# -DAAAAA333=1) +list(APPEND ADD_DEFINITIONS -DportasmHANDLE_INTERRUPT=FreeRTOS_Interrupt_Handler) ####################################################### ############ Add private compile option ################ #add compile option for this component that won't affect other modules -# list(APPEND ADD_DEFINITIONS_PRIVATE -DAAAAA=1) +# list(APPEND ADD_DEFINITIONS_PRIVATE -Dxxx) ####################################################### generate_library() diff --git a/components/shell/CMakeLists.txt b/components/shell/CMakeLists.txt index 8bd8cf94..5d96f8f6 100644 --- a/components/shell/CMakeLists.txt +++ b/components/shell/CMakeLists.txt @@ -20,30 +20,28 @@ list(APPEND ADD_SRCS ${sources}) ####################################################### ########### Add required/dependent components ######### -#list(APPEND ADD_REQUIREMENTS BSP_${BOARD}_Driver) +#list(APPEND ADD_REQUIREMENTS xxx) ####################################################### ############ Add static libs ########################## # if(CONFIG_COMPONENT1_INCLUDE_STATIC_LIB) -# list(APPEND ADD_STATIC_LIB "lib/libtest.a") +# list(APPEND ADD_STATIC_LIB "libxxx.a") # endif() ####################################################### ############ Add dynamic libs ######################### -# list(APPEND ADD_DYNAMIC_LIB "lib/arch/v831/libmaix_nn.so" -# "lib/arch/v831/libmaix_cam.so" +# list(APPEND ADD_DYNAMIC_LIB "libxxx.so" # ) ####################################################### ############ Add global compile option ################ #add components denpend on this component -#list(APPEND ADD_DEFINITIONS -D${BOARD} -DARCH_RISCV) +# list(APPEND ADD_DEFINITIONS -Dxxx) ####################################################### ############ Add private compile option ################ #add compile option for this component that won't affect other modules -#list(APPEND ADD_DEFINITIONS_PRIVATE -D${BOARD}_DRIVER) +# list(APPEND ADD_DEFINITIONS_PRIVATE -Dxxx) ####################################################### - generate_library() diff --git a/components/usb_stack/CMakeLists.txt b/components/usb_stack/CMakeLists.txt index 0335adb6..be3acf73 100644 --- a/components/usb_stack/CMakeLists.txt +++ b/components/usb_stack/CMakeLists.txt @@ -6,6 +6,7 @@ list(APPEND ADD_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/class/hid" "${CMAKE_CURRENT_SOURCE_DIR}/class/msc" "${CMAKE_CURRENT_SOURCE_DIR}/class/video" +#"${CMAKE_CURRENT_SOURCE_DIR}/class/vendor" "${CMAKE_CURRENT_SOURCE_DIR}/class/winusb" ) ####################################################### @@ -24,30 +25,28 @@ list(APPEND ADD_SRCS ${sources}) ####################################################### ########### Add required/dependent components ######### -#list(APPEND ADD_REQUIREMENTS BSP_${BOARD}_Driver) +#list(APPEND ADD_REQUIREMENTS xxx) ####################################################### ############ Add static libs ########################## # if(CONFIG_COMPONENT1_INCLUDE_STATIC_LIB) -# list(APPEND ADD_STATIC_LIB "lib/libtest.a") +# list(APPEND ADD_STATIC_LIB "libxxx.a") # endif() ####################################################### ############ Add dynamic libs ######################### -# list(APPEND ADD_DYNAMIC_LIB "lib/arch/v831/libmaix_nn.so" -# "lib/arch/v831/libmaix_cam.so" +# list(APPEND ADD_DYNAMIC_LIB "libxxx.so" # ) ####################################################### ############ Add global compile option ################ #add components denpend on this component -# list(APPEND ADD_DEFINITIONS -DAAAAA222=1 -# -DAAAAA333=1) +# list(APPEND ADD_DEFINITIONS -Dxxx) ####################################################### ############ Add private compile option ################ #add compile option for this component that won't affect other modules -# list(APPEND ADD_DEFINITIONS_PRIVATE -DAAAAA=1) +# list(APPEND ADD_DEFINITIONS_PRIVATE -Dxxx) ####################################################### generate_library() diff --git a/project.build b/project.build index 7c6878c7..dee46e7b 100644 --- a/project.build +++ b/project.build @@ -1,4 +1,4 @@ PHONY := __build __build: - cmake -DBOARD=$(BOARD) -DSUPPORT_SHELL=DISABLE -DAPP=$(APP) .. + cmake -DBOARD=$(BOARD) -DSUPPORT_SHELL=$(SUPPORT_SHELL) -DSUPPORT_FREERTOS=$(SUPPORT_FREERTOS) -DSUPPORT_LVGL=$(SUPPORT_LVGL) -DSUPPORT_FLOAT=$(SUPPORT_FLOAT) -DAPP=$(APP) .. make -j diff --git a/tools/cmake/compiler_flags.cmake b/tools/cmake/compiler_flags.cmake index 30763262..3c30121d 100644 --- a/tools/cmake/compiler_flags.cmake +++ b/tools/cmake/compiler_flags.cmake @@ -10,21 +10,25 @@ # -g Produce debugging information in the operating system’s native format. # -Os Optimize for size. -Os enables all -O2 optimizations. # -flto Runs the standard link-time optimizer. - -SET(MARCH "rv32imafc") SET(MCPU "riscv-e24") +if(${SUPPORT_FLOAT} STREQUAL "y") +SET(MARCH "rv32imafc") SET(MABI "ilp32f") +else() +SET(MARCH "rv32imac") +SET(MABI "ilp32") +endif() SET(MCU_FLAG "-march=${MARCH} -mabi=${MABI}") - -SET(COMMON_FLAGS "-O2 -g3 -fshort-enums -fno-common \ + +SET(COMMON_FLAGS "-Os -g3 -fshort-enums -fno-common \ -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields \ --Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -fno-jump-tables \ --Wignored-qualifiers -Wswitch-default -Wunused -Wundef -msmall-data-limit=4") +-Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self \ +-Wignored-qualifiers -Wunused -Wundef -msmall-data-limit=4") # compiler: language specific flags set(CMAKE_C_FLAGS "${MCU_FLAG} ${COMMON_FLAGS} -std=c99" CACHE INTERNAL "c compiler flags") set(CMAKE_C_FLAGS_DEBUG "-Og -g" CACHE INTERNAL "c compiler flags: Debug") -set(CMAKE_C_FLAGS_RELEASE "-Os -flto" CACHE INTERNAL "c compiler flags: Release") +set(CMAKE_C_FLAGS_RELEASE "-Os" CACHE INTERNAL "c compiler flags: Release") # message("") # message("-----------------------------------------------------------------------------------------------------------------------------------------------------") @@ -37,7 +41,7 @@ set(CMAKE_C_FLAGS_RELEASE "-Os -flto" CACHE INTERNAL "c compiler flags: Release" set(CMAKE_CXX_FLAGS "${MCU_FLAG} ${COMMON_FLAGS} -std=c++11 " CACHE INTERNAL "cxx compiler flags") set(CMAKE_CXX_FLAGS_DEBUG "-Og -g" CACHE INTERNAL "cxx compiler flags: Debug") -set(CMAKE_CXX_FLAGS_RELEASE "-Os -flto" CACHE INTERNAL "cxx compiler flags: Release") +set(CMAKE_CXX_FLAGS_RELEASE "-Os" CACHE INTERNAL "cxx compiler flags: Release") # message("") # message("-----------------------------------------------------------------------------------------------------------------------------------------------------") @@ -50,7 +54,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "-Os -flto" CACHE INTERNAL "cxx compiler flags: Rele set(CMAKE_ASM_FLAGS "${MCU_FLAG} ${COMMON_FLAGS}" CACHE INTERNAL "asm compiler flags") set(CMAKE_ASM_FLAGS_DEBUG "-Og -g" CACHE INTERNAL "asm compiler flags: Debug") -set(CMAKE_ASM_FLAGS_RELEASE "-Os -flto" CACHE INTERNAL "asm compiler flags: Release") +set(CMAKE_ASM_FLAGS_RELEASE "-Os" CACHE INTERNAL "asm compiler flags: Release") # message("") # message("-----------------------------------------------------------------------------------------------------------------------------------------------------") @@ -64,7 +68,12 @@ set(CMAKE_ASM_FLAGS_RELEASE "-Os -flto" CACHE INTERNAL "asm compiler flags: Rele # --specs=nano.specs Link with newlib-nano. # --specs=nosys.specs No syscalls, provide empty implementations for the POSIX system calls. -if(${SUPPORT_SHELL} STREQUAL "ENABLE") +if(${SUPPORT_FLOAT} STREQUAL "y") +add_definitions(-DBFLB_PRINT_FLOAT_SUPPORT) +else() +endif() + +if(${SUPPORT_SHELL} STREQUAL "y") add_definitions(-DSHELL_SUPPORT) else() endif() diff --git a/tools/cmake/tools.cmake b/tools/cmake/tools.cmake index 87100aa7..00c3b55e 100644 --- a/tools/cmake/tools.cmake +++ b/tools/cmake/tools.cmake @@ -114,7 +114,8 @@ function(generate_bin) set(HEX_FILE ${OUTPUT_DIR}/main.hex) set(BIN_FILE ${OUTPUT_DIR}/main.bin) set(MAP_FILE ${OUTPUT_DIR}/main.map) - + set(ASM_FILE ${OUTPUT_DIR}/main.asm) + if(TARGET_REQUIRED_SRCS) list(APPEND SRCS ${TARGET_REQUIRED_SRCS}) endif() @@ -143,7 +144,7 @@ function(generate_bin) # Add libs target_link_libraries(${target_name}.elf ${mcu}_driver) - if(${SUPPORT_SHELL} STREQUAL "ENABLE") + if(${SUPPORT_SHELL} STREQUAL "y") target_link_libraries(${target_name}.elf shell) else() include_directories(${CMAKE_SOURCE_DIR}/components/shell) @@ -157,6 +158,7 @@ function(generate_bin) add_custom_command(TARGET ${target_name}.elf POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary $ ${BIN_FILE} + COMMAND ${CMAKE_OBJDUMP} -d -S $ >${ASM_FILE} # COMMAND ${CMAKE_OBJCOPY} -Oihex $ ${HEX_FILE} COMMAND ${CMAKE_COMMAND} -E copy ${BIN_FILE} ${CMAKE_SOURCE_DIR}/tools/bflb_flash_tool/img/project.bin COMMENT "Generate ${BIN_FILE}\r\nCopy ${BIN_FILE} into download path") diff --git a/tools/openocd/602.init b/tools/openocd/602.init index 76910ed8..3f212b25 100644 --- a/tools/openocd/602.init +++ b/tools/openocd/602.init @@ -1,15 +1,15 @@ -set architecture riscv:rv32 -#target remote :3333 -#set disassemble-next-line on -set mem inaccessible-by-default off -#gdb_breakpoint_override [hard|soft|disable] - -mem 0x22008000 0x22014000 rw -mem 0x42008000 0x42014000 rw -mem 0x22014000 0x22020000 rw -mem 0x42014000 0x42020000 rw -mem 0x22020000 0x22030000 rw -mem 0x42020000 0x42030000 rw -mem 0x22030000 0x2204C000 rw -mem 0x42030000 0x4204C000 rw -mem 0x23000000 0x23400000 ro +set architecture riscv:rv32 +#target remote :3333 +#set disassemble-next-line on +set mem inaccessible-by-default off +#gdb_breakpoint_override [hard|soft|disable] + +mem 0x22008000 0x22014000 rw +mem 0x42008000 0x42014000 rw +mem 0x22014000 0x22020000 rw +mem 0x42014000 0x42020000 rw +mem 0x22020000 0x22030000 rw +mem 0x42020000 0x42030000 rw +mem 0x22030000 0x2204C000 rw +mem 0x42030000 0x4204C000 rw +mem 0x23000000 0x23400000 ro diff --git a/tools/openocd/602.svd b/tools/openocd/602.svd index 63f23bc7..1910415f 100644 --- a/tools/openocd/602.svd +++ b/tools/openocd/602.svd @@ -1,236 +1,236 @@ - - - bouffalolab - bouffalolab - 602 - WiFi BT - - high-performance, 32-bit RV32IMAFC core - - - 8 - 32 - 32 - 0x00000000 - 0xFFFFFFFF - - - 602 - little - - - - - - CLINT - Core Local Interruptor. - 0x02000000 - CLINT - 32 - read-write - - - 0 - 0x10000 - registers - - - - - - MSIP - Machine Software Interrupt Pending Register. - 0x0000 - - - - MTIMECMP_LO - Machine Timer Compare Register Low. - 0x4000 - - - - MTIMECMP_HI - Machine Timer Compare Register High. - 0x4004 - - - - MTIME_LO - Machine Timer Register Low. - 0xBFF8 - - - - MTIME_HI - Machine Timer Register High. - 0xBFFC - - - - - - - CLIC - Core Local Interrupter controller. - 0x02800000 - CLIC - 8 - read-write - - - 0 - 0x10000 - registers - - - - - - 128 - 1 - PENDING[%s] - CLIC Interrupt Pending Registers. - 0x0000 - - PENDING00 - - - - - 128 - 1 - ENABLE[%s] - CLIC Interrupt enable Registers. - 0x0400 - - ENABLE00 - - - - - 128 - 1 - INTCFG[%s] - CLIC Interrupt config Registers. - 0x0800 - - INTCFG37 - - - - - clic_cfg - clic_cfg. - 0x0C00 - - nvbits00 - nlbits13 - nmbits45 - - - - - - - - GLB - GLB. - 0x40000000 - GLB - 32 - read-write - - - 0 - 0x1000 - registers - - - - - - clk_cfg0 - clk_cfg0. - 0x0000 - - pll_en00 - fclk_en11 - hclk_en22 - bclk_en33 - pll_set45 - hbn_root_clk_set67 - hclk_div815 - bclk_div1623 - fclk_sw_state2426 - chip_rdy2727 - glb_id2831 - - - - - - - - - eFuse - eFuse Programmable Memory. - 0x40007000 - eFuse - 32 - read-only - - - 0 - 0x1000 - registers - - - - - - ef_cfg_0 - ef_cfg_0. - 0x0000 - - ef_sboot_en45 - ef_boot_sel811 - ef_cpu0_enc_en77 - ef_cpu1_enc_en66 - ef_sboot_en45 - ef_sboot_sign_mode23 - ef_sf_aes_mode01 - - - - - ef_wifi_mac_low - ef_wifi_mac_low. - 0x0014 - - mac_addr1031 - - - - - ef_wifi_mac_high - ef_wifi_mac_high. - 0x0018 - - dev_info73131 - dev_info63030 - dev_info52929 - dev_info4_32728 - dev_info2_02426 - cust_id1_02223 - mac_addr1_crc5_01621 - mac_addr1015 - - - - - - - - - + + + bouffalolab + bouffalolab + 602 + WiFi BT + + high-performance, 32-bit RV32IMAFC core + + + 8 + 32 + 32 + 0x00000000 + 0xFFFFFFFF + + + 602 + little + + + + + + CLINT + Core Local Interruptor. + 0x02000000 + CLINT + 32 + read-write + + + 0 + 0x10000 + registers + + + + + + MSIP + Machine Software Interrupt Pending Register. + 0x0000 + + + + MTIMECMP_LO + Machine Timer Compare Register Low. + 0x4000 + + + + MTIMECMP_HI + Machine Timer Compare Register High. + 0x4004 + + + + MTIME_LO + Machine Timer Register Low. + 0xBFF8 + + + + MTIME_HI + Machine Timer Register High. + 0xBFFC + + + + + + + CLIC + Core Local Interrupter controller. + 0x02800000 + CLIC + 8 + read-write + + + 0 + 0x10000 + registers + + + + + + 128 + 1 + PENDING[%s] + CLIC Interrupt Pending Registers. + 0x0000 + + PENDING00 + + + + + 128 + 1 + ENABLE[%s] + CLIC Interrupt enable Registers. + 0x0400 + + ENABLE00 + + + + + 128 + 1 + INTCFG[%s] + CLIC Interrupt config Registers. + 0x0800 + + INTCFG37 + + + + + clic_cfg + clic_cfg. + 0x0C00 + + nvbits00 + nlbits13 + nmbits45 + + + + + + + + GLB + GLB. + 0x40000000 + GLB + 32 + read-write + + + 0 + 0x1000 + registers + + + + + + clk_cfg0 + clk_cfg0. + 0x0000 + + pll_en00 + fclk_en11 + hclk_en22 + bclk_en33 + pll_set45 + hbn_root_clk_set67 + hclk_div815 + bclk_div1623 + fclk_sw_state2426 + chip_rdy2727 + glb_id2831 + + + + + + + + + eFuse + eFuse Programmable Memory. + 0x40007000 + eFuse + 32 + read-only + + + 0 + 0x1000 + registers + + + + + + ef_cfg_0 + ef_cfg_0. + 0x0000 + + ef_sboot_en45 + ef_boot_sel811 + ef_cpu0_enc_en77 + ef_cpu1_enc_en66 + ef_sboot_en45 + ef_sboot_sign_mode23 + ef_sf_aes_mode01 + + + + + ef_wifi_mac_low + ef_wifi_mac_low. + 0x0014 + + mac_addr1031 + + + + + ef_wifi_mac_high + ef_wifi_mac_high. + 0x0018 + + dev_info73131 + dev_info63030 + dev_info52929 + dev_info4_32728 + dev_info2_02426 + cust_id1_02223 + mac_addr1_crc5_01621 + mac_addr1015 + + + + + + + + + diff --git a/tools/openocd/702.init b/tools/openocd/702.init index 76910ed8..3f212b25 100644 --- a/tools/openocd/702.init +++ b/tools/openocd/702.init @@ -1,15 +1,15 @@ -set architecture riscv:rv32 -#target remote :3333 -#set disassemble-next-line on -set mem inaccessible-by-default off -#gdb_breakpoint_override [hard|soft|disable] - -mem 0x22008000 0x22014000 rw -mem 0x42008000 0x42014000 rw -mem 0x22014000 0x22020000 rw -mem 0x42014000 0x42020000 rw -mem 0x22020000 0x22030000 rw -mem 0x42020000 0x42030000 rw -mem 0x22030000 0x2204C000 rw -mem 0x42030000 0x4204C000 rw -mem 0x23000000 0x23400000 ro +set architecture riscv:rv32 +#target remote :3333 +#set disassemble-next-line on +set mem inaccessible-by-default off +#gdb_breakpoint_override [hard|soft|disable] + +mem 0x22008000 0x22014000 rw +mem 0x42008000 0x42014000 rw +mem 0x22014000 0x22020000 rw +mem 0x42014000 0x42020000 rw +mem 0x22020000 0x22030000 rw +mem 0x42020000 0x42030000 rw +mem 0x22030000 0x2204C000 rw +mem 0x42030000 0x4204C000 rw +mem 0x23000000 0x23400000 ro diff --git a/tools/openocd/if_bflb_dbg.cfg b/tools/openocd/if_bflb_dbg.cfg index 9f754f8d..e2e382db 100644 --- a/tools/openocd/if_bflb_dbg.cfg +++ b/tools/openocd/if_bflb_dbg.cfg @@ -1,16 +1,16 @@ -# BouffaloLab USB-JTAG/TTL adapter -interface ftdi -ftdi_vid_pid 0x0403 0x6010 - -ftdi_channel 1 -ftdi_tdo_sample_edge falling -transport select jtag -adapter_khz 10000 - -ftdi_layout_init 0x00f8 0x00fb -#ftdi_layout_signal nTRST -data 0x0400 -#ftdi_layout_signal nSRST -ndata 0x0020 - -#reset_config srst_only srst_push_pull -#adapter_nsrst_delay 100 -#adapter_nsrst_assert_width 100 +# BouffaloLab USB-JTAG/TTL adapter +interface ftdi +ftdi_vid_pid 0x0403 0x6010 + +ftdi_channel 1 +ftdi_tdo_sample_edge falling +transport select jtag +adapter_khz 10000 + +ftdi_layout_init 0x00f8 0x00fb +#ftdi_layout_signal nTRST -data 0x0400 +#ftdi_layout_signal nSRST -ndata 0x0020 + +#reset_config srst_only srst_push_pull +#adapter_nsrst_delay 100 +#adapter_nsrst_assert_width 100 diff --git a/tools/openocd/if_bflb_link.cfg b/tools/openocd/if_bflb_link.cfg index 5de10689..865ac1f1 100644 --- a/tools/openocd/if_bflb_link.cfg +++ b/tools/openocd/if_bflb_link.cfg @@ -1,16 +1,16 @@ -# BouffaloLab USB-JTAG/TTL adapter -interface ftdi -ftdi_vid_pid 0x0403 0x6010 - -ftdi_channel 1 -ftdi_tdo_sample_edge falling -transport select jtag -adapter_khz 30000 - -ftdi_layout_init 0x00f8 0x00fb -#ftdi_layout_signal nTRST -data 0x0400 -#ftdi_layout_signal nSRST -ndata 0x0020 - -#reset_config srst_only srst_push_pull -#adapter_nsrst_delay 100 -#adapter_nsrst_assert_width 100 +# BouffaloLab USB-JTAG/TTL adapter +interface ftdi +ftdi_vid_pid 0x0403 0x6010 + +ftdi_channel 1 +ftdi_tdo_sample_edge falling +transport select jtag +adapter_khz 30000 + +ftdi_layout_init 0x00f8 0x00fb +#ftdi_layout_signal nTRST -data 0x0400 +#ftdi_layout_signal nSRST -ndata 0x0020 + +#reset_config srst_only srst_push_pull +#adapter_nsrst_delay 100 +#adapter_nsrst_assert_width 100 diff --git a/tools/openocd/if_ft2232d.cfg b/tools/openocd/if_ft2232d.cfg index 1146ec73..32e414d7 100644 --- a/tools/openocd/if_ft2232d.cfg +++ b/tools/openocd/if_ft2232d.cfg @@ -1,15 +1,15 @@ -# USB-JTAG/TTL based on FT2232D -interface ftdi -ftdi_vid_pid 0x0403 0x6010 - -ftdi_channel 0 -transport select jtag -adapter_khz 2000 - -ftdi_layout_init 0x0508 0x0f2b -#ftdi_layout_signal nTRST -data 0x0400 -ftdi_layout_signal nSRST -ndata 0x0020 - -reset_config srst_only srst_push_pull -adapter_nsrst_delay 100 -adapter_nsrst_assert_width 100 +# USB-JTAG/TTL based on FT2232D +interface ftdi +ftdi_vid_pid 0x0403 0x6010 + +ftdi_channel 0 +transport select jtag +adapter_khz 2000 + +ftdi_layout_init 0x0508 0x0f2b +#ftdi_layout_signal nTRST -data 0x0400 +ftdi_layout_signal nSRST -ndata 0x0020 + +reset_config srst_only srst_push_pull +adapter_nsrst_delay 100 +adapter_nsrst_assert_width 100 diff --git a/tools/openocd/if_jlink.cfg b/tools/openocd/if_jlink.cfg index 34e8d2c8..27e704e8 100644 --- a/tools/openocd/if_jlink.cfg +++ b/tools/openocd/if_jlink.cfg @@ -1,7 +1,7 @@ -# USB-JTAG/TTL based on FT2232D -interface jlink - -transport select jtag -adapter_khz 12000 - - +# USB-JTAG/TTL based on FT2232D +interface jlink + +transport select jtag +adapter_khz 12000 + + diff --git a/tools/openocd/openocd-usb-sipeed-xip.cfg b/tools/openocd/openocd-usb-sipeed-xip.cfg index 1deb31d2..0f713437 100644 --- a/tools/openocd/openocd-usb-sipeed-xip.cfg +++ b/tools/openocd/openocd-usb-sipeed-xip.cfg @@ -1,40 +1,40 @@ -# SiPEED USB-JTAG/TTL based on FT2232D -interface ftdi -ftdi_vid_pid 0x0403 0x6010 -# http://blog.sipeed.com/p/727.html -ftdi_channel 0 -transport select jtag -adapter_khz 10000 - -ftdi_layout_init 0x0508 0x0f1b -ftdi_layout_signal nTRST -data 0x0200 -noe 0x0100 -ftdi_layout_signal nSRST -data 0x0800 -noe 0x0400 - -set _CHIPNAME riscv -#jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000001 -jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x0 - -set _TARGETNAME $_CHIPNAME.cpu -target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME -#$_TARGETNAME.0 configure -work-area-phys 0x80000000 -work-area-size 10000 -work-area-backup 1 -#$_TARGETNAME.0 configure -work-area-phys 0x50000000 -work-area-size 32768 -work-area-backup 0 - -echo "SiPEED USB-JTAG/TTL Ready for Remote Connections" - -proc install_bootrom {} { -# sleep 1000 - init - reset init - load_image chiptest_bootrom.bin 0x21000000 bin - sleep 500 - reg pc 0x21000000 -# sleep 500 -# bp 0x21002f0c 4 hw -# resume -} - -echo "Start loading BOOTROM under project folder" -install_bootrom -echo "flash the XIP code before debugging" -echo "ONLY load symbol in GDB" -echo "use [gdb_breakpoint_override hard] for XIP debugging" +# SiPEED USB-JTAG/TTL based on FT2232D +interface ftdi +ftdi_vid_pid 0x0403 0x6010 +# http://blog.sipeed.com/p/727.html +ftdi_channel 0 +transport select jtag +adapter_khz 10000 + +ftdi_layout_init 0x0508 0x0f1b +ftdi_layout_signal nTRST -data 0x0200 -noe 0x0100 +ftdi_layout_signal nSRST -data 0x0800 -noe 0x0400 + +set _CHIPNAME riscv +#jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000001 +jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x0 + +set _TARGETNAME $_CHIPNAME.cpu +target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME +#$_TARGETNAME.0 configure -work-area-phys 0x80000000 -work-area-size 10000 -work-area-backup 1 +#$_TARGETNAME.0 configure -work-area-phys 0x50000000 -work-area-size 32768 -work-area-backup 0 + +echo "SiPEED USB-JTAG/TTL Ready for Remote Connections" + +proc install_bootrom {} { +# sleep 1000 + init + reset init + load_image chiptest_bootrom.bin 0x21000000 bin + sleep 500 + reg pc 0x21000000 +# sleep 500 +# bp 0x21002f0c 4 hw +# resume +} + +echo "Start loading BOOTROM under project folder" +install_bootrom +echo "flash the XIP code before debugging" +echo "ONLY load symbol in GDB" +echo "use [gdb_breakpoint_override hard] for XIP debugging" diff --git a/tools/openocd/openocd-usb-sipeed.cfg b/tools/openocd/openocd-usb-sipeed.cfg index b2460328..8a819e5e 100644 --- a/tools/openocd/openocd-usb-sipeed.cfg +++ b/tools/openocd/openocd-usb-sipeed.cfg @@ -1,24 +1,24 @@ -# SiPEED USB-JTAG/TTL based on FT2232D -interface ftdi -ftdi_vid_pid 0x0403 0x6010 -# http://blog.sipeed.com/p/727.html -ftdi_channel 0 -transport select jtag -adapter_khz 1000 - -ftdi_layout_init 0x0508 0x0f1b -ftdi_layout_signal nTRST -data 0x0200 -noe 0x0100 -ftdi_layout_signal nSRST -data 0x0800 -noe 0x0400 - -set _CHIPNAME riscv -#jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000001 -jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x0 - -set _TARGETNAME $_CHIPNAME.cpu -target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME -#$_TARGETNAME.0 configure -work-area-phys 0x80000000 -work-area-size 10000 -work-area-backup 1 -#$_TARGETNAME.0 configure -work-area-phys 0x50000000 -work-area-size 32768 -work-area-backup 0 - -riscv set_prefer_sba on - -echo "SiPEED USB-JTAG/TTL Ready for Remote Connections" +# SiPEED USB-JTAG/TTL based on FT2232D +interface ftdi +ftdi_vid_pid 0x0403 0x6010 +# http://blog.sipeed.com/p/727.html +ftdi_channel 0 +transport select jtag +adapter_khz 1000 + +ftdi_layout_init 0x0508 0x0f1b +ftdi_layout_signal nTRST -data 0x0200 -noe 0x0100 +ftdi_layout_signal nSRST -data 0x0800 -noe 0x0400 + +set _CHIPNAME riscv +#jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000001 +jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x0 + +set _TARGETNAME $_CHIPNAME.cpu +target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME +#$_TARGETNAME.0 configure -work-area-phys 0x80000000 -work-area-size 10000 -work-area-backup 1 +#$_TARGETNAME.0 configure -work-area-phys 0x50000000 -work-area-size 32768 -work-area-backup 0 + +riscv set_prefer_sba on + +echo "SiPEED USB-JTAG/TTL Ready for Remote Connections" diff --git a/tools/openocd/tgt_602.cfg b/tools/openocd/tgt_602.cfg index 53c813ba..c30c1a17 100644 --- a/tools/openocd/tgt_602.cfg +++ b/tools/openocd/tgt_602.cfg @@ -1,45 +1,45 @@ -#target chip - -set _CHIPNAME riscv -jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000c05 - -set _TARGETNAME $_CHIPNAME.cpu -target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME -$_TARGETNAME.0 configure -work-area-phys 0x22020000 -work-area-size 0x10000 -work-area-backup 1 -#$_TARGETNAME.0 configure -rtos auto - -echo "Ready for Remote Connections" - -$_TARGETNAME.0 configure -event reset-assert-pre { - echo "reset-assert-pre" - adapter_khz 100 -} - -$_TARGETNAME.0 configure -event reset-deassert-post { - echo "reset-deassert-post" - adapter_khz 4000 - reg mstatus 0x7800 - reg mie 0x0 -# reg pc 0x22008000 -} - -$_TARGETNAME.0 configure -event reset-init { - echo "reset-init" -# 4MHz for FPGA - adapter_khz 4000 -} - -gdb_memory_map enable -gdb_flash_program disable - -riscv set_prefer_sba on -riscv set_command_timeout_sec 1 - -init -reset init - -#jtag arp_init - -#resume -#exit - +#target chip + +set _CHIPNAME riscv +jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000c05 + +set _TARGETNAME $_CHIPNAME.cpu +target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME +$_TARGETNAME.0 configure -work-area-phys 0x22020000 -work-area-size 0x10000 -work-area-backup 1 +#$_TARGETNAME.0 configure -rtos auto + +echo "Ready for Remote Connections" + +$_TARGETNAME.0 configure -event reset-assert-pre { + echo "reset-assert-pre" + adapter_khz 100 +} + +$_TARGETNAME.0 configure -event reset-deassert-post { + echo "reset-deassert-post" + adapter_khz 4000 + reg mstatus 0x7800 + reg mie 0x0 +# reg pc 0x22008000 +} + +$_TARGETNAME.0 configure -event reset-init { + echo "reset-init" +# 4MHz for FPGA + adapter_khz 4000 +} + +gdb_memory_map enable +gdb_flash_program disable + +riscv set_prefer_sba on +riscv set_command_timeout_sec 1 + +init +reset init + +#jtag arp_init + +#resume +#exit + diff --git a/tools/openocd/tgt_702.cfg b/tools/openocd/tgt_702.cfg index a3b46560..b1771666 100644 --- a/tools/openocd/tgt_702.cfg +++ b/tools/openocd/tgt_702.cfg @@ -1,45 +1,45 @@ -#target chip - -set _CHIPNAME riscv -jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000e05 - -set _TARGETNAME $_CHIPNAME.cpu -target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME -$_TARGETNAME.0 configure -work-area-phys 0x22020000 -work-area-size 0x10000 -work-area-backup 1 -#$_TARGETNAME.0 configure -rtos auto - -echo "Ready for Remote Connections" - -$_TARGETNAME.0 configure -event reset-assert-pre { - echo "reset-assert-pre" - adapter_khz 100 -} - -$_TARGETNAME.0 configure -event reset-deassert-post { - echo "reset-deassert-post" - adapter_khz 4000 - reg mstatus 0x7800 - reg mie 0x0 -# reg pc 0x22008000 -} - -$_TARGETNAME.0 configure -event reset-init { - echo "reset-init" -# 4MHz for FPGA - adapter_khz 4000 -} - -gdb_memory_map enable -gdb_flash_program disable - -riscv set_prefer_sba on -riscv set_command_timeout_sec 1 - -init -reset init - -#jtag arp_init - -#resume -#exit - +#target chip + +set _CHIPNAME riscv +jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000e05 + +set _TARGETNAME $_CHIPNAME.cpu +target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME +$_TARGETNAME.0 configure -work-area-phys 0x22020000 -work-area-size 0x10000 -work-area-backup 1 +#$_TARGETNAME.0 configure -rtos auto + +echo "Ready for Remote Connections" + +$_TARGETNAME.0 configure -event reset-assert-pre { + echo "reset-assert-pre" + adapter_khz 100 +} + +$_TARGETNAME.0 configure -event reset-deassert-post { + echo "reset-deassert-post" + adapter_khz 4000 + reg mstatus 0x7800 + reg mie 0x0 +# reg pc 0x22008000 +} + +$_TARGETNAME.0 configure -event reset-init { + echo "reset-init" +# 4MHz for FPGA + adapter_khz 4000 +} + +gdb_memory_map enable +gdb_flash_program disable + +riscv set_prefer_sba on +riscv set_command_timeout_sec 1 + +init +reset init + +#jtag arp_init + +#resume +#exit +