<p>Harald Welte <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/9909">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">DFU: disable configured console UART before starting main app<br><br>The DFU uses the UART peripheral (with IRQ/ISR) for the debug output<br>console. Before starting the main application we should make sure<br>this configuration is reset to avoid interference (particularly the<br>IRQ/ISR).<br>This is not too important though since the main application<br>reconfigures the UART for console output.<br>Other peripheral could also be disabled (e.g. all other PIO used<br>by DFU), but most of them also get configured by the main application.<br><br>Change-Id: I8234d1b85938ad6393094c08183f613ad09ee01b<br>---<br>M firmware/libboard/common/include/uart_console.h<br>M firmware/libboard/common/source/board_cstartup_gnu.c<br>M firmware/libboard/common/source/uart_console.c<br>3 files changed, 19 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/firmware/libboard/common/include/uart_console.h b/firmware/libboard/common/include/uart_console.h</span><br><span>index c48c2c1..0e49bfd 100644</span><br><span>--- a/firmware/libboard/common/include/uart_console.h</span><br><span>+++ b/firmware/libboard/common/include/uart_console.h</span><br><span>@@ -34,6 +34,7 @@</span><br><span> #include <stdint.h></span><br><span> </span><br><span> extern void UART_Configure( uint32_t dwBaudrate, uint32_t dwMasterClock ) ;</span><br><span style="color: hsl(120, 100%, 40%);">+extern void UART_Exit(void) ;</span><br><span> extern void UART_PutChar( uint8_t uc ) ;</span><br><span> extern uint32_t UART_GetChar( void ) ;</span><br><span> extern uint32_t UART_IsRxReady( void ) ;</span><br><span>diff --git a/firmware/libboard/common/source/board_cstartup_gnu.c b/firmware/libboard/common/source/board_cstartup_gnu.c</span><br><span>index 4b561ec..42231fb 100644</span><br><span>--- a/firmware/libboard/common/source/board_cstartup_gnu.c</span><br><span>+++ b/firmware/libboard/common/source/board_cstartup_gnu.c</span><br><span>@@ -173,6 +173,8 @@</span><br><span>          * the second entry in the vector table is the reset address, corresponding to the application start </span><br><span>          */ </span><br><span>         if (((*((uint32_t*)(IFLASH_ADDR+BOARD_DFU_BOOT_SIZE)))&0xFFFF0000)==0x20000000) { </span><br><span style="color: hsl(120, 100%, 40%);">+            UART_Exit(); </span><br><span style="color: hsl(120, 100%, 40%);">+            __disable_irq(); </span><br><span>             BootIntoApp(); </span><br><span>             /* Infinite loop */ </span><br><span>             while ( 1 ) ; </span><br><span>diff --git a/firmware/libboard/common/source/uart_console.c b/firmware/libboard/common/source/uart_console.c</span><br><span>index a47ba0c..fe64922 100644</span><br><span>--- a/firmware/libboard/common/source/uart_console.c</span><br><span>+++ b/firmware/libboard/common/source/uart_console.c</span><br><span>@@ -103,6 +103,22 @@</span><br><span>     _ucIsConsoleInitialized=1 ; </span><br><span> } </span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/** </span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Disables the USART peripheral and related IRQ </span><br><span style="color: hsl(120, 100%, 40%);">+ */ </span><br><span style="color: hsl(120, 100%, 40%);">+void UART_Exit(void) </span><br><span style="color: hsl(120, 100%, 40%);">+{ </span><br><span style="color: hsl(120, 100%, 40%);">+      if (!_ucIsConsoleInitialized) { </span><br><span style="color: hsl(120, 100%, 40%);">+              return; </span><br><span style="color: hsl(120, 100%, 40%);">+      } </span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+      Uart *pUart = CONSOLE_UART; </span><br><span style="color: hsl(120, 100%, 40%);">+      pUart->UART_IDR = UART_IDR_TXRDY; </span><br><span style="color: hsl(120, 100%, 40%);">+      pUart->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX | UART_CR_RXDIS | UART_CR_TXDIS | UART_CR_RSTSTA; </span><br><span style="color: hsl(120, 100%, 40%);">+      PMC->PMC_PCDR0 = 1 << CONSOLE_ID; </span><br><span style="color: hsl(120, 100%, 40%);">+      NVIC_DisableIRQ(CONSOLE_IRQ); </span><br><span style="color: hsl(120, 100%, 40%);">+} </span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span> /** Interrupt Service routine to transmit queued data */ </span><br><span> void CONSOLE_ISR(void) </span><br><span> { </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/9909">change 9909</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/9909"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: simtrace2 </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I8234d1b85938ad6393094c08183f613ad09ee01b </div>
<div style="display:none"> Gerrit-Change-Number: 9909 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kévin Redon <kredon@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>