Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for Renesas RX (RX65N and RX72N) #408

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
61bd21d
Adding support for RX65N and RX72N with native Makefile and RX ELF GC…
dgarske Feb 16, 2024
4ed1add
Added initialization of the clocks. UART is working.
dgarske Feb 20, 2024
13028fa
Support for running from on-chip high speed oscillator (HOCO). The ta…
dgarske Feb 22, 2024
01fe472
Fix stack issue and implement RX GCC `do_boot`. Increased user stack …
dgarske Feb 23, 2024
2ea4f84
Fixes for test-app. Fixes and cleanups for big endian data handling o…
dgarske Feb 23, 2024
abbb97f
Improvements for endianess.
dgarske Feb 29, 2024
aecd27d
Fix test-app entry point and setup/relocate exception and reset vectors.
dgarske Mar 15, 2024
a7202dc
Added srecord output support. Added RX GPIO registers. Fixed startup …
dgarske Apr 18, 2024
b6a6d23
Support for external SPI flash.
dgarske Apr 25, 2024
ffb3dfa
Support for SPI flash via the RSPI peripheral.
dgarske Apr 25, 2024
89aa922
Fix GPL version.
dgarske Apr 26, 2024
247b237
Fix SPI to use byte data access. Improve the SPI CS options. Portabil…
dgarske Apr 30, 2024
ab79ed8
Fix RTC clock stop issue. Add new `BOOT_ENTRY_OFFSET` option for RX t…
dgarske May 7, 2024
48ba0c4
Fix stage1 build. Remove files not needed.
dgarske May 10, 2024
ca0f1cc
Fix cppcheck issue. Fix uart_init function conflict with UART_FLASH a…
dgarske May 10, 2024
a7a4587
Fix RTC stop code (on cold start).
dgarske May 13, 2024
43a6330
Disable forcing RX PSW user-mode unless `RX_PSW_USER_MODE` is defined.
dgarske May 14, 2024
b32bb02
Support for Renesas RX72N with wolfBoot GCC RX and Make. Tested on RX…
dgarske May 22, 2024
547f72e
Cleanups. Don't force 1024 header size in example. Remove execute bits.
dgarske May 23, 2024
f2afd3c
Support for Renesas RX QSPI.
dgarske May 23, 2024
fa64ff6
QSPI fixes.
dgarske May 24, 2024
c937a43
Fixes for Renesas RX QSPI driver.
dgarske May 30, 2024
649c37b
Consolidate RX65N/RX72N common code (99% the same).
dgarske May 31, 2024
1aee86b
Fix RX PLL multiplier after refactor (code consolidation).
dgarske May 31, 2024
6d69959
Fixes for RX QSPI and Flash after additional testing. QSPI fixes for …
dgarske Jun 4, 2024
d34d8b6
Fix cppcheck portability with 32-bit unsigned shift.
dgarske Jun 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ debug/lauterbach
*.gcda
*.gcno
coverage.*

IDE/MPLAB/test-app/test-usb-updater.same51.X/dist/
IDE/MPLAB/test-app/test-usb-updater.same51.X/.generated_files/
IDE/MPLAB/bootloader/wolfboot-same51.dualbank.X/dist/
Expand Down Expand Up @@ -202,3 +203,11 @@ include/x86/fsp/FspmUpd.h
include/x86/fsp/FspsUpd.h
include/x86/fsp/FsptUpd.h
include/x86/fsp/MemInfoHob.h

# IDE Renesas e2Studio generated
IDE/Renesas/e2studio/RX72N/app_RenesasRX01/HardwareDebug
IDE/Renesas/e2studio/RX72N/app_RenesasRX01/src/smc_gen
IDE/Renesas/e2studio/RX72N/wolfBoot/HardwareDebug
IDE/Renesas/e2studio/RX72N/wolfBoot/src/smc_gen
lib/r_bsp_v7.42
lib/r_flash_rx_v5.11
61 changes: 30 additions & 31 deletions IDE/Renesas/e2studio/RA6M4/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

## 1. Overview

This example demonstrates simple secure firmware update by wolfBoot.
A sample application v1 is securely updated to v2. Both versions behave the same except displaying its version of v1 or v2.
This example demonstrates simple secure firmware update by wolfBoot.
A sample application v1 is securely updated to v2. Both versions behave the same except displaying its version of v1 or v2.
They are compiled by e2Studio and running on the target board.

