Skip to content

Commit f3d0d8f

Browse files
danielinuxdgarske
authored andcommitted
PSoC6 support: updated configuration, docs added to Targets.md, revert
custom NVM_CACHE_SIZE
1 parent 5d932fe commit f3d0d8f

7 files changed

Lines changed: 93 additions & 23 deletions

File tree

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ endif
141141

142142
ifeq ($(NVM_FLASH_WRITEONCE),1)
143143
CFLAGS+= -DNVM_FLASH_WRITEONCE
144-
ifneq ($(NVM_CACHE_SIZE),)
145-
CFLAGS+= -DNVM_CACHE_SIZE=$(NVM_CACHE_SIZE)
146-
endif
147144
endif
148145

149146

arch.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ ifeq ($(TARGET),psoc6)
165165
$(CYPRESS_PDL)/drivers/source/cy_wdt.o \
166166
$(CYPRESS_PDL)/drivers/source/TOOLCHAIN_GCC_ARM/cy_syslib_gcc.o \
167167
$(CYPRESS_PDL)/devices/templates/COMPONENT_MTB/COMPONENT_CM0P/system_psoc6_cm0plus.o
168-
PKA_EXTRA_CFLAGS+=-I$(CYPRESS_PDL)/drivers/include/ \
168+
CFLAGS+=-I$(CYPRESS_PDL)/drivers/include/ \
169169
-I$(CYPRESS_PDL)/devices/include \
170170
-I$(CYPRESS_PDL)/cmsis/include \
171171
-I$(CYPRESS_TARGET_LIB) \

docs/Targets.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,3 +552,87 @@ make CROSS_COMPILE=aarch64-unknown-nto-qnx7.0.0-
552552
#### Signing
553553

