Bare Metal startup code


I’m new to this forum and to Beaglebone (Black) programming. Comming from Cortex M4 (Atmel’s SAM4S XPlained Pro board), I made the step to Cortex A series processors.

I’m trying to set up the BBB as a pure bare metal device, without Linux or any other OS. I delved in Starterware with CCS, but unfortunately my SEGGER J-Link is supported by CCS only for about 3 months… So I’m switching to Eclipse development and am porting the Starterware code to the gcc ARM none eabi. I can compile the drivers, grlib, etc and run the boot process from my ide environment on the real hardware using J_Link JTag debugging.

AFAIK It isn’t possible uo use the standard C functions (like printf etc) in the bootloader because it doesn’t use C startup code. I want to develop C/C++ code that runs in DDR3 space and uses C/C++ startup code to provide the nessecary functionality. I Think newlib is the way to go for embedded systems (writing my own stubs for _sbrk etc.)

Now comes the tricky part : How to build a real bare-metal C/C++ application running in the DDR3 space…
AFAIK the bootloader code must jump into the C/C++ startup code instead of directly to main. Also, which lib to include in the linker for the BBB? Where can I find the start address of that specific libc ? Secondary, the bootloaders first assemby file jumps to the ‘main’ as entry point in the c code, but I assume that the real application also has to have a ‘main’ function. How to distinguish both of them? One in the internal ram (0x402F0400…) and the other in DDR3 (0x8000000…) ? And how to jump from the bootloaders main to the applications main?

Thanks in advance,


If you have Starterware installed, take a look in the boot loader folder of your installation. You'll find all of your answers there. Basically, a boot loader is just used to setup your hardware, like your DDR3 that you want to execute from. Once the hardware is good to go, you need to copy your application from either the internal eMMC or from an SD card into RAM. Then you pass control to your application by jumping to its main address. All of the info you need is in the Starterware boot loader folder. I suggest you study it good. Bare metal programming is incredibly rewarding, but is definitely not for everyone.