From d4e4469ff7aba5522859cd43e2c7ec6ea97b5fc7 Mon Sep 17 00:00:00 2001 From: Lukas Pajak Date: Tue, 3 Dec 2024 10:52:34 +0100 Subject: [PATCH 1/3] [sw] Add UART_DISABLED flag to reduce footprint --- sw/lib/source/neorv32_uart.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sw/lib/source/neorv32_uart.c b/sw/lib/source/neorv32_uart.c index 08a245f6c..31b994c73 100644 --- a/sw/lib/source/neorv32_uart.c +++ b/sw/lib/source/neorv32_uart.c @@ -20,6 +20,29 @@ #include #include +// Drastically reduces the footprint, when knowing that uart is not synthesized anyway. +#ifdef UART_DISABLED +int neorv32_uart_available(neorv32_uart_t *UARTx) { return 0; } +int neorv32_uart_get_rx_fifo_depth(neorv32_uart_t *UARTx) { return 0; } +int neorv32_uart_get_tx_fifo_depth(neorv32_uart_t *UARTx) { return 0; } +void neorv32_uart_setup(neorv32_uart_t *UARTx, uint32_t baudrate, uint32_t irq_mask) {} +void neorv32_uart_enable(neorv32_uart_t *UARTx) {} +void neorv32_uart_disable(neorv32_uart_t *UARTx) {} +void neorv32_uart_rtscts_enable(neorv32_uart_t *UARTx) {} +void neorv32_uart_rtscts_disable(neorv32_uart_t *UARTx) {} +void neorv32_uart_putc(neorv32_uart_t *UARTx, char c) {} +void neorv32_uart_rx_clear(neorv32_uart_t *UARTx) {} +void neorv32_uart_tx_clear(neorv32_uart_t *UARTx) {} +int neorv32_uart_tx_busy(neorv32_uart_t *UARTx) { return 0; } +char neorv32_uart_getc(neorv32_uart_t *UARTx) {return 0; } +int neorv32_uart_char_received(neorv32_uart_t *UARTx) { return 0; } +char neorv32_uart_char_received_get(neorv32_uart_t *UARTx) { return 0; } +void neorv32_uart_puts(neorv32_uart_t *UARTx, const char *s) {} +void neorv32_uart_vprintf(neorv32_uart_t *UARTx, const char *format, va_list args) {} +void neorv32_uart_printf(neorv32_uart_t *UARTx, const char *format, ...) {} +int neorv32_uart_scan(neorv32_uart_t *UARTx, char *buffer, int max_size, int echo) { return 0; } +#else + /**********************************************************************//** * Check if UART unit was synthesized. @@ -433,3 +456,5 @@ int neorv32_uart_scan(neorv32_uart_t *UARTx, char *buffer, int max_size, int ech return length; } + +#endif //UART_DISABLED \ No newline at end of file From 154642d9643aec57c4de76dec4d5a7cff73a7762 Mon Sep 17 00:00:00 2001 From: Lukas Pajak Date: Tue, 3 Dec 2024 11:18:04 +0100 Subject: [PATCH 2/3] [docs] Add UART_DISABLED and lto to mk example --- docs/datasheet/software.adoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/datasheet/software.adoc b/docs/datasheet/software.adoc index c4e0e4e11..2689319b9 100644 --- a/docs/datasheet/software.adoc +++ b/docs/datasheet/software.adoc @@ -155,6 +155,12 @@ USER_FLAGS += -Wl,--defsym,__neorv32_ram_size=8k # Adjust maximum heap size USER_FLAGS += -Wl,--defsym,__neorv32_heap_size=1k +# Reduce library footprint when no UART is synthesized +#USER_FLAGS += -DUART_DISABLED + +# Enable link-time-optimization +#USER_FLAGS += -flto + # Additional compiler flags (append to this variable) #USER_FLAGS += ... From 9e48921704305b0f42bedc98dbb5ce77a411931d Mon Sep 17 00:00:00 2001 From: stnolting Date: Tue, 3 Dec 2024 19:44:55 +0100 Subject: [PATCH 3/3] [sw/lib] uart: add trailing new line --- sw/lib/source/neorv32_uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sw/lib/source/neorv32_uart.c b/sw/lib/source/neorv32_uart.c index 31b994c73..c8eb80184 100644 --- a/sw/lib/source/neorv32_uart.c +++ b/sw/lib/source/neorv32_uart.c @@ -457,4 +457,4 @@ int neorv32_uart_scan(neorv32_uart_t *UARTx, char *buffer, int max_size, int ech return length; } -#endif //UART_DISABLED \ No newline at end of file +#endif //UART_DISABLED