STM32F10X MCU U-boot porting

来源:互联网 发布:域名注册的流程 编辑:程序博客网 时间:2024/06/07 20:48

U-boot version:

GIT clone git://git.denx.de/u-boot.git

Tag: 2016.01-rc1

ARM GCC: arm-none-eabi-gcc 5.2.1


STM32F10X MCU has no DDR. And it has only 64KB SRAM.

The first step of the porting is to re-design the U-boot address space.

What I do is:

1.Keep .text and .rodata section in the MCU internal NOR flash.

2.Just move the .data and .bss section into the SRAM and use 8KB top address SRAM.

3.Malloc buffer use 24KB SRAM and follows .data section.

4.GD and LD follows malloc buffer.

5.SP follows GD.

u-boot SRAM 分配图addressusage0x2000e000 ~0x20010000u-boot .data and .bss section0x20008000 ~ 0x2000e000malloc buffer0x20008000-sizeof(BD)-sizeof(GD) ~ 0x20008000BD + GD0x20000000~0x20008000-sizeof(BD)-sizeof(GD)SP stack, 底部从0x20000000可以用来干别的.


The the steps to implement it:

1. Disable U-boot relocate feature. Refer to my another blog。

2. 重新安排U-boot.lds里的段排列,把.data 和 .bss段排在一起并且使用SRAM的地址链接。其他段放在一起并使用NOR flash地址。下面列出例子。

MEMORY{ NVM (r): ORIGIN = (0x08000000 + 0x0), LENGTH = ((256 * 1024) - 0x0) RAM (rw): ORIGIN = 0x2000e000, LENGTH = (8 * 1024)}SECTIONS{  .text : {  *(.text)  *(.rodata*) } >NVM .data : {  _data_start = .;  _data_lma_start = LOADADDR(.data);  *(.data)  . = ALIGN(4);  *(.ramcode)  _data_end = .; } >RAM AT>NVM  .bss : {  _bss_start = .;  *(.bss)  *(COMMON)  _bss_end = .; } >RAM }
注意在board_f.c 中有很多reserve buffer的函数在init_sequence_r[]数组中,要注意按照定义的SRAM分配图来修改对应的reserve函数。
同时可以把很多大的常量移入rodata段,比如数组init_sequence_r[] 和 env_hel_text[] 。 在他们的定义上加上const关键字,他们就会被放在.rodata段。

3. Remove unnecessary commands and drivers to minimize the binary size. This is on configs/STM32F1XX_defconfig.

4. rewrite the data relocation function and make it be call at very beginning of the boot.

@Modified the relocate_code function in arch/arm/lib/relocation.S

@call it at _main in arch/arm/lib/crt0.S

5. Define the section and buffer size on include/configs/stm32f10x.h

6. Port clock configure functions on my board.

7. Port UART configure functions on my board.


Done.

0 0
原创粉丝点击