The .bin built by arm-none-eabi-gcc cannot execute on stm32f2xx

Asked by yu

I built a stm32f2xx project with BSP and uCOS by arm-none-eabi-gcc on both windows and ubuntu. But both binaries cannot be executed on the board. I don't know what's wrong with it. The project can be built by Keil, and the binary can be executed on the board. Could anyone help me? Thank you very much!

I have no error in compiling and linking on Ubuntu. But the binary cannot be executed. Here is the makefile.
-------------------------------------------------------------------------------
DEFS += -DUSE_STDPERIPH_DRIVER

INCS += -I./BSP/STM32F2xx/inc -I./BSP/CMSIS/Device_Support -I./BSP/CMSIS -I./uCOS-II/Ports -I./User -I./uCOS-II/Source -I./uC-CPU/ARM-Cortex-M3/RealView -I./uC-LIB/Ports/ARM-Cortex-M3/RealView -I./uC-CPU -I./BSP -I./uC-LIB -I./FAT_FS/inc -I./ComponentLib -I./IDEOutput

# 使用其他外设在这里添加
OBJS += startup_stm32f2xx.o
OBJS += BSP/CMSIS/system_stm32f2xx.o
OBJS += User/main.o
OBJS += User/app_hooks.o
OBJS += BSP/BSP_ELF.o
OBJS += BSP/BSP_ELF_GPIO.o
OBJS += BSP/BSP_ELF_CAN.o
OBJS += BSP/BSP_ELF_Disp.o
OBJS += BSP/BSP_ELF_RTC.o
OBJS += BSP/BSP_ELF_WatchDog.o
OBJS += BSP/BSP_ELF_FSMC_NAND.o
OBJS += BSP/BSP_ELF_SPI.o
OBJS += BSP/BSP_ELF_SuperIO.o
OBJS += BSP/BSP_ELF_UART.o
OBJS += BSP/BSP_ELF_MAC.o
OBJS += BSP/BSP_ELF_SocFLASH.o
OBJS += uC-CPU/cpu_core.o
OBJS += uC-CPU/ARM-Cortex-M3/GNU/cpu_a.o
OBJS += uC-CPU/ARM-Cortex-M3/GNU/cpu_c.o
OBJS += uC-LIB/lib_ascii.o
OBJS += uC-LIB/lib_math.o
OBJS += uC-LIB/lib_mem.o
OBJS += uC-LIB/lib_str.o
OBJS += uC-LIB/Ports/ARM-Cortex-M3/GCC/lib_mem_a.o
OBJS += uCOS-II/Source/os_core.o
OBJS += uCOS-II/Source/os_flag.o
OBJS += uCOS-II/Source/os_mbox.o
OBJS += uCOS-II/Source/os_mem.o
OBJS += uCOS-II/Source/os_mutex.o
OBJS += uCOS-II/Source/os_q.o
OBJS += uCOS-II/Source/os_sem.o
OBJS += uCOS-II/Source/os_task.o
OBJS += uCOS-II/Source/os_time.o
OBJS += uCOS-II/Source/os_tmr.o
OBJS += uCOS-II/Ports/ARM-Cortex-M3/Generic/GNU/os_cpu_a.o
OBJS += uCOS-II/Ports/ARM-Cortex-M3/Generic/GNU/os_cpu_c.o
OBJS += uCOS-II/Ports/ARM-Cortex-M3/Generic/GNU/os_dbg.o
OBJS += BSP/STM32F2xx/src/misc.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_adc.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_can.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_crc.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_cryp.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_cryp_aes.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_cryp_des.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_cryp_tdes.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_dac.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_dbgmcu.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_dcmi.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_dma.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_exti.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_flash.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_fsmc.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_gpio.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_hash.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_hash_md5.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_hash_sha1.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_i2c.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_iwdg.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_pwr.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_rcc.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_rng.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_rtc.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_sdio.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_spi.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_syscfg.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_tim.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_usart.o
OBJS += BSP/STM32F2xx/src/stm32f2xx_wwdg.o
OBJS += ComponentLib/ELF_ADConvertor.o
OBJS += ComponentLib/ELF_AnalogOutput.o
OBJS += ComponentLib/ELF_DigitalInput.o
OBJS += ComponentLib/ELF_Comm7E7E.o

