PlatformIO's built-in upload breaks on the S2 Mini (1200bps USB touch reset disconnects the native USB port). All flash targets now call esptool directly with the correct S2 partition offsets: bootloader at 0x1000, firmware at 0x10000, LittleFS at 0x290000. Also adds USB.begin() before Serial.begin() in main.cpp — required for ESP32-S2 native USB-CDC to initialize properly.
46 lines
1016 B
Makefile
46 lines
1016 B
Makefile
.PHONY: build buildfs upload uploadfs monitor clean ota flash erase
|
|
|
|
# Serial port — override with: make upload PORT=/dev/ttyACM0
|
|
PORT ?= /dev/ttyACM2
|
|
BAUD ?= 921600
|
|
BUILD_DIR = .pio/build/lolin_s2_mini
|
|
|
|
# ESP32-S2 bootloader lives at 0x1000 (not 0x0 like S3/C3)
|
|
BOOTLOADER_OFFSET = 0x1000
|
|
|
|
# LittleFS partition offset (from partition table)
|
|
FS_OFFSET = 0x290000
|
|
|
|
ESPTOOL = ~/.platformio/penv/bin/esptool
|
|
|
|
build:
|
|
pio run
|
|
|
|
buildfs:
|
|
pio run -t buildfs
|
|
|
|
upload: build
|
|
$(ESPTOOL) --chip esp32s2 --port $(PORT) --baud $(BAUD) \
|
|
write_flash \
|
|
$(BOOTLOADER_OFFSET) $(BUILD_DIR)/bootloader.bin \
|
|
0x8000 $(BUILD_DIR)/partitions.bin \
|
|
0x10000 $(BUILD_DIR)/firmware.bin
|
|
|
|
uploadfs: buildfs
|
|
$(ESPTOOL) --chip esp32s2 --port $(PORT) --baud $(BAUD) \
|
|
write_flash $(FS_OFFSET) $(BUILD_DIR)/littlefs.bin
|
|
|
|
flash: upload uploadfs
|
|
|
|
monitor:
|
|
pio device monitor --port $(PORT)
|
|
|
|
erase:
|
|
$(ESPTOOL) --chip esp32s2 --port $(PORT) erase_flash
|
|
|
|
clean:
|
|
pio run -t clean
|
|
|
|
ota:
|
|
pio run -t upload --upload-port attenuator.local
|