Micropython on ESP32-C3

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
jd3096
Posts: 13
Joined: Mon Jul 05, 2021 1:22 pm

Re: Micropython on ESP32-C3

Post by jd3096 » Thu Jul 15, 2021 5:03 am

mattyt wrote:
Tue Jul 13, 2021 11:43 am
I've just pushed a container to the docker hub that can help build that. You should be able to use:

Code: Select all

> docker run -ti --rm -v ~/my_micropython:/micropython micropython/build-micropython-esp32 bash -c -l "cd micropython && make -C mpy-cross && make -C ports/esp32 submodules && make -C ports/esp32 BOARD=GENERIC_C3"
Assuming you have a clone of MicroPython (checked out to the ESP32-C3 #7438 PR) on your host at ~/my_micropython.
it seems git submodule update --init ../../lib/berkeley-db-1.xx goes wrong

User avatar
mattyt
Posts: 410
Joined: Mon Jan 23, 2017 6:39 am

Re: Micropython on ESP32-C3

Post by mattyt » Thu Jul 15, 2021 5:41 am

Interesting; perhaps try a clean?

Code: Select all

> docker run -ti --rm -v ~/my_micropython:/micropython micropython/build-micropython-esp32 bash -c -l "cd micropython && make -C ports/esp32 BOARD=GENERIC_C3 clean"
And then build again:

Code: Select all

> docker run -ti --rm -v ~/my_micropython:/micropython micropython/build-micropython-esp32 bash -c -l "cd micropython && make -C mpy-cross && make -C ports/esp32 submodules && make -C ports/esp32 BOARD=GENERIC_C3"
Also, can you please share what your host operating system is? I am suspicious that it might be a Windows host...and if so can you also try and use WSL?

jd3096
Posts: 13
Joined: Mon Jul 05, 2021 1:22 pm

Re: Micropython on ESP32-C3

Post by jd3096 » Thu Jul 15, 2021 6:40 am

mattyt wrote:
Thu Jul 15, 2021 5:41 am
Interesting; perhaps try a clean?

Code: Select all

> docker run -ti --rm -v ~/my_micropython:/micropython micropython/build-micropython-esp32 bash -c -l "cd micropython && make -C ports/esp32 BOARD=GENERIC_C3 clean"
And then build again:

Code: Select all

> docker run -ti --rm -v ~/my_micropython:/micropython micropython/build-micropython-esp32 bash -c -l "cd micropython && make -C mpy-cross && make -C ports/esp32 submodules && make -C ports/esp32 BOARD=GENERIC_C3"
Also, can you please share what your host operating system is? I am suspicious that it might be a Windows host...and if so can you also try and use WSL?
My host operating system is Ubuntu 20.04.2 LTS in VMWARE,
clean don't work:
Executing action: fullclean
Build directory '/micropython/ports/esp32/build-GENERIC_C3' not found. Nothing to clean.
Done

I am suspicious that my clone operate is wrong,how to
have a clone of MicroPython (checked out to the ESP32-C3 #7438 PR) on your host at ~/my_micropython?
My command is git clone https://github.com/dpgeorge/micropython.git
Is that correct?
Thank you.

jd3096
Posts: 13
Joined: Mon Jul 05, 2021 1:22 pm

Re: Micropython on ESP32-C3

Post by jd3096 » Thu Jul 15, 2021 7:04 am

mattyt wrote:
Tue Jul 13, 2021 11:43 am
I've just pushed a container to the docker hub that can help build that. You should be able to use:

Code: Select all

> docker run -ti --rm -v ~/my_micropython:/micropython micropython/build-micropython-esp32 bash -c -l "cd micropython && make -C mpy-cross && make -C ports/esp32 submodules && make -C ports/esp32 BOARD=GENERIC_C3"
Assuming you have a clone of MicroPython (checked out to the ESP32-C3 #7438 PR) on your host at ~/my_micropython.
i think the crucial problem is how to clone micropython especial for esp32-initial-c3-support
it seems this step i made mistakes

jd3096
Posts: 13
Joined: Mon Jul 05, 2021 1:22 pm

Re: Micropython on ESP32-C3

Post by jd3096 » Thu Jul 15, 2021 11:13 am

jd3096 wrote:
Thu Jul 15, 2021 6:40 am
mattyt wrote:
Thu Jul 15, 2021 5:41 am
Interesting; perhaps try a clean?

Code: Select all

> docker run -ti --rm -v ~/my_micropython:/micropython micropython/build-micropython-esp32 bash -c -l "cd micropython && make -C ports/esp32 BOARD=GENERIC_C3 clean"
And then build again:

Code: Select all

> docker run -ti --rm -v ~/my_micropython:/micropython micropython/build-micropython-esp32 bash -c -l "cd micropython && make -C mpy-cross && make -C ports/esp32 submodules && make -C ports/esp32 BOARD=GENERIC_C3"
Also, can you please share what your host operating system is? I am suspicious that it might be a Windows host...and if so can you also try and use WSL?
My host operating system is Ubuntu 20.04.2 LTS in VMWARE,
clean don't work:
Executing action: fullclean
Build directory '/micropython/ports/esp32/build-GENERIC_C3' not found. Nothing to clean.
Done

I am suspicious that my clone operate is wrong,how to
have a clone of MicroPython (checked out to the ESP32-C3 #7438 PR) on your host at ~/my_micropython?
My command is git clone https://github.com/dpgeorge/micropython.git
Is that correct?
Thank you.
I should clone the branch esp32-initial-c3-support,now I am successed,thanks a lot.

User avatar
mattyt
Posts: 410
Joined: Mon Jan 23, 2017 6:39 am

Re: Micropython on ESP32-C3

Post by mattyt » Thu Jul 15, 2021 11:43 am

Glad you sorted it out! :)

jd3096
Posts: 13
Joined: Mon Jul 05, 2021 1:22 pm

Re: Micropython on ESP32-C3

Post by jd3096 » Sun Jul 25, 2021 10:53 pm

Roberthh wrote:
Mon Jul 05, 2021 1:34 pm
The build for ESP32-C3 is under construction. See https://github.com/micropython/micropython/pull/7438
From that PR it is possible to build a trial version.
Recently,I want to test sleep and wake up function on esp32c3,here is my code:

import machine,esp32
from machine import Pin
import time

wake1 = Pin(2, mode = Pin.IN)
#level parameter can be: esp32.WAKEUP_ANY_HIGH or esp32.WAKEUP_ALL_LOW
esp32.wake_on_ext0(pin = wake1, level = esp32.WAKEUP_ALL_LOW)

print('Im awake. Going to sleep in 2 seconds')
time.sleep(2)
print('Going to sleep now')
time.sleep_ms(100)
machine.lightsleep()

it works on esp32,but when i try to test in on esp32c3, it sleep and won't wake up by pin pushed.
How to wake up correclty on esp32c3?
what's the problem?

User avatar
reppad
Posts: 10
Joined: Mon Aug 16, 2021 10:46 am

Re: Micropython on ESP32-C3

Post by reppad » Mon Aug 16, 2021 10:50 am

Hello,

I would like help to deploy a prebuilt MicroPython firmware on an ESP32-C3 board, for now it does not boot.

The board I use is an AI Thinker ESP32-C3-32S_Kit with 4MB flash
https://docs.ai-thinker.com/_media/esp3 ... cation.pdf

I downloaded last esptool (3.1) that is compatible with ESP32-C3 from https://github.com/espressif/esptool/releases/tag/v3.1

I downloaded esp32c3-20210816-unstable-v1.16-215-gc70930fb2.bin from https://micropython.org/download/all/


I tried to erase flash (seems OK) :

Code: Select all

> .\esptool.exe -p COM5 erase_flash
esptool.py v3.1
Serial port COM5
Connecting....
Detecting chip type... ESP32-C3
Chip is unknown ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 7c:df:a1:xx:xx:xx
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 16.2s
Hard resetting via RTS pin...

Then I tried to write the firmware on ESP flash at address OxO :

Code: Select all

> .\esptool.exe -p COM5 write_flash 0x0 esp32c3-20210816-unstable-v1.16-215-gc70930fb2.bin
esptool.py v3.1
Serial port COM5
Connecting....
Detecting chip type... ESP32-C3
Chip is unknown ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 7c:df:a1:xx:xx:xx
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00168fff...
Compressed 1475424 bytes to 855101...
Wrote 1475424 bytes (855101 compressed) at 0x00000000 in 76.2 seconds (effective 154.9 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
(As my understanding the memory layout on C3 is different than ESP32 and S2 but I tried at address 0x1000 too...).

The upload seems OK but MicroPython does not boot, I can't access repl and I don't see any sign of MicroPython.

Do you see something I miss or not doing right ?
Many thanks for help !

User avatar
reppad
Posts: 10
Joined: Mon Aug 16, 2021 10:46 am

Re: Micropython on ESP32-C3

Post by reppad » Wed Aug 18, 2021 10:02 am

New episode, I dug a bit and found the solution.
First good news, the procedure above works like a charm to load MicroPython on ESP32-C3 :)

My problem is the board does not have the proper circuitry to manage RTS & DTR when opening the serial port.
This circuitry exists on the schematic of the documentation but on the real board transistors VT1 and VT2 as well as resistors R1 and R2 are not populated, so DTR and RTS are directly connected to pins GPIO0 and EN.
This case is mentionned here: https://github.com/espressif/esptool/wi ... bootloader

In most serial app I tested the board is set in programming mode because serial terminal programs asserts both RTS and DTR when opening the serial port, even if flow control is disabled (screen, putty, thonny, arduino ide, mobaxterm).
The program "Termite" does not have this behavior so all works with this software.
Personally I'm not fan of this tool so I prefer using an external USB to UART dongle to avoid this issue, with this solution I can use any serial termnal program because dongle RTS & DTR pins are not connected to ESP pins.

Hope this will help someone !

bdambrosio
Posts: 1
Joined: Wed Sep 22, 2021 10:07 pm

Re: Micropython on ESP32-C3 - one final step

Post by bdambrosio » Wed Sep 22, 2021 10:11 pm

Thank you all. This worked for me with one add'l hack: My normal fdti dongle (I know, I know, but its always worked for me before) would show the repl prompt, but I couldn't write. Luckily I had a 2102-based one lying around, and it worked fine.

Post Reply