Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd71e67f

Browse files
committed
expands --flash-size command line argument to support more SOC's
1 parent6ae9e26 commitd71e67f

File tree

2 files changed

+188
-54
lines changed

2 files changed

+188
-54
lines changed

‎README.md‎

Lines changed: 76 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,62 @@ installed (gcc, clang, msvc) and the necessary support libs.
3030

3131
###*Requirements*
3232
_________________
33-
Linux
33+
compiling for ESP32
34+
* Ubuntu (Linux): you can install all of these using`apt-get install`
35+
* build-essential
36+
* cmake
37+
* ninja-build
38+
* python
39+
40+
* macOS
41+
*`command xcode-select–install`
42+
*`brew install make`
43+
*`brew install cmake`
44+
*`brew install ninja`
45+
*`brew install python`
46+
47+
48+
Compiling for RP2
49+
* Ubuntu (Linux): you can install all of these using`apt-get install`
50+
* build-essential
51+
* cmake
52+
* ninja-build
53+
* python
54+
* gcc-arm-none-eabi
55+
* libnewlib-arm-none-eabi
56+
57+
* macOS
58+
*`command xcode-select–install`
59+
*`brew install make`
60+
*`brew install cmake`
61+
*`brew install ninja`
62+
*`brew install python`
63+
*`brew install armmbed/formulae/arm-none-eabi-gcc`
64+
65+
* Windows
66+
* Not yet supported
67+
68+
69+
Compiling for STM32:
70+
* Ubuntu (Linux): you can install all of these using`apt-get install`
71+
* gcc-arm-none-eabi
72+
* libnewlib-arm-none-eabi
73+
* build-essential
74+
* ninja-build
75+
* python
76+
77+
* macOS
78+
*`command xcode-select–install`
79+
*`brew install make`
80+
*`brew install ninja`
81+
*`brew install python`
82+
*`brew install armmbed/formulae/arm-none-eabi-gcc`
83+
84+
* Windows
85+
* Not yet supported
86+
87+
88+
Compiling for Ubuntu (Linux): you can install all of these using`apt-get install`
3489

3590
* build-essential
3691
* libffi-dev
@@ -65,19 +120,14 @@ Linux
65120
* libdecor-0-dev
66121

67122

68-
Compiling for STM32 unider Linux
69-
70-
* gcc-arm-none-eabi
71-
* libnewlib-arm-none-eabi
123+
Compiling for macOS
124+
*`command xcode-select–install`
125+
*`brew install libffi`
126+
*`brew install ninja`
127+
*`brew install make`
72128

73129

74-
OSX
75-
76-
* brew install llvm
77-
78-
79-
Windows
80-
130+
Compiling for Windows
81131
* not supported yet
82132

83133
<br>
@@ -94,6 +144,7 @@ The first argument is positional and it must be one of the following.
94144

95145
* esp32
96146
* windows
147+
* macOS
97148
* stm32
98149
* unix
99150
* rp2
@@ -155,7 +206,20 @@ ____________________
155206
____________________________
156207
* --skip-partition-resize: do not resize the firmware partition
157208
* --partition-size: set a custom firmware partition size
209+
* --octal-flash ¹: This is only available for the 16mb flash and the 32mb flash
210+
* --flash-size ² ³: This is how much flash storage is available.
211+
212+
Allowed Values are:
213+
214+
* ESP32-S3: 4, 8, 16 and 32 (default is 8)
215+
* ESP32-S2: 2 and 4 (default is 4)
216+
* ESP32: 4, 8 and 16 (default is 4)
217+
, The default is 8.
218+
158219

220+
¹ Available for the ESP32-S3 when`BOARD_VARIANT` is set to`SPIRAM_OCT`<br>
221+
² Available for the ESP32, ESP32-S2 and ESP32-S3<br>
222+
³ Available only when`BOARD_VARIANT` is set to`SPIRAM` or`SPIRAM_OCT`<br>
159223

