diff options
| author | Andrew Leech <andrew.leech@planetinnovation.com.au> | 2025-06-05 10:43:48 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-06-10 11:09:14 +1000 |
| commit | 95203ab88b50f5083c28afe6a39aae605b4df2da (patch) | |
| tree | 225f2aecb3da2e2bab51a692f301510add862b91 | |
| parent | b8e56a17b126fd990b7cdf3fb81944d504146f69 (diff) | |
tools/boardgen.py: Ensure board pin locals_dict has consistent order.
`tools/boardgen.py` is used by the `make-pins.py` scripts in many ports to
generate the pin definitions for the machine module.
In #17391 it was found that this is currently generating the C structs for
board pin definitions with inconsistent ordering (across different build
runs), which makes it sometimes impossible to get a consistent binary file
even for no change in source files.
This commit fixes that by sorting the board pin names alphabetically.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
| -rw-r--r-- | tools/boardgen.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/boardgen.py b/tools/boardgen.py index 39bedf71c..3723e7ce3 100644 --- a/tools/boardgen.py +++ b/tools/boardgen.py @@ -108,6 +108,10 @@ class Pin: ) ) + # Iterate over board pin names in consistent sorted order. + def board_pin_names(self): + return sorted(self._board_pin_names, key=lambda x: x[0]) + # Override this to handle an af specified in af.csv. def add_af(self, af_idx, af_name, af): raise NotImplementedError @@ -295,7 +299,7 @@ class PinGenerator: file=out_source, ) for pin in self.available_pins(): - for board_pin_name, board_hidden in pin._board_pin_names: + for board_pin_name, board_hidden in pin.board_pin_names(): if board_hidden: # Don't include hidden pins in Pins.board. continue @@ -389,7 +393,7 @@ class PinGenerator: # #define pin_BOARDNAME (pin_CPUNAME) if board: - for board_pin_name, _board_hidden in pin._board_pin_names: + for board_pin_name, _board_hidden in pin.board_pin_names(): # Note: Hidden board pins are still available to C via the macro. # Note: The RHS isn't wrapped in (), which is necessary to make the # STATIC_AF_ macro work on STM32. |
