Starting bare metal...


4 posts
by poglad » Tue Nov 06, 2012 9:33 pm
I know there is a website mentioned elsewhere with a course on bare metal programming on the Pi... I've also just been looking at the DexOS website. If I go down the DexOS route (for now), will I be at any disadvantage in terms of a performance hit etc? Is it harder to address the hardware or call GPU stuff without a C compiler there?

Thanks!
User avatar
Posts: 102
Joined: Tue Jul 31, 2012 8:47 am
Location: Aberdeen, Scotland
by gertk » Tue Nov 06, 2012 10:53 pm
It does not matter how you program 'Bare Metal' in C or assembler.

For ease of writing C is definitely easier and should you get into performance issues you can always add assembler routines if needed. With gcc you can mix them without problems.
For programming the GPU you will have to dig in deep, adding an OpenGL lib is probably a lot easier.

In my experiments I am using a simple 16 bit framebuffer which is handled by the CPU only.

Another tip for writing and testing Bare Metal: get an USB to 3,3V serial adapter, connect it to the mini-uart pins of the Pi and use dwelch67 serial bootloader on the SD card and a terminal program on the PC. Also a sturdy switch in the power cable to the Pi is also a must! Without these you end up compiling, copying to the SD card, insert SD card in Pi, reboot and test, remove SD card, compile, reprogram, ad nauseum.. It will wear out the cardslot of the Pi and it is slow... :)

Happy programming!
Posts: 47
Joined: Mon Aug 29, 2011 9:08 am
by poglad » Wed Nov 07, 2012 2:48 am
Thanks! :-)
User avatar
Posts: 102
Joined: Tue Jul 31, 2012 8:47 am
Location: Aberdeen, Scotland
by gertk » Wed Nov 07, 2012 9:46 pm
This is what my setup looks like:

MicroSD adapter with massive 8GB card (left over from my G1...) formatted in two partitions: one small 100 Mb FAT16 boot partition and a bigger FAT32 storage partition (for later use)

Powerswitch in between the cable to the micro USB connector (positive line) and the FT232BOB module dangling in between the PC and the Pi. Note! The RX and TX connections need to be crossed: Pi TX connects to FT232 RX and Pi RX connects to FT232 TX. This may depend on the type of USB to (low voltage) serial cable you use.

The FT232BOB module itself is powered by the USB port of the PC so there are only three cables connected to the Pi: RX, TX and GND
Attachments
very_small_2012-10-25 22.33.53.jpg
very_small_2012-10-25 22.33.53.jpg (53.61 KiB) Viewed 951 times
Posts: 47
Joined: Mon Aug 29, 2011 9:08 am