fix and update rx72n

pull/388/head
Hideki Miyazaki 2023-10-20 16:21:33 +09:00 committed by Daniele Lacamera
parent 445cd7bae2
commit 0f5b5abf5f
7 changed files with 158 additions and 51 deletions

View File

@ -44,9 +44,10 @@ Flash Allocation:
0xffc10000: Primary partition (Header)
0xffc10100: Primary partition (Application image) /* When it uses IMAGE_HEADER_SIZE 256, e.g. ED25519, EC256, EC384 or EC512 */
0xffc10200: Primary partition (Application image) /* When it uses IMAGE_HEADER_SIZE 512, e.g. RSA2048, RSA3072 */
0xffdf0000: Update partition (Header)
0xffdf0100: Update partition (Application image)
0xfffd0000: Swap sector
0xffdf8000: Update partition (Header)
0xffdf8100: Update partition (Application image) /* When it uses IMAGE_HEADER_SIZE 256, e.g. ED25519, EC256, EC384 or EC512 */
0xffdf8200: Update partition (Application image) /* When it uses IMAGE_HEADER_SIZE 512, e.g. RSA2048, RSA3072 */
0xfffe0000: Swap sector
```
@ -201,14 +202,14 @@ application V1.
=== Boot Partition[ffc10000] ===
Magic: WOLF
Version: 01
Status: ff
Tail Mgc: ????
Status: ff (New)
Tail Mgc: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
=== Update Partition[ffdf0000] ===
Magic: WOLF
Version: 02
Status: ff
Tail Mgc: ????
=== Update Partition[ffdf8000] ===
Magic: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Version: 00
Status: ff (New)
Tail Mgc: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Current Firmware Version: 1
Hit any key to call wolfBoot_success the firmware.
@ -217,35 +218,31 @@ Hit any key to call wolfBoot_success the firmware.
After hitting any key, the application calls wolfBoot_success() to set boot partition
state and wait for any key again.
If you re-start the boot program at this moment,
after checking the integrity and authenticity, it jumps to the application.
You can see the state is Success("00").
```
=== Boot Partition[ffc10000] ===
Magic: WOLF
Version: 01
Status: 00
Status: 00 (Success)
Tail Mgc: BOOT
=== Update Partition[ffdf0000] ===
Magic: WOLF
Version: 02
Status: ff
Tail Mgc: ????
=== Update Partition[ffdf8000] ===
Magic: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Version: 00
Status: 00 (Success)
Tail Mgc: BOOT
Hit any key to update the firmware.
```
You can see the state is Success("00").
### 3-8 Generate Signed app V2 and download it
Similar to V1, you can signe and generate a binary of V2. The update partition starts at "0xffdf0000".
Similar to V1, you can signe and generate a binary of V2. The update partition starts at "0xffdf8000".
You can download it by the flash programmer.
```
$ sign --ecc256 app_RenesasRx01.bin ../../../../../pri-ecc256.der 2.0
rx-elf-objcopy.exe -I binary -O srec --change-addresses=0xffdf0000 app_RenesasRx01_v2.0_signed.bin app_RenesasRx01_v2.0_signed.hex
rx-elf-objcopy.exe -I binary -O srec --change-addresses=0xffdf8000 app_RenesasRx01_v2.0_signed.bin app_RenesasRx01_v2.0_signed.hex
```
@ -253,7 +250,7 @@ rx-elf-objcopy.exe -I binary -O srec --change-addresses=0xffdf0000 app_RenesasRx
Now the image is downloaded but note that the partition status is not changed yet.
When it is re-boot, it checks integrity and authenticity of V1 and initiate V1 as in
step 6.
step 8.
```
| ------------------------------------------------------------------- |
@ -261,13 +258,28 @@ step 6.
| ------------------------------------------------------------------- |
Current Firmware Version: 1
....
Hit any key to update the firmware.
Firmware Update is triggered
```
After you see the message, hit any key so that the application calls
wolfBoot_update_trigger() which changes the partition status and triggers
updating the firmware.
updating the firmware. You will see the following messages.
```
Firmware Update is triggered
=== Boot Partition[ffc10000] ===
Magic: WOLF
Version: 01
Status: 00 (Success)
Tail Mgc: BOOT
=== Update Partition[ffdf8000] ===
Magic: <20><><EFBFBD><EFBFBD>
Version: 00
Status: 70 (Updating)
Tail Mgc: BOOT
```
Since this is just a trigger, the application can continue the process.
In the demo application it outputs a message "Firmware Update is triggered" and enters
@ -291,11 +303,11 @@ Version: 02
Status: 10
Tail Mgc: BOOT
=== Update Partition[ffdf0000] ===
=== Update Partition[ffdf8000] ===
Magic: WOLF
Version: 01
Status: ff
Tail Mgc: ????
Status: 30
Tail Mgc: BOOT
Current Firmware Version: 2
```

View File

