M5Stamp C3U unable to load program
i've just rec'd the M5Stamp C3U and i'm running into problems with programming it in the Arduino IDE.
I downloaded both of the suggested USB drivers, the CH9102 and the CP2104 and installed them. I've added a link for the ESP32C3 and M5Stack in the boards manager in preferences and installed ESP32-Arduino and M5Stack-Arduino and can see the lists of boards under those headings in the 'boards' submenu in the Arduino IDE. I've tried uploading using the STAMP-C3 and ESP32C3 Dev Module boards.
Sometimes the C3U is recognised by my PC and sometimes it isn't. When it is recognised, the led on the C3U is off, and when it isn't recognised, the led is on.
If it is recognised by my PC i try loading a sketch onto it i get this error message...
Traceback (most recent call last):
File "esptool.py", line 5387, in <module>
File "esptool.py", line 5380, in _main
File "esptool.py", line 4687, in main
Serial port COM11
File "esptool.py", line 114, in get_default_connected_device
File "esptool.py", line 332, in init
File "serial\serialutil.py", line 392, in write_timeout
File "serial\serialwin32.py", line 222, in _reconfigure_port
serial.serialutil.SerialException: Cannot configure port, something went wrong. Original message: PermissionError(13, 'A device attached to the system is not functioning.', None, 31)
 Failed to execute script 'esptool' due to unhandled exception!
the selected serial port  Failed to execute script 'esptool' due to unhandled exception!
does not exist or your board is not connected
...and the led on the C3U turns on. and it is no longer recognised by my PC.
There is so little info on this product that i don't know if i'm meant to do something with the 'reset' button or if it needs a bootloader flashed onto it first, or maybe something else i have missed.
I usually run into problems when i'm writing my code, not before i've even uploaded my first sketch :(
Can anyone offer a solution to this problem?
maybe below instructions from the documentation can help:
Enter the program download mode operation:
- Long press the center button (G9) of STAMP C3U under power failure condition.
- Connect to the computer, after the port is successfully identified, program burning.
what that means is:
- disconnect (= power failure condition) M5StampC3U from the USB port
- press and hold (= long press) the center button
- while holding the center button, connect M5StampC3U to USB
Now M5StampC3U should be in download mode.
Alternative method: Or what I use (with USB connected all the time):
- press and hold the center button
- while holding the center button, click the reset button (small one)
- then release center button
thanks for the advice. Doing it your way is working now. I am able to upload.
Can you tell me, what are the differences working with Serial on the STAMP C3U from other microcontrollers.
I have used this code to set up the Serial port so i can get info to my Serial Monitor but it isn't working. I am running a simple Blink test sketch in the Arduino IDE and the LED i attached is blinking so i know the sketch uploaded and is working fine, but i am getting no text showing up in the Serial Monitor...
...that code is in the setup function. I have the "Upload Speed" setting in the Arduino IDE set to 115,200 and the Serial Monitor is also set to 115,200 but nothing shows up on the Serial Monitor.
I think that is normal for the StampC3U. 'U' stands for the internal USB (in contrast to an external USB Serial converter) and in order to get debug output some flags need to be defined. See here and here. Edif:
Unfortunately by default these flags are undefined in the ESP32-Arduino libraries.Looking through sdkconfig.h in github it looks like the necessary flag
#define CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG 1is set in Arduino 2.0.2 and up. Not sure why it is not working though.
Ah, i figured it out. On that first link it mentions CDC and i realised that is one of the settings in the Tools menu of the Arduino IDE. It was disabled so i enabled it and uploaded the code and now i can get text to the Serial Monitor.
Thanks for all your help, felmue. I wouldn't have been able to get this working without you. :)
tonyd last edited by
What Pin did you assign to the LED? The examples have 21, but I think it's 2. I can compile code , but can't get the LED to flash. I can do a WIFI scan, so know the toolchain is working
you are correct, the RGB LED is connected to GPIO2.
Here is a blinking RGB LED example for Arduino.
And here is an example using the RGB LED for ESP-IDF.
tonyd last edited by
Thanks @felmue. When I looked at your code I realised my mistake. I'd been treating the RGB LED as a simple LED, not an RGB. I should have read the spec sheet! It's all working as expected. I have also managed to get the M5Stamp attached to Blynk.