From af94d676b60af5a73f8ef87483454e77bec7901e Mon Sep 17 00:00:00 2001 From: Mattia Moffa Date: Fri, 13 Mar 2026 21:22:06 +0100 Subject: [PATCH] Address more copilot remarks --- docs/Targets.md | 1 - hal/nrf54l.c | 54 ---------------------------------------- hal/spi/spi_drv_nrf54l.c | 10 +++++--- hal/spi/spi_drv_nrf54l.h | 16 ++++++------ test-app/app_nrf54l.c | 1 - 5 files changed, 14 insertions(+), 68 deletions(-) diff --git a/docs/Targets.md b/docs/Targets.md index 4f2f8470..4829cfd0 100644 --- a/docs/Targets.md +++ b/docs/Targets.md @@ -4593,7 +4593,6 @@ not interact with the RISC-V coprocessor. Two configurations are available at `config/examples`: - `nrf54l15.config`: TrustZone disabled; wolfBoot and the application always run in secure mode. - Delta updates are enabled. - `nrf54l15-wolfcrypt-tz.config`: TrustZone enabled; wolfBoot runs in secure mode and boots the application as non-secure code. Includes a non-secure callable (NSC) wolfPKCS11 API for diff --git a/hal/nrf54l.c b/hal/nrf54l.c index df3bd698..e4a10e60 100644 --- a/hal/nrf54l.c +++ b/hal/nrf54l.c @@ -308,60 +308,6 @@ void uart_init(void) } #endif -static uintptr_t ext_flash_addr_calc(uintptr_t address) -{ - /* offset external flash addresses by the update partition address */ - if (address < WOLFBOOT_PARTITION_UPDATE_ADDRESS) { - return 0; - } - address -= WOLFBOOT_PARTITION_UPDATE_ADDRESS; - return address; -} - -int ext_flash_write(uintptr_t address, const uint8_t *data, int len) -{ -#ifdef DEBUG_FLASH - uintptr_t addr = ext_flash_addr_calc(address); - wolfBoot_printf("Ext Write: Len %d, Addr 0x%" PRIxPTR " (off 0x%" PRIxPTR - ") -> %p\n", - len, address, addr, data); -#endif - return 0; -} - -int ext_flash_read(uintptr_t address, uint8_t *data, int len) -{ -#ifdef DEBUG_FLASH - uintptr_t addr = ext_flash_addr_calc(address); - wolfBoot_printf("Ext Read: Len %d, Addr 0x%" PRIxPTR " (off 0x%" PRIxPTR - ") -> %p\n", - len, address, addr, data); -#endif - memset(data, FLASH_BYTE_ERASED, len); - return len; -} - -int ext_flash_erase(uintptr_t address, int len) -{ -#ifdef DEBUG_FLASH - uintptr_t addr = ext_flash_addr_calc(address); - wolfBoot_printf("Ext Erase: Len %d, Addr 0x%" PRIxPTR " (off 0x%" PRIxPTR - ")\n", - len, address, addr); -#endif - return 0; -} - -void ext_flash_lock(void) -{ - /* no op */ -} - -void ext_flash_unlock(void) -{ - /* no op */ -} - static void high_freq_clock_init(void) { /* Start the HFXO and wait until it is running */ diff --git a/hal/spi/spi_drv_nrf54l.c b/hal/spi/spi_drv_nrf54l.c index c734a113..e2e5cc7f 100644 --- a/hal/spi/spi_drv_nrf54l.c +++ b/hal/spi/spi_drv_nrf54l.c @@ -95,7 +95,9 @@ void RAMFUNCTION spi_write(const char byte) SPI_EVENTS_DMA_TX_BUSERROR == 0) ; SPI_EVENTS_STOPPED = 0; - spi_rx_ready = 1; + + if (SPI_EVENTS_DMA_RX_BUSERROR == 0 && SPI_EVENTS_DMA_RX_BUSERROR == 0) + spi_rx_ready = 1; } @@ -113,9 +115,9 @@ void spi_init(int polarity, int phase) GPIO_PIN_CNF(SPI_MISO_PORT, SPI_MISO_PIN) = (GPIO_CNF_IN | GPIO_CNF_PULL_UP); - GPIO_OUTSET(SPI_CS_PORT) = (1 << SPI_CS_PIN); - GPIO_OUTCLR(SPI_SCK_PORT) = (1 << SPI_SCK_PIN); - GPIO_OUTCLR(SPI_MOSI_PORT) = (1 << SPI_MOSI_PIN); + GPIO_OUTSET(SPI_CS_PORT) = (1U << SPI_CS_PIN); + GPIO_OUTCLR(SPI_SCK_PORT) = (1U << SPI_SCK_PIN); + GPIO_OUTCLR(SPI_MOSI_PORT) = (1U << SPI_MOSI_PIN); SPI_ENABLE_REG = SPIM_ENABLE_ENABLE_Disabled; SPI_PSEL_MISO = (PSEL_PORT(SPI_MISO_PORT) | SPI_MISO_PIN); diff --git a/hal/spi/spi_drv_nrf54l.h b/hal/spi/spi_drv_nrf54l.h index f9c8507e..8f6c92f5 100644 --- a/hal/spi/spi_drv_nrf54l.h +++ b/hal/spi/spi_drv_nrf54l.h @@ -24,28 +24,28 @@ /* Default pin-mux matches the nRF54L15-DK */ #ifndef SPI_CS_PORT - #define SPI_CS_PORT 0 + #define SPI_CS_PORT 2 #endif #ifndef SPI_CS_PIN - #define SPI_CS_PIN 25 + #define SPI_CS_PIN 5 #endif #ifndef SPI_SCK_PORT - #define SPI_SCK_PORT 0 + #define SPI_SCK_PORT 2 #endif #ifndef SPI_SCK_PIN - #define SPI_SCK_PIN 29 + #define SPI_SCK_PIN 1 #endif #ifndef SPI_MOSI_PORT - #define SPI_MOSI_PORT 0 + #define SPI_MOSI_PORT 2 #endif #ifndef SPI_MOSI_PIN - #define SPI_MOSI_PIN 28 + #define SPI_MOSI_PIN 2 #endif #ifndef SPI_MISO_PORT - #define SPI_MISO_PORT 0 + #define SPI_MISO_PORT 2 #endif #ifndef SPI_MISO_PIN - #define SPI_MISO_PIN 27 + #define SPI_MISO_PIN 4 #endif #ifndef SPI_CS_TPM diff --git a/test-app/app_nrf54l.c b/test-app/app_nrf54l.c index 31334692..94c6756d 100644 --- a/test-app/app_nrf54l.c +++ b/test-app/app_nrf54l.c @@ -34,7 +34,6 @@ void WEAKFUNCTION RAMFUNCTION arch_reboot(void) AIRCR = AIRCR_SYSRESETREQ | AIRCR_VKEY; while(1) ; - wolfBoot_panic(); } #endif