User avatar
Gavinmc42
Posts: 1549
Joined: Wed Aug 28, 2013 3:31 am

Re: What are situations to use bare metal when python is so much easier?

Fri Aug 25, 2017 11:07 am

It also has not been ported to the Pi but it is on Github
MicroPython updated to v1.9.1-31
http://forum.tinycorelinux.net/index.ph ... 170.0.html
So Micropython comes as standard on piCore, did some banchmarks, there is a few tricks highlighted here
http://forum.tinycorelinux.net/index.ph ... 778.0.html

Have not done much benchmarking on the 1GHz Zero :lol:

I have done quite a bit with the standard basic piCore OS, comes with just enough to make single application devices.
The only reason I moved to Ultibo was the trend to using Linux plus busybox as DOS machines :oops:

You can install the full python on piCore,but I choose to use the minimal piCore as a way to learn Linux and how to do things without massive libraries.
It would be called embedded Linux if on a router etc.

Using big libraries etc just means you learn how to use them, not how to use core Linux features like shell, Awk, Sed, Netcat etc....
Most of my piCore stuff get tested on my old reliable 128MB SDcards, try doing that with Raspbian.
Have not found any 8-16MB cards for Ultibo :lol:

Baremetal makes smaller code, memory does cost
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

LdB
Posts: 582
Joined: Wed Dec 07, 2016 2:29 pm

Re: What are situations to use bare metal when python is so much easier?

Fri Aug 25, 2017 1:49 pm

You can also reach 68Mhz on the GPIO baremetal (but you will struggle getting it out on the PI IO connector) but slightly up on those numbers :-)

hippy
Posts: 2343
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: What are situations to use bare metal when python is so much easier?

Fri Aug 25, 2017 4:47 pm

Gavinmc42 wrote:
Fri Aug 25, 2017 12:41 am
but is Micropython baremetal?
Is Ultibo, is Arduino C, is anything ?

First one has to define what "bare metal" is. IMO it's not so much what one uses but how one is using it.

Writing the code to peek and poke on-chip registers in order to get a character sent out of a UART would certainly fall under "bare metal", no matter what language is used to do that. But once one has encapsulated doing that in an easy to use subroutine and are calling that subroutine one isn't really bare metal programming any more.

That's where the contention that using Ultibo isn't bare metal programming comes from. Users of it are just writing Pascal code, calling provided functions, not doing bare metal themselves.

I would generally consider anything which requires knowledge of the specifics of the hardware to be bare metal; addresses of registers, ID codes of mailboxes, where one's code is placed in memory. If one is accessing AUX_MU_IO_REG or GPSET0 or specifying .org 0x800; that's bare metal. Calling UartSend() or SetPin() then no. *frameBuffer=0x81 - on the borderline.

A wider-scoped definition of bare metal on a Pi is arguably when one is creating a single standalone bootcode.bin or kernel.img rather than creating an application which runs under some other OS.

LdB
Posts: 582
Joined: Wed Dec 07, 2016 2:29 pm

Re: What are situations to use bare metal when python is so much easier?

Fri Aug 25, 2017 5:09 pm

Agree 100% but I would also put one more restriction.

That to class as baremetal you must be able to include sections of native assembler code if desired as an indication that you can go raw to the CPU if required. Ultibo, C, C++ and assembler itself all meet that requirement.

dwelch67
Posts: 843
Joined: Sat May 26, 2012 5:32 pm

Re: What are situations to use bare metal when python is so much easier?

Sat Aug 26, 2017 4:12 pm

the minimal disassembly attempt I did for JAVA, I seem to remember there are system call instructions, could be wrong, but if true a JVM does system things for you. Now C has system calls, lets call printf() one but you can have a bare metal printf...or can you.

Is arduino bare metal when you use their sandbox and apis?

I think it is subject to opinion. Something very offensive is the cloud community has picked up this term to use it completely wrong. they dont mean no operating system, they dont even mean fewer operating systems they mean move drivers off of one operating system to something else, rent a customer a cloud machine that looks very much like a clean server, any services you have/need for that system you do with minimal or no impact on the processor the customer is using. for example add another processor on the motherboard that is yours, run an os on that and drivers/etc to manage the machine or what pretends to be a machine (look at how facebook does their gpus for example). You didnt remove all the operating systems yet they call that baremetal because the customer is presented with a machine without a providers operating system on it.
I dont call that baremetal that machine is running an operating system be it the providers or the customers or both.

Anyway, I would discourage but dont disagree that Lua, etc make things easier from one perspective. (getting them up and running takes real bare metal skills and if you can do that then why bother writing in Lua, JAVA, etc?)

did the OP come back and read this stuff?

hippy
Posts: 2343
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: What are situations to use bare metal when python is so much easier?

Sun Aug 27, 2017 12:37 am

LdB wrote:
Fri Aug 25, 2017 4:22 am
MicroPython still can't compile itself (it requires a C compiler for that) a status FreePascal like you use on Ultibo reached rather fast.
That "still can't" is probably a "won't ever", and it has never been a goal as far as I am aware.

Whilst it might be nice to be able to compile itself it's far from essential and I don't see not being able to do so as a limitation, flaw or failure.

1) There's no obvious need for it and I don't think there's anyone who sees how it is as a problem. Many languages don't self compile and it's not often a necessity, for bare metal or anything else.

2) The embedded world which MicroPython targets is well used to developing on a host PC then downloading executable images to the target.

3) Most MicroPython targets are minimal systems, aren't the sort of thing which one would ever expect to host development tools, would ever want to.

4) The people developing MicroPython itself aren't generally the people using MicroPython to deliver results. The people using MicroPython aren't generally the ones developing MicroPython.

5) It really isn't worth rewriting all the C code as MicroPython code, testing and debugging all that, just for the sake it. There is almost no benefit at all in MicroPython being able to self-compile and there are better, more useful, more important, and more beneficial things to direct time and effort towards.

To me it seems you are presenting it as if a problem when I don't see that it is, but I am always open to hearing arguments for MicroPython to strive for self-compilation as a goal.

User avatar
Gavinmc42
Posts: 1549
Joined: Wed Aug 28, 2013 3:31 am

Re: What are situations to use bare metal when python is so much easier?

Sun Aug 27, 2017 2:05 am

I have used micropython to toggle GPIO pins for a single stepper motor on piCore.
Not perfect as the jitter caused by the Linux OS is audible. Newer methods like DMA as used in the Python CNC can fix this issue.
But it was quick to develop and I can still still remote ssh into the box and change the code at any time.

Interpreted languages like python/micropython means you can modify code on running systems without stopping everything and recompiling C code and downloading a new version etc. Guess I just made the case for using python ;)

It is not easy doing this for baremetal, but some/most have enough memory to do this these days.
Remote system upgrades in the field are mostly now regarded as normal.
Upgrading a full OS requires more memory to do than the few KBs of a python script.

If the device is RF connected with slow data rates, upgrade complete OS or just the script?
I use Synapse Wireless modules, these allow over the air python script application updates.
Newer versions now also allow over the air OS updating.

Ultibo can use Pascalscript but it also has remote kernel.img upgrade as standard.
It has the capability to use either or both methods at the same time.
The Pi's can allow this, not many other SBC's or embedded systems can offers so many ways to do things.
With Pi's you are not restricted to just one way of coding. Big memory and 1GHz means less restrictions too.
Even shell script is fast enough to flash a warning LED or a beeper :lol:
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

LdB
Posts: 582
Joined: Wed Dec 07, 2016 2:29 pm

Re: What are situations to use bare metal when python is so much easier?

Sun Aug 27, 2017 2:44 am

hippy wrote:
Sun Aug 27, 2017 12:37 am
To me it seems you are presenting it as if a problem when I don't see that it is, but I am always open to hearing arguments for MicroPython to strive for self-compilation as a goal.
Then you just gave another example of something python can't and according to you will not ever do :-)

As an aside any language that can't compile itself runs the risk of becoming obsolete as the language it is compiled on may die out.

However the OP asked why would you use baremetal when python was so much easier. So far we have a long growing list of things that python can't and is claimed will never do, so we are back to the situation why is thread still alive.

Final Answer: Baremetal is there to keep python alive and looking simple, as python can't do all the hard stuff and has no aspiration to do it. Hence the question was silly in the first place :-)

jahboater
Posts: 1924
Joined: Wed Feb 04, 2015 6:38 pm

Re: What are situations to use bare metal when python is so much easier?

Sun Aug 27, 2017 7:45 am

LdB wrote:
Sun Aug 27, 2017 2:44 am
As an aside any language that can't compile itself runs the risk of becoming obsolete as the language it is compiled on may die out.
Python, Javascript and probably others are reliant on C (to implement their interpreters and run-time libraries) as far as I can see. Hopefully C will be around for a long time. It is perhaps a little sad that programming languages purporting to be "general purpose" cannot implement a compiler or interpreter.

Whilst clearly daft, the original question has provoked quite an amusing thread over two pages and 34 posts so far :)

hippy
Posts: 2343
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: What are situations to use bare metal when python is so much easier?

Sun Aug 27, 2017 4:42 pm

LdB wrote:
Sun Aug 27, 2017 2:44 am
hippy wrote:
Sun Aug 27, 2017 12:37 am
To me it seems you are presenting it as if a problem when I don't see that it is, but I am always open to hearing arguments for MicroPython to strive for self-compilation as a goal.
Then you just gave another example of something python can't and according to you will not ever do :-)
Many languages cannot do things or are not well suited to doing them. That's not a problem if one doesn't need those abilities.

Not being able to self-compile is not something which limits what MicroPython can do. Not being able to self-compile is not something which limits what any programming language can do.

Self-compilation is only something which might matter to developers of the compiler or interpreter for those languages. It has no benefit for those simply using that compiler or interpreter, there is no disadvantage if it doesn't.
LdB wrote:
Sun Aug 27, 2017 2:44 am
As an aside any language that can't compile itself runs the risk of becoming obsolete as the language it is compiled on may die out.
Maybe so but, as MicropPython is coded in C, it seems unlikely it will be obsoleted unless C is.

It seems you are scrapping at the very bottom of the barrel to take issue with MicroPython, and perhaps even Python. Not sure why because there will often be far more obvious and more legitimate reasons as to why Python is not the best choice of language for a particular application. On the other hand there are reasons why choosing Python can be a good choice.
LdB wrote:
Sun Aug 27, 2017 2:44 am
Baremetal is there to keep python alive and looking simple, as python can't do all the hard stuff and has no aspiration to do it. Hence the question was silly in the first place.
In the sense of 'either or' it isn't a brilliantly phrased question because that's not the choice.

Python can however can interact with the bare metal on the Pi. All it needs is the right library and one can go poking around with the hardware, twiddling I/O, playing with video frame buffers, and even talk to the GPU via mailboxes.

User avatar
OutoftheBOTS
Posts: 438
Joined: Tue Aug 01, 2017 10:06 am

Re: What are situations to use bare metal when python is so much easier?

Sun Aug 27, 2017 9:16 pm

This was quite an interesting thread to read.

In reality only programming in assembler would be pure bare metal literally writing machine instructions line by line. C has a compiler that does a hell of a lot of work for you for example to create a for loop in assembler it is more than 20 lines of code yet it is only 1 line of of in C, the C compiler fills in the more than 20 lines for you.

The question is more a question about high level languages vs low level languages i.e how much auto fill is done for you and how much you have to write yourself.

Up till last Christmas I hadn't done any programming in 25 years hadn't even turned on a computer till I had to email a few years ago. What I have discovered is that computer have become very very very powerful and cope really well with waste of power. In the old days writing the most efficient code for CPU use and memory use was the most important but these days the life span of a program is super short so development time of the code is much more important. Using what ever platform that gets to finished product as fast as possible is more viable than efficient code.

Further up this thread there was a couple of good examples where using a low level environment was better than a high level environment but in most cases people use low level environment because of it is their beliefs not because it is practical.

hippy
Posts: 2343
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: What are situations to use bare metal when python is so much easier?

Mon Aug 28, 2017 1:33 am

OutoftheBOTS wrote:
Sun Aug 27, 2017 9:16 pm
The question is more a question about high level languages vs low level languages i.e how much auto fill is done for you and how much you have to write yourself.
To an extent. I would still say -

Code: Select all

ld #0x30
st UART_TX

Code: Select all

*UART_TX = 0x30;

Code: Select all

PokeByte(UART_TX,0x30)
Were all as much bare metal as any of the others were.

That was my point about it's not what one uses but what one is doing and how one is doing that.

Higher-level languages allow a conciseness of coding, but that doesn't mean that what one is doing isn't bare metal.

To me, what makes them all bare metal is knowing one has to write to a particular location to do what one wants to do, and one needs to know where that location is. Non bare metal would hide that away.

User avatar
Gavinmc42
Posts: 1549
Joined: Wed Aug 28, 2013 3:31 am

Re: What are situations to use bare metal when python is so much easier?

Mon Aug 28, 2017 3:26 am

Code: Select all

To me, what makes them all bare metal is knowing one has to write to a particular location to do what one wants to do, and one needs to know where that location is. Non bare metal would hide that away.
If baremetal means knowing all the bits n all the registers on the Pi chips then no one programs Pi's baremetal( maybe a few at RPF?)
CPU's have gotten so complex the data no longer exists in a single datasheet.

I may have compiled C source on Pi's but I don't remember doing any C code except for messing about with the USB rpiboot for Zero USB booting. In fact I prefer just about any language than C on Pi's :lol:
Sure C will compile code for every know micro/cpu and I use C all the time for microcontrollers I connect to Pi's.
But if you do code in C on Pi's you need to consider that OS called Linux that thinks it is in charge.

Python is easier, but it is not perfect either, I eventually had to give up using it for reliable i2c comms, even gave up on Linux all together.
There are a number of baremetal options now for Pi's, try them all. Like C? then Circle will your cup of tea even though it is C++.

I have tried most languages that will run in Raspbian, I discovered the more of them I learn the more they look alike.
Except for Python with that silly white space punctuation.

Some do things better than others, Python needs external libraries like Numpy etc to do anything useful with arrays, images etc.
Pi's are about learning, you can learn just about every language as nearly all will run of Pi's.
Some are real picky and you do need ARMv7 or ARMv8 Pi's.

There are easy languages that work fine if not great and then you hit a brick wall.
You could still do everything in C but then you will never learn anything new :lol:

So who will port baremetal Micropython to the Pi? Then the OP's question is redundant.
Then port baremetal Numpy eek. :roll:
Ultibo uses Free Pascal and Pascal has always had native array support.
Some FPC image units and many others will port with no problems to Ultibo.

Who will be the first to baremetal the VC4 accelerated graphics?
Try doing baremetal Video or camera stuff on Pi's. That is a world of pain.
One way is to skip the VC4 hardware and use the ARM NEON, er most NEON is assembler or C, with only one exception I know of.

The main reason for baremetal is fast boot, you want things to just work when turned on not take ages booting.
Unless we write in VC4 baremetal this is going to be about 2 seconds minimum. If you need faster than that then Pi's are not for you.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

LdB
Posts: 582
Joined: Wed Dec 07, 2016 2:29 pm

Re: What are situations to use bare metal when python is so much easier?

Mon Aug 28, 2017 5:40 am

I have given up on this rather silly thread but will just comment on errors and inaccuracies so we don't have a thread with errors in the baremetal section.
hippy wrote:
Mon Aug 28, 2017 1:33 am

Code: Select all

*UART_TX = 0x30;
PokeByte(UART_TX,0x30)
Were all as much bare metal as any of the others were.
Sorry they aren't and neither of those two last lines are guaranteed to work and in fact both will probably fail totally, you need to give me more info to convince me they might work on a Pi system. These are the sorts of dangerous comments that are being made on a forum dedicated to baremetal. You might think about why those lines might not work as a learning exercise, or if you aren't prepared to do it new readers might at least think about it.

This is one of the problems with languages you need to think about what code it might produce versus what the hardware is. The hardware has very specific requirements for access and it is very unforgiving.
Gavinmc42 wrote:
Mon Aug 28, 2017 3:26 am
But if you do code in C on Pi's you need to consider that OS called Linux that thinks it is in charge.
Gavin I write in C baremetal all the time and never go near linux, you lost me with this statement? Or where you talking about people coding C on linux and it is just worded strange.
Gavinmc42 wrote:
Mon Aug 28, 2017 3:26 am
Who will be the first to baremetal the VC4 accelerated graphics?
It can't be fully baremetalled until they release the full details of the VC4. However plenty of us have shimmed the released VCOS system and got EGL running which is about as close as we can get at the moment.
Gavinmc42 wrote:
Mon Aug 28, 2017 3:26 am
Try doing baremetal Video or camera stuff on Pi's.
I have no interest in the camera stuff so have no idea. However the video wasn't that hard but I am using a commercial encode/decoder library. I don't know of any free or public domain code that could be used to do it so that is probably in the more challenging list. I have seen posts about VLC doing something but I have no idea if the code is released or works.