# 使用了编译优化和硬件浮点数
CFLAGS += -Wall -mthumb -g -O0 -ffunction-sections -fdata-sections -g3 -mcpu=cortex-m3

LFLAGS += -mthumb -Wl,--gc-sections -mcpu=cortex-m3

# 最后生成的bin文件
all:blink.bin

clean:
 @rm -f $(OBJS) $(OBJ_FLASH) $(OBJ_SRAM)
 @rm -f blink.bin blink.elf

blink.bin:blink.elf
 @arm-none-eabi-objcopy -O binary -S $< $@

blink.elf:$(OBJS) $(OBJ_FLASH)
 @arm-none-eabi-gcc $(LFLAGS) $^ -TSTM32_Flash.ld -o $@
 @arm-none-eabi-size $@

#burn:blink.bin
# @st-flash write $< 0x08000000

%.o:%.S
 @echo cc: $<
 @arm-none-eabi-gcc $(CFLAGS) -c $< -o $@
%.o:%.c
 @echo cc: $<
 @arm-none-eabi-gcc $(CFLAGS) $(DEFS) $(INCS) -c $< -o $@
-------------------------------------------------------------------------------
I met an error in linking on windows, undefined reference to _sbrk. So I add --specs=nosys.specs option in the linking step and add symbol "end" in the .ld file, the linking succeed. However, the binary cannot be executed. Here is the .bat file.
-------------------------------------------------------------------------------
@echo off
SET CPU_TYPE=STM32F207IG
SET CPU_VENDOR=STMicroelectronics
SET UV2_TARGET=STM32F2XPro
SET CPU_CLOCK=0x00F42400
SET INCLUDE_DIR=-I.\BSP\STM32F2xx\inc -I.\BSP\CMSIS\Device_Support -I.\BSP\CMSIS -I.\uCOS-II\Ports -I.\User -I.\uCOS-II\Source -I.\uC-CPU\ARM-Cortex-M3\RealView -I.\uC-LIB\Ports\ARM-Cortex-M3\RealView -I.\uC-CPU -I.\BSP -I.\uC-LIB -I.\FAT_FS\inc -I.\ComponentLib -I.\IDEOutput
SET OUTPUT=batoutput
SET G++=arm-none-eabi-g++
SET CC=arm-none-eabi-gcc
SET OBJCPY=arm-none-eabi-objcopy
SET DEF=-DUSE_STDPERIPH_DRIVER
SET CFLAGS=-Wall -mthumb -g -O0 -ffunction-sections -fdata-sections -g3 -mcpu=cortex-m3
SET LFLAGS=-mthumb -Wl,--gc-sections -mcpu=cortex-m3

