Micropython port for Atmel SAME70Q20

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
learnerforlife
Posts: 13
Joined: Mon Sep 17, 2018 5:38 am

Micropython port for Atmel SAME70Q20

Post by learnerforlife » Mon Sep 17, 2018 5:57 am

Hi,
I need to port micropython to a custom board based on SAME70Q20 MCU. It is an ARM cortex - M7 core running upto 300 MHz. It has 384K of SRAM and 1M of flash which I think makes it more than capable of running micropython. Has anyone done any work on related atmel MCU? or should I start from scratch getting the minimal port working first and work my way up from there. Ultimately I need to make it work with our existing firmware which is based on FreeRTOS. Can anyone help if they have already done something, so that I don't have to reinvent the wheel.

BramPeeters
Posts: 49
Joined: Wed Jan 31, 2018 3:10 pm

Re: Micropython port for Atmel SAME70Q20

Post by BramPeeters » Mon Sep 17, 2018 9:05 pm

I did it for an stm32f429 (cortext m4) so I cant really help with the Atmel things, but some ramblings on things I encountered....

You can look at the cc3200 port for integration with freertos. I would not first try to do it native , and then freertos as you seem to suggest. Go for freertos integration immediately but initially strip out all the HW related things from the modules/pyb. Just stick to basic micropython stuff and then enable/port/create the drivers you need, if any (depends on what exactly you need micropython for and how much you want to do in micropython versus in C, eg do you need direct network access/gpio/timers access from within micropython, or maybe only some higher level stuff such as mqtt/a led driver/... and keep the low lever stuff in C (which is more efficient, though i suggest with 300Mhz that will not immediately be an issue (i am running at 48Mhz and so far no problems) ) ).

The biggest initial porting work I had was trying to get things compiling in an IAR based toolchain (viewtopic.php?f=3&t=1409) because of all the non standard stuff (this was 1.9.3, i haven't looked at 1.9.4 (yet) ). If you can use something gcc based you probably have a much easier road ahead of you.

And if you start adding C drivers familiarize yourself with how to garbage collector works, there are some good threads on it here :)

Also doing callbacks from 'normal' freertos threads into micropython land requires some trickery (viewtopic.php?f=3&t=4670, though i am not sure i am setting a good example there).

And even though my freertos is running in preemptive mode, in order to keep life simple i have forced (through the GIL ) all my micropython tasks in a 'cooperative' mode , including when a callback originating from a regular freertos thread occurs. I never call directly from a hard interrupt level into micropython.

Good luck!

Edit: fixed some typos/brainfarts
Last edited by BramPeeters on Tue Sep 18, 2018 9:05 am, edited 1 time in total.

learnerforlife
Posts: 13
Joined: Mon Sep 17, 2018 5:38 am

Re: Micropython port for Atmel SAME70Q20

Post by learnerforlife » Tue Sep 18, 2018 5:03 am

Thanks a lot @BramPeeters, I will start looking at porting it directly to FreeRTOS. Yesterday I was trying to get the minimal build working with little success. :D
I dont't need any low level access from uPython and also I am using arm gcc toolchain so I do have an advantage there.

learnerforlife
Posts: 13
Joined: Mon Sep 17, 2018 5:38 am

Re: Micropython port for Atmel SAME70Q20

Post by learnerforlife » Thu Sep 20, 2018 4:30 am

Hi, I have got the micropython core compiling with my device's firmware. Can anyone give pointers on how to get the input/output and REPL working?

learnerforlife
Posts: 13
Joined: Mon Sep 17, 2018 5:38 am

Re: Micropython port for Atmel SAME70Q20

Post by learnerforlife » Thu Sep 20, 2018 1:21 pm

Never mind got the REPL working now. :D

Post Reply