Merge pull request #44 from wolfSSL/psoc6

Psoc6 support
pull/48/head
David Garske 2020-05-20 08:35:38 -07:00 committed by GitHub
commit a48bc603d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 592 additions and 30 deletions

View File

@ -1,4 +1,3 @@
tar rem:3333
file wolfboot.elf
foc c

View File

@ -57,9 +57,8 @@ ifeq ($(SIGN),ED25519)
./lib/wolfssl/wolfcrypt/src/wolfmath.o \
./lib/wolfssl/wolfcrypt/src/fe_low_mem.o
PUBLIC_KEY_OBJS=./src/ed25519_pub_key.o
CFLAGS+=-DWOLFBOOT_SIGN_ED25519 -nostdlib \
CFLAGS+=-DWOLFBOOT_SIGN_ED25519 \
-Wstack-usage=1024
LDFLAGS+=-nostdlib
endif
ifeq ($(SIGN),RSA2048)
@ -191,10 +190,6 @@ wolfboot.bin: wolfboot.elf
@echo "\t[BIN] $@"
$(Q)$(OBJCOPY) -O binary $^ $@
wolfboot.hex: wolfboot.elf
@echo "\t[HEX] $@"
$(Q)$(OBJCOPY) -O ihex $^ $@
align: wolfboot-align.bin
.bootloader-partition-size:
@ -256,6 +251,12 @@ $(LSCRIPT): hal/$(TARGET).ld .bootloader-partition-size FORCE
sed -e "s/##WOLFBOOT_PARTITION_BOOT_ADDRESS##/`cat .bootloader-partition-size`/g" \
> $@
hex: wolfboot.hex
%.hex:%.elf
@echo "\t[ELF2HEX] $@"
@$(OBJCOPY) -O ihex $^ $@
src/ed25519_pub_key.c: ed25519.der
src/ecc256_pub_key.c: ecc256.der

47
arch.mk
View File

@ -134,17 +134,6 @@ ifeq ($(TARGET),lpc)
OBJS+=$(MCUXPRESSO_DRIVERS)/drivers/fsl_usart.o $(MCUXPRESSO_DRIVERS)/drivers/fsl_flexcomm.o
endif
CFLAGS+=-DARCH_FLASH_OFFSET=$(ARCH_FLASH_OFFSET)
## Toolchain setup
CC=$(CROSS_COMPILE)gcc
LD=$(CROSS_COMPILE)gcc
AS=$(CROSS_COMPILE)gcc
OBJCOPY:=$(CROSS_COMPILE)objcopy
SIZE:=$(CROSS_COMPILE)size
BOOT_IMG?=test-app/image.bin
ifeq ($(TARGET),stm32f4)
SPI_TARGET=stm32
endif
@ -162,6 +151,42 @@ ifeq ($(TARGET),stm32wb)
endif
endif
ifeq ($(TARGET),psoc6)
CORTEX_M0=1
PKA_EXTRA_OBJS+= $(CYPRESS_PDL)/drivers/source/cy_flash.o \
$(CYPRESS_PDL)/drivers/source/cy_ipc_pipe.o \
$(CYPRESS_PDL)/drivers/source/cy_ipc_sema.o \
$(CYPRESS_PDL)/drivers/source/cy_ipc_drv.o \
$(CYPRESS_PDL)/drivers/source/cy_device.o \
$(CYPRESS_PDL)/drivers/source/cy_sysclk.o \
$(CYPRESS_PDL)/drivers/source/cy_sysint.o \
$(CYPRESS_PDL)/drivers/source/cy_syslib.o \
$(CYPRESS_PDL)/drivers/source/cy_ble_clk.o \
$(CYPRESS_PDL)/drivers/source/cy_wdt.o \
$(CYPRESS_PDL)/drivers/source/TOOLCHAIN_GCC_ARM/cy_syslib_gcc.o \
$(CYPRESS_PDL)/devices/templates/COMPONENT_MTB/COMPONENT_CM0P/system_psoc6_cm0plus.o
CFLAGS+=-I$(CYPRESS_PDL)/drivers/include/ \
-I$(CYPRESS_PDL)/devices/include \
-I$(CYPRESS_PDL)/cmsis/include \
-I$(CYPRESS_TARGET_LIB) \
-I$(CYPRESS_CORE_LIB)/include \
-I$(CYPRESS_PDL)/devices/include/ip \
-I$(CYPRESS_PDL)/devices/templates/COMPONENT_MTB \
-DCY8C624ABZI_D44
ARCH_FLASH_OFFSET=0x10000000
endif
CFLAGS+=-DARCH_FLASH_OFFSET=$(ARCH_FLASH_OFFSET)
## Toolchain setup
CC=$(CROSS_COMPILE)gcc
LD=$(CROSS_COMPILE)gcc
AS=$(CROSS_COMPILE)gcc
OBJCOPY:=$(CROSS_COMPILE)objcopy
SIZE:=$(CROSS_COMPILE)size
BOOT_IMG?=test-app/image.bin
## Update mechanism
ifeq ($(ARCH),AARCH64)