%CC% %CFLAGS% -c startup_stm32f2xx.S -o %OUTPUT%\startup_stm32f2xx.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\CMSIS\system_stm32f2xx.c -o %OUTPUT%\system_stm32f2xx.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c User\main.c -o %OUTPUT%\main.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c User\app_hooks.c -o %OUTPUT%\app_hooks.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\BSP_ELF.c -o %OUTPUT%\BSP_ELF.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\BSP_ELF_GPIO.c -o %OUTPUT%\BSP_ELF_GPIO.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\BSP_ELF_CAN.c -o %OUTPUT%\BSP_ELF_CAN.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\BSP_ELF_Disp.c -o %OUTPUT%\BSP_ELF_Disp.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\BSP_ELF_RTC.c -o %OUTPUT%\BSP_ELF_RTC.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\BSP_ELF_WatchDog.c -o %OUTPUT%\BSP_ELF_WatchDog.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\BSP_ELF_FSMC_NAND.c -o %OUTPUT%\BSP_ELF_FSMC_NAND.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\BSP_ELF_SPI.c -o %OUTPUT%\BSP_ELF_SPI.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\BSP_ELF_SuperIO.c -o %OUTPUT%\BSP_ELF_SuperIO.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\BSP_ELF_UART.c -o %OUTPUT%\BSP_ELF_UART.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\BSP_ELF_MAC.c -o %OUTPUT%\BSP_ELF_MAC.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\BSP_ELF_SocFLASH.c -o %OUTPUT%\BSP_ELF_SocFLASH.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uC-CPU\cpu_core.c -o %OUTPUT%\cpu_core.o
%CC% %CFLAGS% -c uC-CPU\ARM-Cortex-M3\GNU\cpu_a.S -o %OUTPUT%\cpu_a.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uC-CPU\ARM-Cortex-M3\GNU\cpu_c.c -o %OUTPUT%\cpu_c.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uC-LIB\lib_ascii.c -o %OUTPUT%\lib_ascii.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uC-LIB\lib_math.c -o %OUTPUT%\lib_math.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uC-LIB\lib_mem.c -o %OUTPUT%\lib_mem.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uC-LIB\lib_str.c -o %OUTPUT%\lib_str.o
%CC% %CFLAGS% -c uC-LIB\Ports\ARM-Cortex-M3\GCC\lib_mem_a.S -o %OUTPUT%\lib_mem_a.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uCOS-II\Source\os_core.c -o %OUTPUT%\os_core.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uCOS-II\Source\os_flag.c -o %OUTPUT%\os_flag.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uCOS-II\Source\os_mbox.c -o %OUTPUT%\os_mbox.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uCOS-II\Source\os_mem.c -o %OUTPUT%\os_mem.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uCOS-II\Source\os_mutex.c -o %OUTPUT%\os_mutex.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uCOS-II\Source\os_q.c -o %OUTPUT%\os_q.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uCOS-II\Source\os_sem.c -o %OUTPUT%\os_sem.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uCOS-II\Source\os_task.c -o %OUTPUT%\os_task.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uCOS-II\Source\os_time.c -o %OUTPUT%\os_time.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uCOS-II\Source\os_tmr.c -o %OUTPUT%\os_tmr.o
%CC% %CFLAGS% -c uCOS-II\Ports\ARM-Cortex-M3\Generic\GNU\os_cpu_a.S -o %OUTPUT%\os_cpu_a.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uCOS-II\Ports\ARM-Cortex-M3\Generic\GNU\os_cpu_c.c -o %OUTPUT%\os_cpu_c.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c uCOS-II\Ports\ARM-Cortex-M3\Generic\GNU\os_dbg.c -o %OUTPUT%\os_dbg.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\misc.c -o %OUTPUT%\misc.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_adc.c -o %OUTPUT%\stm32f2xx_adc.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_can.c -o %OUTPUT%\stm32f2xx_can.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_crc.c -o %OUTPUT%\stm32f2xx_crc.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_cryp.c -o %OUTPUT%\stm32f2xx_cryp.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_cryp_aes.c -o %OUTPUT%\stm32f2xx_cryp_aes.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_cryp_des.c -o %OUTPUT%\stm32f2xx_cryp_des.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_cryp_tdes.c -o %OUTPUT%\stm32f2xx_cryp_tdes.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_dac.c -o %OUTPUT%\stm32f2xx_dac.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_dbgmcu.c -o %OUTPUT%\stm32f2xx_dbgmcu.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_dcmi.c -o %OUTPUT%\stm32f2xx_dcmi.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_dma.c -o %OUTPUT%\stm32f2xx_dma.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_exti.c -o %OUTPUT%\stm32f2xx_exti.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_flash.c -o %OUTPUT%\stm32f2xx_flash.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_fsmc.c -o %OUTPUT%\stm32f2xx_fsmc.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_gpio.c -o %OUTPUT%\stm32f2xx_gpio.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_hash.c -o %OUTPUT%\stm32f2xx_hash.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_hash_md5.c -o %OUTPUT%\stm32f2xx_hash_md5.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_hash_sha1.c -o %OUTPUT%\stm32f2xx_hash_sha1.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_i2c.c -o %OUTPUT%\stm32f2xx_i2c.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_iwdg.c -o %OUTPUT%\stm32f2xx_iwdg.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_pwr.c -o %OUTPUT%\stm32f2xx_pwr.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_rcc.c -o %OUTPUT%\stm32f2xx_rcc.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_rng.c -o %OUTPUT%\stm32f2xx_rng.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_rtc.c -o %OUTPUT%\stm32f2xx_rtc.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_sdio.c -o %OUTPUT%\stm32f2xx_sdio.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_spi.c -o %OUTPUT%\stm32f2xx_spi.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_syscfg.c -o %OUTPUT%\stm32f2xx_syscfg.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_tim.c -o %OUTPUT%\stm32f2xx_tim.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_usart.c -o %OUTPUT%\stm32f2xx_usart.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c BSP\STM32F2xx\src\stm32f2xx_wwdg.c -o %OUTPUT%\stm32f2xx_wwdg.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c ComponentLib\ELF_ADConvertor.c -o %OUTPUT%\ELF_ADConvertor.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c ComponentLib\ELF_AnalogOutput.c -o %OUTPUT%\ELF_AnalogOutput.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c ComponentLib\ELF_DigitalInput.c -o %OUTPUT%\ELF_DigitalInput.o
%CC% %DEF% %CFLAGS% %INCLUDE_DIR% -c ComponentLib\ELF_Comm7E7E.c -o %OUTPUT%\ELF_Comm7E7E.o

