Skip to content

Commit 272a2dc

Browse files
authored
Merge pull request adafruit#8218 from jepler/esp32-camera
Update the camera board to use ESP32-S3 microcontroller
2 parents 793df30 + cd181eb commit 272a2dc

File tree

15 files changed

+165
-133
lines changed

15 files changed

+165
-133
lines changed

docs/shared_bindings_matrix.py

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -148,66 +148,36 @@ def get_board_mapping():
148148
return boards
149149

150150

151-
def read_mpconfig():
152-
"""Open 'circuitpy_mpconfig.mk' and return the contents."""
153-
configs = []
154-
cpy_mpcfg = get_circuitpython_root_dir() / "py" / "circuitpy_mpconfig.mk"
155-
with open(cpy_mpcfg) as mpconfig:
156-
configs = mpconfig.read()
157-
158-
return configs
159-
160-
161151
def build_module_map():
162152
"""Establish the base of the JSON file, based on the contents from
163-
`configs`. Base will contain module names, if they're part of
164-
the `FULL_BUILD`, or their default value (0, 1, or a list of
165-
modules that determine default [see audiocore, audiomixer, etc.]).
166-
153+
`configs`. Base contains the module name and the controlling C macro name.
167154
"""
168155
base = dict()
169156
modules = get_bindings()
170-
configs = read_mpconfig()
171-
full_build = False
172157
for module in modules:
173158
full_name = module
174159
if module in ADDITIONAL_MODULES:
175160
search_identifier = ADDITIONAL_MODULES[module]
176161
else:
177162
search_identifier = "CIRCUITPY_" + module.lstrip("_").upper()
178-
re_pattern = f"{re.escape(search_identifier)}\s*\??=\s*(.+)"
179-
find_config = re.findall(re_pattern, configs)
180-
if not find_config:
181-
continue
182-
find_config = ", ".join([x.strip("$()") for x in find_config])
183-
184-
full_build = int("CIRCUITPY_FULL_BUILD" in find_config)
185-
if not full_build:
186-
default_val = find_config
187-
else:
188-
default_val = "None"
189163

190164
base[module] = {
191165
"name": full_name,
192-
"full_build": str(full_build),
193-
"default_value": default_val,
194-
"excluded": {},
195166
"key": search_identifier,
196167
}
197168

198169
return base
199170

200171

