提交 dcce8489 编写于 作者: T tanek liang 提交者: Bernard Xiong

[bsp] add gcc support

上级 234c6113
......@@ -8,20 +8,22 @@ Import('rtconfig')
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
CPPDEFINES = []
objs = objs + SConscript(os.path.join('drivers', 'SConscript'))
objs = objs + SConscript(os.path.join('utilities', 'SConscript'))
if rtconfig.CROSS_TOOL == 'gcc':
objs = objs + SConscript(os.path.join('mcuxpresso', 'SConscript'))
CPPDEFINES += ['__USE_CMSIS']
elif rtconfig.CROSS_TOOL == 'keil':
objs = objs + SConscript(os.path.join('arm', 'SConscript'))
elif rtconfig.CROSS_TOOL == 'iar':
objs = objs + SConscript(os.path.join('iar', 'SConscript'))
src = Glob('*.c')
CPPPATH = [cwd]
CPPDEFINES = ['CORE_M4', 'CPU_LPC54608', 'CPU_LPC54608J512ET180=1']
src = Glob('*.c')
CPPPATH = [cwd]
CPPDEFINES += ['CORE_M4', 'CPU_LPC54608', 'CPU_LPC54608J512ET180=1']
group = DefineGroup('CMSIS', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
......
......@@ -82,7 +82,7 @@ extern void SystemInit(void);
// When the application defines a handler (with the same name), this will
// automatically take precedence over these weak definitions
//*****************************************************************************
void ResetISR(void);
void Reset_Handler(void);
WEAK void NMI_Handler(void);
WEAK void HardFault_Handler(void);
WEAK void MemManage_Handler(void);
......@@ -234,7 +234,7 @@ extern int main(void);
//*****************************************************************************
// External declaration for the pointer to the stack top from the Linker Script
//*****************************************************************************
extern void _vStackTop(void);
extern void _estack(void);
//*****************************************************************************
// External declaration for LPC MCU vector table checksum from Linker Script
......@@ -256,8 +256,8 @@ extern void * __Vectors __attribute__ ((alias ("g_pfnVectors")));
__attribute__ ((used, section(".isr_vector")))
void (* const g_pfnVectors[])(void) = {
// Core Level - CM4
&_vStackTop, // The initial stack pointer
ResetISR, // The reset handler
&_estack, // The initial stack pointer
Reset_Handler, // The reset handler
NMI_Handler, // The NMI handler
HardFault_Handler, // The hard fault handler
MemManage_Handler, // The MPU fault handler
......@@ -336,7 +336,7 @@ void (* const g_pfnVectors[])(void) = {
//*****************************************************************************
// Functions to carry out the initialization of RW and BSS data sections. These
// are written as separate functions rather than being inlined within the
// ResetISR() function in order to cope with MCUs with multiple banks of
// Reset_Handler() function in order to cope with MCUs with multiple banks of
// memory.
//*****************************************************************************
__attribute__ ((section(".after_vectors.init_data")))
......@@ -363,19 +363,23 @@ void bss_init(unsigned int start, unsigned int len) {
// contains the load address, execution address and length of each RW data
// section and the execution and length of each BSS (zero initialized) section.
//*****************************************************************************
extern unsigned int __data_section_table;
extern unsigned int __data_section_table_end;
extern unsigned int __bss_section_table;
extern unsigned int __bss_section_table_end;
extern unsigned int _sdata;
extern unsigned int _edata;
extern unsigned int _sidata;
extern unsigned int _sbss;
extern unsigned int _ebss;
//*****************************************************************************
// Reset entry point for your code.
// Sets up a simple runtime environment and initializes the C/C++
// library.
//Reset entry point for your code.
//Sets up a simple runtime environment and initializes the C/C++
//library.
//*****************************************************************************
__attribute__ ((section(".after_vectors.reset")))
void ResetISR(void) {
void Reset_Handler(void) {
/* Data and BSS variables */
unsigned int *srcdata, *dstdata, *sbss;
// Disable interrupts
__asm volatile ("cpsid i");
......@@ -383,36 +387,41 @@ void ResetISR(void) {
__asm volatile ("LDR R0, =0x40000220\n\t"
"MOV R1, #56\n\t"
"STR R1, [R0]");
// extern void Reset_ASM_Handler();
// Reset_ASM_Handler();
srcdata = &_sidata;
dstdata = &_sdata;
sbss = &_sbss;
/* Copy data */
while(dstdata != &_edata)
{
*(dstdata++) = *(srcdata++);
}
/* Clear BSS */
while(sbss != &_ebss)
{
*(sbss++) = '\0';
}
#if defined (__USE_CMSIS)
// If __USE_CMSIS defined, then call CMSIS SystemInit code
SystemInit();
#endif // (__USE_CMSIS)
//
// Copy the data sections from flash to SRAM.
//
unsigned int LoadAddr, ExeAddr, SectionLen;
unsigned int *SectionTableAddr;
// Load base address of Global Section Table
SectionTableAddr = &__data_section_table;
// Copy the data sections from flash to SRAM.
while (SectionTableAddr < &__data_section_table_end) {
LoadAddr = *SectionTableAddr++;
ExeAddr = *SectionTableAddr++;
SectionLen = *SectionTableAddr++;
data_init(LoadAddr, ExeAddr, SectionLen);
}
// //
// // Copy the data sections from flash to SRAM.
// //
// //data_init(_sidata, _sdata, _edata - _sdata);
// // At this point, SectionTableAddr = &__bss_section_table;
// // Zero fill the bss segment
// //bss_init(_sbss, _ebss - _sbss);
//bss_init(_sbss, _ebss - _sbss);
// At this point, SectionTableAddr = &__bss_section_table;
// Zero fill the bss segment
while (SectionTableAddr < &__bss_section_table_end) {
ExeAddr = *SectionTableAddr++;
SectionLen = *SectionTableAddr++;
bss_init(ExeAddr, SectionLen);
}
#if !defined (__USE_CMSIS)
// Assume that if __USE_CMSIS defined, then CMSIS SystemInit code
......
......@@ -38,9 +38,45 @@ void rt_init_thread_entry(void *parameter)
#endif
}
void build_dump(void)
{
#if defined(__CC_ARM)
rt_kprintf("using MDK\n");
#elif defined(__IAR_SYSTEMS_ICC__)
rt_kprintf("using IAR\n");
#elif defined(__GNUC__)
rt_kprintf("using GCC\n");
#else
rt_kprintf("unkown Compiler\n");
#endif
}
void link_dump(void)
{
extern unsigned int _sdata;
extern unsigned int _edata;
extern unsigned int _sidata;
extern unsigned int _sbss;
extern unsigned int _ebss;
#define DUMP_VAR(__VAR) \
rt_kprintf("%-20s %p\n", #__VAR, &__VAR)
DUMP_VAR(_sdata);
DUMP_VAR(_edata);
DUMP_VAR(_sidata);
DUMP_VAR(_sbss);
DUMP_VAR(_ebss);
}
int rt_application_init(void)
{
rt_thread_t tid;
build_dump();
link_dump();
tid = rt_thread_create("init",
rt_init_thread_entry, RT_NULL,
2048, RT_THREAD_PRIORITY_MAX / 3, 20);
......
......@@ -7,7 +7,7 @@
MEMORY
{
CODE (rx) : ORIGIN = 0x00000000, LENGTH = 0x00080000
DATA (rw) : ORIGIN = 0x10000000, LENGTH = 0x00010000
DATA (rw) : ORIGIN = 0x20000000, LENGTH = 0x00028000
}
ENTRY(Reset_Handler)
_system_stack_size = 0x200;
......@@ -17,7 +17,7 @@ SECTIONS
.text :
{
. = ALIGN(4);
KEEP(*(.interrupt_vector)) /* Startup code */
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
*(.text) /* remaining code */
*(.text.*) /* remaining code */
......
......@@ -55,7 +55,7 @@ if PLATFORM == 'gcc':
CXXFLAGS = CFLAGS
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
POST_ACTION = OBJCPY + ' -O ihex $TARGET rtthread.hex\n' + SIZE + ' $TARGET \n'
elif PLATFORM == 'armcc':
# toolchains
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册