RT1052 BootLoader总结
rt1052 bootloader总结
-
概述
bootloader涉及到的rt1052单片机资源有:cache,ram,外部sdram,arm7汇编指令,外部dataflash.
升级功能涉及到的其他功能有:服务器存贮和传输升级bin文件;上位机接收和发送bin文件;判断升级是否成功和提示。
-
流程图
-
app程序与bootloader程序不同的地方总结如下
3.1 xxx.s启动文件增加了如下区域
area |.ram_vtor_table|, data, readonly
import |image$$arm_lib_stack$$zi$$limit|
r_vectors dcd |image$$arm_lib_stack$$zi$$limit| ; top of stack
dcd reset_handler ; reset handler
dcd nmi_handler ;nmi handler
《mimxrt1052xxxxx_flexspi_nor_sdram.scf》
#define m_itcm_vectors_start 0x00000000
#define m_itcm_vectors_size 0x00000400
#define m_itcm_start 0x00000400
#define m_itcm_size 0x0001fc00
rw_vectors_data m_itcm_vectors_start m_itcm_vectors_size { ; rw data
startup_mimxrt1052.o (.ram_vtor_table)
}
arm_lib_heap +0 empty heap_size { ; heap region growing up
}
arm_lib_stack m_data_start+m_data_size empty -stack_size { ; stack region growing down
}
3.2 evkbimxrt1050_flexspi_nor.ini更改sp,pc
sp = _rdword(0x60008000); // setup stack pointer
pc = _rdword(0x60008004); // setup program counter
_wdword(0xe000ed08, 0x60008000); // setup vector table offset register
3.3 ***.scf分散加载文件更改
#define m_interrupts_start 0x60008000
#define m_interrupts_size 0x00000400
3.4 target-->user,生成bin,命令。
run1:fromelf.exe --bincombined --bincombined_base=0x60008000 --output "$l@l.bin" "$l@l.out"
run2:fromelf.exe --m32 --output "$l@l.srec" "#l"
3.5 linker:设置改变:
-
--remove
-
--keep=*(.boot_hdr.ivt)
-
--keep=*(.boot_hdr.boot_data)
-
--keep=*(.boot_hdr.dcd_data)
-
--keep=*(.boot_hdr.conf)
-
--keep=*(noncacheable)
-
--keep=*(m_usb_dma_init_data)
--predefine="-dxip_boot_header_enable=1"
改为:
--remove
--keep=*(.ram_vtor_table)
--predefine="-dxip_boot_header_enable=1"
3.6应用程序初始化里面的sdram的初始化一定要去掉!!
// /* set semc_podf. */
// clock_setdiv(kclock_semcdiv, 7);
// /* set semc alt clock source. */
// clock_setmux(kclock_semcaltmux, 0);
// /* set semc clock source. */
// clock_setmux(kclock_semcmux, 0);
3.8 main函数里面:增加
__disable_irq();
scb->vtor = 0x00000000; //enable itcm vectors table
__enable_irq();
4.0 keil报错处理:"flexspi_nor_debug\cgaaxf.out": error: q0471e: base address 0x60008000 is above start address 0x60000000 of load region #0
处理办法: 删掉输出文件夹里面的*.bin文件。
4.1需要深入研究的地方有:
__isb();
__dsb();
/* enable i cache and d cache */
scb_disabledcache();
scb_disableicache();
vcontrolswitch();
已经确认,vcontrolswitch();之前,必须关闭cache。创造一个干净的环境。
bootloader打印信息如下:
start xmodem1k client.
app sp:0x81d00000.
app pc:0x6000863d.
mcu ready to recv data...
cccccccccccccccccccc
wait timeout,jump app.
------------------------------------------
app sp:0x81d00000.
app pc:0x60008415.
mcu ready to recv data...
wait timeout,jump app.
------------------------------------------
20181217 two int main2(void) : 0x6000a6b5.
pc:0x6000a6b5
技术咨询请加微信:18124528727