%CC% -o %OUTPUT%\stm32f2xxpro.elf %OUTPUT%\startup_stm32f2xx.o %OUTPUT%\system_stm32f2xx.o %OUTPUT%\main.o %OUTPUT%\app_hooks.o %OUTPUT%\BSP_ELF.o %OUTPUT%\BSP_ELF_GPIO.o %OUTPUT%\BSP_ELF_CAN.o %OUTPUT%\BSP_ELF_Disp.o %OUTPUT%\BSP_ELF_RTC.o %OUTPUT%\BSP_ELF_WatchDog.o %OUTPUT%\BSP_ELF_FSMC_NAND.o %OUTPUT%\BSP_ELF_SPI.o %OUTPUT%\BSP_ELF_SuperIO.o %OUTPUT%\BSP_ELF_UART.o %OUTPUT%\BSP_ELF_MAC.o %OUTPUT%\BSP_ELF_SocFLASH.o %OUTPUT%\cpu_core.o %OUTPUT%\cpu_a.o %OUTPUT%\cpu_c.o %OUTPUT%\lib_ascii.o %OUTPUT%\lib_math.o %OUTPUT%\lib_mem.o %OUTPUT%\lib_str.o %OUTPUT%\lib_mem_a.o %OUTPUT%\os_core.o %OUTPUT%\os_flag.o %OUTPUT%\os_mbox.o %OUTPUT%\os_mem.o %OUTPUT%\os_mutex.o %OUTPUT%\os_q.o %OUTPUT%\os_sem.o %OUTPUT%\os_task.o %OUTPUT%\os_time.o %OUTPUT%\os_tmr.o %OUTPUT%\os_cpu_a.o %OUTPUT%\os_cpu_c.o %OUTPUT%\os_dbg.o %OUTPUT%\misc.o %OUTPUT%\stm32f2xx_adc.o %OUTPUT%\stm32f2xx_can.o %OUTPUT%\stm32f2xx_crc.o %OUTPUT%\stm32f2xx_cryp.o %OUTPUT%\stm32f2xx_cryp_aes.o %OUTPUT%\stm32f2xx_cryp_des.o %OUTPUT%\stm32f2xx_cryp_tdes.o %OUTPUT%\stm32f2xx_dac.o %OUTPUT%\stm32f2xx_dbgmcu.o %OUTPUT%\stm32f2xx_dcmi.o %OUTPUT%\stm32f2xx_dma.o %OUTPUT%\stm32f2xx_exti.o %OUTPUT%\stm32f2xx_flash.o %OUTPUT%\stm32f2xx_fsmc.o %OUTPUT%\stm32f2xx_gpio.o %OUTPUT%\stm32f2xx_hash.o %OUTPUT%\stm32f2xx_hash_md5.o %OUTPUT%\stm32f2xx_hash_sha1.o %OUTPUT%\stm32f2xx_i2c.o %OUTPUT%\stm32f2xx_iwdg.o %OUTPUT%\stm32f2xx_pwr.o %OUTPUT%\stm32f2xx_rcc.o %OUTPUT%\stm32f2xx_rng.o %OUTPUT%\stm32f2xx_rtc.o %OUTPUT%\stm32f2xx_sdio.o %OUTPUT%\stm32f2xx_spi.o %OUTPUT%\stm32f2xx_syscfg.o %OUTPUT%\stm32f2xx_tim.o %OUTPUT%\stm32f2xx_usart.o %OUTPUT%\stm32f2xx_wwdg.o %OUTPUT%\ELF_ADConvertor.o %OUTPUT%\ELF_AnalogOutput.o %OUTPUT%\ELF_DigitalInput.o %OUTPUT%\ELF_Comm7E7E.o --specs=nosys.specs %LFLAGS% -TSTM32_Flash.ld