@ -28,6 +28,17 @@
#include "hal.h"
#include "wolfboot/wolfboot.h"
static const char* state2str(uint8_t s)
{
switch(s) {
case IMG_STATE_NEW: return "New";
case IMG_STATE_UPDATING: return "Updating";
case IMG_STATE_TESTING: return "Testing";
case IMG_STATE_SUCCESS: return "Success";
default: return "Unknown";
}
}
static void printPart(uint8_t *part)
{
#ifdef WOLFBOOT_DEBUG_PARTION
@ -43,7 +54,7 @@ static void printPart(uint8_t *part)
ver = wolfBoot_get_blob_version(part);
printf("Version: %02x\n", ver);
state = *(part + WOLFBOOT_PARTITION_SIZE - sizeof(uint32_t) - 1);
printf("Status: %02x\n", state);
printf("Status: %02x (%s)\n", state,state2str(state));
magic = part + WOLFBOOT_PARTITION_SIZE - sizeof(uint32_t);
printf("Tail Mgc: %c%c%c%c\n", magic[0], magic[1], magic[2], magic[3]);
@ -107,6 +118,14 @@ void main(void)
wolfBoot_update_trigger();
printf("Firmware Update is triggered\n");
printPartitions();
} else if (firmware_version == 2) {
printf("Hit any key to call wolfBoot_success the firmware.\n");
getchar();
wolfBoot_success();
printPartitions();
}
} else {
printf("Invalid Firmware Version\n");

View File

@ -67,9 +67,9 @@
#define WOLFBOOT_PARTITION_SWAP_ADDRESS 0x0
#else
#define WOLFBOOT_BOOT_SIZE 0x20000
#define WOLFBOOT_BOOT_SIZE 0x10000
#define WOLFBOOT_RX_EXCVECT 0x10000
#define WOLFBOOT_SECTOR_SIZE 0x20000
#define WOLFBOOT_SECTOR_SIZE 0x10000
#define WOLFBOOT_PARTITION_SIZE\
((WOLFBOOT_FLASH_SIZE - WOLFBOOT_BOOT_SIZE -\

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="ASCII"?>
<com.renesas.linkersection.model:SectionContainer xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:com.renesas.linkersection.model="http:///LinkerSection.ecore">
<sections name="SU">
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4"/>
</sections>
<sections name="SI"/>
<sections name="B_1"/>
<sections name="R_1"/>
<sections name="B_2"/>
<sections name="R_2"/>
<sections name="B"/>
<sections name="R"/>
<sections name="B_8"/>
<sections name="R_8"/>
<sections name="RPFRAM"/>
<sections name="RPFRAM2"/>
<sections name="PResetPRG">
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4290839040"/>
</sections>
<sections name="C_1"/>
<sections name="C_2"/>
<sections name="C"/>
<sections name="C_8"/>
<sections name="C$*"/>
<sections name="D*"/>
<sections name="W*"/>
<sections name="L"/>
<sections name="P"/>
<sections name="PFRAM"/>
<sections name="PFRAM2"/>
<sections name="EXCEPTVECT">
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4294967168"/>
</sections>
<sections name="RESETVECT">
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4294967292"/>
</sections>
</com.renesas.linkersection.model:SectionContainer>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="ASCII"?>
<com.renesas.linkersection.model:SectionContainer xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:com.renesas.linkersection.model="http:///LinkerSection.ecore">
<sections name="SU">
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4"/>
</sections>
<sections name="SI"/>
<sections name="B_1"/>
<sections name="R_1"/>
<sections name="B_2"/>
<sections name="R_2"/>
<sections name="B"/>
<sections name="R"/>
<sections name="B_8"/>
<sections name="R_8"/>
<sections name="RPFRAM"/>
<sections name="RPFRAM2"/>
<sections name="PResetPRG">
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4291232256"/>
</sections>
<sections name="C_1"/>
<sections name="C_2"/>
<sections name="C"/>
<sections name="C_8"/>
<sections name="C$*"/>
<sections name="D*"/>
<sections name="W*"/>
<sections name="L"/>
<sections name="P"/>
<sections name="PFRAM"/>
<sections name="PFRAM2"/>
<sections name="EXCEPTVECT">
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4294967168"/>
</sections>
<sections name="RESETVECT">
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4294967292"/>
</sections>
</com.renesas.linkersection.model:SectionContainer>

View File

@ -23,7 +23,7 @@ if [ $# -ne 4 ];then
fi
VER1_ADDR=0xffc10000
VER2_ADDR=0xffdf0000
VER2_ADDR=0xffdf8000
# signature method
RSA2048_SIGN="rsa2048"

View File

@ -129,6 +129,8 @@ const char Cfile_Banner[]="/* Keystore file for wolfBoot, automatically generate
const char Store_hdr[] = "\n"
"#if defined(__APPLE__) && defined(__MACH__)\n"
"#define KEYSTORE_SECTION __attribute__((section (\"__KEYSTORE,__keystore\")))\n"
"#elif defined(__CCRX__)\n"
"#define KEYSTORE_SECTION\n"
"#else\n"
"#define KEYSTORE_SECTION __attribute__((section (\".keystore\")))\n"
"#endif\n\n"