Ref: http://esp32.com/viewtopic.php?f=13&t=546&sid=
76ff371ae2b259441a2cf355e96d74b9#p2275
This is a really subtle bug, gcc noticed the UART array elements are read-only so
implicitly moved the elements to .rodata as if it was const. However
this array is accessed from the UART ISR, so has to be in IRAM or DRAM.
\r
\r
static uart_obj_t *p_uart_obj[UART_NUM_MAX] = {0};\r
-static uart_dev_t* UART[UART_NUM_MAX] = {&UART0, &UART1, &UART2};\r
+/* DRAM_ATTR is required to avoid UART array placed in flash, due to accessed from ISR */\r
+static DRAM_ATTR uart_dev_t* const UART[UART_NUM_MAX] = {&UART0, &UART1, &UART2};\r
static portMUX_TYPE uart_spinlock[UART_NUM_MAX] = {portMUX_INITIALIZER_UNLOCKED, portMUX_INITIALIZER_UNLOCKED, portMUX_INITIALIZER_UNLOCKED};\r
\r
esp_err_t uart_set_word_length(uart_port_t uart_num, uart_word_length_t data_bit)\r