View File

@ -0,0 +1,30 @@
ARCH?=ARM
TARGET?=psoc6
SIGN?=ED25519
HASH?=SHA256
CYPRESS_PDL?=./lib/psoc6pdl
CYPRESS_TARGET_LIB?=./lib/TARGET_CY8CKIT-062S2-43012
CYPRESS_CORE_LIB?=./lib/core-lib
DEBUG?=1
VTOR?=1
CORTEX_M0?=1
NO_ASM?=0
EXT_FLASH?=0
SPI_FLASH?=0
NO_XIP?=0
UART_FLASH?=0
ALLOW_DOWNGRADE?=0
NVM_FLASH_WRITEONCE?=1
WOLFBOOT_VERSION?=0
V?=0
SPMATH?=1
RAM_CODE?=0
DUALBANK_SWAP?=0
IMAGE_HEADER_SIZE?=256
PKA?=1
WOLFTPM?=0
WOLFBOOT_PARTITION_SIZE?=0x80000
WOLFBOOT_SECTOR_SIZE?=4096
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x10080000
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x10100000
WOLFBOOT_PARTITION_SWAP_ADDRESS?=10010000

View File

@ -552,3 +552,94 @@ make CROSS_COMPILE=aarch64-unknown-nto-qnx7.0.0-
#### Signing
`tools/keytools/sign.py --rsa4096 --sha3 /srv/linux-rpi4/vmlinux.bin rsa4096.der 1`
## Cypress PSoC-62S2 (CY8CKIT-062S2)
The Cypress PSoC 62S2 is a dual-core Cortex-M4 & Cortex-M0+ MCU. The secure boot process is managed by the M0+.
WolfBoot can be compiled as second stage flash bootloader to manage application verification and firmware updates.
### Building
The following configuration has been tested using PSoC 62S2 Wi-Fi BT Pioneer Kit (CY8CKIT-052S2-43012).
#### Target specific requirements
wolfBoot uses the following components to access peripherals on the PSoC:
* [Cypress Core Library](https://github.com/cypresssemiconductorco/core-lib)
* [PSoC 6 Peripheral Driver Library](https://github.com/cypresssemiconductorco/psoc6pdl)
* [CY8CKIT-062S2-43012 BSP](https://github.com/cypresssemiconductorco/TARGET_CY8CKIT-062S2-43012)
Cypress provides a [customized OpenOCD](https://github.com/cypresssemiconductorco/Openocd) for programming the flash and
debugging.
### Clock settings
wolfBoot configures PLL1 to run at 100 MHz and is driving `CLK_FAST`, `CLK_PERI`, and `CLK_SLOW` at that frequency.
#### Build configuration
The following configuration has been tested on the PSoC CY8CKIT-62S2-43012:
```
make TARGET=psoc6 \
NVM_FLASH_WRITEONCE=1 \
CYPRESS_PDL=./lib/psoc6pdl \
CYPRESS_TARGET_LIB=./lib/TARGET_CY8CKIT-062S2-43012 \
CYPRESS_CORE_LIB=./lib/core-lib \
WOLFBOOT_SECTOR_SIZE=4096
```
Note: A reference `.config` can be found in `./config/examples/cypsoc6.config`.
#### OpenOCD installation
Compile and install the customized OpenOCD.
Use the following configuration file when running `openocd` to connect to the PSoC6 board:
```
# openocd.cfg for PSoC-62S2
source [find interface/kitprog3.cfg]
transport select swd
adapter speed 1000
source [find target/psoc6_2m.cfg]
init
reset init
```
### Loading the firmware
To upload `factory.bin` to the device with OpenOCD, connect the device,
run OpenOCD with the configuration from the previous section, then connect
to the local openOCD server running on TCP port 4444 using `telnet localhost 4444`.
From the telnet console, type:
`program factory.bin 0x10000000`
When the transfer is finished, you can either close openOCD or start a debugging session.
### Debugging
Debugging with OpenOCD:
Use the OpenOCD configuration from the previous sections to run OpenOCD.
From another console, connect using gdb, e.g.:
```
arm-none-eabi-gdb
(gdb) target remote:3333
```
To reset the board to start from the M0+ flash bootloader position (wolfBoot reset handler), use
the monitor command sequence below:
```
(gdb) mon init
(gdb) mon reset init
(gdb) mon psoc6 reset_halt
```

152
hal/psoc6.c 100644
View File

@ -0,0 +1,152 @@
/* psoc6.c
*
* Copyright (C) 2020 wolfSSL Inc.
*
* This file is part of wolfBoot.
*
* wolfBoot is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfBoot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#include <stdint.h>
#include <target.h>
#include <string.h>
#include "image.h"
#include "cy_device_headers.h"
#include "cy_flash.h"
#include "cy_syspm.h"
#include "cy_sysclk.h"
#include "cy_syslib.h"
#include "cy_ipc_drv.h"
#include "psoc6_02_config.h"
#define ROW_SIZE (0x1000)
#define FLASH_BASE_ADDRESS (0x10000000)
#define CPU_FREQ (100000000)
uint8_t psoc6_write_buffer[ROW_SIZE];
#ifndef NVM_FLASH_WRITEONCE
# error "wolfBoot psoc6 HAL: no WRITEONCE support detected. Please define NVM_FLASH_WRITEONCE"
#endif
#ifdef __WOLFBOOT
static const cy_stc_pll_manual_config_t srss_0_clock_0_pll_0_pllConfig =
{
.feedbackDiv = 100,
.referenceDiv = 2,
.outputDiv = 4,
.lfMode = false,
.outputMode = CY_SYSCLK_FLLPLL_OUTPUT_AUTO,
};
static void hal_set_pll(void)
{
/*Set clock path 1 source to IMO, this feeds PLL1*/
Cy_SysClk_ClkPathSetSource(1U, CY_SYSCLK_CLKPATH_IN_IMO);
/*Set the input for CLK_HF0 to the output of the PLL, which is on clock path 1*/
Cy_SysClk_ClkHfSetSource(0U, CY_SYSCLK_CLKHF_IN_CLKPATH1);
Cy_SysClk_ClkHfSetDivider(0U, CY_SYSCLK_CLKHF_NO_DIVIDE);
/*Set divider for CM4 clock to 0, might be able to lower this to save power if needed*/
Cy_SysClk_ClkFastSetDivider(0U);
/*Set divider for peripheral and CM0 clock to 0 - This must be 0 to get fastest clock to CM0*/
Cy_SysClk_ClkPeriSetDivider(0U);
/*Set divider for CM0 clock to 0*/
Cy_SysClk_ClkSlowSetDivider(0U);
/*Set flash memory wait states */
Cy_SysLib_SetWaitStates(false, 100);
/*Configure PLL for 100 MHz*/
if (CY_SYSCLK_SUCCESS != Cy_SysClk_PllManualConfigure(1U, &srss_0_clock_0_pll_0_pllConfig))
{
while(1)
;
}
/*Enable PLL*/
if (CY_SYSCLK_SUCCESS != Cy_SysClk_PllEnable(1U, 10000u))
{
while(1)
;
}
}
void hal_init(void)
{
Cy_PDL_Init(CY_DEVICE_CFG);
Cy_Flash_Init();
hal_set_pll();
}
void hal_prepare_boot(void)
{
}
#endif
/* Only Row-aligned writes allowed. This is guaranteed by wolfBoot if NVM_CACHE is
* in use (via NVM_FLASH_WRITEONCE=1), as unaligned writes become cached.
*/
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
{
const uint8_t *src = data;
if (len < ROW_SIZE)
return -1;
if ((((uint32_t)data) & FLASH_BASE_ADDRESS) == FLASH_BASE_ADDRESS) {
if (len != ROW_SIZE) {
return -1;
}
memcpy(psoc6_write_buffer, data, len);
src = psoc6_write_buffer;
}
while (len) {
Cy_Flash_ProgramRow(address, (const uint32_t *) src);
len -= ROW_SIZE;
if ((len > 0) && (len < ROW_SIZE))
return -1;
}
return 0;
}
void RAMFUNCTION hal_flash_unlock(void)
{
}
void RAMFUNCTION hal_flash_lock(void)
{
}
int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
{
int start = -1, end = -1;
uint32_t end_address;
uint32_t p = (uint32_t)address;
if (len == 0)
return -1;
end_address = address + len;
while ((end_address - p) >= ROW_SIZE) {
Cy_Flash_EraseRow(p);
p += ROW_SIZE;
}
return 0;
}

96
hal/psoc6.ld 100644
View File

@ -0,0 +1,96 @@
MEMORY
{
FLASH (rx) : ORIGIN = 0x10000000, LENGTH = ##WOLFBOOT_PARTITION_BOOT_ADDRESS##
RAM (rwx) : ORIGIN = 0x08000000, LENGTH = 64K
}
SECTIONS
{
.text :
{
_start_text = .;
__Vectors = .;
KEEP(*(.isr_vector))
KEEP(*(.vectors))
. = ALIGN(0x400);
*(.text*)
*(.rodata*)
*(.init*)
*(.fini*)
. = ALIGN(4);
_end_text = .;
__etext = .;
} > FLASH
.edidx :
{
. = ALIGN(4);
*(.ARM.exidx*)
} > FLASH
_stored_data = .;
.data : AT (_stored_data)
{
_start_data = .;
__data_start__ = .;
KEEP(*(.data*))
. = ALIGN(4);
KEEP(*(.ramcode))
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
KEEP(*(.cy_ramfunc*))
. = ALIGN(4);
_end_data = .;
__data_end__ = .;
} > RAM
.bss (NOLOAD) :
{
_start_bss = .;
__bss_start__ = .;
__zero_table_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
_end_bss = .;
__bss_end__ = .;
__zero_table_end__ = .;
_end = .;
. = ALIGN(0x100);
__ramVectors = .;
} > RAM
. = ALIGN(4);
}
END_STACK = ORIGIN(RAM) + LENGTH(RAM);
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - 0x4000;
PROVIDE(__stack = __StackTop);

56
hal/skeleton.c 100644
View File

@ -0,0 +1,56 @@
/* skeleton.c
*
* Stubs for custom HAL implementation. Defines the
* functions used by wolfboot for a specific target.
*
* Copyright (C) 2020 wolfSSL Inc.
*
* This file is part of wolfBoot.
*
* wolfBoot is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfBoot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#include <stdint.h>
#include <target.h>
#include "image.h"
#ifdef __WOLFBOOT
void hal_init(void)
{
}
void hal_prepare_boot(void)
{
}
#endif
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
{
}
void RAMFUNCTION hal_flash_unlock(void)
{
}
void RAMFUNCTION hal_flash_lock(void)
{
}
int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
{
}

View File

@ -34,6 +34,12 @@
#endif
#define IMAGE_HEADER_OFFSET (2 * sizeof(uint32_t))
#ifdef NVM_FLASH_WRITEONCE
# define FLASHBUFFER_SIZE WOLFBOOT_SECTOR_SIZE
#else
# define FLASHBUFFER_SIZE IMAGE_HEADER_SIZE
#endif
#define WOLFBOOT_MAGIC 0x464C4F57 /* WOLF */
#define WOLFBOOT_MAGIC_TRAIL 0x544F4F42 /* BOOT */
@ -111,4 +117,5 @@ int wolfBoot_dualboot_candidate(void);
# error "No valid hash algorithm defined!"
#endif
#endif /* !WOLFBOOT_H */

View File

@ -35,6 +35,7 @@ extern uint32_t *END_STACK;
extern void main(void);
void isr_reset(void) {
register unsigned int *src, *dst;
#if defined(PLATFORM_kinetis)
@ -75,7 +76,6 @@ void isr_empty(void)
/* Ignore unmapped event and continue */
}
#define VTOR (*(volatile uint32_t *)(0xE000ED08))
/* This is the main loop for the bootloader.
*
@ -87,6 +87,7 @@ void isr_empty(void)
* - Call the application entry point
*
*/
#define VTOR (*(volatile uint32_t *)(0xE000ED08))
static void *app_entry;
static uint32_t app_end_stack;
@ -114,12 +115,19 @@ void RAMFUNCTION do_boot(const uint32_t *app_offset)
asm volatile("mov pc, %0" ::"r"(app_entry));
}
#ifdef PLATFORM_psoc6
typedef void(*NMIHANDLER)(void);
# define isr_NMI (NMIHANDLER)(0x0000000D)
#else
# define isr_NMI isr_empty
#endif
__attribute__ ((section(".isr_vector")))
void (* const IV[])(void) =
{
(void (*)(void))(&END_STACK),
isr_reset, // Reset
isr_fault, // NMI
isr_NMI, // NMI
isr_fault, // HardFault
isr_fault, // MemFault
isr_fault, // BusFault

View File

@ -39,9 +39,11 @@ uint32_t ext_cache;
#define PART_UPDATE_ENDFLAGS ((WOLFBOOT_PARTITION_UPDATE_ADDRESS + WOLFBOOT_PARTITION_SIZE) - TRAILER_SKIP)
#ifdef NVM_FLASH_WRITEONCE
#define NVM_CACHE_SIZE WOLFBOOT_SECTOR_SIZE
#include <stddef.h>
extern void *memcpy(void *dst, const void *src, size_t n);
static uint8_t NVM_CACHE[WOLFBOOT_SECTOR_SIZE];
static uint8_t NVM_CACHE[NVM_CACHE_SIZE];
int RAMFUNCTION hal_trailer_write(uint32_t addr, uint8_t val) {
uint32_t addr_align = addr & (~(WOLFBOOT_SECTOR_SIZE - 1));
uint32_t addr_off = addr & (WOLFBOOT_SECTOR_SIZE - 1);

View File

@ -32,8 +32,6 @@ static volatile const uint32_t __attribute__((used)) wolfboot_version = WOLFBOOT
extern void (** const IV_RAM)(void);
#endif
#define FLASHBUFFER_SIZE 256
#ifndef DUALBANK_SWAP
static int wolfBoot_copy_sector(struct wolfBoot_image *src, struct wolfBoot_image *dst, uint32_t sector)
{

View File

@ -28,7 +28,6 @@
#include "spi_flash.h"
#include "wolfboot/wolfboot.h"
#define FLASHBUFFER_SIZE 256
#ifdef RAM_CODE
extern unsigned int _start_text;

View File

@ -0,0 +1,55 @@
MEMORY
{
FLASH (rx) : ORIGIN = ##WOLFBOOT_TEST_APP_ADDRESS##, LENGTH = ##WOLFBOOT_TEST_APP_SIZE##
RAM (rwx) : ORIGIN = 0x08000000, LENGTH = 64K
}
SECTIONS
{
.text :
{
_start_text = .;
KEEP(*(.isr_vector))
. = ALIGN(0x400);
*(.text*)
*(.rodata*)
*(.init*)
*(.fini*)
. = ALIGN(4);
_end_text = .;
} > FLASH
.edidx :
{
. = ALIGN(4);
*(.ARM.exidx*)
} > FLASH
_stored_data = .;
.data : AT (_stored_data)
{
_start_data = .;
KEEP(*(.data*))
. = ALIGN(4);
_end_data = .;
} > RAM
.bss (NOLOAD) :
{
_start_bss = .;
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
_end_bss = .;
__bss_end__ = .;
_end = .;
} > RAM
. = ALIGN(4);
}
END_STACK = ORIGIN(RAM) + LENGTH(RAM);
PROVIDE(_start_heap = _end);
PROVIDE(_end_stack = ORIGIN(RAM) + LENGTH(RAM));

View File

@ -46,6 +46,10 @@ ifeq ($(TARGET),stm32f7)
LSCRIPT_TEMPLATE=ARM-stm32f7.ld
CFLAGS+=-DDUALBANK_SWAP
endif
ifeq ($(TARGET),psoc6)
LSCRIPT_TEMPLATE=ARM-psoc6.ld
endif
LDFLAGS:=$(CFLAGS) -T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=image.map
ifeq ($(EXT_FLASH),1)

View File

@ -0,0 +1,35 @@
/* main.c
*
* Test bare-metal boot-led-on application
*
* Copyright (C) 2020 wolfSSL Inc.
*
* This file is part of wolfBoot.
*
* wolfBoot is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfBoot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "wolfboot/wolfboot.h"
void main(void) {
/* Wait for reboot */
while(1)
;
}

View File

@ -10,6 +10,9 @@ ifeq ($(ARCH),)
MCUXPRESSO_CMSIS?=$(MCUXPRESSO)/CMSIS
FREEDOM_E_SDK?=$(HOME)/src/freedom-e-sdk
STM32CUBE?=$(HOME)/STM32Cube/Repository/STM32Cube_FW_WB_V1.3.0
CYPRESS_PDL?=$(HOME)/src/psoc6pdl
CYPRESS_TARGET_LIB?=$(HOME)/src/TARGET_CY8CKIT-062S2-43012
CYPRESS_CORE_LIB?=$(HOME)/src/cypress-core-lib
DEBUG?=0
VTOR?=1
CORTEX_M0?=0
@ -41,8 +44,9 @@ endif
CONFIG_VARS:= ARCH TARGET SIGN HASH MCUXPRESSO MCUXPRESSO_CPU MCUXPRESSO_DRIVERS \
MCUXPRESSO_CMSIS FREEDOM_E_SDK STM32CUBE DEBUG VTOR CORTEX_M0 NO_ASM EXT_FLASH \
SPI_FLASH NO_XIP UART_FLASH ALLOW_DOWNGRADE NVM_FLASH_WRITEONCE WOLFBOOT_VERSION V \
MCUXPRESSO_CMSIS FREEDOM_E_SDK STM32CUBE CYPRESS_PDL CYPRESS_CORE_LIB CYPRESS_TARGET_LIB DEBUG VTOR \
CORTEX_M0 NO_ASM EXT_FLASH SPI_FLASH NO_XIP UART_FLASH ALLOW_DOWNGRADE NVM_FLASH_WRITEONCE \
WOLFBOOT_VERSION V \
SPMATH RAM_CODE DUALBANK_SWAP IMAGE_HEADER_SIZE PKA WOLFTPM \
WOLFBOOT_PARTITION_SIZE WOLFBOOT_SECTOR_SIZE \
WOLFBOOT_PARTITION_BOOT_ADDRESS WOLFBOOT_PARTITION_UPDATE_ADDRESS \

View File

@ -130,7 +130,6 @@ static void keygen_rsa(WC_RNG *rng, char *pubkeyfile, int size)
exit(4);
}
fwrite(priv_der, privlen, 1, fpriv);
fwrite(pub, 32, 1, fpriv);
fclose(fpriv);
fpub = fopen(pubkeyfile, "w");
@ -146,7 +145,7 @@ static void keygen_rsa(WC_RNG *rng, char *pubkeyfile, int size)
fwritekey(pub_der, publen, fpub);
fprintf(fpub, "\n};\n");
fprintf(fpub, "const uint32_t ecc256_pub_key_len = %d;\n", publen);
fprintf(fpub, "const uint32_t rsa%d_pub_key_len = %d;\n", size, publen);
fclose(fpub);
}
#endif
@ -233,6 +232,7 @@ static void keygen_ed25519(WC_RNG *rng, char *pubkfile)
exit(3);
}
fwrite(priv, 32, 1, fpriv);
fwrite(pub, 32, 1, fpriv);
fclose(fpriv);
fpub = fopen(pubkfile, "w");
if (fpub == NULL) {

View File

@ -126,8 +126,8 @@ int main(int argc, char** argv)
const char* signature_file = NULL;
char output_image_file[PATH_MAX];
char* tmpstr;
const char* sign_str = NULL;
const char* hash_str = NULL;
const char* sign_str = "AUTO";
const char* hash_str = "SHA256";
FILE *f, *f2;
uint8_t* key_buffer = NULL;
size_t key_buffer_sz = 0;