clang tested with mcb1800, add heap to lpc18 linker

This commit is contained in:
hathach
2024-04-22 18:08:41 +07:00
parent c097c85dcf
commit db30eee0fc
7 changed files with 64 additions and 38 deletions

View File

@@ -72,8 +72,7 @@ extern bool msc_app_init(void);
extern void msc_app_task(void); extern void msc_app_task(void);
/*------------- MAIN -------------*/ /*------------- MAIN -------------*/
int main(void) int main(void) {
{
board_init(); board_init();
printf("TinyUSB Host MassStorage Explorer Example\r\n"); printf("TinyUSB Host MassStorage Explorer Example\r\n");
@@ -87,8 +86,7 @@ int main(void)
msc_app_init(); msc_app_init();
while (1) while (1) {
{
// tinyusb host task // tinyusb host task
tuh_task(); tuh_task();
@@ -103,28 +101,25 @@ int main(void)
// TinyUSB Callbacks // TinyUSB Callbacks
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void tuh_mount_cb(uint8_t dev_addr) void tuh_mount_cb(uint8_t dev_addr) {
{
(void) dev_addr; (void) dev_addr;
} }
void tuh_umount_cb(uint8_t dev_addr) void tuh_umount_cb(uint8_t dev_addr) {
{
(void) dev_addr; (void) dev_addr;
} }
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Blinking Task // Blinking Task
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void led_blinking_task(void) void led_blinking_task(void) {
{
const uint32_t interval_ms = 1000; const uint32_t interval_ms = 1000;
static uint32_t start_ms = 0; static uint32_t start_ms = 0;
static bool led_state = false; static bool led_state = false;
// Blink every interval ms // Blink every interval ms
if ( board_millis() - start_ms < interval_ms) return; // not enough time if (board_millis() - start_ms < interval_ms) return; // not enough time
start_ms += interval_ms; start_ms += interval_ms;
board_led_write(led_state); board_led_write(led_state);

View File

@@ -95,7 +95,6 @@ void msc_app_task(void)
// //
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
bool inquiry_complete_cb(uint8_t dev_addr, tuh_msc_complete_data_t const * cb_data) bool inquiry_complete_cb(uint8_t dev_addr, tuh_msc_complete_data_t const * cb_data)
{ {
msc_cbw_t const* cbw = cb_data->cbw; msc_cbw_t const* cbw = cb_data->cbw;

View File

@@ -311,6 +311,20 @@ SECTIONS
PROVIDE(end = .); PROVIDE(end = .);
} > RamLoc40 AT> RamLoc40 /* > RamLoc32 AT> RamLoc32 */ } > RamLoc40 AT> RamLoc40 /* > RamLoc32 AT> RamLoc32 */
.heap (NOLOAD): {
__heap_start = .;
__HeapBase = .;
__heap_base = .;
__end = .;
PROVIDE(end = .);
PROVIDE(_end = .);
PROVIDE(__end__ = .);
KEEP(*(.heap*))
__HeapLimit = .;
__heap_limit = .;
__heap_end = .;
} > RamLoc40
/* NOINIT section for RamLoc40 */ /* NOINIT section for RamLoc40 */
.noinit_RAM2 (NOLOAD) : ALIGN(4) .noinit_RAM2 (NOLOAD) : ALIGN(4)
{ {
@@ -383,15 +397,17 @@ SECTIONS
PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0); PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
/* ## Create checksum value (used in startup) ## */ /* ## Create checksum value (used in startup) ## */
PROVIDE(__valid_user_code_checksum = 0 - /* This cause issue with clang linker, so it is disabled */
(_vStackTop /* MemManage_Handler, BusFault_Handler, UsageFault_Handler may not be defined */
+ (ResetISR + 1) /* PROVIDE(__valid_user_code_checksum = 0 -*/
+ (NMI_Handler + 1) /* (_vStackTop*/
+ (HardFault_Handler + 1) /* + (ResetISR + 1)*/
+ (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */ /* + (NMI_Handler + 1)*/
+ (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */ /* + (HardFault_Handler + 1)*/
+ (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */ /* + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1)*/
) ); /* + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1)*/
/* + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1)*/
/* ) );*/
/* Provide basic symbols giving location and size of main text /* Provide basic symbols giving location and size of main text
* block, including initial values of RW data sections. Note that * block, including initial values of RW data sections. Note that

View File

@@ -255,7 +255,6 @@ SECTIONS
*(COMMON) *(COMMON)
. = ALIGN(4) ; . = ALIGN(4) ;
_ebss = .; _ebss = .;
PROVIDE(end = .);
} > RamLoc40 /* RamLoc32 */ } > RamLoc40 /* RamLoc32 */
/* NOINIT section for RamLoc40 */ /* NOINIT section for RamLoc40 */
@@ -266,6 +265,20 @@ SECTIONS
. = ALIGN(4) ; . = ALIGN(4) ;
} > RamLoc40 } > RamLoc40
.heap (NOLOAD): {
__heap_start = .;
__HeapBase = .;
__heap_base = .;
__end = .;
PROVIDE(end = .);
PROVIDE(_end = .);
PROVIDE(__end__ = .);
KEEP(*(.heap*))
__HeapLimit = .;
__heap_limit = .;
__heap_end = .;
} > RamLoc40
/* NOINIT section for RamAHB32 */ /* NOINIT section for RamAHB32 */
.noinit_RAM3 (NOLOAD) : ALIGN(4) .noinit_RAM3 (NOLOAD) : ALIGN(4)
{ {
@@ -298,19 +311,21 @@ SECTIONS
. = ALIGN(4) ; . = ALIGN(4) ;
_end_noinit = .; _end_noinit = .;
} > RamLoc32 } > RamLoc32
PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0); PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
/* ## Create checksum value (used in startup) ## */ /* ## Create checksum value (used in startup) ## */
PROVIDE(__valid_user_code_checksum = 0 - /* This cause issue with clang linker, so it is disabled */
(_vStackTop /* MemManage_Handler, BusFault_Handler, UsageFault_Handler may not be defined */
+ (ResetISR + 1) /* PROVIDE(__valid_user_code_checksum = 0 -*/
+ (NMI_Handler + 1) /* (_vStackTop*/
+ (HardFault_Handler + 1) /* + (ResetISR + 1)*/
+ (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */ /* + (NMI_Handler + 1)*/
+ (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */ /* + (HardFault_Handler + 1)*/
+ (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */ /* + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1)*/
) ); /* + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1)*/
/* + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1)*/
/* ) );*/
/* Provide basic symbols giving location and size of main text /* Provide basic symbols giving location and size of main text
* block, including initial values of RW data sections. Note that * block, including initial values of RW data sections. Note that

View File

@@ -47,9 +47,11 @@ function(add_board_target BOARD_TARGET)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU") if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_link_options(${BOARD_TARGET} PUBLIC target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_GNU}" "LINKER:--script=${LD_FILE_GNU}"
# nanolib --specs=nosys.specs --specs=nano.specs
--specs=nosys.specs )
--specs=nano.specs elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_GNU}"
) )
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR") elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${BOARD_TARGET} PUBLIC target_link_options(${BOARD_TARGET} PUBLIC

View File

@@ -39,7 +39,6 @@ function(add_board_target BOARD_TARGET)
if (NOT DEFINED LD_FILE_GNU) if (NOT DEFINED LD_FILE_GNU)
set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${MCU_VARIANT_XXAA}.ld) set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${MCU_VARIANT_XXAA}.ld)
endif () endif ()
set(LD_FILE_Clang ${LD_FILE_GNU})
if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID}) if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
set(STARTUP_FILE_GNU ${NRFX_DIR}/mdk/gcc_startup_${MCU_VARIANT}.S) set(STARTUP_FILE_GNU ${NRFX_DIR}/mdk/gcc_startup_${MCU_VARIANT}.S)
@@ -89,7 +88,7 @@ function(add_board_target BOARD_TARGET)
) )
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_link_options(${BOARD_TARGET} PUBLIC target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_Clang}" "LINKER:--script=${LD_FILE_GNU}"
-L${NRFX_DIR}/mdk -L${NRFX_DIR}/mdk
) )
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR") elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")

View File

@@ -92,7 +92,7 @@ CFG_TUH_MEM_SECTION TU_ATTR_ALIGNED(4096) static ehci_data_t ehci_data;
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Debug // Debug
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#if CFG_TUSB_DEBUG >= (EHCI_DBG + 1) #if 0 && CFG_TUSB_DEBUG >= (EHCI_DBG + 1)
static inline void print_portsc(ehci_registers_t* regs) { static inline void print_portsc(ehci_registers_t* regs) {
TU_LOG_HEX(EHCI_DBG, regs->portsc); TU_LOG_HEX(EHCI_DBG, regs->portsc);
TU_LOG(EHCI_DBG, " Connect Status : %u\r\n", regs->portsc_bm.current_connect_status); TU_LOG(EHCI_DBG, " Connect Status : %u\r\n", regs->portsc_bm.current_connect_status);