Browse Source

fixed compiling error in stm32f0x

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2197 bbd45198-f89e-11dd-88c7-29a3b14d5316
dzzxzz@gmail.com 13 years ago
parent
commit
d402cfea19

+ 3 - 2
bsp/mb9bf506r/applications/application.c

@@ -1,7 +1,7 @@
 /*
  * File      : application.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2009 - 2011, RT-Thread Development Team
+ * COPYRIGHT (C) 2009 - 2012, RT-Thread Development Team
  *
  * The license and distribution terms for this file may be
  * found in the file LICENSE in this distribution or at
@@ -62,7 +62,8 @@ int rt_application_init(void)
 	tid = rt_thread_create("init",
 			rt_init_thread_entry, RT_NULL,
 			2048, RT_THREAD_PRIORITY_MAX/3, 20);
-	if (tid != RT_NULL) rt_thread_startup(tid);
+	if (tid != RT_NULL)
+		rt_thread_startup(tid);
 
 	return 0;
 }

+ 0 - 11
bsp/stm32f0x/Libraries/SConscript

@@ -12,17 +12,6 @@ CMSIS/ST/STM32F0xx/Source/Templates/system_stm32f0xx.c
 
 src += Glob('STM32F0xx_StdPeriph_Driver/src/*.c')
 
-# starupt scripts for each STM32 kind
-# startup_scripts = {}
-# startup_scripts['STM32F10X_CL']     = 'startup_stm32f10x_cl.s'
-# startup_scripts['STM32F10X_HD']     = 'startup_stm32f10x_hd.s'
-# startup_scripts['STM32F10X_HD_VL']  = 'startup_stm32f10x_hd_vl.s'
-# startup_scripts['STM32F10X_LD']     = 'startup_stm32f10x_ld.s'
-# startup_scripts['STM32F10X_LD_VL']  = 'startup_stm32f10x_ld_vl.s'
-# startup_scripts['STM32F10X_MD']     = 'startup_stm32f10x_md.s'
-# startup_scripts['STM32F10X_MD_VL']  = 'startup_stm32f10x_md_vl.s'
-# startup_scripts['STM32F10X_XL']	    = 'startup_stm32f10x_xl.s'
-
 #add for startup script 
 if rtconfig.CROSS_TOOL == 'gcc':
      src = src + ['CMSIS/ST/STM32F0xx/Source/Templates/gcc_ride7/startup_stm32f0xx.s']

+ 1 - 1
bsp/stm32f0x/SConstruct

@@ -10,7 +10,7 @@ else:
 sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
 from building import *
 
-TARGET = 'rtthread-stm32f4xx.' + rtconfig.TARGET_EXT
+TARGET = 'rtthread-stm32f0xx.' + rtconfig.TARGET_EXT
 
 env = Environment(tools = ['mingw'],
 	AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,

+ 6 - 6
bsp/stm32f0x/rtconfig.py

@@ -12,10 +12,10 @@ if os.getenv('RTT_CC'):
 # EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
 if  CROSS_TOOL == 'gcc':
 	PLATFORM 	= 'gcc'
-	EXEC_PATH 	= 'E:/Program Files/CodeSourcery/Sourcery G++ Lite/bin'
+	EXEC_PATH 	= 'C:/Program Files/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin'
 elif CROSS_TOOL == 'keil':
 	PLATFORM 	= 'armcc'
-	EXEC_PATH 	= 'E:/Keil'
+	EXEC_PATH 	= 'C:/Keil'
 elif CROSS_TOOL == 'iar':
     print '================ERROR============================'
     print 'Not support iar yet!'
@@ -40,7 +40,7 @@ if PLATFORM == 'gcc':
     OBJDUMP = PREFIX + 'objdump'
     OBJCPY = PREFIX + 'objcopy'
 
-    DEVICE = ' -mcpu=cortex-m0 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections'
+    DEVICE = ' -mcpu=cortex-m0 -mthumb -ffunction-sections -fdata-sections'
     CFLAGS = DEVICE 
     AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
     LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-stm32.map,-cref,-u,Reset_Handler -T stm32_rom.ld'
@@ -103,7 +103,7 @@ elif PLATFORM == 'iar':
     CFLAGS += ' --no_scheduling' 
     CFLAGS += ' --debug' 
     CFLAGS += ' --endian=little' 
-    CFLAGS += ' --cpu=Cortex-M4' 
+    CFLAGS += ' --cpu=Cortex-M0' 
     CFLAGS += ' -e' 
     CFLAGS += ' --fpu=None'
     CFLAGS += ' --dlib_config "' + IAR_PATH + '/arm/INC/c/DLib_Config_Normal.h"'    
@@ -114,10 +114,10 @@ elif PLATFORM == 'iar':
     AFLAGS += ' -s+' 
     AFLAGS += ' -w+' 
     AFLAGS += ' -r' 
-    AFLAGS += ' --cpu Cortex-M4' 
+    AFLAGS += ' --cpu Cortex-M0' 
     AFLAGS += ' --fpu None' 
 
-    LFLAGS = ' --config stm32f10x_flash.icf'
+    LFLAGS = ' --config stm32f0xx_flash.icf'
     LFLAGS += ' --redirect _Printf=_PrintfTiny' 
     LFLAGS += ' --redirect _Scanf=_ScanfSmall' 
     LFLAGS += ' --entry __iar_program_start'    

+ 134 - 0
bsp/stm32f0x/stm32_rom.ld

@@ -0,0 +1,134 @@
+/*
+ * linker script for STM32F0x with GNU ld
+ * bernard.xiong 2009-10-14
+ */
+
+/* Program Entry, set to mark it as "used" and avoid gc */
+MEMORY
+{
+    CODE (rx) : ORIGIN = 0x08000000, LENGTH = 64k /* 64KB flash */
+    DATA (rw) : ORIGIN = 0x20000000, LENGTH =  8k /* 8K sram */
+}
+ENTRY(Reset_Handler)
+_system_stack_size = 0x100;
+
+SECTIONS
+{
+    .text :
+    {
+        . = ALIGN(4);
+        KEEP(*(.isr_vector))            /* Startup code */
+        . = ALIGN(4);
+        *(.text)                        /* remaining code */
+        *(.text.*)                      /* remaining code */
+        *(.rodata)                      /* read-only data (constants) */
+        *(.rodata*)
+        *(.glue_7)
+        *(.glue_7t)
+        *(.gnu.linkonce.t*)
+
+        /* section information for finsh shell */
+        . = ALIGN(4);
+        __fsymtab_start = .;
+        KEEP(*(FSymTab))
+        __fsymtab_end = .;
+        . = ALIGN(4);
+        __vsymtab_start = .;
+        KEEP(*(VSymTab))
+        __vsymtab_end = .;
+        . = ALIGN(4);
+
+        . = ALIGN(4);
+        _etext = .;
+    } > CODE = 0
+
+    /* .ARM.exidx is sorted, so has to go in its own output section.  */
+    __exidx_start = .;
+    .ARM.exidx :
+    {
+        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+
+        /* This is used by the startup in order to initialize the .data secion */
+        _sidata = .;
+    } > CODE
+    __exidx_end = .;
+
+    /* .data section which is used for initialized data */
+
+    .data : AT (_sidata)
+    {
+        . = ALIGN(4);
+        /* This is used by the startup in order to initialize the .data secion */
+        _sdata = . ;
+
+        *(.data)
+        *(.data.*)
+        *(.gnu.linkonce.d*)
+
+        . = ALIGN(4);
+        /* This is used by the startup in order to initialize the .data secion */
+        _edata = . ;
+    } >DATA
+
+	.stack : 
+	{
+		. = . + _system_stack_size;
+		. = ALIGN(4);
+		_estack = .;
+	} >DATA
+
+    __bss_start = .;
+    .bss :
+    {
+        . = ALIGN(4);
+        /* This is used by the startup in order to initialize the .bss secion */
+        _sbss = .;
+
+        *(.bss)
+        *(.bss.*)
+        *(COMMON)
+
+        . = ALIGN(4);
+        /* This is used by the startup in order to initialize the .bss secion */
+        _ebss = . ;
+        
+        *(.bss.init)
+    } > DATA
+    __bss_end = .;
+
+    _end = .;
+
+    /* Stabs debugging sections.  */
+    .stab          0 : { *(.stab) }
+    .stabstr       0 : { *(.stabstr) }
+    .stab.excl     0 : { *(.stab.excl) }
+    .stab.exclstr  0 : { *(.stab.exclstr) }
+    .stab.index    0 : { *(.stab.index) }
+    .stab.indexstr 0 : { *(.stab.indexstr) }
+    .comment       0 : { *(.comment) }
+    /* DWARF debug sections.
+     * Symbols in the DWARF debugging sections are relative to the beginning
+     * of the section so we begin them at 0.  */
+    /* DWARF 1 */
+    .debug          0 : { *(.debug) }
+    .line           0 : { *(.line) }
+    /* GNU DWARF 1 extensions */
+    .debug_srcinfo  0 : { *(.debug_srcinfo) }
+    .debug_sfnames  0 : { *(.debug_sfnames) }
+    /* DWARF 1.1 and DWARF 2 */
+    .debug_aranges  0 : { *(.debug_aranges) }
+    .debug_pubnames 0 : { *(.debug_pubnames) }
+    /* DWARF 2 */
+    .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
+    .debug_abbrev   0 : { *(.debug_abbrev) }
+    .debug_line     0 : { *(.debug_line) }
+    .debug_frame    0 : { *(.debug_frame) }
+    .debug_str      0 : { *(.debug_str) }
+    .debug_loc      0 : { *(.debug_loc) }
+    .debug_macinfo  0 : { *(.debug_macinfo) }
+    /* SGI/MIPS DWARF 2 extensions */
+    .debug_weaknames 0 : { *(.debug_weaknames) }
+    .debug_funcnames 0 : { *(.debug_funcnames) }
+    .debug_typenames 0 : { *(.debug_typenames) }
+    .debug_varnames  0 : { *(.debug_varnames) }
+}

