|
| 1 | +## wolfBoot for Renesas RX72N |
| 2 | + |
| 3 | +``` |
| 4 | +MCU: Renesas RX72N |
| 5 | +Board: RX72N/Envision Kit |
| 6 | +IDE: e2Studio |
| 7 | +Compiler: CCRX |
| 8 | +FIT Module: r_flash_rx |
| 9 | +
|
| 10 | +Optional: |
| 11 | +Flash Wirter: Renesas Flash Programmer v3 |
| 12 | +
|
| 13 | +e2Studio Project: |
| 14 | +wolfBoot IDE/Renesas/e2studio_CCRX/wolfBoot |
| 15 | +Sample app IDE/Renesas/e2studio_CCRX/app_RenesasRX01 |
| 16 | +
|
| 17 | +Key tool: |
| 18 | +Key generation tools/keytools/keygen |
| 19 | +Signature tools/keytools/sign |
| 20 | +
|
| 21 | +Flash Allocation: |
| 22 | ++---------------------------+------------------------+-----+ |
| 23 | +| B |H| |H| | | |
| 24 | +| o |e| Primary |e| Update |Swap | |
| 25 | +| o |a| Partition |a| Partition |Sect | |
| 26 | +| t |d| |d| | | |
| 27 | ++---------------------------+------------------------+-----+ |
| 28 | +0xffc00000: wolfBoot |
| 29 | +0xffc10000: Primary partition (Header) |
| 30 | +0xffc10100: Primary partition (Application image) |
| 31 | +0xffdf0000: Update partition (Header) |
| 32 | +0xffdf0100: Update partition (Application image) |
| 33 | +0xfffd0000: Swap sector |
| 34 | +``` |
| 35 | + |
| 36 | +### Decription |
| 37 | +It has key tools running under the host environment such as Linux, Windows or MacOS. |
| 38 | +For comiling the tools, follow the instruction described in the user manual. |
| 39 | + |
| 40 | +It demonstrates simple secure firmware update by wolfBoot. A sample application v1 is |
| 41 | +cerurely updated to v2. Both versions behave the same except displaying its version of v1 or v2. |
| 42 | +They are compiled by e2Studio and running on the target board. |
| 43 | + |
| 44 | +In this demo, you may download two versions of application binary file by Renesas Flash Programmer. |
| 45 | +You can download and excute wolfBoot by e2Studio debugger. Use a USB connection between PC and the |
| 46 | +board for the debugger and flash programmer. |
| 47 | + |
| 48 | + |
| 49 | +### 1) Key generation |
| 50 | + |
| 51 | +``` |
| 52 | +$ export PATH:$PATH:<wolfBoot>/tools/keytools |
| 53 | +$ keygen --ed255519 -g ./pri-ed25519.der |
| 54 | +``` |
| 55 | + |
| 56 | +It generates a pair of private and public key with -g option. The private |
| 57 | +key is stored in the specified file. The public key is stored in a key store |
| 58 | +as a C source code soo that it can be compiled and linked with wolfBoot. |
| 59 | +If you have an existing key pair, you can use -i option to import the pablic |
| 60 | +key to the store. |
| 61 | + |
| 62 | +You can specify various signature algorithms such as |
| 63 | + |
| 64 | +``` |
| 65 | +--ed25519 --ed448 --ecc256 --ecc384 --ecc521 --rsa2048 --rsa3072 --rsa4096 |
| 66 | +``` |
| 67 | + |
| 68 | +### 2) Compile wolfBoot |
| 69 | + |
| 70 | +Open project under IDE/Renesas/e2studio_CCRX/wolfBoot with e2Studio, and build the project. |
| 71 | + |
| 72 | +Project properties are preset for the demo. |
| 73 | + |
| 74 | +``` |
| 75 | +Smart Configurator |
| 76 | +Flash Driver: r_flash_rx |
| 77 | +
|
| 78 | +Include Paths |
| 79 | +"C:..\..\..\..\..\IDE/Renesas/e2Studio_CCRX/include |
| 80 | +"C:..\..\..\..\..\wolfBoot\wolfboot/include" |
| 81 | +"C:..\..\..\..\..\wolfBoot\wolfboot\include" |
| 82 | +
|
| 83 | +Pre-Include |
| 84 | +../../../../../include/user_settings.h |
| 85 | +
|
| 86 | +Pre-defined Pre-processor Macro |
| 87 | +__WOLFBOOT |
| 88 | +WOLFBOOT_PARTIION_INFO |
| 89 | +PRINTF_ENABLED |
| 90 | +
|
| 91 | +``` |
| 92 | + |
| 93 | +WOLFBOOT_PARTION_INFO, PRINTF_ENABLED are for debug information about partitions. |
| 94 | +Eliminate them for operational use. |
| 95 | + |
| 96 | + |
| 97 | +### 3) Compile the sample application |
| 98 | + |
| 99 | +Open project under IDE/Renesas/e2studio_CCRX/app_RenesasRx01 with e2Studio, and build the project. |
| 100 | + |
| 101 | + |
| 102 | +Project properties are preset for the demo. |
| 103 | + |
| 104 | +``` |
| 105 | +Smart Configurator |
| 106 | +Flash Driver: r_flash_rx |
| 107 | +
|
| 108 | +Include Paths |
| 109 | +"C:..\..\..\..\..\IDE/Renesas/e2Studio_CCRX/include |
| 110 | +"C:..\..\..\..\..\wolfBoot\wolfboot/include" |
| 111 | +"C:..\..\..\..\..\wolfBoot\wolfboot\include" |
| 112 | +
|
| 113 | +Pre-Include |
| 114 | +../../../../../include/user_settings.h |
| 115 | +
|
| 116 | +Code Origin and entry point (PResetPRG) is "0xffc10100" (See Section Viewer of Linker Section). |
| 117 | +``` |
| 118 | + |
| 119 | +app_RenesasRx01.x in ELF is gnerated under HardwareDebug. You can derive bair binary file |
| 120 | +(app_RenesasRx01.bin) by rx-elf-objcopy.exe command as follows. -R are for eliminate unnecessary |
| 121 | +secrions. |
| 122 | + |
| 123 | +``` |
| 124 | +$ rx-elf-objcopy.exe -O binary\ |
| 125 | + -R '$ADDR_C_FE7F5D00' -R '$ADDR_C_FE7F5D10' -R '$ADDR_C_FE7F5D20' -R '$ADDR_C_FE7F5D30'\ |
| 126 | + -R '$ADDR_C_FE7F5D40' -R '$ADDR_C_FE7F5D48' -R '$ADDR_C_FE7F5D50' -R '$ADDR_C_FE7F5D64'\ |
| 127 | + -R '$ADDR_C_FE7F5D70' -R EXCEPTVECT -R RESETVECT app_RenesasRx01.x app_RenesasRx01.bin |
| 128 | +``` |
| 129 | + |
| 130 | +### 4) Generate Signature for app V1 |
| 131 | + |
| 132 | +"sign" command under tools/keytools benerates a signature for the binary with a specified version. |
| 133 | +It generates a file contain a partition header and application image. The partition header |
| 134 | +contain generated signature and other control fields. Output file name is made up from |
| 135 | +the input file name and version like app_RenesasRx01_v1.0_signed.bin. |
| 136 | + |
| 137 | +``` |
| 138 | +$ sign --ed25519 app_RenesasRx01.bin ../../../../../pri-ed25519.der 1.0 |
| 139 | +ed25519.der 1.0 |
| 140 | +wolfBoot KeyTools (Compiled C version) |
| 141 | +wolfBoot version 10B0000 |
| 142 | +Update type: Firmware |
| 143 | +Input image: app_RenesasRx.bin |
| 144 | +Selected cipher: ED25519 |
| 145 | +Selected hash : SHA256 |
| 146 | +Public key: ed25519.der |
| 147 | +Output image: app_RenesasRx_v1.0_signed.bin |
| 148 | +Target partition id : 1 |
| 149 | +Calculating SHA256 digest... |
| 150 | +Signing the digest... |
| 151 | +Output image(s) successfully created. |
| 152 | +``` |
| 153 | + |
| 154 | +### 5) Download the app V1 |
| 155 | + |
| 156 | +You can convert the binary file to hex format and download it to the board by Flash Programmer. |
| 157 | +The partition starts at "0xffc10000". |
| 158 | + |
| 159 | +``` |
| 160 | +$ rx-elf-objcopy.exe -I binary -O srec --change-addresses=0xffc10000 app_RenesasRx01_v1.0_signed.bin app_RenesasRx01_v1.0_signed.hex |
| 161 | +``` |
| 162 | + |
| 163 | + |
| 164 | +### 6) Execute inital boot |
| 165 | + |
| 166 | +Now, you can download and start wolfBoot program by e2Studio debugger. |
| 167 | +After starting the program, you can see the partition information as follows. |
| 168 | +If the boot program succeeds integlity and authenticity check, it initiate the |
| 169 | +application V1. |
| 170 | + |
| 171 | + |
| 172 | +``` |
| 173 | +=== Boot Partition[ffc10000] === |
| 174 | +Magic: WOLF |
| 175 | +Version: 01 |
| 176 | +Status: ff |
| 177 | +Tail Mgc: ���� |
| 178 | +
|
| 179 | +
|
| 180 | +=== Update Partition[ffdf0000] === |
| 181 | +Magic: ���� |
| 182 | +Version: ff |
| 183 | +Status: ff |
| 184 | +Tail Mgc: ���� |
| 185 | +
|
| 186 | +| ------------------------------------------------------------------- | |
| 187 | +| Renesas RX User Application in BOOT partition started by wolfBoot | |
| 188 | +| ------------------------------------------------------------------- | |
| 189 | +
|
| 190 | +Current Firmware Version: 1 |
| 191 | +Hit any key to update the firmware. |
| 192 | +``` |
| 193 | +The application calls wolfBoot_success() to set boot partition |
| 194 | +state and wait for any key. if you re-start the boot program at this moment, |
| 195 | +after checking the integlity and authenticity, it jumps to the application. |
| 196 | +You can see the state is Success("00"). |
| 197 | + |
| 198 | +``` |
| 199 | +=== Boot Partition[ffc10000] === |
| 200 | +Magic: WOLF |
| 201 | +Version: 01 |
| 202 | +Status: 00 |
| 203 | +Tail Mgc: BOOT |
| 204 | +``` |
| 205 | + |
| 206 | +### 7) Generate Signed app V2 and download it |
| 207 | + |
| 208 | +Similar to V1, you can signe and generate a binary of V2. The update partition starts at "0xffdf0000". |
| 209 | +You can download it by the flash programmer. |
| 210 | + |
| 211 | + |
| 212 | +``` |
| 213 | +$ sign --ed25519 app_RenesasRx01.bin ../../../../../pri-ed25519.der 2.0 |
| 214 | +rx-elf-objcopy.exe -I binary -O srec --change-addresses=0xffdf0000 app_RenesasRx01_v2.0_signed.bin app_RenesasRx01_v2.0_signed.hex |
| 215 | +``` |
| 216 | + |
| 217 | + |
| 218 | +### 8) Re-boot and secure update to V2 |
| 219 | + |
| 220 | +Now the image is downloaded but note that the partition status is not changed yet. |
| 221 | +When it is re-boot, it checks integlity and authenticity of V1 and initiate V1 as in |
| 222 | +step 6. |
| 223 | + |
| 224 | +``` |
| 225 | +| ------------------------------------------------------------------- | |
| 226 | +| Renesas RX User Application in BOOT partition started by wolfBoot | |
| 227 | +| ------------------------------------------------------------------- | |
| 228 | +
|
| 229 | +Current Firmware Version: 1 |
| 230 | +Hit any key to update the firmware. |
| 231 | +``` |
| 232 | + |
| 233 | +After you see the message, hit any key so that the application calls |
| 234 | +wolfBoot_update_trigger() whcih changes the partition status and triggers |
| 235 | +updating the firmware. |
| 236 | + |
| 237 | +Since this is just a trigger, the application can continue the process. |
| 238 | +In the demo application it outputs a message "Update Triggered" and enters |
| 239 | +a infinit loop of nop. |
| 240 | + |
| 241 | +Now you can re-boot it by start wolfBoot by e2Studion debugger. The boot |
| 242 | +program checks integlity and authenticity of V2 now, swap the partition |
| 243 | +safely and initiates V2. You will see following message after the partition |
| 244 | +information. |
| 245 | + |
| 246 | + |
| 247 | +``` |
| 248 | +| ------------------------------------------------------------------- | |
| 249 | +| Renesas RX User Application in BOOT partition started by wolfBoot | |
| 250 | +| ------------------------------------------------------------------- | |
| 251 | +
|
| 252 | +Current Firmware Version: 2 |
| 253 | +Hit any key to update the firmware. |
| 254 | +``` |
| 255 | + |
| 256 | +Not the application behavior is almost identical but the Version is "2" this time. |
| 257 | + |
0 commit comments