%OBJCPY% -O binary %OUTPUT%\stm32f2xxpro.elf %OUTPUT%\stm32f2xxpro.bin
-------------------------------------------------------------------------------
Here is the .ld file. I should copy the .bin to 0x08040000 address to startup. This address is tested by the .bin file created by Keil.
-------------------------------------------------------------------------------
/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */

/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x1000; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */

/* Specify the memory areas */
MEMORY
{
  FLASH (rx) : ORIGIN = 0x08040000, LENGTH = 100K
  /* PARAM_SECTOR (rx) : ORIGIN = 0x08008000, LENGTH = 16K */
  RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 40K
  /* MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K */
}

/* Define output sections */
SECTIONS
{
  /* The startup code goes first into FLASH */
  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >FLASH

  /* The program code and other data goes into FLASH */
  .text :
  {
    . = ALIGN(4);
    *(.text) /* .text sections (code) */
    *(.text*) /* .text* sections (code) */
    *(.rodata) /* .rodata sections (constants, strings, etc.) */
    *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
    *(.glue_7) /* glue arm to thumb code */
    *(.glue_7t) /* glue thumb to arm code */

    KEEP (*(.init))
    KEEP (*(.fini))

    . = ALIGN(4);
    _etext = .; /* define a global symbols at end of code */
  } >FLASH

   .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
    .ARM : {
    __exidx_start = .;
      *(.ARM.exidx*)
      __exidx_end = .;
    } >FLASH

  .ARM.attributes : { *(.ARM.attributes) } > FLASH

  .preinit_array :
  {
    PROVIDE_HIDDEN (__preinit_array_start = .);
    KEEP (*(.preinit_array*))
    PROVIDE_HIDDEN (__preinit_array_end = .);
  } >FLASH
  .init_array :
  {
    PROVIDE_HIDDEN (__init_array_start = .);
    KEEP (*(SORT(.init_array.*)))
    KEEP (*(.init_array*))
    PROVIDE_HIDDEN (__init_array_end = .);
  } >FLASH
  .fini_array :
  {
    PROVIDE_HIDDEN (__fini_array_start = .);
    KEEP (*(.fini_array*))
    KEEP (*(SORT(.fini_array.*)))
    PROVIDE_HIDDEN (__fini_array_end = .);
  } >FLASH

  /* used by the startup to initialize data */
  _sidata = .;

  /* Initialized data sections goes into RAM, load LMA copy after code */
  .data : AT ( _sidata )
  {
    . = ALIGN(4);
    _sdata = .; /* create a global symbol at data start */
    *(.data) /* .data sections */
    *(.data*) /* .data* sections */

    . = ALIGN(4);
    _edata = .; /* define a global symbol at data end */
  } >RAM

  /* Uninitialized data section */
  . = ALIGN(4);
  .bss :
  {
    /* This is used by the startup in order to initialize the .bss secion */
    _sbss = .; /* define a global symbol at bss start */
    __bss_start__ = _sbss;
    *(.bss)
    *(.bss*)
    *(COMMON)

    . = ALIGN(4);
    _ebss = .; /* define a global symbol at bss end */
    __bss_end__ = _ebss;
  } >RAM

/* PROVIDE ( end = _ebss ); */
/* PROVIDE ( _end = _ebss ); */

  /* User_heap_stack section, used to check that there is enough RAM left */
  /* embOS needs some dedicated labels for heap- and stack-check */
  /* The heap has to start with the label __heap_start__ */
  /* The heap has to end with the label __heap_end__ */
  /* The stack has to start with the label __stack_start__ */
  /* The stack has to end with the label __stack_end__ */

  ._user_heap_stack :
  {
    . = ALIGN(8);
    __heap_start__ = .;
    end = __heap_start__;
    . = . + _Min_Heap_Size;
    __heap_end__ = .;
    . = ALIGN(8);
    __stack_start__ = .;
    . = . + _Min_Stack_Size;
    __stack_end__ = .;
    _estack = .;
    . = ALIGN(8);
  } >RAM

  /* Remove information from the standard libraries */
  /DISCARD/ :
  {
    libc.a ( * )
    libm.a ( * )
    libgcc.a ( * )
 /* libg.a ( * ) */
 /* libnosys.a ( * ) */
  }
}
-------------------------------------------------------------------------------