hippy
Posts: 2343
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: What are situations to use bare metal when python is so much easier?

Mon Aug 28, 2017 12:54 pm

Gavinmc42 wrote:
Mon Aug 28, 2017 3:26 am
If baremetal means knowing all the bits n all the registers on the Pi chips then no one programs Pi's baremetal( maybe a few at RPF?)
CPU's have gotten so complex the data no longer exists in a single datasheet.
That's not my definition of bare metal; one only needs to know enough to do what one wants to do, not all of it.
Gavinmc42 wrote:
Mon Aug 28, 2017 3:26 am
I have tried most languages that will run in Raspbian, I discovered the more of them I learn the more they look alike.
Except for Python with that silly white space punctuation.
Yet putting the same amount of silly white space punctuation into a C or any other program so we properly indent code as always recommended is perfectly acceptable.

Python isn't that far removed from C with its indentation. Let's start with some C, and agree that consistent indentation is important ...

Code: Select all

void function()
{
  if ( a == 1 )
  {
    a = b;
  }
  else
  {
    c = d;
  }
}
Compact that down to as few lines as possible; move "{" and "}" up as far as
they can go ...

Code: Select all

void function() {
  if ( a == 1 ) {
    a = b; }
  else {
    c = d; } }
That's still C. But let's replace "{" with ":" and lose the "}" ...

Code: Select all

void function() :
  if ( a == 1 ) :
    a = b;
  else :
    c = d;
Finally let's make it Python; tidy it up, and remove the C syntactic fluff ...

Code: Select all

def function():
  if a == 1:
    a = b
  else:
    c = d
Voila, it's Python. Indentation hasn't actually changed. Just that all the fluff which was never actually needed because it can be inferred from the indentation isn't there.
Gavinmc42 wrote:
Mon Aug 28, 2017 3:26 am
So who will port baremetal Micropython to the Pi? Then the OP's question is redundant.
Stefan Naumann seems to be most active and determined in pursuing that -

https://www.stefannaumann.de/en/2017/05 ... spberry-pi
https://www.stefannaumann.de/en/2017/07 ... -pi-part-2

He appears to have MicroPython booting on a Pi, though it's really just the start, proven PoC, rather than useful as it's unfinished.

If anyone wants to help with that I am sure he will be grateful.

LdB
Posts: 582
Joined: Wed Dec 07, 2016 2:29 pm

Re: What are situations to use bare metal when python is so much easier?

Mon Aug 28, 2017 1:19 pm

Unfortunately Stefan Naumann isn't even close infact the biggest issues he will face he hasn't even realized yet and it's somewhat obscured from him because he is playing with the Pi1. He does realize he is just learning which is always a good thing and I would never discourage. Makogan who was a poster on here I was helping also has an O/S called PIOS, do you know if they are the same thing or an unfortunate name clash?

The question is do you want micropython ported? I am pretty sure I can do it but I suspect I will have to make a couple of additions to the language to clarify to the subsystem what my intention is. Python on linux or windows uses the subsystem to clarify it but with no O/S we will need to spell it out somehow.

hippy
Posts: 2343
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: What are situations to use bare metal when python is so much easier?

Mon Aug 28, 2017 1:45 pm

LdB wrote:
Mon Aug 28, 2017 1:19 pm
The question is do you want micropython ported? I am pretty sure I can do it but I suspect I will have to make a couple of additions to the language to clarify to the subsystem what my intention is.
I would love to see a bootable Python environment ported to the Pi and I believe many others would as well. And there would probably be many more delighted to have it if it existed.

If you, or anyone, were going to do it; I would personally have no issues with making additions to the language so long as it still ran Python code.

I might debate on what I think would be the best ways to do it but I am more interested in being able to boot a Python environment, run Python code on that, than how we get to that goal. If it means forking or going in a different direction that's okay by me. If you wanted to take ownership I believe it's only right that you get to choose how it will be.

