0
votes

I am just recently trying to get into embedded programming and am looking for a few resources. I've done quite a bit of programming in higher level languages but have always been fascinated by how hardware actually works. As a forcing function to get myself to finally learn about hardware I recently purchased a BeagleBoard XM with the goal of programming it bare metal with assembly.

I've spent a week or so reading through the TRM in my spare time as well as searching the web for sample code. I've found a few resources which provide good examples for displaying data through the serial port but nothing much beyond that. I had hoped to find a few examples of people making use of interrupts and sdma but have yet to find any. My goal as a starter project is to write a very simple program which would take a character input from the serial port and echo it back to the screen. I would like to make it such that it made use of interrupts/sdma. Reading through the TRM it isn't apparent how to make this happen. Being completely new to this subject it is incredibly difficult to know exactly what I even need to look for in order to make sense of the documentation. I wondered if there are any experts out there who might be able to provide any sample asm code which makes use of a few of the hardware features of the BeagleBoard. After all, no amount of documentation can ever substitute a good concrete example of code.

3
Frankly I don't think the Beagle is the ideal vehicle to learn the bare metal way of doing things embedded, I'd suggest you get a low cost board based on eg the LPC17xx - check out the mBed or the LPCXpresso.fvu
Yes, I started out with a book and a few pic microcontrollers. The beagleboard is fun, but it isn't the best place to start learning embedded assembly.a sandwhich
I've read you can run linux on the beagleboard. It probably uses asm for booting. Also if you have c code you can compile it and look at the disassembly.user707582

3 Answers

1
votes

BeagleBoard uses a Cortex-A8. That's quite a complex chip and it's not trivial to get it running just from reading the manuals, especially for a beginner. You could try reading the existing code which runs on it already - U-Boot, and maybe the drivers from the Linux kernel. Don't expect to see much assembly besides the very low level startup code.

But probably a better idea is what fvu suggested - get a simple MCU board such as LPCXpressor or mbed and playh with it. Cortex-M3/M0, while not trivial, is much simpler to get running, and plenty of simple, small samples are available for the various peripherals.

1
votes

I have to agree with what everyone else is saying. While, in theory, everything you need is there, the beagle is not the best platform for doing things like this first time. I have a number of examples of how to bring up a number of small microcontrollers http://github.com/dwelch67 and there are sites like http://gandalf.arubi.uni-kl.de/avr_projects/arm_projects/ and others with even more examples.

I have a beagleboard, baremetal uart out code, but sounds like you have that (in yagbat, for lack of a better place (wasnt worth its own repo) I have a beagleboard directory).

The msp430 launchpad is under $5 and not a bad processor. Made by texas instruments (same folks that make the omap) so the manuals should have a similar feel.

There is of course the arduinos, but you want to go around the sandbox, which is not hard, see my examples.

To stay in the arm family there is the mbed (around $50+), (avoid the sandbox, easy to do) and a good one that you might like because it is barely a microcontroller with all the stuff it has in it is the stm32f4 discovery board from st, I have links in my example page. It is about $20, goes up to 168MHz, has a reduced floating point unit (rare for a microcontroller) separate instruction and data caches, lots of ram/rom compared to other microcontrollers, etc. All at that giveaway price of $20.

A lot of these microcontrolers are going to be thumb or thumb+thumb2. The cortex-m3 and 4 are armv7-m so support thumb plus the full thumb2. the cortex-m0 and -m1 are armv6 based so only support a little thumb2, not enough to bother. I have a thumb emulator that you can play with thumb with (no thumb2 support), as well. I think the cortex-A in the beagleboard, is armv7 based so it supports the same thumb+thumb2 that the cortex-m3 and -m4 support. The stm32f4 is -m4 based the mbed comes in two flavors one is -m3 and the new one -m0 based. A lot of the cortex-m based microcontrollers are -m3 based as it came out first the -m4 and -m0 are just gaining some traction. You can with thumb or thumb2 start to use a unified instruction set which is a blurring between arm and thumb(2) allowing one source to assemble to both arm instructions and thumb instructions (with some limitations of course). So you can either just write in thumb/thumb2 and take that knowledge directly to the cortex-A (with one bx instructions to switch modes from ARM to thumb) or take your thumb2 code or unified code directly to the cortex-A and assemble as arm.

The biggest thing here is not really the learning of assembly though the key is reading the manuals, the more manuals from more vendors, the better you understand how to find the info you need for this more complicated target. With my experience I had a hard time with portions of the omap manual as well. Most manuals have errors, or are incomplete, etc you have to learn to work/hack through that, and that just takes experience. With the omap you will likely need to dig through linux or uboot sources for that platform to supplement the manual. Since the beagle uses a bootloader, its good because some stuff is done for you, bad because you need to reverse engineer both the hardware and software to figure out where to place your interrupt vector table so that you can perform interrupt based solutions. I highly recommend starting with non-interrupt, polled, based then slowly transition the knowledge to interrupt. Trying to hit a home run every time at bat will fail. Take it one base hit at a time.

0
votes

Your problem is two-fold: understand baremetal and OS programming and understand the beagleboard hardware. For the latter, I recommend looking at other peoples code alongside the datasheets. Reading the datasheats only is very time consuming. Start with u-boot code for the beagleboard:

Some other baremetal projects that are not BB-XM but I have found useful:

Your second problem is to understand low-level programming on ARM. I recommend these books, note however that these are written for older architectures. Nevertheless, they should still be very useful to you:

The latter even has a chapter on writing your own small OS.