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
No known key found for this signature in database
GPG Key ID: 26FAB84F615C3C52
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);
/*------------- MAIN -------------*/
int main(void)
{
int main(void) {
board_init();
printf("TinyUSB Host MassStorage Explorer Example\r\n");
@ -87,8 +86,7 @@ int main(void)
msc_app_init();
while (1)
{
while (1) {
// tinyusb host task
tuh_task();
@ -103,28 +101,25 @@ int main(void)
// TinyUSB Callbacks
//--------------------------------------------------------------------+
void tuh_mount_cb(uint8_t dev_addr)
{
void tuh_mount_cb(uint8_t dev_addr) {
(void) dev_addr;
}
void tuh_umount_cb(uint8_t dev_addr)
{
void tuh_umount_cb(uint8_t dev_addr) {
(void) dev_addr;
}
//--------------------------------------------------------------------+
// Blinking Task
//--------------------------------------------------------------------+
void led_blinking_task(void)
{
void led_blinking_task(void) {
const uint32_t interval_ms = 1000;
static uint32_t start_ms = 0;
static bool led_state = false;
// 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;
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)
{
msc_cbw_t const* cbw = cb_data->cbw;

View File

@ -311,6 +311,20 @@ SECTIONS
PROVIDE(end = .);
} > 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_RAM2 (NOLOAD) : ALIGN(4)
{
@ -383,15 +397,17 @@ SECTIONS
PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
/* ## Create checksum value (used in startup) ## */
PROVIDE(__valid_user_code_checksum = 0 -
(_vStackTop
+ (ResetISR + 1)
+ (NMI_Handler + 1)
+ (HardFault_Handler + 1)
+ (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
+ (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
+ (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
) );
/* This cause issue with clang linker, so it is disabled */
/* MemManage_Handler, BusFault_Handler, UsageFault_Handler may not be defined */
/* PROVIDE(__valid_user_code_checksum = 0 -*/
/* (_vStackTop*/
/* + (ResetISR + 1)*/
/* + (NMI_Handler + 1)*/
/* + (HardFault_Handler + 1)*/
/* + (( 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
* block, including initial values of RW data sections. Note that

View File

@ -255,7 +255,6 @@ SECTIONS
*(COMMON)
. = ALIGN(4) ;
_ebss = .;
PROVIDE(end = .);
} > RamLoc40 /* RamLoc32 */
/* NOINIT section for RamLoc40 */
@ -266,6 +265,20 @@ SECTIONS
. = ALIGN(4) ;
} > 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_RAM3 (NOLOAD) : ALIGN(4)
{
@ -298,19 +311,21 @@ SECTIONS
. = ALIGN(4) ;
_end_noinit = .;
} > RamLoc32
PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
/* ## Create checksum value (used in startup) ## */
PROVIDE(__valid_user_code_checksum = 0 -
(_vStackTop
+ (ResetISR + 1)
+ (NMI_Handler + 1)
+ (HardFault_Handler + 1)
+ (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
+ (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
+ (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
) );
/* This cause issue with clang linker, so it is disabled */
/* MemManage_Handler, BusFault_Handler, UsageFault_Handler may not be defined */
/* PROVIDE(__valid_user_code_checksum = 0 -*/
/* (_vStackTop*/
/* + (ResetISR + 1)*/
/* + (NMI_Handler + 1)*/
/* + (HardFault_Handler + 1)*/
/* + (( 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
* 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")
target_link_options(${BOARD_TARGET} PUBLIC
"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")
target_link_options(${BOARD_TARGET} PUBLIC

View File

@ -39,7 +39,6 @@ function(add_board_target BOARD_TARGET)
if (NOT DEFINED LD_FILE_GNU)
set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${MCU_VARIANT_XXAA}.ld)
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)
@ -89,7 +88,7 @@ function(add_board_target BOARD_TARGET)
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_Clang}"
"LINKER:--script=${LD_FILE_GNU}"
-L${NRFX_DIR}/mdk
)
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
//--------------------------------------------------------------------+
#if CFG_TUSB_DEBUG >= (EHCI_DBG + 1)
#if 0 && CFG_TUSB_DEBUG >= (EHCI_DBG + 1)
static inline void print_portsc(ehci_registers_t* regs) {
TU_LOG_HEX(EHCI_DBG, regs->portsc);
TU_LOG(EHCI_DBG, " Connect Status : %u\r\n", regs->portsc_bm.current_connect_status);