Javier M. García López teaches how to program Freerunner from OpenMoko.org with assembler language. A Little Introduction, however a great contribution from a technical point of view
If I need/want to do some code for my Freerunner as far it's a mobile phone and not a powerfull PC, I must cross compiling my source code. So I need all the tools to compile and link , so how do i get those?.
The people from OpenEmbedded - base distro for Freerunner - and the people from FSO - freesmartphone - give you those tools. You can just download at Toolchain or you can get a Makefile at downloads.freesmartphone.org and create it youself , this makefile download the OpenMoko distro and creates the tools with the help of a python tool called bitbake OpenEmbedded Guide bitbake.
Once you have the toolchain from openmoko or your own one with the FSO help you can start .The tools have this name arm-angstrom-linux-gnueabi-gcc for the gcc. It's very importan the name because the part that says eabi means that your code will be compiled with the new binary interface that is a change in order to get better performance from the ARM procesors.
The Freerunner ARM processors supports that new interface because it's has the v4l architecture as the cat /proc/cpuinfo command could tell you if you open a ssh session in your Freerunner and run that command.
root@om-gta02:~# cat /proc/cpuinfo
Processor : ARM920T rev 0 (v4l)
BogoMIPS : 198.65
Features : swp half thumb
CPU implementer : 0x41
CPU architecture: 4T
CPU variant : 0x1
CPU part : 0x920
CPU revision : 0
Hardware : GTA02
Revision : 0360
Serial : 0000000000000000
The ARM processor in the Freerunner also support others optimizations as is the Thumb , that is the ability to put more intructions in the same size as use less space for data and instructions but it gives you less performace and even the possibility of mix both ARM and Thumb instructions.
The linux kernel for the ARM architecture supports the EABI by means of the assembler code for system calls , ... as you can see in kernel sources in arch/arm/kernel/entry-common.S
/*
* If we have CONFIG_OABI_COMPAT then we need to look at the swi
* value to determine if it is an EABI or an old ABI call.
*/
tst r8,
movne r10,
ldreq r10, [lr,
ldr r10, [lr,
A710( and ip, r10,
A710( teq ip,
A710( bne .Larm710bug )
/*
* Pure EABI user space always put syscall number into scno (r7).
*/
A710( ldr ip, [lr,
A710( and ip, ip,
A710( teq ip,
A710( bne .Larm710bug )
/* Legacy ABI only, possibly thumb mode. */
tst r8,
addne scno, r7,
ldreq scno, [lr,
/* Legacy ABI only. */
ldr scno, [lr,
A710( and ip, scno,
A710( teq ip,
A710( bne .Larm710bug )
The big difference in system calls between old ABI - OABI - and the new one - EABI - is that in the assembler instruction for system calls - swi - the parameter is ignored in EABI and the number of syscall goes in r7 register, the parameters of the system call must be from r0 to r7 - r7 not included it has the system call number -
As an example of this here is a hello world :
;INI : Hello World ASM ARM example
.text
.align 2
.global _start
_start:
mov r0,#1 @ stdout
adr r1,msg @ Adress
mov r2,#11 @ Long
mov r7,#4
swi 0x00
mov r0,#0
mov r7,#1 @ exit
swi 0x00
.align 2
msg:
.asciz "Hello World\n"
;INI : Hello World ASM ARM example
As a Makefile to compile assembler code you can use this one:
TARGETS := helloWorld
all: $(TARGETS)
$(TARGETS): %: %.S
gcc $^ -o $@ -nostartfiles -static
strip $@
clean:
rm -f $(TARGETS)
BTW: The gcc must point to
arm-angstrom-linux-gnueabi-gcc, of course ,-).
References
[1]
wiki.debian.org/ArmEabiPort
[1]
www.arm.linux.org.uk/developer/patches/viewpatch.php
[1]
openmoko.org
[1]
freesmartphone.org
[1]
www.mikrocontroller.net