Skip to content

Commit 6e88701

Browse files
rizlikdanielinux
authored andcommitted
address reviewer comments
1 parent e3c7f6c commit 6e88701

File tree

2 files changed

+145
-146
lines changed

2 files changed

+145
-146
lines changed

docs/Targets.md

Lines changed: 143 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ This README describes configuration of supported targets.
1010
* [Infineon AURIX TC3xx](#infineon-aurix-tc3xx)
1111
* [Intel x86-64 Intel FSP](#intel-x86_64-with-intel-fsp-support)
1212
* [Kontron VX3060-S2](#kontron-vx3060-s2)
13+
* [Microchip PIC32CK](#microchip-pic32ck)
14+
* [Microchip PIC32CZ](#microchip-pic32cz)
1315
* [Microchip SAMA5D3](#microchip-sama5d3)
1416
* [Microchip SAME51](#microchip-same51)
1517
* [Nordic nRF52840](#nordic-nrf52840)
@@ -44,8 +46,6 @@ This README describes configuration of supported targets.
4446
* [STM32WB55](#stm32wb55)
4547
* [TI Hercules TMS570LC435](#ti-hercules-tms570lc435)
4648
* [Xilinx Zynq UltraScale](#xilinx-zynq-ultrascale)
47-
* [Microchip PIC32CZ](#microchip-pic32cz)
48-
* [Microchip PIC32CK](#microchip-pic32ck)
4949

5050
## STM32F4
5151

@@ -1556,6 +1556,147 @@ at addresses 0x400000 and 0x800000, authenticate, load to DRAM and stage from
15561556
Ensure that the application is compiled to run from `LOAD_ADDRESS`.
15571557
Check `test-app/ARM-sama5d3.ld` for details.
15581558

1559+
## Microchip PIC32CK
1560+
1561+
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.
1562+
1563+
### Configuration
1564+
1565+
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.
1566+
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.
1567+
1568+
### Building
1569+
1570+
To build wolfBoot for the PIC32CK:
1571+
1572+
1. Configure the build using the example configuration file:
1573+
1574+
```sh
1575+
cp config/examples/pic32ck.config .config
1576+
make clean
1577+
make
1578+
```
1579+
1580+
2. Sign the application:
1581+
1582+
```sh
1583+
./tools/keytools/sign --ed25519 --sha256 ./test-app/image.bin wolfboot_signing_private_key.der 1
1584+
./tools/keytools/sign --ed25519 --sha256 ./test-app/image.bin wolfboot_signing_private_key.der 2
1585+
```
1586+
1587+
### Programming and Testing
1588+
1589+
To program the flash chip using the JLink tool:
1590+
1591+
Identify the correct JLink device for your PIC32CK. In the examples the model is PIC32CK2051SG.
1592+
1593+
1. Run the following command:
1594+
1595+
```sh
1596+
JLinkExe -device PIC32CK2051SG -if SWD -speed 4000 -autoconnect 1
1597+
```
1598+
1599+
2. At the JLink prompt, use the following commands:
1600+
1601+
```
1602+
halt
1603+
reset
1604+
erase
1605+
loadfile wolfboot.bin 0x08000000
1606+
loadfile test-app/image_v1_signed.bin 0x0c000000
1607+
loadfile test-app/image_v2_signed.bin 0x0c07f000
1608+
reset
1609+
q
1610+
```
1611+
1612+
### Programming with MPlab IPE
1613+
1614+
In order to program using the MPlab IPE, you need to create the hex files for wolfBoot, and the signed application images:
1615+
1616+
```bash
1617+
arm-none-eabi-objcopy -O ihex wolfboot.elf wolfboot.hex
1618+
arm-none-eabi-objcopy -I binary -O ihex --change-addresses=0x0C000000 test-app/image_v1_signed.bin image_v1_signed.hex
1619+
arm-none-eabi-objcopy -I binary -O ihex --change-addresses=0x0C07F000 test-app/image_v2_signed.bin image_v2_signed.hex
1620+
```
1621+
1622+
then enable advanced setting in the MPLAB IPE GUI, and enable the "Allow Import Multiple Hex file" option in the Production view.
1623+
Once enabled the option, load the hex files into the MPLAB IPE GUI (File -> Import -> Multiple hex) and program the device.
1624+
1625+
### Behavior During Testing
1626+
1627+
- 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.
1628+
## Microchip PIC32CZ
1629+
1630+
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.
1631+
1632+
### Configuration
1633+
1634+
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`.
1635+
1636+
### Building
1637+
1638+
To build wolfBoot for the PIC32CZ:
1639+
1640+
1. Configure the build using the example configuration file:
1641+
1642+
```sh
1643+
cp config/examples/pic32cz.config .config
1644+
make clean
1645+
make
1646+
```
1647+
1648+
2. Sign the application:
1649+
1650+
```sh
1651+
./tools/keytools/sign --ed25519 --sha256 ./test-app/image.bin wolfboot_signing_private_key.der 1
1652+
./tools/keytools/sign --ed25519 --sha256 ./test-app/image.bin wolfboot_signing_private_key.der 2
1653+
```
1654+
1655+
### Programming and Testing
1656+
1657+
To program the flash chip using the JLink tool:
1658+
1659+
Identify the correct JLink device for your PIC32CZ board. In the examples the model is PIC32CZ4010CA90.
1660+
1661+
1. Run the following command:
1662+
1663+
```sh
1664+
JLinkExe -device PIC32CZ4010CA90 -if SWD -speed 4000 -autoconnect 1
1665+
```
1666+
1667+
2. At the JLink prompt, use the following commands:
1668+
1669+
```
1670+
halt
1671+
reset
1672+
erase
1673+
loadfile wolfboot.bin 0x08000000
1674+
loadfile test-app/image_v1_signed.bin 0x0c000000
1675+
loadfile test-app/image_v2_signed.bin 0x0c200000
1676+
reset
1677+
q
1678+
```
1679+
1680+
### Programming with MPLAB IPE
1681+
1682+
In order to program using the MPLAB IPE, you need to create the hex files for wolfBoot, and the signed application images:
1683+
1684+
```bash
1685+
arm-none-eabi-objcopy -O ihex wolfboot.elf wolfboot.hex
1686+
arm-none-eabi-objcopy -I binary -O ihex --change-addresses=0x0C000000 test-app/image_v1_signed.bin image_v1_signed.hex
1687+
arm-none-eabi-objcopy -I binary -O ihex --change-addresses=0x0C200000 test-app/image_v2_signed.bin image_v2_signed.hex
1688+
```
1689+
1690+
then enable advanced setting in the MPLAB IPE GUI, and enable the "Allow Import Multiple Hex file" option in the Production view.
1691+
Once enabled the option, load the hex files into the MPLAB IPE GUI (File -> Import -> Multiple hex) and program the device.
1692+
1693+
### Behavior During Testing
1694+
1695+
The test behavior depends on whether the `DUALBANK_SWAP` feature is enabled:
1696+
1697+
- **If `DUALBANK_SWAP=1`:** The higher version of the application will be automatically selected, and LED1 will turn on.
1698+
- **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.
1699+
15591700

15601701
## Microchip SAME51
15611702

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

34053546
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.

hal/pic32c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ int pic32_flash_write(uint32_t address, const uint8_t *data, int len)
248248
if (!pic32_addr_is_dqword_aligned(address) || len < FCW_WRITE_SIZE) {
249249
_addr = pic32_addr_dqword_align(address);
250250
/* Setup an aligned buffer with the following rules:
251-
* - For bytes outside the writing range: 0xFF (no change)
252-
* - For bytes inside the writing range: data | !current_data
251+
* - For addresses outside the writing range: 0xFF (no change)
252+
* - For addresses inside the writing range: data | !current_data
253253
*
254254
* This approach ensures we only flip bits from 1 to 0 when writing
255255
* without an erase operation. When the address is aligned and length

0 commit comments

Comments
 (0)