LdB
Posts: 582
Joined: Wed Dec 07, 2016 2:29 pm

Re: What are situations to use bare metal when python is so much easier?

Mon Aug 28, 2017 3:11 pm

So let me check we are talking about running it on Cython API aren't you. You don't want me to put it on a cutdown linux pthread?
What I am asking about is this problem as the Pi2 and 3 have multicores
http://python-notes.curiousefficiency.o ... ython.html

My problem with the github code is this
This combination of requirements simply doesn’t work - the GIL effectively restricts bytecode execution to a single core, thus rendering pure Python threads an ineffective tool for distributing CPU bound work across multiple cores

The current arm implementation is specifically 32bit and we need to teach it some more tricks and possibly support 64 bit.
https://github.com/micropython/micropyt ... y/asmarm.c
https://github.com/micropython/micropyt ... y/asmarm.h

Do you want a 64 bit version and if so how do you want me to tell the python system 32bit or 64bit.

The whole maths FPU is a nightmare I have to deal with different FPU's for different PI boards.
http://docs.micropython.org/en/v1.9.1/p ... float.html
I know which I have at runtime but I have to forbid you guys from writing FPU specific code like they suggest here.
I need some API mechanism to hide the exact FPU format from you but write in a more generic form and as I don't use python that is a bit of a challenge :-)

We might need a discussion about malloc on the garbage collector down the track but I can work with it for now.

Update: Having now played around with the python interpreter I must say I don't get the fascination with the language. Everything it does any modern C14++ compiler like GCC can do it's just a bit more verbose typing. Must be me I actually don't get the attraction to the language but continuing on we will see if it grows on me. Anyhow just working on the output code conversion now.

I would also suggest you look at Microsoft Opensource project Pyjion which is interesting.
https://github.com/Microsoft/Pyjion
Last edited by LdB on Mon Aug 28, 2017 5:46 pm, edited 1 time in total.

hippy
Posts: 2343
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: What are situations to use bare metal when python is so much easier?

Mon Aug 28, 2017 5:36 pm

LdB wrote:
Mon Aug 28, 2017 3:11 pm
So let me check we are talking about running it on Cython API aren't you.
I have no idea. I know nothing about Cython API, linux pthreads, nor have any care whether it supports 64-bit, though it really needs to run on any Pi SoC, particularly the Zero W.

All I want is a Python environment which can be booted on the Pi, just like MicroPython is for the micro:bit and PyBoard, which can run Python code. I don't really mind how it does things under the hood. If it only runs on one core that will be good enough for most people.

One could say MicroPython exists so all that needs to be done is provide a means to initialise the Pi from boot, then call MicroPython's main() and everything's done - though one needs to provide a few bare metal routines so it can actually do something useful. Package that up as a kernel.img and sorted.

Of course the bigger challenge is in providing the libraries and any bare metal code needed to interface to the Pi hardware. And I'm sure there will be some unexpected issues and difficulties which will crop up along the way.

LdB
Posts: 582
Joined: Wed Dec 07, 2016 2:29 pm

Re: What are situations to use bare metal when python is so much easier?

Mon Aug 28, 2017 6:17 pm

This is where you lost me, the only bits of python that is really good seems to be the bits that don't seem to interest you from that comment?

Do you know you can start the Pi with exactly one line of code in C or Ultibo because we provided you the bootstub which sounds like all you want. I am going to give you a console in python the same way as I do in baremetal but everything else will still be dead SD card, USB etc.

Just to make sure I am not wasting my time, if you look at my repo example I have a console running lets say this one. Look at the image display at bottom.
https://github.com/LdB-ECM/Raspberry-Pi ... m32_64_USB

The whole pickup of the CPU and the cores etc is all done for you, it occurs in an assembler file smartstart32.s for 32 bit and smartstart64.s for 64 bit. If you go back to stefan's site ( https://www.stefannaumann.de/en/2017/05 ... pberry-pi/) his bootstub loader was two lines of code in startup_rpi.s and hence it does nothing.

So all I am doing is going to get the python interpreter running which is dead easy (and stefan managed that) and connect it to the assembler code stub. So you can spit stuff to the screen but you can't type or anything because you have no USB and therefore no keyboard. To some degree you are then on your own and I strongly doubt you will ever get much more running because of the complexity.