554554
`tools/keytools/sign.py --rsa4096 --sha3 /srv/linux-rpi4/vmlinux.bin rsa4096.der 1`
555+
556+
## Cypress PSoC-62S2 (CY8CKIT-062S2)
557+
558+
The Cypress PSoC 62S2 is a dual-core Cortex-M4 & Cortex-M0+ MCU. The secure boot process is managed by the M0+.
559+
WolfBoot can be compiled as second stage flash bootloader to manage application verification and firmware updates.
560+
561+
### Building
562+
563+
The following configuration has been tested using PSoC 62S2 Wi-Fi BT Pioneer Kit (CY8CKIT-052S2-43012).
564+
565+
#### Target specific requirements
566+
567+
wolfBoot uses the following components to access peripherals on the PSoC:
568+
569+
* [Cypress Core Library](https://github.com/cypresssemiconductorco/core-lib)
570+
* [PSoC 6 Peripheral Driver Library](https://github.com/cypresssemiconductorco/psoc6pdl)
571+
* [CY8CKIT-062S2-43012 BSP](https://github.com/cypresssemiconductorco/TARGET_CY8CKIT-062S2-43012)
572+
573+
Cypress provides a [customized OpenOCD](https://github.com/cypresssemiconductorco/Openocd) for programming the flash and
574+
debugging.
575+
576+
#### Build configuration
577+
578+
The following configuration has been tested on the PSoC CY8CKIT-62S2-43012:
579+
580+
```
581+
make TARGET=psoc6
582+
NVM_FLASH_WRITEONCE=1
583+
CYPRESS_PDL=/home/dan/src/psoc6pdl
584+
CYPRESS_TARGET_LIB=/home/dan/src/TARGET_CY8CKIT-062S2-43012
585+
CYPRESS_CORE_LIB=/home/dan/src/core-lib
586+
WOLFBOOT_SECTOR_SIZE=4096
587+
```
588+
589+
#### OpenOCD installation
590+
591+
Compile and install the customized OpenOCD.
592+
593+
Use the following configuration file when running `openocd` to connect to the PSoC6 board:
594+
595+
```
596+
# openocd.cfg for PSoC-62S2
597+
598+
source [find interface/kitprog3.cfg]
599+
transport select swd
600+
adapter speed 1000
601+
source [find target/psoc6_2m.cfg]
602+
init
603+
reset init
604+
```
605+
606+
### Loading the firmware
607+
608+
To upload `factory.bin` to the device with OpenOCD, connect the device,
609+
run OpenOCD with the configuration from the previous section, then connect
610+
to the local openOCD server running on TCP port 4444 using `telnet localhost 4444`.
611+
612+
From the telnet console, type:
613+
614+
`program factory.bin 0x10000000`
615+
616+
When the transfer is finished, you can either close openOCD or start a debugging session.
617+
618+
### Debugging
619+
620+
Debugging with OpenOCD:
621+
622+
Use the OpenOCD configuration from the previous sections to run OpenOCD.
623+
624+
From another console, connect using gdb, e.g.:
625+
626+
```
627+
arm-none-eabi-gdb
628+
(gdb) target remote:3333
629+
```
630+
631+
To reset the board to start from the M0+ flash bootloader position (wolfBoot reset handler), use
632+
the monitor command sequence below:
633+
634+
```
635+
(gdb) mon init
636+
(gdb) mon reset init
637+
(gdb) mon psoc6 reset_halt
638+
```

hal/psoc6.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ uint8_t psoc6_write_buffer[ROW_SIZE];
4444
# error "wolfBoot psoc6 HAL: no WRITEONCE support detected. Please define NVM_FLASH_WRITEONCE"
4545
#endif
4646

47-
#if (NVM_CACHE_SIZE != ROW_SIZE)
48-
# error "Wrong NVM_CACHE_SIZE specified for this platform. Please set NVM_CACHE_SIZE to match ROW_SIZE"
49-
#endif
50-
5147
#ifdef __WOLFBOOT
5248
/* Replace Cy_SysLib_DelayUs with a custom call that does not use SysTick
5349
* (required by Cy_SysClk_PllEnable)
@@ -129,7 +125,7 @@ void hal_prepare_boot(void)
129125
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
130126
{
131127
const uint8_t *src = data;
132-
if (len < NVM_CACHE_SIZE)
128+
if (len < ROW_SIZE)
133129
return -1;
134130
if ((((uint32_t)data) & FLASH_BASE_ADDRESS) == FLASH_BASE_ADDRESS) {
135131
if (len != ROW_SIZE) {
@@ -140,8 +136,8 @@ int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
140136
}
141137
while (len) {
142138
Cy_Flash_ProgramRow(address, (const uint32_t *) src);
143-
len -= NVM_CACHE_SIZE;
144-
if ((len > 0) && (len < NVM_CACHE_SIZE))
139+
len -= ROW_SIZE;
140+
if ((len > 0) && (len < ROW_SIZE))
145141
return -1;
146142
}
147143
return 0;
@@ -163,12 +159,9 @@ int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
163159
if (len == 0)
164160
return -1;
165161
end_address = address + len;
166-
/* Assume NVM_CACHE_SIZE is always defined for this platform
167-
* (see #error statements above)
168-
* */
169-
while ((end_address - p) >= NVM_CACHE_SIZE) {
162+
while ((end_address - p) >= ROW_SIZE) {
170163
Cy_Flash_EraseRow(p);
171-
p += NVM_CACHE_SIZE;
164+
p += ROW_SIZE;
172165
}
173166
return 0;
174167
}

include/wolfboot/wolfboot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#define IMAGE_HEADER_OFFSET (2 * sizeof(uint32_t))
3636

3737
#ifdef NVM_FLASH_WRITEONCE
38-
# define FLASHBUFFER_SIZE NVM_CACHE_SIZE
38+
# define FLASHBUFFER_SIZE WOLFBOOT_SECTOR_SIZE
3939
#else
4040
# define FLASHBUFFER_SIZE IMAGE_HEADER_SIZE
4141
#endif

src/libwolfboot.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ uint32_t ext_cache;
3939
#define PART_UPDATE_ENDFLAGS ((WOLFBOOT_PARTITION_UPDATE_ADDRESS + WOLFBOOT_PARTITION_SIZE) - TRAILER_SKIP)
4040

4141
#ifdef NVM_FLASH_WRITEONCE
42-
43-
#ifndef NVM_CACHE_SIZE
44-
#error "Please define NVM_CACHE_SIZE for this flash model"
45-
#endif
42+
#define NVM_CACHE_SIZE WOLFBOOT_SECTOR_SIZE
4643

4744
#include <stddef.h>
4845
extern void *memcpy(void *dst, const void *src, size_t n);

tools/config.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ ifeq ($(ARCH),)
2323
UART_FLASH?=0
2424
ALLOW_DOWNGRADE?=0
2525
NVM_FLASH_WRITEONCE?=0
26-
NVM_CACHE_SIZE=512
2726
WOLFBOOT_VERSION?=0
2827
V?=0
2928
SPMATH?=1
@@ -47,7 +46,7 @@ endif
4746
CONFIG_VARS:= ARCH TARGET SIGN HASH MCUXPRESSO MCUXPRESSO_CPU MCUXPRESSO_DRIVERS \
4847
MCUXPRESSO_CMSIS FREEDOM_E_SDK STM32CUBE CYPRESS_PDL CYPRESS_CORE_LIB CYPRESS_TARGET_LIB DEBUG VTOR \
4948
CORTEX_M0 NO_ASM EXT_FLASH SPI_FLASH NO_XIP UART_FLASH ALLOW_DOWNGRADE NVM_FLASH_WRITEONCE \
50-
NVM_CACHE_SIZE WOLFBOOT_VERSION V \
49+
WOLFBOOT_VERSION V \
5150
SPMATH RAM_CODE DUALBANK_SWAP IMAGE_HEADER_SIZE PKA WOLFTPM \
5251
WOLFBOOT_PARTITION_SIZE WOLFBOOT_SECTOR_SIZE \
5352
WOLFBOOT_PARTITION_BOOT_ADDRESS WOLFBOOT_PARTITION_UPDATE_ADDRESS \

0 commit comments

Comments
 (0)