Browse Source

zephyr: Use zephyr build system to merge configurations.

The zephyr build system supports merging application-level board
configurations, so there is no need to reproduce this functionality in
MicroPython.

If CONF_FILE is not explicitly set, then the zephyr build system looks for
prj.conf in the application directory.  Therefore we rename the MicroPython
prj_base.conf to prj.conf.

Furthermore, if the zephyr build system finds boards/$(BOARD).conf in the
application directory, it merges that configuration with prj.conf.
Therefore we rename all the MicroPython board .conf files and move them
into a boards/ directory.

The minimal configuration, prj_minimal.conf, is left in the application
directory because it is used as an explicitly set CONF_FILE in
make-minimal.
pull/6015/head
Maureen Helm 5 years ago
committed by Damien George
parent
commit
25434e976b
  1. 18
      ports/zephyr/Makefile
  2. 0
      ports/zephyr/boards/96b_carbon.conf
  3. 0
      ports/zephyr/boards/disco_l475_iot1.conf
  4. 0
      ports/zephyr/boards/frdm_k64f.conf
  5. 0
      ports/zephyr/boards/frdm_kw41z.conf
  6. 0
      ports/zephyr/boards/mimxrt1050_evk.conf
  7. 0
      ports/zephyr/boards/qemu_cortex_m3.conf
  8. 0
      ports/zephyr/boards/qemu_x86.conf
  9. 0
      ports/zephyr/boards/reel_board.conf
  10. 0
      ports/zephyr/boards/rv32m1_vega_ri5cy.conf
  11. 29
      ports/zephyr/makeprj.py
  12. 0
      ports/zephyr/prj.conf

18
ports/zephyr/Makefile

@ -8,7 +8,6 @@
# To build a "minimal" configuration, use "make-minimal" wrapper. # To build a "minimal" configuration, use "make-minimal" wrapper.
BOARD ?= qemu_x86 BOARD ?= qemu_x86
CONF_FILE = prj_$(BOARD)_merged.conf
OUTDIR_PREFIX = $(BOARD) OUTDIR_PREFIX = $(BOARD)
# Default heap size is 16KB, which is on conservative side, to let # Default heap size is 16KB, which is on conservative side, to let
@ -92,26 +91,23 @@ build/genhdr/qstr.i.last: | $(Z_EXPORTS)
LIBMICROPYTHON_EXTRA_CMD = -$(RM) -f outdir/$(OUTDIR_PREFIX)/zephyr.lnk LIBMICROPYTHON_EXTRA_CMD = -$(RM) -f outdir/$(OUTDIR_PREFIX)/zephyr.lnk
# MicroPython's global clean cleans everything, fast # MicroPython's global clean cleans everything, fast
CLEAN_EXTRA = outdir libmicropython.a prj_*_merged.conf CLEAN_EXTRA = outdir libmicropython.a
# Clean Zephyr things in Zephyr way # Clean Zephyr things in Zephyr way
z_clean: z_clean:
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) clean $(MAKE) -f Makefile.zephyr BOARD=$(BOARD) clean
# This rule is for prj_$(BOARD)_merged.conf, not $(CONF_FILE), which
# can be overriden.
# prj_$(BOARD).conf is optional, that's why it's resolved with $(wildcard)
# function.
prj_$(BOARD)_merged.conf: prj_base.conf $(wildcard prj_$(BOARD).conf)
$(PYTHON) makeprj.py prj_base.conf prj_$(BOARD).conf $@
test: test:
cd $(TOP)/tests && ./run-tests --target minimal --device "execpty:make -C ../ports/zephyr run BOARD=$(BOARD) QEMU_PTY=1" cd $(TOP)/tests && ./run-tests --target minimal --device "execpty:make -C ../ports/zephyr run BOARD=$(BOARD) QEMU_PTY=1"
cmake: outdir/$(BOARD)/Makefile cmake: outdir/$(BOARD)/Makefile
outdir/$(BOARD)/Makefile: $(CONF_FILE) ifneq ($(CONF_FILE),)
mkdir -p outdir/$(BOARD) && cmake -DBOARD=$(BOARD) -DCONF_FILE=$(CONF_FILE) -Boutdir/$(BOARD) -H. CMAKE_MOD += -DCONF_FILE=$(CONF_FILE)
endif
outdir/$(BOARD)/Makefile:
mkdir -p outdir/$(BOARD) && cmake -DBOARD=$(BOARD) $(CMAKE_MOD) -Boutdir/$(BOARD) -H.
$(Z_EXPORTS): outdir/$(BOARD)/Makefile $(Z_EXPORTS): outdir/$(BOARD)/Makefile
make --no-print-directory -C outdir/$(BOARD) outputexports CMAKE_COMMAND=: >$@ make --no-print-directory -C outdir/$(BOARD) outputexports CMAKE_COMMAND=: >$@

0
ports/zephyr/prj_96b_carbon.conf → ports/zephyr/boards/96b_carbon.conf

0
ports/zephyr/prj_disco_l475_iot1.conf → ports/zephyr/boards/disco_l475_iot1.conf

0
ports/zephyr/prj_frdm_k64f.conf → ports/zephyr/boards/frdm_k64f.conf

0
ports/zephyr/prj_frdm_kw41z.conf → ports/zephyr/boards/frdm_kw41z.conf

0
ports/zephyr/prj_mimxrt1050_evk.conf → ports/zephyr/boards/mimxrt1050_evk.conf

0
ports/zephyr/prj_qemu_cortex_m3.conf → ports/zephyr/boards/qemu_cortex_m3.conf

0
ports/zephyr/prj_qemu_x86.conf → ports/zephyr/boards/qemu_x86.conf

0
ports/zephyr/prj_reel_board.conf → ports/zephyr/boards/reel_board.conf

0
ports/zephyr/prj_rv32m1_vega_ri5cy.conf → ports/zephyr/boards/rv32m1_vega_ri5cy.conf

29
ports/zephyr/makeprj.py

@ -1,29 +0,0 @@
#!/usr/bin/env python3
import sys
import os
import hashlib
def hash_file(fname):
if not os.path.exists(fname):
return b""
hasher = hashlib.md5()
with open(fname, "rb") as f:
hasher.update(f.read())
return hasher.digest()
old_digest = hash_file(sys.argv[3])
with open(sys.argv[3] + ".tmp", "wb") as f:
f.write(open(sys.argv[1], "rb").read())
if os.path.exists(sys.argv[2]):
f.write(open(sys.argv[2], "rb").read())
new_digest = hash_file(sys.argv[3] + ".tmp")
if new_digest != old_digest:
print("Replacing")
os.rename(sys.argv[3] + ".tmp", sys.argv[3])
else:
os.remove(sys.argv[3] + ".tmp")

0
ports/zephyr/prj_base.conf → ports/zephyr/prj.conf

Loading…
Cancel
Save