It was pretty trivial for me because I work in C so compiling the python interpreter source was no issue and I can just connect it to my assembler stub and the only reason I said if you wanted it I will do it.

It just seems strange that if all you want to do is smack a few GPIO port lines you would rather go thru this whole process rather than learn a few lines of Pascal or C. The big advantage is you can use all the code out there which can do so much more. On python you are stuck to what you can work out and most will be not doable without a baremetal stub anyhow.

The other really easy option would be a Python to C++ or Python to Pascal conversion which already exist because python is such a simple language. Since it appears most of the difficult python stuff is not what interests you.

Anyhow happy to do it if you want it still but don't expect miracles from it as it will just be a python interpreter over a baremetal stub.

hippy
Posts: 2343
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: What are situations to use bare metal when python is so much easier?

Mon Aug 28, 2017 7:11 pm

LdB wrote:
Mon Aug 28, 2017 6:17 pm
This is where you lost me, the only bits of python that is really good seems to be the bits that don't seem to interest you from that comment?
The only thing I am interested in is having a bootable Python environment, with the ability to interact with some, preferably all, of the Pi hardware. Basically that I can run my Python code with that just as I would under Linux but without having Linux. Similar to how the micro:bit and PyBoard work. Like the BBC Micro did but booting to a Python environment rather than Basic.

I'm not particularly interested in the creation of that or how it's done; I simply want to have it, would find it useful to have.
LdB wrote:
Mon Aug 28, 2017 6:17 pm
So all I am doing is going to get the python interpreter running which is dead easy (and stefan managed that) and connect it to the assembler code stub. So you can spit stuff to the screen but you can't type or anything because you have no USB and therefore no keyboard. To some degree you are then on your own and I strongly doubt you will ever get much more running because of the complexity.
It works on the micro:bit, it works on the PyBoard, works on other boards, so I guess the limitation is how much effort people are prepared to put in to making it work.

Stefan used a UART for input and output because having that and having the REPL work is pretty much the starting point for going further.

I personally wouldn't call any bootable Python useful on a Pi until it had a screen display, was taking input from a USB keyboard, was able to access and use a file system on SD card, and could communicate with the outside world through a network stack. That has to come and there will be a good deal of effort in achieving that.

Stefan's started on the road towards that but hasn't got far. If you think you can contribute usefully then it would be welcomed, but if not that's not a problem.

User avatar
Gavinmc42
Posts: 1549
Joined: Wed Aug 28, 2013 3:31 am

Re: What are situations to use bare metal when python is so much easier?

Tue Aug 29, 2017 1:48 am

Gavinmc42 wrote: ↑
Mon Aug 28, 2017 2:26 pm
But if you do code in C on Pi's you need to consider that OS called Linux that thinks it is in charge.

Gavin I write in C baremetal all the time and never go near linux, you lost me with this statement? Or where you talking about people coding C on linux and it is just worded strang
e.

I was just comparing Python/Linux against C/Linux, not C baremetal, and yes I do look at your C code to see how you do things ;)
One day I hope to understand it all :oops:
I can read C much easier than any other language, I just choose not to use it so I can expand my brain and skill set.

Baremetal Python is an interesting idea and someone will do it, probably based on C compiled interpreter and a Hardware Abstraction Layer.
There is now enough hardware source code for USB, GPIO, Framebuffer etc for this to be ported, C and Pascal.

Script interpreters on baremetal is something we have talked about on the Ultibo forum.
Probably because it is easier to do this in FPC because it is taking stuff already done in the PC world and Ultibo compiles it and sometimes it just works. That has more to do with the Free Pascal creed of compile everywhere and the cleanness of the source, none of that register reading writing assembly mess. But you can still do inline assembler in FPC if you want too.

There is a FPC Lua interpreter , someone could do a Micropython one in Ultibo, all the low level hardware stuff and framebuffer already works.
Ultibo could turn into a script interpreter engine for any language. If a non pro-coder like me can make shell extensions then anything could be done. A full BASH command language running on Ultibo? Why? because we can :lol:
A DOS look alike could even be done, "dir" is just an alias for "ls" etc. If Ultibo can make a kernel.img that takes commands like DOS or BASH what is it?

