STM32系列代码嵌入固件可用空间

STM32系列
pyboard相关
回复
ethan_can
帖子: 5
注册时间: 2022年 1月 19日 17:23

STM32系列代码嵌入固件可用空间

#1

帖子 ethan_can »

如题,目前为了保护代码,想自己编译Micropython固件,将代码藏入固件中,但未知我具体允许能放入的代码内存占用量,以STM32 F405  PYB11官方板为例,闪存是1M的,那么允许我在固件添加多大容量的代码?如果通过修改固件中的分区空间量,该如何修改?

头像
shaoziyang
帖子: 3917
注册时间: 2019年 10月 21日 13:48

Re: STM32系列代码嵌入固件可用空间

#2

帖子 shaoziyang »

分区地址在 ld 文件中设置,例如405的ld文件( \micropython\ports\stm32\boards\stm32f405.ld)是:

 
/*
    GNU linker script for STM32F405
*/

/* Specify the memory areas */
MEMORY
{
    FLASH (rx)      : ORIGIN = 0x08000000, LENGTH = 1024K /* entire flash */
    FLASH_ISR (rx)  : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */
   FLASH_FS (rx)   : ORIGIN = 0x08004000, LENGTH = 112K /* sectors 1,2,3,4 are for filesystem */
    FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 896K /* sectors 5,6,7,8,9,10,11 */
    CCMRAM (xrw)    : ORIGIN = 0x10000000, LENGTH = 64K
    RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 128K
}

/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 2K;
_minimum_heap_size = 16K;

/* Define the stack.  The stack is full descending so begins just above last byte
   of RAM.  Note that EABI requires the stack to be 8-byte aligned for a call. */
_estack = ORIGIN(RAM) + LENGTH(RAM) - _estack_reserve;
_sstack = _estack - 16K; /* tunable */

/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
_heap_start = _ebss; /* heap starts just after statically allocated memory */
_heap_end = _sstack;

 
 
 
 
 

gs001588
帖子: 1559
注册时间: 2019年 11月 6日 00:06

Re: STM32系列代码嵌入固件可用空间

#3

帖子 gs001588 »

刚看了下STM32F405的数据手册,sectors 5,6,7,8,9,10,11每个大小128K,看来只能作为系统ROM或缓存用;sector 0(16K)作为中断向量表和系统启动代码用;留给用户文件系统的也就只能是sectors 1,2,3,4这段区间,(1、2、3为16K,4为64K),如果5到11要用作文件系统的话,要擦除或修改一下某个单元的数据就比较麻烦。
一切反动派都是纸老虎。看起来,反动派的样子是可怕的,但是实际上并没有什么了不起的力量。从长远的观点看问题,真正强大的力量不是属于反动派,而是属于人民。

回复

  • 随机主题
    回复总数
    阅读次数
    最新文章