RPi version without underlying O.S.?
I have been reading many web pages and info on BBC Basic, and sorting out old info from current info.
I saw that there is a version of BBC Basic that runs on an RPi Pico.
That leads to my question: Is there a version of BBC Basic that runs on an RPi, (e.g. RPi 3B+), WITHOUT running on top of the RPi O.S.?
The version that runs on the Pico, I suspect, is running right on the base hardware, without any O.S.
So, the question is, does a similar version exist for the other RPi’s?
The follow-on question is: If that version exists, can it be compiled, and not run through an interpreter?
The project in mind would require some basic I/O pin bit-banging at a high speed, ideally interrupt driven from a Timer module, for relatively precisely timed interrupts, (+/- the small amount of jitter from finishing the current instruction prior to entering the ISR). Ideally the interrupt rate would be firing at 10 M interrupts / sec. On a 1.2 GHz clock, dual core, micro, (RPi 3B+), that would give one about 120 clock cycles for the bit-banged I/O per interrupt, on one of the two cores. I realize that this core would be running almost completely in the ISRs, with very little foreground processing, (but the other core could handle the User I/O, HW setup, and control of the core dedicated to the fast ISR operations).
Clearly this cannot be done on an RPi running its OS, as Linux wasn’t designed for real-time microcontroller data processing. Its real world ISR rates, (per on-line discussions), tops out at about 10 K Interrupts / Sec, even though the core is running with a clock rate in excess of 1 GHz.
I’ve used Bascom Basic and ZBasic on (Microchip) AVR microcontrollers, but their maximum clock is 32 MHz on the Xmega series. That lead to my looking into “bare metal programming” on an ARM. It has been years since I did any ASM programming, (Intel 8080 days…), and I like programming in Basic.
That, therefore, is what lead me to wonder if there was a BBC Basic RPi version, (like that that runs on the Pico), that runs on the other RPi’s, without an OS? (And, ideally, compiled, not interpreted).
I’m likely dreaming… But I at least wanted to ask if such a version exists, or if it was on any of the developer’s future projects list?
Thank you,
JC
RPi version without underlying O.S.?
-
- Posts: 2
- Joined: Thu 04 Jul 2024, 09:03
Re: RPi version without underlying O.S.?
Pico is the closest you'll get, however it's not true that it's not running without an OS, it is running on top of a version of RISC OS that has been adapted for the RPi. Even the "full fat" RISC OS distribution has the same capability after a few *CONFIGURE commands.
To access the GPIO, you need the GPIO module as it isn't shipped with RISC OS for the RPi. You can get this from here http://www.tankstage.co.uk/software.html and there's a thread on RiscOSOpen here https://www.riscosopen.org/forum/forums/5/topics/1445 that's also well worth a read. If you're running outside of the RISC OS desktop, BASIC will be single-tasking with only interrupts, no true multitasking is happening.
To access the GPIO, you need the GPIO module as it isn't shipped with RISC OS for the RPi. You can get this from here http://www.tankstage.co.uk/software.html and there's a thread on RiscOSOpen here https://www.riscosopen.org/forum/forums/5/topics/1445 that's also well worth a read. If you're running outside of the RISC OS desktop, BASIC will be single-tasking with only interrupts, no true multitasking is happening.
-
- Posts: 272
- Joined: Tue 18 Jun 2024, 09:32
Re: RPi version without underlying O.S.?
Not that I'm aware of. If there is I would expect it to be derived from the RISC OS version, which is probably closer to the bare metal.
To get the kind of graphics performance that the Pi OS (SDL2) version provides one would have to leverage the GPU, and I wouldn't have a clue how to do that without OpenGL.
Strictly speaking BBC BASIC cannot be compiled, there are language features that make that impossible. I know that there are / have been 'BBC BASIC compilers' but they all restrict you to only a subset of the language. Unless you're doing 'raw computation' (e.g. some numerical calculation) most programs are input/output bound so the speed of the language is of little importance.The follow-on question is: If that version exists, can it be compiled, and not run through an interpreter?
When I've written similar programs, all the time-critical code has been in assembly language. Back in the day, hybrid BASIC / assembler programs were a favourite of mine; it's how I coded Free-D (real-time camera tracking) in BBC BASIC.The project in mind would require some basic I/O pin bit-banging at a high speed, ideally interrupt driven from a Timer module,
I know virtually nothing about Linux, I'm a dyed-in-the-wool Windows programmer. With that OS one can play with process/thread priorities to enable real-time assembler code to run without the OS getting in the way (with a multi-core CPU anyway). Free-D takes in HD video, processes the image, and outputs the camera parameters with only a one-frame delay. It has to be 100% reliable because it might be driving a live TV (virtual) studio.Clearly this cannot be done on an RPi running its OS, as Linux wasn’t designed for real-time microcontroller data processing.
-
- Posts: 272
- Joined: Tue 18 Jun 2024, 09:32
Re: RPi version without underlying O.S.?
There's potential for confusion between 'RISC OS Pico' and the 'Raspberry Pi Pico' which are completely unrelated. To me (and I think the OP) 'Pico' refers to the Raspberry Pi Pico, on which BBC BASIC indeed runs 'without a (conventional) OS'.
-
- Posts: 2
- Joined: Thu 04 Jul 2024, 09:03
Re: RPi version without underlying O.S.?
Fair enough - I completely forgot about that variant. However, OP did ask about running BASIC without an OS on the "regular" Pi types, which, the closest to bare metal is RISC OS, and my module suggestions stand for talking to the GPIO via BASIC. While not entirely without an OS, it comes with far lower overhead than running under Linux.Richard Russell wrote: ↑Sun 03 Nov 2024, 23:12There's potential for confusion between 'RISC OS Pico' and the 'Raspberry Pi Pico' which are completely unrelated. To me (and I think the OP) 'Pico' refers to the Raspberry Pi Pico, on which BBC BASIC indeed runs 'without a (conventional) OS'.
-
- Posts: 272
- Joined: Tue 18 Jun 2024, 09:32
Re: RPi version without underlying O.S.?
That's probably true if by "overhead" you mean memory usage, but I wouldn't expect it to follow that interrupt-driven assembler code (for example) would suffer any greater latency under Linux than under RISC OS, particularly if you can effectively dedicate a CPU core to it.
The Raspberry Pi Pico, albeit having entirely different hardware and a significantly different CPU, is a good model for how BBC BASIC can be run without any OS at all, with an entire core dedicated to generating real-time stereo sound (in the case of the console version) or VGA-compatible video (in the case of the GUI version).
If suitable drivers (for the required I/O) are available for a Raspberry Pi I would expect it to be significantly easier to build a bare-metal version of BBC BASIC from the sources used for the RPi Pico version than those for any RISC OS version.
I believe they don't work on the latest model (Raspberry Pi 5) on which the GPIO uses a separate chip.my module suggestions stand for talking to the GPIO via BASIC.
-
- Posts: 272
- Joined: Tue 18 Jun 2024, 09:32
Re: RPi version without underlying O.S.?
Potentially the Raspberry Pi 5 could be less-than-ideal for the OP's application, because its GPIO is, I believe, driven via an I²C link to the new chip, and can therefore suffer a greater latency than was the case with the earlier models on which the GPIO was fed from the main SoC silicon.Richard Russell wrote: ↑Sun 03 Nov 2024, 23:38 I believe they don't work on the latest model (Raspberry Pi 5) on which the GPIO uses a separate chip.
-
- Posts: 2
- Joined: Sun 03 Nov 2024, 20:44
Re: RPi version without underlying O.S.?
Hello everyone,
Thank you for your interest and comments.
I only mentioned the RPi Pico as an example of a microcontroller with a version of BBC Basic that runs on the raw microcontroller HW without an O.S.
The hope was that there was a similar version of BBC Basic that would run on one of the (much) faster RPi's, (clocked at 1+ GHz), again without an O.S.
JC
Thank you for your interest and comments.
I only mentioned the RPi Pico as an example of a microcontroller with a version of BBC Basic that runs on the raw microcontroller HW without an O.S.
The hope was that there was a similar version of BBC Basic that would run on one of the (much) faster RPi's, (clocked at 1+ GHz), again without an O.S.
JC
-
- Posts: 272
- Joined: Tue 18 Jun 2024, 09:32
Re: RPi version without underlying O.S.?
Would you consider creating such a thing yourself? The information you would need seems to be readily available online, for example the YouTube series below, and in conjunction with the source code of the Raspberry Pi Pico edition of BBC BASIC perhaps it wouldn't be too difficult.