Fix regressions detected by github workflows

pull/562/head
Daniele Lacamera 2025-04-07 14:37:37 +02:00
parent 50725b38d9
commit 386a172587
10 changed files with 22 additions and 16 deletions

View File

@ -45,6 +45,9 @@ project(wolfBoot)
include(cmake/utils.cmake) include(cmake/utils.cmake)
include(cmake/functions.cmake) include(cmake/functions.cmake)
include_directories(include)
include_directories(lib/wolfssl)
if(NOT DEFINED WOLFBOOT_TARGET) if(NOT DEFINED WOLFBOOT_TARGET)
message(FATAL_ERROR "WOLFBOOT_TARGET must be defined") message(FATAL_ERROR "WOLFBOOT_TARGET must be defined")
else() else()
@ -620,6 +623,8 @@ if(NOT SPMATH AND NOT SPMATHALL)
list(APPEND USER_SETTINGS USE_FAST_MATH) list(APPEND USER_SETTINGS USE_FAST_MATH)
endif() endif()
list(APPEND WOLFBOOT_DEFS WOLFSSL_USER_SETTINGS)
add_library(user_settings INTERFACE) add_library(user_settings INTERFACE)
target_compile_definitions(user_settings INTERFACE ${USER_SETTINGS} ${SIGN_OPTIONS}) target_compile_definitions(user_settings INTERFACE ${USER_SETTINGS} ${SIGN_OPTIONS})
@ -699,7 +704,7 @@ configure_file(include/target.h.in ${CMAKE_CURRENT_BINARY_DIR}/target.h @ONLY)
add_library(target INTERFACE) add_library(target INTERFACE)
target_compile_definitions(target INTERFACE ${WOLFBOOT_DEFS}) target_compile_definitions(target INTERFACE ${WOLFBOOT_DEFS})
target_include_directories(target BEFORE INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(target BEFORE INTERFACE ${CMAKE_CURRENT_BINARY_DIR} lib/wolfssl)
set(KEYSTORE ${CMAKE_CURRENT_BINARY_DIR}/keystore.c) set(KEYSTORE ${CMAKE_CURRENT_BINARY_DIR}/keystore.c)

View File

@ -253,7 +253,7 @@ ifeq ($(ARCH),ARM)
CORTEX_A5=1 CORTEX_A5=1
UPDATE_OBJS:=src/update_ram.o UPDATE_OBJS:=src/update_ram.o
CFLAGS+=-DWOLFBOOT_DUALBOOT -DEXT_FLASH -DNAND_FLASH -fno-builtin -ffreestanding CFLAGS+=-DWOLFBOOT_DUALBOOT -DEXT_FLASH -DNAND_FLASH -fno-builtin -ffreestanding
#CFLAGS+=-DWOLFBOOT_USE_STDLIBC CFLAGS+=-DWOLFBOOT_USE_STDLIBC
endif endif
## Cortex CPU ## Cortex CPU

View File

@ -78,7 +78,7 @@ static int division(uint32_t dividend,
return 0; return 0;
} }
static uint32_t div(uint32_t dividend, uint32_t divisor) static uint32_t div_u(uint32_t dividend, uint32_t divisor)
{ {
uint32_t quotient = 0; uint32_t quotient = 0;
uint32_t remainder = 0; uint32_t remainder = 0;
@ -504,7 +504,7 @@ static void nand_read_info(void)
nand_flash.bad_block_pos = (*(uint16_t *)(onfi_data + PARAMS_POS_FEATURES)) & 1; nand_flash.bad_block_pos = (*(uint16_t *)(onfi_data + PARAMS_POS_FEATURES)) & 1;
nand_flash.ext_page_len = *(uint16_t *)(onfi_data + PARAMS_POS_EXT_PARAM_PAGE_LEN); nand_flash.ext_page_len = *(uint16_t *)(onfi_data + PARAMS_POS_EXT_PARAM_PAGE_LEN);
nand_flash.parameter_page = *(uint16_t *)(onfi_data + PARAMS_POS_PARAMETER_PAGE); nand_flash.parameter_page = *(uint16_t *)(onfi_data + PARAMS_POS_PARAMETER_PAGE);
nand_flash.pages_per_block = div(nand_flash.block_size, nand_flash.page_size); nand_flash.pages_per_block = div_u(nand_flash.block_size, nand_flash.page_size);
nand_flash.pages_per_device = nand_flash.pages_per_block * nand_flash.block_count; nand_flash.pages_per_device = nand_flash.pages_per_block * nand_flash.block_count;
nand_flash.oob_size = *(uint16_t *)(onfi_data + PARAMS_POS_OOBSIZE); nand_flash.oob_size = *(uint16_t *)(onfi_data + PARAMS_POS_OOBSIZE);
nand_flash.revision = *(uint16_t *)(onfi_data + PARAMS_POS_REVISION); nand_flash.revision = *(uint16_t *)(onfi_data + PARAMS_POS_REVISION);
@ -605,8 +605,8 @@ static int nand_check_bad_block(uint32_t block)
int ext_flash_read(uintptr_t address, uint8_t *data, int len) int ext_flash_read(uintptr_t address, uint8_t *data, int len)
{ {
uint8_t buffer_page[NAND_FLASH_PAGE_SIZE]; uint8_t buffer_page[NAND_FLASH_PAGE_SIZE];
uint32_t block = div(address, nand_flash.block_size); /* The block where the address falls in */ uint32_t block = div_u(address, nand_flash.block_size); /* The block where the address falls in */
uint32_t page = div(address, nand_flash.page_size); /* The page where the address falls in */ uint32_t page = div_u(address, nand_flash.page_size); /* The page where the address falls in */
uint32_t start_page_in_block = mod(page, nand_flash.pages_per_block); /* The start page within this block */ uint32_t start_page_in_block = mod(page, nand_flash.pages_per_block); /* The start page within this block */
uint32_t in_block_offset = mod(address, nand_flash.block_size); /* The offset of the address within the block */ uint32_t in_block_offset = mod(address, nand_flash.block_size); /* The offset of the address within the block */
uint32_t remaining = nand_flash.block_size - in_block_offset; /* How many bytes remaining to read in the first block */ uint32_t remaining = nand_flash.block_size - in_block_offset; /* How many bytes remaining to read in the first block */
@ -637,7 +637,7 @@ int ext_flash_read(uintptr_t address, uint8_t *data, int len)
} while (ret < 0); } while (ret < 0);
/* Amount of pages to be read from this block */ /* Amount of pages to be read from this block */
pages_to_read = div((sz + nand_flash.page_size - 1), nand_flash.page_size); pages_to_read = div_u((sz + nand_flash.page_size - 1), nand_flash.page_size);
if (pages_to_read * nand_flash.page_size > remaining) if (pages_to_read * nand_flash.page_size > remaining)
pages_to_read--; pages_to_read--;

View File

@ -378,7 +378,7 @@ void do_boot(const uint32_t *app_offset)
wret = write(fd, app_offset, app_size); wret = write(fd, app_offset, app_size);
if (wret != app_size) { if (wret != app_size) {
wolfBoot_printf( "can't write test-app to memfd, address %p: fd %d rval %d errno %d\n", app_offset, fd, wret, errno); wolfBoot_printf( "can't write test-app to memfd, address %p\n", app_offset);
exit(-1); exit(-1);
} }
wolfBoot_printf("Stored test-app to memfd, address %p (%zu bytes)\n", app_offset, wret); wolfBoot_printf("Stored test-app to memfd, address %p (%zu bytes)\n", app_offset, wret);

View File

@ -205,7 +205,7 @@ extern "C" {
# define update_hash wc_Sha3Update # define update_hash wc_Sha3Update
# define final_hash wc_Sha3Final # define final_hash wc_Sha3Final
# define key_hash key_sha3_384 # define key_hash key_sha3_384
typedef wc_sha3_384 wolfBoot_hash_t; typedef wc_Sha3 wolfBoot_hash_t;
# define HDR_HASH HDR_SHA3_384 # define HDR_HASH HDR_SHA3_384
#else #else
# error "No valid hash algorithm defined!" # error "No valid hash algorithm defined!"

View File

@ -48,7 +48,7 @@
#endif #endif
#ifdef MMU #if defined(MMU) || defined (WOLFBOOT_FSP) || defined (ARCH_PPC)
/* Loader for elf32 or elf64 format program headers /* Loader for elf32 or elf64 format program headers
* Returns the entry point function * Returns the entry point function
*/ */
@ -181,7 +181,7 @@ int elf_hdr_size(const unsigned char *ehdr)
} }
return sz; return sz;
} }
#if !defined(MMU) && !defined(WOLFBOOT_FSP) && !defined(ARCH_PPC)
int elf_store_image_scattered(const unsigned char *hdr, unsigned long *entry_out, int ext_flash) { int elf_store_image_scattered(const unsigned char *hdr, unsigned long *entry_out, int ext_flash) {
const unsigned char *image; const unsigned char *image;
int is_elf32; int is_elf32;
@ -274,6 +274,7 @@ int elf_store_image_scattered(const unsigned char *hdr, unsigned long *entry_out
} }
return 0; return 0;
} }
#endif
int elf_load_image(uint8_t *image, uintptr_t *entry, int ext_flash) int elf_load_image(uint8_t *image, uintptr_t *entry, int ext_flash)

