Merge tag 'v2022.04-rc4' into next
[platform/kernel/u-boot.git] / Makefile
index 5064996..06572ac 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 VERSION = 2022
-PATCHLEVEL = 01
+PATCHLEVEL = 04
 SUBLEVEL =
-EXTRAVERSION = -rc2
+EXTRAVERSION = -rc4
 NAME =
 
 # *DOCUMENTATION*
@@ -517,10 +517,12 @@ version_h := include/generated/version_autogenerated.h
 timestamp_h := include/generated/timestamp_autogenerated.h
 defaultenv_h := include/generated/defaultenv_autogenerated.h
 dt_h := include/generated/dt.h
+env_h := include/generated/environment.h
 
 no-dot-config-targets := clean clobber mrproper distclean \
                         help %docs check% coccicheck \
-                        ubootversion backup tests check qcheck tcheck
+                        ubootversion backup tests check qcheck tcheck pylint \
+                        pylint_err
 
 config-targets := 0
 mixed-targets  := 0
@@ -943,8 +945,9 @@ INPUTS-$(CONFIG_SPL_FRAMEWORK) += u-boot.img
 endif
 endif
 INPUTS-$(CONFIG_TPL) += tpl/u-boot-tpl.bin
-INPUTS-$(CONFIG_OF_SEPARATE) += u-boot.dtb
-INPUTS-$(CONFIG_BINMAN_STANDALONE_FDT) += u-boot.dtb
+
+# Allow omitting the .dtb output if it is not normally used
+INPUTS-$(CONFIG_OF_SEPARATE) += $(if $(CONFIG_OF_OMIT_DTB),dts/dt.dtb,u-boot.dtb)
 ifeq ($(CONFIG_SPL_FRAMEWORK),y)
 INPUTS-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
 endif
@@ -1053,6 +1056,10 @@ quiet_cmd_cfgcheck = CFGCHK  $2
 cmd_cfgcheck = $(srctree)/scripts/check-config.sh $2 \
                $(srctree)/scripts/config_whitelist.txt $(srctree)
 
+quiet_cmd_ofcheck = OFCHK   $2
+cmd_ofcheck = $(srctree)/scripts/check-of.sh $2 \
+               $(srctree)/scripts/of_allowlist.txt
+
 # Concat the value of all the CONFIGs (result is 'y' or 'yy', etc. )
 got = $(foreach cfg,$(1),$($(cfg)))
 
@@ -1122,10 +1129,20 @@ endif
                $(CONFIG_WATCHDOG)$(CONFIG_HW_WATCHDOG))
        $(call deprecated,CONFIG_DM_ETH,Ethernet drivers,v2020.07,$(CONFIG_NET))
        $(call deprecated,CONFIG_DM_I2C,I2C drivers,v2022.04,$(CONFIG_SYS_I2C_LEGACY))
+       $(call deprecated,CONFIG_DM_KEYBOARD,Keyboard drivers,v2022.10,$(CONFIG_KEYBOARD))
+       @# CONFIG_SYS_TIMER_RATE has brackets in it for some boards which
+       @# confuses this rule. Use if() to send just a single character which
+       @# is enable to tell 'deprecated' that one of these symbols exists
+       $(call deprecated,CONFIG_TIMER,Timer drivers,v2023.01,$(if $(strip $(CONFIG_SYS_TIMER_RATE)$(CONFIG_SYS_TIMER_COUNTER)),x))
+       $(call deprecated,CONFIG_DM_SERIAL,Serial drivers,v2023.04,$(CONFIG_SERIAL))
+       $(call deprecated,CONFIG_DM_SCSI,SCSI drivers,v2023.04,$(CONFIG_SCSI))
        @# Check that this build does not use CONFIG options that we do not
        @# know about unless they are in Kconfig. All the existing CONFIG
        @# options are whitelisted, so new ones should not be added.
        $(call cmd,cfgcheck,u-boot.cfg)
+       @# Check that this build does not override OF_HAS_PRIOR_STAGE by
+       @# disabling OF_BOARD.
+       $(call cmd,ofcheck,$(KCONFIG_CONFIG))
 
 PHONY += dtbs
 dtbs: dts/dt.dtb
@@ -1179,7 +1196,7 @@ u-boot.bin: u-boot-fit-dtb.bin FORCE
 u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
        $(call if_changed,cat)
 
-else ifeq ($(CONFIG_OF_SEPARATE),y)
+else ifeq ($(CONFIG_OF_SEPARATE).$(CONFIG_OF_OMIT_DTB),y.)
 u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
        $(call if_changed,cat)
 
@@ -1302,12 +1319,16 @@ default_dt := $(if $(DEVICE_TREE),$(DEVICE_TREE),$(CONFIG_DEFAULT_DEVICE_TREE))
 
 quiet_cmd_binman = BINMAN  $@
 cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
+               $(foreach f,$(BINMAN_TOOLPATHS),--toolpath $(f)) \
                 --toolpath $(objtree)/tools \
                $(if $(BINMAN_VERBOSE),-v$(BINMAN_VERBOSE)) \
                build -u -d u-boot.dtb -O . -m --allow-missing \
+               --fake-ext-blobs \
                -I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \
                -I arch/$(ARCH)/dts -a of-list=$(CONFIG_OF_LIST) \
+               $(foreach f,$(BINMAN_INDIRS),-I $(f)) \
                -a atf-bl31-path=${BL31} \
+               -a tee-os-path=${TEE} \
                -a opensbi-path=${OPENSBI} \
                -a default-dt=$(default_dt) \
                -a scp-path=$(SCP) \
@@ -1391,7 +1412,7 @@ MKIMAGEFLAGS_u-boot-spl.kwb = -n $(KWD_CONFIG_FILE) \
        $(if $(KEYDIR),-k $(KEYDIR))
 
 MKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \
-               -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage
+               -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -A $(ARCH) -T pblimage
 
 ifeq ($(CONFIG_MPC85xx)$(CONFIG_OF_SEPARATE),yy)
 UBOOT_BIN := u-boot-with-dtb.bin
@@ -1411,7 +1432,7 @@ u-boot-lzma.img: u-boot.bin.lzma FORCE
 
 u-boot-dtb.img u-boot.img u-boot.kwb u-boot.pbl u-boot-ivt.img: \
                $(if $(CONFIG_SPL_LOAD_FIT),u-boot-nodtb.bin \
-                       $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SANDBOX)$(CONFIG_BINMAN_STANDALONE_FDT),dts/dt.dtb) \
+                       $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SANDBOX),dts/dt.dtb) \
                ,$(UBOOT_BIN)) FORCE
        $(call if_changed,mkimage)
        $(BOARD_SIZE_CHECK)
@@ -1517,7 +1538,6 @@ else
 ifeq ($(CONFIG_BINMAN),y)
 flash.bin: spl/u-boot-spl.bin $(INPUTS-y) FORCE
        $(call if_changed,binman)
-       $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@
 else
 flash.bin: spl/u-boot-spl.bin u-boot.itb FORCE
        $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@
@@ -1764,9 +1784,9 @@ else
 quiet_cmd_u-boot__ ?= LD      $@
       cmd_u-boot__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@          \
                -T u-boot.lds $(u-boot-init)                                    \
-               $(if $(CONFIG_EFI_APP_64BIT),,--whole-archive)                  \
+               --whole-archive                                                 \
                        $(u-boot-main)                                          \
-               $(if $(CONFIG_EFI_APP_64BIT),,--no-whole-archive)               \
+               --no-whole-archive                                              \
                $(PLATFORM_LIBS) -Map u-boot.map;                               \
                $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
 endif
@@ -1794,6 +1814,69 @@ quiet_cmd_sym ?= SYM     $@
 u-boot.sym: u-boot FORCE
        $(call if_changed,sym)
 
