Skip to content

Commit 0f5b5ab

Browse files
miyazakhdanielinux
authored andcommitted
fix and update rx72n
1 parent 445cd7b commit 0f5b5ab

File tree

7 files changed

+158
-51
lines changed

7 files changed

+158
-51
lines changed

IDE/Renesas/e2studio/RX72N/Readme.md

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ Flash Allocation:
4444
0xffc10000: Primary partition (Header)
4545
0xffc10100: Primary partition (Application image) /* When it uses IMAGE_HEADER_SIZE 256, e.g. ED25519, EC256, EC384 or EC512 */
4646
0xffc10200: Primary partition (Application image) /* When it uses IMAGE_HEADER_SIZE 512, e.g. RSA2048, RSA3072 */
47-
0xffdf0000: Update partition (Header)
48-
0xffdf0100: Update partition (Application image)
49-
0xfffd0000: Swap sector
47+
0xffdf8000: Update partition (Header)
48+
0xffdf8100: Update partition (Application image) /* When it uses IMAGE_HEADER_SIZE 256, e.g. ED25519, EC256, EC384 or EC512 */
49+
0xffdf8200: Update partition (Application image) /* When it uses IMAGE_HEADER_SIZE 512, e.g. RSA2048, RSA3072 */
50+
0xfffe0000: Swap sector
5051
5152
```
5253

@@ -75,13 +76,13 @@ $ export PATH:$PATH:<wolfBoot>/tools/keytools
7576
$ keygen --ecc256 -g ./pri-ecc256.der
7677
```
7778

78-
This generates a pair of private and public keys with -g option. The private key is stored
79-
in the specified file. The public key is stored in a key store as a C source code
79+
This generates a pair of private and public keys with -g option. The private key is stored
80+
in the specified file. The public key is stored in a key store as a C source code
8081
in "src/keystore.c" soo that it can be compiled and linked with wolfBoot.
8182
If you have an existing key pair, you can use -i option to import the pablic
8283
key to the store.
8384

84-
You can specify various signature algorithms such as
85+
You can specify various signature algorithms such as
8586

8687
```
8788
--ed25519 --ed448 --ecc256 --ecc384 --ecc521 --rsa2048 --rsa3072
@@ -140,7 +141,7 @@ Pre-Include
140141
Code Origin and entry point (PResetPRG) is "0xffc10200" (See Section Viewer of Linker Section).
141142
```
142143

143-
app_RenesasRx01.x in ELF is generated under HardwareDebug. You can derive bair binary file
144+
app_RenesasRx01.x in ELF is generated under HardwareDebug. You can derive bair binary file
144145
(app_RenesasRx01.bin) by rx-elf-objcopy.exe command as follows. -R are for eliminate unnecessary
145146
secrions.
146147

@@ -189,7 +190,7 @@ $ rx-elf-objcopy.exe -I binary -O srec --change-addresses=0xffc10000 app_Renesas
189190
Now, you can download and start wolfBoot program by e2Studio debugger.
190191
After starting the program, you can see the partition information as follows.
191192
If the boot program succeeds integrity and authenticity check, it initiate the
192-
application V1.
193+
application V1.
193194

194195

195196
```
@@ -201,73 +202,84 @@ application V1.
201202
=== Boot Partition[ffc10000] ===
202203
Magic: WOLF
203204
Version: 01
204-
Status: ff
205-
Tail Mgc: ????
205+
Status: ff (New)
206+
Tail Mgc: ����
206207
207-
=== Update Partition[ffdf0000] ===
208-
Magic: WOLF
209-
Version: 02
210-
Status: ff
211-
Tail Mgc: ????
208+
=== Update Partition[ffdf8000] ===
209+
Magic: ����
210+
Version: 00
211+
Status: ff (New)
212+
Tail Mgc: ����
212213
213214
Current Firmware Version: 1
214215
Hit any key to call wolfBoot_success the firmware.
215216
```
216217

217218
After hitting any key, the application calls wolfBoot_success() to set boot partition
218-
state and wait for any key again.
219-
220-
If you re-start the boot program at this moment,
221-
after checking the integrity and authenticity, it jumps to the application.
222-
You can see the state is Success("00").
219+
state and wait for any key again.
223220

224221
```
225222
=== Boot Partition[ffc10000] ===
226223
Magic: WOLF
227224
Version: 01
228-
Status: 00
225+
Status: 00 (Success)
229226
Tail Mgc: BOOT
230227
231-
=== Update Partition[ffdf0000] ===
232-
Magic: WOLF
233-
Version: 02
234-
Status: ff
235-
Tail Mgc: ????
228+
=== Update Partition[ffdf8000] ===
229+
Magic: ����
230+
Version: 00
231+
Status: 00 (Success)
232+
Tail Mgc: BOOT
236233
237-
Hit any key to update the firmware.
238234
```
235+
You can see the state is Success("00").
239236

240237
### 3-8 Generate Signed app V2 and download it
241238

242-
Similar to V1, you can signe and generate a binary of V2. The update partition starts at "0xffdf0000".
239+
Similar to V1, you can signe and generate a binary of V2. The update partition starts at "0xffdf8000".
243240
You can download it by the flash programmer.
244241

245242

246243
```
247244
$ sign --ecc256 app_RenesasRx01.bin ../../../../../pri-ecc256.der 2.0
248-
rx-elf-objcopy.exe -I binary -O srec --change-addresses=0xffdf0000 app_RenesasRx01_v2.0_signed.bin app_RenesasRx01_v2.0_signed.hex
245+
rx-elf-objcopy.exe -I binary -O srec --change-addresses=0xffdf8000 app_RenesasRx01_v2.0_signed.bin app_RenesasRx01_v2.0_signed.hex
249246
```
250247

251248

252249
### 3-9 Re-boot and secure update to V2
253250

254251
Now the image is downloaded but note that the partition status is not changed yet.
255252
When it is re-boot, it checks integrity and authenticity of V1 and initiate V1 as in
256-
step 6.
253+
step 8.
257254

258255
```
259256
| ------------------------------------------------------------------- |
260257
| Renesas RX User Application in BOOT partition started by wolfBoot |
261258
| ------------------------------------------------------------------- |
262259
263260
Current Firmware Version: 1
261+
....
264262
Hit any key to update the firmware.
265-
Firmware Update is triggered
266263
```
267264

268265
After you see the message, hit any key so that the application calls
269266
wolfBoot_update_trigger() which changes the partition status and triggers
270-
updating the firmware.
267+
updating the firmware. You will see the following messages.
268+
269+
```
270+
Firmware Update is triggered
271+
=== Boot Partition[ffc10000] ===
272+
Magic: WOLF
273+
Version: 01
274+
Status: 00 (Success)
275+
Tail Mgc: BOOT
276+
277+
=== Update Partition[ffdf8000] ===
278+
Magic: ����
279+
Version: 00
280+
Status: 70 (Updating)
281+
Tail Mgc: BOOT
282+
```
271283

