Skip to content
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

Add s3 support #171

Merged
merged 14 commits into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions .github/workflows/build_esp32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-fast: false
matrix:
board:
# Alphabetical order
# S2 Alphabetical order
- 'adafruit_feather_esp32s2'
- 'adafruit_feather_esp32s2_tft'
- 'adafruit_feather_esp32s2_reverse_tft'
Expand Down Expand Up @@ -47,21 +47,21 @@ jobs:
- 'unexpectedmaker_feathers2'
- 'unexpectedmaker_feathers2_neo'
- 'unexpectedmaker_tinys2'
# S3 Alphabetical order
- 'espressif_esp32s3_devkitc_1'
- 'espressif_esp32s3_devkitm_1'
steps:
- name: Setup Python
uses: actions/setup-python@v2

- name: Pull ESP-IDF docker
run: docker pull espressif/idf:release-v4.4

- name: Checkout
uses: actions/checkout@v2

- name: Checkout submodules
run: git submodule update --init lib/tinyusb lib/uf2

- name: Build
run: docker run --rm -v $PWD:/project -w /project espressif/idf:release-v4.3 make -C ports/esp32s2/ BOARD=${{ matrix.board }} all self-update copy-artifact
run: docker run --rm -v $PWD:/project -w /project espressif/idf:release-v4.4 make -C ports/esp32s2/ BOARD=${{ matrix.board }} all self-update copy-artifact