In this demo, you may download two versions of the application binary file by Renesas Flash Programmer.
You can download and excute wolfBoot by e2Studio debugger. Use a USB connection between PC and the board for the debugger and flash programmer.
In this demo, you may download two versions of the application binary file by Renesas Flash Programmer.
You can download and execute wolfBoot by e2Studio debugger. Use a USB connection between PC and the board for the debugger and flash programmer.

Please see `Readme_wSCE.md` for Renesas SCE use case.
## 2. Components and Tools

## 2. Components and Tools

|Item|Name/Version|Note|
|:--|:--|:--|
Expand All @@ -25,7 +25,6 @@ Please see `Readme_wSCE.md` for Renesas SCE use case.
|Key tool|keygen and sign|Included in wolfBoot|



|FIT Components|Version|
|:--|:--|
|Board Support Package Common Files|v3.6.0|
Expand All @@ -38,7 +37,6 @@ Please see `Readme_wSCE.md` for Renesas SCE use case.
|Flash Memory High Performance|v3.6.0|



e2Studio Project:\
wolfBoot IDE/Renesas/e2studio/RA6M4/wolfBoot\
Sample app IDE/Renesas/e2studio/RA6M4/app_RA
Expand Down Expand Up @@ -80,7 +78,7 @@ The private key is stored in the specified file.
The public key is stored in a key store as a C source code in "src/keystore.c" so that it can be compiled and linked with wolfBoot.
If you have an existing key pair, you can use -i option to import the public key to the store.

You can specify various signature algorithms such as
You can specify various signature algorithms such as

```les
--ed25519 --ed448 --ecc256 --ecc384 --ecc521 --rsa2048 --rsa3072 --rsa4096
Expand All @@ -90,7 +88,7 @@ You can specify various signature algorithms such as

Open project under IDE/Renesas/e2studio/RA6M4/wolfBoot with e2Studio, and build the project. Project properties are preset for the demo.

`WOLFBOOT_PARTION_INFO` is for debug information about partitions. Eliminate them for operational use.
`PRINTF_ENABLED` is for debug information about partitions. Eliminate them for operational use.

#### 2-1) Create `dummy_library` Static Library
+ Click File->New->`RA C/C++ Project`.
Expand All @@ -103,9 +101,9 @@ Open project under IDE/Renesas/e2studio/RA6M4/wolfBoot with e2Studio, and build
+ Go to `BSP` tab and increase Heap Size under `RA Common` on Properties page, e.g. 0x10000
+ Go to `Stacks` tab
+ Add `SCE Protected Mode` stack from `New Stack` -> `Security`
+ Add `g_flash0 Flash(r_falsh_hp)` stack from `New Stack` -> `Storage`
+ Add `g_flash0 Flash(r_flash_hp)` stack from `New Stack` -> `Storage`

Modify `g_flash0 Flash(r_flash_hp)` properites as follows:
Modify `g_flash0 Flash(r_flash_hp)` properties as follows:
|Property|Value|
|:--|:--|
|Data Flash Background Operation|Disabled|
Expand All @@ -115,7 +113,8 @@ Modify `g_flash0 Flash(r_flash_hp)` properites as follows:
+ Open Smart Configurator by clicking copied configuration.xml
+ Click `Generate Project Content` on Smart Configurator
+ Set `BSP_FEATURE_FLASH_SUPPORTS_ACCESS_WINDOW` to 1)
+ Build `wolfBoot` projet
+ Build `wolfBoot` project

### 3) Compile the sample application

Open project under IDE/Renesas/e2studio/RA6M4/app_RA with e2Studio, and build the project.
Expand All @@ -140,20 +139,20 @@ Project properties are preset for the demo.
0x2000094c 0xa8 ./src/SEGGER_RTT/SEGGER_RTT.o
0x2000094c _SEGGER_RTT
````

you can specify "RTT control block" to 0x2000094c by Address
OR
you can specify "RTT control block" to 0x20000000 0x1000 by Search Range

#### 3-2). Create `dummy_application`
+ Click File->New->`RA C/C++ Project`.
+ Select `EK-RA6M4` from Drop-down list.
+ Check `Executable`.
+ Select `No RTOS` from RTOS selection. Click Next.
+ Check `Bare Metal Minimal`. Click Finish.
+ Go to `BSP` tab and Add `g_flash0 Flash(r_falsh_hp)` stack from `New Stack` -> `Storage`
+ Go to `BSP` tab and Add `g_flash0 Flash(r_flash_hp)` stack from `New Stack` -> `Storage`

Modify `g_flash0 Flash(r_flash_hp)` properites as follows:
Modify `g_flash0 Flash(r_flash_hp)` properties as follows:
|Property|Value|
|:--|:--|
|Data Flash Background Operation|Disabled|
Expand All @@ -163,18 +162,18 @@ Modify `g_flash0 Flash(r_flash_hp)` properites as follows:
+ Open Smart Configurator by clicking copied configuration.xml
+ Click `Generate Project Content` on Smart Configurator
+ Set `BSP_FEATURE_FLASH_SUPPORTS_ACCESS_WINDOW` to 1)
+ Build `app_RA` projet
+ Build `app_RA` project

Code Origin and entry point is "0x00010200". app_RA.elf is generated under Debug.
Code Origin and entry point is "0x00010200". app_RA.elf is generated under Debug.

### 4) Generate Signature for app V1
You can derive bair binary file (app_RA.bin) by objcopy command as follows.
You can derive the binary file (app_RA.bin) using objcopy command as follows:

```
$ aarch64-none-elf-objcopy.exe -O binary -j .text -j .data app_RA.elf app_RA.bin
```

"sign" command under tools/keytools benerates a signature for the binary with a specified version.
"sign" command under tools/keytools generates a signature for the binary with a specified version.
It generates a file contain a partition header and application image.
The partition header contain generated signature and other control fields.
Output file name is made up from the input file name and version like app_RenesasRx01_v1.0_signed.bin.
Expand Down Expand Up @@ -204,10 +203,10 @@ You can convert the binary file to hex format and download it to the board by Fl
$ aarch64-none-elf-objcopy.exe -I binary -O srec --change-addresses=0x00010000 app_RA_v1.0_signed.bin app_RA_v1.0_signed.hex
```