I have never written for Linux at Kernel/OS level and I will never understand it in detail, it is just too big.
Yet I can see how even I can now make an OS with baremetal.
And of course Ultibo is FPC and has native multicore features, I could make a multicore OS and not even need to know anything about registers. That is more than just baremetal, it is something else?

Why use baremetal? Because we can. :ugeek:
With Ultibo QEMU you don't even need any metal now :lol:
Micropython on Ultibo QEMU on anything that runs QEMU? :shock:

Baremetal VCOS/EGL, yep progress is getting made and there is a forum thread on baremetal camera.
Hanging out waiting for the Ultibo 64bit stuff to be complete, then NEON can be used faster and we can skip those VPU/QPU's.

Even though we have a good Idea on most of the VC4 registers now, we still don't know everything and lack of example code restricts use of things like hardware VG/Scalers. So we have to use Linux, Blobs and Python etc.
More clues will appear as Eric backports from VC5?
That is just the graphics stuff, but camera ISP etc, I keep getting told it's too hard, it' s 500 man years.
Every one needs a hobby in retirement :lol:

But I am preaching to the converted, you guys know this anyway.
Some noob might find this post and be inspired :P
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

dwelch67
Posts: 843
Joined: Sat May 26, 2012 5:32 pm

Re: What are situations to use bare metal when python is so much easier?

Tue Aug 29, 2017 3:06 am

asdf
Last edited by dwelch67 on Tue Aug 29, 2017 4:23 am, edited 1 time in total.

LdB
Posts: 582
Joined: Wed Dec 07, 2016 2:29 pm

Re: What are situations to use bare metal when python is so much easier?

Tue Aug 29, 2017 3:36 am

hippy wrote:
Mon Aug 28, 2017 7:11 pm
I personally wouldn't call any bootable Python useful on a Pi until it had a screen display, was taking input from a USB keyboard, was able to access and use a file system on SD card, and could communicate with the outside world through a network stack. That has to come and there will be a good deal of effort in achieving that.
So long as you realize most of that will have to be baremetal and that is the point for this to move on you need people who can baremetal. You aren't going to be able to leverage python code and programmers.
hippy wrote:
Mon Aug 28, 2017 7:11 pm
Stefan's started on the road towards that but hasn't got far. If you think you can contribute usefully then it would be welcomed, but if not that's not a problem.
It really isn't a big deal for me it's an interpreter which the code already exists in C sitting on a baremetal stub it's just not very exciting. I have the SD, USB, Keyboard, Video and Ethernet working but I am not at this stage committing to add them to the python libraries because that I suspect will require a lot more effort than I am prepared to do.

LdB
Posts: 582
Joined: Wed Dec 07, 2016 2:29 pm

Re: What are situations to use bare metal when python is so much easier?

Tue Aug 29, 2017 3:54 am

Gavinmc42 wrote:
Tue Aug 29, 2017 1:48 am
There is a FPC Lua interpreter , someone could do a Micropython one in Ultibo, all the low level hardware stuff and framebuffer already works.
Ultibo could turn into a script interpreter engine for any language. If a non pro-coder like me can make shell extensions then anything could be done. A full BASH command language running on Ultibo? Why? because we can :lol:
If you have direct contact with Ultibo there is a group working with python on FreePascal and have everything running, could the work be ported easily?
Gavinmc42 wrote:
Tue Aug 29, 2017 1:48 am
And of course Ultibo is FPC and has native multicore features,
For MicroPython that would actually be a problem because they haven't sorted that mess out yet. I suspect on an Ultibo port you would be better off going for full python. The question would be is that more work than anyone was prepared to do.
Gavinmc42 wrote:
Tue Aug 29, 2017 1:48 am
Baremetal VCOS/EGL, yep progress is getting made and there is a forum thread on baremetal camera.
Hanging out waiting for the Ultibo 64bit stuff to be complete, then NEON can be used faster and we can skip those VPU/QPU's.
Yeah I was surprised you guys hadn't got that running in your release yet. I looked at actually helping you doing it on Ultibo but I don't understand the multicore task switcher and I realized I have to connect it somehow.

Return to “Bare metal”

Who is online

Users browsing this forum: No registered users and 8 guests