cisen / blog

Time waits for no one.
135 stars 20 forks source link

tockloader 源码相关 #906

Open cisen opened 4 years ago

cisen commented 4 years ago

https://github.com/cisen/sourcecode-tockloader-00

问答

tbf的安装内存是如何确定的?

每次安装app都需要重装一次系统?

MPU_MIN_ALIGN = 8K;

- app的烧录地址是tockloader解析tbf文件计算得到的

**openocd flash的address是如何计算的?**
- 在`tockloader\board_interface.py`的`get_apps_start_address`函数,获取tbf的appaddr字段,默认地址是0x30000
- 各个板子可以根据自己的情况定内存位置,自定义是在`tockloader\board_interface.py`的`'apps_start_address': 0x20430000,`配置

**所有app flash进去的地址都是30000?**
- 是的,[tockloader](https://github.com/tock/tockloader/blob/5f0ea486c717106c430d66f9c75b0c4489f0bb3c/tockloader/main.py#L542),使用虚拟内存,每个进程一个页目录
- tock说明

╔═══════════╤══════════════════════════════════════════╗ ║ Address │ Region Name Used | Allocated (bytes) ║ ╚0x20006000═╪══════════════════════════════════════════╝ │ ▼ Grant 948 | 948 0x20005C4C ┼─────────────────────────────────────────── │ Unused 0x200049F0 ┼─────────────────────────────────────────── │ ▲ Heap 0 | 4700 S 0x200049F0 ┼─────────────────────────────────────────── R │ Data 496 | 496 A 0x20004800 ┼─────────────────────────────────────────── M │ ▼ Stack 72 | 2048 0x200047B8 ┼─────────────────────────────────────────── │ Unused 0x20004000 ┴─────────────────────────────────────────── ..... 0x00030400 ┬─────────────────────────────────────────── F │ App Flash 976 L 0x00030030 ┼─────────────────────────────────────────── A │ Protected 48 S 0x00030000 ┴─────────────────────────────────────────── H

- 在tock里面的各个layout.id文件都声明:
```id
/* Memory Spaces Definitions, 448K flash, 64K ram */
/* Bootloader is at address 0x00000000 */
MEMORY
{
  rom (rx)  : ORIGIN = 0x00010000, LENGTH = 0x00020000
  prog (rx) : ORIGIN = 0x00030000, LENGTH = 0x00040000
  ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00020000
}

MPU_MIN_ALIGN = 8K;
Address Range Length (bytes) Content Description
0x0-3FF 1024 Bootloader Reserved flash for the bootloader. Likely the vector table.
0x400-0x5FF 512 Flags Reserved space for flags. If the bootloader is present, the first 14 bytes are "TOCKBOOTLOADER".
0x600-0x9FF 1024 Attributes Up to 16 key-value pairs of attributes that describe the board and the software running on it.
0xA00-0xFFFF 61.5k Bootloader The software bootloader provides non-JTAG methods of programming the kernel and applications.
0x10000-0x2FFFF 128k Kernel Flash space for the kernel.
0x30000-0x7FFFF 320k Apps Flash space for applications.

RAM

Address Range Length (bytes) Content Description
0x20000000-0x2000FFFF 64k Kernel and app RAM The kernel links with all of the RAM, and then allocates a buffer internally for application use.

多个app是如何flash的?