Page 1 of 2

Micropython on Raspberry Pi2?

Posted: Thu Apr 30, 2015 11:35 pm
by Jonas
Ok. Sorry if this is totally stupid.
I recieved my RPi2 and it has a quad-core processor, and as I understand it's like four processors in one chip. I read about that it's possible to dedicate the processors to different tasks in linux. And it got me thinking...
First let me say that I dont know much about processors architecture and their internal workings.

So, is it possible to run micropython on a raspberry pi 2's single processor and let the other three run as usual?

Or, just run micropython on a raspberry pi, and use it as as a microcontroller?

This is not something I can or will try to do, but I can't get this of my mind.

Re: Micropython on Raspberry Pi2?

Posted: Fri May 01, 2015 12:24 am
by dhylands
Generally speaking, unless you really know what you're doing, the scheduler will do a better job of load balancing your 4 processors than you can can.

You can run the full version of python on the raspberry pi if you like. If you want to run mciropython, then you'll need to run the unix version of micropython.

Re: Micropython on Raspberry Pi2?

Posted: Sat May 02, 2015 8:01 am
by MarkHaysHarris777
hi, full python2 and python3 come installed on Raspbian for the RPi2... python2 comes installed for yocto linux on the Intel Edison, as well. Other than an educational experiment, I can't see much benefit of running micro python on the RPi2-- unless you were thinking of having a micro python controller with 1G of memory! ... and dumping the gnu/linux OS. But, then it wouldn't be a raspberry pi, would it?

What I'm thinking of doing is using the micropython controller as a peripheral controller (display controller and keyboard scanner) for a calculator science station I'm thinking of... freeing up the Intel Edison to do strictly analytics &etc (same could apply for the RPi2 also). The pyboard doesn't really have enough memory to be the main system; however, it is one powerful controller-- and much easier and more robust than the Arduino (IMHO) due to its python design... I think its absolutely brilliant to use the REPL as the OS... who woulda thought?

If you want to play with python on your RPi just open a LxTerminal and type: python3

Re: Micropython on Raspberry Pi2?

Posted: Sat May 02, 2015 9:08 am
by Jonas
It was just a thought if it is possible to use the raspberry pi as a microcontroller, or for raspberry pi 2, to use one processor as a microcontroller and the rest as a pc.
It seems like alot of people use raspberry pi to communicate with microcontrollers, so why not integrate a microcontroller directly on the board?
As for the RPi2 to use one processor to collect time critical measurements and the other three to do the processing and graphics.
I don't know much about this, I'm just curious.

Re: Micropython on Raspberry Pi2?

Posted: Sat May 02, 2015 9:28 am
by riklaunim
With an addon board you can have a microcontroller that Raspberry can communicate with (UART, USB or what else) where Pi is master and the addon can work without Pi. For both to work independent you can connect them (like micropython board and Pi) via some way (wifi, bluetooth, ethernet, UART etc.) and exchange information in both ways.

Re: Micropython on Raspberry Pi2?

Posted: Sat May 02, 2015 4:17 pm
by pythoncoder
There might be a case for running MicroPython on a bare-metal Raspberry Pi. Linux isn't a real time OS, so while the Pi can run Cpython the OS can pre-emptively pause execution to devote resources to another process. This can cause random delays quite possibly in the tens of milliseconds with no well-defined upper bound. MicroPython on bare metal also offers interrupt handlers which I assume is impossible in userland under Linux.

On the other hand it wouldn't make use of the quad-core CPU of the Pi2. It depends on the application.

Re: Micropython on Raspberry Pi2?

Posted: Sat May 02, 2015 4:24 pm
by dhylands
Jonas wrote:It was just a thought if it is possible to use the raspberry pi as a microcontroller, or for raspberry pi 2, to use one processor as a microcontroller and the rest as a pc.
It seems like alot of people use raspberry pi to communicate with microcontrollers, so why not integrate a microcontroller directly on the board?
As for the RPi2 to use one processor to collect time critical measurements and the other three to do the processing and graphics.
I don't know much about this, I'm just curious.
What you're really asking is it possible to run multiple OSes simultaneously. The problem is that you have to coordinate all of the shared resources between the OSes (like memory, interrupts, peripherals, etc). So while it technically might be possible, it generally isn't practical. This is the same reason you don't see Windows and linux being run simultaneoulsy on everybody's uad core PCs.

Re: Micropython on Raspberry Pi2?

Posted: Mon May 04, 2015 11:10 am
by pfalcon
See http://forum.micropython.org/viewtopic.php?f=5&t=102 for examples of running Python on bare metal, as an "OS". Even big guys like Intel do that - but for good, practical reasons. If you don't have practical reasons, it's much harder to achieve something useful ;-).

Re: Micropython on Raspberry Pi2?

Posted: Wed Apr 13, 2016 7:00 pm
by Hellmut1956
It is possible to make a proprietary Linux implementation and there is the possibility to link cores to tasks. Search under the tag "Xenomai". Basically you have a "normal linux running on cores of the Raspi but assign i.e. one core to be used for running hard real time. The Linux extension is known under the term "cobalt", while the one running normal Linux is called "mercury". So the core on which "cobalt" will run has a deterministic behaviour, while the "mercury" named Linux has the limitations on deterministic behaviour. Using the famous "patch" you can improve normal Linux best deterministic behaviour.
Under this "hood" a Raspi B+ is probably the most cost efficient platform as, opposed to the Raspi "Zero" it has more then one core. I am right now in the process to learn how to do what I am writing about!
Getting to the Python issues of this thread. A Raspi Zero is a good choice, once it is really available, to run a Raspi as a controller board and programming it with Python! But also the B+ is not a bad choice! I am a naval modeller aficionado and a Raspi offers a cheap platform with Wifi capability to control a ship model from a PC or smart phone or tablet. I am planning to make an "intelligent Panel" for my electronic lab using i.e. a zero or a B+. So I can have the Raspi in the Panel show the monitored values of current and tension on the display of my PC!

Re: Micropython on Raspberry Pi2?

Posted: Thu Apr 14, 2016 8:43 pm
by Jim.S
(This comment might be slightly off topic) I have only just learnt that the Raspberry PI has SPI and I2C ports. However, the Python functions that are used to program them seem quite different from the corresponding Micropython functions. It might be quite useful if the Unix version of Micropython could incorporate drivers for the Rasberry Pi I2C and SPI (and also the GPIO and uarts) that were programatically the same as for the pyboard. (Simple wrappers for the functions might suffice, but I don't understand what affect the underlying linux operating system might have)

This could allow code (and hardware) developed on the Rasberry Pi to be transferred to the Pyboard and the BBC Micro:bit. This might be useful in schools and colleges