Running MicroPython on custom hardware

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
rzingler
Posts: 1
Joined: Wed Nov 01, 2017 2:16 am

Running MicroPython on custom hardware

Post by rzingler » Wed Nov 01, 2017 2:41 am

Hi, I'm newbie to MicroPython plattform.

Actually, I develop firmware in C language, using FreeRTOS. I want to know if there are tutorials explaining how to port the MicroPython interpreter to a specific hardware plattform, in my case a custom LPC1768 (Cortex-M3) board. Since I'm newbie, I've many doubts, listed below:

Is the interpreter source code available in C language, so that I can use a established an working environment to compile it?
How do I establish the link between the interpreter and existing HAL functions? Is there a default or more convenient way to do this?
Can I get some advantages by using the already working FreeRTOS plattform to run the interpreter?

Thanks in advance!

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: Running MicroPython on custom hardware

Post by jickster » Mon Nov 06, 2017 5:02 pm

I've started working with micropython less than 2 months ago so take that into account with respect to my advice.
rzingler wrote:
Wed Nov 01, 2017 2:41 am
Hi, I'm newbie to MicroPython plattform.

Actually, I develop firmware in C language, using FreeRTOS. I want to know if there are tutorials explaining how to port the MicroPython interpreter to a specific hardware plattform, in my case a custom LPC1768 (Cortex-M3) board.
There's not tutorials on the C-code, unfortunately, meaning you'll have to figure out how to modify the many tables of function pointers to add your own functionality. Even the comments in the code are less verbose than I'd like.
I'd start with the ports/minimal or ports/bare-arm.

If you need more info i.e. a comment on a line of code, go to the github commit message for that file.

You're using ARM which is good because the exception framework uses ARM assembly (though I ?think you can choose not to? Irrelevant because you're using ARM so don't worry about it).
rzingler wrote:
Wed Nov 01, 2017 2:41 am
Is the interpreter source code available in C language, so that I can use a established an working environment to compile it?
Yes. The code is available here https://github.com/micropython/micropython/releases
rzingler wrote:
Wed Nov 01, 2017 2:41 am
How do I establish the link between the interpreter and existing HAL functions? Is there a default or more convenient way to do this?
You have to look in the code for HAL-related functions. Search for "LED", "ADC", "timer" and you'll quickly find where you need to add your specific HAL code. There's not some kind of easy generator script that auto-generates the HAL functions using your own plugin functions but it's really not hard.
rzingler wrote:
Wed Nov 01, 2017 2:41 am
Can I get some advantages by using the already working FreeRTOS plattform to run the interpreter?
Thanks in advance!
I have zero knowledge of FreeRTOS (or even other RTOS) but I will say that I'm integrating micropython into a cooperative multitasking OS which is a pain because I have to modify micropython source code to explicitly call MyRTOS.yield().

If FreeRTOS uses preemptive multitasking, you won't have to do that.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Running MicroPython on custom hardware

Post by pythoncoder » Tue Nov 07, 2017 7:41 am

There is an official MicroPython port for the Zephyr RTOS.
Peter Hinch
Index to my micropython libraries.

Post Reply