### 6) Execute inital boot
### 6) Execute initial boot

Now, you can download and start wolfBoot program by e2Studio debugger.
After starting the program, you can see the partition information as follows.
Now, you can download and start wolfBoot program by e2Studio debugger.
After starting the program, you can see the partition information as follows.
If the boot program succeeds integrity and authenticity check, it initiate the application V1. To initially run `wolfBoot` project,
1.) Right-Click the Project name.
2.) Select `Debug As` -> `Renesas GDB Hardware Debugging`
Expand All @@ -230,13 +229,13 @@ Application Entry Address: 0x00010200
Magic: WOLF
Version: 01
Status: FF
Tail Mgc:
Tail Mgc:

=== Update Partition[00080000] ===
Magic:
Magic:
Version: 00
Status: FF
Tail Mgc:
Tail Mgc:
Current Firmware Version : 1

Calling wolfBoot_success()
Expand All @@ -254,7 +253,7 @@ Status: 00
Tail Mgc: BOOT

=== Update Partition[00080000] ===
Magic:
Magic:
Version: 00
Status: FF
Tail Mgc:
Expand All @@ -267,7 +266,7 @@ We are going to generate and download V2 application into "Update partition".

### 7) Generate Signed app V2 and download it

Similar to V1, you can signe and generate a binary of V2. The update partition starts at "0x00080000".
Similar to V1, you can sign and generate a binary of V2. The update partition starts at "0x00080000".
You can download it by the flash programmer.

Updtate partition:
Expand Down Expand Up @@ -309,7 +308,7 @@ Tail Mgc: BOOT
Magic: WOLF
Version: 01
Status: FF
Tail Mgc:
Tail Mgc:
Current Firmware Version : 2

