Hi, I'm trying to upload my code for 2 bldc motors to my ESP32-S2-MINI-2
I can't find this model on the board options, and when I try to upload code on the ATMegaZero ESP-32-S2, this happens:
Sketch uses 310915 bytes (14%) of program storage space. Maximum is 2097152 bytes.
Global variables use 34644 bytes (10%) of dynamic memory, leaving 293036 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.8.1
Serial port COM10
Connecting....
Chip is ESP32-S2FNR2 (revision v1.0)
Features: WiFi, Embedded Flash 4MB, Embedded PSRAM 2MB, ADC and temperature sensor calibration in BLK2 of efuse V2
Crystal is 40MHz
MAC: 70:04:1d:fb:8b:86
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
A fatal error occurred: File C:\Users(my name)\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.1/variants/atmegazero_esp32s2/tinyuf2.bin (length 139088) at offset 4259840 will not fit in 4194304 bytes of flash. Change the --flash_size argument, or flashing address.
Failed uploading: uploading error: exit status 2
This is the code:
#include <ESP32Servo.h>
Servo ESC;
Servo ESC2;
const int ESC_PIN = 32;
const int ESC2_PIN = 33;
const int POT = 36;
int potV = 0;
void setup() {
ESC.attach(ESC_PIN,1000,2000); // (pin, min pulse width, max pulse width in microseconds)
}
Could someone tell me how to fix this?
Hi @unpogged.
I took a look at the product page for the "ATMegaZero ESP32-S2" board and found this information:
https://atmegazero.com/#/atmegazero_esp32s2_specifications
- 256Mbit (32MB) SPI Flash but we can only use 16MB at the moment due to firmware limitations.
Despite the fact that there is 16 MB of usable flash memory on this board, the board definition creates a custom board options menu that allows us to select different flash sizes, and is configured to use 4 MB as the default setting. I can see you are using that default setting.
It makes sense to allow the configuration of the flash memory size in the generic board definitions like "ESP32S2 Dev Module" that are intended to support any arbitrary ESP32-S2-based board (the ESP32 microcontrollers use an external flash memory chip, and so the amount of flash is at the discretion of the board manufacturer). However, for a hardware product that has a specific flash size, it doesn't make any sense at all. My guess is that the board manufacturer didn't take the time to actually understand the board definition but rather simply copy/pasted one of the other board definitions.
So if the technical specs I referenced above are correct for your board (which I think is safe to assume if you bought it from the "ATMegaZero" company, but perhaps not so if you bought a clone of their board off Aliexpress or eBay), then you can fix the problem by simply selecting Tools > Flash Size > 16MB (128Mb) from the Arduino IDE menus and then trying another upload.