RTOS Integration

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
nelfata
Posts: 74
Joined: Wed Apr 30, 2014 10:50 pm

RTOS Integration

Post by nelfata » Fri Aug 01, 2014 9:12 am

I am starting on integrating the ChibiOS RTOS with MP.
I would like to get some feedback on what would be more beneficial: MP as a library or ChibiOS as a library.
Either modules can be compiled as a static library.

Here are some thoughts to consider:
1. ChibiOS implements drivers for just about all peripherals of a large collection of MCUs, so MP can take advantage of these low level drivers and porting to multiple platforms could be made relatively fast. Some features of the RTOS could be disabled and will not interfere with the MP. But that would require an application dependent configuration file (already provided) and a library rebuild.
2. There might be a need to merge the two projects, and might require some Makefile changes, perhaps the current file layout or project architecture might be impacted. Building ChibiOS as library could be just a simple link from MP, but it depends on the objectives here.
3. The are some files that needs to be addressed: main, vectors, linker files, startup files.
4. A thread interface/module could be created to take advantage of the RTOS capabilities...

Please comment/provide any interesting thoughts.

Thank you.

User avatar
dhylands
Posts: 3234
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: RTOS Integration

Post by dhylands » Fri Aug 01, 2014 2:49 pm

There is a certain appeal, but I think that there is also an appeal to having something OS-less.

Right now, if micropython were integrated with any multi-thread capable OS, it would need to run on a single thread.

With the unix port, you're running micropython in a multi-threaded capable, but only single threaded environment. So mimicking something like that probably gets off the ground the fastest.

I think that however its done (as far as libraries go), ChibiOS would be a seperate "port" and would live alongside the others.

nelfata
Posts: 74
Joined: Wed Apr 30, 2014 10:50 pm

Re: RTOS Integration

Post by nelfata » Fri Aug 01, 2014 3:38 pm

That should be simple enough to enable/disable with the configuration files.
I can try it, but I believe that the RTOS can be totally disabled unless you wish to use its drivers in a single thread environment.
I think it makes sense to have the RTOS be built as a static library.

rambo
Posts: 11
Joined: Fri Jun 06, 2014 9:36 pm
Location: Finland
Contact:

Re: RTOS Integration

Post by rambo » Sat Sep 06, 2014 3:11 pm

I am starting on integrating the ChibiOS RTOS with MP.
I would like to get some feedback on what would be more beneficial: MP as a library or ChibiOS as a library.
Either modules can be compiled as a static library.
Woohoo! I was sorta trying to do something like this early in the summer (pestered dhylands on IRC a lot, thanks for all the help) but then dropped it due to lack of time.

I basically would like to have MP as library so that I can kick up a thread running MP (load script from flash or sdcard, interactive python shell launched from chibios shell would be nice but not required) while keeping everything else business-as-usual for ChibiOS.

So where can I fork your git repo and try my hand at this again ?

nelfata
Posts: 74
Joined: Wed Apr 30, 2014 10:50 pm

Re: RTOS Integration

Post by nelfata » Sat Sep 06, 2014 3:20 pm

I managed to get the ChibiOS as a library that links from the MP Makefile in stmhal.
I figured since the main.c is in MP then better to make ChibiOS as a library.
I got to a point where everything builds cleanly but could not get the ChibiOS to initialize the hardware correctly, with MP it is very difficult to debug startup code without attaching a JTAG debugger, which I have but requires another set of tools running on Windows (Ride7 IDE).
I also had issues with the STM library, there are conflicts due to the fact that MP is running the latest from ST but ChibiOS is lacking behind.
Eventually I found that that was taking long. But I would be ready to work on it again.
I think that would be the ultimate integration, as ChibiOS implements multiple platforms and multiple drivers and it would be a nice thing to port MP and ChibiOS on any of those platforms (with sufficient RAM/FLASH of course).

I am not sure what is the best way to integrate and to proceed perhaps you can throw some ideas, and by the way I am not a GIT addict, so may need some input here.

rambo
Posts: 11
Joined: Fri Jun 06, 2014 9:36 pm
Location: Finland
Contact:

Re: RTOS Integration

Post by rambo » Sat Sep 06, 2014 6:51 pm

I am not a GIT addict, so may need some input here.
I'm no expert either, but the internet is full of tutorials (githubs own tutorials are IMO very newbie friendly). Is your code somewhere I can see it ?
I also had issues with the STM library, there are conflicts due to the fact that MP is running the latest from ST but ChibiOS is lacking behind.
I thought ChibiOS does not use the STM library at all but implements some of the features by itself.

I still think it would be better to run MP as ChibiOS thread, instead of using ChibiOS just as a HAL library (or maybe I misunderstood what you meant by ChibiOS as library).

I suggest we talk this over on IRC (see http://forum.micropython.org/viewtopic. ... t=irc#p632 )

I'm rather new to ChibiOS and everythign else ARM (and C is not my strongest language) but I'm trying...

nelfata
Posts: 74
Joined: Wed Apr 30, 2014 10:50 pm

Re: RTOS Integration

Post by nelfata » Sun Sep 07, 2014 1:05 am

I can zip what I have and send it to you somehow. We could chat over Skype if you'd like.

The older ChibiOS used to use the ST library, I looked recently and you are right it is no longer the case, but there GPIO structure definitions for example conflicts with the MP code definitions.

I am not yet sure which should call what, there are many MP drivers that could be useful so it was one reason I preferred to build ChibiOS as a library, but we can discuss that.

In any case let us chat and we can take it from there.

Post Reply