Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tockloader 源码相关 #906

Open
cisen opened this issue May 31, 2020 · 0 comments
Open

tockloader 源码相关 #906

cisen opened this issue May 31, 2020 · 0 comments

Comments

@cisen
Copy link
Owner

cisen commented May 31, 2020

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

问答

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

  • tockloader\tab.py的extract_app函数是解析tbf文件的入口
  • tbf文件解析的关键在tockloader\tbfh.py的header的初始化函数,它解析了tab的所有信息
  • 解析完tbf就会调用_reshuffle_apps开始烧录app
  • 根据链接的类型,使用flash_binary调用硬件串口接口jlink版openocd版,使用openocd等命令将app烧录进主板

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

  • 不是,链接id里面声明了app的安装地址,初始化进程的时候就会从该地址读取进程数据。而操作系统是0x000000的地址,比如
# boards/nordic/nrf52dk/chip_layout.ld
/* Memory Space Definitions, 512K flash, 64K ram */
MEMORY
{
  rom (rx)  : ORIGIN = 0x00000000, LENGTH = 192K
  prog (rx) : ORIGIN = 0x00030000, LENGTH = 320K
  ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
}

MPU_MIN_ALIGN = 8K;
  • app的烧录地址是tockloader解析tbf文件计算得到的

openocd flash的address是如何计算的?

  • tockloader\board_interface.pyget_apps_start_address函数,获取tbf的appaddr字段,默认地址是0x30000
  • 各个板子可以根据自己的情况定内存位置,自定义是在tockloader\board_interface.py'apps_start_address': 0x20430000,配置

所有app flash进去的地址都是30000?

  • 是的,tockloader,使用虚拟内存,每个进程一个页目录
  • 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文件都声明:
/* 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;
  • tock的内存官方声明

Flash

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的?

  • _reshuffle_apps函数,如果已经安装到板子上的,它还会从板子上重新读取bin数据,然后重新烧录
  • 大部分的烧录的开始地址都是0x30000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant