STM32F10X MCU U-boot porting

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 分配图
addressusage
0x2000e000 ~0x20010000u-boot .data and .bss section
0x20008000 ~ 0x2000e000malloc buffer
0x20008000-sizeof(BD)-sizeof(GD) ~ 0x20008000BD + GD
0x20000000~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.

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值