diff --git a/.cproject b/.cproject index 12c85d88..7d96c806 100644 --- a/.cproject +++ b/.cproject @@ -153,7 +153,7 @@ make - BOARD=bl706_iot + build BOARD=bl706_iot APP=helloworld true false @@ -161,6 +161,7 @@ make + clean true false diff --git a/.gitignore b/.gitignore index 7628a207..99d0c133 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ out/* build/* .vscode/settings.json .settings +*.pyc **/.cdk **/Lst @@ -9,7 +10,6 @@ build/* examples/**/*.mk examples/**/*.cdkws -!examples/bl_mcu_sdk.cdkws examples/**/*.mk examples/**/*.bat examples/**/cdk/*.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index cd0dadc0..4bf5ae17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,12 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.15) set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/tools/cmake/riscv64-unknown-elf-gcc.cmake) include(${CMAKE_SOURCE_DIR}/tools/cmake/compiler_flags.cmake) include(${CMAKE_SOURCE_DIR}/tools/cmake/tools.cmake) PROJECT(${BOARD} C CXX ASM) +# set(CMAKE_VERBOSE_MAKEFILE ON) + include_directories(${CMAKE_SOURCE_DIR}/common/misc) include_directories(${CMAKE_SOURCE_DIR}/bsp/bsp_common/platform) @@ -14,14 +16,24 @@ else() message(FATAL_ERROR "${CMAKE_SOURCE_DIR}/bsp/board/${BOARD} is not exist") endif() +if(${SUPPORT_FLOAT} STREQUAL "y") +add_definitions(-DBFLB_PRINT_FLOAT_SUPPORT) +else() +endif() + +if(${SUPPORT_SHELL} STREQUAL "y") +add_definitions(-DSHELL_SUPPORT) +else() +endif() + add_subdirectory(common) add_subdirectory(components/fatfs) add_subdirectory(components/usb_stack) -if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/drivers/${mcu}_driver) -add_subdirectory(drivers/${mcu}_driver) +if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/drivers/${CHIP}_driver) +add_subdirectory(drivers/${CHIP}_driver) else() -message(FATAL_ERROR "${CMAKE_SOURCE_DIR}/drivers/${mcu}_driver is not exist") +message(FATAL_ERROR "${CMAKE_SOURCE_DIR}/drivers/${CHIP}_driver is not exist") endif() if(${SUPPORT_SHELL} STREQUAL "y") @@ -36,5 +48,16 @@ if(${SUPPORT_LVGL} STREQUAL "y") add_subdirectory(components/lvgl) endif() -search_application(${CMAKE_SOURCE_DIR}/examples) +if(${SUPPORT_XZ} STREQUAL "y") +add_subdirectory(components/xz) +endif() + +if(${SUPPORT_BLE} STREQUAL "y") +if(${SUPPORT_FREERTOS} STREQUAL "n") +message(FATAL_ERROR "ble need freertos,so you should set SUPPORT_FREERTOS=y") +endif() +add_subdirectory(components/ble) +endif() + +search_application(${CMAKE_SOURCE_DIR}/${APP_DIR}) diff --git a/Makefile b/Makefile index 9acb2d18..d3ed94de 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,30 @@ BOARD?=bl706_iot -APP?=helloworld CHIP?=bl702 -INTERFACE?=jlink -BAUDRATE ?=12000 +APP_DIR?=examples +APP?=helloworld +CPU_ID?=m0 SUPPORT_SHELL?=n SUPPORT_FREERTOS?=n SUPPORT_LVGL?=n SUPPORT_FLOAT?=n +SUPPORT_BLE?=n +SUPPORT_XZ?=n + +INTERFACE?=jlink +BAUDRATE ?=12000 export BOARD +export CHIP +export APP_DIR export APP +export CPU_ID export SUPPORT_SHELL export SUPPORT_FREERTOS export SUPPORT_LVGL export SUPPORT_FLOAT +export SUPPORT_BLE +export SUPPORT_XZ # The command to remove a file. RM = cmake -E rm -rf diff --git a/bl_mcu_flash.launch b/bl_mcu_flash.launch index 11865fe3..40b67e0f 100644 --- a/bl_mcu_flash.launch +++ b/bl_mcu_flash.launch @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + @@ -46,7 +46,7 @@ - + @@ -59,4 +59,5 @@ + diff --git a/bl_mcu_ram.launch b/bl_mcu_ram.launch new file mode 100644 index 00000000..4c3d4ed2 --- /dev/null +++ b/bl_mcu_ram.launch @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/project.build b/project.build index dee46e7b..83fa69fa 100644 --- a/project.build +++ b/project.build @@ -1,4 +1,17 @@ -PHONY := __build +cmake_definition+= -DCHIP=$(CHIP) +cmake_definition+= -DCPU_ID=$(CPU_ID) +cmake_definition+= -DBOARD=$(BOARD) +cmake_definition+= -DSUPPORT_FLOAT=$(SUPPORT_FLOAT) +cmake_definition+= -DSUPPORT_SHELL=$(SUPPORT_SHELL) +cmake_definition+= -DSUPPORT_FREERTOS=$(SUPPORT_FREERTOS) +cmake_definition+= -DSUPPORT_LVGL=$(SUPPORT_LVGL) +cmake_definition+= -DSUPPORT_BLE=$(SUPPORT_BLE) +cmake_definition+= -DSUPPORT_XZ=$(SUPPORT_XZ) +cmake_definition+= -DAPP_DIR=$(APP_DIR) +cmake_definition+= -DAPP=$(APP) + __build: - cmake -DBOARD=$(BOARD) -DSUPPORT_SHELL=$(SUPPORT_SHELL) -DSUPPORT_FREERTOS=$(SUPPORT_FREERTOS) -DSUPPORT_LVGL=$(SUPPORT_LVGL) -DSUPPORT_FLOAT=$(SUPPORT_FLOAT) -DAPP=$(APP) .. - make -j + cmake $(cmake_definition) .. + make -j4 + +.PHONY:__build \ No newline at end of file diff --git a/tools/bflb_flash_tool/bflb_iot_tool b/tools/bflb_flash_tool/bflb_iot_tool index 237d1bc1..5853dbd0 100644 Binary files a/tools/bflb_flash_tool/bflb_iot_tool and b/tools/bflb_flash_tool/bflb_iot_tool differ diff --git a/tools/bflb_flash_tool/bflb_iot_tool.exe b/tools/bflb_flash_tool/bflb_iot_tool.exe index 1096a21b..fd40c9f8 100644 Binary files a/tools/bflb_flash_tool/bflb_iot_tool.exe and b/tools/bflb_flash_tool/bflb_iot_tool.exe differ diff --git a/tools/bflb_flash_tool/bflb_iot_tool命令行工具说明.txt b/tools/bflb_flash_tool/bflb_iot_tool命令行工具说明.txt new file mode 100644 index 00000000..b327341e --- /dev/null +++ b/tools/bflb_flash_tool/bflb_iot_tool命令行工具说明.txt @@ -0,0 +1,21 @@ +build +bflb_iot_tool.exe --chipname=bl602 --xtal=40M --firmware="D:\\bouffalolab\\tool\\bflb-flash-tool\\img\\project.bin" --build + +build + download +bflb_iot_tool.exe --chipname=bl602 --port=COM9 --xtal=40M --firmware="D:\\bouffalolab\\tool\\bflb-flash-tool\\img\\project.bin" + + +--chipname:必填 +--interface:默认uart +--port:com口,默认自动查找 +--baudrate:波特率默认115200 +--xtal:xtal +--dts:device tree文件 +--firmware:默认img目录下的project.bin +--build:只生成镜像 +--erase:擦除flash +--single:单文件烧写 +--addr:烧写地址默认0 +--config:eflash_loader_cfg.ini + + diff --git a/tools/bflb_flash_tool/bflb_mcu_tool b/tools/bflb_flash_tool/bflb_mcu_tool index e7d06004..9949a02f 100644 Binary files a/tools/bflb_flash_tool/bflb_mcu_tool and b/tools/bflb_flash_tool/bflb_mcu_tool differ diff --git a/tools/bflb_flash_tool/bflb_mcu_tool.exe b/tools/bflb_flash_tool/bflb_mcu_tool.exe index 141e87f4..cff04777 100644 Binary files a/tools/bflb_flash_tool/bflb_mcu_tool.exe and b/tools/bflb_flash_tool/bflb_mcu_tool.exe differ diff --git a/tools/bflb_flash_tool/bflb_mcu_tool命令行工具说明.txt b/tools/bflb_flash_tool/bflb_mcu_tool命令行工具说明.txt new file mode 100644 index 00000000..7c356ac4 --- /dev/null +++ b/tools/bflb_flash_tool/bflb_mcu_tool命令行工具说明.txt @@ -0,0 +1,23 @@ +build +bflb_mcu_tool.exe --chipname=bl602 --xtal=40M --flashclk=48M --firmware="D:\\bouffalolab\\tool\\bflb-flash-tool\\img\\project.bin" --build + +build + download +bflb_mcu_tool.exe --chipname=bl602 --port=COM9 --xtal=40M --flashclk=48M --firmware="D:\\bouffalolab\\tool\\bflb-flash-tool\\img\\project.bin" + + +--chipname:必填 +--interface:默认uart +--bootsrc:默认flash +--port:com口,默认自动查找 +--baudrate:波特率默认115200 +--xtal:xtal +--flashclk:flash clock +--pllclk:pll clock +--firmware:默认img目录下的project.bin +--addr:烧写地址默认2000 +--build:只生成镜像 +--erase:擦除flash + + + + diff --git a/tools/bflb_flash_tool/chips/bl602/builtin_imgs/mfg/bl602_bl604_mfg_gu_932b317e_26m_autoboot_rfpa.bin b/tools/bflb_flash_tool/chips/bl602/builtin_imgs/mfg/bl602_bl604_mfg_gu_932b317e_26m_autoboot_rfpa.bin new file mode 100644 index 00000000..d43c454f Binary files /dev/null and b/tools/bflb_flash_tool/chips/bl602/builtin_imgs/mfg/bl602_bl604_mfg_gu_932b317e_26m_autoboot_rfpa.bin differ diff --git a/tools/bflb_flash_tool/chips/bl602/builtin_imgs/mfg/bl602_bl604_mfg_gu_932b317e_32m_rfpa.bin b/tools/bflb_flash_tool/chips/bl602/builtin_imgs/mfg/bl602_bl604_mfg_gu_932b317e_32m_rfpa.bin new file mode 100644 index 00000000..48f1ecc7 Binary files /dev/null and b/tools/bflb_flash_tool/chips/bl602/builtin_imgs/mfg/bl602_bl604_mfg_gu_932b317e_32m_rfpa.bin differ diff --git a/tools/bflb_flash_tool/chips/bl702/device_tree/bl_factory_params_IoTKitA_32M.dts b/tools/bflb_flash_tool/chips/bl702/device_tree/bl_factory_params_IoTKitA_32M.dts index 71b9fc43..a0ffe806 100644 --- a/tools/bflb_flash_tool/chips/bl702/device_tree/bl_factory_params_IoTKitA_32M.dts +++ b/tools/bflb_flash_tool/chips/bl702/device_tree/bl_factory_params_IoTKitA_32M.dts @@ -79,5 +79,8 @@ xtal = <36 36 0 60 60>; pwr = <14>; }; + rf_temp { + en_tcal = <0>; + }; }; }; diff --git a/tools/bflb_flash_tool/chips/bl702/device_tree/bl_factory_params_IoTKitA_None.dts b/tools/bflb_flash_tool/chips/bl702/device_tree/bl_factory_params_IoTKitA_None.dts index 71b9fc43..a0ffe806 100644 --- a/tools/bflb_flash_tool/chips/bl702/device_tree/bl_factory_params_IoTKitA_None.dts +++ b/tools/bflb_flash_tool/chips/bl702/device_tree/bl_factory_params_IoTKitA_None.dts @@ -79,5 +79,8 @@ xtal = <36 36 0 60 60>; pwr = <14>; }; + rf_temp { + en_tcal = <0>; + }; }; }; diff --git a/tools/bflb_flash_tool/chips/bl702/device_tree/bl_factory_params_IoTKitA_RC32M.dts b/tools/bflb_flash_tool/chips/bl702/device_tree/bl_factory_params_IoTKitA_RC32M.dts index 71b9fc43..a0ffe806 100644 --- a/tools/bflb_flash_tool/chips/bl702/device_tree/bl_factory_params_IoTKitA_RC32M.dts +++ b/tools/bflb_flash_tool/chips/bl702/device_tree/bl_factory_params_IoTKitA_RC32M.dts @@ -79,5 +79,8 @@ xtal = <36 36 0 60 60>; pwr = <14>; }; + rf_temp { + en_tcal = <0>; + }; }; }; diff --git a/tools/bflb_flash_tool/chips/bl702/efuse_bootheader/flash_para.bin b/tools/bflb_flash_tool/chips/bl702/efuse_bootheader/flash_para.bin new file mode 100644 index 00000000..2efb7eda Binary files /dev/null and b/tools/bflb_flash_tool/chips/bl702/efuse_bootheader/flash_para.bin differ diff --git a/tools/bflb_flash_tool/chips/bl702/img_create_mcu/bootheader.bin b/tools/bflb_flash_tool/chips/bl702/img_create_mcu/bootheader.bin new file mode 100644 index 00000000..2326fa10 Binary files /dev/null and b/tools/bflb_flash_tool/chips/bl702/img_create_mcu/bootheader.bin differ diff --git a/tools/bflb_flash_tool/chips/bl702/img_create_mcu/bootheader_cfg.ini b/tools/bflb_flash_tool/chips/bl702/img_create_mcu/bootheader_cfg.ini new file mode 100644 index 00000000..d5ec9246 --- /dev/null +++ b/tools/bflb_flash_tool/chips/bl702/img_create_mcu/bootheader_cfg.ini @@ -0,0 +1,196 @@ +[EFUSE_CFG] +######################################################################## +#2bits +ef_sf_aes_mode = 0 +#2bits +ef_sboot_sign_mode = 0 +#2bits +ef_sboot_en = 0 +#2bits +ef_dbg_jtag_dis = 0 +#4bits +ef_dbg_mode = 0 +#32bits +ef_dbg_pwd_low = 0 +#32bits +ef_dbg_pwd_high = 0 +################################################################### +ef_key_slot_2_w0 = 0 +ef_key_slot_2_w1 = 0 +ef_key_slot_2_w2 = 0 +ef_key_slot_2_w3 = 0 +ef_key_slot_3_w0 = 0 +ef_key_slot_3_w1 = 0 +ef_key_slot_3_w2 = 0 +ef_key_slot_3_w3 = 0 +ef_key_slot_4_w0 = 0 +ef_key_slot_4_w1 = 0 +ef_key_slot_4_w2 = 0 +ef_key_slot_4_w3 = 0 + +wr_lock_key_slot_4_l = 0 +wr_lock_dbg_pwd = 0 +wr_lock_key_slot_2 = 0 +wr_lock_key_slot_3 = 0 +wr_lock_key_slot_4_h = 0 +rd_lock_dbg_pwd = 0 +rd_lock_key_slot_2 = 0 +rd_lock_key_slot_3 = 0 +rd_lock_key_slot_4 = 0 + +[BOOTHEADER_CFG] +magic_code = 0x504e4642 +revision = 0x01 +#########################flash cfg############################# +flashcfg_magic_code = 0x47464346 +#flashcfg_magic_code=0 +io_mode = 4 +cont_read_support = 1 +sfctrl_clk_delay = 1 +sfctrl_clk_invert = 0x01 + +reset_en_cmd = 0x66 +reset_cmd = 0x99 +exit_contread_cmd = 0xff +exit_contread_cmd_size = 3 + +jedecid_cmd = 0x9f +jedecid_cmd_dmy_clk = 0 +qpi_jedecid_cmd = 0x9f +qpi_jedecid_dmy_clk = 0 + +sector_size = 4 +mfg_id = 0xef +page_size = 256 + +chip_erase_cmd = 0xc7 +sector_erase_cmd = 0x20 +blk32k_erase_cmd = 0x52 +blk64k_erase_cmd = 0xd8 + +write_enable_cmd = 0x06 +page_prog_cmd = 0x02 +qpage_prog_cmd = 0x32 +qual_page_prog_addr_mode = 0 + +fast_read_cmd = 0x0b +fast_read_dmy_clk = 1 +qpi_fast_read_cmd = 0x0b +qpi_fast_read_dmy_clk = 1 + +fast_read_do_cmd = 0x3b +fast_read_do_dmy_clk = 1 +fast_read_dio_cmd = 0xbb +fast_read_dio_dmy_clk = 0 + +fast_read_qo_cmd = 0x6b +fast_read_qo_dmy_clk = 1 +fast_read_qio_cmd = 0xeb +fast_read_qio_dmy_clk = 2 + +qpi_fast_read_qio_cmd = 0xeb +qpi_fast_read_qio_dmy_clk = 2 +qpi_page_prog_cmd = 0x02 +write_vreg_enable_cmd = 0x50 + +wel_reg_index = 0 +qe_reg_index = 1 +busy_reg_index = 0 +wel_bit_pos = 1 + +qe_bit_pos = 1 +busy_bit_pos = 0 +wel_reg_write_len = 2 +wel_reg_read_len = 1 + +qe_reg_write_len = 1 +qe_reg_read_len = 1 +release_power_down = 0xab +busy_reg_read_len = 1 + +reg_read_cmd0 = 0x05 +reg_read_cmd1 = 0x35 + +reg_write_cmd0 = 0x01 +reg_write_cmd1 = 0x31 + +enter_qpi_cmd = 0x38 +exit_qpi_cmd = 0xff +cont_read_code = 0x20 +cont_read_exit_code = 0xff + +burst_wrap_cmd = 0x77 +burst_wrap_dmy_clk = 0x03 +burst_wrap_data_mode = 2 +burst_wrap_code = 0x40 + +de_burst_wrap_cmd = 0x77 +de_burst_wrap_cmd_dmy_clk = 0x03 +de_burst_wrap_code_mode = 2 +de_burst_wrap_code = 0xF0 + +sector_erase_time = 300 +blk32k_erase_time = 1200 + +blk64k_erase_time = 1200 +page_prog_time = 5 + +chip_erase_time = 65535 +power_down_delay = 3 +qe_data = 0 + +flashcfg_crc32 = 0 + +#########################clk cfg#################################### +clkcfg_magic_code = 0x47464350 +#clkcfg_magic_code=0 + +#0:Not use XTAL to set PLL, 1:XTAL is 32M, 2:XTAL is RC32M +xtal_type = 1 +#0:RC32M, 1:XTAL, 2:PLL 57.6M, 3:PLL 96M, 4:PLL 144M +pll_clk = 4 +hclk_div = 0 +bclk_div = 1 +#0:144M, 1:XCLK(RC32M or XTAL), 2:57.6M, 3:72M, 4:BCLK, 5:96M +flash_clk_type = 3 +flash_clk_div = 0 +clkcfg_crc32 = 0 + +########################boot cfg#################################### +#1:ECC +sign = 0 +#1:AES128,2:AES256,3:AES192 +encrypt_type = 0 +key_sel = 0 +no_segment = 1 +cache_enable = 1 +notload_in_bootrom = 0 +aes_region_lock = 0 +cache_way_disable = 0 +crc_ignore = 0 +hash_ignore = 0 +boot2_enable = 0 +boot2_rollback = 0 + +########################image cfg#################################### +#total image len or segment count +img_len = 0x100 +bootentry = 0 +#img RAM address or flash offset +img_start = 0x2000 + +#img hash +hash_0 = 0xdeadbeef +hash_1 = 0 +hash_2 = 0 +hash_3 = 0 +hash_4 = 0 +hash_5 = 0 +hash_6 = 0 +hash_7 = 0 + +#address of partition tables for boot2 in bootrom +boot2_pt_table_0 = 0x1000 +boot2_pt_table_1 = 0x2000 + +crc32 = 0xdeadbeef diff --git a/tools/bflb_flash_tool/chips/bl702/img_create_mcu/efusedata.bin b/tools/bflb_flash_tool/chips/bl702/img_create_mcu/efusedata.bin new file mode 100644 index 00000000..65f57c2e Binary files /dev/null and b/tools/bflb_flash_tool/chips/bl702/img_create_mcu/efusedata.bin differ diff --git a/tools/bflb_flash_tool/chips/bl702/img_create_mcu/efusedata_mask.bin b/tools/bflb_flash_tool/chips/bl702/img_create_mcu/efusedata_mask.bin new file mode 100644 index 00000000..551efc7e Binary files /dev/null and b/tools/bflb_flash_tool/chips/bl702/img_create_mcu/efusedata_mask.bin differ diff --git a/tools/bflb_flash_tool/chips/bl702/img_create_mcu/img_create_cfg.ini b/tools/bflb_flash_tool/chips/bl702/img_create_mcu/img_create_cfg.ini new file mode 100644 index 00000000..0eaa2c23 --- /dev/null +++ b/tools/bflb_flash_tool/chips/bl702/img_create_mcu/img_create_cfg.ini @@ -0,0 +1,15 @@ +[Img_Cfg] +boot_header_file = d:\BouffaloLabWS\bl_mcu_sdk\tools\bflb_flash_tool\chips\bl702\img_create_mcu/bootheader.bin +efuse_file = d:\BouffaloLabWS\bl_mcu_sdk\tools\bflb_flash_tool\chips\bl702\img_create_mcu/efusedata.bin +efuse_mask_file = d:\BouffaloLabWS\bl_mcu_sdk\tools\bflb_flash_tool\chips\bl702\img_create_mcu/efusedata_mask.bin +encrypt_key_org = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F +aesiv_file = img_create/aesiv_cpu0.bin +publickey_file = "" +privatekey_file_uecc = "" +segheader_file = d:\BouffaloLabWS\bl_mcu_sdk\tools\bflb_flash_tool\chips\bl702\img_create_mcu/segheader_tmp.bin +segdata_file = D:/BouffaloLabWS/bl_mcu_sdk/examples/timer/timer_basic/cdk/Obj/timer_basic.bin +bootinfo_file = d:\BouffaloLabWS\bl_mcu_sdk\tools\bflb_flash_tool\chips\bl702\img_create_mcu/bootinfo.bin +img_file = d:\BouffaloLabWS\bl_mcu_sdk\tools\bflb_flash_tool\chips\bl702\img_create_mcu/img.bin +whole_img_file = d:\BouffaloLabWS\bl_mcu_sdk\tools\bflb_flash_tool\chips\bl702\img_create_mcu/img_if.bin +aes_key_org = "" +aes_iv = "" diff --git a/tools/bflb_flash_tool/clear.bat b/tools/bflb_flash_tool/clear.bat index ca94585c..43a09c61 100644 --- a/tools/bflb_flash_tool/clear.bat +++ b/tools/bflb_flash_tool/clear.bat @@ -11,20 +11,28 @@ del /a /f /s /q .\chips\bl702\img_create_iot\*.bin del /a /f /s /q .\chips\bl56x\img_create_iot\*.bin del /a /f /s /q .\chips\bl60x\img_create_iot\*.bin del /a /f /s /q .\chips\bl606p\img_create_iot\*.bin +del /a /f /s /q .\chips\bl602u\img_create_iot\*.bin +del /a /f /s /q .\chips\bl808\img_create_iot\*.bin del /a /f /s /q .\chips\bl602\img_create_mcu\*.bin del /a /f /s /q .\chips\bl702\img_create_mcu\*.bin del /a /f /s /q .\chips\bl56x\img_create_mcu\*.bin del /a /f /s /q .\chips\bl60x\img_create_mcu\*.bin del /a /f /s /q .\chips\bl606p\img_create_mcu\*.bin +del /a /f /s /q .\chips\bl602u\img_create_mcu\*.bin +del /a /f /s /q .\chips\bl808\img_create_mcu\*.bin del /a /f /s /q .\chips\bl602\efuse_bootheader\*.bin del /a /f /s /q .\chips\bl702\efuse_bootheader\*.bin del /a /f /s /q .\chips\bl56x\efuse_bootheader\*.bin del /a /f /s /q .\chips\bl60x\efuse_bootheader\*.bin del /a /f /s /q .\chips\bl606p\efuse_bootheader\*.bin +del /a /f /s /q .\chips\bl602u\efuse_bootheader\*.bin +del /a /f /s /q .\chips\bl808\efuse_bootheader\*.bin del /a /f /s /q .\chips\*.pack rd /s /Q .\chips\bl602\ota rd /s /Q .\chips\bl702\ota rd /s /Q .\chips\bl56x\ota rd /s /Q .\chips\bl60x\ota rd /s /Q .\chips\bl606p\ota +rd /s /Q .\chips\bl602u\ota +rd /s /Q .\chips\bl808\ota pause \ No newline at end of file diff --git a/tools/bflb_flash_tool/img/bl602_bl604_mfg_gu_2966aff8b_40m_autoboot.bin b/tools/bflb_flash_tool/img/bl602_bl604_mfg_gu_2966aff8b_40m_autoboot.bin new file mode 100644 index 00000000..02e65021 Binary files /dev/null and b/tools/bflb_flash_tool/img/bl602_bl604_mfg_gu_2966aff8b_40m_autoboot.bin differ diff --git a/tools/bflb_flash_tool/utils/flash-conf/bl602/TH25Q16HB_eb6015.conf b/tools/bflb_flash_tool/utils/flash-conf/bl602/TH25Q16HB_eb6015.conf new file mode 100644 index 00000000..7cec4a50 --- /dev/null +++ b/tools/bflb_flash_tool/utils/flash-conf/bl602/TH25Q16HB_eb6015.conf @@ -0,0 +1,73 @@ +[FLASH_CFG] +exit_contread_cmd = 0xff +exit_contread_cmd_size = 3 +mfg_id = 0xeb +io_mode = 4 +de_burst_wrap_cmd = 0x77 +de_burst_wrap_cmd_dmy_clk = 0x03 +de_burst_wrap_code_mode = 2 +de_burst_wrap_code = 0xF0 +write_enable_cmd = 0x06 +wel_reg_index = 0 +wel_bit_pos = 1 +wel_reg_read_len = 1 +wel_reg_write_len = 2 +qe_reg_index = 1 +qe_bit_pos = 1 +qe_reg_write_len = 2 +qe_reg_read_len = 1 +busy_reg_index = 0 +busy_bit_pos = 0 +busy_reg_read_len = 1 +release_power_down = 0xab +reg_read_cmd0 = 0x05 +reg_read_cmd1 = 0x35 +reg_write_cmd0 = 0x01 +reg_write_cmd1 = 0x01 +fast_read_qio_cmd = 0xeb +fast_read_qio_dmy_clk = 2 +cont_read_support = 1 +cont_read_code = 0xa0 +burst_wrap_cmd = 0x77 +burst_wrap_dmy_clk = 0x03 +burst_wrap_data_mode = 2 +burst_wrap_code = 0x40 +chip_erase_cmd = 0xc7 +sector_erase_cmd = 0x20 +blk32k_erase_cmd = 0x52 +blk64k_erase_cmd = 0xd8 +page_prog_cmd = 0x02 +qpage_prog_cmd = 0x32 +qual_page_prog_addr_mode = 0 +reset_en_cmd = 0x66 +reset_cmd = 0x99 +cont_read_exit_code = 0xff +jedecid_cmd = 0x9f +jedecid_cmd_dmy_clk = 0 +qpi_jedecid_cmd = 0x9f +qpi_jedecid_dmy_clk = 0 +sector_size = 4 +page_size = 256 +fast_read_cmd = 0x0b +fast_read_dmy_clk = 1 +qpi_fast_read_cmd = 0x0b +qpi_fast_read_dmy_clk = 1 +fast_read_do_cmd = 0x3b +fast_read_do_dmy_clk = 1 +fast_read_dio_cmd = 0xbb +fast_read_dio_dmy_clk = 0 +fast_read_qo_cmd = 0x6b +fast_read_qo_dmy_clk = 1 +qpi_fast_read_qio_cmd = 0xeb +qpi_fast_read_qio_dmy_clk = 2 +qpi_page_prog_cmd = 0x02 +write_vreg_enable_cmd = 0x50 +enter_qpi_cmd = 0x38 +exit_qpi_cmd = 0xff +sector_erase_time = 800 +blk32k_erase_time = 3000 +blk64k_erase_time = 4000 +page_prog_time = 10 +chip_erase_time = 65535 +power_down_delay = 20 +qe_data = 0 \ No newline at end of file diff --git a/tools/bflb_flash_tool/utils/flash-conf/bl602/ZB25D40B_5e3213.conf b/tools/bflb_flash_tool/utils/flash-conf/bl602/ZB25D40B_5e3213.conf new file mode 100644 index 00000000..5e605a14 --- /dev/null +++ b/tools/bflb_flash_tool/utils/flash-conf/bl602/ZB25D40B_5e3213.conf @@ -0,0 +1,73 @@ +[FLASH_CFG] +exit_contread_cmd = 0xff +exit_contread_cmd_size = 3 +mfg_id = 0x5e +io_mode = 0x11 +de_burst_wrap_cmd = 0x77 +de_burst_wrap_cmd_dmy_clk = 0x03 +de_burst_wrap_code_mode = 2 +de_burst_wrap_code = 0xF0 +write_enable_cmd = 0x06 +wel_reg_index = 0 +wel_bit_pos = 1 +wel_reg_read_len = 1 +wel_reg_write_len = 2 +qe_reg_index = 1 +qe_bit_pos = 1 +qe_reg_write_len = 1 +qe_reg_read_len = 1 +busy_reg_index = 0 +busy_bit_pos = 0 +busy_reg_read_len = 1 +release_power_down = 0xab +reg_read_cmd0 = 0x05 +reg_read_cmd1 = 0x35 +reg_write_cmd0 = 0x01 +reg_write_cmd1 = 0x31 +fast_read_qio_cmd = 0xeb +fast_read_qio_dmy_clk = 2 +cont_read_support = 0 +cont_read_code = 0x20 +burst_wrap_cmd = 0x77 +burst_wrap_dmy_clk = 0x03 +burst_wrap_data_mode = 2 +burst_wrap_code = 0x40 +chip_erase_cmd = 0xc7 +sector_erase_cmd = 0x20 +blk32k_erase_cmd = 0x52 +blk64k_erase_cmd = 0xd8 +page_prog_cmd = 0x02 +qpage_prog_cmd = 0x32 +qual_page_prog_addr_mode = 0 +reset_en_cmd = 0x66 +reset_cmd = 0x99 +cont_read_exit_code = 0xff +jedecid_cmd = 0x9f +jedecid_cmd_dmy_clk = 0 +qpi_jedecid_cmd = 0x9f +qpi_jedecid_dmy_clk = 0 +sector_size = 4 +page_size = 256 +fast_read_cmd = 0x0b +fast_read_dmy_clk = 1 +qpi_fast_read_cmd = 0x0b +qpi_fast_read_dmy_clk = 1 +fast_read_do_cmd = 0x3b +fast_read_do_dmy_clk = 1 +fast_read_dio_cmd = 0xbb +fast_read_dio_dmy_clk = 0 +fast_read_qo_cmd = 0x6b +fast_read_qo_dmy_clk = 1 +qpi_fast_read_qio_cmd = 0xeb +qpi_fast_read_qio_dmy_clk = 2 +qpi_page_prog_cmd = 0x02 +write_vreg_enable_cmd = 0x50 +enter_qpi_cmd = 0x38 +exit_qpi_cmd = 0xff +sector_erase_time = 300 +blk32k_erase_time = 1200 +blk64k_erase_time = 1200 +page_prog_time = 5 +chip_erase_time = 33000 +power_down_delay = 8 +qe_data = 0 \ No newline at end of file diff --git a/tools/bflb_flash_tool/utils/flash-conf/bl602/ZB25D80B_5e3214.conf b/tools/bflb_flash_tool/utils/flash-conf/bl602/ZB25D80B_5e3214.conf new file mode 100644 index 00000000..5e605a14 --- /dev/null +++ b/tools/bflb_flash_tool/utils/flash-conf/bl602/ZB25D80B_5e3214.conf @@ -0,0 +1,73 @@ +[FLASH_CFG] +exit_contread_cmd = 0xff +exit_contread_cmd_size = 3 +mfg_id = 0x5e +io_mode = 0x11 +de_burst_wrap_cmd = 0x77 +de_burst_wrap_cmd_dmy_clk = 0x03 +de_burst_wrap_code_mode = 2 +de_burst_wrap_code = 0xF0 +write_enable_cmd = 0x06 +wel_reg_index = 0 +wel_bit_pos = 1 +wel_reg_read_len = 1 +wel_reg_write_len = 2 +qe_reg_index = 1 +qe_bit_pos = 1 +qe_reg_write_len = 1 +qe_reg_read_len = 1 +busy_reg_index = 0 +busy_bit_pos = 0 +busy_reg_read_len = 1 +release_power_down = 0xab +reg_read_cmd0 = 0x05 +reg_read_cmd1 = 0x35 +reg_write_cmd0 = 0x01 +reg_write_cmd1 = 0x31 +fast_read_qio_cmd = 0xeb +fast_read_qio_dmy_clk = 2 +cont_read_support = 0 +cont_read_code = 0x20 +burst_wrap_cmd = 0x77 +burst_wrap_dmy_clk = 0x03 +burst_wrap_data_mode = 2 +burst_wrap_code = 0x40 +chip_erase_cmd = 0xc7 +sector_erase_cmd = 0x20 +blk32k_erase_cmd = 0x52 +blk64k_erase_cmd = 0xd8 +page_prog_cmd = 0x02 +qpage_prog_cmd = 0x32 +qual_page_prog_addr_mode = 0 +reset_en_cmd = 0x66 +reset_cmd = 0x99 +cont_read_exit_code = 0xff +jedecid_cmd = 0x9f +jedecid_cmd_dmy_clk = 0 +qpi_jedecid_cmd = 0x9f +qpi_jedecid_dmy_clk = 0 +sector_size = 4 +page_size = 256 +fast_read_cmd = 0x0b +fast_read_dmy_clk = 1 +qpi_fast_read_cmd = 0x0b +qpi_fast_read_dmy_clk = 1 +fast_read_do_cmd = 0x3b +fast_read_do_dmy_clk = 1 +fast_read_dio_cmd = 0xbb +fast_read_dio_dmy_clk = 0 +fast_read_qo_cmd = 0x6b +fast_read_qo_dmy_clk = 1 +qpi_fast_read_qio_cmd = 0xeb +qpi_fast_read_qio_dmy_clk = 2 +qpi_page_prog_cmd = 0x02 +write_vreg_enable_cmd = 0x50 +enter_qpi_cmd = 0x38 +exit_qpi_cmd = 0xff +sector_erase_time = 300 +blk32k_erase_time = 1200 +blk64k_erase_time = 1200 +page_prog_time = 5 +chip_erase_time = 33000 +power_down_delay = 8 +qe_data = 0 \ No newline at end of file diff --git a/tools/bflb_flash_tool/utils/flash-conf/bl602/ZB25Q16B_5e4015.conf b/tools/bflb_flash_tool/utils/flash-conf/bl602/ZB25Q16B_5e4015.conf new file mode 100644 index 00000000..90756fed --- /dev/null +++ b/tools/bflb_flash_tool/utils/flash-conf/bl602/ZB25Q16B_5e4015.conf @@ -0,0 +1,73 @@ +[FLASH_CFG] +exit_contread_cmd = 0xff +exit_contread_cmd_size = 3 +mfg_id = 0x5e +io_mode = 4 +de_burst_wrap_cmd = 0x77 +de_burst_wrap_cmd_dmy_clk = 0x03 +de_burst_wrap_code_mode = 2 +de_burst_wrap_code = 0xF0 +write_enable_cmd = 0x06 +wel_reg_index = 0 +wel_bit_pos = 1 +wel_reg_read_len = 1 +wel_reg_write_len = 2 +qe_reg_index = 1 +qe_bit_pos = 1 +qe_reg_write_len = 1 +qe_reg_read_len = 1 +busy_reg_index = 0 +busy_bit_pos = 0 +busy_reg_read_len = 1 +release_power_down = 0xab +reg_read_cmd0 = 0x05 +reg_read_cmd1 = 0x35 +reg_write_cmd0 = 0x01 +reg_write_cmd1 = 0x31 +fast_read_qio_cmd = 0xeb +fast_read_qio_dmy_clk = 2 +cont_read_support = 1 +cont_read_code = 0x20 +burst_wrap_cmd = 0x77 +burst_wrap_dmy_clk = 0x03 +burst_wrap_data_mode = 2 +burst_wrap_code = 0x40 +chip_erase_cmd = 0xc7 +sector_erase_cmd = 0x20 +blk32k_erase_cmd = 0x52 +blk64k_erase_cmd = 0xd8 +page_prog_cmd = 0x02 +qpage_prog_cmd = 0x32 +qual_page_prog_addr_mode = 0 +reset_en_cmd = 0x66 +reset_cmd = 0x99 +cont_read_exit_code = 0xff +jedecid_cmd = 0x9f +jedecid_cmd_dmy_clk = 0 +qpi_jedecid_cmd = 0x9f +qpi_jedecid_dmy_clk = 0 +sector_size = 4 +page_size = 256 +fast_read_cmd = 0x0b +fast_read_dmy_clk = 1 +qpi_fast_read_cmd = 0x0b +qpi_fast_read_dmy_clk = 1 +fast_read_do_cmd = 0x3b +fast_read_do_dmy_clk = 1 +fast_read_dio_cmd = 0xbb +fast_read_dio_dmy_clk = 0 +fast_read_qo_cmd = 0x6b +fast_read_qo_dmy_clk = 1 +qpi_fast_read_qio_cmd = 0xeb +qpi_fast_read_qio_dmy_clk = 2 +qpi_page_prog_cmd = 0x02 +write_vreg_enable_cmd = 0x50 +enter_qpi_cmd = 0x38 +exit_qpi_cmd = 0xff +sector_erase_time = 300 +blk32k_erase_time = 1200 +blk64k_erase_time = 1200 +page_prog_time = 5 +chip_erase_time = 33000 +power_down_delay = 8 +qe_data = 0 \ No newline at end of file diff --git a/tools/bflb_flash_tool/utils/flash-conf/bl602/ZBVQ16_5e6015.conf b/tools/bflb_flash_tool/utils/flash-conf/bl602/ZBVQ16_5e6015.conf index d75813d4..58c87807 100644 --- a/tools/bflb_flash_tool/utils/flash-conf/bl602/ZBVQ16_5e6015.conf +++ b/tools/bflb_flash_tool/utils/flash-conf/bl602/ZBVQ16_5e6015.conf @@ -64,9 +64,9 @@ qpi_page_prog_cmd = 0x02 write_vreg_enable_cmd = 0x50 enter_qpi_cmd = 0x38 exit_qpi_cmd = 0xff -sector_erase_time = 300 -blk32k_erase_time = 1200 -blk64k_erase_time = 1200 +sector_erase_time = 400 +blk32k_erase_time = 1600 +blk64k_erase_time = 2000 page_prog_time = 5 chip_erase_time = 65535 power_down_delay = 8 diff --git a/tools/bflb_flash_tool/utils/flash-conf/bl602/ZBWQ16A_5e3415.conf b/tools/bflb_flash_tool/utils/flash-conf/bl602/ZBWQ16A_5e3415.conf new file mode 100644 index 00000000..90756fed --- /dev/null +++ b/tools/bflb_flash_tool/utils/flash-conf/bl602/ZBWQ16A_5e3415.conf @@ -0,0 +1,73 @@ +[FLASH_CFG] +exit_contread_cmd = 0xff +exit_contread_cmd_size = 3 +mfg_id = 0x5e +io_mode = 4 +de_burst_wrap_cmd = 0x77 +de_burst_wrap_cmd_dmy_clk = 0x03 +de_burst_wrap_code_mode = 2 +de_burst_wrap_code = 0xF0 +write_enable_cmd = 0x06 +wel_reg_index = 0 +wel_bit_pos = 1 +wel_reg_read_len = 1 +wel_reg_write_len = 2 +qe_reg_index = 1 +qe_bit_pos = 1 +qe_reg_write_len = 1 +qe_reg_read_len = 1 +busy_reg_index = 0 +busy_bit_pos = 0 +busy_reg_read_len = 1 +release_power_down = 0xab +reg_read_cmd0 = 0x05 +reg_read_cmd1 = 0x35 +reg_write_cmd0 = 0x01 +reg_write_cmd1 = 0x31 +fast_read_qio_cmd = 0xeb +fast_read_qio_dmy_clk = 2 +cont_read_support = 1 +cont_read_code = 0x20 +burst_wrap_cmd = 0x77 +burst_wrap_dmy_clk = 0x03 +burst_wrap_data_mode = 2 +burst_wrap_code = 0x40 +chip_erase_cmd = 0xc7 +sector_erase_cmd = 0x20 +blk32k_erase_cmd = 0x52 +blk64k_erase_cmd = 0xd8 +page_prog_cmd = 0x02 +qpage_prog_cmd = 0x32 +qual_page_prog_addr_mode = 0 +reset_en_cmd = 0x66 +reset_cmd = 0x99 +cont_read_exit_code = 0xff +jedecid_cmd = 0x9f +jedecid_cmd_dmy_clk = 0 +qpi_jedecid_cmd = 0x9f +qpi_jedecid_dmy_clk = 0 +sector_size = 4 +page_size = 256 +fast_read_cmd = 0x0b +fast_read_dmy_clk = 1 +qpi_fast_read_cmd = 0x0b +qpi_fast_read_dmy_clk = 1 +fast_read_do_cmd = 0x3b +fast_read_do_dmy_clk = 1 +fast_read_dio_cmd = 0xbb +fast_read_dio_dmy_clk = 0 +fast_read_qo_cmd = 0x6b +fast_read_qo_dmy_clk = 1 +qpi_fast_read_qio_cmd = 0xeb +qpi_fast_read_qio_dmy_clk = 2 +qpi_page_prog_cmd = 0x02 +write_vreg_enable_cmd = 0x50 +enter_qpi_cmd = 0x38 +exit_qpi_cmd = 0xff +sector_erase_time = 300 +blk32k_erase_time = 1200 +blk64k_erase_time = 1200 +page_prog_time = 5 +chip_erase_time = 33000 +power_down_delay = 8 +qe_data = 0 \ No newline at end of file diff --git a/tools/bflb_flash_tool/utils/jlink/JLink_x64.dll b/tools/bflb_flash_tool/utils/jlink/JLink_x64.dll new file mode 100644 index 00000000..4df24421 Binary files /dev/null and b/tools/bflb_flash_tool/utils/jlink/JLink_x64.dll differ diff --git a/tools/bflb_flash_tool/utils/openocd/if_usb_dbg.cfg b/tools/bflb_flash_tool/utils/openocd/if_usb_dbg.cfg new file mode 100644 index 00000000..645755a5 --- /dev/null +++ b/tools/bflb_flash_tool/utils/openocd/if_usb_dbg.cfg @@ -0,0 +1,16 @@ +# BouffaloLab USB-JTAG/TTL adapter +interface ftdi +ftdi_vid_pid 0x0403 0x6010 + +ftdi_channel 0 +#ftdi_tdo_sample_edge falling +transport select jtag +adapter_khz 4000 + +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/cmake/compiler_flags.cmake b/tools/cmake/compiler_flags.cmake index 3c30121d..4f1b23a8 100644 --- a/tools/cmake/compiler_flags.cmake +++ b/tools/cmake/compiler_flags.cmake @@ -1,100 +1,18 @@ -#set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) -# Object build options -# -O0 No optimizations, reduce compilation time and make debugging produce the expected results. -# -fno-builtin Do not use built-in functions provided by GCC. -# -Wall Print only standard warnings, for all use Wextra -# -ffunction-sections Place each function item into its own section in the output file. -# -fdata-sections Place each data item into its own section in the output file. -# -fomit-frame-pointer Omit the frame pointer in functions that don’t need one. -# -Og Enables optimizations that do not interfere with debugging. -# -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(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}") +include(${CMAKE_SOURCE_DIR}/drivers/${CHIP}_driver/cpu_flags.cmake) -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 \ --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" CACHE INTERNAL "c compiler flags: Release") +list(APPEND GLOBAL_C_FLAGS -Os -g3) +list(APPEND GLOBAL_C_FLAGS -fshort-enums -fno-common -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields) +list(APPEND GLOBAL_C_FLAGS -Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -Wignored-qualifiers -Wunused -Wundef) +list(APPEND GLOBAL_C_FLAGS -msmall-data-limit=4) -# message("") -# message("-----------------------------------------------------------------------------------------------------------------------------------------------------") -# message("Setting C compiler") -# message("C compiler flags options: ${CMAKE_C_FLAGS}") -# message("C compiler debug options: ${CMAKE_C_FLAGS_DEBUG}") -# message("C compiler release options: ${CMAKE_C_FLAGS_RELEASE}") -# message("-----------------------------------------------------------------------------------------------------------------------------------------------------") +list(APPEND GLOBAL_LD_FLAGS -Wl,--cref -Wl,--gc-sections -nostartfiles -g3) +list(APPEND GLOBAL_LD_FLAGS -fms-extensions -ffunction-sections -fdata-sections) +list(APPEND GLOBAL_LD_FLAGS -Wall -Wchar-subscripts -std=c99) + +# Add common options +add_compile_options(${GLOBAL_C_FLAGS}) +add_compile_options($<$:-std=c99>) +add_compile_options($<$:-std=c++11>) +add_link_options(${GLOBAL_LD_FLAGS}) -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" CACHE INTERNAL "cxx compiler flags: Release") - -# message("") -# message("-----------------------------------------------------------------------------------------------------------------------------------------------------") -# message("Setting C++ compiler") -# message("C++ compiler flags options: ${CMAKE_CXX_FLAGS}") -# message("C++ compiler debug options: ${CMAKE_CXX_FLAGS_DEBUG}") -# message("C++ compiler release options: ${CMAKE_CXX_FLAGS_RELEASE}") -# message("-----------------------------------------------------------------------------------------------------------------------------------------------------") - - -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" CACHE INTERNAL "asm compiler flags: Release") - -# message("") -# message("-----------------------------------------------------------------------------------------------------------------------------------------------------") -# message("Setting ASM compiler") -# message("ASM compiler flags options: ${CMAKE_ASM_FLAGS}") -# message("ASM compiler debug options: ${CMAKE_ASM_FLAGS_DEBUG}") -# message("ASM compiler release options: ${CMAKE_ASM_FLAGS_RELEASE}") -# message("-----------------------------------------------------------------------------------------------------------------------------------------------------") - -# -Wl,--gc-sections Perform the dead code elimination. -# --specs=nano.specs Link with newlib-nano. -# --specs=nosys.specs No syscalls, provide empty implementations for the POSIX system calls. - -if(${SUPPORT_FLOAT} STREQUAL "y") -add_definitions(-DBFLB_PRINT_FLOAT_SUPPORT) -else() -endif() - -if(${SUPPORT_SHELL} STREQUAL "y") -add_definitions(-DSHELL_SUPPORT) -else() -endif() - -if(${BOARD} MATCHES "(bl602u.*)") -set(mcu bl602u) - -elseif(${BOARD} MATCHES "(bl602).*") -set(mcu bl602) - -elseif(${BOARD} MATCHES "(bl702|bl704|bl706).*") -set(mcu bl702) - -elseif(${BOARD} MATCHES "(bl606p).*") -set(mcu bl606p) - -else() -endif() - -SET(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/drivers/${mcu}_driver/${mcu}_flash.ld) - -set(CMAKE_EXE_LINKER_FLAGS "${MCU_FLAG} -Wl,--cref -Wl,--gc-sections -nostartfiles -lc -lm -g3 \ --fms-extensions -ffunction-sections -fdata-sections -Wall -Wchar-subscripts \ --Wformat -Wuninitialized -Winit-self -Wignored-qualifiers -Wswitch-default -Wunused -Wundef -std=c99" CACHE INTERNAL "Linker options") diff --git a/tools/cmake/tools.cmake b/tools/cmake/tools.cmake index 00c3b55e..667dad3d 100644 --- a/tools/cmake/tools.cmake +++ b/tools/cmake/tools.cmake @@ -1,17 +1,21 @@ function(generate_library) get_filename_component(library_name ${CMAKE_CURRENT_LIST_DIR} NAME) - message(STATUS "[register library component: ${library_name} ], path:${CMAKE_CURRENT_LIST_DIR}") + message(STATUS "[register library component: ${library_name}], path:${CMAKE_CURRENT_LIST_DIR}") # Add src to lib if(ADD_SRCS) add_library(${library_name} STATIC ${ADD_SRCS}) set(include_type PUBLIC) - else() - add_library(${library_name} INTERFACE) - set(include_type INTERFACE) + + foreach(f ${ADD_SRCS}) + if(${f} MATCHES ".S|.s") + set_property(SOURCE ${f} PROPERTY LANGUAGE C) + endif() + endforeach() endif() - # Add include + # Add global config include + if(ADD_INCLUDE) foreach(include_dir ${ADD_INCLUDE}) get_filename_component(abs_dir ${include_dir} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_LIST_DIR}) if(NOT IS_DIRECTORY ${abs_dir}) @@ -19,79 +23,74 @@ function(generate_library) endif() target_include_directories(${library_name} ${include_type} ${abs_dir}) endforeach() + endif() # Add private include + if(ADD_PRIVATE_INCLUDE) foreach(include_dir ${ADD_PRIVATE_INCLUDE}) - if(${include_type} STREQUAL INTERFACE) - message(FATAL_ERROR "${CMAKE_CURRENT_LIST_FILE}: ADD_PRIVATE_INCLUDE set but no source file!") - endif() get_filename_component(abs_dir ${include_dir} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_LIST_DIR}) if(NOT IS_DIRECTORY ${abs_dir}) message(FATAL_ERROR "${CMAKE_CURRENT_LIST_FILE}: ${include_dir} not found!") endif() target_include_directories(${library_name} PRIVATE ${abs_dir}) endforeach() - - # Add global config include - target_include_directories(${library_name} PUBLIC ${global_config_dir}) - - # Add requirements - target_link_libraries(${library_name} ${ADD_REQUIREMENTS}) + endif() # Add definitions public - foreach(difinition ${ADD_DEFINITIONS}) - target_compile_options(${library_name} PUBLIC ${difinition}) - endforeach() + if(ADD_DEFINITIONS) + target_compile_options(${library_name} PUBLIC ${ADD_DEFINITIONS}) + endif() # Add definitions private - foreach(difinition ${ADD_DEFINITIONS_PRIVATE}) - target_compile_options(${library_name} PRIVATE ${difinition}) - endforeach() + if(ADD_DEFINITIONS_PRIVATE) + target_compile_options(${library_name} PRIVATE ${ADD_DEFINITIONS_PRIVATE}) + endif() + + # Add requirements + if(ADD_REQUIREMENTS) + foreach(lib ${ADD_REQUIREMENTS}) + if(TARGET ${lib}) + add_dependencies(${library_name} ${lib}) + target_link_libraries(${library_name} ${lib}) + else() + message(FATAL_ERROR "${lib} is not a target") + endif() + endforeach() + endif() # Add static lib if(ADD_STATIC_LIB) foreach(lib ${ADD_STATIC_LIB}) if(NOT EXISTS "${lib}") - prepend(lib_full "${CMAKE_CURRENT_LIST_DIR}/" ${lib}) - if(NOT EXISTS "${lib_full}") - message(FATAL_ERROR "Can not find ${lib} or ${lib_full}") - endif() - set(lib ${lib_full}) + message(FATAL_ERROR "Can not find ${lib}") endif() - target_link_libraries(${library_name} ${lib}) + get_filename_component(static_lib_relative_dir ${lib} DIRECTORY) + get_filename_component(static_lib_name ${lib} NAME) + target_link_directories(${library_name} PUBLIC ${static_lib_relative_dir}) + target_link_libraries(${library_name} ${static_lib_name}) endforeach() endif() + # Add dynamic lib if(ADD_DYNAMIC_LIB) - set(dynamic_libs ${g_dynamic_libs}) foreach(lib ${ADD_DYNAMIC_LIB}) if(NOT EXISTS "${lib}") - prepend(lib_full "${CMAKE_CURRENT_LIST_DIR}/" ${lib}) - if(NOT EXISTS "${lib_full}") - message(FATAL_ERROR "Can not find ${lib} or ${lib_full}") - endif() - set(lib ${lib_full}) + message(FATAL_ERROR "Can not find ${lib}") endif() - list(APPEND dynamic_libs ${lib}) - get_filename_component(lib_dir ${lib} DIRECTORY) - get_filename_component(lib_name ${lib} NAME) - target_link_libraries(${library_name} -L${lib_dir} ${lib_name}) + get_filename_component(dynamic_lib_relative_dir ${lib} DIRECTORY) + get_filename_component(dynamic_lib_name ${lib} NAME) + target_link_directories(${library_name} PUBLIC ${dynamic_lib_relative_dir}) + target_link_libraries(${library_name} ${dynamic_lib_name}) endforeach() - set(g_dynamic_libs ${dynamic_libs} CACHE INTERNAL "g_dynamic_libs") endif() endfunction() function(generate_bin) get_filename_component(current_relative_dir_name ${CMAKE_CURRENT_LIST_DIR} NAME) - - #上面写法等价于string(REGEX REPLACE ".*/(.*)" "\\1" current_relative_dir_name ${CMAKE_CURRENT_LIST_DIR}) string(REGEX REPLACE "(.*)/${current_relative_dir_name}$" "\\1" above_absolute_dir ${CMAKE_CURRENT_LIST_DIR}) - get_filename_component(above_relative_dir_name ${above_absolute_dir} NAME) - set(platform ${CMAKE_SOURCE_DIR}/bsp/bsp_common/platform/bflb_platform.c) - foreach(mainfile IN LISTS mains) # Get file name without directory get_filename_component(mainname ${mainfile} NAME_WE) @@ -101,31 +100,39 @@ function(generate_bin) set(target_name firmware) else() if(${above_relative_dir_name} STREQUAL "examples") - set(OUTPUT_DIR ${CMAKE_SOURCE_DIR}/out/${current_relative_dir_name}) + set(OUTPUT_DIR ${CMAKE_SOURCE_DIR}/out/${APP_DIR}/${current_relative_dir_name}) set(target_name ${current_relative_dir_name}_${mainname}) else() - set(OUTPUT_DIR ${CMAKE_SOURCE_DIR}/out/${above_relative_dir_name}/${current_relative_dir_name}) + set(OUTPUT_DIR ${CMAKE_SOURCE_DIR}/out/${APP_DIR}/${above_relative_dir_name}/${current_relative_dir_name}) set(target_name ${current_relative_dir_name}_${mainname}) endif() endif() file(MAKE_DIRECTORY ${OUTPUT_DIR}) - 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) + set(HEX_FILE ${OUTPUT_DIR}/${target_name}.hex) + set(BIN_FILE ${OUTPUT_DIR}/${target_name}.bin) + set(MAP_FILE ${OUTPUT_DIR}/${target_name}.map) + set(ASM_FILE ${OUTPUT_DIR}/${target_name}.asm) if(TARGET_REQUIRED_SRCS) - list(APPEND SRCS ${TARGET_REQUIRED_SRCS}) + foreach(src ${TARGET_REQUIRED_SRCS}) + if((NOT EXISTS ${src}) AND (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${src})) + message(FATAL_ERROR "${src} not exist,maybe you should autocomplete your path\r\n") + endif() + list(APPEND SRCS ${src}) + endforeach() + endif() + list(APPEND SRCS ${CMAKE_SOURCE_DIR}/bsp/bsp_common/platform/bflb_platform.c) list(APPEND SRCS ${CMAKE_SOURCE_DIR}/bsp/board/${BOARD}/board.c) - add_executable(${target_name}.elf ${mainfile} ${SRCS} ${platform}) + add_executable(${target_name}.elf ${mainfile} ${SRCS}) - set_target_properties(${target_name}.elf PROPERTIES LINK_FLAGS "-T${LINKER_SCRIPT}") + set_target_properties(${target_name}.elf PROPERTIES LINK_FLAGS "-T${LINKER_SCRIPT} -Wl,-Map=${MAP_FILE}") set_target_properties(${target_name}.elf PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT}) + set_target_properties(${target_name}.elf PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIR}") # Add private include @@ -138,11 +145,13 @@ function(generate_bin) endforeach() # Add definitions private - foreach(difinition ${TARGET_REQUIRED_PRIVATE_OPTIONS}) - target_compile_options(${target_name}.elf PRIVATE ${difinition}) - endforeach() + if(TARGET_REQUIRED_PRIVATE_OPTIONS) + target_compile_options(${target_name}.elf PRIVATE ${TARGET_REQUIRED_PRIVATE_OPTIONS}) + endif() + + add_dependencies(${target_name}.elf ${CHIP}_driver) # Add libs - target_link_libraries(${target_name}.elf ${mcu}_driver) + target_link_libraries(${target_name}.elf ${CHIP}_driver) if(${SUPPORT_SHELL} STREQUAL "y") target_link_libraries(${target_name}.elf shell) @@ -154,8 +163,8 @@ function(generate_bin) target_link_libraries(${target_name}.elf ${TARGET_REQUIRED_LIBS}) endif() - target_link_libraries(${target_name}.elf "-Wl,-Map=${MAP_FILE}") - + target_link_libraries(${target_name}.elf m) + add_custom_command(TARGET ${target_name}.elf POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary $ ${BIN_FILE} COMMAND ${CMAKE_OBJDUMP} -d -S $ >${ASM_FILE} @@ -176,11 +185,11 @@ if(DEFINED APP) get_filename_component(app_relative_dir ${cmakelists_file} DIRECTORY) get_filename_component(app_name ${app_relative_dir} NAME) if(${APP} STREQUAL "all") - message("[run app:${app_name}],path:${app_relative_dir}") + message(STATUS "[run app:${app_name}], path:${app_relative_dir}") add_subdirectory(${app_relative_dir}) set(app_find_ok 1) elseif(${app_name} MATCHES "^${APP}") - message("[run app:${app_name}],path:${app_relative_dir}") + message(STATUS "[run app:${app_name}], path:${app_relative_dir}") add_subdirectory(${app_relative_dir}) set(app_find_ok 1) endif() diff --git a/tools/openocd/602.init b/tools/openocd/602.init index 3f212b25..76910ed8 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 1910415f..63f23bc7 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 3f212b25..76910ed8 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_702_hack.cfg b/tools/openocd/if_702_hack.cfg new file mode 100644 index 00000000..d42ceedc --- /dev/null +++ b/tools/openocd/if_702_hack.cfg @@ -0,0 +1,21 @@ +# BouffaloLab USB-JTAG/TTL adapter +interface ftdi +#adapter driver ftdi +ftdi_vid_pid 0x0403 0x6010 + +ftdi_channel 0 +#ftdi_tdo_sample_edge falling +transport select jtag +adapter_khz 5000 +#adapter speed 1000 + +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 + +#bindto 0.0.0.0 + diff --git a/tools/openocd/if_bflb_dbg.cfg b/tools/openocd/if_bflb_dbg.cfg index e2e382db..9f754f8d 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 865ac1f1..5de10689 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 32e414d7..1146ec73 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 27e704e8..34e8d2c8 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 0f713437..1deb31d2 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 8a819e5e..b2460328 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 c30c1a17..53c813ba 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 b1771666..d3b66b7c 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 5000 +} + +$_TARGETNAME.0 configure -event reset-deassert-post { + echo "reset-deassert-post" + adapter_khz 5000 + reg mstatus 0x7800 + reg mie 0x0 +# reg pc 0x22008000 +} + +$_TARGETNAME.0 configure -event reset-init { + echo "reset-init" +# 4MHz for FPGA + adapter_khz 5000 +} + +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_e907.cfg b/tools/openocd/tgt_e907.cfg new file mode 100644 index 00000000..cdbd62ea --- /dev/null +++ b/tools/openocd/tgt_e907.cfg @@ -0,0 +1,45 @@ +#target chip + +set _CHIPNAME riscv +jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x10000b6f + +set _TARGETNAME $_CHIPNAME.cpu +target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME +$_TARGETNAME.0 configure -work-area-phys 0x3eff0000 -work-area-size 0x10000 -work-area-backup 0 +#$_TARGETNAME.0 configure -rtos auto + +echo "Ready for Remote Connections" + +$_TARGETNAME.0 configure -event reset-assert-pre { + echo "reset-assert-pre" + adapter speed 4000 +} + +$_TARGETNAME.0 configure -event reset-deassert-post { + echo "reset-deassert-post" + adapter speed 4000 + reg mstatus 0x7800 + reg mie 0x0 +# reg pc 0x22008000 +} + +$_TARGETNAME.0 configure -event reset-init { + echo "reset-init" +# 4MHz for FPGA + adapter speed 4000 +} + +gdb_memory_map enable +gdb_flash_program disable + +riscv set_prefer_sba off +riscv set_command_timeout_sec 1 + +init +#reset init + +#jtag arp_init + +#resume +#exit +