Arduino compatible platform for a simple multitasking os?

Hi,

So a few years ago I wanted to create a OS that can multitask the way modern operating systems do.
Now, back then it didn't work out as I had too luttle knowledge.
So now I want to try again, and to start, I have a question:
I am looking for a board that can be programmed by arduino software, and doesn't already run an os or has an os layer around it.(so no rtos or something)
It also needs to be able to jump the execution address in ram, so programs need to be able to load in ram, and I should be able to jump to it and start executing it.
This is required to jump between programs, that are loaded from sd card.

Or is above not needed for a preemtive multitasking os like linux has?
Eitherway, I need to be able to run multiple, seperately loaded and compiled programs.(created with the arduino ide as hex or bin)

Anyone know something like that?

Thanks

And is this the correct subforum to post this? If not, please move this to the correct location.

leds_are_cool:
Eitherway, I need to be able to run multiple, seperately loaded and compiled programs.(created with the arduino ide as hex or bin)

Why?

The strength of the Arduino is that it does not need an operating system that might interfere with real-time computing. And with only 2k of SRAM on an Uno (8k on a Mega) the scope for several programs plus an over-arching operating system is rather limited.

And the Arduino IDE is designed for uploading a single program that overwrites any existing code.

There is no reason in principle why you could not write an operating system from the ground up for a Raspberry Pi or even for a laptop.

...R

multitask the way modern operating systems

modern! ROFL etc

Setting a system so that many programs could be run at the same time started in the 1950's

Mark

You need to take a look at the architecture of the AVR chip, which is Harvard. This means it has a separate bus to access program memory versus data memory. Program memory == Flash, data memory == RAM. The architecture does not allow for program execution from RAM.

This is consistent for most MCUs (stored program in flash) as opposed to devices such as Pi and PCs which load their OS from storage on power up and execute from RAM.

Arduino programs think they have complete control over the hardware. If you have an OS that will accept multiple programs then those programs are, by definition, NOT Arduino programs.

The Due and Teensy 3.x processors have the hardware instructions necessary for multitasking. Libraries exist for this. Start by looking at the official Scheduler library.

DKWatson:
You need to take a look at the architecture of the AVR chip, which is Harvard. This means it has a separate bus to access program memory versus data memory. Program memory == Flash, data memory == RAM. The architecture does not allow for program execution from RAM.

This is consistent for most MCUs (stored program in flash) as opposed to devices such as Pi and PCs which load their OS from storage on power up and execute from RAM.

yeah, I know. I was mostly looking in the DUE and other arm things direction.
I believe I need the Von-neuman(or something like that) architecture thingy.(ARM?)

MorganS:
Arduino programs think they have complete control over the hardware. If you have an OS that will accept multiple programs then those programs are, by definition, NOT Arduino programs.

The Due and Teensy 3.x processors have the hardware instructions necessary for multitasking. Libraries exist for this. Start by looking at the official Scheduler library.

Thanks, I'll take a look at it.

edit:
Sheduler is cooperative, that is not what I want. I want preemptive.
My intent is not to keep the real time feature, I want to create a simple os, no need for complicated real time timing features.(Yet anyways)

leds_are_cool:
Sheduler is cooperative, that is not what I want. I want preemptive.
My intent is not to keep the real time feature, I want to create a simple os, no need for complicated real time timing features.(Yet anyways)

If this is for the fun of doing it then fine - I'm all in favour of that sort of pastime.

If you actually want a useful OS to allow you to do something useful then get a RaspberryPi or BeagleBone with Linux. Or just a cheap laptop.

...R

If you don't care about true real-time, then use a RPi, Beaglebone or other Linux-based board. You get a development environment that is 100X better (even MS VisualStudio), and mountains of existing code to build your applications in a fraction of the time than you will with Arduino and a home-grown task-switcher. You'll also have 500X more memory, and 100X more CPU power. You'll be miles ahead unless you value you time at $0.0000001/hour.

Regards,
Ray L.

If it is for education, buy a book on how to design operating systems.

I would start with the low-level drivers that will allow 2 tasks to access the SD card. Then try to extend that to all SPI devices.

RayLivingston:
If you don't care about true real-time, then use a RPi, Beaglebone or other Linux-based board. You get a development environment that is 100X better (even MS VisualStudio), and mountains of existing code to build your applications in a fraction of the time than you will with Arduino and a home-grown task-switcher. You'll also have 500X more memory, and 100X more CPU power. You'll be miles ahead unless you value you time at $0.0000001/hour.

