mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
Merge pull request #621 from hathach/rp2040-logger-enumfix
Rp2040 logger and enum fix
This commit is contained in:
commit
26caddae23
@ -33,7 +33,7 @@ if(FAMILY STREQUAL "rp2040")
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -37,7 +37,7 @@ elseif(FAMILY STREQUAL "rp2040")
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -33,7 +33,7 @@ if(FAMILY STREQUAL "rp2040")
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -39,7 +39,7 @@ elseif(FAMILY STREQUAL "rp2040")
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -33,7 +33,7 @@ if(FAMILY STREQUAL "rp2040")
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -34,7 +34,7 @@ if(FAMILY STREQUAL "rp2040")
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -33,7 +33,7 @@ if(FAMILY STREQUAL "rp2040")
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -33,7 +33,7 @@ if(FAMILY STREQUAL "rp2040")
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -33,7 +33,7 @@ if(FAMILY STREQUAL "rp2040")
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -33,7 +33,7 @@ if(FAMILY STREQUAL "rp2040")
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -34,7 +34,7 @@ if(FAMILY STREQUAL "rp2040")
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -80,7 +80,7 @@ if(FAMILY STREQUAL "rp2040")
|
||||
HTTPD_USE_CUSTOM_FSDATA=0
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -33,7 +33,7 @@ if(FAMILY STREQUAL "rp2040")
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -34,7 +34,7 @@ if(FAMILY STREQUAL "rp2040")
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -33,7 +33,7 @@ if(FAMILY STREQUAL "rp2040")
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
|
@ -112,13 +112,18 @@ endif
|
||||
|
||||
# Log level is mapped to TUSB DEBUG option
|
||||
ifneq ($(LOG),)
|
||||
CMAKE_DEFSYM += -DLOG=$(LOG)
|
||||
CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
|
||||
endif
|
||||
|
||||
# Logger: default is uart, can be set to rtt or swo
|
||||
ifneq ($(LOGGER),)
|
||||
CMAKE_DEFSYM += -DLOGGER=$(LOGGER)
|
||||
endif
|
||||
|
||||
ifeq ($(LOGGER),rtt)
|
||||
RTT_SRC = lib/SEGGER_RTT
|
||||
CFLAGS += -DLOGGER_RTT -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
|
||||
RTT_SRC = lib/SEGGER_RTT
|
||||
INC += $(TOP)/$(RTT_SRC)/RTT
|
||||
SRC_C += $(RTT_SRC)/RTT/SEGGER_RTT.c
|
||||
else ifeq ($(LOGGER),swo)
|
||||
|
@ -11,30 +11,30 @@ ifeq ($(FAMILY),esp32s2)
|
||||
.PHONY: all clean flash
|
||||
|
||||
all:
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) build
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) build
|
||||
|
||||
build: all
|
||||
|
||||
clean:
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) clean
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) clean
|
||||
|
||||
fullclean:
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) fullclean
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) fullclean
|
||||
|
||||
flash:
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) flash
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) flash
|
||||
|
||||
bootloader-flash:
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) bootloader-flash
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) bootloader-flash
|
||||
|
||||
app-flash:
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) app-flash
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) app-flash
|
||||
|
||||
erase:
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) erase_flash
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) erase_flash
|
||||
|
||||
monitor:
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) monitor
|
||||
idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) monitor
|
||||
|
||||
UF2_FAMILY_ID = 0xbfdd4eee
|
||||
$(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).hex
|
||||
@ -43,13 +43,18 @@ $(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).hex
|
||||
|
||||
else ifeq ($(FAMILY),rp2040)
|
||||
|
||||
all:
|
||||
[ -d $(BUILD) ] || cmake -S . -B $(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) -DPICO_BUILD_DOCS=0
|
||||
$(BUILD):
|
||||
cmake -S . -B $(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) -DPICO_BUILD_DOCS=0 $(CMAKE_DEFSYM)
|
||||
|
||||
all: $(BUILD)
|
||||
$(MAKE) -C $(BUILD)
|
||||
|
||||
clean:
|
||||
$(RM) -rf $(BUILD)
|
||||
|
||||
flash:
|
||||
@$(CP) $(BUILD)/$(PROJECT).uf2 /media/$(USER)/RPI-RP2
|
||||
|
||||
else
|
||||
# GNU Make build system
|
||||
|
||||
|
@ -76,6 +76,38 @@ bool __no_inline_not_in_flash_func(get_bootsel_button)() {
|
||||
}
|
||||
#endif
|
||||
|
||||
//------------- Segger RTT retarget -------------//
|
||||
#if defined(LOGGER_RTT)
|
||||
// Logging with RTT
|
||||
|
||||
#include "pico/stdio/driver.h"
|
||||
#include "SEGGER_RTT.h"
|
||||
|
||||
static void stdio_rtt_write (const char *buf, int length)
|
||||
{
|
||||
SEGGER_RTT_Write(0, buf, length);
|
||||
}
|
||||
|
||||
static int stdio_rtt_read (char *buf, int len)
|
||||
{
|
||||
return SEGGER_RTT_Read(0, buf, len);
|
||||
}
|
||||
|
||||
static stdio_driver_t stdio_rtt =
|
||||
{
|
||||
.out_chars = stdio_rtt_write,
|
||||
.out_flush = NULL,
|
||||
.in_chars = stdio_rtt_read
|
||||
};
|
||||
|
||||
void stdio_rtt_init(void)
|
||||
{
|
||||
stdio_set_driver_enabled(&stdio_rtt, true);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
gpio_init(LED_PIN);
|
||||
@ -86,9 +118,11 @@ void board_init(void)
|
||||
#endif
|
||||
|
||||
#ifdef UART_DEV
|
||||
uart_init(UART_DEV, CFG_BOARD_UART_BAUDRATE);
|
||||
gpio_set_function(UART_TX_PIN, GPIO_FUNC_UART);
|
||||
gpio_set_function(UART_RX_PIN, GPIO_FUNC_UART);
|
||||
stdio_uart_init_full(UART_DEV, CFG_BOARD_UART_BAUDRATE, UART_TX_PIN, UART_RX_PIN);
|
||||
#endif
|
||||
|
||||
#if defined(LOGGER_RTT)
|
||||
stdio_rtt_init();
|
||||
#endif
|
||||
|
||||
// todo probably set up device mode?
|
||||
|
@ -30,4 +30,28 @@ target_include_directories(${PROJECT} PUBLIC
|
||||
|
||||
target_compile_definitions(${PROJECT} PUBLIC
|
||||
CFG_TUSB_MCU=OPT_MCU_RP2040
|
||||
PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1
|
||||
)
|
||||
|
||||
if(DEFINED LOG)
|
||||
target_compile_definitions(${PROJECT} PUBLIC CFG_TUSB_DEBUG=${LOG} )
|
||||
pico_enable_stdio_uart(${PROJECT} 1)
|
||||
endif()
|
||||
|
||||
if(LOGGER STREQUAL "rtt")
|
||||
pico_enable_stdio_uart(${PROJECT} 0)
|
||||
|
||||
target_compile_definitions(${PROJECT} PUBLIC
|
||||
LOGGER_RTT
|
||||
SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
|
||||
)
|
||||
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
${TOP}/lib/SEGGER_RTT/RTT/SEGGER_RTT.c
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT} PUBLIC
|
||||
${TOP}/lib/SEGGER_RTT/RTT
|
||||
)
|
||||
endif()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user