Fixed Serial2 issue for ESP32C3, added arduino-build.

This commit is contained in:
Brad Nelson
2022-10-08 13:02:38 -07:00
parent 1826a75cd0
commit 97ab39160a
3 changed files with 97 additions and 3 deletions

View File

@ -484,6 +484,88 @@ $(ESP32)/ESP32forth/ESP32forth.ino: $(ESP32_PARTS) | $(ESP32)/ESP32forth
boot=@$(GEN)/esp32_boot.h \ boot=@$(GEN)/esp32_boot.h \
>$@ >$@
# ---- ESP32 ARDUINO BUILD AND FLASH ----
ARDUINO_BUILDER="/mnt/c/Program Files (x86)/Arduino/arduino-builder.exe"
ARDUINO="c:/Program Files (x86)/Arduino"
LOCALAPPDATA=$(subst \,/,$(shell cmd.exe /c echo %LOCALAPPDATA%))
ARDUINO_APP=${LOCALAPPDATA}/Arduino15
ARDUINO_APP_DIR=$(subst C:/,/mnt/c/,${ARDUINO_APP})
ESPTOOL=${ARDUINO_APP_DIR}/packages/esp32/tools/esptool_py/4.2.1/esptool.exe
ESP32_BOARD_esp32=-fqbn=esp32:esp32:esp32:PSRAM=disabled,PartitionScheme=no_ota,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,LoopCore=1,EventsCore=1,DebugLevel=none,EraseFlash=none
ESP32_BOARD_esp32s2=-fqbn=esp32:esp32:esp32s2:CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none,EraseFlash=none
ESP32_BOARD_esp32s3=-fqbn=esp32:esp32:esp32s3:PSRAM=disabled,FlashMode=qio,FlashSize=4M,LoopCore=1,EventsCore=1,USBMode=hwcdc,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PartitionScheme=default,CPUFreq=240,UploadSpeed=921600,DebugLevel=none,EraseFlash=none
ESP32_BOARD_esp32c3=-fqbn=esp32:esp32:esp32c3:CDCOnBoot=default,PartitionScheme=default,CPUFreq=160,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none,EraseFlash=none
ESP32_BOARD_esp32cam=-fqbn=esp32:esp32:esp32cam:CPUFreq=240,FlashMode=qio,PartitionScheme=huge_app,FlashFreq=80,DebugLevel=none,EraseFlash=none
$(ESP32)/%_build:
mkdir -p $@
$(ESP32)/%_cache:
mkdir -p $@
$(ESP32)/%_build/ESP32forth.ino.bin: $(ESP32)/ESP32forth/ESP32forth.ino | \
$(ESP32)/%_build $(ESP32)/%_cache
${ARDUINO_BUILDER} \
-hardware ${ARDUINO}/hardware \
-hardware ${ARDUINO_APP}/packages \
-tools ${ARDUINO}/tools-builder \
-tools ${ARDUINO}/hardware/tools/avr \
-tools ${ARDUINO_APP}/packages \
-built-in-libraries ${ARDUINO}/libraries \
-prefs=build.warn_data_percentage=75 \
${ESP32_BOARD_$(subst _build,,$(notdir $(word 1,$|)))} \
-build-path $(word 1,$|) \
-build-cache $(word 2,$|) \
$(ESP32)/ESP32forth/ESP32forth.ino
esp32all: \
$(ESP32)/esp32_build/ESP32forth.ino.bin \
$(ESP32)/esp32s2_build/ESP32forth.ino.bin \
$(ESP32)/esp32s3_build/ESP32forth.ino.bin \
$(ESP32)/esp32c3_build/ESP32forth.ino.bin \
$(ESP32)/esp32cam_build/ESP32forth.ino.bin
PORT?=COM3
BAUD_esp32=921600
BAUD_esp32s2=921600
BAUD_esp32s3=921600
BAUD_esp32c3=921600
BAUD_esp32cam=460800
BOOTLOADER_esp32=0x1000
BOOTLOADER_esp32s2=0x1000
BOOTLOADER_esp32s3=0x0
BOOTLOADER_esp32c3=0x0
BOOTLOADER_esp32cam=0x1000
CHIP_esp32=esp32
CHIP_esp32s2=esp32s2
CHIP_esp32s3=esp32s3
CHIP_esp32c3=esp32c3
CHIP_esp32cam=esp32
%-flash: $(ESP32)/%_build/ESP32forth.ino.bin
${ESPTOOL} \
--chip ${CHIP_$(subst -flash,,$@)} \
--baud ${BAUD_$(subst -flash,,$@)} \
--port ${PORT} \
--before default_reset \
--after hard_reset write_flash -z \
--flash_mode dio \
--flash_freq 80m \
--flash_size 4MB \
${BOOTLOADER_$(subst -flash,,$@)} $(ESP32)/$(subst -flash,,$@)_build/ESP32forth.ino.bootloader.bin \
0x8000 $(ESP32)/$(subst -flash,,$@)_build/ESP32forth.ino.partitions.bin \
0xe000 ${ARDUINO_APP}/packages/esp32/hardware/esp32/2.0.5/tools/partitions/boot_app0.bin \
0x10000 $(ESP32)/$(subst -flash,,$@)_build/ESP32forth.ino.bin
# ---- PACKAGE ---- # ---- PACKAGE ----
$(ESP32)/ESP32forth.zip: $(ESP32)/ESP32forth/ESP32forth.ino $(ESP32)/ESP32forth.zip: $(ESP32)/ESP32forth/ESP32forth.ino

