diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2023-08-03 15:21:32 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-11-03 13:59:19 +1100 |
commit | fc54d25a456359fdf044f28d2700b658e323c6e5 (patch) | |
tree | 0df8c4b0aacbbb6fd1e32e7d17f57e43d5c57017 | |
parent | c3c7c602da724b697a71c19ebce3e49c67e760f6 (diff) |
stm32/boards/make-pins.py: Don't generate qstrs.
Qstrs are picked up from the generated pin source files in the usual qstr
processing stage.
Similarly for the stm constant qstrs.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
-rw-r--r-- | ports/stm32/Makefile | 26 | ||||
-rwxr-xr-x | ports/stm32/boards/make-pins.py | 38 | ||||
-rw-r--r-- | ports/stm32/make-stmconst.py | 30 | ||||
-rwxr-xr-x | ports/stm32/mboot/Makefile | 3 |
4 files changed, 17 insertions, 80 deletions
diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile index 8d920ae95..3bb18ee3c 100644 --- a/ports/stm32/Makefile +++ b/ports/stm32/Makefile @@ -25,12 +25,11 @@ include ../../py/mkenv.mk -include mpconfigport.mk include $(BOARD_DIR)/mpconfigboard.mk -# Files that are generated and needed before the QSTR build. -QSTR_GENERATED_HEADERS = $(GEN_PINS_QSTR) $(GEN_STMCONST_QSTR) - # qstr definitions (must come before including py.mk) -QSTR_DEFS += qstrdefsport.h $(QSTR_GENERATED_HEADERS) -QSTR_GLOBAL_DEPENDENCIES += mpconfigboard_common.h $(BOARD_DIR)/mpconfigboard.h $(QSTR_GENERATED_HEADERS) +QSTR_DEFS += qstrdefsport.h + +# Files that are generated and needed before the QSTR build. +QSTR_GLOBAL_DEPENDENCIES += mpconfigboard_common.h $(BOARD_DIR)/mpconfigboard.h $(GEN_STMCONST_HDR) # MicroPython feature configurations MICROPY_ROM_TEXT_COMPRESSION ?= 1 @@ -71,7 +70,6 @@ BOARD_PINS = $(BOARD_DIR)/pins.csv PREFIX_FILE = boards/stm32f4xx_prefix.c GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c GEN_PINS_HDR = $(HEADER_BUILD)/pins.h -GEN_PINS_QSTR = $(BUILD)/pins_qstr.h GEN_PINS_AF_CONST = $(HEADER_BUILD)/pins_af_const.h GEN_PINS_AF_DEFS = $(HEADER_BUILD)/pins_af_defs.h GEN_PINS_AF_PY = $(BUILD)/pins_af.py @@ -86,7 +84,6 @@ GEN_CDCINF_HEADER = $(HEADER_BUILD)/pybcdc_inf.h GEN_PLLFREQTABLE_HDR = $(HEADER_BUILD)/pllfreqtable.h GEN_STMCONST_HDR = $(HEADER_BUILD)/modstm_const.h -GEN_STMCONST_QSTR = $(BUILD)/modstm_qstr.h GEN_STMCONST_MPZ = $(HEADER_BUILD)/modstm_mpz.h CMSIS_MCU_HDR = $(STM32LIB_CMSIS_ABS)/Include/$(CMSIS_MCU_LOWER).h @@ -655,7 +652,7 @@ $(BUILD)/firmware.elf: $(OBJ) $(call GENERATE_ELF,$@,$^) # List of sources for qstr extraction -SRC_QSTR += $(SRC_C) $(SRC_CXX) $(SHARED_SRC_C) +SRC_QSTR += $(SRC_C) $(SRC_CXX) $(SHARED_SRC_C) $(GEN_PINS_SRC) # Append any auto-generated sources that are needed by sources listed in # SRC_QSTR SRC_QSTR_AUTO_DEPS += $(GEN_CDCINF_HEADER) @@ -676,13 +673,12 @@ main.c: $(GEN_CDCINF_HEADER) # Use a pattern rule here so that make will only call make-pins.py once to make # both pins_$(BOARD).c and pins.h -$(BUILD)/%_$(BOARD).c $(HEADER_BUILD)/%.h $(HEADER_BUILD)/%_af_const.h $(HEADER_BUILD)/%_af_defs.h $(BUILD)/%_qstr.h: $(BOARD_DIR)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD) +$(BUILD)/%_$(BOARD).c $(HEADER_BUILD)/%.h $(HEADER_BUILD)/%_af_const.h $(HEADER_BUILD)/%_af_defs.h: $(BOARD_DIR)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD) $(ECHO) "GEN $@" $(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) \ --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --hdr-obj-decls \ - --qstr $(GEN_PINS_QSTR) --af-const $(GEN_PINS_AF_CONST) \ - --af-defs $(GEN_PINS_AF_DEFS) --af-defs-cmp-strings \ - --af-py $(GEN_PINS_AF_PY) > $(GEN_PINS_SRC) + --af-const $(GEN_PINS_AF_CONST) --af-defs $(GEN_PINS_AF_DEFS) \ + --af-defs-cmp-strings --af-py $(GEN_PINS_AF_PY) > $(GEN_PINS_SRC) modmachine.c: $(GEN_PLLFREQTABLE_HDR) $(GEN_PLLFREQTABLE_HDR): $(PLLVALUES) | $(HEADER_BUILD) @@ -690,11 +686,9 @@ $(GEN_PLLFREQTABLE_HDR): $(PLLVALUES) | $(HEADER_BUILD) $(Q)$(PYTHON) $(PLLVALUES) -c -m $(CMSIS_MCU_LOWER) file:$(BOARD_DIR)/stm32$(MCU_SERIES)xx_hal_conf.h > $@ $(BUILD)/modstm.o: $(GEN_STMCONST_HDR) -# Use a pattern rule here so that make will only call make-stmconst.py once to -# make both modstm_const.h and modstm_qstr.h -$(HEADER_BUILD)/%_const.h $(BUILD)/%_qstr.h: $(CMSIS_MCU_HDR) make-stmconst.py | $(HEADER_BUILD) +$(HEADER_BUILD)/modstm_const.h: $(CMSIS_MCU_HDR) make-stmconst.py | $(HEADER_BUILD) $(ECHO) "GEN stmconst $@" - $(Q)$(PYTHON) make-stmconst.py --qstr $(GEN_STMCONST_QSTR) --mpz $(GEN_STMCONST_MPZ) $(CMSIS_MCU_HDR) > $(GEN_STMCONST_HDR) + $(Q)$(PYTHON) make-stmconst.py --mpz $(GEN_STMCONST_MPZ) $(CMSIS_MCU_HDR) > $(GEN_STMCONST_HDR) $(GEN_CDCINF_HEADER): $(GEN_CDCINF_FILE) $(FILE2H) | $(HEADER_BUILD) $(ECHO) "GEN $@" diff --git a/ports/stm32/boards/make-pins.py b/ports/stm32/boards/make-pins.py index a3e6ee066..f0fcb8243 100755 --- a/ports/stm32/boards/make-pins.py +++ b/ports/stm32/boards/make-pins.py @@ -188,9 +188,6 @@ class AlternateFunction(object): ) print_conditional_endif(cond_var) - def qstr_list(self): - return [self.mux_name()] - class Pin(object): """Holds the information associated with a pin.""" @@ -301,13 +298,6 @@ class Pin(object): if self.alt_fn_count > 0: hdr_file.write("extern const pin_af_obj_t pin_{:s}_af[];\n".format(n)) - def qstr_list(self): - result = [] - for alt_fn in self.alt_fn: - if alt_fn.is_supported(): - result += alt_fn.qstr_list() - return result - class NamedPin(object): def __init__(self, name, pin): @@ -462,26 +452,6 @@ class Pins(object): ) ) - def print_qstr(self, qstr_filename): - with open(qstr_filename, "wt") as qstr_file: - qstr_set = set([]) - for named_pin in self.cpu_pins: - pin = named_pin.pin() - if pin.is_board_pin(): - qstr_set |= set(pin.qstr_list()) - qstr_set |= set([named_pin.name()]) - for named_pin in self.board_pins: - if not named_pin.is_hidden(): - qstr_set |= set([named_pin.name()]) - for qstr in sorted(qstr_set): - cond_var = None - if qstr.startswith("AF"): - af_words = qstr.split("_") - cond_var = conditional_var(af_words[1]) - print_conditional_if(cond_var, file=qstr_file) - print("Q({})".format(qstr), file=qstr_file) - print_conditional_endif(cond_var, file=qstr_file) - def print_af_hdr(self, af_const_filename): with open(af_const_filename, "wt") as af_const_file: af_hdr_set = set([]) @@ -598,13 +568,6 @@ def main(): default="stm32f4xx_prefix.c", ) parser.add_argument( - "-q", - "--qstr", - dest="qstr_filename", - help="Specifies name of generated qstr header file", - default="build/pins_qstr.h", - ) - parser.add_argument( "-r", "--hdr", dest="hdr_filename", @@ -640,7 +603,6 @@ def main(): for i in range(1, 4): pins.print_adc(i) pins.print_header(args.hdr_filename, args.hdr_obj_decls) - pins.print_qstr(args.qstr_filename) pins.print_af_hdr(args.af_const_filename) pins.print_af_py(args.af_py_filename) pins.print_af_defs(args.af_defs_filename, args.af_defs_cmp_strings) diff --git a/ports/stm32/make-stmconst.py b/ports/stm32/make-stmconst.py index 4e4f2d715..6d64fe3cf 100644 --- a/ports/stm32/make-stmconst.py +++ b/ports/stm32/make-stmconst.py @@ -183,22 +183,20 @@ def print_int_obj(val, needed_mpzs): needed_mpzs.add(val) -def print_periph(periph_name, periph_val, needed_qstrs, needed_mpzs): +def print_periph(periph_name, periph_val, needed_mpzs): qstr = periph_name.upper() print("{ MP_ROM_QSTR(MP_QSTR_%s), " % qstr, end="") print_int_obj(periph_val, needed_mpzs) print(" },") - needed_qstrs.add(qstr) -def print_regs(reg_name, reg_defs, needed_qstrs, needed_mpzs): +def print_regs(reg_name, reg_defs, needed_mpzs): reg_name = reg_name.upper() for r in reg_defs: qstr = reg_name + "_" + r[0] print("{ MP_ROM_QSTR(MP_QSTR_%s), " % qstr, end="") print_int_obj(r[1], needed_mpzs) print(" }, // %s-bits, %s" % (r[2], r[3])) - needed_qstrs.add(qstr) # This version of print regs groups registers together into submodules (eg GPIO submodule). @@ -208,7 +206,7 @@ def print_regs(reg_name, reg_defs, needed_qstrs, needed_mpzs): # As such, we don't use this version. # And for the number of constants we have, this function seems to use about the same amount # of ROM as print_regs. -def print_regs_as_submodules(reg_name, reg_defs, modules, needed_qstrs): +def print_regs_as_submodules(reg_name, reg_defs, modules): mod_name_lower = reg_name.lower() + "_" mod_name_upper = mod_name_lower.upper() modules.append((mod_name_lower, mod_name_upper)) @@ -220,14 +218,12 @@ STATIC const mp_rom_map_elem_t stm_%s_globals_table[] = { """ % (mod_name_lower, mod_name_upper) ) - needed_qstrs.add(mod_name_upper) for r in reg_defs: print( " { MP_ROM_QSTR(MP_QSTR_%s), MP_ROM_INT(%#x) }, // %s-bits, %s" % (r[0], r[1], r[2], r[3]) ) - needed_qstrs.add(r[0]) print( """}; @@ -248,13 +244,6 @@ def main(): cmd_parser = argparse.ArgumentParser(description="Extract ST constants from a C header file.") cmd_parser.add_argument("file", nargs=1, help="input file") cmd_parser.add_argument( - "-q", - "--qstr", - dest="qstr_filename", - default="build/stmconst_qstr.h", - help="Specified the name of the generated qstr header file", - ) - cmd_parser.add_argument( "--mpz", dest="mpz_filename", default="build/stmconst_mpz.h", @@ -269,14 +258,13 @@ def main(): reg_defs["GPIO"].append(["BSRRL", 0x18, 16, "legacy register"]) reg_defs["GPIO"].append(["BSRRH", 0x1A, 16, "legacy register"]) - needed_qstrs = set() needed_mpzs = set() print("// Automatically generated from %s by make-stmconst.py" % args.file[0]) print("") for periph_name, periph_val in periphs: - print_periph(periph_name, periph_val, needed_qstrs, needed_mpzs) + print_periph(periph_name, periph_val, needed_mpzs) for reg in ( "ADC", @@ -309,8 +297,8 @@ def main(): "IPCC", ): if reg in reg_defs: - print_regs(reg, reg_defs[reg], needed_qstrs, needed_mpzs) - # print_regs_as_submodules(reg, reg_defs[reg], modules, needed_qstrs) + print_regs(reg, reg_defs[reg], needed_mpzs) + # print_regs_as_submodules(reg, reg_defs[reg], modules) # print("#define MOD_STM_CONST_MODULES \\") # for mod_lower, mod_upper in modules: @@ -318,12 +306,6 @@ def main(): print("") - with open(args.qstr_filename, "wt") as qstr_file: - print("#if MICROPY_PY_STM_CONST", file=qstr_file) - for qstr in sorted(needed_qstrs): - print("Q({})".format(qstr), file=qstr_file) - print("#endif // MICROPY_PY_STM_CONST", file=qstr_file) - with open(args.mpz_filename, "wt") as mpz_file: for mpz in sorted(needed_mpzs): assert 0 <= mpz <= 0xFFFFFFFF diff --git a/ports/stm32/mboot/Makefile b/ports/stm32/mboot/Makefile index 54fc8f483..a37b046ca 100755 --- a/ports/stm32/mboot/Makefile +++ b/ports/stm32/mboot/Makefile @@ -227,7 +227,6 @@ GEN_QSTRDEFS_GENERATED = $(HEADER_BUILD)/qstrdefs.generated.h GEN_ROOT_POINTERS = $(HEADER_BUILD)/root_pointers.h GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c GEN_PINS_HDR = $(HEADER_BUILD)/pins.h -GEN_PINS_QSTR = $(HEADER_BUILD)/pins_qstr.h GEN_PINS_AF_CONST = $(HEADER_BUILD)/pins_af_const.h GEN_PINS_AF_DEFS = $(HEADER_BUILD)/pins_af_defs.h GEN_PINS_AF_PY = $(BUILD)/pins_af.py @@ -246,7 +245,7 @@ $(GEN_ROOT_POINTERS): | $(HEADER_BUILD) $(GEN_PINS_AF_DEFS): $(BOARD_PINS) $(MAKE_PINS) ../$(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD) $(ECHO) "GEN $@" $(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af ../$(AF_FILE) \ - --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --qstr $(GEN_PINS_QSTR) \ + --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) \ --af-const $(GEN_PINS_AF_CONST) --af-defs $(GEN_PINS_AF_DEFS) \ --af-py $(GEN_PINS_AF_PY) > $(GEN_PINS_SRC) |