Note that there are some explanatory texts on larger screens.

plurals
  1. POCrosscompiling for ARM9 in Linux
    text
    copied!<p>I am always using this procedure to cross compile programs for ARM926ej-s on my Arch Linux machine: </p> <p><strong>1st</strong> I compile the assembly source files using: </p> <pre><code>arm-none-eabi-as -mcpu=arm926ej-s -c -Wall -ooutput_as.o input_as.s </code></pre> <p><strong>2nd</strong> I compile C source files using:</p> <pre><code>arm-none-eabi-gcc -mcpu=arm926ej-s -c -Wall -mno-thumb-interwork -mapcs-frame -mno-sched-prolog -fno-hosted -O3 -gdwarf-2 -ooutput_c.o input_c.c </code></pre> <p><strong>3rd</strong> I link those to get an executable elf file <code>executable</code>:</p> <pre><code>arm-none-eabi-ld -Tlinker_script.ld -oexecutable output_as.o output_c.o </code></pre> <p><strong>4th</strong> I convert elf into binary using: </p> <pre><code>arm-none-eabi-objcopy -Ielf32-littlearm -Obinary --strip-all --verbose executable executable_bin </code></pre> <p><strong>5th</strong> I prepare the binary for the USB-DFU transfer using application <a href="http://www.lpclinux.com/Downloads/WebHome" rel="nofollow">unsimgcr</a> - this application somehow prepares the format to be uploaded to ARM microprocessors:</p> <pre><code>unsimgcr -pd executable_bin executable_bin_usb </code></pre> <hr> <p>And then i usualy upload the prepared program <code>executable_bin_usb</code> to the ARM926ej-s using application <a href="https://aur.archlinux.org/packages/?O=0&amp;K=dfu-util" rel="nofollow">dfu-util</a> like this: </p> <pre><code>sudo dfu-util -R -t2048 -Dexecutable_bin_usb </code></pre> <hr> <p>For some reason when in step <strong>5</strong> when I use unsimgcr i get this error: </p> <pre><code>[ziga@ziga-cq56 test]$ unsimgcr -pd executable_bin executable_bin_usbLPC3130/31/41/52 Un-Secure Image Creator Utility v1.1 Opening executable_bin Incompatible file size! </code></pre> <p>Does anyone have any clue what i might be doing wrong or what is wrong in my program which is just a basic test program - here are all the source files which I got <a href="http://balau82.wordpress.com/2010/02/14/simplest-bare-metal-program-for-arm/" rel="nofollow">here</a> (this toolchain works for other programs): </p> <p><strong>input_as.s</strong></p> <pre><code>.section INTERRUPT_VECTOR, "x" .global _Reset _Reset: B Reset_Handler B . B . B . B . B . B . B . Reset_Handler: LDR sp, =stack_top BL c_entry B . </code></pre> <p><strong>input_c.c</strong></p> <pre><code>int c_entry() { return 0; } </code></pre> <p><strong>linker_script.ld</strong></p> <pre><code>ENTRY(_Reset) SECTIONS { . = 0x11029000; .text : { startup.o (INTERRUPT_VECTOR) *(.text) } .data : { *(.data) } .bss : { *(.bss) } . = . + 0x1000; stack_top = .; } </code></pre> <p>In linker script we set the entry point at location <code>0x11029000</code> which is needed in ARM, but i have no idea why would the size of my program be incompatible... Does anyone have any clue?</p> <p>If I use the command <code>arm-none-eabi-readelf -a executable</code>to get some info about my elf file <code>executable</code> i get this info. It might come handy:</p> <pre><code>[ziga@ziga-cq56 test]$ arm-none-eabi-readelf -a executable 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: 0x11029000 Start of program headers: 52 (bytes into file) Start of section headers: 4716 (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: 14 Section header string table index: 11 Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .text PROGBITS 11029000 001000 000038 00 AX 0 0 4 [ 2] .ARM.attributes ARM_ATTRIBUTES 00000000 001038 000030 00 0 0 1 [ 3] .comment PROGBITS 00000000 001068 00002a 01 MS 0 0 1 [ 4] .debug_abbrev PROGBITS 00000000 001092 000034 00 0 0 1 [ 5] .debug_info PROGBITS 00000000 0010c6 000044 00 0 0 1 [ 6] .debug_line PROGBITS 00000000 00110a 000035 00 0 0 1 [ 7] .debug_pubnames PROGBITS 00000000 00113f 00001e 00 0 0 1 [ 8] .debug_aranges PROGBITS 00000000 00115d 000020 00 0 0 1 [ 9] .debug_str PROGBITS 00000000 00117d 000034 01 MS 0 0 1 [10] .debug_frame PROGBITS 00000000 0011b4 000020 00 0 0 4 [11] .shstrtab STRTAB 00000000 0011d4 000097 00 0 0 1 [12] .symtab SYMTAB 00000000 00149c 000140 10 13 17 4 [13] .strtab STRTAB 00000000 0015dc 000035 00 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings) I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) There are no section groups in this file. Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000000 0x11028000 0x11028000 0x01038 0x01038 R E 0x8000 Section to Segment mapping: Segment Sections... 00 .text There is no dynamic section in this file. There are no relocations in this file. There are no unwind sections in this file. Symbol table '.symtab' contains 20 entries: Num: Value Size Type Bind Vis Ndx Name 0: 00000000 0 NOTYPE LOCAL DEFAULT UND 1: 11029000 0 SECTION LOCAL DEFAULT 1 2: 00000000 0 SECTION LOCAL DEFAULT 2 3: 00000000 0 SECTION LOCAL DEFAULT 3 4: 00000000 0 SECTION LOCAL DEFAULT 4 5: 00000000 0 SECTION LOCAL DEFAULT 5 6: 00000000 0 SECTION LOCAL DEFAULT 6 7: 00000000 0 SECTION LOCAL DEFAULT 7 8: 00000000 0 SECTION LOCAL DEFAULT 8 9: 00000000 0 SECTION LOCAL DEFAULT 9 10: 00000000 0 SECTION LOCAL DEFAULT 10 11: 11029020 0 NOTYPE LOCAL DEFAULT 1 Reset_Handler 12: 11029000 0 NOTYPE LOCAL DEFAULT 1 $a 13: 1102902c 0 NOTYPE LOCAL DEFAULT 1 $d 14: 00000000 0 FILE LOCAL DEFAULT ABS main.c 15: 11029030 0 NOTYPE LOCAL DEFAULT 1 $a 16: 00000010 0 NOTYPE LOCAL DEFAULT 10 $d 17: 11029538 0 NOTYPE GLOBAL DEFAULT ABS stack_top 18: 11029030 8 FUNC GLOBAL DEFAULT 1 c_entry 19: 11029000 0 NOTYPE GLOBAL DEFAULT 1 _Reset No version information found in this file. Attribute Section: aeabi File Attributes Tag_CPU_name: "ARM926EJ-S" Tag_CPU_arch: v5TEJ Tag_ARM_ISA_use: Yes Tag_THUMB_ISA_use: Thumb-1 Tag_ABI_PCS_wchar_t: 4 Tag_ABI_FP_denormal: Needed Tag_ABI_FP_exceptions: Needed Tag_ABI_FP_number_model: IEEE 754 Tag_ABI_align_needed: 8-byte Tag_ABI_enum_size: small Tag_DIV_use: Not allowed </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload