Can't upload code to ESP32 - Please help! - TypeError: argument of type 'NoneType' is not iterable

Hello everyone!

I have never worked with the Arduino IDE or ESP32 boards before, but I'm trying to build a scale with a load cell. For this, I bought an ESP32 Dev Kit C v4 (ESP32 Dev Kit C V4 NodeMCU WLAN WiFi Development Board) and connected a load cell with an HX711 converter.

Now I want to upload code using the Arduino IDE. For this, I connected the board to my computer via USB, installed the universal CP210x drivers (CP210x USB to UART Bridge VCP Drivers - Silicon Labs) (on Windows), and checked if I could access it via Putty, which was no problem.

Next, I installed Arduino IDE 2.3.2, then installed the esp32 package from Espressif Systems via the Board Manager, and selected "ESP32 Dev Module" under Boards. After that, I only adjusted the Upload Speed to 115200 and then tried to upload code.

But no matter what I do or which code I upload, I always get the following error message during the upload:

Der Sketch verwendet 268769 Bytes (20%) des Programmspeicherplatzes. Das Maximum sind 1310720 Bytes.
Globale Variablen verwenden 17024 Bytes (5%) des dynamischen Speichers, 310656 Bytes für lokale Variablen verbleiben. Das Maximum sind 327680 Bytes.
"C:\Users\Test\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.6/esptool.exe" --chip esp32 --port "COM3" --baud 115200  --before default_reset --after hard_reset write_flash  -z --flash_mode keep --flash_freq keep --flash_size keep 0x1000 "C:\Users\Test\AppData\Local\Temp\arduino\sketches\C5B8A5B0F3399114B3DC0CE6CD770957/Waagen.ino.bootloader.bin" 0x8000 "C:\Users\Test\AppData\Local\Temp\arduino\sketches\C5B8A5B0F3399114B3DC0CE6CD770957/Waagen.ino.partitions.bin" 0xe000 "C:\Users\Test\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1/tools/partitions/boot_app0.bin" 0x10000 "C:\Users\Test\AppData\Local\Temp\arduino\sketches\C5B8A5B0F3399114B3DC0CE6CD770957/Waagen.ino.bin"
esptool.py v4.6
Serial port COM3
Connecting.........Traceback (most recent call last):
File "esptool.py", line 37, in <module>
File "esptool_init_.py", line 1064, in main
File "esptool_init.py", line 859, in main
File "esptool\cmds.py", line 466, in write_flash
File "esptool\util.py", line 37, in flash_size_bytes
TypeError: argument of type 'NoneType' is not iterable
[9256] Failed to execute script 'esptool' due to unhandled exception!

