Error in micropython porting

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
deepak
Posts: 5
Joined: Sun Apr 19, 2020 5:20 pm

Error in micropython porting

Post by deepak » Sun Apr 19, 2020 5:46 pm

Hi everyone,

I am new to micropython and was trying to build nuttx with latest micropython using following method:

I reverted the commit in which micropython was supported then in the micropython makefile, I changed the micropython version from 1.3.8 to 1.12, then tried to build but got following error :

apps/interpreters/micropython/micropython-1.12/py/mphal.h:34:23: fatal error: mphalport.h: No such file or directory
#include <mphalport.h>

so I tried to search this file then it was in /mpy-cross and ports/unix folder then I tried to give the address manually
#include "mpy-cross/mphalport.h"

then it gave the following error:

apps/interpreters/micropython/micropython-1.12/py/builtin.h:81:29: error: conflicting types for 'mp_builtin_open_obj'
MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_open_obj);

tried to include using ports/unix but still got the same above error.

please check this and let me know why it didn't include mphalport.h by itself and how can I correct the 2nd error.
Thank in advance for the help.

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

Re: Error in micropython porting

Post by jimmo » Sun Apr 19, 2020 11:17 pm

Hi,

It helps with these sort of questions to provide a lot more context and background. Fortunately I at least know what NuttX is, but more info always helpful (i.e. link to repo, which revision, which commands you're running, etc).
deepak wrote:
Sun Apr 19, 2020 5:46 pm
I changed the micropython version from 1.3.8 to 1.12
I suspect this is the key issue. A _lot_ has changed since 1.3.8.
deepak wrote:
Sun Apr 19, 2020 5:46 pm
mphalport.h
I forget exactly when this was added (since 1.3.8) but it's a key thing that a port has to provide to define some common hardware-level methods. You can't just give it a different port's file as it will be different for every port (and generally there will be a corresponding mphalport.c to provide the actual implementation).

This is kind of the "embedding" scenario that has been discussed a few times recently but unfortunately there isn't a really good example of how to do this. micropython/examples/embedding is unfortunately quite convoluted and difficult to apply. (It's on my list, but there are lots of things on my list...) That said, it might be a good starting point for what you need to do -- the key thing to remember with it is that all of the Unix stuff can be ignored (e.g. moduos.c) and anything that includes code from the unix port.

Post Reply