本文基于Zephyr起步(原生)和nrf52840dk_nrf52840开发板
目录
配置
mcuboot
1 2 3 4
| vim ~/zephyrproject/bootloader/mcuboot/boot/zephyr/prj.conf
|
makefile
1
| cd ~/zephyrproject/bootloader/mcuboot/samples/zephyr
|
- 上述修改保持和开发板设备树(flash0)配置一致
1
| cat ~/zephyrproject/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| &flash0 { partitions { boot_partition: partition@0 { label = "mcuboot"; reg = <0x000000000 0x0000C000>; }; slot0_partition: partition@c000 { label = "image-0"; reg = <0x0000C000 0x00067000>; }; slot1_partition: partition@73000 { label = "image-1"; reg = <0x00073000 0x00067000>; }; }; };
|
1 2 3 4 5 6 7 8 9 10 11
| flash_boot: $(PYOCD) flash -a 0 mcuboot.bin --target nrf52840
flash_hello1: $(PYOCD) flash -a 0xc000 signed-hello1.bin --target nrf52840
flash_hello2: $(PYOCD) flash -a 0x73000 signed-hello2.bin --target nrf52840
flash_full: $(PYOCD) flash -e chip -a 0 full.bin --target nrf52840
|
1 2 3 4
| pip3 install -U pyocd
pyocd -V
|
运行
1 2 3 4 5 6 7
| cd ~/zephyrproject/bootloader/mcuboot/samples/zephyr
make clean
make full.bin BOARD=nrf52840dk_nrf52840
make flash_full
|
![zephyr-bootloader-01.png](/images/2022/05/zephyr-bootloader-01.png)
![zephyr-bootloader-02.png](/images/2022/05/zephyr-bootloader-02.png)
![zephyr-bootloader-03.png](/images/2022/05/zephyr-bootloader-03.png)
工具
- readelf - display information about ELF files
1 2 3
| brew install binutils
readelf -S build/nrf52840dk_nrf52840/hello2/zephyr/zephyr.elf
|
1 2 3 4 5 6 7
| There are 27 section headers, starting at offset 0xa32e4:
Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] rom_start PROGBITS 0000c000 0000c0 000300 00 WAX 0 0 4 [ 2] text PROGBITS 0000c300 0003c0 0045fc 00 AX 0 0 4
|
- hexinfo - summarize a hex file’s contents
1 2 3
| pip3 install -U intelhex
hexinfo.py build/nrf52840dk_nrf52840/hello2/zephyr/zephyr.hex
|
1 2 3 4
| - file: 'build/nrf52840dk_nrf52840/hello2/zephyr/zephyr.hex' entry: 0x0000D6BD data: - { first: 0x0000C000, last: 0x00010E27, length: 0x00004E28 }
|
参考