ARM Beagleboard: Difference between revisions
[unchecked revision] | [unchecked revision] |
Content deleted Content added
mNo edit summary |
m Bot: Replace deprecated source tag with syntaxhighlight |
||
(23 intermediate revisions by 8 users not shown) | |||
Line 1:
{{In Progress}}
[[Category:ARM]]▼
<
TODO: VERIFY THE TUTORIAL(S)!!!
==Intro==
This is a tutorial on bare-metal [OS] development on the Texas Instruments
Experience in Linux/nix (
▲This is a tutorial on bare-metal [OS] development on the Texas Instruments Beagleboard. This tutorial is written specifically for the Beagleboard-xM Rev C because the author has no other hardware to test on.
▲Experience in Linux/nix (_very_ important) and at least one assembly language (_incredibly_ important, or at least extensive C knowledge) is assumed and required. Please make sure you can figure out how to get a basic x86 OS (no copypaste!) to the booting stage before attempting this guide. No need to make much more than a 'Hello World', since what you know about x86 won't really apply here.
===Materials===▼
▲=== Materials ===
You will need a:
==Getting Started==
===Testing your serial port===
Line 36 ⟶ 27:
First things first, you're going to want to make sure all your hardware works. Set up your serial port, however yours works, and open up minicom. Make sure you have flow control turned off.
Now jumper '''PIN 2 (RX)''' to '''PIN 3 (TX)''' on the DB-9 side. Just type some characters into minicom, and they should be echoed back.
Ensure you can run at 115200 baud, 8N1, which is what you will use to connect to the
If you get 'Permission Denied' '''do NOT become root!''' This is unnecessary. Instead do:
<
sudo adduser <user> dialout
</syntaxhighlight>
This will let your user use serial ports without needing root.
Or do ls -l /dev/ttyS* to find out the group that own the device, then add you into that group under /etc/group (normally the group is uucp)
===Testing the Beagleboard===▼
Follow the guide here http://elinux.org/BeagleBoardDebian#Debian_armhf_port to install the Debian armhf image to a microSD card. We don't really need to boot Debian from it, but it's a nice simple <small>ghetto/lazy</small> way to get u-boot set up and working.
Connect the
You should get some meaningful output. Unplug your
===Getting an assembler===
Line 57 ⟶ 50:
Append:
<
deb http://www.emdebian.org/debian/ squeeze main
</syntaxhighlight>
to your /etc/apt/sources.list, changing 'squeeze' for your version of Debian - I'm running wheezy, for example.
now run:
<
sudo aptitude update
sudo aptitude install
</syntaxhighlight>
That will install a C compiler, and also install
==Writing some CODE!==
Now that we have all the
===Linker Script===
We'll basically take the one from the stackoverflow.com link, No.1 in the ref list, ''with one change''. The linker script there uses 0x80300000 as the start address. This will work just fine, however the default load address of u-boot's 'loady' command loads things into 0x80200000. So there's one less thing we have to specify ^_^.
====linker.ld====
Take note of what it does. It's pretty simple. Refer to docs if necessary.
<
/* rammap */
MEMORY
Line 93 ⟶ 86:
.text : { *(.text*) } > ram
}
</syntaxhighlight>
===Makefile===
This is the basic makefile I use. It's similar to the one on the stackoverflow link
▲<source lang="asm">
ARMGNU = arm-linux-gnueabi
Line 112 ⟶ 104:
$(ARMGNU)-objcopy boot.elf -O srec boot.srec
$(ARMGNU)-objcopy boot.elf -O binary boot.bin
</syntaxhighlight>
==Assembly!==▼
▲===Assembly!===
YAY! We can write some code now!
You are free to branch to C code after following this tutorial, but remember, you will need to write some things in ASM, just like on x86
====boot.asm====
<tt><
#UART base locations from the TRM
.equ UART1.BASE, 0x4806A000
.equ UART2.BASE, 0x4806C000
#According to the Beagleboard-xM System Reference Manual, UART3 is connected to the serial port.
.equ UART3.BASE, 0x49020000
.equ UART4.BASE, 0x49042000
Line 148 ⟶ 136:
# (store the least-significant-byte of r1 into the address pointed by r0)
strb r1,[r0]
# If we kept writing to the serial port, we'd eventually overflow the 64-byte FIFO, and since we don't handle interrupts yet, we'll hang (?)
# In ASM, labels are like case: statements in C. Code flows into them as if they don't exist - because they don't.
_hang:
# (branch (jump, JMP) to _hang)
# b _hang
</
==='Compiling' it===
Since it's ASM we technically don't 'compile' it, we 'assemble' (and 'link' it). But anyway, go to where you saved your files and type 'make'. This should progress without any errors.
==Executing code on the device==
Remember that
===Introduction to u-boot===
Reset your
You should see:
<
U-Boot 2011.03-rc1-00000-g9a3cc57-dirty (Apr 04 2011 - 12:36:16)
Line 186 ⟶ 175:
Die ID #2e7000029ff80000016842c813020023
Hit any key to stop autoboot: 3
</syntaxhighlight>
Hit a key. Before Linux loads.
<
OMAP3 beagleboard.org #
</syntaxhighlight>
Whee, a u-boot prompt.
===Loading code===
Now it's time to load our code into RAM. To do this, we will use 'loady' and the y-modem protocol. We can do all this from
Just type 'loady'. Don't worry about being fast on your first go, you'll miss it anyway.
<
OMAP3 beagleboard.org # loady
## Ready for binary (ymodem) download to 0x80200000 at 115200 bps...
</syntaxhighlight>
Now hit Ctrl+A. A bar will appear at the bottom.
Line 221 ⟶ 210:
Ctrl+C out of the ymodem transfer window if nothing happens.
Reset your
Be patient, ymodem can take a few seconds to 'sync'.
After the file is loaded into RAM,
<
READY: Press any key.
</syntaxhighlight>
and
<
Cm - CRC mode, 9(SOH)/0(STX)/0(CAN) packets, 3 retries
## Total Size = 0x00000350 = 848 Bytes
OMAP3 beagleboard.org #
</syntaxhighlight>
is printed (my file is bigger... don't worry about that), we just have to execute the code in memory!
===Executing Code===
Execution is started from an address with 'go'. Our _start address is 0x80200000. So, we type:
<
OMAP3 beagleboard.org # go 0x80200000
</syntaxhighlight>
and we should get:
<
## Starting application at 0x80200000 ...
!
</syntaxhighlight>
If you get that, congratulations! You've just written an 'Operating' System (;)) for the
==What to do now==
Read the ARM ARM.
Read the TRM.
Find out how to do push/pop and how to return from functions (and how to return using a pop) from example code and the ARM.
Write routines to print integers and strings.
Set up virtual memory.
Enable interrupts
Write some device drivers.
Line 275 ⟶ 262:
etc. Do all the stuff you would in an x86 OS.
==Branching to C==
TODO: Add this
Line 286 ⟶ 273:
But I quite honestly haven't tried ^_^.
==Help==
For help, you can try joining #Beagle (note the capital B!) on irc.freenode.net
== See also ==
*[[ARM Integrator-CP Bare Bones]]
*[[ARM Overview]]
*[[GameBoy Advance Barebones]]
*[[GameBoy Advance Introduction]]
== References ==▼
▲[[Category:ARM]]
▲=References=
▲[1] http://stackoverflow.com/questions/6870712/beagleboard-bare-metal-programming
▲[2] http://sourceware.org/binutils/docs/as/
|