Posts: 15
Joined: Sun Jan 15, 2017 10:18 pm

Run Single Program 24/7

Tue Sep 19, 2017 9:55 pm

Hi I'm completely new to bare metal programming and I have never done it before. Sorry I couldn't come up with a better title :oops:
Anyways I like to do stuff myself instead of having it being done for me by some black box. I am studying Computer Science currently so I do understand (at least in theory) how Assembler is supposed to work. And I recently had this idea of having pretty much the bare minimum of a computer just run 24/7 calculating something. Like some new numbers for or something similar, where I could easily write a C program for it. Then I would want to connect it to some simple 7-segment display which would be possible to control without any drivers (like just 7 on/off inputs). And then I could put it somewhere and it shows the latest result of it's calculations digit by digit on that display.
I hope you get the general idea.
I do know, that this is a Raspberry Pi specific forum but do you think that this would actually maybe work even without the extra stuff a raspberry has? If I can get my program really really small, shouldn't I be able to pretty much run it just on the CPU caches without even RAM? Or BIOS and stuff? I guess it will definitely be easier on the Raspberry because of the tutorials and all that are on here and the pins it has and so on. But would it be doable on just a CPU alone? How would one start it?
Sorry for the many questions, I'm just trying to figure out a viable way I could actually bring this idea to life. And I want to try to do it bare metal because I find the concept really interesting and I think it should be a lot faster if there are literally no cache misses because everything would be in the cache.
Thanks for any suggestions and answers in advance.
PS: I have a Raspberry Pi 3 at the moment but I would probably use a Raspberry Zero for that if a single CPU is too hard (which I guess it is)

User avatar
Posts: 1049
Joined: Mon Oct 19, 2015 6:21 am
Location: Finland

Re: Run Single Program 24/7

Wed Sep 20, 2017 3:03 am

The idea is feasible. In the time of Transputers we actually carefully created parts of code that run inside the CPU cache to get enormous speed boosts. With Digital Alpha you could hand tune the code for amazing pipeline speed boost. We are easily talking about a factor of 10.

The Pi also has a GPU which can use the cache as well. So there may be very much to gain by clever coding.

Posts: 15
Joined: Sun Jan 15, 2017 10:18 pm

Re: Run Single Program 24/7

Wed Sep 20, 2017 11:40 am

It's actually that much of a speed boost? I would have thought that it would only have minor impact if at all because compilers are so advanced and optimize everything themselves but that's great then! I just don't really know how to use Multithreading on that level, I haven't even used Multithreading at all...
So would that be very hard? Or is there some help somwhere on how one would do this? On a GPU that problem would be a lot greater, too, wouldn't it? Since it has so many cores?
Thanks for the reply,

Posts: 1004
Joined: Wed Dec 07, 2016 2:29 pm

Re: Run Single Program 24/7

Wed Sep 20, 2017 11:54 am

It is the number of cores the GPU has (12) and being a vector processor that makes all the bang.

Best just look at the samples and tools to play with it

The ARM is really a co-processor and all the bootloader is done by the GPU and when it sets everything up it releases the ARM reset. Obviously for most of this stuff they don't release the ARM reset and it sits tucked up out of the way. But there are samples running both.

You can also play with it under linux.

I guess on say a Pi3 you could really setup an AMP with the GPU and 4 ARM cores, crazy stuff :-)

Posts: 15
Joined: Sun Jan 15, 2017 10:18 pm

Re: Run Single Program 24/7

Wed Sep 20, 2017 2:11 pm

Ok, I just did some research about how I could achieve what I want to do and I think I'm gonna mess around with Ultibo a bit and see if I can use that. It looks pretty promising to me so I will try it out.

Posts: 946
Joined: Sat May 26, 2012 5:32 pm

Re: Run Single Program 24/7

Thu Sep 21, 2017 1:45 am

an operating system is nothing more than a bunch of machine code instructions and data. the processor cannot tell an operating system from a bare metal program, its the humans that make the distinction.

doing a project in assembly language is usually for the purpose of doing it in assembly language like climbing the mountain because it is there, you are not climbing the deadly mountain to get to the other side you are climbing it to say you climbed it if you wanted to get to the other side you usually go around or cross at the lowest point practical. Write your bare metal program in C with some assembly as required for various reasons but it should be well under one percent of a typical project, fairly close to zero percent. The compiler generates the assembly for you which the assembler then makes the machine code for you.

from one perspective the pi is way overkill for simple projects like making a clock or temperature display, but at the same time price wise it is on par with fully branded arduinos and others, although those used to be over $50 and have come down some but not down to what they really should cost. you can get a pi-zero and put pins on it for about the price of an st discovery board or a ti launchpad which are all cheap but could be cheaper with some of the profit taken out. And it is fun to have all that extra/wasted processing power knowing that that is not what you are limited, by you have more than enough ram and clock cycles to do things, you dont have to sweat it...

whatever your stepping stone or stones are to get from applications on an operating system to bare metal, be it ultibo or some other solution, so be it. a lot of work still has been done for you so depending on whether this is you climbing the bare metal mountain for educational purposes or you simply want to get to the other side (bang out some gadget that performs a task without getting your hands really dirty).

have fun, no reason I can tell so far why you cant do what you are trying to do...and no reason why it cant run 24/7...(unless you wear out the flash on the sd card by abusing it, not sure if that is in your use case)

Return to “Bare metal, Assembly language”