Chip is ESP32-D0WD-V3 (revision v3.1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: a0:a3:b3:97:00:6c
Uploading stub...
Running stub...
Stub running...
WARNING: Failed to communicate with the flash chip, read/write operations will fail. Try checking the chip connections or removing any other hardware connected to IOs.
Configuring flash size...
Fehlgeschlagenes Hochladen: Hochladefehler: exit status 1

I really don't know how to proceed from here. I've googled extensively, initially tried it under Ubuntu, used different versions of the Arduino IDE, and selected various boards. When I connect via Putty at the same baud rate, I can see that the board starts without any issues...

ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x37 (SPI_FAST_FLASH_BOOT)
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
ets Jul 29 2019 12:21:46

rst:0x10 (RTCWDT_RTC_RESET),boot:0x37 (SPI_FAST_FLASH_BOOT)
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
ets Jul 29 2019 12:21:46

rst:0x10 (RTCWDT_RTC_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:7672
load:0x40078000,len:16432
load:0x40080400,len:3704
entry 0x4008067c
I (28) boot: ESP-IDF qa-test-v4.3.3-20220423 2nd stage bootloader
I (28) boot: compile time 11:11:52
I (28) boot: chip revision: 3
I (32) boot_comm: chip revision: 3, min. bootloader chip revision: 0
I (39) boot.esp32: SPI Speed      : 40MHz
I (43) boot.esp32: SPI Mode       : DIO
I (48) boot.esp32: SPI Flash Size : 4MB
I (53) boot: Enabling RNG early entropy source...
I (58) boot: Partition Table:
I (62) boot: ## Label            Usage          Type ST Offset   Length
I (69) boot:  0 phy_init         RF data          01 01 0000f000 00001000
I (76) boot:  1 otadata          OTA data         01 00 00010000 00002000
I (84) boot:  2 nvs              WiFi data        01 02 00012000 0000e000
I (91) boot:  3 at_customize     unknown          40 00 00020000 000e0000
I (99) boot:  4 ota_0            OTA app          00 10 00100000 00180000
I (106) boot:  5 ota_1            OTA app          00 11 00280000 00180000
I (114) boot: End of partition table
E (118) boot: ota data partition invalid and no factory, will try all partitions
I (126) boot_comm: chip revision: 3, min. application chip revision: 0
I (133) esp_image: segment 0: paddr=00100020 vaddr=3f400020 size=295d8h (169432)                                                         map
I (203) esp_image: segment 1: paddr=00129600 vaddr=3ffbdb60 size=04474h ( 17524)                                                         load
I (210) esp_image: segment 2: paddr=0012da7c vaddr=40080000 size=0259ch (  9628)                                                         load
I (214) esp_image: segment 3: paddr=00130020 vaddr=400d0020 size=111630h (111979                                                        2) map
I (623) esp_image: segment 4: paddr=00241658 vaddr=4008259c size=1b568h (111976)                                                         load
I (669) esp_image: segment 5: paddr=0025cbc8 vaddr=400c0000 size=00064h (   100)                                                         load
I (669) esp_image: segment 6: paddr=0025cc34 vaddr=50000000 size=00010h (    16)                                                         load
I (689) boot: Loaded app from partition at offset 0x100000
I (689) boot: Disabling RNG early entropy source...
module_name:WROOM-32
max tx power=78,ret=0
2.4.0

I hope someone here can point me in the right direction.. I would be grateful for any advice!

P.S.:

I don't know if it's relevant, but here's how I connected the scales (and the button for tare) to the board:

HX711 Module 1: DOUT (GPIO 32), SCK (GPIO 33)
HX711 Module 2: DOUT (GPIO 25), SCK (GPIO 26)
HX711 Module 3: DOUT (GPIO 27), SCK (GPIO 14)
HX711 Module 4: DOUT (GPIO 12), SCK (GPIO 13)
Button 1: Signal (GPIO 4)
Button 2: Signal (GPIO 16)
Button 3: Signal (GPIO 17)
Button 4: Signal (GPIO 18)

I hope someone can point me in the right direction.. I would be grateful for any advice!

Have you tried any older version in the IDE boards manager ?
You are probably using 3.0.1, try 2.0.11 (nothing to lose)

Hi @nerdlicht.

It is possible for a short or external circuitry connected to the Arduino board to interfere with the upload process, causing this type of upload error.

Make sure the board is not sitting on anything conductive that could short the contacts on the bottom of the board. Make sure there isn't any conductive debris (e.g., strands of wire or component leads) on the board or on the surface the board is sitting on.

If you have a shield or any external circuitry or components connected to your Arduino board, try this experiment:

  1. Disconnect the USB cable of the Arduino board from your computer.
  2. Disconnect any shields, modules, external circuitry, etc. from your board.
  3. Connect the Arduino board to your computer with a USB cable.

Now try uploading a sketch to the board again. Does the upload succeed?

This experiment will determine whether the upload error was caused by interference from your external circuitry. If so, you can then focus your attention on identifying the specific problem with the circuit and resolving it.

2 Likes

Thank you for the tip! You were actually right. It seems to be related to the connected components. After I disconnected everything from the board, I was able to upload the code successfully.

Then I was able to reconnect everything, boot the board, and the code executed. Now, I’m wondering if this is "normal"... do I actually have a short circuit somewhere? Or is it possible that everything is wired correctly, and it’s just because the components (buttons and HX711 modules) are connected?

To upload the code, I had to hold down the boot button on the board, briefly press the reset button, and only then was the upload possible. None of the guides I have read so far mentioned this. Is this normal?

Could my problems be related to which GPIO pins I used? I fed the board manual to ChatGPT and asked if the pins I used were okay, and this was the response. Can I ignore ChatGPT’s concerns, or should I avoid using pins 12 and 4?

Based on the provided GPIO pin allocation and the ESP32 Dev Kit C V4 documentation, here is an assessment of the pin usage:

### HX711 Modules
1. **HX711 Module 1**: 
   - DOUT (GPIO 32) - OK
   - SCK (GPIO 33) - OK
2. **HX711 Module 2**: 
   - DOUT (GPIO 25) - OK
   - SCK (GPIO 26) - OK
3. **HX711 Module 3**: 
   - DOUT (GPIO 27) - OK
   - SCK (GPIO 14) - OK
4. **HX711 Module 4**: 
   - DOUT (GPIO 12) - OK
   - SCK (GPIO 13) - OK

### Taster (Button) Pins
1. **Taster 1**: Signal (GPIO 4) - OK
2. **Taster 2**: Signal (GPIO 16) - OK
3. **Taster 3**: Signal (GPIO 17) - OK
4. **Taster 4**: Signal (GPIO 18) - OK

### Analysis
- **HX711 Modules**: All GPIOs used for the HX711 modules (GPIO 32, 33, 25, 26, 27, 14, 12, 13) are digital I/O pins and support the required functionalities for communication with the HX711 module.
- **Taster Pins**: GPIOs 4, 16, 17, and 18 are suitable for digital input from buttons. 

### Special Considerations
- **GPIO 12**: This pin has a special function and must be LOW during boot. Since it is used for the HX711 SCK, ensure the device connected to it does not interfere with the boot process  .
- **Pins HIGH at Boot**: GPIOs 1, 3, 5, 6 to 11, 14, and 15 may output PWM signals or change state to HIGH at boot. None of these pins are used in your configuration, so there should be no unexpected behavior during boot .
- **Strapping Pins**: GPIO 0, 2, 4, 5, 12, and 15 are used for boot mode selection. GPIO 4 is used for a button and GPIO 12 for the HX711 module. Ensure that these connections do not interfere with entering the correct boot mode when programming the ESP32 .

### Conclusion
The pin configuration you provided is appropriate for use with the ESP32 Dev Kit C V4, with special attention to GPIO 12 during boot. Ensure no peripherals connected to GPIO 12 interfere with the ESP32 booting process.

For further details, refer to the ESP32 documentation   .

My main concern would be about any connections to the pins that are marked "SPI" on the pinout:

image

The ESP8266 microcontroller uses an external flash memory chip. The sketch program is written to that chip during an upload. The pins on the ESP8266 microcontroller that are connected to the flash chip are also broken out to these pins on the board. If you connect things to those pins, it can interfere with the microcontroller's ability to communicate with the flash chip.

A post was split to a new topic: GPIO8 and GPIO9 are default SDA and SCL on the ESP32-S3 so neither of them can be used when uploading?

I have exactly the same board and error. What solved it for me was, unplugging the power on the VCC and GND pins I had powering an RS485 max board. Seems like it was maybe drawing too much power?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.