Skip to content

Commit 2d6cf95

Browse files
rizlikdanielinux
authored andcommitted
add support for PIC32CZ and PIC32CK
1 parent 4154057 commit 2d6cf95

File tree

16 files changed

+1286
-1
lines changed

16 files changed

+1286
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Test PIC32CZ and PIC32CK Build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build-pic32cz:
11+
uses: ./.github/workflows/test-build.yml
12+
with:
13+
arch: ARM
14+
config-file: config/examples/pic32cz.config
15+
make-args: "TARGET=pic32cz"
16+
build-pic32ck:
17+
uses: ./.github/workflows/test-build.yml
18+
with:
19+
arch: ARM
20+
config-file: config/examples/pic32ck.config
21+
make-args: "TARGET=pic32ck"

arch.mk

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ ifeq ($(ARCH),ARM)
156156
SPI_TARGET=stm32
157157
endif
158158

159+
ifeq ($(TARGET),pic32cz)
160+
ARCH_FLASH_OFFSET=0x08000000
161+
CORTEX_M7=1
162+
OBJS+=hal/pic32c.o
163+
endif
164+
165+
ifeq ($(TARGET),pic32ck)
166+
ARCH_FLASH_OFFSET=0x08000000
167+
CORTEX_M33=1
168+
OBJS+=hal/pic32c.o
169+
endif
170+
159171
ifeq ($(TARGET),stm32l4)
160172
SPI_TARGET=stm32
161173
ARCH_FLASH_OFFSET=0x08000000

config/examples/pic32ck.config

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ARCH=ARM
2+
TARGET=pic32ck
3+
SIGN?=ED25519
4+
HASH?=SHA256
5+
VTOR?=1
6+
SPMATH?=1
7+
NO_MPU=1
8+
WOLFBOOT_PARTITION_SIZE=0x10000
9+
BOOTLOADER_PARTITION_SIZE=0x20000
10+
WOLFBOOT_SECTOR_SIZE=0x1000
11+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x0c000000
12+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x0c07f000
13+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x0c0fe000
14+
TZEN=0

config/examples/pic32cz.config

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ARCH=ARM
2+
TARGET=pic32cz
3+
SIGN?=ED25519
4+
HASH?=SHA256
5+
VTOR?=1
6+
SPMATH?=1
7+
NO_MPU=1
8+
WOLFBOOT_PARTITION_SIZE=0x10000
9+
WOLFBOOT_SECTOR_SIZE=0x1000
10+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x0c000000
11+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x0c200000
12+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x0c030000
13+
#DUALBANK_SWAP=0

docs/Targets.md

