Author Topic: Embedded ARM OS options?  (Read 6048 times)

0 Members and 1 Guest are viewing this topic.

Offline bd139Topic starter

  • Super Contributor
  • ***
  • Posts: 23055
  • Country: gb
Embedded ARM OS options?
« on: February 14, 2018, 10:14:39 am »
Currently working on a prototype for a medium complexity mixed mode analogue and digital device. This is based around the PSoC 6 / Cortex M4. I have considerably underestimated the complexity of trying to build something with an event loop on a single thread as I have several peripherals and subsystems to control at the same time. Three of these are isolated. I hit a wall trying to add a serial port to it so I can control the device from a host machine. How do I talk to all the functions? Architectural fail. Start again.

This brings me into the world of operating systems. Are there any "easy to roll", "very light weight" and "license free" tiny operating systems for ARM Cortex M4? All I need to do is run about 10-12 "tasks" which have static memory allocation and are event based (interrupt or timer driven). These will communicate via shared memory or FIFO if the OS allows that abstraction. Ergo I really need a preemptable scheduler with safe communication primitives. Real time guarantees aren't required for this; it's noddy user interface functions. I can possibly build something using setjmp in C and manual preemption wrapped in a header library (I have done this in the distant past) but I'd like to avoid that mess and go for a clean abstraction.

Before anyone suggests it, Linux is way too heavy. There is no budget to import something commercial.

Edit: just a note, kicking it back down to another core is a possibility. It's all hanging off a PSoC 4 board at the moment. I'm actually doing most of the work in C on a Linux VM at the moment just to see how it fits together. There is no actual target device yet :)
« Last Edit: February 14, 2018, 10:26:24 am by bd139 »
 

Offline chickenHeadKnob

  • Super Contributor
  • ***
  • Posts: 1059
  • Country: ca
Re: Embedded ARM OS options?
« Reply #1 on: February 14, 2018, 10:48:52 am »
I'm not a PSOC person but I believe FreeRtos has been ported to the psoc5. It will do everything you need (and more but only is you need it)
 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: Embedded ARM OS options?
« Reply #2 on: February 14, 2018, 10:49:25 am »
There's more RTOSes for ARM than stars in the sky. ARM have their own CMSIS-RTX (based on Keil's RTX, Apache license). FreeRTOS is popular (modified GPL), though its API is butt-ugly IMO.

Offline bd139Topic starter

  • Super Contributor
  • ***
  • Posts: 23055
  • Country: gb
Re: Embedded ARM OS options?
« Reply #3 on: February 14, 2018, 10:51:59 am »
Thanks will have a look at these. I've looked at FreeRTOS already and it's a possibility but I agree the API is ugly.

PSoC to me here is just a standard ARM core with some funky shit around the edges that make me not have to add a few opamps to the BOM on this :)
 

Offline jeremy

  • Super Contributor
  • ***
  • Posts: 1079
  • Country: au
Re: Embedded ARM OS options?
« Reply #4 on: February 14, 2018, 10:58:11 am »
The good thing about freertos is that it is ridiculously battle tested and stable (IMO), and can also be 100% statically allocated if need be. It also doesn’t force you to use a whole bunch of libraries you don’t need, and doesn’t force you to use a specific build tool (I’m looking at you, mbed...)

You can also run it on a PC for testing.

I’ve seen better APIs, but I’m not sure I’d go so far as saying the freertos one is “ugly”.

Edit: also interesting you are using the PSoC 6, I wasn’t aware they were really on the market yet other than dev kits.
« Last Edit: February 14, 2018, 11:00:01 am by jeremy »
 

Offline bd139Topic starter

  • Super Contributor
  • ***
  • Posts: 23055
  • Country: gb
Re: Embedded ARM OS options?
« Reply #5 on: February 14, 2018, 11:02:26 am »
Not using yet. Awaiting dev kit availability. The target design will likely be PSoC 6 but I'm using a PSoC 4 kit at the moment hooked up into the rig. All the software is running on a desktop machine poking it. I'm really awaiting the final pricing of PSoC 6 ICs before I commit to it.
 

Offline Berni

  • Super Contributor
  • ***
  • Posts: 5012
  • Country: si
Re: Embedded ARM OS options?
« Reply #6 on: February 14, 2018, 11:17:22 am »
Yep freeRTOS is the way to go. Its free, very well tested and doesn't bring a bunch of crap you probably don't need.

As for the API being ugly that's likely due to one of these high reliability coding standards it tries to conform to. Somehow things like this are supposed to prevent programmers from making silly bug or at least make it less often. In reality it probably just makes code harder to read.
 

