Skip to content

Commit 0bafb4e

Browse files
authored
Merge pull request #36 from kdschlosser/develop
Adds new command line parameters and removes the need to use "python3" in the build command
2 parents 89bb84d + d38ef69 commit 0bafb4e

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

builder/esp32.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,17 @@ def get_espidf():
138138
board = None
139139
skip_partition_resize = False
140140
partition_size = None
141+
flash_size = 8
142+
oct_flash = False
141143

142144

143145
def parse_args(extra_args, lv_cflags, brd):
144146
global board
145147
global board_variant
146148
global skip_partition_resize
147149
global partition_size
150+
global flash_size
151+
global oct_flash
148152

149153
board = brd
150154

@@ -166,6 +170,28 @@ def parse_args(extra_args, lv_cflags, brd):
166170
if arg.startswith('BOARD_VARIANT'):
167171
raise RuntimeError(f'BOARD_VARIANT not supported by "{board}"')
168172

173+
if board == 'ESP32_GENERIC_S3':
174+
esp_argParser = ArgumentParser(prefix_chars='-')
175+
176+
esp_argParser.add_argument(
177+
'--octal-flash',
178+
help='octal spi flash',
179+
dest='oct_flash',
180+
action='store_true'
181+
)
182+
183+
esp_argParser.add_argument(
184+
'--flash-size',
185+
dest='flash_size',
186+
help='flash size',
187+
default=8,
188+
type=int,
189+
action='store'
190+
)
191+
esp_args, extra_args = esp_argParser.parse_known_args(extra_args)
192+
flash_size = esp_args.flash_size
193+
oct_flash = esp_args.oct_flash
194+
169195
esp_argParser = ArgumentParser(prefix_chars='-')
170196

171197
esp_argParser.add_argument(
@@ -379,6 +405,65 @@ def submodules():
379405
def compile(): # NOQA
380406
env = setup_idf_environ()
381407

408+
if board == 'ESP32_GENERIC_S3':
409+
base_config = [
410+
'CONFIG_ESPTOOLPY_FLASHMODE_QIO=y',
411+
'CONFIG_ESPTOOLPY_FLASHFREQ_80M=y',
412+
'CONFIG_ESPTOOLPY_AFTER_NORESET=y',
413+
'CONFIG_PARTITION_TABLE_CUSTOM=y',
414+
]
415+
416+
if flash_size == 4:
417+
base_config.extend([
418+
'CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y',
419+
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=n',
420+
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=n',
421+
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=n',
422+
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4MiB.csv"'
423+
])
424+
elif flash_size == 8:
425+
base_config.extend([
426+
'CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n',
427+
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y',
428+
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=n',
429+
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=n',
430+
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"'
431+
])
432+
433+
elif flash_size == 16:
434+
base_config.extend([
435+
'CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n',
436+
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=n',
437+
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y',
438+
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=n',
439+
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-16MiB.csv"'
440+
])
441+
if flash_size == 32:
442+
base_config.extend([
443+
'CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n',
444+
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=n',
445+
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=n',
446+
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=y',
447+
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-32MiB.csv"'
448+
])
449+
else:
450+
base_config = [
451+
'CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n',
452+
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y',
453+
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=n',
454+
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=n',
455+
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"'
456+
]
457+
458+
if oct_flash:
459+
base_config[0] = 'CONFIG_ESPTOOLPY_FLASHMODE_DOUT=y'
460+
base_config.append('CONFIG_ESPTOOLPY_OCT_FLASH=y')
461+
462+
base_config = '\n'.join(base_config)
463+
464+
with open('lib/micropython/ports/esp32/boards/ESP32_GENERIC_S3/sdkconfig.board', 'w') as f:
465+
f.write(base_config + '\n')
466+
382467
if board in ('ESP32_GENERIC_S2', 'ESP32_GENERIC_S3'):
383468

384469
mphalport_path = 'lib/micropython/ports/esp32/mphalport.c'

make.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python3
2+
13
import os
24
import sys
35
import builder

0 commit comments

Comments
 (0)