Eclipse setup - missing definitions

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
flindt
Posts: 11
Joined: Tue Jun 20, 2017 8:51 am

Eclipse setup - missing definitions

Post by flindt » Tue Jun 20, 2017 9:06 am

Hi Guys

Currently I have set up eclipse to compile and debug micrypython on a STM32F429DISC, and this is working great :)

However, in eclipse the definitions from generated headers like qstrdefs.generated.h are not recognised.
Examples: MP_QSTR_opt, MP_STATE_PORT, MP_DEFINE_CONST_FUN_OBJ_KW

This creates a lot of "noise" in the editor, even though the project compiles and runs just file using the included makefiles.

Does anyone know a way to make eclipse aware of these generated header files and include them in the scan for symbols?

cheers
Poul Flindt

User avatar
dhylands
Posts: 3466
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Eclipse setup - missing definitions

Post by dhylands » Tue Jun 20, 2017 8:20 pm

You'd need to write a script which expands the QDEF macros. You can see in py/qtr.h https://github.com/micropython/micropyt ... .h#L39-L46 the following:

Code: Select all

enum {
#ifndef NO_QSTR
#define QDEF(id, str) id,
#include "genhdr/qstrdefs.generated.h"
#undef QDEF
#endif
    MP_QSTRnumber_of, // no underscore so it can't clash with any of the above
};
The C preprocessor will take the QDEF macros from genhdr/qstrdefs.generated.h:

Code: Select all

QDEF(MP_QSTR_NULL, (const byte*)"\x00\x00\x00" "")
QDEF(MP_QSTR_, (const byte*)"\x05\x15\x00" "")
QDEF(MP_QSTR__star_, (const byte*)"\x8f\xb5\x01" "*")
QDEF(MP_QSTR__, (const byte*)"\xfa\xb5\x01" "_")
QDEF(MP_QSTR__slash_, (const byte*)"\x8a\xb5\x01" "/")
QDEF(MP_QSTR__percent__hash_o, (const byte*)"\x6c\x1a\x03" "%#o")
QDEF(MP_QSTR__percent__hash_x, (const byte*)"\x7b\x1a\x03" "%#x")
...
and create something like this:

Code: Select all

enum {
MP_QSTR_NULL,
MP_QSTR_,
MP_QSTR__star_,
MP_QSTR__,
MP_QSTR__slash_,
MP_QSTR__percent__hash_o,
MP_QSTR__percent__hash_x,
...
    MP_QSTRnumber_of, // no underscore so it can't clash with any of the above
};
Then you need to coerce eclipse to look at your generated definitions.

You could create a dummy.c file (in the stmhal directory) which contains the following:

Code: Select all

#include "../py/qstr.h"
and run:

Code: Select all

make build-PYBV10/qstr.pp
and this will generate build-PYBV10/dumy.pp which is the preprocessed version. It might be enough to rename dummy.pp to dummy.h and get eclipse to use that (I've never used eclipse, so I'm not sure what's needed).

flindt
Posts: 11
Joined: Tue Jun 20, 2017 8:51 am

Re: Eclipse setup - missing definitions

Post by flindt » Fri Jun 23, 2017 8:03 am

Thanks Dave.

The project builds fine, and in the process creates genhdr/qstrdefs.generated.h.
I was hoping to use the this file, as it seems like double the work to build it again just for eclipse...

Ill play around a little and if I cant coerce eclipse to look in the build folder and include it without adding to the code base.

SUBBU3881
Posts: 17
Joined: Mon Dec 04, 2017 10:46 am

Re: Eclipse setup - missing definitions

Post by SUBBU3881 » Mon Jan 29, 2018 10:00 am

Hi,
I am also facing similar issue. Can you please help me in resolving the issues.

I tried to build MicroPython source code on the directory "/minimal" and I commented STMicro related code in the source because I need for Just MicroPython Interpreter only. I am using Infineon's HighTec IDE to cross-build the source code. Now I am facing some issues :? mentioned below.

What about the .py files in "/py" directory.? provide some details.

Some header files are out-come of .py files in "/py" directory. How can I generate them.?

Are the .py files are needed to build on the source build of MicroPython or Needed to build separately.?

Please help in this regard.

Thanks and Regards,
Siva Prakash Reddy

flindt
Posts: 11
Joined: Tue Jun 20, 2017 8:51 am

Re: Eclipse setup - missing definitions

Post by flindt » Tue Jan 30, 2018 7:17 am

Can you explain what you are trying to do?

The way the build system is setup, you build for a specific target - there should be no need to to comment out code.
See the README file here : https://github.com/micropython/micropyt ... ts/minimal

The minimal target port should be able to compile to run on a linux, or on a STM32 board, dependent on an option "cross=1" -> STM32.

As for your last question, I am not into the details of how much of the .py files are needed for a particulart build - but this information can be found in the build setup if you have the time.
I would strongly suggest that you do not edit any files from a clean checkout until you have a working build - it just makes the finding mistakes so much harder.

cheers

SUBBU3881
Posts: 17
Joined: Mon Dec 04, 2017 10:46 am

Re: Eclipse setup - missing definitions

Post by SUBBU3881 » Fri Feb 02, 2018 6:55 am

Thanks for the response.

I am trying to build MicroPython for Infineon's TriCore Architecture. I downloaded source code of MicroPython from git and I selected "/minimal" to cross build it for TriCore Arch. I didn't found cross-compiler tool for TriCore to build on Linux PC. So, I downloaded Infineon's HighTech IDE (Eclipse Based) and I created a Project and then added "/minimal", "/py", "/lib" directories and some files in "/utils" directory to this project. After that, I am facing "MP_QSTR_XXXX" and "genhdr/qstrdefs.generated.h" issues.

Please, mention the necessary steps to be followed to build MicroPython Interpreter. Also, mention the way I followed is correct or not.?

Please send me your Makefile for reference.


Thanks and Regards,
Siva Prakash Reddy

User avatar
dhylands
Posts: 3466
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Eclipse setup - missing definitions

Post by dhylands » Fri Feb 02, 2018 5:33 pm

I'd recommend that you run the minimal build under linux using gcc (and building for arm not tricore) and do

Code: Select all

make V=1
That will cause all of the commands being executed, including the ones which build the generated headers to be shown,

chrismas9
Posts: 149
Joined: Wed Jun 25, 2014 10:07 am

Re: Eclipse setup - missing definitions

Post by chrismas9 » Sat Feb 03, 2018 4:27 pm

Did you create an Eclipse project? You need to create makefile project from existing makefile. Point to one of the MicroPython makefiles. Then create and build target, eg BOARD=PYBV10. In your case you will also need to specify CC=TricoreCompilerName, either in the makefile or the build target. In Eclipse the build target is the command line parameters for make. Try BOARD=MyBoard CC=TricoreCompilerName.

MicroPython makefile does lots of magic with gnu utilities and Python including qstr stuff.

Post Reply