+ 15 - 0
bsp/stm32f0x/stm32_rom.sct

@@ -0,0 +1,15 @@
+; *************************************************************
+; *** Scatter-Loading Description File generated by uVision ***
+; *************************************************************
+
+LR_IROM1 0x08000000 0x00010000  {    ; load region size_region
+  ER_IROM1 0x08000000 0x00010000  {  ; load address = execution address
+   *.o (RESET, +First)
+   *(InRoot$$Sections)
+   .ANY (+RO)
+  }
+  RW_IRAM1 0x20000000 0x00002000  {  ; RW data
+   .ANY (+RW +ZI)
+  }
+}
+

+ 2 - 0
components/libc/minilibc/time.c

@@ -205,6 +205,7 @@ char *ctime(const time_t *timep)
 	return asctime(localtime(timep));
 }
 
+#ifdef RT_USING_DEVICE
 int gettimeofday(struct timeval *tp, void *ignore)
 {
 	time_t time;
@@ -225,3 +226,4 @@ int gettimeofday(struct timeval *tp, void *ignore)
 
 	return 0;
 }
+#endif

+ 20 - 16
components/libc/newlib/syscalls.c

@@ -193,6 +193,7 @@ _wait_r(struct _reent *ptr, int *status)
 	return -1;
 }
 
