Skip to content

Add QURT to list of HALs we do not build bootloaders for - #33885

Open
peterbarker wants to merge 10 commits into
ArduPilot:masterfrom
peterbarker:pr-claude/bootloader-blacklist-linux-boards
Open

Add QURT to list of HALs we do not build bootloaders for#33885
peterbarker wants to merge 10 commits into
ArduPilot:masterfrom
peterbarker:pr-claude/bootloader-blacklist-linux-boards

Conversation

@peterbarker

Copy link
Copy Markdown
Contributor

Summary

Tweaks the list of boards where bootloader building is blacklisted to exclude QURT

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Description

... also removes a pair of Linux boards - they're already excluded because of their HAL.

@khancyr khancyr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

peterbarker and others added 10 commits July 30, 2026 19:16
… blacklist

canzero and t3-gem-o1 are AP_HAL_Linux boards, not ChibiOS boards, so
they are already added to the bootloader blacklist by the loop which
excludes every board whose hal is Linux, ESP32 or SITL.

No functional change; the returned set is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The loop which blacklists boards by HAL predates the addition of the
QURT HAL, so ModalAI-VOXL2 and ModalAI-VOXL3 were neither excluded by
HAL nor named in the explicit blacklist.  A bootloader build task was
therefore generated for them, which fails; QURT has no bootloader and
no hwdef-bl.dat.

No QURT board was named in the explicit blacklist, so nothing is
removed from there.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
shlex is a character-at-a-time lexer written in Python, and it
dominated the cost of processing hwdefs: 65% of the time spent parsing
all 443 ChibiOS hwdefs was inside shlex.split().

Almost no hwdef line needs it.  A line containing none of shlex's
special characters, whose whitespace is only spaces and tabs, is split
identically by str.split(); 99.1% of the lines the parser sees qualify.
Take that path when it applies and fall back to shlex otherwise.

Processing all 443 ChibiOS hwdefs goes from 1.39s to 0.45s.  The parse
state of all 490 boards, and the hwdef.h, ldscript.ld and hw.dat
generated for a sample of 13 boards and their bootloaders, are
unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
valid_type() rebuilt an 18-entry list of patterns and ran up to 18
uncompiled re.match() calls for every pin line in every hwdef.  Compile
the alternation once as a class member instead.

get_mcu_lib() called importlib.import_module() every time, which is
also once per pin line; remember the module we found.

Together these take processing all 443 ChibiOS hwdefs from 0.45s to
0.40s.  The parse state of all 490 boards is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Every line was split into words three times over: once by
process_file() to see whether it was an include line, once by the
HAL-specific process_line(), and once again by the base
process_line() the HAL-specific one delegates to.

Have process_line() take the words the caller has already split out,
and only split in process_file() for lines which could be an include.
That takes the number of splits done to process all 443 ChibiOS hwdefs
from 140374 to 56389, and the time from 0.40s to 0.35s.

The parse state of all 490 boards, and the hwdef.h, ldscript.ld and
hw.dat generated for a sample of 14 boards and their bootloaders, are
unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
valid_type() still ran nine uncompiled re.match() calls for every pin
line, cross-checking the peripheral number in a pin's type against the
one in its label.  Compile them once as class members.

Processing all 443 ChibiOS hwdefs goes from 0.35s to 0.32s.  The parse
state of all 490 boards is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Three places looped over af_labels asking whether a label named an
alternative function, and none of them used the entry which matched.
str.startswith() takes a tuple of prefixes and does the whole test at
once, so ask it that way instead; two of the three are in
get_alt_function(), which is called for every pin line.

Processing all 443 ChibiOS hwdefs goes from 0.335s to 0.325s.  The
parse state of all 490 boards is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A board which takes another board's bootloader says so in its own
hwdef, so there is no need to name it in the blacklist as well; 23 of
the 42 entries were doing that, and each new such board had to be
added here by hand.

Read the directive with board_list's hwdef_for_board() rather than by
matching the hwdef text, so that undefs, overrides and includes are
handled the way the build handles them.  This became affordable when
hwdef processing got faster: parsing all 443 ChibiOS hwdefs takes
0.33s, against the minutes or hours of building which follow.

Note that this deliberately does not treat a missing hwdef-bl.dat as
meaning a board has no bootloader.  A board which needs one but is
missing one must fail, not be silently skipped, so those boards stay
listed explicitly.

The returned set is unchanged: 89 boards, the same 89 as before.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Processing these hwdefs printed "<name> already in defines with same
value".  In four of them the board repeats a define it has just taken
from the hwdef it includes:

  DAKEFPVH743            DEFAULT_NTF_LED_TYPES  from DAKEFPVH743Pro
  MatekF765-Wing-bdshot  DEFAULT_NTF_LED_TYPES  from MatekF765-Wing
  SkystarsH7HDv2         AP_MSP_VIDEOTX_ENABLED from SkystarsH7HD-bdshot
  TBS_LUCID_H7_WING      DEFAULT_NTF_LED_TYPES  from TBS_LUCID_H7

and in the other two the same define appears twice in the one file:

  sparknavi-blue         HAL_WITH_RAMTRON
  esp32diy               HAL_LOGGING_BACKENDS_DEFAULT

The generated hwdef.h held each of these twice, as an identical
redefinition, and now holds it once; the value reaching the compiler is
unchanged.  hw.dat loses the line too, so it and the ROMFS which
embeds it are one line shorter.

Parsed state - defines, intdefines, config, pins and the rest - is
unchanged for all 490 boards.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Working out the blacklist parses every ChibiOS hwdef, which takes a
third of a second, and both build_boards.py and
size_compare_branches.py did it while starting up whether or not the
run would build a bootloader.

Make it a property filled in on first use.  All three places which
consult it already do so only for the bootloader vehicle, so a run
which does not build one now never parses a hwdef for this.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@peterbarker
peterbarker force-pushed the pr-claude/bootloader-blacklist-linux-boards branch from a1e2dbb to dd0440a Compare July 30, 2026 09:32
@peterbarker
peterbarker requested a review from khancyr July 30, 2026 09:34
@peterbarker

Copy link
Copy Markdown
Contributor Author

@khancyr thanks for the review - but I've now kinda extended the scope of this PR somewhat :-)

  • sped up parsing of hwdefs by a factor of 4
  • used hwdef parsing to decide if a board uses a bootloader from another board, so we can eliminate 19 entries from the list (and won't need more entries in the future....)
  • lazily fills in blacklist to avoid pointless startup overhead most of the time
  • prunes some crap out of some hwdef files which they inherit anyway

I'm currently doing a size_compare_branches.py for every single board to make sure this is a no-compiler-output change, results will be in tomorrow my time :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: ReadyForDevCall

Development

Successfully merging this pull request may close these issues.

2 participants