201172
def get_settings_from_makefile(port_dir, board_name):
202-
"""Invoke make in a mode which prints the database, then parse it for
203-
settings.
173+
"""Invoke make to print the value of critical build settings
204174
205175
This means that the effect of all Makefile directives is taken
206176
into account, without having to re-encode the logic that sets them
207177
in this script, something that has proved error-prone
208178
"""
209179
contents = subprocess.run(
210-
["make", "-C", port_dir, f"BOARD={board_name}", "-qp", "print-CC"],
180+
["make", "-C", port_dir, "-f", "Makefile", f"BOARD={board_name}", "print-CFLAGS", "print-CIRCUITPY_BUILD_EXTENSIONS", "print-FROZEN_MPY_DIRS"],
211181
encoding="utf-8",
212182
errors="replace",
213183
stdout=subprocess.PIPE,
@@ -223,9 +193,10 @@ def get_settings_from_makefile(port_dir, board_name):
223193

224194
settings = {}
225195
for line in contents.stdout.split("\n"):
226-
# Handle both = and := definitions.
227-
m = re.match(r"^([A-Z][A-Z0-9_]*) :?= (.*)$", line)
228-
if m:
196+
if line.startswith('CFLAGS ='):
197+
for m in re.findall('-D([A-Z][A-Z0-9_]*)=(\d+)', line):
198+
settings[m[0]] = m[1]
199+
elif m := re.match(r"^([A-Z][A-Z0-9_]*) = (.*)$", line):
229200
settings[m.group(1)] = m.group(2)
230201

231202
return settings
@@ -268,6 +239,10 @@ def get_repository_url(directory):
268239
repository_urls[directory] = path
269240
return path
270241

242+
def remove_prefix(s, prefix):
243+
if not s.startswith(prefix):
244+
raise ValueError(f"{s=} does not start with {prefix=}")
245+
return s.removeprefix(prefix)
271246

272247
def frozen_modules_from_dirs(frozen_mpy_dirs, withurl):
273248
"""
@@ -280,7 +255,8 @@ def frozen_modules_from_dirs(frozen_mpy_dirs, withurl):
280255
"""
281256
frozen_modules = []
282257
for frozen_path in filter(lambda x: x, frozen_mpy_dirs.split(" ")):
283-
source_dir = get_circuitpython_root_dir() / frozen_path[7:]
258+
frozen_path = remove_prefix(frozen_path, '../../')
259+
source_dir = get_circuitpython_root_dir() / frozen_path
284260
url_repository = get_repository_url(source_dir)
285261
for sub in source_dir.glob("*"):
286262
if sub.name in FROZEN_EXCLUDES:

ports/espressif/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,13 @@ $(BUILD)/esp-idf:
330330
TARGET_SDKCONFIG = esp-idf-config/sdkconfig-$(IDF_TARGET).defaults
331331

332332
ifeq ($(CIRCUITPY_ESP_FLASH_SIZE), 2MB)
333-
FLASH_SDKCONFIG = esp-idf-config/sdkconfig-$(CIRCUITPY_ESP_FLASH_SIZE)-no-ota-no-uf2.defaults
333+
FLASH_SDKCONFIG ?= esp-idf-config/sdkconfig-$(CIRCUITPY_ESP_FLASH_SIZE)-no-ota-no-uf2.defaults
334334
else
335335
UF2_BOOTLOADER ?= $(CIRCUITPY_USB)
336336
ifeq ($(UF2_BOOTLOADER), 1)
337-
FLASH_SDKCONFIG = esp-idf-config/sdkconfig-$(CIRCUITPY_ESP_FLASH_SIZE).defaults
337+
FLASH_SDKCONFIG ?= esp-idf-config/sdkconfig-$(CIRCUITPY_ESP_FLASH_SIZE).defaults
338338
else
339-
FLASH_SDKCONFIG = esp-idf-config/sdkconfig-$(CIRCUITPY_ESP_FLASH_SIZE)-no-uf2.defaults
339+
FLASH_SDKCONFIG ?= esp-idf-config/sdkconfig-$(CIRCUITPY_ESP_FLASH_SIZE)-no-uf2.defaults
340340
endif
341341
endif
342342

ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.mk

Lines changed: 0 additions & 10 deletions
This file was deleted.

ports/espressif/boards/adafruit_esp32s2_camera/sdkconfig

Lines changed: 0 additions & 33 deletions
This file was deleted.

ports/espressif/boards/adafruit_esp32s2_camera/board.c renamed to ports/espressif/boards/adafruit_esp32s3_camera/board.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void board_init(void) {
8484
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
8585
display_init_sequence,
8686
sizeof(display_init_sequence),
87-
&pin_GPIO41, // backlight pin
87+
NULL, // backlight pin
8888
NO_BRIGHTNESS_COMMAND,
8989
1.0f, // brightness
9090
false, // single_byte_bounds

ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h renamed to ports/espressif/boards/adafruit_esp32s3_camera/mpconfigboard.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@
2727
// Micropython setup
2828

2929
#define MICROPY_HW_BOARD_NAME "Adafruit Camera"
30-
#define MICROPY_HW_MCU_NAME "ESP32S2"
30+
#define MICROPY_HW_MCU_NAME "ESP32S3"
3131

32-
#define MICROPY_HW_NEOPIXEL (&pin_GPIO21)
32+
#define MICROPY_HW_NEOPIXEL (&pin_GPIO1)
3333
#define MICROPY_HW_NEOPIXEL_COUNT (1)
3434

35-
#define MICROPY_HW_LED_STATUS (&pin_GPIO1)
36-
3735
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO33)
3836
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO34)
3937

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
USB_VID = 0x239A
2+
USB_PID = 0x8118
3+
USB_PRODUCT = "Camera"
4+
USB_MANUFACTURER = "Adafruit"
5+
6+
IDF_TARGET = esp32s3
7+
8+
CIRCUITPY_ESP_FLASH_MODE = dio
9+
CIRCUITPY_ESP_FLASH_FREQ = 40m
10+
CIRCUITPY_ESP_FLASH_SIZE = 4MB
11+
FLASH_SDKCONFIG = esp-idf-config/sdkconfig-4MB-1ota.defaults
12+
13+
CIRCUITPY_AUDIOBUSIO = 0
14+
CIRCUITPY_CANIO = 0
15+
CIRCUITPY_ESPCAMERA = 1
16+
CIRCUITPY_FRAMEBUFFERIO = 0
17+
CIRCUITPY_KEYPAD = 0
18+
CIRCUITPY_ONEWIREIO = 0
19+
CIRCUITPY_PARALLELDISPLAY = 0
20+
CIRCUITPY_RGBMATRIX = 0
21+
CIRCUITPY_ROTARYIO = 0

ports/espressif/boards/adafruit_esp32s2_camera/pins.c renamed to ports/espressif/boards/adafruit_esp32s3_camera/pins.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
2424
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) },
2525
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) },
2626
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) },
27-
{ MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_GPIO41) },
28-
{ MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO40) },
29-
{ MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO39) },
3027
{ MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_GPIO38) },
28+
{ MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO39) },
29+
{ MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO40) },
3130

32-
{ MP_ROM_QSTR(MP_QSTR_CARD_CS), MP_ROM_PTR(&pin_GPIO2) },
31+
{ MP_ROM_QSTR(MP_QSTR_CARD_CS), MP_ROM_PTR(&pin_GPIO48) },
3332

3433
{ MP_ROM_QSTR(MP_QSTR_IRQ), MP_ROM_PTR(&pin_GPIO3) },
3534

36-
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO21) },
35+
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO1) },
3736

38-
{ MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO45) },
37+
{ MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO41) },
3938

4039
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) },
41-
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO1) },
40+
41+
{ MP_ROM_QSTR(MP_QSTR_BATTERY_MONITOR), MP_ROM_PTR(&pin_GPIO4) },
4242

4343
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO17) },
4444
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO18) },
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Component config
2+
#
3+
#
4+
# ESP32S3-Specific
5+
#
6+
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
7+
8+
#
9+
# SPI RAM config
10+
#
11+
CONFIG_SPIRAM_MODE_QUAD=y
12+
# CONFIG_SPIRAM_MODE_OCT is not set
13+
CONFIG_SPIRAM_TYPE_AUTO=y
14+
# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set
15+
# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set
16+
# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set
17+
CONFIG_SPIRAM_SIZE=2097152
18+
19+
#
20+
# PSRAM Clock and CS IO for ESP32S3
21+
#
22+
CONFIG_DEFAULT_PSRAM_CLK_IO=30
23+
CONFIG_DEFAULT_PSRAM_CS_IO=26
24+
# end of PSRAM Clock and CS IO for ESP32S3
25+
26+
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
27+
# CONFIG_SPIRAM_RODATA is not set
28+
# CONFIG_SPIRAM_SPEED_80M is not set
29+
CONFIG_SPIRAM_SPEED_80M=y
30+
# CONFIG_SPIRAM_SPEED_26M is not set
31+
# CONFIG_SPIRAM_SPEED_20M is not set
32+
CONFIG_SPIRAM=y
33+
CONFIG_SPIRAM_BOOT_INIT=y
34+
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
35+
CONFIG_SPIRAM_USE_MEMMAP=y
36+
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
37+
# CONFIG_SPIRAM_USE_MALLOC is not set
38+
CONFIG_SPIRAM_MEMTEST=y
39+
# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set
40+
# end of SPI RAM config
41+
42+
# end of ESP32S3-Specific
43+
44+
#
45+
# LWIP
46+
#
47+
CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3"
48+
# end of LWIP
49+
50+
# CONFIG_OV7670_SUPPORT is not set
51+
# CONFIG_NT99141_SUPPORT is not set
52+
CONFIG_OV3360_SUPPORT=n
53+
# CONFIG_OV2640_SUPPORT is not set
54+
CONFIG_OV5640_SUPPORT=y
55+
# CONFIG_GC2145_SUPPORT is not set
56+
# CONFIG_GC032A_SUPPORT is not set
57+
# CONFIG_GC0308_SUPPORT is not set
58+
# CONFIG_BF3005_SUPPORT is not set
59+
# CONFIG_BF20A6_SUPPORT is not set
60+
# CONFIG_SC101IOT_SUPPORT is not set
61+
# CONFIG_SC030IOT_SUPPORT is not set
62+
# end of Component config
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# ESP-IDF Partition Table
2+
# Name, Type, SubType, Offset, Size, Flags
3+
# bootloader.bin,, 0x1000, 32K
4+
# partition table, 0x8000, 4K
5+
6+
nvs, data, nvs, 0x9000, 20K,
7+
otadata, data, ota, 0xe000, 8K,
8+
ota_0, app, ota_0, 0x10000, 2816K,
9+
uf2, app, factory,0x2d0000, 256K,
10+
ffat, data, fat, 0x310000, 960K,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Serial flasher config
3+
#
4+
# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set
5+
# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set
6+
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
7+
# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set
8+
# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set
9+
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
10+
CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y
11+
# end of Serial flasher config
12+
13+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp-idf-config/partitions-4MB-1ota.csv"
14+
#
15+
# Partition Table
16+
#
17+
CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-4MB-1ota.csv"
18+
# end of Partition Table

ports/espressif/esp32-camera

ports/espressif/mpconfigport.mk

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ CIRCUITPY_FULL_BUILD ?= 1
1414
CIRCUITPY_ALARM ?= 1
1515
CIRCUITPY_ANALOGBUFIO ?= 1
1616
CIRCUITPY_AUDIOBUSIO ?= 1
17-
CIRCUITPY_AUDIOBUSIO_I2SOUT ?= 1
1817
CIRCUITPY_AUDIOBUSIO_PDMIN ?= 0
19-
CIRCUITPY_AUDIOCORE ?= 1
2018
CIRCUITPY_AUDIOIO ?= 0
21-
CIRCUITPY_AUDIOMIXER ?= 1
2219
CIRCUITPY_AUDIOMP3 ?= 0
2320
CIRCUITPY_BLEIO ?= 1
2421
CIRCUITPY_BLEIO_HCI = 0

ports/espressif/tools/build_memory_info.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ def find_region(start_address):
7373
ota = None
7474
app = None
7575
for partition in csv.reader(f):
76-
if partition[0][0] == "#":
76+
if not partition: # empty row
77+
continue
78+
if partition[0].startswith("#"):
7779
continue
7880
subtype = partition[2].strip()
7981
if subtype == "factory":

0 commit comments

Comments
 (0)