+#ifdef RT_USING_DEVICE
 _ssize_t
 _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
 {
@@ -214,6 +215,7 @@ _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
 	return rc;
 #endif
 }
+#endif
 
 #ifndef RT_USING_PTHREADS
 
@@ -235,26 +237,28 @@ _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
 
 
 struct timeval _timevalue = {0};
-static void libc_system_time_init()
+#ifdef RT_USING_DEVICE
+static void libc_system_time_init(void)
 {
-    time_t time;
-    rt_tick_t tick;
-    rt_device_t device;
-
-    time = 0;
-    device = rt_device_find("rtc");
-    if (device != RT_NULL)
-    {
+	time_t time;
+	rt_tick_t tick;
+	rt_device_t device;
+
+	time = 0;
+	device = rt_device_find("rtc");
+	if (device != RT_NULL)
+	{
 		/* get realtime seconds */
-        rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
-    }
+		rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
+	}
 
 	/* get tick */
-    tick = rt_tick_get();
+	tick = rt_tick_get();
 
-    _timevalue.tv_usec = MICROSECOND_PER_SECOND - (tick%RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK;
-    _timevalue.tv_sec = time - tick/RT_TICK_PER_SECOND - 1;
+	_timevalue.tv_usec = MICROSECOND_PER_SECOND - (tick%RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK;
+	_timevalue.tv_sec = time - tick/RT_TICK_PER_SECOND - 1;
 }
+#endif
 
 int libc_get_time(struct timespec *time)
 {
@@ -376,7 +380,7 @@ void
 _exit (int status)
 {
 	rt_kprintf("thread:%s exit with %d\n", rt_thread_self()->name, status);
-    RT_ASSERT(0);
+	RT_ASSERT(0);
 
-    while (1);
+	while (1);
 }