272284
Since this is just a trigger, the application can continue the process.
273285
In the demo application it outputs a message "Firmware Update is triggered" and enters
@@ -291,11 +303,11 @@ Version: 02
291303
Status: 10
292304
Tail Mgc: BOOT
293305
294-
=== Update Partition[ffdf0000] ===
306+
=== Update Partition[ffdf8000] ===
295307
Magic: WOLF
296308
Version: 01
297-
Status: ff
298-
Tail Mgc: ????
309+
Status: 30
310+
Tail Mgc: BOOT
299311
300312
Current Firmware Version: 2
301313
```

IDE/Renesas/e2studio/RX72N/app_RenesasRX01/src/app_RenesasRX01.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@
2828
#include "hal.h"
2929
#include "wolfboot/wolfboot.h"
3030

31+
static const char* state2str(uint8_t s)
32+
{
33+
switch(s) {
34+
case IMG_STATE_NEW: return "New";
35+
case IMG_STATE_UPDATING: return "Updating";
36+
case IMG_STATE_TESTING: return "Testing";
37+
case IMG_STATE_SUCCESS: return "Success";
38+
default: return "Unknown";
39+
}
40+
}
41+
3142
static void printPart(uint8_t *part)
3243
{
3344
#ifdef WOLFBOOT_DEBUG_PARTION
@@ -43,7 +54,7 @@ static void printPart(uint8_t *part)
4354
ver = wolfBoot_get_blob_version(part);
4455
printf("Version: %02x\n", ver);
4556
state = *(part + WOLFBOOT_PARTITION_SIZE - sizeof(uint32_t) - 1);
46-
printf("Status: %02x\n", state);
57+
printf("Status: %02x (%s)\n", state,state2str(state));
4758
magic = part + WOLFBOOT_PARTITION_SIZE - sizeof(uint32_t);
4859
printf("Tail Mgc: %c%c%c%c\n", magic[0], magic[1], magic[2], magic[3]);
4960

@@ -107,6 +118,14 @@ void main(void)
107118

108119
wolfBoot_update_trigger();
109120
printf("Firmware Update is triggered\n");
121+
printPartitions();
122+
123+
} else if (firmware_version == 2) {
124+
printf("Hit any key to call wolfBoot_success the firmware.\n");
125+
getchar();
126+
127+
wolfBoot_success();
128+
printPartitions();
110129
}
111130
} else {
112131
printf("Invalid Firmware Version\n");

IDE/Renesas/e2studio/RX72N/include/target.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
#define WOLFBOOT_PARTITION_SWAP_ADDRESS 0x0
6868

6969
#else
70-
#define WOLFBOOT_BOOT_SIZE 0x20000
70+
#define WOLFBOOT_BOOT_SIZE 0x10000
7171
#define WOLFBOOT_RX_EXCVECT 0x10000
72-
#define WOLFBOOT_SECTOR_SIZE 0x20000
72+
#define WOLFBOOT_SECTOR_SIZE 0x10000
7373

7474
#define WOLFBOOT_PARTITION_SIZE\
7575
((WOLFBOOT_FLASH_SIZE - WOLFBOOT_BOOT_SIZE -\
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="ASCII"?>
2+
<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">
3+
<sections name="SU">
4+
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4"/>
5+
</sections>
6+
<sections name="SI"/>
7+
<sections name="B_1"/>
8+
<sections name="R_1"/>
9+
<sections name="B_2"/>
10+
<sections name="R_2"/>
11+
<sections name="B"/>
12+
<sections name="R"/>
13+
<sections name="B_8"/>
14+
<sections name="R_8"/>
15+
<sections name="RPFRAM"/>
16+
<sections name="RPFRAM2"/>
17+
<sections name="PResetPRG">
18+
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4290839040"/>
19+
</sections>
20+
<sections name="C_1"/>
21+
<sections name="C_2"/>
22+
<sections name="C"/>
23+
<sections name="C_8"/>
24+
<sections name="C$*"/>
25+
<sections name="D*"/>
26+
<sections name="W*"/>
27+
<sections name="L"/>
28+
<sections name="P"/>
29+
<sections name="PFRAM"/>
30+
<sections name="PFRAM2"/>
31+
<sections name="EXCEPTVECT">
32+
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4294967168"/>
33+
</sections>
34+
<sections name="RESETVECT">
35+
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4294967292"/>
36+
</sections>
37+
</com.renesas.linkersection.model:SectionContainer>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="ASCII"?>
2+
<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">
3+
<sections name="SU">
4+
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4"/>
5+
</sections>
6+
<sections name="SI"/>
7+
<sections name="B_1"/>
8+
<sections name="R_1"/>
9+
<sections name="B_2"/>
10+
<sections name="R_2"/>
11+
<sections name="B"/>
12+
<sections name="R"/>
13+
<sections name="B_8"/>
14+
<sections name="R_8"/>
15+
<sections name="RPFRAM"/>
16+
<sections name="RPFRAM2"/>
17+
<sections name="PResetPRG">
18+
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4291232256"/>
19+
</sections>
20+
<sections name="C_1"/>
21+
<sections name="C_2"/>
22+
<sections name="C"/>
23+
<sections name="C_8"/>
24+
<sections name="C$*"/>
25+
<sections name="D*"/>
26+
<sections name="W*"/>
27+
<sections name="L"/>
28+
<sections name="P"/>
29+
<sections name="PFRAM"/>
30+
<sections name="PFRAM2"/>
31+
<sections name="EXCEPTVECT">
32+
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4294967168"/>
33+
</sections>
34+
<sections name="RESETVECT">
35+
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="4294967292"/>
36+
</sections>
37+
</com.renesas.linkersection.model:SectionContainer>

IDE/Renesas/e2studio/RX72N/x2hex.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if [ $# -ne 4 ];then
2323
fi
2424

2525
VER1_ADDR=0xffc10000
26-
VER2_ADDR=0xffdf0000
26+
VER2_ADDR=0xffdf8000
2727

2828
# signature method
2929
RSA2048_SIGN="rsa2048"
@@ -78,21 +78,21 @@ if [ $TSIPUSE -eq 1 -o $TSIPUSE -eq 2 ]; then
7878

7979
fi
8080

81-
echo "Version 1 app start address : " $VER1_ADDR
82-
echo "Version 2 app start address : " $VER2_ADDR
81+
echo "Version 1 app start address : " $VER1_ADDR
82+
echo "Version 2 app start address : " $VER2_ADDR
8383
echo "Signature method : " $SIGN_METHOD
8484

85-
echo
85+
echo
8686
echo COPY app_RenesasRx01.x to RXELF_BIN_DIR to convert bin file
8787
cp ${APP_RX}/HardwareDebug/app_RenesasRx01.x "${RXELF_BIN_DIR}"
8888

8989
pushd "${RXELF_BIN_DIR}"
9090

91-
echo
91+
echo
9292
echo Run rx-elf-objcopy.exe to generate bin
9393
"${RXELF_OBJCPY_BIN}" -O binary -R '$ADDR_C_FE7F5D00' -R '$ADDR_C_FE7F5D10' -R '$ADDR_C_FE7F5D20' -R '$ADDR_C_FE7F5D30' -R '$ADDR_C_FE7F5D40' -R '$ADDR_C_FE7F5D48' -R '$ADDR_C_FE7F5D50' -R '$ADDR_C_FE7F5D64' -R '$ADDR_C_FE7F5D70' -R EXCEPTVECT -R RESETVECT app_RenesasRx01.x app_RenesasRx01.bin
9494

95-
echo
95+
echo
9696
echo copy app_RenesasRx01.bin to wolfBoot folder to sign
9797
cp app_RenesasRx01.bin ${WOLFBOOT_DIR}
9898

@@ -102,34 +102,34 @@ echo "generate key"
102102
keygen --${SIGN_METHOD} -g ./pri-${SIGN_METHOD}.der
103103

104104

105-
echo
105+
echo
106106
echo sign app_RenesasRx01.bin for version 1
107107
sign --${SIGN_METHOD}${SIGN_METHOD_EX} app_RenesasRx01.bin ./pri-${SIGN_METHOD}.der 1.0
108108

109-
echo
109+
echo
110110
echo sign app_RenesasRx01.bin for version 2
111111
sign --${SIGN_METHOD}${SIGN_METHOD_EX} app_RenesasRx01.bin ./pri-${SIGN_METHOD}.der 2.0
112112

113-
echo
113+
echo
114114
echo copy app_RenesasRx01_v1.0/v2.0_signed.bin RXELF_BIN_DIR
115115
cp app_RenesasRx01_v1.0_signed.bin "${RXELF_BIN_DIR}"
116116
cp app_RenesasRx01_v2.0_signed.bin "${RXELF_BIN_DIR}"
117117

118118
popd
119119

120-
echo
120+
echo
121121
echo Run rx-elf-objcopy.exe to generate hex for version 1
122122
"${RXELF_OBJCPY_BIN}" -I binary -O srec --change-addresses=${VER1_ADDR} app_RenesasRx01_v1.0_signed.bin app_RenesasRx01_v1.0_signed.hex
123123

124-
echo
124+
echo
125125
echo Run rx-elf-objcopy.exe to generate hex for version 2
126126
"${RXELF_OBJCPY_BIN}" -I binary -O srec --change-addresses=${VER2_ADDR} app_RenesasRx01_v2.0_signed.bin app_RenesasRx01_v2.0_signed.hex
127127

128-
echo
128+
echo
129129
echo move *.hex to ${CURRENT}
130130
mv app_RenesasRx01_v1.0_signed.hex app_RenesasRx01_v2.0_signed.hex ${CURRENT}
131131

132-
echo
132+
echo
133133
echo Clean up all copied and generated files
134134
rm -rf app_RenesasRx01.x app_RenesasRx01.bin app_RenesasRx01_v1.0_signed.bin app_RenesasRx01_v2.0_signed.bin
135135
popd

tools/keytools/keygen.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ const char Cfile_Banner[]="/* Keystore file for wolfBoot, automatically generate
129129
const char Store_hdr[] = "\n"
130130
"#if defined(__APPLE__) && defined(__MACH__)\n"
131131
"#define KEYSTORE_SECTION __attribute__((section (\"__KEYSTORE,__keystore\")))\n"
132+
"#elif defined(__CCRX__)\n"
133+
"#define KEYSTORE_SECTION\n"
132134
"#else\n"
133135
"#define KEYSTORE_SECTION __attribute__((section (\".keystore\")))\n"
134136
"#endif\n\n"

0 commit comments

Comments
 (0)