cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4xx HAL dumps RAM through UART on Framing Error? (possible security issue)

SMisi
Associate II

I am using DMA for receiving data, but interrupts for transmitting over UART and I am experiencing following issue:

When the UART experiences Framing Error, the DMA stream triggers an interrupt to which HAL responds by eventually calling UART_DMAAbortOnError() which will zero both RX and TX transfer counters, but does not terminate the Interrupt driven transmission properly. If this happens during a transmission the UART interrupt handler calls UART_Transmit_IT() which contains following boundary check:

if (--huart->TxXferCount == 0U)

But the TxXferCount was set to 0 by the UART_DMAAbortOnError(), so the counter will wrap around and the UART will effectively dump half of the RAM.

Does anybody know the correct work-around, beside modifying HAL code?

Thanks

3 REPLIES 3
Ozone
Lead II

> Does anybody know the correct work-around, beside modifying HAL code?

I think not.

It is best to consider Cube/HAL code as a free gift for beginners, and useful for rapid prototyping.

But it is unfit for serious commercial purposes.

SMisi
Associate II

I eventually ended up disabling DMA using HAL_UART_DMAPause() and HAL_UART_DMAResume() while transmitting, since I did not need full-duplex communication. That seems to have helped.

It is certainly littered with stuff like this, but we keep hearing how it's MISRA, LINT'd or whatever.

And very little of it seems to have been real-world tested, stressed or gotten much QA scrutiny

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..