160224
<br>
161225

‎builder/esp32.py‎

Lines changed: 112 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def get_espidf():
142142
board=None
143143
skip_partition_resize=False
144144
partition_size=None
145-
flash_size=8
145+
flash_size=0
146146
oct_flash=False
147147

148148

@@ -174,27 +174,59 @@ def parse_args(extra_args, lv_cflags, brd):
174174
ifarg.startswith('BOARD_VARIANT'):
175175
raiseRuntimeError(f'BOARD_VARIANT not supported by "{board}"')
176176

177-
ifboard=='ESP32_GENERIC_S3':
178-
esp_argParser=ArgumentParser(prefix_chars='-')
177+
ifboard_variantin ('SPIRAM','SPIRAM_OCT'):
178+
ifboard=='ESP32_GENERIC_S2':
179+
esp_argParser=ArgumentParser(prefix_chars='-')
180+
181+
esp_argParser.add_argument(
182+
'--flash-size',
183+
dest='flash_size',
184+
help='flash size',
185+
choices=(2,4),
186+
default=4,
187+
type=int,
188+
action='store'
189+
)
190+
esp_args,extra_args=esp_argParser.parse_known_args(extra_args)
191+
flash_size=esp_args.flash_size
192+
193+
ifboard=='ESP32_GENERIC':
194+
esp_argParser=ArgumentParser(prefix_chars='-')
195+
196+
esp_argParser.add_argument(
197+
'--flash-size',
198+
dest='flash_size',
199+
help='flash size',
200+
choices=(4,8,16),
201+
default=4,
202+
type=int,
203+
action='store'
204+
)
205+
esp_args,extra_args=esp_argParser.parse_known_args(extra_args)
206+
flash_size=esp_args.flash_size
179207

180-
esp_argParser.add_argument(
181-
'--octal-flash',
182-
help='octal spi flash',
183-
dest='oct_flash',
184-
action='store_true'
185-
)
208+
elifboard=='ESP32_GENERIC_S3':
209+
esp_argParser=ArgumentParser(prefix_chars='-')
186210

187-
esp_argParser.add_argument(
188-
'--flash-size',
189-
dest='flash_size',
190-
help='flash size',
191-
default=8,
192-
type=int,
193-
action='store'
194-
)
195-
esp_args,extra_args=esp_argParser.parse_known_args(extra_args)
196-
flash_size=esp_args.flash_size
197-
oct_flash=esp_args.oct_flash
211+
esp_argParser.add_argument(
212+
'--octal-flash',
213+
help='octal spi flash',
214+
dest='oct_flash',
215+
action='store_true'
216+
)
217+
218+
esp_argParser.add_argument(
219+
'--flash-size',
220+
dest='flash_size',
221+
help='flash size',
222+
choices=(4,8,16,32),
223+
default=8,
224+
type=int,
225+
action='store'
226+
)
227+
esp_args,extra_args=esp_argParser.parse_known_args(extra_args)
228+
flash_size=esp_args.flash_size
229+
oct_flash=esp_args.oct_flash
198230

199231
esp_argParser=ArgumentParser(prefix_chars='-')
200232

@@ -466,7 +498,10 @@ def submodules():
466498
defcompile():# NOQA
467499
env=setup_idf_environ()
468500

469-
ifboard=='ESP32_GENERIC_S3':
501+
if (
502+
boardin ('ESP32_GENERIC','ESP32_GENERIC_S2','ESP32_GENERIC_S3')and
503+
board_variantin ('SPIRAM','SPIRAM_OCT')
504+
):
470505
base_config= [
471506
'CONFIG_ESPTOOLPY_FLASHMODE_QIO=y',
472507
'CONFIG_ESPTOOLPY_FLASHFREQ_80M=y',
@@ -480,15 +515,17 @@ def compile(): # NOQA
480515
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=n',
481516
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=n',
482517
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=n',
483-
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4MiB.csv"'
518+
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME='
519+
'"partitions-4MiB.csv"'
484520
])
485521
elifflash_size==8:
486522
base_config.extend([
487523
'CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n',
488524
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y',
489525
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=n',
490526
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=n',
491-
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"'
527+
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME='
528+
'"partitions-8MiB.csv"'
492529
])
493530

