mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 04:51:12 +02:00
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>
This commit is contained in:
committed by
Damien George
parent
b8e56a17b1
commit
95203ab88b
@@ -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.
|
||||
|
Reference in New Issue
Block a user