Lines changed: 144 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ This README describes configuration of supported targets.
4444
* [STM32WB55](#stm32wb55)
4545
* [TI Hercules TMS570LC435](#ti-hercules-tms570lc435)
4646
* [Xilinx Zynq UltraScale](#xilinx-zynq-ultrascale)
47-
47+
* [Microchip PIC32CZ](#microchip-pic32cz)
48+
* [Microchip PIC32CK](#microchip-pic32ck)
4849

4950
## STM32F4
5051

@@ -3402,3 +3403,145 @@ wolfBoot supports the AURIX TC3xx family of devices, and provides a demo applica
34023403
For detailed instructions on using wolfBoot with the AURIX TC3xx, please refer to [IDE/AURIX/README.md](../IDE/AURIX/README.md).
34033404

34043405
wolfBoot can also integrate with [wolfHSM](https://www.wolfssl.com/products/wolfhsm/) on AURIX TC3xx devices, offloading cryptographic operations and key storage to the AURIX HSM core. For more information on using wolfBoot with wolfHSM on AURIX devices, please contact us at [email protected].
3406+
3407+
## Microchip PIC32CZ
3408+
3409+
The PIC32CZ is a high-performance 32-bit microcontroller family from Microchip featuring an ARM Cortex-M7 core. wolfBoot has been tested on the PIC32CZCA91 Curiosity board, which has GPIO pins PB21 and PB22 connected to LED0 and LED1, respectively, for status indication.
3410+
3411+
### Configuration
3412+
3413+
The PIC32CZ supports a dual-bank update mechanism that can be activated using the `DUALBANK_SWAP=1` option in the configuration file. When activated, the boot partition must be configured to reside in the lower Program Flash Memory (PFM) area, while the update partition should be in the upper PFM area. An example configuration for the PIC32CZ with 4MB RAM is provided in `config/examples/pic32cz.config`.
3414+
3415+
### Building
3416+
3417+
To build wolfBoot for the PIC32CZ:
3418+
3419+
1. Configure the build using the example configuration file:
3420+
3421+
```sh
3422+
cp config/examples/pic32cz.config .config
3423+
make clean
3424+
make
3425+
```
3426+
3427+
2. Sign the application:
3428+
3429+
```sh
3430+
./tools/keytools/sign --ed25519 --sha256 ./test-app/image.bin wolfboot_signing_private_key.der 1
3431+
./tools/keytools/sign --ed25519 --sha256 ./test-app/image.bin wolfboot_signing_private_key.der 2
3432+
```
3433+
3434+
### Programming and Testing
3435+
3436+
To program the flash chip using the JLink tool:
3437+
3438+
Identify the correct JLink device for your PIC32CZ board. In the examples the model is PIC32CZ4010CA90.
3439+
3440+
1. Run the following command:
3441+
3442+
```sh
3443+
JLinkExe -device PIC32CZ4010CA90 -if SWD -speed 4000 -autoconnect 1
3444+
```
3445+
3446+
2. At the JLink prompt, use the following commands:
3447+
3448+
```
3449+
halt
3450+
reset
3451+
erase
3452+
loadfile wolfboot.bin 0x08000000
3453+
loadfile test-app/image_v1_signed.bin 0x0c000000
3454+
loadfile test-app/image_v2_signed.bin 0x0c200000
3455+
reset
3456+
q
3457+
```
3458+
3459+
### Programming with MPlab IPE
3460+
3461+
In order to program using the MPlab IPE, you need to create the hex files for wolfBoot, and the signed application images:
3462+
3463+
```bash
3464+
arm-none-eabi-objcopy -O ihex wolfboot.elf wolfboot.hex
3465+
arm-none-eabi-objcopy -I binary -O ihex --change-addresses=0x0C000000 test-app/image_v1_signed.bin image_v1_signed.hex
3466+
arm-none-eabi-objcopy -I binary -O ihex --change-addresses=0x0C200000 test-app/image_v2_signed.bin image_v2_signed.hex
3467+
```
3468+
3469+
Then enable advanced setting in the MPLAB IPE Gui, and enable the "Allow Import Multiple Hex file" option in the Production view.
3470+
After that load the hex files into the MPLAB IPE Gui (File -> Import -> Multiple hex) and program the device.
3471+
3472+
### Behavior During Testing
3473+
3474+
The test behavior depends on whether the `DUALBANK_SWAP` feature is enabled:
3475+
3476+
- **If `DUALBANK_SWAP=1`:** The higher version of the application will be automatically selected, and LED1 will turn on.
3477+
- **If `DUALBANK_SWAP=0`:** The application version 1 will boot first. The application will trigger the update and light LED0. On the next reset, wolfBoot will update the application, boot application version 2, and turn on LED1.
3478+
3479+
## Microchip PIC32CK
3480+
3481+
The PIC32CK is a high-performance 32-bit microcontroller family from Microchip featuring an ARM Cortex-M33 core. wolfBoot has been tested on the PIC32CKSG Curiosity board, which has GPIO pins PD20 and PB25 connected to LED0 and LED1, respectively, for status indication.
3482+
3483+
### Configuration
3484+
3485+
The PIC32CK SG family models support TrustZone. The flash and memory areas marked as secure or non secure depend on configuration settings. If setting `TZEN=0`, wolfBoot ignores TrustZone configuration, with the net effect to stage the application in the secure domain. In this case the flash area used to store BOOT and UPDATE partition should be marked as secure. The config file provided in `config/examples/pic32ck.config` sets `TZEN=0` and uses flash partition addresses that are marked as secure under default settings.
3486+
The PIC32CK supports a dual-bank update mechanism but, based on configuration settings, the swap may cause an area marked as secure to be mapped in non-secure flash space. For this reason `DUALBANK_SWAP` feature should be only used after precise configuration.
3487+
3488+
### Building
3489+
3490+
To build wolfBoot for the PIC32CK:
3491+
3492+
1. Configure the build using the example configuration file:
3493+
3494+
```sh
3495+
cp config/examples/pic32ck.config .config
3496+
make clean
3497+
make
3498+
```
3499+
3500+
2. Sign the application:
3501+
3502+
```sh
3503+
./tools/keytools/sign --ed25519 --sha256 ./test-app/image.bin wolfboot_signing_private_key.der 1
3504+
./tools/keytools/sign --ed25519 --sha256 ./test-app/image.bin wolfboot_signing_private_key.der 2
3505+
```
3506+
3507+
### Programming and Testing
3508+
3509+
To program the flash chip using the JLink tool:
3510+
3511+
Identify the correct JLink device for your PIC32CK. In the examples the model is PIC32CK2051SG.
3512+
3513+
1. Run the following command:
3514+
3515+
```sh
3516+
JLinkExe -device PIC32CK2051SG -if SWD -speed 4000 -autoconnect 1
3517+
```
3518+
3519+
2. At the JLink prompt, use the following commands:
3520+
3521+
```
3522+
halt
3523+
reset
3524+
erase
3525+
loadfile wolfboot.bin 0x08000000
3526+
loadfile test-app/image_v1_signed.bin 0x0c000000
3527+
loadfile test-app/image_v2_signed.bin 0x0c07f000
3528+
reset
3529+
q
3530+
```
3531+
3532+
### Programming with MPlab IPE
3533+
3534+
In order to program using the MPlab IPE, you need to create the hex files for wolfBoot, and the signed application images:
3535+
3536+
```bash
3537+
arm-none-eabi-objcopy -O ihex wolfboot.elf wolfboot.hex
3538+
arm-none-eabi-objcopy -I binary -O ihex --change-addresses=0x0C000000 test-app/image_v1_signed.bin image_v1_signed.hex
3539+
arm-none-eabi-objcopy -I binary -O ihex --change-addresses=0x0C07F000 test-app/image_v2_signed.bin image_v2_signed.hex
3540+
```
3541+
3542+
Then enable advanced setting in the MPLAB IPE Gui, and enable the "Allow Import Multiple Hex file" option in the Production view.
3543+
After that load the hex files into the MPLAB IPE Gui (File -> Import -> Multiple hex) and program the device.
3544+
3545+
### Behavior During Testing
3546+
3547+
- The application version 1 will boot first. The application will trigger the update and light LED0. On the next reset, wolfBoot will update the application, boot application version 2, and turn on LED1.

0 commit comments

Comments
 (0)