Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All the text below is now irrelevant because of @Lana-chan 's PR. I'm now trying to merge it with @jeffmer 's GPIO commit. To keep track of the changes go to my fork
Hi,So I made this draft PR to keep track and report on what I tried to get a recent micropython driver for the twatch V3 that supports PDM.The idea came from this message from @devnoname120 where he mentions this repo by @lemariva which states:
I first tried to build and flash the most recent micropython using @jeffmer 's commit for GPIO_WAKEUP.
Building the recent micropython
Steps I took to build and flash the recent micropython with GPIO_WAKEUP:
(The instructions to build then compile were from this README)
git clone -b v5.0.2 --recursive https://github.com/espressif/esp-idf.git
cd esp-idf && git checkout v5.0.2 && git submodule update --init --recursive && ./install.sh && source export.sh
Note: I think all of this has to happen in the same terminal window because the esp-idf export.sh changes some PATH needed for the make command
cd .. && git clone https://github.com/jeffmer/micropython/
cd micropython && make -C mpy-cross && cd ports/esp32 && make submodules && make BOARD=ESP32_GENERIC BOARD_VARIANT=SPIRAM
python -m esptool --port /dev/ttyACM0 erase_flash
make
command. (something like/home/USER/.espressif/python_env/idf5.0_py3.10_env/bin/python ../../../esp-idf/components/esptool_py/esptool/esptool.py -p /dev/ttyACM0 -b 460800 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_size 4MB --flash_freq 40m 0x1000 build-ESP32_GENERIC-SPIRAM/bootloader/bootloader.bin 0x8000 build-ESP32_GENERIC-SPIRAM/partition_table/partition-table.bin 0x10000 build-ESP32_GENERIC-SPIRAM/micropython.bin
). I think you can alternatively usepython -m esptool --port /dev/ttyACM0 --chip esp32 write_flash -z 0x1000 build-ESP32_GENERIC-SPIRAM/firmware.bin
cd .. && git clone https://github.com/jeffmer/TTGO-T-watch-2020-Micropython-OS/ && cd TTGO-T-watch-2020-Micropython-OS/src
compile.sh
to point to the one built in the micropython folder./compile.sh
./install.sh
This was succesful and produced a build that flashed without issues on my V3 watch.
Now, to get the commit from @lemariva working without knowing any C I had to do some modifications to the commit code. As I don't know C I don't really know if some of my changes invalidated the commit or not but I got it flashing and booting as normal.
Trying to add PDM support
There are 4 files in @lemariva's commit:
modmachine.h
modmachine.c
+ { MP_ROM_QSTR(MP_QSTR_I2S), MP_ROM_PTR(&machine_hw_i2s_type) }, \
in the sectionwake abilities
but I ran into some issues so I ended up movingtypedef enum
and a declaration ofis_soft_reset
just a bit higher in the code.Makefile
machine_i2s.c
but the Makefile changed at lot between the recent micropython and the one for @lemariva so I ended up ignoring this step as I think the Makefile was using a glob to compile all *.c files. Given that I add compiling issue in machine_i2s.c I think this was true.machine_i2s.c
so apparently this file did not exist in micropython at the time of lemariva so at the time I just needed to add it directly. But now there is a machine_i2s.c file in micropython so I needed to somehow merge the changes.
What I did was paste the whole machine_i2s.c file from lemariva at the end of the recent one, try to compile then make sense of the errors.
I also added at the top some
#include
statements.The first change was fixed by @DonvdH in this message
* The first notable change was that in lemariva there is a line:that returned error:So I changedI2S_NUM_MAX
toI2S_NUM_1
and got:So I triedI2S_NUM_0
and got the same.Finally tried with
I2S_NUM_AUTO
and got it passed that line.I have no idea what I'm doing.which returned errors like
error: 'mp_obj_type_t' {aka 'const struct _mp_obj_type_t'} has no member named 'locals_dict'
also for.make_new
and.print
.Noticing that the end of
machine_i2c.c
ended up with a similar looking bunch of lines I intuitively merged it to:which produced a build that apparently worked and successfuly built.
I think it was successful in the sense that it resulted in a flashable build, but I got many warnings and no errors, but all from machine_i2s. Here are the warnigs I got:
At the end of all this I flashed the whole thing using the above commands and the watch booted successfuly. But now what? when doing
from machine import I2S ; dir(I2S)
I don't see a PDM mode, but I don't if that's expected or not. Basically I don't know if my commit was working or not, if it did change the build, if it added functionnality or not etc.Please help
machine_i2s.c
files was a problem.