ARM Beagleboard: Difference between revisions

m
Bot: Replace deprecated source tag with syntaxhighlight
[unchecked revision][unchecked revision]
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
(7 intermediate revisions by 3 users not shown)
Line 8:
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/Unixnix ('''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 ===
Line 30:
 
If you get 'Permission Denied' '''do NOT become root!''' This is unnecessary. Instead do:
<sourcesyntaxhighlight lang="asm">
sudo adduser <user> dialout
</syntaxhighlight>
</source>
This will let your user use serial ports without needing root.
 
Line 39:
===Testing the BeagleBoard===
 
Follow the guide here http://elinux.org/BeagleBoardDebian#Debian_armhf_port to install the Debian armhf image to a Micro SDmicroSD 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 BeagleBoard up via serial, and make sure Minicom is running (on your PC). Put the Micro SDmicroSD card in the BeagleBoard. Connect the BeagleBoard to its power supply. You should see some output on the serial port. If not, Google around to figure out why not. If a few bytes of garbage appear in Minicom only, make sure the Micro SDmicroSD card is inserted and VALID. Also make sure you didn't press the 'user button'.
 
You should get some meaningful output. Unplug your BeagleBoard when you are done with it.
Line 50:
 
Append:
<sourcesyntaxhighlight lang="asm">
deb http://www.emdebian.org/debian/ squeeze main
</syntaxhighlight>
</source>
to your /etc/apt/sources.list, changing 'squeeze' for your version of Debian - I'm running wheezy, for example.
 
now run:
<sourcesyntaxhighlight lang="asm">
sudo aptitude update
sudo aptitude install gcc-4.4-arm-linux-gnueabi # check this! it might be an older version for non-wheezy...
</syntaxhighlight>
</source>
 
That will install a C compiler, and also install Binutils, which for this tutorial is really all we need, but you may later wish to write your code in C.
Line 75:
Take note of what it does. It's pretty simple. Refer to docs if necessary.
 
<sourcesyntaxhighlight lang="asm">
/* rammap */
MEMORY
Line 86:
.text : { *(.text*) } > ram
}
</syntaxhighlight>
</source>
 
===Makefile===
Line 92:
This is the basic makefile I use. It's similar to the one on the stackoverflow link.
 
<sourcesyntaxhighlight lang="asm">
ARMGNU = arm-linux-gnueabi
 
Line 104:
$(ARMGNU)-objcopy boot.elf -O srec boot.srec
$(ARMGNU)-objcopy boot.elf -O binary boot.bin
</syntaxhighlight>
</source>
 
===Assembly!===
Line 114:
====boot.asm====
 
<tt><sourcesyntaxhighlight lang="asm">
#UART base locations from the TRM
.equ UART1.BASE, 0x4806A000
Line 141:
# (branch (jump, JMP) to _hang)
# b _hang
</sourcesyntaxhighlight></tt>
 
==='Compiling' it===
Line 149:
==Executing code on the device==
 
Remember that minicomMinicom window we almost forgot about? It's time to use it ;).
 
===Introduction to u-boot===
 
Reset your BeagleboardBeagleBoard (hit the reset button).
 
You should see:
 
<sourcesyntaxhighlight lang="asm">
U-Boot 2011.03-rc1-00000-g9a3cc57-dirty (Apr 04 2011 - 12:36:16)
Line 175:
Die ID #2e7000029ff80000016842c813020023
Hit any key to stop autoboot: 3
</syntaxhighlight>
</source>
 
Hit a key. Before Linux loads.
 
<sourcesyntaxhighlight lang="asm">
OMAP3 beagleboard.org #
</syntaxhighlight>
</source>
 
Whee, a u-boot prompt.
Line 187:
===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 minicomMinicom - that's why we needed Minicom and not GNU Screen. Hopefully you did what I asked ;).
 
Just type 'loady'. Don't worry about being fast on your first go, you'll miss it anyway.
 
<sourcesyntaxhighlight lang="asm">
OMAP3 beagleboard.org # loady
## Ready for binary (ymodem) download to 0x80200000 at 115200 bps...
</syntaxhighlight>
</source>
 
Now hit Ctrl+A. A bar will appear at the bottom.
Line 210:
Ctrl+C out of the ymodem transfer window if nothing happens.
 
Reset your BeagleboardBeagleBoard and try again - now that the file is already selected, you can just hit enter twice in the file prompt window, preventing timeouts.
 
Be patient, ymodem can take a few seconds to 'sync'.
 
After the file is loaded into RAM,
<sourcesyntaxhighlight lang="asm">
READY: Press any key.
</syntaxhighlight>
</source>
and
<sourcesyntaxhighlight lang="asm">
Cm - CRC mode, 9(SOH)/0(STX)/0(CAN) packets, 3 retries
## Total Size = 0x00000350 = 848 Bytes
OMAP3 beagleboard.org #
</syntaxhighlight>
</source>
is printed (my file is bigger... don't worry about that), we just have to execute the code in memory!
 
Line 229:
 
Execution is started from an address with 'go'. Our _start address is 0x80200000. So, we type:
<sourcesyntaxhighlight lang="asm">
OMAP3 beagleboard.org # go 0x80200000
</syntaxhighlight>
</source>
 
and we should get:
 
<sourcesyntaxhighlight lang="asm">
## Starting application at 0x80200000 ...
!
</syntaxhighlight>
</source>
 
If you get that, congratulations! You've just written an 'Operating' System (;)) for the BeagleboardBeagleBoard! The process will seem long winded at first, but it's not really at all.
 
==What to do now==