arduino / summer-of-code

Arduino @ Google Summer of Code
40 stars 51 forks source link

Arduino to MicroPython Transcompiler for Portenta #150

Closed ashpande closed 3 years ago

ashpande commented 4 years ago

Hi,

I am Ashutosh Pandey, 3rd year CSE student of DSCE Bangalore. For GSoC I will be working on writing a 'source to source' compiler to convert Arduino (C++) code to Micropython to speed up the porting of Libraries. The main goal is to make a command line tool which can take input of an example of a library and output equivalent micropython code. The idea is a modification of @RobTillaart 's suggestion to write a script in python to do the same on the Developers group

I realise that making a 1:1 conversion that compiles perfectly is not possible because generating a perfect parser for C++ is not possible, the source and target languages are different, and because lower level details on the Portenta are not available yet, but it is possible to translate a big chunk of the example programs because C++ is a statically typed language that has a lot of details on resource and memory management, so this should be much more feasible than going from Python ---> C++.

There are some existing projects that attempt to convert C++ code to Python like Pybee Seasnake

I am working on building a minimum viable prototype, so that I can include the details of how to implement this in my proposal. I know that time is running low but I want to submit a detailed proposal :D . I will be using Flex and Bison, instead of writing a python script because both are open source and well maintained.

On the personal side, I have experience of working with Arduino/Raspberry Pi. I have built multiple projects including:

  1. A healthkit based on arduino/raspberry pi that can measure ECG/EMG/Temperature/Pressure/Blood alcohol etc and relay it to an app.
  2. An exercise tracker that can track unconventional exercises, like pushups, situps, arm rotations etc.
  3. A motion capture system based on Arduino/LabVIEW.
  4. A 3D Printed Prosthetic Hand in which I am working to add myoelectric control.

All these have been done for Hackathons, I have uploaded their codes to my Github.

Thank you!

ashpande commented 4 years ago

My final proposal has been uploaded :)

https://drive.google.com/file/d/1z2qUlTnPmm_nRXp1Yo-LPh3SZQNt2c9o/view

Thank you!

RobTillaart commented 4 years ago

Why not start from the GCC compiler?
Just thinking out loud...

ashpande commented 4 years ago

@RobTillaart honestly the GCC codebase was pretty intimidating, and I wasn't quite sure on how to integrate Arduino Language reference into it. I even thought of using compiling to Haxe since Haxe has Python as one of the Target languages.

Anyway, now since the proposal is done I'll take a deeper look into it. If nothing else, maybe I can find a way to use the GCC front end in a manageable way, I'll have to write the rest for the Arduino functions anyway..

And thanks for the original idea btw!

ashpande commented 4 years ago

Update 21/04/2020

Markdown proposal can be found at: https://github.com/AshutoshPandey123456/GSocArduino2020/blob/master/proposal.md

ashpande commented 4 years ago

@alranel thank you for selecting me :D I want to know if this GitHub issue is still the best place to communicate or whether I should reach out to you by some other means.

Will get to work on the project right away! Also look forward to interacting with members of the Arduino community!