From 2e383bf90173aa8fa7b4da8a6cded5527907c465 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 22 Apr 2024 12:12:56 +0700 Subject: [PATCH] dcd nrf change atoimc_bool to atomic_flag --- hw/bsp/nrf/boards/feather_nrf52840_express/board.cmake | 1 - hw/bsp/nrf/family.cmake | 4 ++-- hw/bsp/nrf/linker/nrf52840_s140_v6.ld | 2 +- hw/bsp/nrf/linker/nrf52840_xxaa.ld | 8 +------- hw/bsp/samd51/family.c | 5 +++++ src/portable/nordic/nrf5x/dcd_nrf5x.c | 5 ++--- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/hw/bsp/nrf/boards/feather_nrf52840_express/board.cmake b/hw/bsp/nrf/boards/feather_nrf52840_express/board.cmake index 726438d05..6ff1a7b59 100644 --- a/hw/bsp/nrf/boards/feather_nrf52840_express/board.cmake +++ b/hw/bsp/nrf/boards/feather_nrf52840_express/board.cmake @@ -1,6 +1,5 @@ set(MCU_VARIANT nrf52840) set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/../../linker/nrf52840_s140_v6.ld) -#set(LD_FILE_GNU ${NRFX_DIR}/mdk/nrf52840_xxaa.ld) # enable max3421 host driver for this board set(MAX3421_HOST 1) diff --git a/hw/bsp/nrf/family.cmake b/hw/bsp/nrf/family.cmake index c038a2035..52a6fc196 100644 --- a/hw/bsp/nrf/family.cmake +++ b/hw/bsp/nrf/family.cmake @@ -30,10 +30,10 @@ set(FAMILY_MCUS NRF5X CACHE INTERNAL "") # only need to be built ONCE for all examples function(add_board_target BOARD_TARGET) if (NOT TARGET ${BOARD_TARGET}) - if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID}) + if (NOT DEFINED LD_FILE_GNU) set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${MCU_VARIANT}_xxaa.ld) - set(LD_FILE_Clang ${LD_FILE_GNU}) endif () + set(LD_FILE_Clang ${LD_FILE_GNU}) if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID}) set(STARTUP_FILE_GNU ${NRFX_DIR}/mdk/gcc_startup_${MCU_VARIANT}.S) diff --git a/hw/bsp/nrf/linker/nrf52840_s140_v6.ld b/hw/bsp/nrf/linker/nrf52840_s140_v6.ld index e27fa1c91..7cc94a405 100644 --- a/hw/bsp/nrf/linker/nrf52840_s140_v6.ld +++ b/hw/bsp/nrf/linker/nrf52840_s140_v6.ld @@ -1,7 +1,7 @@ /* Linker script to configure memory regions. */ SEARCH_DIR(.) -GROUP(-lgcc -lc -lnosys) +/*GROUP(-lgcc -lc -lnosys) not compatible with clang*/ MEMORY { diff --git a/hw/bsp/nrf/linker/nrf52840_xxaa.ld b/hw/bsp/nrf/linker/nrf52840_xxaa.ld index 8768fe072..377c248bb 100644 --- a/hw/bsp/nrf/linker/nrf52840_xxaa.ld +++ b/hw/bsp/nrf/linker/nrf52840_xxaa.ld @@ -1,6 +1,7 @@ /* Linker script to configure memory regions. */ SEARCH_DIR(.) +/*GROUP(-lgcc -lc -lnosys) not compatible with clang*/ MEMORY { @@ -10,7 +11,6 @@ MEMORY CODE_RAM (rwx) : ORIGIN = 0x800000, LENGTH = 0x40000 } - INCLUDE "nrf_common.ld" /* nrfx v2 linker does not define __tbss_start/end__ __sbss_start/end__*/ @@ -18,9 +18,3 @@ INCLUDE "nrf_common.ld" /*__tbss_end__ = __tbss_end;*/ /*__sbss_start__ = __sbss_start;*/ /*__sbss_end__ = __sbss_end;*/ - -/* picolibc crt0 */ -/*__data_source = __copy_table_start__;*/ -/*__tls_base = __tdata_start;*/ -/*PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) );*/ -/*PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) );*/ diff --git a/hw/bsp/samd51/family.c b/hw/bsp/samd51/family.c index 170c88191..d56d9f695 100644 --- a/hw/bsp/samd51/family.c +++ b/hw/bsp/samd51/family.c @@ -388,3 +388,8 @@ bool tuh_max3421_spi_xfer_api(uint8_t rhport, uint8_t const* tx_buf, uint8_t* rx } #endif + +void HardFault_Handler(void) { + __BKPT(0); + while (1); +} diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c index d31925806..56e7f39a0 100644 --- a/src/portable/nordic/nrf5x/dcd_nrf5x.c +++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c @@ -119,7 +119,7 @@ static struct { xfer_td_t xfer[EP_CBI_COUNT + 1][2]; // nRF can only carry one DMA at a time, this is used to guard the access to EasyDMA - atomic_bool dma_running; + atomic_flag dma_running; } _dcd; /*------------------------------------------------------------------*/ @@ -155,7 +155,6 @@ static void edpt_dma_start(volatile uint32_t* reg_startep) { // DMA is complete static void edpt_dma_end(void) { - TU_ASSERT(_dcd.dma_running,); atomic_flag_clear(&_dcd.dma_running); } @@ -618,7 +617,7 @@ void dcd_int_handler(uint8_t rhport) { } if (int_status & USBD_INTEN_USBEVENT_Msk) { - TU_LOG(3, "EVENTCAUSE = 0x%04lX\r\n", NRF_USBD->EVENTCAUSE); + TU_LOG(3, "EVENTCAUSE = 0x%04" PRIX32 "\r\n", NRF_USBD->EVENTCAUSE); enum { EVT_CAUSE_MASK = USBD_EVENTCAUSE_SUSPEND_Msk | USBD_EVENTCAUSE_RESUME_Msk | USBD_EVENTCAUSE_USBWUALLOWED_Msk |