|
| 1 | +## wolfBoot port for rp2350 (Raspberry pi pico 2) |
| 2 | + |
| 3 | +### Requirements |
| 4 | + |
| 5 | +#### External debugger |
| 6 | + |
| 7 | +As the two images (bootloader + application) are stored in different areas in |
| 8 | +the flash memory, a SWD connector is required to upload the binary images into |
| 9 | +the flash, as opposed to the default bootloader, allowing to upload non-signed |
| 10 | +applications into a storage device |
| 11 | + |
| 12 | +#### PicoSDK |
| 13 | + |
| 14 | +Clone the repository from raspberrypi's github: |
| 15 | + |
| 16 | +``` |
| 17 | +git clone https://github.com/raspberrypi/pico-sdk.git |
| 18 | +``` |
| 19 | + |
| 20 | +Export the `PICO_SDK_PATH` environment variable to point to the pico-sdk directory: |
| 21 | + |
| 22 | +``` |
| 23 | +export PICO_SDK_PATH=/path/to/pico-sdk |
| 24 | +``` |
| 25 | + |
| 26 | +### Configuring wolfBoot to build with pico-sdk |
| 27 | + |
| 28 | +From wolfBoot root directory, copy the example configuration: |
| 29 | + |
| 30 | +``` |
| 31 | +cp config/examples/rp2350.config .config |
| 32 | +``` |
| 33 | + |
| 34 | +By default, the config file indicates the following partition layout: |
| 35 | + |
| 36 | +``` |
| 37 | +wolfBoot partition: 256 KB, at address 0x10000000 to 0x1003FFFF |
| 38 | +Boot partition: 768 KB, at address 0x10040000 to 0x1007FFFF |
| 39 | +Update partition: 768 KB, at address 0x10100000 to 0x1013FFFF |
| 40 | +Swap space: 4 KB, at address 0x101C0000 to 0x101C0FFF |
| 41 | +Unused flash space: 252 KB, at address 0x101C1000 to 0x101FFFFF |
| 42 | +``` |
| 43 | + |
| 44 | +You can now edit the .config file to change partition sizes/offsets, algorithms, |
| 45 | +add/remove features, etc. |
| 46 | + |
| 47 | +When the configuration is complete, run `make`. This will: |
| 48 | + |
| 49 | +- Build the key tools (keygen & sign): |
| 50 | +- Generate the configuration header `target.h` |
| 51 | +- Generate a new keypair (only once), and place the public key in the |
| 52 | +keystore |
| 53 | + |
| 54 | +The environment has now been prepared to build and flash the two images |
| 55 | +(wolfBoot + test application). |
| 56 | + |
| 57 | +### Building and uploading wolfBoot.bin |
| 58 | + |
| 59 | +After preparing the configuration and creating the keypair, |
| 60 | +return to this directory and run: |
| 61 | + |
| 62 | +``` |
| 63 | +cd wolfboot |
| 64 | +./build-wolfboot.sh |
| 65 | +``` |
| 66 | + |
| 67 | +The script above will compile wolfboot as rp2350 second-stage bootloader. |
| 68 | +This version of wolfboot incorporates the `.boot2` sequence needed to enable |
| 69 | +the QSPI device, provided by the pico-sdk and always embedded in all |
| 70 | +applications. |
| 71 | + |
| 72 | +wolfboot.bin contains the bootloader, configured as follows: |
| 73 | + |
| 74 | +### Building and uploading the application |
| 75 | + |
| 76 | +``` |
| 77 | +cd test-app |
| 78 | +./build-signed-app.sh |
| 79 | +``` |
| 80 | +The script above will compile the test application and sign it with the |
| 81 | +wolfBoot private key. The signed application is then uploaded to the boot |
| 82 | +partition of the flash memory, at address 0x10040000. |
| 83 | + |
| 84 | +The linker script included is modified to change the application entry point |
| 85 | +from 0x10000000 to 0x10040400, which is the start of the application code, |
| 86 | +taking into account the wolfBoot header size. |
| 87 | + |
| 88 | + |
| 89 | +### Testing the application |
| 90 | + |
| 91 | +The application is a simple blinky example, which toggles the LED on the board |
| 92 | +every 500ms. |
| 93 | + |
| 94 | +If the above steps are successful, the LED on the board should start blinking. |
| 95 | + |
0 commit comments