View File

@ -833,7 +833,7 @@ static int header_sha256(wc_Sha256 *sha256_ctx, struct wolfBoot_image *img)
if (stored_sha_len != WOLFBOOT_SHA_DIGEST_SIZE) if (stored_sha_len != WOLFBOOT_SHA_DIGEST_SIZE)
return -1; return -1;
#ifdef WOLFBOOT_ENABLE_WOLFHSM_CLIENT #ifdef WOLFBOOT_ENABLE_WOLFHSM_CLIENT
(void)wc_InitSha256_ex(&sha256_ctx, NULL, hsmClientDevIdHash); (void)wc_InitSha256_ex(sha256_ctx, NULL, hsmClientDevIdHash);
#else #else
wc_InitSha256(sha256_ctx); wc_InitSha256(sha256_ctx);
#endif #endif
@ -924,7 +924,7 @@ static int header_sha384(wc_Sha384 *sha384_ctx, struct wolfBoot_image *img)
if (stored_sha_len != WOLFBOOT_SHA_DIGEST_SIZE) if (stored_sha_len != WOLFBOOT_SHA_DIGEST_SIZE)
return -1; return -1;
#ifdef WOLFBOOT_ENABLE_WOLFHSM_CLIENT #ifdef WOLFBOOT_ENABLE_WOLFHSM_CLIENT
(void)wc_InitSha384_ex(&sha384_ctx, NULL, hsmClientDevIdHash); (void)wc_InitSha384_ex(sha384_ctx, NULL, hsmClientDevIdHash);
#else #else
wc_InitSha384(sha384_ctx); wc_InitSha384(sha384_ctx);
#endif #endif

