Kévin Redon has uploaded this change for review. ( https://gerrit.osmocom.org/9909
Change subject: DFU: disable configured console UART before starting main app ...................................................................... DFU: disable configured console UART before starting main app The DFU uses the UART peripheral (with IRQ/ISR) for the debug output console. Before starting the main application we should make sure this configuration is reset to avoid interference (particularly the IRQ/ISR). This is not too important though since the main application reconfigures the UART for console output. Other peripheral could also be disabled (e.g. all other PIO used by DFU), but most of them also get configured by the main application. Change-Id: I8234d1b85938ad6393094c08183f613ad09ee01b --- M firmware/libboard/common/include/uart_console.h M firmware/libboard/common/source/board_cstartup_gnu.c M firmware/libboard/common/source/uart_console.c 3 files changed, 19 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/09/9909/1 diff --git a/firmware/libboard/common/include/uart_console.h b/firmware/libboard/common/include/uart_console.h index c48c2c1..0e49bfd 100644 --- a/firmware/libboard/common/include/uart_console.h +++ b/firmware/libboard/common/include/uart_console.h @@ -34,6 +34,7 @@ #include <stdint.h> extern void UART_Configure( uint32_t dwBaudrate, uint32_t dwMasterClock ) ; +extern void UART_Exit(void) ; extern void UART_PutChar( uint8_t uc ) ; extern uint32_t UART_GetChar( void ) ; extern uint32_t UART_IsRxReady( void ) ; diff --git a/firmware/libboard/common/source/board_cstartup_gnu.c b/firmware/libboard/common/source/board_cstartup_gnu.c index 4b561ec..42231fb 100644 --- a/firmware/libboard/common/source/board_cstartup_gnu.c +++ b/firmware/libboard/common/source/board_cstartup_gnu.c @@ -173,6 +173,8 @@ * the second entry in the vector table is the reset address, corresponding to the application start */ if (((*((uint32_t*)(IFLASH_ADDR+BOARD_DFU_BOOT_SIZE)))&0xFFFF0000)==0x20000000) { + UART_Exit(); + __disable_irq(); BootIntoApp(); /* Infinite loop */ while ( 1 ) ; diff --git a/firmware/libboard/common/source/uart_console.c b/firmware/libboard/common/source/uart_console.c index a47ba0c..fe64922 100644 --- a/firmware/libboard/common/source/uart_console.c +++ b/firmware/libboard/common/source/uart_console.c @@ -103,6 +103,22 @@ _ucIsConsoleInitialized=1 ; } +/** + * \brief Disables the USART peripheral and related IRQ + */ +void UART_Exit(void) +{ + if (!_ucIsConsoleInitialized) { + return; + } + + Uart *pUart = CONSOLE_UART; + pUart->UART_IDR = UART_IDR_TXRDY; + pUart->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX | UART_CR_RXDIS | UART_CR_TXDIS | UART_CR_RSTSTA; + PMC->PMC_PCDR0 = 1 << CONSOLE_ID; + NVIC_DisableIRQ(CONSOLE_IRQ); +} + /** Interrupt Service routine to transmit queued data */ void CONSOLE_ISR(void) { -- To view, visit https://gerrit.osmocom.org/9909 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: simtrace2 Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: I8234d1b85938ad6393094c08183f613ad09ee01b Gerrit-Change-Number: 9909 Gerrit-PatchSet: 1 Gerrit-Owner: Kévin Redon <kre...@sysmocom.de>