Skip to content

Add Adafruit esp32s2 boards with custom bootloader, partition and upload.extra_flags #5056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
400 changes: 400 additions & 0 deletions boards.txt

Large diffs are not rendered by default.

25 changes: 17 additions & 8 deletions platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,18 @@ build.loop_core=
build.event_core=
build.extra_flags=-DESP32 -DCORE_DEBUG_LEVEL={build.code_debug} {build.loop_core} {build.event_core} {build.defines} {build.extra_flags.{build.mcu}}

# Check if custom partitions exist
recipe.hooks.prebuild.1.pattern=bash -c "[ ! -f "{build.source.path}"/partitions.csv ] || cp -f "{build.source.path}"/partitions.csv "{build.path}"/partitions.csv"
recipe.hooks.prebuild.2.pattern=bash -c "[ -f "{build.path}"/partitions.csv ] || cp "{runtime.platform.path}"/tools/partitions/{build.partitions}.csv "{build.path}"/partitions.csv"
# Check if custom partitions exist: source > variant > build.partitions
recipe.hooks.prebuild.1.pattern=bash -c "[ ! -f {build.source.path}/partitions.csv ] || cp -f {build.source.path}/partitions.csv {build.path}/partitions.csv"
recipe.hooks.prebuild.2.pattern=bash -c "[ -f {build.path}/partitions.csv ] || [ ! -f {build.variant.path}/partitions.csv ] || cp {build.variant.path}/partitions.csv {build.path}/partitions.csv"
recipe.hooks.prebuild.3.pattern=bash -c "[ -f {build.path}/partitions.csv ] || cp {runtime.platform.path}/tools/partitions/{build.partitions}.csv {build.path}/partitions.csv"

recipe.hooks.prebuild.1.pattern.windows=cmd /c if exist "{build.source.path}\partitions.csv" COPY /y "{build.source.path}\partitions.csv" "{build.path}\partitions.csv"
recipe.hooks.prebuild.2.pattern.windows=cmd /c if not exist "{build.path}\partitions.csv" COPY "{runtime.platform.path}\tools\partitions\{build.partitions}.csv" "{build.path}\partitions.csv"
recipe.hooks.prebuild.2.pattern.windows=cmd /c if not exist "{build.path}\partitions.csv" if exist "{build.variant.path}\partitions.csv" COPY "{build.variant.path}\partitions.csv" "{build.path}\partitions.csv"
recipe.hooks.prebuild.3.pattern.windows=cmd /c if not exist "{build.path}\partitions.csv" COPY "{runtime.platform.path}\tools\partitions\{build.partitions}.csv" "{build.path}\partitions.csv"

# Check if custom bootloader exist: source > variant > build.boot
recipe.hooks.prebuild.4.pattern=bash -c "[ -f {build.source.path}/bootloader.bin ] && cp -f {build.source.path}/bootloader.bin {build.path}/{build.project_name}.bootloader.bin || ( [ -f {build.variant.path}/bootloader.bin ] && cp {build.variant.path}/bootloader.bin {build.path}/{build.project_name}.bootloader.bin || cp -f {runtime.platform.path}/tools/sdk/{build.mcu}/bin/bootloader_{build.boot}_{build.flash_freq}.bin {build.path}/{build.project_name}.bootloader.bin )"
recipe.hooks.prebuild.4.pattern.windows=cmd /c IF EXIST "{build.source.path}\bootloader.bin" ( COPY /y "{build.source.path}\bootloader.bin" "{build.path}\{build.project_name}.bootloader.bin" ) ELSE ( IF EXIST "{build.variant.path}\bootloader.bin" ( COPY "{build.variant.path}\bootloader.bin" "{build.path}\{build.project_name}.bootloader.bin" ) ELSE ( COPY /y "{runtime.platform.path}\tools\sdk\{build.mcu}\bin\bootloader_{build.boot}_{build.flash_freq}.bin" "{build.path}\{build.project_name}.bootloader.bin" ) )

## Compile c files
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" -DARDUINO_VARIANT="{build.variant}" {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
Expand All @@ -119,8 +126,9 @@ recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-Wl,--Map={build
recipe.objcopy.partitions.bin.pattern={tools.gen_esp32part.cmd} -q "{build.path}/partitions.csv" "{build.path}/{build.project_name}.partitions.bin"

## Create bin
recipe.objcopy.bin.pattern="{tools.esptool_py.path}/{tools.esptool_py.cmd}" --chip {build.mcu} elf2image --flash_mode "{build.flash_mode}" --flash_freq "{build.flash_freq}" --flash_size "{build.flash_size}" -o "{build.path}/{build.project_name}.bin" "{build.path}/{build.project_name}.elf"
recipe.objcopy.bin.pattern.linux=python "{tools.esptool_py.path}/{tools.esptool_py.cmd}" --chip {build.mcu} elf2image --flash_mode "{build.flash_mode}" --flash_freq "{build.flash_freq}" --flash_size "{build.flash_size}" -o "{build.path}/{build.project_name}.bin" "{build.path}/{build.project_name}.elf"
recipe.objcopy.bin.pattern_args=--chip {build.mcu} elf2image --flash_mode "{build.flash_mode}" --flash_freq "{build.flash_freq}" --flash_size "{build.flash_size}" -o "{build.path}/{build.project_name}.bin" "{build.path}/{build.project_name}.elf"
recipe.objcopy.bin.pattern="{tools.esptool_py.path}/{tools.esptool_py.cmd}" {recipe.objcopy.bin.pattern_args}
recipe.objcopy.bin.pattern.linux=python "{tools.esptool_py.path}/{tools.esptool_py.cmd}" {recipe.objcopy.bin.pattern_args}

## Save bin
recipe.output.tmp_file={build.project_name}.{build.mcu}.bin
Expand All @@ -136,6 +144,7 @@ recipe.size.regex.data=^(?:\.dram0\.data|\.dram0\.bss|\.noinit)\s+([0-9]+).*
tools.esptool_py.upload.protocol=esp32
tools.esptool_py.upload.params.verbose=
tools.esptool_py.upload.params.quiet=
tools.esptool_py.upload.pattern="{path}/{cmd}" --chip {build.mcu} --port "{serial.port}" --baud {upload.speed} {upload.flags} --before default_reset --after hard_reset write_flash -z --flash_mode {build.flash_mode} --flash_freq {build.flash_freq} --flash_size detect 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0x1000 "{runtime.platform.path}/tools/sdk/{build.mcu}/bin/bootloader_{build.boot}_{build.flash_freq}.bin" 0x10000 "{build.path}/{build.project_name}.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin"
tools.esptool_py.upload.pattern.linux=python "{path}/{cmd}" --chip {build.mcu} --port "{serial.port}" --baud {upload.speed} {upload.flags} --before default_reset --after hard_reset write_flash -z --flash_mode {build.flash_mode} --flash_freq {build.flash_freq} --flash_size detect 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0x1000 "{runtime.platform.path}/tools/sdk/{build.mcu}/bin/bootloader_{build.boot}_{build.flash_freq}.bin" 0x10000 "{build.path}/{build.project_name}.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin"
tools.esptool_py.upload.pattern_args=--chip {build.mcu} --port "{serial.port}" --baud {upload.speed} {upload.flags} --before default_reset --after hard_reset write_flash -z --flash_mode {build.flash_mode} --flash_freq {build.flash_freq} --flash_size detect 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0x1000 "{build.path}/{build.project_name}.bootloader.bin" 0x10000 "{build.path}/{build.project_name}.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin" {upload.extra_flags}
tools.esptool_py.upload.pattern="{path}/{cmd}" {upload.pattern_args}
tools.esptool_py.upload.pattern.linux=python "{path}/{cmd}" {upload.pattern_args}
tools.esptool_py.upload.network_pattern={network_cmd} -i "{serial.port}" -p "{network.port}" "--auth={network.password}" -f "{build.path}/{build.project_name}.bin"
Binary file added variants/adafruit_feather_esp32s2/bootloader.bin
Binary file not shown.
11 changes: 11 additions & 0 deletions variants/adafruit_feather_esp32s2/partitions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
# bootloader.bin,, 0x1000, 32K
# partition table, 0x8000, 4K

nvs, data, nvs, 0x9000, 20K,
otadata, data, ota, 0xe000, 8K,
ota_0, 0, ota_0, 0x10000, 1408K,
ota_1, 0, ota_1, 0x170000, 1408K,
uf2, app, factory,0x2d0000, 256K,
ffat, data, fat, 0x310000, 960K,
62 changes: 62 additions & 0 deletions variants/adafruit_feather_esp32s2/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <stdint.h>


#define USB_VID 0x239A
#define USB_PID 0x80EB
#define USB_MANUFACTURER "Adafruit"
#define USB_PRODUCT "Adafruit Feather ESP32-S2"
#define USB_SERIAL ""


#define EXTERNAL_NUM_INTERRUPTS 46
#define NUM_DIGITAL_PINS 48
#define NUM_ANALOG_INPUTS 20

#define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
#define digitalPinToInterrupt(p) (((p)<48)?(p):-1)
#define digitalPinHasPWM(p) (p < 46)

static const uint8_t PIN_NEOPIXEL = 33;
static const uint8_t PIN_NEOPIXEL_POWER = 21;
static const uint8_t LED_BUILTIN = 13;

static const uint8_t TX = 39;
static const uint8_t RX = 38;

static const uint8_t SDA = 3;
static const uint8_t SCL = 4;

static const uint8_t SS = 42;
static const uint8_t MOSI = 35;
static const uint8_t SCK = 36;
static const uint8_t MISO = 37;

static const uint8_t A0 = 18;
static const uint8_t A1 = 17;
static const uint8_t A2 = 16;
static const uint8_t A3 = 15;
static const uint8_t A4 = 14;
static const uint8_t A5 = 8;

static const uint8_t T1 = 1;
static const uint8_t T2 = 2;
static const uint8_t T3 = 3;
static const uint8_t T4 = 4;
static const uint8_t T5 = 5;
static const uint8_t T6 = 6;
static const uint8_t T7 = 7;
static const uint8_t T8 = 8;
static const uint8_t T9 = 9;
static const uint8_t T10 = 10;
static const uint8_t T11 = 11;
static const uint8_t T12 = 12;
static const uint8_t T13 = 13;
static const uint8_t T14 = 14;

static const uint8_t DAC1 = 17;
static const uint8_t DAC2 = 18;

#endif /* Pins_Arduino_h */
Binary file added variants/adafruit_feather_esp32s2/tinyuf2.bin
Binary file not shown.
Binary file added variants/adafruit_funhouse_esp32s2/bootloader.bin
Binary file not shown.
11 changes: 11 additions & 0 deletions variants/adafruit_funhouse_esp32s2/partitions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
# bootloader.bin,, 0x1000, 32K
# partition table, 0x8000, 4K

nvs, data, nvs, 0x9000, 20K,
otadata, data, ota, 0xe000, 8K,
ota_0, 0, ota_0, 0x10000, 1408K,
ota_1, 0, ota_1, 0x170000, 1408K,
uf2, app, factory,0x2d0000, 256K,
ffat, data, fat, 0x310000, 960K,
73 changes: 73 additions & 0 deletions variants/adafruit_funhouse_esp32s2/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <stdint.h>


#define USB_VID 0x239A
#define USB_PID 0x80F9

#define USB_MANUFACTURER "Adafruit"
#define USB_PRODUCT "Adafruit Funhouse ESP32-S2"
#define USB_SERIAL ""


#define EXTERNAL_NUM_INTERRUPTS 46
#define NUM_DIGITAL_PINS 48
#define NUM_ANALOG_INPUTS 20

#define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
#define digitalPinToInterrupt(p) (((p)<48)?(p):-1)
#define digitalPinHasPWM(p) (p < 46)

static const uint8_t PIN_DOTSTAR_DATA = 14;
static const uint8_t PIN_DOTSTAR_CLOCK = 15;
static const uint8_t LED_BUILTIN = 37;

static const uint8_t TX = 2;
static const uint8_t RX = 3;

static const uint8_t TFT_BACKLIGHT = 21;
static const uint8_t TFT_DC = 39;
static const uint8_t TFT_CS = 40;
static const uint8_t TFT_RESET = 41;

static const uint8_t SPEAKER = 42;
static const uint8_t BUTTON_DOWN = 3;
static const uint8_t BUTTON_SELECT = 4;
static const uint8_t BUTTON_UP = 5;
static const uint8_t SENSOR_PIR = 16;
static const uint8_t SENSOR_LIGHT = 18;

static const uint8_t SDA = 34;
static const uint8_t SCL = 33;

static const uint8_t SS = 40;
static const uint8_t MOSI = 35;
static const uint8_t SCK = 36;
static const uint8_t MISO = 37;

static const uint8_t A0 = 17;
static const uint8_t A1 = 2;
static const uint8_t A2 = 3;
static const uint8_t A3 = 18; // light sensor

static const uint8_t T1 = 1;
static const uint8_t T2 = 2;
static const uint8_t T3 = 3;
static const uint8_t T4 = 4;
static const uint8_t T5 = 5;
static const uint8_t T6 = 6;
static const uint8_t T7 = 7;
static const uint8_t T8 = 8;
static const uint8_t T9 = 9;
static const uint8_t T10 = 10;
static const uint8_t T11 = 11;
static const uint8_t T12 = 12;
static const uint8_t T13 = 13;
static const uint8_t T14 = 14;

static const uint8_t DAC1 = 17;
static const uint8_t DAC2 = 18;

#endif /* Pins_Arduino_h */
Binary file added variants/adafruit_funhouse_esp32s2/tinyuf2.bin
Binary file not shown.
Binary file added variants/adafruit_magtag29_esp32s2/bootloader.bin
Binary file not shown.
11 changes: 11 additions & 0 deletions variants/adafruit_magtag29_esp32s2/partitions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
# bootloader.bin,, 0x1000, 32K
# partition table, 0x8000, 4K

nvs, data, nvs, 0x9000, 20K,
otadata, data, ota, 0xe000, 8K,
ota_0, 0, ota_0, 0x10000, 1408K,
ota_1, 0, ota_1, 0x170000, 1408K,
uf2, app, factory,0x2d0000, 256K,
ffat, data, fat, 0x310000, 960K,
Binary file added variants/adafruit_magtag29_esp32s2/tinyuf2.bin
Binary file not shown.
Binary file added variants/adafruit_metro_esp32s2/bootloader.bin
Binary file not shown.
11 changes: 11 additions & 0 deletions variants/adafruit_metro_esp32s2/partitions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
# bootloader.bin,, 0x1000, 32K
# partition table, 0x8000, 4K

nvs, data, nvs, 0x9000, 20K,
otadata, data, ota, 0xe000, 8K,
ota_0, 0, ota_0, 0x10000, 1408K,
ota_1, 0, ota_1, 0x170000, 1408K,
uf2, app, factory,0x2d0000, 256K,
ffat, data, fat, 0x310000, 960K,
Binary file added variants/adafruit_metro_esp32s2/tinyuf2.bin
Binary file not shown.