Offline bd139Topic starter

  • Super Contributor
  • ***
  • Posts: 23055
  • Country: gb
Re: Embedded ARM OS options?
« Reply #7 on: February 14, 2018, 11:19:55 am »
Fair points. Thanks all. Will look at FreeRTOS in depth.

I'll do a hello world on Linux then I will attempt to get it to target my PSoC dev board and see where I get to. I have an encoder and Si570 synthesizer hooked up so if I can get it to set that by end of March and read/set it via serial port / SCPI i'll be happy :)
 

Offline enz

  • Regular Contributor
  • *
  • Posts: 134
  • Country: de
Re: Embedded ARM OS options?
« Reply #8 on: February 14, 2018, 11:38:06 am »
If you are looking for a simple, but stable, RTOS and don't mind C++, than scmRTOS (https://github.com/scmrtos) could be an attractive alternative. Comes with an MIT license.

I have used it in a couple of projects with a Cortex-M0 and it did work very well and was easy to use.

It doesn't come with a lot of features, nor with a HAL. But this is an advantage in my opinion.

Best regards,
Martin
 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: Embedded ARM OS options?
« Reply #9 on: February 14, 2018, 01:25:49 pm »
Correction to what I wrote above: after Amazon bought FreeRTOS, its license was changed to MIT from the previous GPL with linking exception.

Offline mac.6

  • Regular Contributor
  • *
  • Posts: 226
  • Country: fr
Re: Embedded ARM OS options?
« Reply #10 on: February 14, 2018, 01:26:51 pm »
freeRTOS, as it's basically ported everywhere, works quite fine (minus some quirks between ports), and is not anymore encumbered with GPL as v10 is now MIT.
 

Offline bd139Topic starter

  • Super Contributor
  • ***
  • Posts: 23055
  • Country: gb
Re: Embedded ARM OS options?
« Reply #11 on: February 14, 2018, 02:07:38 pm »
Thanks for the further replies everyone - much appreciated.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3295
  • Country: gb
Re: Embedded ARM OS options?
« Reply #12 on: February 14, 2018, 05:23:16 pm »
Another vote for FreeRTOS here.  It might not be the perfect RTOS but it's mature and reliable and so widely used that any issues you come across are likely to have been solved before.

Setting the appropriate interrupt priority threshold for RTOS and non-RTOS calling interrupts made my head hurt a bit the first time I used it due to the upside down Cortex priority levels, but once you understand how that works it's pretty straight forward.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5360
  • Country: gb
Re: Embedded ARM OS options?
« Reply #13 on: February 14, 2018, 05:41:47 pm »
Correction to what I wrote above: after Amazon bought FreeRTOS, its license was changed to MIT from the previous GPL with linking exception.

Amazon buying FreeRTOS, how did I miss that? I sincerely hope Richard Barry has made a good few quid out of that deal, he deserves it for the quality engineering and dedication he’s put into it over the years, and particularly because it’s been, well, free for most of us. I often wondered what his business model was, ie, were there enough companies buying the paid-for options, for example.

At least Amazon is hardware agnostic in this space, or at least I’d imagine they are. It would’ve been frustrating had one of the microcontroller manufacturers bought it, and the innevitable loss of ongoing support that would go with that.

I agree that the API is a bit of a mindset thing: it’s not that it’s messy, it’s just a bit of a hill to climb.
 

Offline bd139Topic starter

  • Super Contributor
  • ***
  • Posts: 23055
  • Country: gb
Re: Embedded ARM OS options?
« Reply #14 on: February 14, 2018, 05:56:04 pm »
Climbing hard now :)

I picked another target to play with that I have already floating around that works out of box (pic24+mplab)
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 895
  • Country: us
