Skip to content

Commit

Permalink
Makefile: new pmecc header file generation solution
Browse files Browse the repository at this point in the history
For Linux it invokes new addpmecchead.py to generate the 52-word binary
header.
For MPLAB X IDE, the header will be generated by on_project_build hook.
Use cat to concatenate the binary header file and at91bootstrap.bin to
generate (AT91BOOTSTRAP).pmecc.

Signed-off-by: LI BIN <[email protected]>
  • Loading branch information
LiBinSHA authored and ehristev committed Aug 19, 2021
1 parent 114383d commit 4c00dd5
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ endif
endif
VERSION := 3.10.3
REVISION :=
ifdef NIX_SHELL
SCMINFO := $(shell (host-utilities/setlocalversion))
endif

ifeq ($(SCMINFO),)
-include scminfo.mk
Expand Down Expand Up @@ -249,7 +251,7 @@ include fs/src/fat.mk

GC_SECTIONS=--gc-sections

NOSTDINC_FLAGS := -nostdinc -isystem "$(shell $(CC) -print-file-name=include)"
NOSTDINC_FLAGS := -nostdinc -isystem "$(shell "$(CC)" -print-file-name=include)"

CPPFLAGS=$(NOSTDINC_FLAGS) -ffunction-sections -g -Os -Wall \
-mno-unaligned-access \
Expand Down Expand Up @@ -294,7 +296,7 @@ endif

REMOVE_SECTIONS=-R .note -R .comment -R .note.gnu.build-id

gccversion := $(shell $(CC) -dumpversion)
gccversion := $(shell "$(CC)" -dumpversion)

ifdef YYY # For other utils
ifeq ($(CC),gcc)
Expand All @@ -304,11 +306,19 @@ TARGETS=$(AT91BOOTSTRAP) host-utilities .config filesize
endif
endif

TARGETS=$(AT91BOOTSTRAP)

TARGETS=CheckCrossCompile PrintFlags $(AT91BOOTSTRAP)
ifdef NIX_SHELL
TARGETS+=ChkFileSize
endif

ifeq ($(CONFIG_NANDFLASH)$(CONFIG_USE_PMECC), yy)
TARGETS+=${AT91BOOTSTRAP}.pmecc
endif

PHONY:=all

all: CheckCrossCompile PrintFlags $(AT91BOOTSTRAP) ChkFileSize ${AT91BOOTSTRAP}.pmecc
all: $(TARGETS)

CheckCrossCompile:
$(if $(filter-out arm,$(HOSTARCH)),$(if $(CROSS_COMPILE),, \
Expand Down Expand Up @@ -350,17 +360,18 @@ endif

%.o : %.c .config
@echo " CC "$<
@$(CC) $(CPPFLAGS) -c -o $@ $<
@"$(CC)" $(CPPFLAGS) -c -o $@ $<

%.o : %.S .config
@echo " AS "$<
@$(AS) $(ASFLAGS) -c -o $@ $<
@"$(AS)" $(ASFLAGS) -c -o $@ $<

$(AT91BOOTSTRAP).pmecc: $(AT91BOOTSTRAP)
ifeq ($(CONFIG_NANDFLASH), y)
ifeq ($(CONFIG_USE_PMECC), y)
$(Q)./scripts/addpmecchead.py $(AT91BOOTSTRAP) $(AT91BOOTSTRAP).pmecc $(BOARDNAME)
endif
$(AT91BOOTSTRAP).pmecc: $(BINDIR)/pmecc.tmp $(AT91BOOTSTRAP)
$(Q)cat $(BINDIR)/pmecc.tmp $(AT91BOOTSTRAP) > $@

$(BINDIR)/pmecc.tmp: .config | $(BINDIR)
ifdef NIX_SHELL
$(Q)./scripts/addpmecchead.py .config $(BINDIR)
endif

PHONY+= bootstrap
Expand Down Expand Up @@ -467,7 +478,8 @@ distclean: clean config-clean
$(Q)rm -fr .config .config.cmd .config.old
$(Q)rm -fr .auto.deps
$(Q)rm -f .installed
$(Q)rm -f ..*.tmp
$(Q)rm -fr ..make.deps.tmp ..config.tmp
$(Q)rm -f $(BINDIR)/pmecc.tmp
$(Q)rm -f .configured
$(Q)rm -f .prepared
$(Q)rm -f $(subst $$,\$$,$(call rwildcard,scripts,*$$py.class))
Expand All @@ -484,7 +496,7 @@ distclean: clean config-clean

mplabclean: clean
@echo " CLEAN "binary files!
$(Q)rm -fr $(BUILDDIR)
$(Q)rm -fr $(BINDIR)
$(Q)rm -fr log

mrproper: distclean
Expand Down

0 comments on commit 4c00dd5

Please sign in to comment.