Calling wolfBoot_success()
Expand All @@ -324,8 +323,8 @@ Tail Mgc: BOOT
Magic: WOLF
Version: 01
Status: FF
Tail Mgc:
Tail Mgc:
```

You can see "Current Firmware Version : 2". The state is Success("00") and Tail Magic number becomes "BOOT".
You can also see flashing each LED light in 5 second at this new version.
You can also see flashing each LED light in 5 second at this new version.
52 changes: 27 additions & 25 deletions IDE/Renesas/e2studio/RA6M4/Readme_wSCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## 1. Overview

This example demonstrates simple secure firmware update by wolfBoot and uses Renesas SCE.
This example demonstrates simple secure firmware update by wolfBoot and uses Renesas SCE.
A sample application v1 is securely updated to v2. Both versions behave the same except displaying its version of v1 or v2. They are compiled by e2Studio and running on the target board.

In this demo, you may download two versions of the application binary file by Renesas Flash Programmer. You can download and excute wolfBoot by e2Studio debugger. Use a USB connection between PC and the board for the debugger and flash programmer.It is only available RSA with Renesas SCE now.
In this demo, you may download two versions of the application binary file by Renesas Flash Programmer. You can download and execute wolfBoot by e2Studio debugger. Use a USB connection between PC and the board for the debugger and flash programmer.It is only available RSA with Renesas SCE now.

## 2. Components and Tools

Expand Down Expand Up @@ -95,7 +95,7 @@ Enabled `WOLFBOOT_RENESAS_SCEPROTECT` expects to use Renesas SCE.
+ Add `SCE Protected Mode` stack from `New Stack` -> `Security`
+ Add `g_flash0 Flash(r_falsh_hp)` stack from `New Stack` -> `Storage`

Modify `g_flash0 Flash(r_flash_hp)` properites as follows:
Modify `g_flash0 Flash(r_flash_hp)` properties as follows:
|Property|Value|
|:--|:--|
|Data Flash Background Operation|Disabled|
Expand All @@ -105,7 +105,8 @@ Modify `g_flash0 Flash(r_flash_hp)` properites as follows:
+ Open Smart Configurator by clicking copied configuration.xml
+ Click `Generate Project Content` on Smart Configurator
+ Set `BSP_FEATURE_FLASH_SUPPORTS_ACCESS_WINDOW` to 1)
+ Build `wolfBoot` projet
+ Build `wolfBoot` project

### 3) Compile the sample application

Open project under IDE/Renesas/e2studio/RA6M4/app_RA with e2Studio.
Expand All @@ -129,12 +130,12 @@ Open project under IDE/Renesas/e2studio/RA6M4/app_RA with e2Studio.
0x2000094c 0xa8 ./src/SEGGER_RTT/SEGGER_RTT.o
0x2000094c _SEGGER_RTT
````

you can specify "RTT control block" to 0x2000094c by Address
OR
you can specify "RTT control block" to 0x20000000 0x1000 by Search Range


#### 3-2). Create `dummy_application`
+ Click File->New->`RA C/C++ Project`.
+ Select `EK-RA6M4` from Drop-down list.
Expand All @@ -143,7 +144,7 @@ Open project under IDE/Renesas/e2studio/RA6M4/app_RA with e2Studio.
+ Check `Bare Metal Minimal`. Click Finish.
+ Go to `BSP` tab and Add `g_flash0 Flash(r_falsh_hp)` stack from `New Stack` -> `Storage`

Modify `g_flash0 Flash(r_flash_hp)` properites as follows:
Modify `g_flash0 Flash(r_flash_hp)` properties as follows:
|Property|Value|
|:--|:--|
|Data Flash Background Operation|Disabled|
Expand All @@ -154,10 +155,11 @@ Modify `g_flash0 Flash(r_flash_hp)` properites as follows:
+ Click `Generate Project Content` on Smart Configurator
+ Set `BSP_FEATURE_FLASH_SUPPORTS_ACCESS_WINDOW` to 1)
+ Linker option update, Click project->`Properties`->`C/C++ Build`->`Settings`->`GNU Arm Cross Linker`->`Miscellaneous`. Modify `--defsym=FLASH_IMAGE_START=0x10200` to `--defsym=FLASH_IMAGE_START=0x10200`
+ Build `app_RA` projet
+ Build `app_RA` project


Code Origin and entry point is "0x00020200". app_RA.elf is gnerated under Debug.
Code Origin and entry point is "0x00020200". app_RA.elf is generated under Debug.

### 4) Generate Wrapped Key for SCE

SCE needs to have a wrapped key for sign verification installed in advance.
Expand All @@ -182,16 +184,16 @@ Please refer Renesas Manual to generate ufpk.key and upfk.key_enc.key.
After generating "rfp" format key, you can download it to flash data area by using Renesas flash programmer.
The default address for "rfp" key is `0x08001000U` which is set at `user_settings.h`.

### 4) Generate Signature for app V1
You can derive bair binary file (app_RA.bin) by objcopy command as follows.
### 5) Generate Signature for app V1
You can derive the binary file (app_RA.bin) by objcopy command as follows.

```
$ aarch64-none-elf-objcopy.exe -O binary -j .text -j .data app_RA.elf app_RA.bin
```

`sign` command under tools/keytools benerates a signature for the binary with a specified version.
`sign` command under tools/keytools generates a signature for the binary with a specified version.
It generates a file contain a partition header and application image.
The partition header contain generated signature and other control fields.
The partition header contain generated signature and other control fields.
Output file name is made up from the input file name and version like app_RenesasRx01_v1.0_signed.bin.
It needs to specify `--rsa2048enc` option to sign the image because SCE assumes to have DigestInfo structure before hashed data.

Expand All @@ -211,18 +213,18 @@ Signing the digest...
Output image(s) successfully created.
```

