micropython / micropython-infineon

MicroPython ported to Infineon MCUs
MIT License
34 stars 24 forks source link

Building Micropython for Infineon Tricore Architechture #1

Closed SUBBU3881 closed 1 year ago

SUBBU3881 commented 6 years ago

Hello, Can any one help me in building micropython source code for Infineon's Tricore architecture.?

Thanks and Regards, Siva Prakash Reddy

webmeister commented 6 years ago

Sounds like an awesome idea. I have never tried that, so I'm not sure how similar Tricore is to any of the architectures that are already supported (and which therefore could be used as a starting point).

What have you done already and are there any more specific questions that you need help with?

SUBBU3881 commented 6 years ago

Thanks for response. I am trying to port micropython on to tricore architecture that is already running with AUTOSAR. I have micro-python source code, but don't know how to modify this for tricore controller and how to cross-build it for tricore architecture.

Please respond as soon as possible.

Thanks and Regards, Siva Prakash Reddy

dpgeorge commented 6 years ago

but don't know how to modify this for tricore controller and how to cross-build it for tricore architecture.

You shouldn't need to modify much (if anything) of the MicroPython core. But you will need to become familiar with cross compiling for your architecture, and then how to port MicroPython to it. See the minimal/ (or ports/minimal/) directory for an example of a minimal port of MicroPython which works on a Cortex-M arch.

SUBBU3881 commented 6 years ago

Thanks for valuable information.

Can you please provide/suggest how to modify Makefile or cross-compiler of infineon tricore for micropython building.?

SUBBU3881 commented 6 years ago

Can anyone respond in this regard.?

webmeister commented 6 years ago

You could look at what we did to add XMC support in 4916009360927a82ca2ab67f2b996ab96207dc30. In your case, it might be a bit more difficult, since you want to add support not only for a new controller but also a new architecture, but the general steps should be similar.

SUBBU3881 commented 6 years ago

Can you please explain a bit more.

webmeister commented 6 years ago

If you start with the minimal port that we used as a basis for the XMC port, there are three functions that you need to look at in order to run basic MicroPython functionality:

  1. You need to implement mp_hal_stdin_rx_chr from uart_core.c to return a single character from your UART (or whatever communication channel you want to use for user input).
  2. Similarly, you need to implement mp_hal_stdout_tx_strn from the same file, so that it sends the string via UART to the user.
  3. You need to call main from main.c, so that the MicroPython interpreter can execute. Perhaps you also need to do additional stuff before to fully initialize your controller or set up the UART etc.

Then you "just" need to compile that code. Perhaps you've got an existing project for your target platform, that you can use as an example? This is what we did with the XMC port (see the Makefile changes to get an idea what was necessary in our case).

@dpgeorge: Is there some kind of porting guide for MicroPython?

SUBBU3881 commented 6 years ago

Thanks for the valuable response. I tried to build 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.

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

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

  3. 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

SUBBU3881 commented 6 years ago

Please do needful @dpgeorge

dpgeorge commented 6 years ago

Is there some kind of porting guide for MicroPython?

Unfortunately there is no official guide to port MicroPython to a new platform. It would be great to have but there is only so much time in the day :) It is hoped that the code examples (eg the minimal port, and the other full ports) provide enough variation of examples that one can follow what is going on and create a new port from them.

It seems that the issues raised here come from using a very different build system, not GNU make.

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

They are used to generate certain header files. They generate the qstr header file genhdr/qstrdefs.generated.h, and the version file genhdr/mpversion.h. The py/py.mk file contains rules that generate these headers.

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

Yes. When using the provided set of Makefile's these headers are generated automatically.

One way to generate the files is to run "make" in the minimal port and then copy the generated files from minimal/build/genhdr to your project. This won't work perfectly for all cases but might be enough to get it working for you.

Another way to generate the qstrdefs.generated.h file is to do it as a separate step in your build process. It can be done once at the start and then only needs to be done again if you change (add) any MP_QSTR_xxx constants. An example of a script that can generate the file is found here: https://github.com/bbcmicrobit/micropython/blob/version1/tools/makeqstrhdr.sh . It's just a shell script that runs the Python generation scripts and outputs qstrdefs.generated.h. You should adjust the config settings at the start of that script to suit your build environment.

SUBBU3881 commented 6 years ago

Thanks for the response.

In unix build, "genhdr/qstrdefs.generated.h" and "genhdr/mpversion.h" are generated as a part of build only. Which file holds MP_QSTR_xxx constants.? Where can I find them.? How they get generated and used.? Where QDEF() is processed.?

Please, help in this regard.

Thanks and Regards, Siva Prakash Reddy

dpgeorge commented 6 years ago

Which file holds MP_QSTR_xxx constants.?

genhdr/qstrdefs.generated.h holds the list of constants, and py/qstr.h includes this file inside an enum definition in order to actually define the constants.

Where can I find them.?

In py/qstr.h, and also py/qstr.c will define the data structure holding the qstr text (but only as part of the build process because it uses the C preprocessor to include genhdr/qstrdefs.generated.h).

How they get generated and used.?

You need to generate the genhdr/qstrdefs.generated.h file, eg using the stand-alone script linked above (makeqstrhdr.sh).

Where QDEF() is processed.?

py/makeqstrdata.py generates these definitions. py/qstr.h and py/qstr.c use them.

SUBBU3881 commented 6 years ago

Nice explanation sir. I generated genhdr/qstrdefs.generated.h file separately and added to my project files, then I am facing MP_QSTR_xxx constants issue. I am not sure whether the enum get updated or not in qstr.h. How can I check that updation.?

dpgeorge commented 6 years ago

then I am facing MP_QSTR_xxx constants issue

I'm not sure what you mean by this... what is the exact issue?

Tirtsah613 commented 5 years ago

Hello, @SUBBU3881 - Did you manage to build micropython with Infinion Tricore Architecture? If yes, can you please share some instructions? code? Maybe someone else did something like that? In general I want to integrate micropython into a project that built for Infinion Tricore Architecture.

Thanks in advance,

w1oves commented 3 years ago

Hello, @SUBBU3881 @Tirtsah613 Have you finished running MicroPython on the Infenion Tricore architecture? I need to run MicroPython on Infenion Tricore TC2XX, TC3XX series chips. Do you have any suggestions to provide? Thank you very much. My email address is 18297901734@163.com