Skip to content

Commit d38ef69

Browse files
committed
adds --octal-flash and --flash-size for an ESP32_GENERIC_S3 build
There are variants of the esp32-s3 that have 4mb, 8mb, 16mb and 32mb flash and that is what using --flash-size=? allows us to set. The --octal-flash you have to add if the flash uses octal SPI. This is seen with the 32mb flash size. There are some changes that need to occur in order for the flash to work properly. So if you have an esp32-s3 N32R8 you will want to use the following build command ``` make.py esp32 clean submodules mpy_cross BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT --octal-flash --flash-size=32 ```
1 parent c4b34c4 commit d38ef69

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-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'

0 commit comments

Comments
 (0)