Regards,
Ray L.

My intent is not to use it, it is just so I have to do something in the summer. The reason I choose an Arduino(ish) board is because it isn't meant to run an OS, which makes it more fun as I would need to do research on it and all.
I am aware I can just use a Raspberry Pi with Linux, or even roll my own OS for it. But it isn't as fun.

Would the arduino DUE work for loading whole programs into memory and executing them?(since it's arm I believe)

Von Neumann (aka Princeton) vs Harvard architecture only describes a bus structure. The internal architecture must be such that the load to processor comes from RAM, with the AVR it does not (same as most).

As to the other issue, in spite of what you read, which is mostly hype and propaganda, there is NO SUCH THING as a real-time operating system. By definition it's a hardware abstraction layer that offers near-real-time performance. You want to play with freeRTOS that's fine, maybe on a GHz processor you'll get performance in line with embedded Linux. You also give up access to the timers and interrupt, the OS controls all that now. Even in a preemptive mode, you're still running a time-sliced multi-tasking OS. For what you want to do, and probably for 92% (remember the bit about statistics) of cases it's okay. If, however, you're every asked to develop mission critical code, it's not allowed (or malloc or function pointers for that matter).

Now, if you persist (the young are stubborn), I would suggest you take a look at RIOS. That's the Riverdale-Irving OS which is really just a task scheduler with some nice features. It can be used in either collaborative or preemptive modes and is written in about 25 lines of C.

BTW, I have an article that I'll try to find and post, but the general idea was they faced off three boards, Uno a Pi and some Linux unit, and tasked each to produce as high a frequency as possible that still 'looked' like a square wave on a scope. The Pi and Linux units hit a wall around 1MHz. The Uno - 3.4MHz.

For the summer! You have I idea what is required to create even a simple OS do you.

Mark

holmes4:
For the summer! You have I idea what is required to create even a simple OS do you.

I suspect even this piece would take more than a summer ...

MorganS:
I would start with the low-level drivers that will allow 2 tasks to access the SD card. Then try to extend that to all SPI devices.

But, as I said earlier, it would make a fine pastime.

...R

DKWatson:
BTW, I have an article that I'll try to find and post, but the general idea was they faced off three boards, Uno a Pi and some Linux unit, and tasked each to produce as high a frequency as possible that still 'looked' like a square wave on a scope. The Pi and Linux units hit a wall around 1MHz. The Uno - 3.4MHz.

Look into PiFM, it generates an FM signal upto 300MHZ. Bit faster then what you said.
I'll check out RIOS.

MorganS:
If it is for education, buy a book on how to design operating systems.

I would start with the low-level drivers that will allow 2 tasks to access the SD card. Then try to extend that to all SPI devices.

I have already created a simple layer to acces SD cards, I would simply have to make it a process/thread too. So stuff doesn't get mangled.
But I don't have a board to start developing anything yet...

Robin2:
I suspect even this piece would take more than a summer ...
But, as I said earlier, it would make a fine pastime.

...R

holmes4:
For the summer! You have I idea what is required to create even a simple OS do you.

Mark

I am pretty much aware what it takes to create an OS, how would you know how long it would take? Maybe all I want is 2 tasks saying "Hello World!" at the same time and seeing it mixing the characters into one sentence...
But I do want a bit more than that.
You seem to make the mistake that I want to create a full fledged Linux like OS, but all I want is 2 seperately compiled apps to run on a SOC/MCU at the same time.(well, preemptive)
That should be possible as far as I am aware.

But I intend to start simpler, yes.(Hollidays is 6 weeks :wink: )

If you think I will fail/get into problems. Help me avoid them, give me advice.(other then "Is gonna take long time..")

Sorry, PiFM uses an on-board peripheral to generate spread-spectrum RF clock signals. We could attach the same peripheral to any device with the same results, a somewhat meaningless comparison. The test involved nothing but software to toggle an IO pin, similar to how an underlying OS would handle quasi-real-time requests.

http://www.riosscheduler.org/

I am looking for a board that can be programmed by arduino software, and doesn't already run an os or has an os layer around it.(so no rtos or something)
It also needs to be able to jump the execution address in ram

Any of the ARM-based Arduinos should be able to do this; certainly anything with a CM3 or better.
I'd recommend Course | edX for leading you through some of the steps needed to get multitasking working on an ARM. (The class is long over and closed; I'm not sure if you can still "register" review the archived content.)
They used TI ARM Launchpads (which do run Arduino SW via "Energia")

