Qwiic_Py icon indicating copy to clipboard operation
Qwiic_Py copied to clipboard

add support for micropython on RP2040 boards

Open oclyke opened this issue 4 years ago • 4 comments

what it do

  • adds a build script micropython/tools/qwiic-mpy/gen.py which can be used to generate and update bytecode (.mpy) files for micropython from the Qwiic_Py sources.
  • modifies .gitignore so that .mpy files are ignored except within the micropython/dist directory, so that users can access pre-compiled files
  • adds micropython/README.md which explains the basics of how to use everything

dependencies add micropython RP2040 i2c driver - this is necessary b/c it contains the i2c driver for micropython/rp2040

status ✅ build script ✅ module compatibility with filesystem ✅ i2c driver seems to work ✅ device driver testing satisfactory ⚠️ additional boards can be added (non-blocking)

oclyke avatar Feb 04 '21 00:02 oclyke

p.s. i have not included the pre-compiled binaries in the PR yet in case they change during testing. as a reviewer you will need to generate them yourself. fortunately it is as easy as:

  • make sure you have micropython and have built mpy-cross
    • cd raspberrypi/micropython/mpy-cross && make
  • run the generate script from the Qwiic_Py root directory and provide the -m flag to tell it where to find the mpy-cross executable
    • ./micropython/tools/qwiic-mpy/gen.py -m ~/raspberrypi/micropython/mpy-cross/mpy-cross

p.s.s. perhaps this script could make a good candidate for continuous integration

oclyke avatar Feb 04 '21 01:02 oclyke

latest pushes run on the rp2040, however there seems to be an issue with block reads that causes only zero to be read back. more information is needed at this time

oclyke avatar Feb 15 '21 20:02 oclyke

addressing comments:

  • moved "supported platforms" to the end of README so bytecode explanation comes sooner
  • added clarification for rshell command usage
  • added step to upload board files
  • added README about board files in src/boards
  • vestigial file micropythong/src/qwiic_i2c/init.py removed (was holdover from previous issues)
  • comments added to trickier bits of mpygen.py

re: github actions

  • yes i think the mpygen.py script would be a good candidate to automate with ci. the generate-variants script from the Apollo3_Arduino repo shows one way to do this (though it is not necessarily the best way or even a good way for all i know)

note: at the moment i am unable to add demo output to the README - i am away from my test hw. i will get back to this as soon as i can however it should be possible for others to modify this PR so anyone else may add it if they have demo output handy

oclyke avatar Mar 11 '21 03:03 oclyke

Jumping in here with a question, as I’m working with MicroPython on ESP32. The board I have here has a Qwiic connector, would this PR be a starting point for having that supported in MP? / any progress on having this merged in general?

andypiper avatar Feb 05 '22 11:02 andypiper