Getting started with bare-metal programming on BBB

Hi,

I plan to do some bare-metal programming with the BBB (mainly for personal reasons and to play with hard realtime environments, so please do not try to soften me up to use Linux :wink:

As a first task and to get a feeling for the hardware I’d try to access the LEDs (configure the GPIOs they are connected with as digital output and write 0/1 to them).

My question: is there a getting-started-guide for this?

Or to go more in detail:

  • I already found the CPU manual at TI’s pages
  • I found a compiler arm-none-eabi-gcc - is it the correct one?
  • I still need header files where register addresses for the CPU are predefined
  • I still need a description how to download my created binaries to the board so that they are started immediately (instead of the Linux-Distro)

Any Ideas where I can find these things?

Thanks!

Unless you *REALLY* want to go totally bare metal and build your tools
and environment from the ground up as a learning exercise, you should
probably grab StarterWare from TI:

http://www.ti.com/tool/starterware-sitara

...and the compiler of your choice (likely TI's Code Composer Studio or
gcc setup for cross-compiling).

It has a build environment, (some) hardware abstraction, and a variety
of example code.

Once you get something running you can go as close to the bare metal as
you want, but getting a complex SoC like the AM3359 up and running
(low-level hardware initialized properly so you can do things like talk
to DRAM and send serial messages out the UART) is a non-trivial task.
I'd start with their examples and tweak the startup code if/when you
have the need.

Try looking at the PRU, this is a real time co-processor in the chip and
so you can have linux do the normal stuff on the normal processor, and do
the real time GPIO stuff in the PRU. It really is bare metal, and there
is (currently) only an assembler for it (I think I read somewhere that
a C compiler was on the way).

There are lots of links to the relevant materials if you use your
favourite search engine.

David

Starterware is what you want works on white google the group for those who ported to black if you like pain

You will need need the gel file ported for black DRAM differences or you could try using uboot to do init and change the linker to run out of internal RAM

Bare metal allows you understand what happens after reset best you will be given the start.s and a GUI based compiler free called CCS

I suggest unless broke buy the white its under $100 and the jtag is usb based via FDTI

keep in mind starterware is supported by E2E TI forum(someone paid by TI has to answer your post up to point) this groups focus is more Linux but there are post in here

You made the first right choice ie start with the basics how much pain is $95 BBW worth to you

http://processors.wiki.ti.com/index.php/StarterWare

Good Luck

Hi,

I plan to do some bare-metal programming with the BBB (mainly for personal
reasons and to play with hard realtime environments, so please do not try
to soften me up to use Linux :wink:

As a first task and to get a feeling for the hardware I’d try to access the
LEDs (configure the GPIOs they are connected with as digital output and
write 0/1 to them).

My question: is there a getting-started-guide for this?

Or to go more in detail:

  • I already found the CPU manual at TI’s pages
  • I found a compiler arm-none-eabi-gcc - is it the correct one?
  • I still need header files where register addresses for the CPU are
    predefined
  • I still need a description how to download my created binaries to the
    board so that they are started immediately (instead of the Linux-Distro)

Any Ideas where I can find these things?

Thanks!
Try looking at the PRU, this is a real time co-processor in the chip and
so you can have linux do the normal stuff on the normal processor, and do
the real time GPIO stuff in the PRU. It really is bare metal, and there
is (currently) only an assembler for it (I think I read somewhere that
a C compiler was on the way).

There are lots of links to the relevant materials if you use your
favourite search engine.

David

I know there is a possibility to access PRU under linux but as stated above I DEFINITELY want to do some bare metal programming on the “naked” board.

I already checked out TI’s StarterWare and I’m open to use uboot prior to my own code…so I’ll check the boards to find out what has to be changed in order to use it on BBB.

Thanks for the information!

hi
check my bare metal hello world application, this i wrote for my understanding only:
https://github.com/0xCA5A/kickstart/tree/master/beaglebone/bare_metal_hello_world

i like the bootp / tftp boot mode (EMAC1) for early development.
the ti romboot code does bootp on EMAC1 and loads the application (< 109k) into the internal ram and executes it.
much more faster than mmc handling…

if you are interested i can provide a short tutorial how to setup the bootp server using linux.

good luck

Nice done Samuel,

I’ve checked your tutorial, very interesting,

I’ve also found really good pointers to understand the underlying of the BBB Cortex with the Quantum Leap paper.
About the Arm Cortex Develloper’s guide be advised that you point to the 2.0 version which is old now, I advise the 3.0 :
"25 June 2012 C Non-Confidential Updated for third release. Updated to include Cortex-A7 processor, and
big.LITTLE. Index added. Corrected and revised throughout." . you can find it here:

https://silver.arm.com/browse/BX100

David .

I am also doing some experimentation of bare metal programming.

I’ve an example of AM335x ROM’s peripheral booting over usb/rndis/bootp+tftp at https://github.com/auselen/down-to-the-bone with some notes on how to setup bootp+tftp.

My intention was to start with most simple code to turn on a user led without any configuration and just relying on ROM code’s placement in the memory - which I think I achieved.
See https://github.com/auselen/down-to-the-bone/blob/master/baremetal_led . I guess in startup.s you can even ignore the part about disabling interrupts - I just wasn’t sure if that would safe.

br,
Utku

This is a really great source for information - thanks for this! And
yes, a bootp HOWTO would be really useful :slight_smile:

into the internal ram and executes it.
much more faster than mmc handling...

When I connect BBB via USB and without MMC installed I get access to a
drive with some files on it including a u-boot.img and a MLO file. Is
it possible to utilitise this drive for own bare-metal applications
too and withtout an external card?

BBB runs from an onboard eMMC, a MMC chip on the board. You can use that as a SD card type function. But, it has limited space available. You can copy files to it and use it like an SD card.

Gerald

hi!
check here how to configure a bootp server to load and run the test hello world binary.
https://github.com/0xCA5A/kickstart/blob/master/beaglebone/bare_metal_hello_world/README.md

note:
if you want to use bootp you have to modify the sysboot configuration to have EMAC1 in your boot device list.
default bbb boot configuration is: 11100b, boot seq: MMC1 MMC0 UART0 USB0 (doublecheck in am335x manual / bbb schema!)
this can be easily modified to this:
10000b : XIP EMAC1 MMC0 UART0 (MUX1)[2]

connect the expansion header pins LCD_DATA2 and LCD_DATA3 to ground using a 1k resistor to change the configuration (doubleckeck!)

i don’t know exactly what this XIP boot mode does. i hope there is no bus fight or something like that…

this solution works for me.

have fun!

I won’t try to talk you into using Linux for this adventure, but I will try to talk you into using a simpler ARM platform. You should try something like a TI Launchpad with a Cortex-M class processor; not only will the TRM for the platform be much more reasonably-sized, but the M architecture is actually much nicer for bare-metal programming, especially if you are using C! It’s also a much better platform for real-time work; sometimes the pipelining and other tricks that the A-series CPUs use to increase throughput comes at a cost of non-deterministic execution times, which are the enemy of real-time programming with hard deadlines.

In either case, from TI you’ll want the platform’s Technical Reference Manual and Datasheet. The TRM generally has in-depth descriptions of the registers and programming models of all the peripherals that users are expected to use, while the Datasheet will generally have an overview of the functionality provided, the memory mapping of the register banks for the peripherals, and pin-out information for interfacing with the chip. On top of that, you’ll want several manuals from ARM. You’ll want the ARMv7 Architecture Reference Manual (there’s one version for A and R series, and another for M series-- BBB has an A series core) as well as the more specific Cortex A Series Programming Guide (or the M Programming Guide if you go with an M-class CPU instead of the BBB) and the Cortex A8 (or Cortex M3/M4) Technical Reference Manual, which together tell you everything you might want to know about the CPU itself, at least outside of the minor modifications and implementation choices TI made when putting it in the BBB’s SoC. There are various other useful documents in ARM’s library; a handy one for low-level stuff is “Procedure Call Standard for the ARM Architecture” which shows you what assembly instructions constitute a procedure call that can be used to call into compiled libraries.

For a look at what bare metal programming on an M-series (such as the $14 Tiva C Launchpad from TI) board looks like, here are some slides from a guy’s tutorial presentation along with a handout pdf that’s very informative: http://www.bravegnu.org/blog/gnu-eprog-slides.html

I was able to get that toolchain working and run a couple of basic programs in an emulated (via qemu) ARM M3 platform. Really, a microcontroller is the biggest thing you’d really want to write all the code for as a hobbyist. Digging through TRM details and RAM datasheets to figure out the correct timing parameters to program into your SDRAM controller is really not a lot of fun, and you’ll never have the time to get a fraction of the BBB’s peripherals up and running without taking advantage of a LOT of pre-written code. Microcontrollers, on the other hand, are all about bare-metal code and just the functionality you need for the job you’re doing. A Tiva Launchpad would be a great board to experiment with bare metal programming, basic motor control and sensor reading, etc. It’d make a nice little robot brain, or even just a nice little platform to experiment with developing a bare-bones RTOS. If you skim through the A-series and M-series references, I think you’ll agree you’d much rather be doing bare-metal programming on the latter.

BBB is for several reasons the best solution for me. And what I try to
do is not as complex as it sounds, I just want to access some GPIOs,
Ethernet and - perhaps - UART. All the other things like USB,
LCD/HDMI, SPIs and whatever is available on the board is not required.
Meanwhile I have some code running on it - most troubles have been
caused by build problems due to poor Linux support of TIs Starterware.

Anyway, thanks for your thoughts!

I actually wrote, with a small team, a set of drivers for the CPSW core that makes up the Ethernet support in the BBB, although my code actually ran on a different SoC. It was not a barebones driver, as it needed to interface with the timestamping engine to support PTP, and it was written for QNX rather than a no-OS environment, but it’s at least an order of magnitude more complex than writing a UART driver or GPIO access. The BBB’s SoC actually has a 3-port Ethernet switch inside, and the host port is controlled via a DMA interface while the RJ45 on the board is connected to one of the external ports. Even if you’ve had experience writing ethernet drivers before, you are likely to catch a few snags on this one.

I don’t know exactly what Starterware provides for you, and it may be enough to get all the grungy system configuration and basic drivers going, but everything is about 10x harder with a complex and featureful SoC than it is on a microcontroller. But if you’re set on using the BBB for your bare-metal programming experiments, you’re sure to learn a lot (and much of it through hair-pulling frustration), so I wish you luck!

poor Linux support of TIs Starterware?

not sure I understand

Hi,

There is a way to do baremetal with x-loader as a startup…without the emulator.

This link will provide the idea…

http://beagleboard.lohray.com/vm-larix/bare-metal-hello-world

Thanks for the feedback. Meanwhile I'm happy with StarterWare from TI.