- uses: actions/upload-artifact@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion lib/tinyusb
Submodule tinyusb updated 440 files
3 changes: 2 additions & 1 deletion ports/esp32s2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ if(NOT (DEFINED BOARD AND EXISTS "${CMAKE_SOURCE_DIR}/boards/${BOARD}/board.h")
message(FATAL_ERROR "Invalid BOARD specified")
endif()

include(${CMAKE_SOURCE_DIR}/boards/${BOARD}/board.cmake)

# TOP is absolute path to root directory
set(TOP "../..")
get_filename_component(TOP "${TOP}" REALPATH)
Expand All @@ -25,7 +27,6 @@ set(SDKCONFIG_DEFAULTS sdkconfig.defaults boards/${BOARD}/sdkconfig)
set(SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(SUPPORTED_TARGETS esp32s2)

execute_process(COMMAND git describe --dirty --always --tags
OUTPUT_VARIABLE GIT_VERSION
Expand Down
44 changes: 16 additions & 28 deletions ports/esp32s2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,13 @@ all:

build: all

app:
idf.py -B$(BUILD) -DBOARD=$(BOARD) app

clean:
idf.py -B$(BUILD) -DBOARD=$(BOARD) clean
@rm -rf $(BIN)

fullclean:
idf.py -B$(BUILD) -DBOARD=$(BOARD) fullclean
@rm -rf $(BIN)
@rm -rf $(SELF_BUILD)

flash:
idf.py -B$(BUILD) -DBOARD=$(BOARD) $(SERIAL_OPT) flash

bootloader-flash:
idf.py -B$(BUILD) -DBOARD=$(BOARD) $(SERIAL_OPT) bootloader-flash

app-flash:
idf.py -B$(BUILD) -DBOARD=$(BOARD) $(SERIAL_OPT) app-flash

erase:
idf.py -B$(BUILD) -DBOARD=$(BOARD) erase_flash

monitor:
idf.py -B$(BUILD) -DBOARD=$(BOARD) monitor

size-components:
idf.py -B$(BUILD) -DBOARD=$(BOARD) size-components

size-files:
idf.py -B$(BUILD) -DBOARD=$(BOARD) size-files
app bootloader clean flash bootloader-flash app-flash erase monitor dfu-flash dfu size size-components size-files:
idf.py -B$(BUILD) -DBOARD=$(BOARD) $(SERIAL_OPT) $@

$(BUILD)/combined.bin: app
UF2_OFFSET=`awk '{if(FNR==2)print $$1}' $(BUILD)/app-flash_args)`; \
Expand All @@ -63,13 +39,25 @@ $(BUILD)/combined.bin: app
#-------------- Self Update --------------
SELF_BUILD = apps/self_update/$(BUILD)

UF2_FAMILY_ID_S2 = 0xbfdd4eee
UF2_FAMILY_ID_S3 = 0xc47e5767

BOARD_CMAKE := $(file < boards/$(BOARD)/board.cmake)
ifneq ($(findstring esp32s2,$(BOARD_CMAKE)),)
UF2_FAMILY_ID := $(UF2_FAMILY_ID_S2)
else
ifneq ($(findstring esp32s3,$(BOARD_CMAKE)),)
UF2_FAMILY_ID := $(UF2_FAMILY_ID_S3)
endif
endif

$(SELF_BUILD)/update-tinyuf2.bin: app
$(PYTHON3) $(TOP)/lib/uf2/utils/uf2conv.py --carray $(BUILD)/tinyuf2.bin -o $(TOP)/apps/self_update/bootloader_bin.c
idf.py -C apps/self_update/ -B$(SELF_BUILD) -DBOARD=$(BOARD) app
@rm $(TOP)/apps/self_update/bootloader_bin.c

$(SELF_BUILD)/update-tinyuf2.uf2: $(SELF_BUILD)/update-tinyuf2.bin
$(PYTHON3) $(TOP)/lib/uf2/utils/uf2conv.py -f 0xbfdd4eee -b 0x0000 -c -o $@ $^
$(PYTHON3) $(TOP)/lib/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID) -b 0x0000 -c -o $@ $^

self-update: $(SELF_BUILD)/update-tinyuf2.uf2

Expand Down
8 changes: 5 additions & 3 deletions ports/esp32s2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ There are a few ways to enter UF2 mode:

## Convert Binary to UF2

To create your own UF2 file, simply use the [Python conversion script](https://github.com/Microsoft/uf2/blob/master/utils/uf2conv.py) on a .bin file, specifying the family as **0xbfdd4eee**. Note you must specify application address of 0x00 with the -b switch, the bootloader will use it as offset to write to ota partition.

To create a UF2 image from a .bin file using family option `ESP32S2` or its magic number as followss:
To create your own UF2 file, simply use the [Python conversion script](https://github.com/Microsoft/uf2/blob/master/utils/uf2conv.py) on a .bin file, specifying the family id as `ESP32S2`, ``ESP32S3` or their magic number as follows. Note you must specify application address of 0x00 with the -b switch, the bootloader will use it as offset to write to ota partition.

```
uf2conv.py firmware.bin -c -b 0x00 -f ESP32S2
uf2conv.py firmware.bin -c -b 0x00 -f 0xbfdd4eee

uf2conv.py firmware.bin -c -b 0x00 -f ESP32S3
uf2conv.py firmware.bin -c -b 0x00 -f 0xc47e5767

```

## 2nd Stage Bootloader
Expand Down
5 changes: 3 additions & 2 deletions ports/esp32s2/apps/self_update/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.5)

# Check for -DBOARD=
if(NOT (DEFINED BOARD AND EXISTS "${CMAKE_SOURCE_DIR}/../../boards/${BOARD}/board.h") )
file(GLOB BOARD_LIST RELATIVE ${CMAKE_SOURCE_DIR}/../boards "boards/*/board.h")
file(GLOB BOARD_LIST RELATIVE ${CMAKE_SOURCE_DIR}/../../boards "boards/*/board.h")

message("Please specify `-DBOARD=` with one of supported boards")
foreach(board IN LISTS BOARD_LIST)
Expand All @@ -15,14 +15,15 @@ if(NOT (DEFINED BOARD AND EXISTS "${CMAKE_SOURCE_DIR}/../../boards/${BOARD}/boar
message(FATAL_ERROR "Invalid BOARD specified")
endif()

include(${CMAKE_SOURCE_DIR}/../../boards/${BOARD}/board.cmake)

# TOP is absolute path to root directory
set(TOP "../../../..")
get_filename_component(TOP "${TOP}" REALPATH)

set(EXTRA_COMPONENT_DIRS "${TOP}/apps/self_update" "../../boards" "../../components")

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(SUPPORTED_TARGETS esp32s2)

add_compile_definitions(TINYUF2_SELF_UPDATE)

Expand Down
7 changes: 0 additions & 7 deletions ports/esp32s2/apps/self_update/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
CONFIG_IDF_CMAKE=y
CONFIG_IDF_TARGET="esp32s2"
CONFIG_IDF_TARGET_ESP32S2=y
CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y

# Partition Table
#CONFIG_PARTITION_TABLE_CUSTOM=y
#CONFIG_PARTITION_TABLE_OFFSET=0x8000
#CONFIG_PARTITION_TABLE_MD5=y

# Compiler options
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
Expand Down
2 changes: 2 additions & 0 deletions ports/esp32s2/boards/adafruit_feather_esp32s2/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply board specific content here
set(IDF_TARGET "esp32s2")
3 changes: 2 additions & 1 deletion ports/esp32s2/boards/adafruit_feather_esp32s2/sdkconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Board Specific Config

# Partition Table
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4MB.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions-4MB.csv"

# Serial flasher config
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply board specific content here
set(IDF_TARGET "esp32s2")
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Board Specific Config

# Partition Table
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4MB.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions-4MB.csv"

# Serial flasher config
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
2 changes: 2 additions & 0 deletions ports/esp32s2/boards/adafruit_feather_esp32s2_tft/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply board specific content here
set(IDF_TARGET "esp32s2")
3 changes: 2 additions & 1 deletion ports/esp32s2/boards/adafruit_feather_esp32s2_tft/sdkconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Board Specific Config

# Partition Table
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4MB.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions-4MB.csv"

# Serial flasher config
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
2 changes: 2 additions & 0 deletions ports/esp32s2/boards/adafruit_funhouse_esp32s2/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply board specific content here
set(IDF_TARGET "esp32s2")
3 changes: 2 additions & 1 deletion ports/esp32s2/boards/adafruit_funhouse_esp32s2/sdkconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Board Specific Config

# Partition Table
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4MB.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions-4MB.csv"

# Serial flasher config
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
2 changes: 2 additions & 0 deletions ports/esp32s2/boards/adafruit_magtag_29gray/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply board specific content here
set(IDF_TARGET "esp32s2")
3 changes: 2 additions & 1 deletion ports/esp32s2/boards/adafruit_magtag_29gray/sdkconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Board Specific Config

# Partition Table
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4MB.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions-4MB.csv"

# Serial flasher config
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
2 changes: 2 additions & 0 deletions ports/esp32s2/boards/adafruit_metro_esp32s2/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply board specific content here
set(IDF_TARGET "esp32s2")
3 changes: 2 additions & 1 deletion ports/esp32s2/boards/adafruit_metro_esp32s2/sdkconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Board Specific Config

# Partition Table
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4MB.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions-4MB.csv"

# Serial flasher config
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
2 changes: 2 additions & 0 deletions ports/esp32s2/boards/adafruit_qtpy_esp32s2/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply board specific content here
set(IDF_TARGET "esp32s2")
3 changes: 2 additions & 1 deletion ports/esp32s2/boards/adafruit_qtpy_esp32s2/sdkconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Board Specific Config

# Partition Table
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4MB.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions-4MB.csv"

# Serial flasher config
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
2 changes: 2 additions & 0 deletions ports/esp32s2/boards/artisense_rd00/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply board specific content here
set(IDF_TARGET "esp32s2")
3 changes: 2 additions & 1 deletion ports/esp32s2/boards/artisense_rd00/sdkconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Board Specific Config

# Partition Table
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4MB.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions-4MB.csv"

# Serial flasher config
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
2 changes: 2 additions & 0 deletions ports/esp32s2/boards/atmegazero_esp32s2/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply board specific content here
set(IDF_TARGET "esp32s2")
3 changes: 2 additions & 1 deletion ports/esp32s2/boards/atmegazero_esp32s2/sdkconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Board Specific Config

# Partition Table
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-16MB.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions-16MB.csv"

# Serial flasher config
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
10 changes: 9 additions & 1 deletion ports/esp32s2/boards/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@
extern "C" {
#endif

#include "sdkconfig.h"
#include "board.h"

// Family ID for updating Application
#define BOARD_UF2_FAMILY_ID 0xbfdd4eee
#if CONFIG_IDF_TARGET_ESP32S2
#define BOARD_UF2_FAMILY_ID 0xbfdd4eee
#elif CONFIG_IDF_TARGET_ESP32S3
#define BOARD_UF2_FAMILY_ID 0xc47e5767
#else
#error unsupported MCUs
#endif


// Flash Start Address of Application
#define BOARD_FLASH_APP_START 0
Expand Down
2 changes: 2 additions & 0 deletions ports/esp32s2/boards/espressif_esp32s3_devkitc_1/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply board specific content here
set(IDF_TARGET "esp32s3")
74 changes: 74 additions & 0 deletions ports/esp32s2/boards/espressif_esp32s3_devkitc_1/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 Ha Thach (tinyusb.org) for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#ifndef ESPRESSIF_S3_DEVKITC_H_
#define ESPRESSIF_S3_DEVKITC_H_

//--------------------------------------------------------------------+
// Button
//--------------------------------------------------------------------+

// Enter UF2 mode if GPIO is pressed while 2nd stage bootloader indicator
// is on e.g RGB = Purple. If it is GPIO0, user should not hold this while
// reset since that will instead run the 1st stage ROM bootloader
#define PIN_BUTTON_UF2 0

// GPIO that implement 1-bit memory with RC components which hold the
// pin value long enough for double reset detection.
// #define PIN_DOUBLE_RESET_RC

//--------------------------------------------------------------------+
// LED
//--------------------------------------------------------------------+

// GPIO connected to Neopixel data
#define NEOPIXEL_PIN 48

// Brightness percentage from 1 to 255
#define NEOPIXEL_BRIGHTNESS 0x10

// Number of neopixels
#define NEOPIXEL_NUMBER 1


// LED for indicator
// If not defined neopixel will be use for flash writing instead
// #define LED_PIN 42
// #define LED_STATE_ON 1

//--------------------------------------------------------------------+
// USB UF2
//--------------------------------------------------------------------+

#define USB_VID 0x239A
#define USB_PID 0x00A5 // TODO temporarily shared with S2 saola wrover
#define USB_MANUFACTURER "Espressif"
#define USB_PRODUCT "ESP32S3 DevKitC 1"

#define UF2_PRODUCT_NAME USB_MANUFACTURER " " USB_PRODUCT
#define UF2_BOARD_ID "ESP32S3-DevKitC-v1.0"
#define UF2_VOLUME_LABEL "S3DKC1BOOT"
#define UF2_INDEX_URL "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitm-1.html"

#endif
7 changes: 7 additions & 0 deletions ports/esp32s2/boards/espressif_esp32s3_devkitc_1/sdkconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Board Specific Config

# Partition Table
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MB.csv"

# Serial flasher config
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
2 changes: 2 additions & 0 deletions ports/esp32s2/boards/espressif_esp32s3_devkitm_1/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply board specific content here
set(IDF_TARGET "esp32s3")
Loading