Adafruit SAMD21 Datalogger has the same ARM CPU as the Arduino Zero, and has a built-in SD card. Several Adafruit SAMD21 and SAMD51 boards have a built-in 2MB SPI flash...

ESP32 runs FreeRTOS and the Arduino sketch runs as a FreeRTOS thread. The Arduino sketch can call the underlying FreeRTOS APIs so, for example, it can start FreeRTOS threads.

Loading code from an SD card and executing, I do not know. Maybe with a lot of extra work.

leds_are_cool:
I am pretty much aware what it takes to create an OS, how would you know how long it would take? Maybe all I want is 2 tasks saying "Hello World!" at the same time and seeing it mixing the characters into one sentence...
But I do want a bit more than that.

You have to realize that for most people reading this Thread OS does mean Linux or Windows.

If you mean something radically simpler then you need to explain what you want in detail if we are to be on the same wavelength.

My concept of "multi-tasking" on an Arduino is encapsulated in the demo Several Things at a Time

I can conceive of that being broken up into a few separate pieces - one for each function with the code in loop() being the "operating system". And I can conceive of writing an alternative bootloader that would allow each piece to be loaded separately.

I can also envisage all sorts of complications getting that piece-by-piece system to work - but perhaps they can be overcome.

Maybe using that as a model you can more clearly explain what you have in your mind?

...R

DKWatson:
Sorry, PiFM uses an on-board peripheral to generate spread-spectrum RF clock signals. We could attach the same peripheral to any device with the same results, a somewhat meaningless comparison. The test involved nothing but software to toggle an IO pin, similar to how an underlying OS would handle quasi-real-time requests.

http://www.riosscheduler.org/

Interesting, didn't know that.

westfw:
Any of the ARM-based Arduinos should be able to do this; certainly anything with a CM3 or better.
I'd recommend Course | edX for leading you through some of the steps needed to get multitasking working on an ARM. (The class is long over and closed; I'm not sure if you can still "register" review the archived content.)
They used TI ARM Launchpads (which do run Arduino SW via "Energia")

Adafruit SAMD21 Datalogger has the same ARM CPU as the Arduino Zero, and has a built-in SD card. Several Adafruit SAMD21 and SAMD51 boards have a built-in 2MB SPI flash...

Okay, thanks. I'll take the DUE then as I already have one here.
I don't have access to that document, but I'll try to register.

gdsports:
ESP32 runs FreeRTOS and the Arduino sketch runs as a FreeRTOS thread. The Arduino sketch can call the underlying FreeRTOS APIs so, for example, it can start FreeRTOS threads.

ESP32 Arduino: Using FreeRTOS functions - techtutorialsx
ESP32 Arduino: Creating a FreeRTOS task - techtutorialsx

Loading code from an SD card and executing, I do not know. Maybe with a lot of extra work.

ESP32 would be very interesting as it has 2 cores, but the problem with it is that as far as I know it is not able to jymp memory addresses and execute code from memory. That is something I would need.
I'll go and experiment with the ESP32 though, it's a fun little(powerfull) board.

Robin2:
You have to realize that for most people reading this Thread OS does mean Linux or Windows.

If you mean something radically simpler then you need to explain what you want in detail if we are to be on the same wavelength.

My concept of "multi-tasking" on an Arduino is encapsulated in the demo Several Things at a Time

I can conceive of that being broken up into a few separate pieces - one for each function with the code in loop() being the "operating system". And I can conceive of writing an alternative bootloader that would allow each piece to be loaded separately.

I can also envisage all sorts of complications getting that piece-by-piece system to work - but perhaps they can be overcome.

Maybe using that as a model you can more clearly explain what you have in your mind?

...R

I don't see how I have to explain what I want in detail, all I want is executing 2 programs preemptive from memory, and I am looking for a good board that supports it.
I never mentioned I want to run windows or Linux on an Arduino.

The reason I am not going with your multiple things at the same time thing, is because it doesn't work for me.
I want to be able to run functions that block, or take long, without modifying them to run into steps. That is why I want something that multi-tasks preemptively.