How to port Micropython to new Microcontroller

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
baristajosh
Posts: 2
Joined: Sun Jan 06, 2019 9:34 pm

How to port Micropython to new Microcontroller

Post by baristajosh » Sun Jan 06, 2019 9:40 pm

Hi, I wanted to start the process of porting Micropython to an SAM-E54-XplainedPro Dev Board from Atmel
It's based on the ATSAME54P20A (ARM Cortex-M4).
I could not find any good documentation on how to go about porting Micropython to a new board that is not already supported in the Micropython github ports directory.
Can someone point me in the right direction?

HarryOz
Posts: 18
Joined: Thu May 19, 2016 6:02 am

Re: How to port Micropython to new Microcontroller

Post by HarryOz » Tue Jan 08, 2019 3:01 am

Have you had any luck finding out how to port Micropython to a new micro controller / custom board? I want to do the same thing.

yosel.balibrea
Posts: 1
Joined: Wed Jan 09, 2019 8:37 pm

Re: How to port Micropython to new Microcontroller

Post by yosel.balibrea » Wed Jan 09, 2019 9:03 pm

Hi, i have the same problem. I'm trying to port micropython to an FPGA soft core processor (ZPU) and i don't have any help or documentation.

tannewt
Posts: 51
Joined: Thu Aug 25, 2016 2:43 am

Re: How to port Micropython to new Microcontroller

Post by tannewt » Thu Jan 10, 2019 1:50 am

baristajosh, CircuitPython (a fork of MicroPython) supports the SAMD51 which is very similar to the E54 I believe. So, I'd suggest starting there. Once you have CircuitPython going on the E54 you should have enough knowledge to backport SAMD support to MicroPython (which other folks would like too I think.) I'm happy to answer any questions you have too. (You can find me and others on Adafruit discord: https://adafru.it/discord in the #circuitpython channel)

baristajosh
Posts: 2
Joined: Sun Jan 06, 2019 9:34 pm

Re: How to port Micropython to new Microcontroller

Post by baristajosh » Thu Jan 17, 2019 11:52 pm

tannewt wrote:
Thu Jan 10, 2019 1:50 am
baristajosh, CircuitPython (a fork of MicroPython) supports the SAMD51 which is very similar to the E54 I believe. So, I'd suggest starting there. Once you have CircuitPython going on the E54 you should have enough knowledge to backport SAMD support to MicroPython (which other folks would like too I think.) I'm happy to answer any questions you have too. (You can find me and others on Adafruit discord: https://adafru.it/discord in the #circuitpython channel)
Thanks tannewt, not a bad idea....
I'll try that route. I guess I was hoping there was a more formal process to port micropython to a new board.... or at least some rough documentation. I'm sure there is but I just can't seem to find it.

ExXec
Posts: 83
Joined: Sat Oct 20, 2018 4:02 pm

Re: How to port Micropython to new Microcontroller

Post by ExXec » Thu Feb 21, 2019 8:38 pm

I personally found it really helpful to start with the minimal port and then adding the modules from the stm32 folder while adjusting them.

The stm32 is really well documented.

After the minimal port you also want to create the pin and AF mapping like in the board folder. this is essential, because it tells uPython, what pins are available. Then the pin module and then you can already control the digital IO.

-ExXec

St_Arnold
Posts: 2
Joined: Wed Jan 22, 2020 7:07 pm

Re: How to port Micropython to new Microcontroller

Post by St_Arnold » Wed Jan 22, 2020 7:16 pm

@baristajosh
Were you successful in your SAME54 porting project? Care to share?
Is anybody else working on such port?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: How to port Micropython to new Microcontroller

Post by jimmo » Thu Jan 23, 2020 1:50 am

There's now basic support for SAMD21 and SAMD51 in the main repo -- https://github.com/micropython/micropyt ... ports/samd

This would probably provide a good starting point for SAME (similar to what Scott suggested above about looking at the CircuitPython SAMD implementation)

St_Arnold
Posts: 2
Joined: Wed Jan 22, 2020 7:07 pm

Re: How to port Micropython to new Microcontroller

Post by St_Arnold » Sat Jan 25, 2020 4:35 pm

Ok, I'm now attempting to do it myself... But being a beginner working with GIT I'm having some difficulties.
I forked the repo and created a new branch:
https://github.com/st-arnold/micropython/tree/same54
Modified/added files under ports (basically just copied all D51 stuff to E54 as a template at this point)
But I also needed to modify the tinyusb submodule (the specific tree used by micropython) respectively.
I managed to branch and modify it in my local repo but I don't know how push it to GitHub.
I realize this is a Git related question but could someone here help me with this? I tried googling but couldn't find answers to this situation. Should I fork that specific tree first to my GitHub remote (how?) and then set my remote url to it? Or publish my local modified submodule as a new remote repo (will it be linked to the original tree)?
How have other porters done this / what is the right way?

EDIT: The same applies to lib/asf4 submodule which I also should modify in order to compile.
(Having other difficulties there with the automatic loading script...)
If I manage to get this port working I'd like to contribute it upstream if I just learnt, how...

tannewt
Posts: 51
Joined: Thu Aug 25, 2016 2:43 am

Re: How to port Micropython to new Microcontroller

Post by tannewt » Mon Jan 27, 2020 3:31 am

St_Arnold wrote:
Sat Jan 25, 2020 4:35 pm
Ok, I'm now attempting to do it myself... But being a beginner working with GIT I'm having some difficulties.
I forked the repo and created a new branch:
https://github.com/st-arnold/micropython/tree/same54
Modified/added files under ports (basically just copied all D51 stuff to E54 as a template at this point)
But I also needed to modify the tinyusb submodule (the specific tree used by micropython) respectively.
I managed to branch and modify it in my local repo but I don't know how push it to GitHub.
I realize this is a Git related question but could someone here help me with this? I tried googling but couldn't find answers to this situation. Should I fork that specific tree first to my GitHub remote (how?) and then set my remote url to it? Or publish my local modified submodule as a new remote repo (will it be linked to the original tree)?
How have other porters done this / what is the right way?

EDIT: The same applies to lib/asf4 submodule which I also should modify in order to compile.
(Having other difficulties there with the automatic loading script...)
If I manage to get this port working I'd like to contribute it upstream if I just learnt, how...
Hi, first we have an Adafruit Learn Guide about git and github that may help. https://learn.adafruit.com/contribute-t ... and-github It is about CircuitPython but most of it will apply more broadly.

When modifying a submodule like tinyusb or asf4 you'll want to:
1) Fork the corresponding repo on GitHub so that you have a remote, publicly available copy.
2) Copy the clone url for it and add it as a remote. Something like `git remote add <your github username> <clone url>`
3) Push the branch of your changes to your fork. Something like `git push <your github username> <branch name>`
4) Edit `.gitmodules` at the top of the repo to point to your fork instead of the original. This is how other's who use your fork know which repo to pull the commit from.
5) Commit the changes to `.gitmodules` and the subfolder for the submodule to the top level repo.

Once it's setup you only need to do 3 and 5 when you edit the submodule.

Post Reply