summaryrefslogtreecommitdiff
path: root/bsp
diff options
context:
space:
mode:
authortanek liang <[email protected]>2017-11-14 11:09:46 +0800
committerBernard Xiong <[email protected]>2017-11-16 11:05:32 +0800
commitdcce8489dbf37b06ef15cdc84051b783df50f105 (patch)
tree90815e9c6e56de052fcc179ae4f53b58c512919e /bsp
parent234c6113ed8127dfa12b4d30578740bfbad51e32 (diff)
[bsp] add gcc support
Diffstat (limited to 'bsp')
-rw-r--r--bsp/lpc54608-LPCXpresso/SDK_2.2_LPCXpresso54608/devices/LPC54608/SConscript8
-rw-r--r--bsp/lpc54608-LPCXpresso/SDK_2.2_LPCXpresso54608/devices/LPC54608/mcuxpresso/startup_LPC54608.c81
-rw-r--r--bsp/lpc54608-LPCXpresso/applications/application.c36
-rw-r--r--bsp/lpc54608-LPCXpresso/link.lds4
-rw-r--r--bsp/lpc54608-LPCXpresso/rtconfig.py2
5 files changed, 89 insertions, 42 deletions
diff --git a/bsp/lpc54608-LPCXpresso/SDK_2.2_LPCXpresso54608/devices/LPC54608/SConscript b/bsp/lpc54608-LPCXpresso/SDK_2.2_LPCXpresso54608/devices/LPC54608/SConscript
index bc1f869ed5..722ca5f9e1 100644
--- a/bsp/lpc54608-LPCXpresso/SDK_2.2_LPCXpresso54608/devices/LPC54608/SConscript
+++ b/bsp/lpc54608-LPCXpresso/SDK_2.2_LPCXpresso54608/devices/LPC54608/SConscript
@@ -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)
diff --git a/bsp/lpc54608-LPCXpresso/SDK_2.2_LPCXpresso54608/devices/LPC54608/mcuxpresso/startup_LPC54608.c b/bsp/lpc54608-LPCXpresso/SDK_2.2_LPCXpresso54608/devices/LPC54608/mcuxpresso/startup_LPC54608.c
index d45c020543..639f28dc76 100644
--- a/bsp/lpc54608-LPCXpresso/SDK_2.2_LPCXpresso54608/devices/LPC54608/mcuxpresso/startup_LPC54608.c
+++ b/bsp/lpc54608-LPCXpresso/SDK_2.2_LPCXpresso54608/devices/LPC54608/mcuxpresso/startup_LPC54608.c
@@ -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.
+ // //
+ // //data_init(_sidata, _sdata, _edata - _sdata);
- // 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);
- }
+ // // 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
diff --git a/bsp/lpc54608-LPCXpresso/applications/application.c b/bsp/lpc54608-LPCXpresso/applications/application.c
index d6949b3f47..84a475c6e3 100644
--- a/bsp/lpc54608-LPCXpresso/applications/application.c
+++ b/bsp/lpc54608-LPCXpresso/applications/application.c
@@ -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);
diff --git a/bsp/lpc54608-LPCXpresso/link.lds b/bsp/lpc54608-LPCXpresso/link.lds
index 746f3948eb..b3b8961ac5 100644
--- a/bsp/lpc54608-LPCXpresso/link.lds
+++ b/bsp/lpc54608-LPCXpresso/link.lds
@@ -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 */
diff --git a/bsp/lpc54608-LPCXpresso/rtconfig.py b/bsp/lpc54608-LPCXpresso/rtconfig.py
index 9c734eaafe..20b049babb 100644
--- a/bsp/lpc54608-LPCXpresso/rtconfig.py
+++ b/bsp/lpc54608-LPCXpresso/rtconfig.py
@@ -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