mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-14 04:18:56 +00:00
fix missing linker entry with cmake for broadcom family
This commit is contained in:
parent
fc843c5827
commit
1b97cec995
@ -55,8 +55,7 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// Forward USB interrupt events to TinyUSB IRQ Handler
|
||||
//--------------------------------------------------------------------+
|
||||
void USB_IRQHandler(void)
|
||||
{
|
||||
void USB_IRQHandler(void) {
|
||||
tud_int_handler(0);
|
||||
}
|
||||
|
||||
@ -67,8 +66,7 @@ void USB_IRQHandler(void)
|
||||
//--------------------------------------------------------------------+
|
||||
// Board porting API
|
||||
//--------------------------------------------------------------------+
|
||||
void board_init(void)
|
||||
{
|
||||
void board_init(void) {
|
||||
setup_mmu_flat_map();
|
||||
init_caches();
|
||||
|
||||
@ -108,24 +106,21 @@ void board_init(void)
|
||||
BP_EnableIRQs();
|
||||
}
|
||||
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
gpio_set_value(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
|
||||
void board_led_write(bool state) {
|
||||
gpio_set_value(LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
||||
}
|
||||
|
||||
uint32_t board_button_read(void)
|
||||
{
|
||||
uint32_t board_button_read(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int board_uart_read(uint8_t* buf, int len)
|
||||
{
|
||||
(void) buf; (void) len;
|
||||
int board_uart_read(uint8_t* buf, int len) {
|
||||
(void) buf;
|
||||
(void) len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int board_uart_write(void const * buf, int len)
|
||||
{
|
||||
int board_uart_write(void const* buf, int len) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
const char* cbuf = buf;
|
||||
while (!UART1->STAT_b.TX_READY) {}
|
||||
@ -138,30 +133,27 @@ int board_uart_write(void const * buf, int len)
|
||||
return len;
|
||||
}
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
volatile uint32_t system_ticks = 0;
|
||||
|
||||
void TIMER_1_IRQHandler(void)
|
||||
{
|
||||
void TIMER_1_IRQHandler(void) {
|
||||
system_ticks++;
|
||||
SYSTMR->C1 += 977;
|
||||
SYSTMR->CS_b.M1 = 1;
|
||||
}
|
||||
|
||||
uint32_t board_millis(void)
|
||||
{
|
||||
uint32_t board_millis(void) {
|
||||
return system_ticks;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void HardFault_Handler (void)
|
||||
{
|
||||
void HardFault_Handler(void) {
|
||||
// asm("bkpt");
|
||||
}
|
||||
|
||||
// Required by __libc_init_array in startup code if we are compiling using
|
||||
// -nostdlib/-nostartfiles.
|
||||
void _init(void)
|
||||
{
|
||||
void _init(void) {
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
include_guard()
|
||||
|
||||
set(MCU_DIR ${TOP}/hw/mcu/broadcom)
|
||||
set(SDK_DIR ${TOP}/hw/mcu/broadcom)
|
||||
|
||||
# include board specific
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
|
||||
@ -21,22 +21,20 @@ function(add_board_target BOARD_TARGET)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED LD_FILE_GNU)
|
||||
set(LD_FILE_GNU ${MCU_DIR}/broadcom/link.ld)
|
||||
set(LD_FILE_GNU ${SDK_DIR}/broadcom/link.ld)
|
||||
endif ()
|
||||
set(LD_FILE_Clang ${LD_FILE_GNU})
|
||||
|
||||
if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
|
||||
set(STARTUP_FILE_GNU ${MCU_DIR}/broadcom/boot.s)
|
||||
endif ()
|
||||
set(STARTUP_FILE_GNU ${SDK_DIR}/broadcom/boot.s)
|
||||
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
|
||||
|
||||
add_library(${BOARD_TARGET} STATIC
|
||||
${MCU_DIR}/broadcom/gen/interrupt_handlers.c
|
||||
${MCU_DIR}/broadcom/gpio.c
|
||||
${MCU_DIR}/broadcom/interrupts.c
|
||||
${MCU_DIR}/broadcom/mmu.c
|
||||
${MCU_DIR}/broadcom/caches.c
|
||||
${MCU_DIR}/broadcom/vcmailbox.c
|
||||
${SDK_DIR}/broadcom/gen/interrupt_handlers.c
|
||||
${SDK_DIR}/broadcom/gpio.c
|
||||
${SDK_DIR}/broadcom/interrupts.c
|
||||
${SDK_DIR}/broadcom/mmu.c
|
||||
${SDK_DIR}/broadcom/caches.c
|
||||
${SDK_DIR}/broadcom/vcmailbox.c
|
||||
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
||||
)
|
||||
target_compile_options(${BOARD_TARGET} PUBLIC
|
||||
@ -47,7 +45,7 @@ function(add_board_target BOARD_TARGET)
|
||||
-std=c17
|
||||
)
|
||||
target_include_directories(${BOARD_TARGET} PUBLIC
|
||||
${MCU_DIR}
|
||||
${SDK_DIR}
|
||||
)
|
||||
|
||||
update_board(${BOARD_TARGET})
|
||||
@ -55,11 +53,14 @@ function(add_board_target BOARD_TARGET)
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GNU}"
|
||||
-nostdlib -nostartfiles
|
||||
"LINKER:--entry=_start"
|
||||
--specs=nosys.specs
|
||||
-nostartfiles
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_Clang}"
|
||||
"LINKER:--entry=_start"
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
|
@ -55,8 +55,7 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// Forward USB interrupt events to TinyUSB IRQ Handler
|
||||
//--------------------------------------------------------------------+
|
||||
void USB_IRQHandler(void)
|
||||
{
|
||||
void USB_IRQHandler(void) {
|
||||
tud_int_handler(0);
|
||||
}
|
||||
|
||||
@ -67,8 +66,7 @@ void USB_IRQHandler(void)
|
||||
//--------------------------------------------------------------------+
|
||||
// Board porting API
|
||||
//--------------------------------------------------------------------+
|
||||
void board_init(void)
|
||||
{
|
||||
void board_init(void) {
|
||||
setup_mmu_flat_map();
|
||||
init_caches();
|
||||
|
||||
@ -108,24 +106,21 @@ void board_init(void)
|
||||
BP_EnableIRQs();
|
||||
}
|
||||
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
gpio_set_value(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
|
||||
void board_led_write(bool state) {
|
||||
gpio_set_value(LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
||||
}
|
||||
|
||||
uint32_t board_button_read(void)
|
||||
{
|
||||
uint32_t board_button_read(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int board_uart_read(uint8_t* buf, int len)
|
||||
{
|
||||
(void) buf; (void) len;
|
||||
int board_uart_read(uint8_t* buf, int len) {
|
||||
(void) buf;
|
||||
(void) len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int board_uart_write(void const * buf, int len)
|
||||
{
|
||||
int board_uart_write(void const* buf, int len) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
const char* cbuf = buf;
|
||||
while (!UART1->STAT_b.TX_READY) {}
|
||||
@ -138,30 +133,27 @@ int board_uart_write(void const * buf, int len)
|
||||
return len;
|
||||
}
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
volatile uint32_t system_ticks = 0;
|
||||
|
||||
void TIMER_1_IRQHandler(void)
|
||||
{
|
||||
void TIMER_1_IRQHandler(void) {
|
||||
system_ticks++;
|
||||
SYSTMR->C1 += 977;
|
||||
SYSTMR->CS_b.M1 = 1;
|
||||
}
|
||||
|
||||
uint32_t board_millis(void)
|
||||
{
|
||||
uint32_t board_millis(void) {
|
||||
return system_ticks;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void HardFault_Handler (void)
|
||||
{
|
||||
void HardFault_Handler(void) {
|
||||
// asm("bkpt");
|
||||
}
|
||||
|
||||
// Required by __libc_init_array in startup code if we are compiling using
|
||||
// -nostdlib/-nostartfiles.
|
||||
void _init(void)
|
||||
{
|
||||
void _init(void) {
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
include_guard()
|
||||
|
||||
set(MCU_DIR ${TOP}/hw/mcu/broadcom)
|
||||
set(SDK_DIR ${TOP}/hw/mcu/broadcom)
|
||||
set(CMSIS_5 ${TOP}/lib/CMSIS_5)
|
||||
|
||||
# include board specific
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
|
||||
@ -21,22 +22,20 @@ function(add_board_target BOARD_TARGET)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED LD_FILE_GNU)
|
||||
set(LD_FILE_GNU ${MCU_DIR}/broadcom/link8.ld)
|
||||
set(LD_FILE_GNU ${SDK_DIR}/broadcom/link8.ld)
|
||||
endif ()
|
||||
set(LD_FILE_Clang ${LD_FILE_GNU})
|
||||
|
||||
if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
|
||||
set(STARTUP_FILE_GNU ${MCU_DIR}/broadcom/boot8.s)
|
||||
endif ()
|
||||
set(STARTUP_FILE_GNU ${SDK_DIR}/broadcom/boot8.s)
|
||||
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
|
||||
|
||||
add_library(${BOARD_TARGET} STATIC
|
||||
${MCU_DIR}/broadcom/gen/interrupt_handlers.c
|
||||
${MCU_DIR}/broadcom/gpio.c
|
||||
${MCU_DIR}/broadcom/interrupts.c
|
||||
${MCU_DIR}/broadcom/mmu.c
|
||||
${MCU_DIR}/broadcom/caches.c
|
||||
${MCU_DIR}/broadcom/vcmailbox.c
|
||||
${SDK_DIR}/broadcom/gen/interrupt_handlers.c
|
||||
${SDK_DIR}/broadcom/gpio.c
|
||||
${SDK_DIR}/broadcom/interrupts.c
|
||||
${SDK_DIR}/broadcom/mmu.c
|
||||
${SDK_DIR}/broadcom/caches.c
|
||||
${SDK_DIR}/broadcom/vcmailbox.c
|
||||
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
||||
)
|
||||
target_compile_options(${BOARD_TARGET} PUBLIC
|
||||
@ -50,19 +49,25 @@ function(add_board_target BOARD_TARGET)
|
||||
BCM_VERSION=${BCM_VERSION}
|
||||
)
|
||||
target_include_directories(${BOARD_TARGET} PUBLIC
|
||||
${MCU_DIR}
|
||||
${SDK_DIR}
|
||||
${CMSIS_5}/CMSIS/Core_A/Include
|
||||
)
|
||||
|
||||
update_board(${BOARD_TARGET})
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
# target_compile_options(${BOARD_TARGET} PUBLIC
|
||||
# )
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GNU}"
|
||||
-nostdlib -nostartfiles
|
||||
"LINKER:--entry=_start"
|
||||
--specs=nosys.specs
|
||||
-nostartfiles
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_Clang}"
|
||||
"LINKER:--entry=_start"
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
|
@ -7,6 +7,7 @@ CFLAGS += \
|
||||
-ffreestanding \
|
||||
-nostdlib \
|
||||
-nostartfiles \
|
||||
--specs=nosys.specs \
|
||||
-mgeneral-regs-only \
|
||||
-std=c17
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user