### 5) Download the app V1
### 6) Download the app V1

You can convert the binary file to hex format and download it to the board by Flash Programmer. The partition starts at "0x00020000".

```
$ aarch64-none-elf-objcopy.exe -I binary -O srec --change-addresses=0x00020000 app_RA_v1.0_signed.bin app_RA_v1.0_signed.hex
```
### 6) Execute inital boot
### 7) Execute initial boot

Now, you can download and start wolfBoot program by e2Studio debugger.
After starting the program, you can see the partition information as follows.
If the boot program succeeds integlity and authenticity check, it initiate the application V1.
If the boot program succeeds successfully and authenticity check then start application V1.
To initially run `wolfBoot` project,
1.) Right-Click the Project name.
2.) Select `Debug As` -> `Renesas GDB Hardware Debugging`
Expand All @@ -245,13 +247,13 @@ Application Entry Address: 0x00020200
Magic: WOLF
Version: 01
Status: FF
Tail Mgc:
Tail Mgc:

=== Update Partition[00090000] ===
Magic:
Magic:
Version: 00
Status: FF
Tail Mgc:
Tail Mgc:
Current Firmware Version : 1

Calling wolfBoot_success()
Expand All @@ -270,7 +272,7 @@ Status: 00
Tail Mgc: BOOT

=== Update Partition[00090000] ===
Magic:
Magic:
Version: 00
Status: FF
Tail Mgc:
Expand All @@ -281,7 +283,7 @@ You can also see flashing each LED light in 1 second. Notable things about V1 ap
it will also call wolfBoot_update_trigger() so that it tells wolfBoot that new version exists.
We are going to generate and download V2 application into "Update partition".

### 7) Generate Signed app V2 and download it
### 8) Generate Signed app V2 and download it

Similar to V1, you can sign and generate a binary of V2. The update partition starts at "0x00090000".
You can download it by the flash programmer.
Expand All @@ -294,9 +296,9 @@ $ sign --rsa2048enc app_RA.bin ../../../../../pri-rsa2048.der 2.0
$ aarch64-none-elf-objcopy.exe -I binary -O srec --change-addresses=0x00090000 app_RA_v2.0_signed.bin app_RA_v2.0_signed.hex
```

### 8) Reboot and secure update to V2
### 9) Reboot and secure update to V2

The boot program checks integlity and authenticity of V2, swap the partition safely and initiates V2.
The boot program checks integrity and authenticity of V2, swap the partition safely and initiates V2.
You will see following message after the partition information.
You can also see flashing each LED light in 5 second.

Expand All @@ -322,7 +324,7 @@ Tail Mgc: BOOT
Magic: WOLF
Version: 01
Status: FF
Tail Mgc:
Tail Mgc:
Current Firmware Version : 2

Calling wolfBoot_success()
Expand Down