Question information

Language:
English Edit question
Status:
Expired
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
yu (peace567) said :
#2

Hi,
If I comment out the OSTaskCreateExt and add blink code, the LED on the board can blink. So I think the problem is not related to the linker script. I searched 6 files for GNU built, which is different to Keil built. These files are:
os_cpu_a.S
lib_mem_a.S
cpu_a.S
cpu_c.c
os_cpu_c
os_dbg.c

Is there any thing to stop OSTaskCreateExt from executing? Thank you very much!
I also searched hard on google for project similar to mine which can execute under gcc, but I found none.

Here is the main.c which build a executable bin.

int main(void)
{
      OSInit();
      TargetInit();
    BSP_GPIO_Init(); /* Initialize "uC/OS-II, The Real-Time Kernel" */
// OSTaskCreateExt((void (*)(void *))TaskStart, /* Create the start task */
// (void *) 0,
// (OS_STK *)&TaskStartStk[TASK_START_STK_SIZE - 1],
// (INT8U )TASK_START_PRIO ,
// (INT16U )TASK_START_PRIO ,
// (OS_STK *)&TaskStartStk[0],
// (INT32U )TASK_START_STK_SIZE,
// (void *) 0,
// (INT16U )(OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR));

// ENBL_OS_TICK_ISR();
// OSStart(); /* Start multitasking (i.e. give control to uC/OS-II) */

    while(1)
   {
    BSP_IO_Toggle(21);
     TimeDely();
   }
}

Revision history for this message
yu (peace567) said :
#3

Hi,
My problem has been solved. Updated here to help others. Thanks!
The problem located in startup file for gnu gcc. Replace all PendSV_Handler, SysTick_Handler to OS_CPU_PendSVHandler and OS_CPU_SysTickHandler. Compiler cannot find this error.

eg:
  .word PendSV_Handler
  .word SysTick_Handler
should be
  .word OS_CPU_PendSVHandler
  .word OS_CPU_SysTickHandler

As os_cpu.h and os_cpu_a.S all use OS_CPU_PendSVHandler and OS_CPU_SysTickHandler

Meanwhile, the include path -I.\uC-CPU\ARM-Cortex-M3\RealView -I.\uC-LIB\Ports\ARM-Cortex-M3\RealView should be -I.\uC-CPU\ARM-Cortex-M3\GNU -I.\uC-LIB\Ports\ARM-Cortex-M3\GNU