View File

@ -38,6 +38,7 @@ static cell_t ResizeFile(cell_t fd, cell_t size);
REQUIRED_ESP_SUPPORT \ REQUIRED_ESP_SUPPORT \
REQUIRED_MEMORY_SUPPORT \ REQUIRED_MEMORY_SUPPORT \
REQUIRED_SERIAL_SUPPORT \ REQUIRED_SERIAL_SUPPORT \
OPTIONAL_SERIAL2_SUPPORT \
REQUIRED_ARDUINO_GPIO_SUPPORT \ REQUIRED_ARDUINO_GPIO_SUPPORT \
REQUIRED_SYSTEM_SUPPORT \ REQUIRED_SYSTEM_SUPPORT \
REQUIRED_FILES_SUPPORT \ REQUIRED_FILES_SUPPORT \
@ -94,7 +95,12 @@ static cell_t ResizeFile(cell_t fd, cell_t size);
XV(serial, "Serial.readBytes", SERIAL_READ_BYTES, n0 = Serial.readBytes(b1, n0); NIP) \ XV(serial, "Serial.readBytes", SERIAL_READ_BYTES, n0 = Serial.readBytes(b1, n0); NIP) \
XV(serial, "Serial.write", SERIAL_WRITE, n0 = Serial.write(b1, n0); NIP) \ XV(serial, "Serial.write", SERIAL_WRITE, n0 = Serial.write(b1, n0); NIP) \
XV(serial, "Serial.flush", SERIAL_FLUSH, Serial.flush()) \ XV(serial, "Serial.flush", SERIAL_FLUSH, Serial.flush()) \
XV(serial, "Serial.setDebugOutput", SERIAL_DEBUG_OUTPUT, Serial.setDebugOutput(n0); DROP) \ XV(serial, "Serial.setDebugOutput", SERIAL_DEBUG_OUTPUT, Serial.setDebugOutput(n0); DROP)
#ifndef ENABLE_SERIAL2_SUPPORT
# define OPTIONAL_SERIAL2_SUPPORT
#else
# define OPTIONAL_SERIAL2_SUPPORT \
XV(serial, "Serial2.begin", SERIAL2_BEGIN, Serial2.begin(tos); DROP) \ XV(serial, "Serial2.begin", SERIAL2_BEGIN, Serial2.begin(tos); DROP) \
XV(serial, "Serial2.end", SERIAL2_END, Serial2.end()) \ XV(serial, "Serial2.end", SERIAL2_END, Serial2.end()) \
XV(serial, "Serial2.available", SERIAL2_AVAILABLE, PUSH Serial2.available()) \ XV(serial, "Serial2.available", SERIAL2_AVAILABLE, PUSH Serial2.available()) \
@ -102,6 +108,7 @@ static cell_t ResizeFile(cell_t fd, cell_t size);
XV(serial, "Serial2.write", SERIAL2_WRITE, n0 = Serial2.write(b1, n0); NIP) \ XV(serial, "Serial2.write", SERIAL2_WRITE, n0 = Serial2.write(b1, n0); NIP) \
XV(serial, "Serial2.flush", SERIAL2_FLUSH, Serial2.flush()) \ XV(serial, "Serial2.flush", SERIAL2_FLUSH, Serial2.flush()) \
XV(serial, "Serial2.setDebugOutput", SERIAL2_DEBUG_OUTPUT, Serial2.setDebugOutput(n0); DROP) XV(serial, "Serial2.setDebugOutput", SERIAL2_DEBUG_OUTPUT, Serial2.setDebugOutput(n0); DROP)
#endif
#define REQUIRED_ARDUINO_GPIO_SUPPORT \ #define REQUIRED_ARDUINO_GPIO_SUPPORT \
Y(pinMode, pinMode(n1, n0); DROPn(2)) \ Y(pinMode, pinMode(n1, n0); DROPn(2)) \

View File

@ -33,8 +33,13 @@
# define ENABLE_SD_MMC_SUPPORT # define ENABLE_SD_MMC_SUPPORT
#endif #endif
// ESP32-C3 has no DACs. // Serial2 does not work on ESP32-S2 / ESP32-C3
#if !defined(CONFIG_IDF_TARGET_ESP32C3) #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
# define ENABLE_SERIAL2_SUPPORT
#endif
// No DACS on ESP32-S3 and ESP32-C3.
#if !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32C3)
# define ENABLE_DAC_SUPPORT # define ENABLE_DAC_SUPPORT
#endif #endif