Merge pull request #1090 from TanekLiang/imxrt_fix

[bsp] fix uart bug and use linker scritp symbol fo heap
This commit is contained in:
Bernard Xiong 2017-12-09 12:01:14 +08:00 committed by GitHub
commit 870c1fd15c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 10 deletions

View File

@ -67,6 +67,9 @@
#define Heap_Size 0x0400
#endif
#define RTT_HEAP_SIZE \
(m_data_size - ImageLength(RW_m_data) - ImageLength(ARM_LIB_HEAP) - ImageLength(ARM_LIB_STACK))
LR_m_text m_text_start m_text_size { ; load region size_region
ER_m_text m_text_start m_text_size { ; load address = execution address
* (RESET,+FIRST)
@ -81,6 +84,8 @@ LR_m_text m_text_start m_text_size { ; load region size_region
}
ARM_LIB_STACK +0 EMPTY Stack_Size { ; Stack region growing down
}
RTT_HEAP +0 EMPTY RTT_HEAP_SIZE {
}
RW_m_ncache m_ncache_start m_ncache_size { ; ncache RW data
* (NonCacheable.init)

View File

@ -253,12 +253,16 @@ SECTIONS
stack_start = .;
. += STACK_SIZE;
stack_end = .;
__StackTop = .;
} > m_dtcm
.RTT_HEAP :
{
heap_start = .;
. = ALIGN(8);
} > m_dtcm
/* Initializes stack on the end of block */
__StackTop = stack_end;
PROVIDE(__stack = __StackTop);
PROVIDE(heap_end = ORIGIN(m_dtcm) + LENGTH(m_dtcm));
.ARM.attributes 0 : { *(.ARM.attributes) }

View File

@ -81,6 +81,7 @@ if (isdefinedsymbol(__heap_size__)) {
define exported symbol __VECTOR_TABLE = m_interrupts_start;
define exported symbol __VECTOR_RAM = m_interrupts_start;
define exported symbol __RAM_VECTOR_TABLE_SIZE = 0x0;
define exported symbol __RTT_HEAP_END = m_dtcm_end;
define memory mem with size = 4G;
define region TEXT_region = mem:[from m_interrupts_start to m_interrupts_end]

View File

@ -21,19 +21,22 @@
#include <fsl_iomuxc.h>
#ifdef __CC_ARM
extern int Image$$ARM_LIB_STACK$$ZI$$Limit;
#define HEAP_BEGIN (&Image$$ARM_LIB_STACK$$ZI$$Limit)
#define HEAP_END (0x2001FFFFu)
extern int Image$$RTT_HEAP$$ZI$$Base;
extern int Image$$RTT_HEAP$$ZI$$Limit;
#define HEAP_BEGIN (&Image$$RTT_HEAP$$ZI$$Base)
#define HEAP_END (&Image$$RTT_HEAP$$ZI$$Limit)
#elif __ICCARM__
#pragma section="HEAP"
#define HEAP_BEGIN (__segment_end("HEAP"))
#define HEAP_END (0x2001FFFFu)
extern void __RTT_HEAP_END;
#define HEAP_END (&__RTT_HEAP_END)
#else
extern int heap_start;
extern int heap_end;
#define HEAP_BEGIN (&heap_start)
#define HEAP_END (0x2001FFFFu)
#define HEAP_END (&heap_end)
#endif
#define HEAP_SIZE ((uint32_t)HEAP_END - (uint32_t)HEAP_BEGIN)

View File

@ -320,18 +320,32 @@ static int imxrt_getc(struct rt_serial_device *serial)
*/
static void uart_isr(struct rt_serial_device *serial)
{
struct imxrt_uart *uart = (struct imxrt_uart *) serial->parent.user_data;
struct imxrt_uart *uart;
LPUART_Type *base;
RT_ASSERT(serial != RT_NULL);
uart = (struct imxrt_uart *) serial->parent.user_data;
RT_ASSERT(uart != RT_NULL);
base = uart->uart_base;
RT_ASSERT(base != RT_NULL);
/* enter interrupt */
rt_interrupt_enter();
/* UART in mode Receiver -------------------------------------------------*/
if (LPUART_GetStatusFlags(uart->uart_base) & kLPUART_RxDataRegFullFlag)
if (LPUART_GetStatusFlags(base) & kLPUART_RxDataRegFullFlag)
{
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
}
/* If RX overrun. */
if (LPUART_STAT_OR_MASK & base->STAT)
{
/* Clear overrun flag, otherwise the RX does not work. */
base->STAT = ((base->STAT & 0x3FE00000U) | LPUART_STAT_OR_MASK);
}
/* leave interrupt */
rt_interrupt_leave();