+# Environment processing
+# ---------------------------------------------------------------------------
+
+# Directory where we expect the .env file, if it exists
+ENV_DIR := $(srctree)/board/$(BOARDDIR)
+
+# Basename of .env file, stripping quotes
+ENV_SOURCE_FILE := $(CONFIG_ENV_SOURCE_FILE:"%"=%)
+
+# Filename of .env file
+ENV_FILE_CFG := $(ENV_DIR)/$(ENV_SOURCE_FILE).env
+
+# Default filename, if CONFIG_ENV_SOURCE_FILE is empty
+ENV_FILE_BOARD := $(ENV_DIR)/$(CONFIG_SYS_BOARD:"%"=%).env
+
+# Select between the CONFIG_ENV_SOURCE_FILE and the default one
+ENV_FILE := $(if $(ENV_SOURCE_FILE),$(ENV_FILE_CFG),$(wildcard $(ENV_FILE_BOARD)))
+
+# Run the environment text file through the preprocessor, but only if it is
+# non-empty, to save time and possible build errors if something is wonky with
+# the board
+quiet_cmd_gen_envp = ENVP    $@
+      cmd_gen_envp = \
+       if [ -s "$(ENV_FILE)" ]; then \
+               $(CPP) -P $(CFLAGS) -x assembler-with-cpp -D__ASSEMBLY__ \
+                       -D__UBOOT_CONFIG__ \
+                       -I . -I include -I $(srctree)/include \
+                       -include linux/kconfig.h -include include/config.h \
+                       -I$(srctree)/arch/$(ARCH)/include \
+                       $< -o $@; \
+       else \
+               touch $@ ; \
+       fi
+include/generated/env.in: include/generated/env.txt FORCE
+       $(call cmd,gen_envp)
+
+# Regenerate the environment if it changes
+# We use 'wildcard' since the file is not required to exist (at present), in
+# which case we don't want this dependency, but instead should create an empty
+# file
+# This rule is useful since it shows the source file for the environment
+quiet_cmd_envc = ENVC    $@
+      cmd_envc = \
+       if [ -f "$<" ]; then \
+               cat $< > $@; \
+       elif [ -n "$(ENV_SOURCE_FILE)" ]; then \
+               echo "Missing file $(ENV_FILE_CFG)"; \
+       else \
+               touch $@ ; \
+       fi
+
+include/generated/env.txt: $(wildcard $(ENV_FILE)) FORCE
+       $(call cmd,envc)
+
+# Write out the resulting environment, converted to a C string
+quiet_cmd_gen_envt = ENVT    $@
+      cmd_gen_envt = \
+       awk -f $(srctree)/scripts/env2string.awk $< >$@
+$(env_h): include/generated/env.in
+       $(call cmd,gen_envt)
+
+# ---------------------------------------------------------------------------
+
 # The actual objects are generated when descending,
 # make sure no implicit rule kicks in
 $(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ;
@@ -1849,7 +1932,7 @@ endif
 # prepare2 creates a makefile if using a separate output directory
 prepare2: prepare3 outputmakefile cfg
 
-prepare1: prepare2 $(version_h) $(timestamp_h) $(dt_h) \
+prepare1: prepare2 $(version_h) $(timestamp_h) $(dt_h) $(env_h) \
                    include/config/auto.conf
 ifeq ($(wildcard $(LDSCRIPT)),)
        @echo >&2 "  Could not find linker script."
@@ -2108,7 +2191,9 @@ CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h tools/version.h \
               u-boot* MLO* SPL System.map fit-dtb.blob* \
               u-boot-ivt.img.log u-boot-dtb.imx.log SPL.log u-boot.imx.log \
               lpc32xx-* bl31.c bl31.elf bl31_*.bin image.map tispl.bin* \
-              idbloader.img flash.bin flash.log defconfig keep-syms-lto.c
+              idbloader.img flash.bin flash.log defconfig keep-syms-lto.c \
+              mkimage-out.spl.mkimage mkimage.spl.mkimage imx-boot.map \
+              itb.fit.fit itb.fit.itb itb.map spl.map
 
 # Directories & files removed with 'make mrproper'
 MRPROPER_DIRS  += include/config include/generated spl tpl \
@@ -2143,7 +2228,8 @@ clean: $(clean-dirs)
                -o -name '*.asn1.[ch]' \
                -o -name '*.symtypes' -o -name 'modules.order' \
                -o -name modules.builtin -o -name '.tmp_*.o.*' \
-               -o -name 'dsdt.aml' -o -name 'dsdt.asl.tmp' -o -name 'dsdt.c' \
+               -o -name 'dsdt_generated.aml' -o -name 'dsdt_generated.asl.tmp' \
+               -o -name 'dsdt_generated.c' \
                -o -name '*.efi' -o -name '*.gcno' -o -name '*.so' \) \
                -type f -print | xargs rm -f
 
@@ -2175,6 +2261,54 @@ distclean: mrproper
                -type f -print | xargs rm -f
        @rm -f boards.cfg CHANGELOG
 
+# See doc/develop/python_cq.rst
+PHONY += pylint pylint_err
+PYLINT_BASE := scripts/pylint.base
+PYLINT_CUR := pylint.cur
+PYLINT_DIFF := pylint.diff
+pylint:
+       $(Q)echo "Running pylint on all files (summary in $(PYLINT_CUR); output in pylint.out/)"
+       $(Q)mkdir -p pylint.out
+       $(Q)rm -f pylint.out/out*
+       $(Q)find tools test -name "*.py" \
+               | xargs -n1 -P$(shell nproc 2>/dev/null || echo 1) \
+                       sh -c 'pylint --reports=y --exit-zero -f parseable --ignore-imports=yes $$@ > pylint.out/$$(echo $$@ | tr / _ | sed s/.py//)' _
+       $(Q)rm -f $(PYLINT_CUR)
+       $(Q)( cd pylint.out; for f in *; do \
+               sed -ne "s/Your code has been rated at \([-0-9.]*\).*/$$f \1/p" $$f; \
+       done ) | sort > $(PYLINT_CUR)
+       $(Q)base=$$(mktemp) cur=$$(mktemp); cut -d' ' -f1 $(PYLINT_BASE) >$$base; \
+               cut -d' ' -f1 $(PYLINT_CUR) >$$cur; \
+               comm -3 $$base $$cur > $(PYLINT_DIFF); \
+               if [ -s $(PYLINT_DIFF) ]; then \
+                       echo "Files have been added/removed. Try:\n\tcp $(PYLINT_CUR) $(PYLINT_BASE)"; \
+                       echo; \
+                       echo "Added files:"; \
+                       comm -13 $$base $$cur; \
+                       echo; \
+                       echo "Removed files:"; \
+                       comm -23 $$base $$cur; \
+                       false; \
+               else \
+                       rm $$base $$cur $(PYLINT_DIFF); \
+               fi
+       $(Q)bad=false; while read base_file base_val <&3 && read cur_file cur_val <&4; do \
+               if awk "BEGIN {exit !($$cur_val < $$base_val)}"; then \
+                       echo "$$base_file: Score was $$base_val, now $$cur_val"; \
+                       bad=true; fi; \
+               done 3<$(PYLINT_BASE) 4<$(PYLINT_CUR); \
+               if $$bad; then \
+                       echo "Some files have regressed, please fix"; \
+                       false; \
+               else \
+                       echo "No pylint regressions"; \
+               fi
+
+# Check for errors only
+pylint_err:
+       $(Q)pylint -E  -j 0 --ignore-imports=yes \
+               $(shell find tools test -name "*.py")
+
 backup:
        F=`basename $(srctree)` ; cd .. ; \
        gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
@@ -2193,6 +2327,7 @@ help:
        @echo  '  check           - Run all automated tests that use sandbox'
        @echo  '  qcheck          - Run quick automated tests that use sandbox'
        @echo  '  tcheck          - Run quick automated tests on tools'
+       @echo  '  pylint          - Run pylint on all Python files'
        @echo  ''
        @echo  'Other generic targets:'
        @echo  '  all             - Build all necessary images depending on configuration'