diff --git a/hal/zynq.ld b/hal/zynq.ld index 74480a1e..0f1215af 100644 --- a/hal/zynq.ld +++ b/hal/zynq.ld @@ -1,8 +1,8 @@ /* Linker Script for Zynq MP */ -/* Stack increased to 32KB for RSA 4096-bit */ -_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x8000; -_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x2000; +/* Stack increased to 64KB for RSA 4096-bit */ +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x10000; +_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x10000; _EL0_STACK_SIZE = DEFINED(_EL0_STACK_SIZE) ? _EL0_STACK_SIZE : 1024; _EL1_STACK_SIZE = DEFINED(_EL1_STACK_SIZE) ? _EL1_STACK_SIZE : 2048; diff --git a/src/image.c b/src/image.c index bcba6aeb..f91ff55c 100644 --- a/src/image.c +++ b/src/image.c @@ -666,6 +666,7 @@ int wolfBoot_verify_integrity(struct wolfBoot_image *img) int wolfBoot_verify_authenticity(struct wolfBoot_image *img) { + int ret; uint8_t *stored_signature; uint16_t stored_signature_size; uint8_t *pubkey_hint; @@ -694,8 +695,8 @@ int wolfBoot_verify_authenticity(struct wolfBoot_image *img) return -1; img->sha_hash = digest; } - if (wolfBoot_verify_signature(img->sha_hash, stored_signature) != 0) - return -1; + if ((ret = wolfBoot_verify_signature(img->sha_hash, stored_signature)) != 0) + return ret; img->signature_ok = 1; return 0; } diff --git a/src/update_ram.c b/src/update_ram.c index aee740c3..a9d89153 100644 --- a/src/update_ram.c +++ b/src/update_ram.c @@ -29,6 +29,11 @@ #include "wolfboot/wolfboot.h" #include +#ifdef DEBUG_ZYNQ + #include + #include "xil_printf.h" +#endif + extern void hal_flash_dualbank_swap(void); static inline void boot_panic(void) @@ -39,7 +44,7 @@ static inline void boot_panic(void) void RAMFUNCTION wolfBoot_start(void) { - int active; + int active, ret[3]; struct wolfBoot_image os_image; uint32_t* load_address = (uint32_t*)WOLFBOOT_LOAD_ADDRESS; uint8_t* image_ptr; @@ -50,6 +55,10 @@ void RAMFUNCTION wolfBoot_start(void) active = wolfBoot_dualboot_candidate(); +#ifdef DEBUG_ZYNQ + xil_printf("Active Part %d\n", active); +#endif + if (active < 0) /* panic if no images available */ boot_panic(); @@ -64,9 +73,13 @@ void RAMFUNCTION wolfBoot_start(void) } for (;;) { - if ((wolfBoot_open_image(&os_image, active) < 0) || - (wolfBoot_verify_integrity(&os_image) < 0) || - (wolfBoot_verify_authenticity(&os_image) < 0)) { + if (((ret[0] = wolfBoot_open_image(&os_image, active)) < 0) || + ((ret[1] = wolfBoot_verify_integrity(&os_image)) < 0) || + ((ret[2] = wolfBoot_verify_authenticity(&os_image)) < 0)) { + + #ifdef DEBUG_ZYNQ + xil_printf("Part %d: Failure: %d %d %d\n", active, ret[0], ret[1], ret[2]); + #endif /* panic if authentication fails and no backup */ if (!wolfBoot_fallback_is_possible()) @@ -83,6 +96,10 @@ void RAMFUNCTION wolfBoot_start(void) } } +#ifdef DEBUG_ZYNQ + xil_printf("Firmware Valid\n"); +#endif + /* First time we boot this update, set to TESTING to await * confirmation from the system */ @@ -109,6 +126,10 @@ void RAMFUNCTION wolfBoot_start(void) #ifdef EXT_FLASH /* Load image to RAM */ if (PART_IS_EXT(&os_image)) { + #ifdef DEBUG_ZYNQ + xil_printf("Loading %d to RAM at %08lx\n", os_image.fw_size, load_address); + #endif + ext_flash_read((uintptr_t)os_image.fw_base, (uint8_t*)load_address, os_image.fw_size); @@ -123,6 +144,10 @@ void RAMFUNCTION wolfBoot_start(void) #ifdef EXT_FLASH /* Load DTS to RAM */ if (PART_IS_EXT(&os_image)) { + #ifdef DEBUG_ZYNQ + xil_printf("Loading DTS %d to RAM at %08lx\n", os_image.fw_size, dts_address); + #endif + ext_flash_read((uintptr_t)os_image.fw_base, (uint8_t*)dts_address, os_image.fw_size); @@ -132,6 +157,11 @@ void RAMFUNCTION wolfBoot_start(void) #endif hal_prepare_boot(); + +#ifdef DEBUG_ZYNQ + xil_printf("Booting at %08lx\n", load_address); +#endif + #ifdef MMU do_boot((uint32_t*)load_address, (uint32_t*)dts_address); #else