View File

@ -271,7 +271,7 @@ backup_on_failure:
#ifdef WOLFBOOT_ELF #ifdef WOLFBOOT_ELF
/* Load elf */ /* Load elf */
if (elf_load_image((uint8_t*)load_address, (uintptr_t*)&load_address) != 0){ if (elf_load_image_mmu((uint8_t*)load_address, (uintptr_t*)&load_address, NULL) != 0){
wolfBoot_printf("Invalid elf, falling back to raw binary\n"); wolfBoot_printf("Invalid elf, falling back to raw binary\n");
} }
#endif #endif

View File

@ -4,7 +4,7 @@
CC=gcc CC=gcc
CFLAGS=-Wall -g -ggdb CFLAGS=-Wall -g -ggdb
CFLAGS+=-I../../include -DWOLFBOOT_ELF -DELF_PARSER -DPRINTF_ENABLED CFLAGS+=-I../../include -DWOLFBOOT_ELF -DELF_PARSER -DPRINTF_ENABLED -DMMU -DARCH_FLASH_OFFSET=0
EXE=elf-parser EXE=elf-parser
LIBS= LIBS=

View File

@ -70,7 +70,7 @@ int main(int argc, char *argv[])
fclose(f); fclose(f);
if (ret == 0) { if (ret == 0) {
ret = elf_load_image(image, &entry); ret = elf_load_image_mmu(image, &entry, NULL);
} }
printf("Return %d, Load %p\n", ret, (void*)entry); printf("Return %d, Load %p\n", ret, (void*)entry);