2

I am working on migrating a project from Kail to Gcc.

Makefile http://www.copypastecode.com/73860/ .ld file http://www.copypastecode.com/73856/

I have a Makefile and a platform.ld script and some .c and .h files. When i make, everything compiles and links and it looks good.

arm-none-eabi-size -B Output/stm32_gps_test.elf

text    data   bss      dec     hex filename
  0       0    2048    2048     800 Output/stm32_gps_test.elf

but when i check the generated files i see this:

ls Output/

7327274 2011-07-02 04:28 stm32_gps_test.elf
0 2011-07-02 04:28 stm32_gps_test.bin
34 2011-07-02 04:28 stm32_gps_test.hex

and:

tail Output/stm32_gps_test.hex

:0400000508000000EF
:00000001FF

Some info on the elf file:

arm-none-eabi-readelf -h Output/stm32_gps_test.elf

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x8000000
  Start of program headers:          52 (bytes into file)
  Start of section headers:          7323752 (bytes into file)
  Flags:                             0x5000002, has entry point, Version5 EABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         1
  Size of section headers:           40 (bytes)
  Number of section headers:         18
  Section header string table index: 15

What is wrong? i have tried to run objcopy to create a binfile and hexfile but the result is always the same.

glts
  • 21,808
  • 12
  • 73
  • 94
Maidenone
  • 723
  • 10
  • 22
  • Did you get an error during linking? You set the flash size to 20kB in the ld script, that will be too small in many cases. – Turbo J Jul 02 '11 at 14:52
  • it was set to larger before, tried to reduce it to see if it had any effect, got 512k of rom and 64k ram. the compiler and linker gives no errors at all.. – Maidenone Jul 02 '11 at 20:49
  • 1
    Try to set `REMOVE_UNUSED` to `0` in your `Makefile`. It looks like ld optimizes away **all** your code. – Turbo J Jul 02 '11 at 22:59
  • Doh, *facepalm* got alot (dump.txt = 88Mb). Disassembly of section .stack: 20000000 <__bss_end>: ... 20000400 <__main_stack_end>: ... – Maidenone Jul 02 '11 at 23:47
  • when i had sat the REMOVE_UNUSED to 1 i got some linking errors, after i had solved them i got a correct file. it compiles and gives correct output! but does not work on my device, but that was not the problem here! care to write an awnser so i can flag it as solved? – Maidenone Jul 03 '11 at 00:10

2 Answers2

0

Does the option --set-section-flags .bss=alloc,load,contents works? With this option, the .bss section will be included in stm32_gps_test.bin.

0

When you disassemble it what do you see? (objdump -D) If you have for example a rom image at 0x80000000 and ram at 0x20000000 the .bin file from objcopy will be at a minimum 0x60000000 bytes plus the size of the image in rom. The intel hex file or srec should work though.

old_timer
  • 69,149
  • 8
  • 89
  • 168
  • objdump -D stm32_gps_test.elf `stm32_gps_test.elf: file format elf32-little objdump: can't disassemble for architecture UNKNOWN!` – Maidenone Jul 02 '11 at 21:05
  • 1
    Please use `arm-none-eabi-objdump` that can read ARM binaries. – Turbo J Jul 02 '11 at 22:52
  • Doh, *facepalm* got alot (dump.txt = 88Mb). Disassembly of section .stack: 20000000 <__bss_end>: ... 20000400 <__main_stack_end>: ... – Maidenone Jul 03 '11 at 00:06