|
| 1 | +# Targets |
| 2 | + |
| 3 | +## STM32-F407 |
| 4 | + |
| 5 | +Example 512KB partitioning on STM32-F407 |
| 6 | + |
| 7 | +The example firmware provided in the `test-app` is configured to boot from the primary partition |
| 8 | +starting at address 0x20000. The flash layout is provided by the default example using the following |
| 9 | +configuration in `target.h`: |
| 10 | + |
| 11 | +```C |
| 12 | +#define WOLFBOOT_SECTOR_SIZE 0x20000 |
| 13 | +#define WOLFBOOT_PARTITION_SIZE 0x20000 |
| 14 | + |
| 15 | +#define WOLFBOOT_PARTITION_BOOT_ADDRESS 0x20000 |
| 16 | +#define WOLFBOOT_PARTITION_UPDATE_ADDRESS 0x40000 |
| 17 | +#define WOLFBOOT_PARTITION_SWAP_ADDRESS 0x60000 |
| 18 | +``` |
| 19 | +
|
| 20 | +This results in the following partition configuration: |
| 21 | +
|
| 22 | + |
| 23 | +
|
| 24 | +This configuration demonstrates one of the possible layouts, with the slots |
| 25 | +aligned to the beginning of the physical sector on the flash. |
| 26 | +
|
| 27 | +The entry point for all the runnable firmware images on this target will be `0x20100`, |
| 28 | +256 Bytes after the beginning of the first flash partition. This is due to the presence |
| 29 | +of the firmware image header at the beginning of the partition, as explained more in details |
| 30 | +in [Firmware image](firmware_image.md) |
| 31 | +
|
| 32 | +In this particular case, due to the flash geometry, the swap space must be as big as 64KB, to account for proper sector swapping between the two images. |
| 33 | +
|
| 34 | +On other systems, the SWAP space can be as small as 512B, if multiple smaller flash blocks are used. |
| 35 | +
|
| 36 | +More information about the geometry of the flash and in-application programming (IAP) can be found in the manufacturer manual of each target device. |
| 37 | +
|
| 38 | +
|
| 39 | +## SiFive HiFive1 RISC-V |
| 40 | +
|
| 41 | +### Features |
| 42 | +* E31 RISC-V 320MHz 32-bit processor |
| 43 | +* Onboard 16KB scratchpad RAM |
| 44 | +* External 4MB QSPI Flash |
| 45 | +
|
| 46 | +### Default Linker Settings |
| 47 | +* FLASH: Address 0x20000000, Len 0x6a120 (424 KB) |
| 48 | +* RAM: Address 0x80000000, Len 0x4000 (16 KB) |
| 49 | +
|
| 50 | +### Stock bootloader |
| 51 | +Start Address: 0x20000000 is 64KB. Provides a "double tap" reset feature to halt boot and allow debugger to attach for reprogramming. Press reset button, when green light comes on press reset button again, then board will flash red. |
| 52 | +
|
| 53 | +### Application Code |
| 54 | +Start Address: 0x20010000 |
| 55 | +
|
| 56 | +### wolfBoot configuration |
| 57 | +
|
| 58 | +The default wolfBoot configuration will add a second stage bootloader, leaving the stock "double tap" bootloader as a fallback for recovery. Your production implementation should replace this and partition addresses in `target.h` will need updated, so they are `0x10000` less. |
| 59 | +
|
| 60 | +For testing wolfBoot here are the changes required: |
| 61 | +
|
| 62 | +1. Makefile arguments: |
| 63 | + * ARCH=RISCV |
| 64 | + * TARGET=hifive1 |
| 65 | + |
| 66 | + ``` |
| 67 | + make ARCH=RISCV TARGET=hifive1 RAM_CODE=1 clean |
| 68 | + make ARCH=RISCV TARGET=hifive1 RAM_CODE=1 |
| 69 | + ``` |
| 70 | +
|
| 71 | + If using the `riscv64-unknown-elf-` cross compiler you can add `CROSS_COMPILE=riscv64-unknown-elf-` to your `make` or modify `arch.mk` as follows: |
| 72 | + |
| 73 | + ``` |
| 74 | + ifeq ($(ARCH),RISCV) |
| 75 | + - CROSS_COMPILE:=riscv32-unknown-elf- |
| 76 | + + CROSS_COMPILE:=riscv64-unknown-elf- |
| 77 | + ``` |
| 78 | +
|
| 79 | +
|
| 80 | +2. `include/target.h` |
| 81 | +
|
| 82 | +Bootloader Size: 0x10000 (64KB) |
| 83 | +Application Size 0x40000 (256KB) |
| 84 | +Swap Sector Size: 0x1000 (4KB) |
| 85 | +
|
| 86 | +```c |
| 87 | +#define WOLFBOOT_SECTOR_SIZE 0x1000 |
| 88 | +#define WOLFBOOT_PARTITION_BOOT_ADDRESS 0x20020000 |
| 89 | +
|
| 90 | +#define WOLFBOOT_PARTITION_SIZE 0x40000 |
| 91 | +#define WOLFBOOT_PARTITION_UPDATE_ADDRESS 0x20060000 |
| 92 | +#define WOLFBOOT_PARTITION_SWAP_ADDRESS 0x200A0000 |
| 93 | +``` |
| 94 | + |
| 95 | +### Build Options |
| 96 | + |
| 97 | +* To use ECC instead of ED25519 use make argument `SIGN=ECC256` |
| 98 | +* To output wolfboot as hex for loading with JLink use make argument `wolfboot.hex` |
| 99 | + |
| 100 | +### Loading |
| 101 | + |
| 102 | +Loading with JLink: |
| 103 | + |
| 104 | +``` |
| 105 | +JLinkExe -device FE310 -if JTAG -speed 4000 -jtagconf -1,-1 -autoconnect 1 |
| 106 | +loadbin factory.bin 0x20010000 |
| 107 | +rnh |
| 108 | +``` |
| 109 | +
|
| 110 | +### Debugging |
| 111 | +
|
| 112 | +Debugging with JLink: |
| 113 | +
|
| 114 | +In one terminal: |
| 115 | +`JLinkGDBServer -device FE310 -port 3333` |
| 116 | +
|
| 117 | +In another terminal: |
| 118 | +``` |
| 119 | +riscv64-unknown-elf-gdb wolfboot.elf -ex "set remotetimeout 240" -ex "target extended-remote localhost:3333" |
| 120 | +add-symbol-file test-app/image.elf 0x20020100 |
| 121 | +``` |
| 122 | +
|
| 123 | +``` |
| 124 | +riscv64-unknown-elf-objdump -D test-app/image.elf |
| 125 | +``` |
0 commit comments