Skip to content

Commit f2300ea

Browse files
committed
bootstrap.sh: limit Zephyr HALs by default
This reworks the current west.yml and bootstrap.sh so that only the HALs used by the Arduino core are installed by default. The list is directly taken from boards.txt, where each board has a 'zephyr_hal' entry. Since the HALs not named in the allowlist are discarded at Zephyr import time, an explicit list makes it impossible to later install every HAL. Instead, allow all HALs by path, then filter them by group using the 'manifest.project-filter' config that is automatically set by bootstrap.sh. This allows to enable all HALs, if needed, by simply removing the filter.
1 parent 5a4a6fb commit f2300ea

File tree

6 files changed

+53
-20
lines changed

6 files changed

+53
-20
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,20 @@ After running the `bootstrap.sh` script, you can symlink the core to `$sketchboo
181181

182182
## 🚀 Adding a new target
183183

184+
> [!TIP]
185+
>
186+
> While Zephyr supports a lot of different hardware targets, only the few
187+
> currently used by the Arduino core are installed by default. To add the
188+
> support for every Zephyr target to your workspace, run the following
189+
> commands:
190+
>
191+
> ```bash
192+
> . venv/bin/activate
193+
> west config -d manifest.project-filter
194+
> west sdk install --version 0.17.0
195+
> west update
196+
> ```
197+
184198
To add a new board that is already supported by mainline Zephyr with the target `$your_board`, follow these steps:
185199
186200
* Get the variant name from your board by running `extra/get_variant_name.sh $your_board`.
@@ -195,7 +209,10 @@ To add a new board that is already supported by mainline Zephyr with the target
195209
* Build the Loader: run `./extra/build.sh $your_board` (with any additional arguments as required) and start debugging the errors. :grin:
196210
* Update the `boards.txt`: add an entry for your board, manually filling the required fields.
197211
198-
In particular, set `build.zephyr_target` and `build.zephyr_args` to the arguments used in the `build.sh` call, and `build.variant` to the variant name identified above.
212+
Make sure to set:
213+
* `build.zephyr_target` and `build.zephyr_args` to the arguments used in the `build.sh` call;
214+
* `build.zephyr_hals` to the (space-separated list of) HAL modules required by the board;
215+
* `build.variant` to the variant name identified above.
199216
* Implement touch support: if your board supports the "1200bps touch" method, implement `_on_1200_bps` in a file located inside the variant folder of your board.
200217
201218
## 🐛 Bug Reporting

boards.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ giga.menu.debug.true.postbuild_debug=-debug
1414

1515
giga.build.zephyr_target=arduino_giga_r1//m7
1616
giga.build.zephyr_args=--shield arduino_giga_display_shield
17+
giga.build.zephyr_hals=hal_stm32
1718
giga.build.variant=arduino_giga_r1_stm32h747xx_m7
1819
giga.build.mcu=cortex-m7
1920
giga.build.fpu=-mfpu=fpv5-d16
@@ -79,6 +80,7 @@ nano33ble.menu.debug.true.postbuild_debug=-debug
7980

8081
nano33ble.build.zephyr_target=arduino_nano_33_ble//sense
8182
nano33ble.build.zephyr_args=
83+
nano33ble.build.zephyr_hals=hal_nordic
8284
nano33ble.build.variant=arduino_nano_33_ble_nrf52840_sense
8385
nano33ble.build.mcu=cortex-m4
8486
nano33ble.build.fpu=-mfpu=fpv4-sp-d16
@@ -142,6 +144,7 @@ ek_ra8d1.menu.debug.true.postbuild_debug=-debug
142144

143145
ek_ra8d1.build.zephyr_target=ek_ra8d1
144146
ek_ra8d1.build.zephyr_args=
147+
ek_ra8d1.build.zephyr_hals=hal_renesas
145148
ek_ra8d1.build.variant=ek_ra8d1_r7fa8d1bhecbd
146149
ek_ra8d1.build.mcu=cortex-m85+nomve
147150
ek_ra8d1.build.fpu=-mfpu=fpv5-d16
@@ -200,6 +203,7 @@ frdm_mcxn947.menu.debug.true.postbuild_debug=-debug
200203

201204
frdm_mcxn947.build.zephyr_target=frdm_mcxn947//cpu0
202205
frdm_mcxn947.build.zephyr_args=
206+
frdm_mcxn947.build.zephyr_hals=hal_nxp
203207
frdm_mcxn947.build.variant=frdm_mcxn947_mcxn947_cpu0
204208
frdm_mcxn947.build.mcu=cortex-m33
205209
frdm_mcxn947.build.fpu=-mfpu=fpv5-sp-d16
@@ -253,6 +257,7 @@ portentah7.menu.debug.true.postbuild_debug=-debug
253257

254258
255259
portentah7.build.zephyr_args=
260+
portentah7.build.zephyr_hals=hal_stm32
256261
portentah7.build.variant=arduino_portenta_h7_stm32h747xx_m7
257262
portentah7.build.mcu=cortex-m7
258263
portentah7.build.fpu=-mfpu=fpv5-d16
@@ -318,6 +323,7 @@ frdm_rw612.menu.debug.true.postbuild_debug=-debug
318323

319324
frdm_rw612.build.zephyr_target=frdm_rw612
320325
frdm_rw612.build.zephyr_args=
326+
frdm_rw612.build.zephyr_hals=hal_stm32
321327
frdm_rw612.build.variant=frdm_rw612_rw612
322328
frdm_rw612.build.mcu=cortex-m33+nodsp
323329
frdm_rw612.build.fpu=-mfpu=fpv5-sp-d16
@@ -370,6 +376,7 @@ niclasense.menu.debug.true.postbuild_debug=-debug
370376

371377
niclasense.build.zephyr_target=arduino_nicla_sense_me
372378
niclasense.build.zephyr_args=
379+
niclasense.build.zephyr_hals=hal_nordic
373380
niclasense.build.variant=arduino_nicla_sense_me_nrf52832
374381
niclasense.build.mcu=cortex-m4
375382
niclasense.build.fpu=-mfpu=fpv4-sp-d16
@@ -449,6 +456,7 @@ portentac33.menu.mode.linked.postbuild_mode=-prelinked
449456

450457
portentac33.build.zephyr_target=arduino_portenta_c33
451458
portentac33.build.zephyr_args=
459+
portentac33.build.zephyr_hals=hal_renesas
452460
portentac33.build.variant=arduino_portenta_c33_r7fa6m5bh3cfc
453461
portentac33.build.mcu=cortex-m33
454462
portentac33.build.fpu=-mfpu=fpv5-sp-d16
@@ -504,6 +512,7 @@ opta.menu.debug.true.postbuild_debug=-debug
504512

505513
opta.build.zephyr_target=arduino_opta//m7
506514
opta.build.zephyr_args=
515+
opta.build.zephyr_hals=hal_stm32
507516
opta.build.variant=arduino_opta_stm32h747xx_m7
508517
opta.build.mcu=cortex-m7
509518
opta.build.fpu=-mfpu=fpv5-d16

extra/bootstrap.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@ if [ ! -f platform.txt ]; then
55
exit 2
66
fi
77

8+
NEEDED_HALS=$(grep 'build.zephyr_hals=' boards.txt | cut -d '=' -f 2 | xargs -n 1 echo | sort -u)
9+
10+
HAL_FILTER="-hal_.*"
11+
for hal in $NEEDED_HALS; do
12+
HAL_FILTER="$HAL_FILTER,+$hal"
13+
done
14+
815
python3 -m venv venv
916
source venv/bin/activate
1017
pip install west
1118
west init -l .
19+
west config manifest.project-filter -- "$HAL_FILTER"
1220
west update "$@"
1321
west zephyr-export
1422
pip install -r ../zephyr/scripts/requirements-base.txt
1523
west sdk install --version 0.17.0 -t arm-zephyr-eabi
1624

17-
# add here the required blobs based on supported platforms
18-
west blobs fetch hal_nxp
25+
for hal in $NEEDED_HALS; do
26+
west blobs fetch $hal
27+
done

extra/build_all.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
FORCE=false
44

5-
while getopts "hfl" opt; do
5+
while getopts "hf" opt; do
66
case $opt in
77
h)
88
echo "Usage: $0 [-hfl]"

extra/get_board_details.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@ for BOARD in $(get_boards); do
1414
VARIANT=$(get_board_field $BOARD "variant")
1515
TARGET=$(get_board_field $BOARD "zephyr_target")
1616
ARGS=$(get_board_field $BOARD "zephyr_args")
17+
HALS=$(get_board_field $BOARD "zephyr_hals")
1718

1819
if [ -z "$TARGET" ] ; then
1920
echo "error: missing '$BOARD.build.zephyr_target'" 1>&2
2021
exit 1
2122
fi
23+
if [ -z "$HALS" ] ; then
24+
echo "error: missing '$BOARD.build.zephyr_hals'" 1>&2
25+
exit 1
26+
fi
2227

23-
echo "{ \"board\": \"$BOARD\", \"variant\": \"$VARIANT\", \"target\": \"$TARGET\", \"args\": \"$ARGS\" }"
28+
echo "{ \"board\": \"$BOARD\", \"variant\": \"$VARIANT\", \"target\": \"$TARGET\", \"args\": \"$ARGS\", \"hals\": \"$HALS\" }"
2429
done | jq -crs .

west.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,21 @@ manifest:
2626
name-allowlist:
2727
- cmsis
2828
- cmsis_6
29-
- hal_nordic
30-
- hal_ti
31-
- hal_ambiq
32-
- hal_espressif
33-
- hal_infineon
34-
- hal_intel
35-
- hal_nxp
36-
- hal_stm32
37-
- hal_xtensa
38-
- hal_nordic
39-
- hal_renesas
40-
- hal_adi
41-
- hal_atmel
42-
- hal_rpi_pico
43-
- hal_silabs
4429
- littlefs
4530
- tinycrypt
4631
- mbedtls
4732
- segger
4833
- thrift
4934
- mcuboot
5035
- lvgl
36+
path-allowlist:
37+
- modules/hal/*
38+
39+
# The actual list of enabled HALs is set by extra/bootstrap.sh via
40+
# the 'manifest.project-filter' config. Enable all Zephyr HALs with:
41+
#
42+
# west config -d manifest.project-filter
43+
5144
- name: ArduinoCore-API
5245
path: modules/lib/ArduinoCore-API
5346
revision: master

0 commit comments

Comments
 (0)