mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
misc: Use LD wrap for redirecting serial data to TinyUSB debug code.
Prior to this update, each port had to be patched to call TinyUSB debugging function. Now these wrappers will call the port's functions if debugging is not enabled.
This commit is contained in:
parent
9e33988946
commit
eec8640d7e
@ -1 +1 @@
|
|||||||
Subproject commit 6e252c7edec9393a7b2f07a35997e19690a5d173
|
Subproject commit 9fceba6be6add8874fc409c93a23b4653b756205
|
||||||
@ -70,14 +70,28 @@ bool tinyusb_debug_enabled(void) {
|
|||||||
return tinyusb_debug_mode;
|
return tinyusb_debug_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tinyusb_debug_tx_strn(const char *str, mp_uint_t len) {
|
extern void __real_tud_cdc_rx_cb(uint8_t itf);
|
||||||
// TODO can be faster.
|
void __wrap_tud_cdc_rx_cb(uint8_t itf) {
|
||||||
if (tinyusb_debug_enabled() && tud_cdc_connected()) {
|
if (tinyusb_debug_enabled()) {
|
||||||
for (int i = 0; i < len; i++) {
|
return;
|
||||||
NVIC_DisableIRQ(PendSV_IRQn);
|
} else {
|
||||||
ringbuf_put((ringbuf_t *) &debug_ringbuf, str[i]);
|
__real_tud_cdc_rx_cb(itf);
|
||||||
NVIC_EnableIRQ(PendSV_IRQn);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern mp_uint_t __real_mp_hal_stdout_tx_strn(const char *str, mp_uint_t len);
|
||||||
|
mp_uint_t __wrap_mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
|
||||||
|
if (tinyusb_debug_enabled()) {
|
||||||
|
if (tud_cdc_connected()) {
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
NVIC_DisableIRQ(PendSV_IRQn);
|
||||||
|
ringbuf_put((ringbuf_t *) &debug_ringbuf, str[i]);
|
||||||
|
NVIC_EnableIRQ(PendSV_IRQn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return len;
|
||||||
|
} else {
|
||||||
|
return __real_mp_hal_stdout_tx_strn(str, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -90,7 +90,8 @@ endif
|
|||||||
CFLAGS += $(HAL_CFLAGS) $(MPY_CFLAGS) $(OMV_CFLAGS)
|
CFLAGS += $(HAL_CFLAGS) $(MPY_CFLAGS) $(OMV_CFLAGS)
|
||||||
# Linker Flags
|
# Linker Flags
|
||||||
LDFLAGS = -mcpu=$(CPU) -mabi=aapcs-linux -mthumb -mfpu=$(FPU) -mfloat-abi=hard -nostdlib \
|
LDFLAGS = -mcpu=$(CPU) -mabi=aapcs-linux -mthumb -mfpu=$(FPU) -mfloat-abi=hard -nostdlib \
|
||||||
-Wl,--print-memory-usage -Wl,--gc-sections -Wl,-T$(BUILD)/$(LDSCRIPT).lds
|
-Wl,--print-memory-usage -Wl,--gc-sections -Wl,-T$(BUILD)/$(LDSCRIPT).lds \
|
||||||
|
-Wl,--wrap=tud_cdc_rx_cb -Wl,--wrap=mp_hal_stdout_tx_strn
|
||||||
|
|
||||||
#------------- Libraries ----------------#
|
#------------- Libraries ----------------#
|
||||||
LIBS += $(TOP_DIR)/$(TENSORFLOW_DIR)/$(CPU)/libtf*.a
|
LIBS += $(TOP_DIR)/$(TENSORFLOW_DIR)/$(CPU)/libtf*.a
|
||||||
|
|||||||
@ -64,7 +64,8 @@ CFLAGS += $(HAL_CFLAGS) $(MPY_CFLAGS) $(OMV_CFLAGS)
|
|||||||
|
|
||||||
# Linker Flags
|
# Linker Flags
|
||||||
LDFLAGS = -mcpu=$(CPU) -mabi=aapcs-linux -mthumb -mfpu=$(FPU) -mfloat-abi=hard\
|
LDFLAGS = -mcpu=$(CPU) -mabi=aapcs-linux -mthumb -mfpu=$(FPU) -mfloat-abi=hard\
|
||||||
-nostdlib -Wl,--gc-sections -Wl,-T$(BUILD)/$(LDSCRIPT).lds
|
-nostdlib -Wl,--gc-sections -Wl,-T$(BUILD)/$(LDSCRIPT).lds \
|
||||||
|
-Wl,--wrap=tud_cdc_rx_cb -Wl,--wrap=mp_hal_stdout_tx_strn
|
||||||
|
|
||||||
#------------- Libraries ----------------#
|
#------------- Libraries ----------------#
|
||||||
LIBS += $(TOP_DIR)/$(TENSORFLOW_DIR)/$(CPU)/libtf*.a
|
LIBS += $(TOP_DIR)/$(TENSORFLOW_DIR)/$(CPU)/libtf*.a
|
||||||
|
|||||||
@ -25,6 +25,11 @@ set(MICROPY_MANIFEST_OMV_LIB_DIR ${TOP_DIR}/../scripts/libraries)
|
|||||||
# Include board cmake fragment
|
# Include board cmake fragment
|
||||||
include(${OMV_BOARD_CONFIG_DIR}/omv_boardconfig.cmake)
|
include(${OMV_BOARD_CONFIG_DIR}/omv_boardconfig.cmake)
|
||||||
|
|
||||||
|
target_link_options(${MICROPY_TARGET} PRIVATE
|
||||||
|
-Wl,--wrap=tud_cdc_rx_cb
|
||||||
|
-Wl,--wrap=mp_hal_stdout_tx_strn
|
||||||
|
)
|
||||||
|
|
||||||
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
||||||
ARM_MATH_CM0PLUS
|
ARM_MATH_CM0PLUS
|
||||||
${OMV_BOARD_MODULES_DEFINITIONS}
|
${OMV_BOARD_MODULES_DEFINITIONS}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user