N2L七宗罪
1、不同例程编辑器版本不兼容差异较大。
2、fsp不同版本不兼容,
3、fsp历史版本下载难。
4、fsp不要选自定义板子,不要选,不要选;
fsp2.1的usb库有问题(??)
// #include "board_cfg.h" //去除开发板库补丁代码
#define BSP_CFG_XSPI0_X1_BOOT (1) #define BSP_CFG_CACHE_FLG (0x00000000) #define BSP_CFG_CS0BCR_V_WRAPCFG_V (0x00000000) #define BSP_CFG_CS0WCR_V_COMCFG_V (0x00000000) #define BSP_CFG_DUMMY0_BMCFG_V (0x00000000) #define BSP_CFG_BSC_FLG_xSPI_FLG (0x00000000) #define BSP_CFG_LDR_ADDR_NML (0x6000004C) #define BSP_CFG_LDR_SIZE_NML (0x00006000) #define BSP_CFG_DEST_ADDR_NML (0x00102000) #define BSP_CFG_DUMMY1 (0x00000000) #define BSP_CFG_DUMMY2 (0x00000000) #define BSP_CFG_DUMMY3_CSSCTL_V (0x0000003F) #define BSP_CFG_DUMMY4_LIOCFGCS0_V (0x00070000) #define BSP_CFG_DUMMY5 (0x00000000) #define BSP_CFG_DUMMY6 (0x00000000) #define BSP_CFG_DUMMY7 (0x00000000) #define BSP_CFG_DUMMY8 (0x00000000) #define BSP_CFG_DUMMY9 (0x00000000) #define BSP_CFG_DUMMY10_ACCESS_SPEED (0x00000006) #define BSP_CFG_CHECK_SUM (0xE0A8)
// jlink 仿真等待补丁
#if 1 // Software loops are only needed when debugging. __asm volatile ( " mov r0, #0 \n" " movw r1, #0xf07f \n" " movt r1, #0x2fa \n" "software_loop: \n" " adds r0, #1 \n" " cmp r0, r1 \n" " bne software_loop \n" ::: "memory"); #endif
//LED //GPIO裸机测试代码
#include "r_ioport.h" extern ioport_instance_ctrl_t g_ioport_ctrl; R_BSP_PinAccessEnable();//R_BSP_PinAccessDisable() R_IOPORT_PinWrite(&g_ioport_ctrl, (bsp_io_port_pin_t) BSP_IO_PORT_14_PIN_0, 0);//setLed4(0); //1=OFF;0=ON R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS);////wait_ms(500);// R_IOPORT_PinWrite(&g_ioport_ctrl, (bsp_io_port_pin_t) BSP_IO_PORT_14_PIN_0, 1);//setLed4(1);// 1=OFF;0=ON R_BSP_SoftwareDelay(900, BSP_DELAY_UNITS_MILLISECONDS);//wait_ms(900);
//xspi0 链接代码
//define symbol RAM_NS_BUFFER_LENGTH = 0x8100; define memory mem with size = 4G; define symbol ATCM_PRV_START = 0x00000000; define symbol ATCM_PRV_LENGTH = 0x20000; //128K //中断 define symbol INTVEC_ADDRESS = ATCM_PRV_START; define symbol __ICFEDIT_intvec_start__ = INTVEC_ADDRESS; //RAM define symbol RAM_ADDRESS = (ATCM_PRV_START + 0x100); //256字节 define symbol RAM_END_ADDRESS = (ATCM_PRV_START + ATCM_PRV_LENGTH - 1); define symbol __ICFEDIT_region_RAM_start__ = RAM_ADDRESS; define symbol __ICFEDIT_region_RAM_end__ = RAM_END_ADDRESS; define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__ ]; //ATCM define symbol __region_ATCM_start__ = ATCM_PRV_START; define symbol __region_ATCM_end__ = ATCM_PRV_START + ATCM_PRV_LENGTH - 1; define region ATCM_region = mem:[from __region_ATCM_start__ to __region_ATCM_end__ ]; //BTCM define symbol BTCM_PRV_START = 0x00100000; define symbol BTCM_PRV_LENGTH = 0x20000; //128K define symbol LOADER_STACK_ADDRESS = (BTCM_PRV_START + 0x2000); // 8K define symbol LOADER_STACK_END_ADDRESS = (BTCM_PRV_START + BTCM_PRV_LENGTH - 1); define symbol __region_D_LOADER_STACK_start__ = LOADER_STACK_ADDRESS; define symbol __region_D_LOADER_STACK_end__ = LOADER_STACK_END_ADDRESS; define region D_LOADER_STACK_region = mem:[from __region_D_LOADER_STACK_start__ to __region_D_LOADER_STACK_end__ ]; define symbol __region_BTCM_start__ = BTCM_PRV_START; define symbol __region_BTCM_end__ = BTCM_PRV_START + BTCM_PRV_LENGTH - 1; define region BTCM_region = mem:[from __region_BTCM_start__ to __region_BTCM_end__ ]; define symbol SYSTEM_RAM_END_OFFSET = 0x00048000;// 256K+32K //RAM define symbol SYSTEM_RAM_PRV_START = 0x10000000; define symbol SYSTEM_RAM_PRV_LENGTH = 0x180000; //1.5M define symbol __region_SYSTEM_RAM_start__ = SYSTEM_RAM_PRV_START; define symbol __region_SYSTEM_RAM_end__ = SYSTEM_RAM_PRV_START + SYSTEM_RAM_PRV_LENGTH - SYSTEM_RAM_END_OFFSET - 1; define region SYSTEM_RAM_region = mem:[from __region_SYSTEM_RAM_start__ to __region_SYSTEM_RAM_end__ ]; define symbol SYSTEM_RAM_MIRROR_PRV_START = 0x30000000; define symbol SYSTEM_RAM_MIRROR_PRV_LENGTH = 0x180000; //1.5M define symbol __region_SYSTEM_RAM_MIRROR_start__ = SYSTEM_RAM_MIRROR_PRV_START; define symbol __region_SYSTEM_RAM_MIRROR_end__ = SYSTEM_RAM_MIRROR_PRV_START + SYSTEM_RAM_MIRROR_PRV_LENGTH - SYSTEM_RAM_END_OFFSET - 1; define region SYSTEM_RAM_MIRROR_region = mem:[from __region_SYSTEM_RAM_MIRROR_start__ to __region_SYSTEM_RAM_MIRROR_end__ ]; define symbol DATA_NONCACHE_OFFSET = 0x00048000; // 256K+32K define symbol DATA_NONCACHE_END_OFFSET = 0x00044000; // 256K+16K define symbol __region_DATA_NONCACHE_start__ = SYSTEM_RAM_MIRROR_PRV_START + SYSTEM_RAM_MIRROR_PRV_LENGTH - DATA_NONCACHE_OFFSET; define symbol __region_DATA_NONCACHE_end__ = SYSTEM_RAM_MIRROR_PRV_START + SYSTEM_RAM_MIRROR_PRV_LENGTH - DATA_NONCACHE_END_OFFSET - 1; define region DATA_NONCACHE_region = mem:[from __region_DATA_NONCACHE_start__ to __region_DATA_NONCACHE_end__ ]; define symbol DMAC_LINK_MODE_OFFSET = 0x00044000; // 256K+16K define symbol DMAC_LINK_MODE_END_OFFSET = 0x00040000; // 256K define symbol __region_DMAC_LINK_MODE_start__ = SYSTEM_RAM_MIRROR_PRV_START + SYSTEM_RAM_MIRROR_PRV_LENGTH - DMAC_LINK_MODE_OFFSET; define symbol __region_DMAC_LINK_MODE_end__ = SYSTEM_RAM_MIRROR_PRV_START + SYSTEM_RAM_MIRROR_PRV_LENGTH - DMAC_LINK_MODE_END_OFFSET - 1; define region DMAC_LINK_MODE_region = mem:[from __region_DMAC_LINK_MODE_start__ to __region_DMAC_LINK_MODE_end__ ]; define symbol __region_SHARED_NONCACHE_BUFFER_start__ = SYSTEM_RAM_MIRROR_PRV_START + SYSTEM_RAM_MIRROR_PRV_LENGTH - 0x00040000; // 256K define symbol __region_SHARED_NONCACHE_BUFFER_end__ = SYSTEM_RAM_MIRROR_PRV_START + SYSTEM_RAM_MIRROR_PRV_LENGTH - 0x00020000 - 1; // 128K define region SHARED_NONCACHE_BUFFER_region = mem:[from __region_SHARED_NONCACHE_BUFFER_start__ to __region_SHARED_NONCACHE_BUFFER_end__]; define symbol NONCACHE_BUFFER_OFFSET = 0x00020000; // 128K define symbol NONCACHE_BUFFER_END_OFFSET = 0; define symbol __region_NONCACHE_BUFFER_start__ = SYSTEM_RAM_MIRROR_PRV_START + SYSTEM_RAM_MIRROR_PRV_LENGTH - NONCACHE_BUFFER_OFFSET; define symbol __region_NONCACHE_BUFFER_end__ = SYSTEM_RAM_MIRROR_PRV_START + SYSTEM_RAM_MIRROR_PRV_LENGTH - NONCACHE_BUFFER_END_OFFSET - 1; define region NONCACHE_BUFFER_region = mem:[from __region_NONCACHE_BUFFER_start__ to __region_NONCACHE_BUFFER_end__ ]; //define symbol xSPI0_CS0_SPACE_MIRROR_PRV_START = 0x40000000; //define symbol xSPI0_CS0_SPACE_MIRROR_PRV_LENGTH = 0x4000000; //define symbol __region_XSPI0_CS0_MIRROR_start__ = xSPI0_CS0_SPACE_MIRROR_PRV_START; //define symbol __region_XSPI0_CS0_MIRROR_end__ = xSPI0_CS0_SPACE_MIRROR_PRV_START + xSPI0_CS0_SPACE_MIRROR_PRV_LENGTH - 1; //define region XSPI0_CS0_MIRROR_region = mem:[from __region_XSPI0_CS0_MIRROR_start__ to __region_XSPI0_CS0_MIRROR_end__ ]; define symbol xSPI0_CS0_SPACE_PRV_START = 0x60000000; //define symbol xSPI0_CS0_SPACE_PRV_LENGTH = 0x4000000; //define symbol __region_XSPI0_CS0_start__ = xSPI0_CS0_SPACE_PRV_START; //define symbol __region_XSPI0_CS0_end__ = xSPI0_CS0_SPACE_PRV_START + xSPI0_CS0_SPACE_PRV_LENGTH - 1; //define region XSPI0_CS0_region = mem:[from __region_XSPI0_CS0_start__ to __region_XSPI0_CS0_end__ ]; define symbol FLASH_ADDRESS = xSPI0_CS0_SPACE_PRV_START; define symbol __ICFEDIT_region_ROM_start__ = FLASH_ADDRESS + 0x20100; //128K + 256字节 define symbol __ICFEDIT_region_ROM_end__ = FLASH_ADDRESS + 0x6FFFF; //448K (+64=512) +320K define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__ ]; //if (_boot_mode_){ //define symbol FLASH_ADDRESS = xSPI0_CS0_SPACE_PRV_START; //boot //}else{ //define symbol FLASH_ADDRESS = xSPI0_CS0_SPACE_PRV_START+0x100000; //app //} /************** SPI boot mode setting **************/ define symbol __region_LDR_PARAM_start__ = FLASH_ADDRESS; define symbol __region_LDR_PARAM_end__ = FLASH_ADDRESS + 0x0000004B; // +75 define region LDR_PARAM_region = mem:[from __region_LDR_PARAM_start__ to __region_LDR_PARAM_end__ ]; define symbol __region_S_LOADER_STACK_start__ = FLASH_ADDRESS + 0x0000004C; // 76 define symbol __region_S_LOADER_STACK_end__ = FLASH_ADDRESS + 0x0000804B; // +32K define region S_LOADER_STACK_region = mem:[from __region_S_LOADER_STACK_start__ to __region_S_LOADER_STACK_end__ ]; define symbol __region_S_intvec_start__ = FLASH_ADDRESS + 0x20000; //128K define symbol __region_S_intvec_end__ = FLASH_ADDRESS + 0x200FF; // +255 define region S_intvec_region = mem:[from __region_S_intvec_start__ to __region_S_intvec_end__ ]; define symbol __region_S_RAM_start__ = FLASH_ADDRESS + 0x70000; //448K define symbol __region_S_RAM_end__ = FLASH_ADDRESS + 0x7FFFF; // +64K define region S_RAM_region = mem:[from __region_S_RAM_start__ to __region_S_RAM_end__ ]; /****************************************************/ define block LDR_PRG_RBLOCK with fixed order { ro code section .loader_text_init object startup_core.o, ro code object startup_core.o, ro code object system_core.o, ro code object startup.o, ro code object system.o, ro code object bsp_clocks.o, ro code object bsp_irq_core.o, ro code object bsp_irq.o, ro code object bsp_register_protection.o, ro code object r_ioport.o, ro code object bsp_cache.o, ro code section .warm_start_init } except { ro code section .intvec_init, ro code section .reset_handler_init }; define block LDR_PRG_WBLOCK with fixed order { rw code section .loader_text object startup_core.o, rw code object startup_core.o, rw code object system_core.o, rw code object startup.o, rw code object system.o, rw code object bsp_clocks.o, rw code object bsp_irq_core.o, rw code object bsp_irq.o, rw code object bsp_register_protection.o, rw code object r_ioport.o, rw code object bsp_cache.o, rw code section .warm_start } except { rw code section .intvec, rw code section .reset_handler }; define block LDR_DATA_ZBLOCK with alignment = 4 { section .bss object startup_core.o, section .bss object system_core.o, section .bss object startup.o, section .bss object system.o, section .bss object bsp_clocks.o, section .bss object bsp_irq_core.o, section .bss object bsp_irq.o, section .bss object bsp_register_protection.o, section .bss object r_ioport.o, section .bss object bsp_cache.o, section .bss object bsp_io.o }; define block LDR_DATA_RBLOCK with fixed order, alignment = 4 { section .data_init object startup_core.o, section .data_init object system_core.o, section .data_init object startup.o, section .data_init object system.o, section .data_init object bsp_clocks.o, section .data_init object bsp_irq_core.o, section .data_init object bsp_irq.o, section .data_init object bsp_register_protection.o, section .data_init object r_ioport.o, section .data_init object bsp_cache.o, section .rodata_init object system_core.o }; define block LDR_DATA_WBLOCK with fixed order, alignment = 4 { section .data object startup_core.o, section .data object system_core.o, section .data object startup.o, section .data object system.o, section .data object bsp_clocks.o, section .data object bsp_irq_core.o, section .data object bsp_irq.o, section .data object bsp_register_protection.o, section .data object r_ioport.o, section .data object bsp_cache.o, section .rodata object system_core.o }; define block HEAP_BLOCK with alignment = 8 { rw section HEAP }; define block THREAD_STACK with alignment = 8 { rw section .stack* }; define block SYS_STACK with alignment = 8 { rw section .sys_stack }; define block SVC_STACK with alignment = 8 { rw section .svc_stack }; define block IRQ_STACK with alignment = 8 { rw section .irq_stack }; define block FIQ_STACK with alignment = 8 { rw section .fiq_stack }; define block UND_STACK with alignment = 8 { rw section .und_stack }; define block ABT_STACK with alignment = 8 { rw section .abt_stack }; define block VECTOR_RBLOCK with alignment = 32 { ro code section .intvec_init}; define block VECTOR_WBLOCK with alignment = 32 { rw code section .intvec }; define block USER_PRG_RBLOCK with alignment = 4 { ro code }; define block USER_PRG_WBLOCK with alignment = 4 { rw code }; define block USER_DATA_ZBLOCK with alignment = 4 { section .bss }; define block USER_DATA_RBLOCK with fixed order, alignment = 4 { section .data_init, section __DLIB_PERTHREAD_init, section .rodata_init, section .version_init }; define block USER_DATA_WBLOCK with fixed order, alignment = 4 { section .data, section __DLIB_PERTHREAD, section .rodata, section .version }; define block USER_DATA_NONCACHE_RBLOCK with alignment = 4 { section .data_noncache_init }; define block USER_DATA_NONCACHE_WBLOCK with alignment = 4 { section .data_noncache }; define block DMAC_LINK_MODE_ZBLOCK with alignment = 4 { section .dmac_link_mode* }; define block SHARED_NONCACHE_BUFFER_ZBLOCK with alignment = 32 { section .shared_noncache_buffer* }; define block NONCACHE_BUFFER_ZBLOCK with alignment = 32 { section .noncache_buffer* }; ///////////////////////////////////////////////////////////////////////////////////////////////// place at address mem: __ICFEDIT_intvec_start__ { block VECTOR_WBLOCK }; place at start of S_LOADER_STACK_region { block LDR_PRG_RBLOCK }; place at start of D_LOADER_STACK_region { block LDR_PRG_WBLOCK }; place in LDR_PARAM_region { readonly section .loader_param }; place in ROM_region { block USER_PRG_RBLOCK , readonly }; place in S_RAM_region { block USER_DATA_RBLOCK , block USER_DATA_NONCACHE_RBLOCK }; place in S_intvec_region { block VECTOR_RBLOCK }; place in S_LOADER_STACK_region { section LDR_DATA_RBLOCK, block LDR_DATA_RBLOCK }; place in D_LOADER_STACK_region { section LDR_DATA_WBLOCK, block LDR_DATA_WBLOCK, section LDR_DATA_ZBLOCK, block LDR_DATA_ZBLOCK }; place in D_LOADER_STACK_region { section SYS_STACK, block SYS_STACK, section SVC_STACK, block SVC_STACK, section IRQ_STACK, block IRQ_STACK, section FIQ_STACK, block FIQ_STACK, section UND_STACK, block UND_STACK, section ABT_STACK, block ABT_STACK }; place in SYSTEM_RAM_MIRROR_region { readwrite }; place in SYSTEM_RAM_MIRROR_region { block USER_PRG_WBLOCK }; place in SYSTEM_RAM_MIRROR_region { block USER_DATA_WBLOCK, block USER_DATA_ZBLOCK }; place in SYSTEM_RAM_MIRROR_region { section HEAP_BLOCK , block HEAP_BLOCK, section THREAD_STACK , block THREAD_STACK }; place in DATA_NONCACHE_region { block USER_DATA_NONCACHE_WBLOCK }; place in DMAC_LINK_MODE_region { block DMAC_LINK_MODE_ZBLOCK }; place in SHARED_NONCACHE_BUFFER_region { block SHARED_NONCACHE_BUFFER_ZBLOCK }; place in NONCACHE_BUFFER_region { block NONCACHE_BUFFER_ZBLOCK }; //-place in ATCM_region { }; //-place in BTCM_region { }; //-place in SYSTEM_RAM_region { }; //-place in SYSTEM_RAM_MIRROR_region { }; //-place in XSPI0_CS0_MIRROR_region { }; //-place in XSPI0_CS0_region { }; initialize manually { ro code object startup_core.o, ro code object system_core.o , ro code object startup.o , ro code object system.o , ro code object bsp_clocks.o , ro code object bsp_irq_core.o , ro code object bsp_irq.o, ro code object bsp_register_protection.o, ro code object r_ioport.o, ro code object bsp_cache.o, ro code section .intvec, ro code section .reset_handler, ro code section .warm_start, ro code, section .data, section __DLIB_PERTHREAD, section .rodata, section .version, section .data_noncache }; do not initialize { section .noinit, section .bss, section .dmac_link_mode*, section .shared_noncache_buffer*, section .noncache_buffer*, rw section HEAP, rw section .stack*, rw section .sys_stack, rw section .svc_stack, rw section .irq_stack, rw section .fiq_stack, rw section .und_stack, rw section .abt_stack };
https://gitee.com/powes/,作者:前沿风暴,转载请注明原文链接:https://www.cnblogs.com/Kreos/p/19162108