Re: Embedded ARM OS options?
« Reply #15 on: February 14, 2018, 06:16:21 pm »
ARM have their own CMSIS-RTX (based on Keil's RTX, Apache license). FreeRTOS is popular (modified GPL), though its API is butt-ugly IMO.
Another vote for CMSIS-RTX. It's actively being maintained by ARM and has a generous license.

The downside is that you'll have to "port" it to your platform, as it's a generic RTOS. That's not especially difficult (IMO), but it is a speed bump.
 

Offline krho

  • Regular Contributor
  • *
  • Posts: 223
  • Country: si
Re: Embedded ARM OS options?
« Reply #16 on: February 14, 2018, 06:37:24 pm »
I just found µOS++ IIIe today it's also generous MIT license.
 

Offline ShowKemp

  • Contributor
  • Posts: 16
  • Country: ls
Re: Embedded ARM OS options?
« Reply #17 on: February 15, 2018, 02:13:52 am »
Hi,

I'm assuming you were using PSoC Creator to develop the application (for the PSoC), for PSoC6 you can add FreeRTOS very easily [1], but it's the FreeRTOS version 9 (i haven't seen if they updated to v10 tho). You can see more projects for the PSoC6 on the same blog, here [2].

I did a port of FreRTOS 9 and 10 for the PSoC4200 devices, you can see it here [3].

Hope it helps.

[1] https://iotexpert.com/2017/05/30/psoc-6-freertos-first-example/
[2] https://iotexpert.com/category/devices/psoc-6/
[3] https://github.com/C47D/FreeRTOS9_49-42xx
 

Offline bd139Topic starter

  • Super Contributor
  • ***
  • Posts: 23055
  • Country: gb
Re: Embedded ARM OS options?
« Reply #18 on: February 15, 2018, 12:22:47 pm »
Thanks for that - appreciated. Will have a look through.

Big failure though; I just blew up my PSoC, kitprog and the USB port it was attached to  :palm: - forgot the power supply I had wired up wasn't floating.
 

Offline Berni

  • Super Contributor
  • ***
  • Posts: 5012
  • Country: si
Re: Embedded ARM OS options?
« Reply #19 on: February 15, 2018, 02:04:03 pm »
Climbing hard now :)

I picked another target to play with that I have already floating around that works out of box (pic24+mplab)

By the way 16bit PICs have a bit of a gotcha when it comes to memory and OSes. There normal addressing modes can only access up to a certain amount of RAM. The memory above that magic number needs a special addressing mode that is only used for this extended memory(Yeah oldschool x86 all over again) so only this lower part of RAM is easily usable by freeRTOS, the upper part is best statically allocated. But the limit is reasonably high so most PICs don't have enough RAM to run into it.
 

Offline bd139Topic starter

  • Super Contributor
  • ***
  • Posts: 23055
  • Country: gb
Re: Embedded ARM OS options?
« Reply #20 on: February 15, 2018, 02:10:42 pm »
Yeah that's not a problem for this. It doesn't need dynamic allocation or any heap really. There's one command buffer and a bunch of configuration and state variables that are global and that's it. In the current incarnation it's all in a big for loop with one procedure for each task and the task when it gets called checks for state change in the globals it knows about and then reacts, or changes the variable based on panel controls etc. Interrupts only mutate the global state at the moment. Makes serial handling difficult to add so adding FreeRTOS here makes stuff easier with queues so I can deliver events instead of watching state.

Inputs for this are: rotary encoder, 5 buttons, 5 ADC inputs (multiplexed), serial port, 2 GP digital lines.
Outputs are: serial port, 3 DAC outputs, one synthesizer IC (I2C), one 44780 LCD, 6 GP digital lines.

uC just controls state or listens to it via serial port and reports it on the display. No intelligence going on.
« Last Edit: February 15, 2018, 02:12:37 pm by bd139 »
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3220
  • Country: ca
Re: Embedded ARM OS options?
« Reply #21 on: February 15, 2018, 03:20:28 pm »
Makes serial handling difficult to add ...

What is the exact problem with the serial? You can use DMA or interrupts, which are much less imposing than RTOS.
 

Offline bd139Topic starter

  • Super Contributor
  • ***
  • Posts: 23055
  • Country: gb
Re: Embedded ARM OS options?
« Reply #22 on: February 15, 2018, 03:42:56 pm »
It's more a matter of scale and management. This thing is starting to have to handle a lot of interrupts.
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3220
  • Country: ca
Re: Embedded ARM OS options?
« Reply #23 on: February 15, 2018, 04:15:04 pm »
It's more a matter of scale and management. This thing is starting to have to handle a lot of interrupts.

RTOS will only add more interrupts ;)

RTOS takes resources and gives you back convenience. So, if the problem is in your inability to organize things, RTOS may help. But if it's too tight without RTOS, RTOS will only make things worse.

 

Offline bd139Topic starter

  • Super Contributor
  • ***
  • Posts: 23055
  • Country: gb
Re: Embedded ARM OS options?
« Reply #24 on: February 15, 2018, 05:06:27 pm »
Definitely agree. RTOS gives me the abstractions and the ability to scale this design up if I want, which is what I'm after. If I had to rewrite it later on, I'd be burning a lot of time which I don't have.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf