hldswrth
Posts: 108
Joined: Mon Sep 10, 2012 4:14 pm

start.elf - what's really needed for bare metal OS?

Thu Nov 29, 2012 1:53 pm

So I'm making progress, coding my bare metal OS, file system, shell, c runtime, even got a port of NetHack working... and all of that in about 150k (barring NetHack, which compiles to 2Mb).

So now I'm looking at start.elf and wondering why I need 2Mb to flash the screen in pretty colours for about 1/10th of a second before my OS takes over.

Has anyone looked at removing/stripping down start.elf?

Regards, Simon

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 22754
Joined: Sat Jul 30, 2011 7:41 pm

Re: start.elf - what's really needed for bare metal OS?

Thu Nov 29, 2012 2:30 pm

It programs the GPU up for display, sorts out all the interfaces etc - prior to jumping to user code. Probably not worth the effort breaking it down.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5269
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: start.elf - what's really needed for bare metal OS?

Thu Nov 29, 2012 2:40 pm

You can delete start.elf (and fixup.dat) if you set gpu_mem=16 in config.txt.
It uses start_cd.elf which is 550K and doesn't include support for GL/VG/OpenMAX etc.

hermanhermitage
Posts: 65
Joined: Sat Jul 07, 2012 11:21 pm
Location: Zero Page

Re: start.elf - what's really needed for bare metal OS?

Thu Nov 29, 2012 2:58 pm

hldswrth wrote: So now I'm looking at start.elf and wondering why I need 2Mb to flash the screen in pretty colours for about 1/10th of a second before my OS takes over.

Has anyone looked at removing/stripping down start.elf?
start_cd.elf is 550kb for 16MB split.

The 2MB start.elf contains a multitasking kernel (ThreadX) and implementations of OpenGL ES / OpenVG (~500k), codecs (50-500k each) - its pretty compact by modern standards. I'd estimate about 200-400k semicolons (lines of live code) assuming a line of code in C generates an average of 4 VideoCore instructions with an average density of 3 bytes per instruction. (Although I see the figure 5m lines of code bandied about - but it's easy enough to do the math).

Some of us boot with a minimal custom bootcode.bin - but no ARM yet, just a toy at this stage. If you look on my GitHub or join #raspberrypi-internals you can learn more. There is a build of binutils for VideoCore in development etc.

I'm focussing on integer vector / multimedia kernels, hopefully we will get some more information out soon. We are always looking for more hands on deck.

hldswrth
Posts: 108
Joined: Mon Sep 10, 2012 4:14 pm

Re: start.elf - what's really needed for bare metal OS?

Thu Nov 29, 2012 3:14 pm

> You can delete start.elf (and fixup.dat) if you set gpu_mem=16 in config.txt.
> It uses start_cd.elf which is 550K and doesn't include support for GL/VG/OpenMAX etc.
I don't have fixup.dat or start_cd.elf. All I have is: bootcode.bin, loader.bin, start.elf, config.txt and my kernel.img.

> The 2MB start.elf contains a multitasking kernel (ThreadX) and implementations
> of OpenGL ES / OpenVG (~500k), codecs (50-500k each)
But those 2MB just get completely overwritten by kernel.img (at least in my case anyway) so not sure what's really needed for a bare metal OS. As far as I can tell it is reading and parsing config.txt and processing those options before passing control to the kernel.

For the moment it does sound like more effort than its worth to remove it, but would be good to understand what a real bare metal OS would have to implement to replace it.

Cheers, Simon

hermanhermitage
Posts: 65
Joined: Sat Jul 07, 2012 11:21 pm
Location: Zero Page

Re: start.elf - what's really needed for bare metal OS?

Thu Nov 29, 2012 3:54 pm

hldswrth wrote:> You can delete start.elf (and fixup.dat) if you set gpu_mem=16 in config.txt.
> It uses start_cd.elf which is 550K and doesn't include support for GL/VG/OpenMAX etc.
I don't have fixup.dat or start_cd.elf. All I have is: bootcode.bin, loader.bin, start.elf, config.txt and my kernel.img.

> The 2MB start.elf contains a multitasking kernel (ThreadX) and implementations
> of OpenGL ES / OpenVG (~500k), codecs (50-500k each)
But those 2MB just get completely overwritten by kernel.img (at least in my case anyway) so not sure what's really needed for a bare metal OS. As far as I can tell it is reading and parsing config.txt and processing those options before passing control to the kernel.

For the moment it does sound like more effort than its worth to remove it, but would be good to understand what a real bare metal OS would have to implement to replace it.

Cheers, Simon
The structure of the SoC may be inverted from what you envisage - The ARM CPU is a little guest bolted on the side. What you view as baremetal can be thought of as almost managed code :-). The ARM sees bus addresses thru the lens of the VideoCores MMU...

Return to “Bare metal, Assembly language”