494531
elifflash_size==16:
@@ -497,37 +534,70 @@ def compile(): # NOQA
497534
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=n',
498535
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y',
499536
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=n',
500-
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-16MiB.csv"'
537+
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME='
538+
'"partitions-16MiB.csv"'
501539
])
502540
ifflash_size==32:
503541
base_config.extend([
504542
'CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n',
505543
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=n',
506544
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=n',
507545
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=y',
508-
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-32MiB.csv"'
546+
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME='
547+
'"partitions-32MiB.csv"'
509548
])
510549
else:
511-
base_config= [
512-
'CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n',
513-
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y',
514-
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=n',
515-
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=n',
516-
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"'
517-
]
550+
raiseRuntimeError('unsupported flash size')
518551

519-
ifoct_flash:
520-
base_config[0]='CONFIG_ESPTOOLPY_FLASHMODE_DOUT=y'
521-
base_config.append('CONFIG_ESPTOOLPY_OCT_FLASH=y')
552+
ifboard=='ESP32_GENERIC_S3':
553+
ifoct_flashandflash_sizein (16,32):
554+
ifflash_size==32:
555+
base_config[0]='CONFIG_ESPTOOLPY_FLASHMODE_DOUT=y'
522556

523-
base_config='\n'.join(base_config)
557+
base_config.append('CONFIG_ESPTOOLPY_OCT_FLASH=y')
524558

525-
sdkconfig_board_path= (
526-
'lib/micropython/ports/esp32/'
527-
'boards/ESP32_GENERIC_S3/sdkconfig.board'
528-
)
529-
withopen(sdkconfig_board_path,'w')asf:
530-
f.write(base_config+'\n')
559+
base_config='\n'.join(base_config)
560+
561+
ifboardin ('ESP32_GENERIC','ESP32_GENERIC_S3'):
562+
mpconfigboard_cmake_path= (
563+
'lib/micropython/ports/esp32/boards/'
564+
f'{board}/mpconfigboard.cmake'
565+
)
566+
567+
withopen(mpconfigboard_cmake_path,'rb')asf:
568+
data=f.read().decode('utf-8')
569+
570+
iff'boards/{board}/sdkconfig.board'notindata:
571+
ifboard=='ESP32_GENERIC':
572+
data=data.replace(
573+
'boards/sdkconfig.spiram',
574+
'boards/sdkconfig.spiram\n '
575+
'boards/ESP32_GENERIC/sdkconfig.board'
576+
)
577+
else:
578+
data=data.replace(
579+
'boards/sdkconfig.spiram_ex',
580+
'boards/sdkconfig.spiram_ex\n '
581+
'boards/ESP32_GENERIC_S2/sdkconfig.board'
582+
)
583+
584+
withopen(mpconfigboard_cmake_path,'wb')asf:
585+
f.write(data.encode('utf-8'))
586+
587+
sdkconfig_spiram_path= (
588+
'lib/micropython/ports/esp32/boards/'
589+
f'{board}/sdkconfig.board'
590+
)
591+
withopen(sdkconfig_spiram_path,'w')asf:
592+
f.write(base_config)
593+
594+
else:
595+
sdkconfig_board_path= (
596+
'lib/micropython/ports/esp32/'
597+
f'boards/{board}/sdkconfig.board'
598+
)
599+
withopen(sdkconfig_board_path,'w')asf:
600+
f.write(base_config+'\n')
531601

532602
ifboardin ('ESP32_GENERIC_S2','ESP32_GENERIC_S3'):
533603

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp