[bsp][sam9260] Optimize code
1. Cleanup unused code in startup.c. 2. Init MMU before init INT contoroller for mapping vector table to visual address 0x0 3. Remove unused section in link scripts.
This commit is contained in:
parent
49fa5c44d7
commit
dc3bd14c2a
|
@ -29,16 +29,6 @@
|
|||
#ifdef RT_USING_FINSH
|
||||
#include <finsh.h>
|
||||
#endif
|
||||
extern void rt_hw_interrupt_init(void);
|
||||
extern void rt_hw_board_init(void);
|
||||
extern void rt_system_timer_init(void);
|
||||
extern void rt_system_scheduler_init(void);
|
||||
extern void rt_thread_idle_init(void);
|
||||
extern void mmu_invalidate_icache();
|
||||
extern void rt_hw_cpu_icache_enable(void);
|
||||
extern void rt_show_version(void);
|
||||
extern void rt_system_heap_init(void*, void*);
|
||||
extern void rt_hw_finsh_init(void);
|
||||
extern void rt_application_init(void);
|
||||
|
||||
/**
|
||||
|
@ -48,65 +38,38 @@ extern void rt_application_init(void);
|
|||
/*@{*/
|
||||
#if defined(__CC_ARM)
|
||||
extern int Image$$ER_ZI$$ZI$$Limit;
|
||||
#define HEAP_START ((void*)&Image$$ER_ZI$$ZI$$Limit)
|
||||
#define HEAP_BEGIN (&Image$$ER_ZI$$ZI$$Limit)
|
||||
#elif (defined (__GNUC__))
|
||||
extern unsigned char __bss_end__;
|
||||
#define HEAP_START ((void*)&__bss_end__)
|
||||
#define HEAP_BEGIN (&__bss_end__)
|
||||
#elif (defined (__ICCARM__))
|
||||
#pragma section="HEAP"
|
||||
#define HEAP_START (__section_begin("HEAP"))
|
||||
#endif
|
||||
|
||||
#define HEAP_END ((void*)0x24000000)
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
extern void finsh_system_init(void);
|
||||
#pragma section=".noinit"
|
||||
#define HEAP_BEGIN (__section_end(".noinit"))
|
||||
#endif
|
||||
|
||||
#define HEAP_END (0x24000000)
|
||||
|
||||
/**
|
||||
* This function will startup RT-Thread RTOS.
|
||||
*/
|
||||
void rtthread_startup(void)
|
||||
static void rtthread_startup(void)
|
||||
{
|
||||
/* disable interrupt first */
|
||||
rt_hw_interrupt_disable();
|
||||
/* enable cpu cache */
|
||||
rt_hw_cpu_icache_disable();
|
||||
mmu_invalidate_icache();
|
||||
rt_hw_cpu_icache_enable();
|
||||
/* initialize board */
|
||||
rt_hw_board_init();
|
||||
|
||||
/* initialize hardware interrupt */
|
||||
rt_hw_interrupt_init();
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* initialize board */
|
||||
rt_hw_board_init();
|
||||
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* initialize tick */
|
||||
rt_system_tick_init();
|
||||
|
||||
/* initialize kernel object */
|
||||
rt_system_object_init();
|
||||
|
||||
/* initialize timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
/* initialize heap memory system */
|
||||
rt_system_heap_init(HEAP_START, HEAP_END);
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
/* initialize module system*/
|
||||
rt_system_module_init();
|
||||
#ifdef RT_USING_HEAP
|
||||
rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
|
||||
#endif
|
||||
|
||||
/* initialize scheduler system */
|
||||
rt_system_scheduler_init();
|
||||
|
||||
/* initialize application */
|
||||
rt_application_init();
|
||||
/* initialize scheduler system */
|
||||
rt_system_scheduler_init();
|
||||
/* initialize system timer*/
|
||||
rt_system_timer_init();
|
||||
/* initialize application */
|
||||
rt_application_init();
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
/* initialize finsh */
|
||||
|
@ -115,26 +78,29 @@ void rtthread_startup(void)
|
|||
finsh_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* initialize timer thread */
|
||||
rt_system_timer_thread_init();
|
||||
|
||||
/* initialize system timer thread */
|
||||
rt_system_timer_thread_init();
|
||||
/* initialize idle thread */
|
||||
rt_thread_idle_init();
|
||||
|
||||
/* initialize idle thread */
|
||||
rt_thread_idle_init();
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
|
||||
/* never reach here */
|
||||
return ;
|
||||
/* never reach here */
|
||||
return ;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* startup RT-Thread RTOS */
|
||||
rtthread_startup();
|
||||
/* disable interrupt first */
|
||||
rt_hw_interrupt_disable();
|
||||
|
||||
return 0;
|
||||
/* startup RT-Thread RTOS */
|
||||
rtthread_startup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
*/
|
||||
/*@{*/
|
||||
|
||||
|
||||
extern void rt_hw_interrupt_init(void);
|
||||
extern void rt_hw_clock_init(void);
|
||||
|
||||
extern void rt_hw_get_clock(void);
|
||||
|
@ -143,6 +143,10 @@ static void at91sam926x_pit_init(void)
|
|||
*/
|
||||
void rt_hw_board_init()
|
||||
{
|
||||
/* initialize mmu */
|
||||
rt_hw_mmu_init(at91_mem_desc, sizeof(at91_mem_desc)/sizeof(at91_mem_desc[0]));
|
||||
/* initialize hardware interrupt */
|
||||
rt_hw_interrupt_init();
|
||||
/* initialize the system clock */
|
||||
rt_hw_clock_init();
|
||||
|
||||
|
@ -150,8 +154,7 @@ void rt_hw_board_init()
|
|||
rt_hw_uart_init();
|
||||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
|
||||
/* initialize mmu */
|
||||
rt_hw_mmu_init(at91_mem_desc, sizeof(at91_mem_desc)/sizeof(at91_mem_desc[0]));
|
||||
|
||||
|
||||
/* initialize timer0 */
|
||||
rt_hw_timer_init();
|
||||
|
|
|
@ -1,26 +1,6 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// blinky.icf - Linker configuration file for blinky.
|
||||
//
|
||||
// Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
//------------------------------------------------------------------------------
|
||||
// Linker scatter for running in external SDRAM on the AT91SAM9260
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Define a memory region that covers the entire 4 GB addressible space of the
|
||||
|
@ -38,12 +18,6 @@ define region FLASH = mem:[from 0x20000000 to 0x207FFFFF];
|
|||
//
|
||||
define region SRAM = mem:[from 0x20800000 to 0x23FFFFFF];
|
||||
|
||||
//
|
||||
// Define a block for the heap. The size should be set to something other
|
||||
// than zero if things in the C library that require the heap are used.
|
||||
//
|
||||
define block HEAP with alignment = 8, size = 0x02000000 { };
|
||||
|
||||
//
|
||||
// Indicate that the read/write values should be initialized by copying from
|
||||
// flash.
|
||||
|
@ -75,7 +49,7 @@ place at start of SRAM { section VTABLE };
|
|||
//
|
||||
// Place all read/write items into SRAM.
|
||||
//
|
||||
place in SRAM { readwrite, block HEAP };
|
||||
place in SRAM { readwrite};
|
||||
keep { section FSymTab };
|
||||
keep { section VSymTab };
|
||||
keep { section .rti_fn* };
|
||||
|
|
|
@ -1,34 +1,6 @@
|
|||
; * ----------------------------------------------------------------------------
|
||||
; * ATMEL Microcontroller Software Support
|
||||
; * ----------------------------------------------------------------------------
|
||||
; * Copyright (c) 2008, Atmel Corporation
|
||||
; *
|
||||
; * All rights reserved.
|
||||
; *
|
||||
; * Redistribution and use in source and binary forms, with or without
|
||||
; * modification, are permitted provided that the following conditions are met:
|
||||
; *
|
||||
; * - Redistributions of source code must retain the above copyright notice,
|
||||
; * this list of conditions and the disclaimer below.
|
||||
; *
|
||||
; * Atmel's name may not be used to endorse or promote products derived from
|
||||
; * this software without specific prior written permission.
|
||||
; *
|
||||
; * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
; * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
; * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
; * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
; * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
; * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
; * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
; * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
; * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
; * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
; * ----------------------------------------------------------------------------
|
||||
|
||||
; *------------------------------------------------------------------------------
|
||||
; * Linker scatter for running in external SDRAM on the AT91SAM9260
|
||||
; *----------------------------------------------------------------------------*/
|
||||
;*------------------------------------------------------------------------------
|
||||
;* Linker scatter for running in external SDRAM on the AT91SAM9260
|
||||
;*----------------------------------------------------------------------------*/
|
||||
|
||||
Load_region 0x20000000 0x00800000
|
||||
{
|
||||
|
@ -38,21 +10,31 @@ Load_region 0x20000000 0x00800000
|
|||
* (RESET +First)
|
||||
.ANY (+RO +RW)
|
||||
}
|
||||
|
||||
ARM_LIB_HEAP +0 EMPTY 0x1000
|
||||
{
|
||||
}
|
||||
|
||||
ARM_LIB_STACK +0 EMPTY 0x1000
|
||||
{
|
||||
}
|
||||
|
||||
; Application ZI data (.bss)
|
||||
ER_ZI +0
|
||||
{
|
||||
* (+ZI)
|
||||
} ; Application ZI data (.bss)
|
||||
}
|
||||
|
||||
;Relocate_region 0x200000 0x1000
|
||||
;{
|
||||
; *.o (VECTOR, +First)
|
||||
;}
|
||||
|
||||
ARM_LIB_HEAP 0x21FFE000 EMPTY 0x1000
|
||||
{
|
||||
}
|
||||
|
||||
ARM_LIB_STACK 0x22000000 EMPTY -0x1000
|
||||
{
|
||||
}
|
||||
;ARM_LIB_HEAP 0x21FFE000 EMPTY 0x1000
|
||||
;{
|
||||
;}
|
||||
|
||||
;ARM_LIB_STACK 0x22000000 EMPTY -0x1000
|
||||
;{
|
||||
;}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue