Skip to contentSkip to conversation

kconfig: Add some new macros

PATCH Superseded Simon Glass 6 participants 20 messages Jan 16, 2022 – Jan 19, 2022

Subsystems (6)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover kconfig: Add some new macros

This series adds a few more macros to kconfig, along with a bit of refactoring of what is there.

It also adds some basic tests for the kconfig macros.

Finally, to make the tests work, it enhances buildman to support changing CONFIG options on the fly when building.

Changes in v4:
- Update stale mention of zero in commit message
- Update stale comments in the header file
- Define the macros even in assembly context
- Expand the series with tests and buildman changes

Changes in v3:
- Add a way to detect use of a non-existent value
- Add new patch to update bloblist to use conditional value

Simon Glass (13):
imx: Don't define __ASSEMBLY__ in C files
mips: Avoid using config_enabled() directly
mmc: fsl: Use brackets around if()
kconfig: Update IS_ENABLED() internals
kconfig: Add support for conditional values
bloblist: Update to use conditional value
patman: Update test_util to run doc tests
buildman: Add a flag to control the traceback
buildman: Make use of test_util
buildman: Add helper functions for updating .config files
buildman: Provide a hint on how to debug thread crashes
buildman: Allow adjusting board config on the fly
test: Add some tests for kconfig.h

 arch/arm/mach-imx/Makefile                    |   2 +-
 .../mach-imx/imx8m/imximage-8mm-lpddr4.cfg    |   1 -
 arch/arm/mach-imx/imx8m/imximage-8mn-ddr4.cfg |   1 -
 .../mach-imx/imx8m/imximage-8mn-lpddr4.cfg    |   1 -
 .../mach-imx/imx8m/imximage-8mp-lpddr4.cfg    |   1 -
 arch/arm/mach-imx/imx8m/imximage.cfg          |   1 -
 arch/arm/mach-imx/spl_qspi.cfg                |   1 -
 arch/arm/mach-imx/spl_sd.cfg                  |   1 -
 arch/mips/lib/cache.c                         |   2 +-
 .../advantech/imx8qm_rom7720_a1/imximage.cfg  |   1 -
 board/aristainetos/aristainetos2.cfg          |   1 -
 board/beacon/imx8mm/imximage-8mm-lpddr4.cfg   |   1 -
 board/beacon/imx8mn/imximage-8mn-lpddr4.cfg   |   1 -
 board/boundary/nitrogen6x/nitrogen6dl.cfg     |   1 -
 board/boundary/nitrogen6x/nitrogen6dl2g.cfg   |   1 -
 board/boundary/nitrogen6x/nitrogen6q.cfg      |   1 -
 board/boundary/nitrogen6x/nitrogen6q2g.cfg    |   1 -
 board/boundary/nitrogen6x/nitrogen6s.cfg      |   1 -
 board/boundary/nitrogen6x/nitrogen6s1g.cfg    |   1 -
 .../imximage-8mm-lpddr4.cfg                   |   1 -
 board/congatec/cgtqmx8/imximage.cfg           |   1 -
 board/ea/mx7ulp_com/imximage.cfg              |   1 -
 .../imx8mm_evk/imximage-8mm-lpddr4.cfg        |   1 -
 .../imx8mn_evk/imximage-8mn-ddr4.cfg          |   1 -
 .../imx8mp_evk/imximage-8mp-lpddr4.cfg        |   1 -
 board/freescale/imx8qm_mek/imximage.cfg       |   1 -
 .../freescale/imx8qm_mek/uboot-container.cfg  |   1 -
 board/freescale/imx8qxp_mek/imximage.cfg      |   1 -
 .../freescale/imx8qxp_mek/uboot-container.cfg |   1 -
 board/freescale/imxrt1020-evk/imximage.cfg    |   1 -
 board/freescale/imxrt1050-evk/imximage.cfg    |   1 -
 board/freescale/mx6slevk/imximage.cfg         |   1 -
 board/freescale/mx6sllevk/imximage.cfg        |   1 -
 board/freescale/mx6sxsabreauto/imximage.cfg   |   1 -
 board/freescale/mx6sxsabresd/imximage.cfg     |   1 -
 board/freescale/mx6ullevk/imximage.cfg        |   1 -
 board/freescale/mx7dsabresd/imximage.cfg      |   1 -
 board/freescale/mx7ulp_evk/imximage.cfg       |   1 -
 .../gateworks/venice/imximage-8mm-lpddr4.cfg  |   1 -
 board/ge/bx50v3/bx50v3.cfg                    |   1 -
 board/kontron/sl-mx8mm/imximage.cfg           |   1 -
 board/novtech/meerkat96/imximage.cfg          |   1 -
 .../out4/o4-imx6ull-nano/K4B4G1646D-BCMA.cfg  |   1 -
 .../o4-imx6ull-nano/MT41K256M16HA-125E.cfg    |   1 -
 .../phytec/phycore_imx8mm/imximage-8mm-sd.cfg |   1 -
 .../phytec/phycore_imx8mp/imximage-8mp-sd.cfg |   1 -
 .../ronetix/imx8mq-cm/imximage-8mq-lpddr4.cfg |   1 -
 board/siemens/capricorn/imximage.cfg          |   1 -
 board/siemens/capricorn/uboot-container.cfg   |   1 -
 board/softing/vining_2000/imximage.cfg        |   1 -
 board/somlabs/visionsom-6ull/imximage.cfg     |   1 -
 board/storopack/smegw01/imximage.cfg          |   1 -
 board/tbs/tbs2910/tbs2910.cfg                 |   1 -
 board/technexion/pico-imx6ul/imximage.cfg     |   1 -
 .../apalis-imx8/apalis-imx8-imximage.cfg      |   1 -
 .../apalis-imx8x/apalis-imx8x-imximage.cfg    |   1 -
 board/toradex/colibri-imx6ull/imximage.cfg    |   1 -
 .../colibri-imx8x/colibri-imx8x-imximage.cfg  |   1 -
 board/toradex/colibri_imx7/imximage.cfg       |   1 -
 board/toradex/verdin-imx8mm/imximage.cfg      |   1 -
 board/tq/tqma6/tqma6dl.cfg                    |   1 -
 board/tq/tqma6/tqma6q.cfg                     |   1 -
 board/tq/tqma6/tqma6s.cfg                     |   1 -
 board/warp/imximage.cfg                       |   1 -
 board/warp7/imximage.cfg                      |   1 -
 common/bloblist.c                             |  15 +-
 drivers/mmc/fsl_esdhc_imx.c                   |   2 +-
 include/bloblist.h                            |  10 -
 include/linux/kconfig.h                       |  52 +++-
 scripts/Makefile.autoconf                     |   2 +-
 test/Kconfig                                  |   1 +
 test/Makefile                                 |   2 +-
 test/lib/Kconfig                              |  23 ++
 test/lib/Makefile                             |   5 +
 test/lib/kconfig.c                            |  58 +++++
 test/lib/kconfig_spl.c                        |  44 ++++
 test/py/tests/test_kconfig.py                 |  34 +++
 tools/buildman/README                         |  49 ++++
 tools/buildman/builder.py                     |  14 +-
 tools/buildman/builderthread.py               |  32 ++-
 tools/buildman/cfgutil.py                     | 235 ++++++++++++++++++
 tools/buildman/cmdline.py                     |   4 +
 tools/buildman/control.py                     |   6 +-
 tools/buildman/func_test.py                   |   8 +-
 tools/buildman/main.py                        |  29 ++-
 tools/buildman/test.py                        | 123 +++++++++
 tools/dtoc/main.py                            |   2 +-
 tools/patman/main.py                          |  20 +-
 tools/patman/test_util.py                     |  17 +-
 89 files changed, 715 insertions(+), 139 deletions(-)
 create mode 100644 test/lib/Kconfig
 create mode 100644 test/lib/kconfig.c
 create mode 100644 test/lib/kconfig_spl.c
 create mode 100644 test/py/tests/test_kconfig.py
 create mode 100644 tools/buildman/cfgutil.py
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
#1 lore raw

PATCH v4 1/13 imx: Don't define __ASSEMBLY__ in C files

This is supposed to be a build-system flag. Move it there so we can define it before linux/kconfig.h is included.

---

(no changes since v1)

 arch/arm/mach-imx/Makefile                                | 2 +-
 arch/arm/mach-imx/imx8m/imximage-8mm-lpddr4.cfg           | 1 -
 arch/arm/mach-imx/imx8m/imximage-8mn-ddr4.cfg             | 1 -
 arch/arm/mach-imx/imx8m/imximage-8mn-lpddr4.cfg           | 1 -
 arch/arm/mach-imx/imx8m/imximage-8mp-lpddr4.cfg           | 1 -
 arch/arm/mach-imx/imx8m/imximage.cfg                      | 1 -
 arch/arm/mach-imx/spl_qspi.cfg                            | 1 -
 arch/arm/mach-imx/spl_sd.cfg                              | 1 -
 board/advantech/imx8qm_rom7720_a1/imximage.cfg            | 1 -
 board/aristainetos/aristainetos2.cfg                      | 1 -
 board/beacon/imx8mm/imximage-8mm-lpddr4.cfg               | 1 -
 board/beacon/imx8mn/imximage-8mn-lpddr4.cfg               | 1 -
 board/boundary/nitrogen6x/nitrogen6dl.cfg                 | 1 -
 board/boundary/nitrogen6x/nitrogen6dl2g.cfg               | 1 -
 board/boundary/nitrogen6x/nitrogen6q.cfg                  | 1 -
 board/boundary/nitrogen6x/nitrogen6q2g.cfg                | 1 -
 board/boundary/nitrogen6x/nitrogen6s.cfg                  | 1 -
 board/boundary/nitrogen6x/nitrogen6s1g.cfg                | 1 -
 board/compulab/imx8mm-cl-iot-gate/imximage-8mm-lpddr4.cfg | 1 -
 board/congatec/cgtqmx8/imximage.cfg                       | 1 -
 board/ea/mx7ulp_com/imximage.cfg                          | 1 -
 board/freescale/imx8mm_evk/imximage-8mm-lpddr4.cfg        | 1 -
 board/freescale/imx8mn_evk/imximage-8mn-ddr4.cfg          | 1 -
 board/freescale/imx8mp_evk/imximage-8mp-lpddr4.cfg        | 1 -
 board/freescale/imx8qm_mek/imximage.cfg                   | 1 -
 board/freescale/imx8qm_mek/uboot-container.cfg            | 1 -
 board/freescale/imx8qxp_mek/imximage.cfg                  | 1 -
 board/freescale/imx8qxp_mek/uboot-container.cfg           | 1 -
 board/freescale/imxrt1020-evk/imximage.cfg                | 1 -
 board/freescale/imxrt1050-evk/imximage.cfg                | 1 -
 board/freescale/mx6slevk/imximage.cfg                     | 1 -
 board/freescale/mx6sllevk/imximage.cfg                    | 1 -
 board/freescale/mx6sxsabreauto/imximage.cfg               | 1 -
 board/freescale/mx6sxsabresd/imximage.cfg                 | 1 -
 board/freescale/mx6ullevk/imximage.cfg                    | 1 -
 board/freescale/mx7dsabresd/imximage.cfg                  | 1 -
 board/freescale/mx7ulp_evk/imximage.cfg                   | 1 -
 board/gateworks/venice/imximage-8mm-lpddr4.cfg            | 1 -
 board/ge/bx50v3/bx50v3.cfg                                | 1 -
 board/kontron/sl-mx8mm/imximage.cfg                       | 1 -
 board/novtech/meerkat96/imximage.cfg                      | 1 -
 board/out4/o4-imx6ull-nano/K4B4G1646D-BCMA.cfg            | 1 -
 board/out4/o4-imx6ull-nano/MT41K256M16HA-125E.cfg         | 1 -
 board/phytec/phycore_imx8mm/imximage-8mm-sd.cfg           | 1 -
 board/phytec/phycore_imx8mp/imximage-8mp-sd.cfg           | 1 -
 board/ronetix/imx8mq-cm/imximage-8mq-lpddr4.cfg           | 1 -
 board/siemens/capricorn/imximage.cfg                      | 1 -
 board/siemens/capricorn/uboot-container.cfg               | 1 -
 board/softing/vining_2000/imximage.cfg                    | 1 -
 board/somlabs/visionsom-6ull/imximage.cfg                 | 1 -
 board/storopack/smegw01/imximage.cfg                      | 1 -
 board/tbs/tbs2910/tbs2910.cfg                             | 1 -
 board/technexion/pico-imx6ul/imximage.cfg                 | 1 -
 board/toradex/apalis-imx8/apalis-imx8-imximage.cfg        | 1 -
 board/toradex/apalis-imx8x/apalis-imx8x-imximage.cfg      | 1 -
 board/toradex/colibri-imx6ull/imximage.cfg                | 1 -
 board/toradex/colibri-imx8x/colibri-imx8x-imximage.cfg    | 1 -
 board/toradex/colibri_imx7/imximage.cfg                   | 1 -
 board/toradex/verdin-imx8mm/imximage.cfg                  | 1 -
 board/tq/tqma6/tqma6dl.cfg                                | 1 -
 board/tq/tqma6/tqma6q.cfg                                 | 1 -
 board/tq/tqma6/tqma6s.cfg                                 | 1 -
 board/warp/imximage.cfg                                   | 1 -
 board/warp7/imximage.cfg                                  | 1 -
 64 files changed, 1 insertion(+), 64 deletions(-)
arch/arm/mach-imx/Makefile +1 -1
index 07954bc2014..77e72702bba 100644
@@ -91,7 +91,7 @@ $(PLUGIN).bin:
 endif
 
 quiet_cmd_cpp_cfg = CFGS    $@
-      cmd_cpp_cfg = $(CPP) $(cpp_flags) -x c -o $@ $<
+      cmd_cpp_cfg = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -x c -o $@ $<
 
 # mkimage source config file
 IMX_CONFIG = $(CONFIG_IMX_CONFIG:"%"=%)
arch/arm/mach-imx/imx8m/imximage-8mm-lpddr4.cfg +0 -1
index 1a2e43e6718..e06d53ef417 100644
@@ -3,7 +3,6 @@
  * Copyright 2019 NXP
  */
 
-#define __ASSEMBLY__
 
 FIT
 BOOT_FROM	sd
arch/arm/mach-imx/imx8m/imximage-8mn-ddr4.cfg +0 -1
index 1405c6560c7..120631a423a 100644
@@ -3,7 +3,6 @@
  * Copyright 2019 NXP
  */
 
-#define __ASSEMBLY__
 
 FIT
 ROM_VERSION	v2
arch/arm/mach-imx/imx8m/imximage-8mn-lpddr4.cfg +0 -1
index 4c63b31db6d..7dae3fa93aa 100644
@@ -3,7 +3,6 @@
  * Copyright 2019 NXP
  */
 
-#define __ASSEMBLY__
 
 FIT
 ROM_VERSION	v2
arch/arm/mach-imx/imx8m/imximage-8mp-lpddr4.cfg +0 -1
index 586a5ff306d..0fba9f50f3e 100644
@@ -3,7 +3,6 @@
  * Copyright 2019 NXP
  */
 
-#define __ASSEMBLY__
 
 FIT
 ROM_VERSION	v2
arch/arm/mach-imx/imx8m/imximage.cfg +0 -1
index 2a3f9591835..30490e04182 100644
@@ -3,7 +3,6 @@
  * Copyright 2018-2021 NXP
  */
 
-#define __ASSEMBLY__
 
 FIT
 BOOT_FROM	sd
arch/arm/mach-imx/spl_qspi.cfg +0 -1
index 1e39ae2f01f..6df779b7715 100644
@@ -3,7 +3,6 @@
  * Copyright (C) 2014, Compulab Ltd - http://compulab.co.il/
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 IMAGE_VERSION	2
arch/arm/mach-imx/spl_sd.cfg +0 -1
index dbaee815357..e739b547005 100644
@@ -3,7 +3,6 @@
  * Copyright (C) 2014, Compulab Ltd - http://compulab.co.il/
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 IMAGE_VERSION	2
board/advantech/imx8qm_rom7720_a1/imximage.cfg +0 -1
index e324c7ca37c..5ecde0c5309 100644
@@ -3,7 +3,6 @@
  * Copyright 2018 NXP
  */
 
-#define __ASSEMBLY__
 
 /* Boot from SD, sector size 0x400 */
 BOOT_FROM SD 0x400
board/aristainetos/aristainetos2.cfg +0 -1
index d088cc83ad4..2454ac5515a 100644
@@ -21,7 +21,6 @@ IMAGE_VERSION 2
  */
 BOOT_FROM      spi
 
-#define __ASSEMBLY__
 #include <config.h>
 #ifdef CONFIG_IMX_HAB
 CSF CONFIG_CSF_SIZE
board/beacon/imx8mm/imximage-8mm-lpddr4.cfg +0 -1
index 90573be5fd9..20061521f22 100644
@@ -3,7 +3,6 @@
  * Copyright 2021 NXP
  */
 
-#define __ASSEMBLY__
 
 BOOT_FROM	sd
 LOADER		u-boot-spl-ddr.bin	0x7E1000
board/beacon/imx8mn/imximage-8mn-lpddr4.cfg +0 -1
index 7286b264944..0edda9c5e06 100644
@@ -3,7 +3,6 @@
  * Copyright 2021 NXP
  */
 
-#define __ASSEMBLY__
 
 ROM_VERSION	v2
 BOOT_FROM	sd
board/boundary/nitrogen6x/nitrogen6dl.cfg +0 -1
index 9558e26a2f1..a57b16a7670 100644
@@ -17,7 +17,6 @@ IMAGE_VERSION 2
  */
 BOOT_FROM      spi
 
-#define __ASSEMBLY__
 #include <config.h>
 #ifdef CONFIG_IMX_HAB
 CSF CONFIG_CSF_SIZE
board/boundary/nitrogen6x/nitrogen6dl2g.cfg +0 -1
index f5a107c2254..7379b891a65 100644
@@ -17,7 +17,6 @@ IMAGE_VERSION 2
  */
 BOOT_FROM      spi
 
-#define __ASSEMBLY__
 #include <config.h>
 #ifdef CONFIG_IMX_HAB
 CSF CONFIG_CSF_SIZE
board/boundary/nitrogen6x/nitrogen6q.cfg +0 -1
index b0bbf0d7975..c7029ab0343 100644
@@ -17,7 +17,6 @@ IMAGE_VERSION 2
  */
 BOOT_FROM      spi
 
-#define __ASSEMBLY__
 #include <config.h>
 #ifdef CONFIG_IMX_HAB
 CSF CONFIG_CSF_SIZE
board/boundary/nitrogen6x/nitrogen6q2g.cfg +0 -1
index 4999254329f..1d58cd4d13d 100644
@@ -17,7 +17,6 @@ IMAGE_VERSION 2
  */
 BOOT_FROM      spi
 
-#define __ASSEMBLY__
 #include <config.h>
 #ifdef CONFIG_IMX_HAB
 CSF CONFIG_CSF_SIZE
board/boundary/nitrogen6x/nitrogen6s.cfg +0 -1
index 16d778491a4..b16d9447fa9 100644
@@ -17,7 +17,6 @@ IMAGE_VERSION 2
  */
 BOOT_FROM      spi
 
-#define __ASSEMBLY__
 #include <config.h>
 #ifdef CONFIG_IMX_HAB
 CSF CONFIG_CSF_SIZE
board/boundary/nitrogen6x/nitrogen6s1g.cfg +0 -1
index 0320078a911..debec755d6b 100644
@@ -17,7 +17,6 @@ IMAGE_VERSION 2
  */
 BOOT_FROM      spi
 
-#define __ASSEMBLY__
 #include <config.h>
 #ifdef CONFIG_IMX_HAB
 CSF CONFIG_CSF_SIZE
board/compulab/imx8mm-cl-iot-gate/imximage-8mm-lpddr4.cfg +0 -1
index 4071219fbf4..f9ce7f89d7c 100644
@@ -3,7 +3,6 @@
  * Copyright 2021 NXP
  */
 
-#define __ASSEMBLY__
 
 BOOT_FROM	sd
 LOADER		u-boot-spl-ddr.bin	0x7e1000
board/congatec/cgtqmx8/imximage.cfg +0 -1
index e324c7ca37c..5ecde0c5309 100644
@@ -3,7 +3,6 @@
  * Copyright 2018 NXP
  */
 
-#define __ASSEMBLY__
 
 /* Boot from SD, sector size 0x400 */
 BOOT_FROM SD 0x400
board/ea/mx7ulp_com/imximage.cfg +0 -1
index 1b218996aea..1731da814d0 100644
@@ -9,7 +9,6 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/freescale/imx8mm_evk/imximage-8mm-lpddr4.cfg +0 -1
index 90573be5fd9..20061521f22 100644
@@ -3,7 +3,6 @@
  * Copyright 2021 NXP
  */
 
-#define __ASSEMBLY__
 
 BOOT_FROM	sd
 LOADER		u-boot-spl-ddr.bin	0x7E1000
board/freescale/imx8mn_evk/imximage-8mn-ddr4.cfg +0 -1
index 22aec26da7d..d0f5b6ccd7b 100644
@@ -3,7 +3,6 @@
  * Copyright 2021 NXP
  */
 
-#define __ASSEMBLY__
 
 ROM_VERSION	v2
 BOOT_FROM	sd
board/freescale/imx8mp_evk/imximage-8mp-lpddr4.cfg +0 -1
index 4c3ecf5a71a..6dedf1724ab 100644
@@ -3,7 +3,6 @@
  * Copyright 2021 NXP
  */
 
-#define __ASSEMBLY__
 
 ROM_VERSION	v2
 BOOT_FROM	sd
board/freescale/imx8qm_mek/imximage.cfg +0 -1
index 7dc6b93eb58..71612678c99 100644
@@ -3,7 +3,6 @@
  * Copyright 2018 NXP
  */
 
-#define __ASSEMBLY__
 
 /* Boot from SD, sector size 0x400 */
 BOOT_FROM SD 0x400
board/freescale/imx8qm_mek/uboot-container.cfg +0 -1
index 6cc47cd1027..93c5d39ae9b 100644
@@ -3,7 +3,6 @@
  * Copyright 2019 NXP
  */
 
-#define __ASSEMBLY__
 
 /* This file is to create a container image could be loaded by SPL */
 BOOT_FROM SD 0x400
board/freescale/imx8qxp_mek/imximage.cfg +0 -1
index cd747d2eee7..89a4736ab7a 100644
@@ -6,7 +6,6 @@
  * and create imx8image boot image
  */
 
-#define __ASSEMBLY__
 
 /* Boot from SD, sector size 0x400 */
 BOOT_FROM SD 0x400
board/freescale/imx8qxp_mek/uboot-container.cfg +0 -1
index 81658118185..b53896f2354 100644
@@ -3,7 +3,6 @@
  * Copyright 2019 NXP
  */
 
-#define __ASSEMBLY__
 
 /* This file is to create a container image could be loaded by SPL */
 BOOT_FROM SD 0x400
board/freescale/imxrt1020-evk/imximage.cfg +0 -1
index 9bcc2c15907..0ed71479a60 100644
@@ -4,7 +4,6 @@
  * Author(s): Giulio Benetti <[email protected]>
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/freescale/imxrt1050-evk/imximage.cfg +0 -1
index cf1665be610..f1f09fd7ebb 100644
@@ -4,7 +4,6 @@
  * Author(s): Giulio Benetti <[email protected]>
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/freescale/mx6slevk/imximage.cfg +0 -1
index b97761a5162..64be101d6ec 100644
@@ -7,7 +7,6 @@
  *
  * The syntax is taken as close as possible with the kwbimage
  */
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/freescale/mx6sllevk/imximage.cfg +0 -1
index 74b3a907bf2..550be3f6c12 100644
@@ -8,7 +8,6 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/freescale/mx6sxsabreauto/imximage.cfg +0 -1
index 4a0bcc5f7d6..da703093aa6 100644
@@ -3,7 +3,6 @@
  * Copyright (C) 2014 Freescale Semiconductor, Inc.
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/freescale/mx6sxsabresd/imximage.cfg +0 -1
index 28ffb2f8bc9..313ab589505 100644
@@ -3,7 +3,6 @@
  * Copyright (C) 2014 Freescale Semiconductor, Inc.
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/freescale/mx6ullevk/imximage.cfg +0 -1
index 155503997d2..0c6f444a7a3 100644
@@ -8,7 +8,6 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/freescale/mx7dsabresd/imximage.cfg +0 -1
index 05446ac833d..59e66fbda16 100644
@@ -8,7 +8,6 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/freescale/mx7ulp_evk/imximage.cfg +0 -1
index ec3673040ba..62fd79afd6c 100644
@@ -8,7 +8,6 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/gateworks/venice/imximage-8mm-lpddr4.cfg +0 -1
index ccaa765cb7d..6bc457c6a20 100644
@@ -3,7 +3,6 @@
  * Copyright 2021 Gateworks Corporation
  */
 
-#define __ASSEMBLY__
 
 BOOT_FROM	sd
 LOADER		u-boot-spl-ddr.bin	0x7E1000
board/ge/bx50v3/bx50v3.cfg +0 -1
index de3955a94d2..1386516a16f 100644
@@ -13,7 +13,6 @@
 IMAGE_VERSION 2
 BOOT_FROM sd
 
-#define __ASSEMBLY__
 #include <config.h>
 #include "asm/arch/mx6-ddr.h"
 #include "asm/arch/iomux.h"
board/kontron/sl-mx8mm/imximage.cfg +0 -1
index f101f3d228f..b5380267114 100644
@@ -3,7 +3,6 @@
  * Copyright (C) 2019 Kontron Electronics GmbH
  */
 
-#define __ASSEMBLY__
 
 BOOT_FROM	sd
 LOADER		u-boot-spl-ddr.bin	0x7E1000
board/novtech/meerkat96/imximage.cfg +0 -1
index 86275b84d9c..a67ce533141 100644
@@ -9,7 +9,6 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/out4/o4-imx6ull-nano/K4B4G1646D-BCMA.cfg +0 -1
index c0dcfe9a0c5..38c4572152b 100644
@@ -2,7 +2,6 @@
 // Copyright (C) 2016 Freescale Semiconductor, Inc.
 // Copyright (C) 2021 Oleh Kravchenko <[email protected]>
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/out4/o4-imx6ull-nano/MT41K256M16HA-125E.cfg +0 -1
index 6f823a7272a..497e7f8fc4a 100644
@@ -2,7 +2,6 @@
 // Copyright (C) 2016 Freescale Semiconductor, Inc.
 // Copyright (C) 2021 Oleh Kravchenko <[email protected]>
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/phytec/phycore_imx8mm/imximage-8mm-sd.cfg +0 -1
index ea74fb7e590..722e62c92d6 100644
@@ -3,7 +3,6 @@
  * Copyright 2021 Phytec Messtechnik GmbH
  */
 
-#define __ASSEMBLY__
 
 BOOT_FROM       sd
 LOADER          u-boot-spl-ddr.bin      0x7E1000
board/phytec/phycore_imx8mp/imximage-8mp-sd.cfg +0 -1
index 4c3ecf5a71a..6dedf1724ab 100644
@@ -3,7 +3,6 @@
  * Copyright 2021 NXP
  */
 
-#define __ASSEMBLY__
 
 ROM_VERSION	v2
 BOOT_FROM	sd
board/ronetix/imx8mq-cm/imximage-8mq-lpddr4.cfg +0 -1
index 268b5ae7163..fae7ad83693 100644
@@ -3,7 +3,6 @@
  * Copyright 2021 NXP
  */
 
-#define __ASSEMBLY__
 
 BOOT_FROM	sd
 LOADER		mkimage.flash.mkimage	0x7E1000
\ No newline at end of file
board/siemens/capricorn/imximage.cfg +0 -1
index 9f9df68e64c..fa871bac212 100644
@@ -6,7 +6,6 @@
  * and create imx8image boot image
  */
 
-#define __ASSEMBLY__
 
 /* Boot from SD, sector size 0x400 */
 BOOT_FROM SD 0x400
board/siemens/capricorn/uboot-container.cfg +0 -1
index 81658118185..b53896f2354 100644
@@ -3,7 +3,6 @@
  * Copyright 2019 NXP
  */
 
-#define __ASSEMBLY__
 
 /* This file is to create a container image could be loaded by SPL */
 BOOT_FROM SD 0x400
board/softing/vining_2000/imximage.cfg +0 -1
index f6f59ddf55c..300aafcae24 100644
@@ -4,7 +4,6 @@
  * Copyright (C) 2017-2019 softing automotive electronics gmbH
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/somlabs/visionsom-6ull/imximage.cfg +0 -1
index b49a2df6dd8..370b303cfa6 100644
@@ -9,7 +9,6 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/storopack/smegw01/imximage.cfg +0 -1
index c7fa06996cc..fd457b27f5e 100644
@@ -8,7 +8,6 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 IMAGE_VERSION	2
board/tbs/tbs2910/tbs2910.cfg +0 -1
index 3ca807b3157..2fa70947cec 100644
@@ -3,7 +3,6 @@
  * Copyright (C) 2017 Soeren Moch <[email protected]>
  */
 
-#define __ASSEMBLY__
 #include "asm/arch/crm_regs.h"
 #include "asm/arch/iomux.h"
 #include "asm/arch/mx6-ddr.h"
board/technexion/pico-imx6ul/imximage.cfg +0 -1
index 993c1da6700..98de1782037 100644
@@ -8,7 +8,6 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/toradex/apalis-imx8/apalis-imx8-imximage.cfg +0 -1
index b8f0f3dc10f..16183f96679 100644
@@ -6,7 +6,6 @@
  * and create imx8image boot image
  */
 
-#define __ASSEMBLY__
 
 /* Boot from SD, sector size 0x400 */
 BOOT_FROM EMMC_FASTBOOT 0x400
board/toradex/apalis-imx8x/apalis-imx8x-imximage.cfg +0 -1
index 58c62d0a659..c229706f80a 100644
@@ -6,7 +6,6 @@
  * and create imx8image boot image
  */
 
-#define __ASSEMBLY__
 
 /* Boot from SD, sector size 0x400 */
 BOOT_FROM EMMC_FASTBOOT 0x400
board/toradex/colibri-imx6ull/imximage.cfg +0 -1
index e162cff90f0..0d81f9b2f4c 100644
@@ -9,7 +9,6 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/toradex/colibri-imx8x/colibri-imx8x-imximage.cfg +0 -1
index 44f6c0c4554..fa176b04084 100644
@@ -6,7 +6,6 @@
  * and create imx8image boot image
  */
 
-#define __ASSEMBLY__
 
 /* Boot from SD, sector size 0x400 */
 BOOT_FROM EMMC_FASTBOOT 0x400
board/toradex/colibri_imx7/imximage.cfg +0 -1
index bdce48b7ffa..41b3577b10d 100644
@@ -9,7 +9,6 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/toradex/verdin-imx8mm/imximage.cfg +0 -1
index fcc92009f3b..0e02e447992 100644
@@ -3,7 +3,6 @@
  * Copyright 2020-2021 Toradex
  */
 
-#define __ASSEMBLY__
 
 BOOT_FROM	emmc_fastboot
 LOADER		u-boot-spl-ddr.bin	0x7e1000
board/tq/tqma6/tqma6dl.cfg +0 -1
index 80c71503161..8cd1885b43f 100644
@@ -11,7 +11,6 @@
 /* image version */
 IMAGE_VERSION 2
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /*
board/tq/tqma6/tqma6q.cfg +0 -1
index 82a0a271d4f..a49489aed3f 100644
@@ -11,7 +11,6 @@
 /* image version */
 IMAGE_VERSION 2
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /*
board/tq/tqma6/tqma6s.cfg +0 -1
index 9cdbb3c7676..02f7e109100 100644
@@ -11,7 +11,6 @@
 /* image version */
 IMAGE_VERSION 2
 
-#define __ASSEMBLY__
 #include <config.h>
 
 /*
board/warp/imximage.cfg +0 -1
index d952c6f2e9e..f6bc604c8b2 100644
@@ -7,7 +7,6 @@
  *
  * The syntax is taken as close as possible with the kwbimage
  */
-#define __ASSEMBLY__
 #include <config.h>
 
 /* image version */
board/warp7/imximage.cfg +0 -1
index 9e7d4725e4a..ca22ee159b7 100644
@@ -8,7 +8,6 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
-#define __ASSEMBLY__
 #include <config.h>
 
 IMAGE_VERSION	2
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
#2 lore raw

Re: [PATCH v4 01/13] imx: Don't define __ASSEMBLY__ in C files

Quoted 4 lines · Simon Glass

This is supposed to be a build-system flag. Move it there so we can define it before linux/kconfig.h is included.

These aren't "C" files, they're DCD files. I think we can move the define as you're suggesting but the subject is wrong is all.

Signature · 1 line
Tom
#3 lore raw

Re: [PATCH v4 01/13] imx: Don't define __ASSEMBLY__ in C files

Hi Tom,

Quoted 10 lines · Tom Rini
Quoted 4 lines · Simon Glass

This is supposed to be a build-system flag. Move it there so we can define it before linux/kconfig.h is included.

These aren't "C" files, they're DCD files. I think we can move the define as you're suggesting but the subject is wrong is all.

I was thinking 'source' files but wrote 'C'. I'll hold off sending a new version unti lI get comments on the rest of it.

Regards,
Simon

#4 lore raw

PATCH v4 2/13 mips: Avoid using config_enabled() directly

In reply to Simon Glass

Use IS_ENABLED() instead, which is the correct macro for checking a CONFIG option.

---

(no changes since v1)

 arch/mips/lib/cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/lib/cache.c +1 -1
index 51a8f433475..ec652f0fba8 100644
@@ -38,7 +38,7 @@ static void probe_l2(void)
 			l2c = read_c0_config5() & MIPS_CONF5_L2C;
 	}
 
-	if (l2c && config_enabled(CONFIG_MIPS_CM)) {
+	if (l2c && IS_ENABLED(CONFIG_MIPS_CM)) {
 		gd->arch.l2_line_size = mips_cm_l2_line_size();
 	} else if (l2c) {
 		/* We don't know how to retrieve L2 config on this system */
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
Reviewed-by on v4 2/13
#5 lore raw

Re: [PATCH v4 02/13] mips: Avoid using config_enabled() directly

Am Sonntag, dem 16.01.2022 um 13:19 -0700 schrieb Simon Glass:

Quoted 5 lines

Use IS_ENABLED() instead, which is the correct macro for checking a CONFIG
option.

Quoted 21 lines

---

(no changes since v1)

 arch/mips/lib/cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/lib/cache.c +1 -1
index 51a8f433475..ec652f0fba8 100644
@@ -38,7 +38,7 @@ static void probe_l2(void)
 			l2c = read_c0_config5() & MIPS_CONF5_L2C;
 	}
 
-	if (l2c && config_enabled(CONFIG_MIPS_CM)) {
+	if (l2c && IS_ENABLED(CONFIG_MIPS_CM)) {
 		gd->arch.l2_line_size = mips_cm_l2_line_size();
 	} else if (l2c) {
 		/* We don't know how to retrieve L2 config on this

system */

Signature · 1 line
- Daniel
#6 lore raw

PATCH v4 3/13 mmc: fsl: Use brackets around if()

In reply to Simon Glass

At present the IS_ENABLED() macro has extra brackets, making it possible to write:

if IS_ENABLED(CONFIG_XXX)

but it is a bit confusing. Add the missing brackets.

---

(no changes since v1)

 drivers/mmc/fsl_esdhc_imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/fsl_esdhc_imx.c +1 -1
index 9299635f509..08ea98fe81a 100644
@@ -453,7 +453,7 @@ static int esdhc_send_cmd_common(struct fsl_esdhc_priv *priv, struct mmc *mmc,
 
 	/* Send the command */
 	esdhc_write32(&regs->cmdarg, cmd->cmdarg);
-	if IS_ENABLED(CONFIG_FSL_USDHC) {
+	if (IS_ENABLED(CONFIG_FSL_USDHC)) {
 		u32 mixctrl = esdhc_read32(&regs->mixctrl);
 
 		esdhc_write32(&regs->mixctrl,
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
Reviewed-by on v4 3/13
#7 lore raw

Re: [PATCH v4 03/13] mmc: fsl: Use brackets around if()

Quoted 21 lines · Simon Glass

At present the IS_ENABLED() macro has extra brackets, making it possible to write:

if IS_ENABLED(CONFIG_XXX)

but it is a bit confusing. Add the missing brackets.

---

(no changes since v1)

  drivers/mmc/fsl_esdhc_imx.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/fsl_esdhc_imx.c +0 -0
index 9299635f509..08ea98fe81a 100644

drivers/mmc/fsl_esdhc_imx.c static int esdhc_send_cmd_common(struct fsl_esdhc_priv *priv, struct mmc *mmc, · line 459

Quoted 8 lines
drivers/mmc/fsl_esdhc_imx.c +1 -1
@@ -453,7 +453,7 @@ static int esdhc_send_cmd_common(struct fsl_esdhc_priv *priv, struct mmc *mmc,
 
  	/* Send the command */
  	esdhc_write32(&regs->cmdarg, cmd->cmdarg);
-	if IS_ENABLED(CONFIG_FSL_USDHC) {
+	if (IS_ENABLED(CONFIG_FSL_USDHC)) {
  		u32 mixctrl = esdhc_read32(&regs->mixctrl);
 
  		esdhc_write32(&regs->mixctrl,
Reviewed-by on v4 3/13
#8 lore raw

Re: [PATCH v4 03/13] mmc: fsl: Use brackets around if()

In reply to Simon Glass
Quoted 8 lines · Simon Glass

At present the IS_ENABLED() macro has extra brackets, making it possible to write:

if IS_ENABLED(CONFIG_XXX)

but it is a bit confusing. Add the missing brackets.

Best Regards,
Jaehoon Chung

Quoted 21 lines

---

(no changes since v1)

 drivers/mmc/fsl_esdhc_imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/fsl_esdhc_imx.c +1 -1
index 9299635f509..08ea98fe81a 100644
@@ -453,7 +453,7 @@ static int esdhc_send_cmd_common(struct fsl_esdhc_priv *priv, struct mmc *mmc,
 
 	/* Send the command */
 	esdhc_write32(&regs->cmdarg, cmd->cmdarg);
-	if IS_ENABLED(CONFIG_FSL_USDHC) {
+	if (IS_ENABLED(CONFIG_FSL_USDHC)) {
 		u32 mixctrl = esdhc_read32(&regs->mixctrl);
 
 		esdhc_write32(&regs->mixctrl,
Reviewed-by
#9 lore raw

Re: [PATCH v4 03/13] mmc: fsl: Use brackets around if()

Hi!

2022년 1월 17일 (월) 08:50, Jaehoon Chung <[email protected]>님이 작성:

Quoted 6 lines · Simon Glass
Quoted 5 lines

At present the IS_ENABLED() macro has extra brackets, making it possible to write:

if IS_ENABLED(CONFIG_XXX)

Quoted 8 lines
Quoted 3 lines

but it is a bit confusing. Add the missing brackets.

Best Regards,
Jaehoon Chung

Quoted 21 lines

drivers/mmc/fsl_esdhc_imx.c static int esdhc_send_cmd_common(struct

Quoted 13 lines

---

(no changes since v1)

 drivers/mmc/fsl_esdhc_imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/fsl_esdhc_imx.c +0 -0
index 9299635f509..08ea98fe81a 100644
@@ -453,7 +453,7 @@ static int esdhc_send_cmd_common(struct

fsl_esdhc_priv *priv, struct mmc *mmc,

Quoted 7 lines
drivers/mmc/fsl_esdhc_imx.c +1 -1
      /* Send the command */
      esdhc_write32(&regs->cmdarg, cmd->cmdarg);
-     if IS_ENABLED(CONFIG_FSL_USDHC) {
+     if (IS_ENABLED(CONFIG_FSL_USDHC)) {
              u32 mixctrl = esdhc_read32(&regs->mixctrl);
 
Quoted 4 lines

drivers/mmc/fsl_esdhc_imx.c static int esdhc_send_cmd_common(struct · line 459

Quoted 2 lines
drivers/mmc/fsl_esdhc_imx.c +0 -0
              esdhc_write32(&regs->mixctrl,
 

--

Thanks. Minkyu Kang.

#10 lore raw

PATCH v4 4/13 kconfig: Update IS_ENABLED() internals

In reply to Simon Glass

The config_enabled() macro currently uses 0 as the default value. Update it to allow any value, so we can pass it something else, such as a non-existent function, to produce a build error if it is not defined.

Also tidy up the code style for IS_ENABLED() and drop the unnecessary brackets (the value is a simple 0 or 1).

---

(no changes since v1)

 include/linux/kconfig.h | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
include/linux/kconfig.h +5 -7
index a1d1a298426..52586a7557b 100644
@@ -17,18 +17,16 @@
  * the last step cherry picks the 2nd arg, we get a zero.
  */
 #define __ARG_PLACEHOLDER_1 0,
-#define config_enabled(cfg) _config_enabled(cfg)
-#define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value)
-#define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0)
+#define config_enabled(cfg, def_val) _config_enabled(cfg, def_val)
+#define _config_enabled(value, def_val) __config_enabled(__ARG_PLACEHOLDER_##value, def_val)
+#define __config_enabled(arg1_or_junk, def_val) ___config_enabled(arg1_or_junk 1, def_val)
 #define ___config_enabled(__ignored, val, ...) val
 
 /*
  * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y',
  * 0 otherwise.
- *
  */
-#define IS_ENABLED(option) \
-	(config_enabled(option))
+#define IS_ENABLED(option)	config_enabled(option, 0)
 
 /*
  * U-Boot add-on: Helper macros to reference to different macros (prefixed by
@@ -76,7 +74,7 @@
 #define __CONFIG_IS_ENABLED_1(option)        __CONFIG_IS_ENABLED_3(option, (1), (0))
 #define __CONFIG_IS_ENABLED_2(option, case1) __CONFIG_IS_ENABLED_3(option, case1, ())
 #define __CONFIG_IS_ENABLED_3(option, case1, case0) \
-	__concat(__unwrap, config_enabled(CONFIG_VAL(option))) (case1, case0)
+	__concat(__unwrap, config_enabled(CONFIG_VAL(option), 0)) (case1, case0)
 
 /*
  * CONFIG_IS_ENABLED(FOO) expands to
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
#11 lore raw

PATCH v4 5/13 kconfig: Add support for conditional values

In reply to Simon Glass

At present if an optional Kconfig value needs to be used it must be bracketed by #ifdef. For example, with this Kconfig setup:

config WIBBLE
bool "Support wibbles, the world needs more wibbles"

config WIBBLE_ADDR
hex "Address of the wibble"
depends on WIBBLE

then the following code must be used:

#ifdef CONFIG_WIBBLE
static void handle_wibble(void)
{
int val = CONFIG_WIBBLE_ADDR;

	...

}
#endif

static void init_machine()
{
...

 #ifdef CONFIG_WIBBLE
	handle_wibble();

#endif
}

Add a new IF_ENABLED_INT() to help with this. So now it is possible to write, without #ifdefs:

static void handle_wibble(void)

 {
        int val = IF_ENABLED_INT(CONFIG_WIBBLE, CONFIG_WIBBLE_ADDR);

	...

}

static void init_machine()
{
...
if (IS_ENABLED(CONFIG_WIBBLE))

	handle_wibble();

}

The value will be CONFIG_WIBBLE_ADDR if CONFIG_WIBBLE is defined and will produce a build error if not.. This allows us to reduce the use of #ifdef in the code, ensuring that the compiler still checks the code even if it is not ultimately used for a particular build.

Add a CONFIG_IF_ENABLED_INT() version as well.

If an attempt is made to use a value that does not exist (i.e. when the conditional is not enabled), an error about a non-existing function is generated, e.g.:

common/bloblist.c:447: undefined reference to `invalid_use_of_IF_ENABLED_INT'

---

Changes in v4:
- Update stale mention of zero in commit message
- Update stale comments in the header file
- Define the macros even in assembly context

Changes in v3:
- Add a way to detect use of a non-existent value

 include/linux/kconfig.h   | 40 +++++++++++++++++++++++++++++++++++++++
 scripts/Makefile.autoconf |  2 +-
 2 files changed, 41 insertions(+), 1 deletion(-)
include/linux/kconfig.h +40 -0
index 52586a7557b..d20da615b96 100644
@@ -57,6 +57,30 @@
  */
 #define CONFIG_VAL(option)  config_val(option)
 
+/*
+ * This uses a similar mechanism to config_enabled() above. If cfg is enabled,
+ * it resolves to the value of opt_cfg, otherwise it resolves to def_val
+ */
+#define config_opt_enabled(cfg, opt_cfg, def_val) _config_opt_enabled(cfg, opt_cfg, def_val)
+#define _config_opt_enabled(cfg_val, opt_value, def_val) \
+	__config_opt_enabled(__ARG_PLACEHOLDER_##cfg_val, opt_value, def_val)
+#define __config_opt_enabled(arg1_or_junk, arg2, def_val) \
+	___config_opt_enabled(arg1_or_junk arg2, def_val)
+#define ___config_opt_enabled(__ignored, val, ...) val
+
+#ifndef __ASSEMBLY__
+/*
+ * Detect usage of a the value when the conditional is not enabled. When used
+ * in assembly context, this likely produces a assembly error, or hopefully at
+ * least something recognisable.
+ */
+long invalid_use_of_IF_ENABLED_INT(void);
+#endif
+
+/* Evaluates to int_option if option is defined, otherwise a build error */
+#define IF_ENABLED_INT(option, int_option) \
+	config_opt_enabled(option, int_option, invalid_use_of_IF_ENABLED_INT())
+
 /*
  * Count number of arguments to a variadic macro. Currently only need
  * it for 1, 2 or 3 arguments.
@@ -111,5 +135,21 @@
 #define CONFIG_IS_ENABLED(option, ...)					\
 	__concat(__CONFIG_IS_ENABLED_, __count_args(option, ##__VA_ARGS__)) (option, ##__VA_ARGS__)
 
+#ifndef __ASSEMBLY__
+/*
+ * Detect usage of a the value when the conditional is not enabled. When used
+ * in assembly context, this likely produces a assembly error, or hopefully at
+ * least something recognisable.
+ */
+long invalid_use_of_CONFIG_IF_ENABLED_INT(void);
+#endif
+
+/*
+ * Evaluates to SPL_/TPL_int_option if SPL_/TPL_/option is not defined,
+ * otherwise build error
+ */
+#define CONFIG_IF_ENABLED_INT(option, int_option) \
+	CONFIG_IS_ENABLED(option, (CONFIG_VAL(int_option)), \
+		(invalid_use_of_CONFIG_IF_ENABLED_INT()))
 
 #endif /* __LINUX_KCONFIG_H */
scripts/Makefile.autoconf +1 -1
index 5ed9abc8e14..0b3ffa08bfa 100644
@@ -68,7 +68,7 @@ quiet_cmd_u_boot_cfg = CFG     $@
       cmd_u_boot_cfg = \
 	$(CPP) $(c_flags) $2 -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > [email protected] && { \
 		grep 'define CONFIG_' [email protected] | \
-			sed '/define CONFIG_IS_ENABLED(/d;/define CONFIG_VAL(/d;' > $@; \
+			sed '/define CONFIG_IS_ENABLED(/d;/define CONFIG_IF_ENABLED_INT(/d;/define CONFIG_VAL(/d;' > $@; \
 		rm [email protected];						\
 	} || {								\
 		rm [email protected]; false;					\
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
#12 lore raw

PATCH v4 6/13 bloblist: Update to use conditional value

In reply to Simon Glass

Use the new IF_ENABLED_INT() feature to avoid needing our own inline function to handle this case. Tidy up the logic to ensure that the value is only used when present. Update the 'expected' comment also.

---

(no changes since v3)

Changes in v3:
- Add new patch to update bloblist to use conditional value

 common/bloblist.c  | 15 +++++++++++----
 include/bloblist.h | 10 ----------
 2 files changed, 11 insertions(+), 14 deletions(-)
common/bloblist.c +11 -4
index 056b50c2cb6..406073c8105 100644
@@ -430,18 +430,23 @@ void bloblist_reloc(void *to, uint to_size, void *from, uint from_size)
 
 int bloblist_init(void)
 {
+	bool fixed = IS_ENABLED(CONFIG_BLOBLIST_FIXED);
 	int ret = -ENOENT;
 	ulong addr, size;
 	bool expected;
 
 	/**
-	 * Wed expect to find an existing bloblist in the first phase of U-Boot
-	 * that runs
+	 * We don't expect to find an existing bloblist in the first phase of
+	 * U-Boot that runs. Also we have no way to receive the address of an
+	 * allocated bloblist from a previous stage, so it must be at a fixed
+	 * address.
 	 */
-	expected = !u_boot_first_phase();
+	expected = fixed && !u_boot_first_phase();
 	if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
 		expected = false;
-	addr = bloblist_addr();
+	if (fixed)
+		addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED,
+				      CONFIG_BLOBLIST_ADDR);
 	size = CONFIG_BLOBLIST_SIZE;
 	if (expected) {
 		ret = bloblist_check(addr, size);
@@ -460,6 +465,8 @@ int bloblist_init(void)
 			if (!ptr)
 				return log_msg_ret("alloc", -ENOMEM);
 			addr = map_to_sysmem(ptr);
+		} else if (!fixed) {
+			return log_msg_ret("!fixed", ret);
 		}
 		log_debug("Creating new bloblist size %lx at %lx\n", size,
 			  addr);
include/bloblist.h +0 -10
index 173129b0273..d0e128acf10 100644
@@ -147,16 +147,6 @@ struct bloblist_rec {
 	u32 spare;
 };
 
-/* access CONFIG_BLOBLIST_ADDR, dealing with it possibly not being defined */
-static inline ulong bloblist_addr(void)
-{
-#ifdef CONFIG_BLOBLIST_FIXED
-	return CONFIG_BLOBLIST_ADDR;
-#else
-	return 0;
-#endif
-}
-
 /**
  * bloblist_check_magic() - return a bloblist if the magic matches
  *
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
#13 lore raw

PATCH v4 7/13 patman: Update test_util to run doc tests

In reply to Simon Glass

At present this function does not run the doctests. Allow the caller to pass these modules in as strings.

Update patman to use this.

---

(no changes since v1)

 tools/dtoc/main.py        |  2 +-
 tools/patman/main.py      | 20 ++++----------------
 tools/patman/test_util.py | 17 +++++++++++------
 3 files changed, 16 insertions(+), 23 deletions(-)
tools/dtoc/main.py +1 -1
index 6f9b526bd74..276cfadf5a3 100755
@@ -58,7 +58,7 @@ def run_tests(processes, args):
     test_util.RunTestSuites(
         result, debug=True, verbosity=1, test_preserve_dirs=False,
         processes=processes, test_name=test_name, toolpath=[],
-        test_class_list=[test_dtoc.TestDtoc,test_src_scan.TestSrcScan])
+        class_and_module_list=[test_dtoc.TestDtoc,test_src_scan.TestSrcScan])
 
     return test_util.ReportResult('binman', test_name, result)
 
tools/patman/main.py +4 -16
index e5be28e3316..c01ae36e9f9 100755
@@ -134,23 +134,11 @@ if args.cmd == 'test':
     import doctest
     from patman import func_test
 
-    sys.argv = [sys.argv[0]]
     result = unittest.TestResult()
-    suite = unittest.TestSuite()
-    loader = unittest.TestLoader()
-    for module in (test_checkpatch.TestPatch, func_test.TestFunctional):
-        if args.testname:
-            try:
-                suite.addTests(loader.loadTestsFromName(args.testname, module))
-            except AttributeError:
-                continue
-        else:
-            suite.addTests(loader.loadTestsFromTestCase(module))
-    suite.run(result)
-
-    for module in ['gitutil', 'settings', 'terminal']:
-        suite = doctest.DocTestSuite(module)
-        suite.run(result)
+    test_util.RunTestSuites(
+        result, False, False, False, None, None, None,
+        [test_checkpatch.TestPatch, func_test.TestFunctional,
+         'gitutil', 'settings', 'terminal'])
 
     sys.exit(test_util.ReportResult('patman', args.testname, result))
 
tools/patman/test_util.py +11 -6
index 4e261755dc6..9654e7319c1 100644
@@ -4,6 +4,7 @@
 #
 
 from contextlib import contextmanager
+import doctest
 import glob
 import multiprocessing
 import os
@@ -139,7 +140,7 @@ def ReportResult(toolname:str, test_name: str, result: unittest.TestResult):
 
 
 def RunTestSuites(result, debug, verbosity, test_preserve_dirs, processes,
-                  test_name, toolpath, test_class_list):
+                  test_name, toolpath, class_and_module_list):
     """Run a series of test suites and collect the results
 
     Args:
@@ -154,11 +155,13 @@ def RunTestSuites(result, debug, verbosity, test_preserve_dirs, processes,
         processes: Number of processes to use to run tests (None=same as #CPUs)
         test_name: Name of test to run, or None for all
         toolpath: List of paths to use for tools
-        test_class_list: List of test classes to run
+        class_and_module_list: List of test classes (type class) and module
+           names (type str) to run
     """
-    for module in []:
-        suite = doctest.DocTestSuite(module)
-        suite.run(result)
+    for module in class_and_module_list:
+        if isinstance(module, str) and (not test_name or test_name == module):
+            suite = doctest.DocTestSuite(module)
+            suite.run(result)
 
     sys.argv = [sys.argv[0]]
     if debug:
@@ -171,7 +174,9 @@ def RunTestSuites(result, debug, verbosity, test_preserve_dirs, processes,
 
     suite = unittest.TestSuite()
     loader = unittest.TestLoader()
-    for module in test_class_list:
+    for module in class_and_module_list:
+        if isinstance(module, str):
+            continue
         # Test the test module about our arguments, if it is interested
         if hasattr(module, 'setup_test_args'):
             setup_test_args = getattr(module, 'setup_test_args')
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
#14 lore raw

PATCH v4 8/13 buildman: Add a flag to control the traceback

In reply to Simon Glass

At present the full horror of the Python traceback is shown by default. It is normally only useful for debugging. Turn it off by default and add a --debug flag to enable it.

---

(no changes since v1)

 tools/buildman/cmdline.py | 2 ++
 tools/buildman/main.py    | 3 +++
 2 files changed, 5 insertions(+)
tools/buildman/cmdline.py +2 -0
index 274b5ac3f45..092a82f4e9c 100644
@@ -32,6 +32,8 @@ def ParseArgs():
           help='Show detailed size delta for each board in the -S summary')
     parser.add_option('-D', '--config-only', action='store_true', default=False,
           help="Don't build, just configure each commit")
+    parser.add_option('--debug', action='store_true',
+        help='Enabling debugging (provides a full traceback on error)')
     parser.add_option('-e', '--show_errors', action='store_true',
           default=False, help='Show errors and warnings')
     parser.add_option('-E', '--warnings-as-errors', action='store_true',
tools/buildman/main.py +3 -0
index 2b714739a20..04698ce9e50 100755
@@ -54,6 +54,9 @@ def RunTests(skip_net_tests):
 
 options, args = cmdline.ParseArgs()
 
+if not options.debug:
+    sys.tracebacklimit = 0
+
 # Run our meagre tests
 if options.test:
     RunTests(options.skip_net_tests)
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
#15 lore raw

PATCH v4 9/13 buildman: Make use of test_util

In reply to Simon Glass

Use test_util to run the tests, with the ability to select a single test to run, if desired.

---

(no changes since v1)

 tools/buildman/main.py | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)
tools/buildman/main.py +11 -15
index 04698ce9e50..c6af311a69b 100755
@@ -27,30 +27,26 @@ from buildman import toolchain
 from patman import patchstream
 from patman import gitutil
 from patman import terminal
+from patman import test_util
 
-def RunTests(skip_net_tests):
+def RunTests(skip_net_tests, verboose, args):
     import func_test
     import test
     import doctest
 
     result = unittest.TestResult()
-    for module in ['buildman.toolchain', 'patman.gitutil']:
-        suite = doctest.DocTestSuite(module)
-        suite.run(result)
-
-    sys.argv = [sys.argv[0]]
+    test_name = args and args[0] or None
     if skip_net_tests:
         test.use_network = False
-    for module in (test.TestBuild, func_test.TestFunctional):
-        suite = unittest.TestLoader().loadTestsFromTestCase(module)
-        suite.run(result)
 
-    print(result)
-    for test, err in result.errors:
-        print(err)
-    for test, err in result.failures:
-        print(err)
+    # Run the entry tests first ,since these need to be the first to import the
+    # 'entry' module.
+    test_util.RunTestSuites(
+        result, False, verboose, False, None, test_name, [],
+        [test.TestBuild, func_test.TestFunctional,
+         'buildman.toolchain', 'patman.gitutil'])
 
+    return test_util.ReportResult('buildman', test_name, result)
 
 options, args = cmdline.ParseArgs()
 
@@ -59,7 +55,7 @@ if not options.debug:
 
 # Run our meagre tests
 if options.test:
-    RunTests(options.skip_net_tests)
+    RunTests(options.skip_net_tests, options.verbose, args)
 
 # Build selected commits for selected boards
 else:
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
#16 lore raw

PATCH v4 10/13 buildman: Add helper functions for updating .config files

In reply to Simon Glass

At present the only straightforward way to write tests that need a slightly different configuration is to create a new board with its own configuration. This is cumbersome.

It would be useful if buildman could adjust the configuration of a build on the fly. In preparation for this, add a utility library which can modify a .config file according to various parameters passed to it.

---

(no changes since v1)

 tools/buildman/cfgutil.py   | 235 ++++++++++++++++++++++++++++++++++++
 tools/buildman/func_test.py |   4 +-
 tools/buildman/test.py      | 123 +++++++++++++++++++
 3 files changed, 360 insertions(+), 2 deletions(-)
 create mode 100644 tools/buildman/cfgutil.py
tools/buildman/cfgutil.py new file +235 -0
new file mode 100644
index 00000000000..4eba50868f5
@@ -0,0 +1,235 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright 2022 Google LLC
+# Written by Simon Glass <[email protected]>
+#
+
+"""Utility functions for dealing with Kconfig .confing files"""
+
+import re
+
+from patman import tools
+
+RE_LINE = re.compile(r'(# )?CONFIG_([A-Z0-9_]+)(=(.*)| is not set)')
+RE_CFG = re.compile(r'(~?)(CONFIG_)?([A-Z0-9_]+)(=.*)?')
+
+def make_cfg_line(opt, adj):
+    """Make a new config line for an option
+
+    Args:
+        opt (str): Option to process, without CONFIG_ prefix
+        adj (str): Adjustment to make (C is config option without prefix):
+             C to enable C
+             ~C to disable C
+             C=val to set the value of C (val must have quotes if C is
+                 a string Kconfig)
+
+    Returns:
+        str: New line to use, one of:
+            CONFIG_opt=y               - option is enabled
+            # CONFIG_opt is not set    - option is disabled
+            CONFIG_opt=val             - option is getting a new value (val is
+                in quotes if this is a string)
+    """
+    if adj[0] == '~':
+        return f'# CONFIG_{opt} is not set'
+    if '=' in adj:
+        return f'CONFIG_{adj}'
+    return f'CONFIG_{opt}=y'
+
+def adjust_cfg_line(line, adjust_cfg, done=None):
+    """Make an adjustment to a single of line from a .config file
+
+    This processes a .config line, producing a new line if a change for this
+    CONFIG is requested in adjust_cfg
+
+    Args:
+        line (str): line to process, e.g. '# CONFIG_FRED is not set' or
+            'CONFIG_FRED=y' or 'CONFIG_FRED=0x123' or 'CONFIG_FRED="fred"'
+        adjust_cfg (dict of str): Changes to make to .config file before
+                building:
+             key: str config to change, without the CONFIG_ prefix, e.g.
+                 FRED
+             value: str change to make (C is config option without prefix):
+                 C to enable C
+                 ~C to disable C
+                 C=val to set the value of C (val must have quotes if C is
+                     a string Kconfig)
+        done (set of set): Adds the config option to this set if it is changed
+            in some way. This is used to track which ones have been processed.
+            None to skip.
+
+    Returns:
+        tuple:
+            str: New string for this line (maybe unchanged)
+            str: Adjustment string that was used
+    """
+    out_line = line
+    m_line = RE_LINE.match(line)
+    adj = None
+    if m_line:
+        _, opt, _, _ = m_line.groups()
+        adj = adjust_cfg.get(opt)
+        if adj:
+            out_line = make_cfg_line(opt, adj)
+            if done is not None:
+                done.add(opt)
+
+    return out_line, adj
+
+def adjust_cfg_lines(lines, adjust_cfg):
+    """Make adjustments to a list of lines from a .config file
+
+    Args:
+        lines (list of str): List of lines to process
+        adjust_cfg (dict of str): Changes to make to .config file before
+                building:
+             key: str config to change, without the CONFIG_ prefix, e.g.
+                 FRED
+             value: str change to make (C is config option without prefix):
+                 C to enable C
+                 ~C to disable C
+                 C=val to set the value of C (val must have quotes if C is
+                     a string Kconfig)
+
+    Returns:
+        list of str: New list of lines resulting from the processing
+    """
+    out_lines = []
+    done = set()
+    for line in lines:
+        out_line, _ = adjust_cfg_line(line, adjust_cfg, done)
+        out_lines.append(out_line)
+
+    for opt in adjust_cfg:
+        if opt not in done:
+            adj = adjust_cfg.get(opt)
+            out_line = make_cfg_line(opt, adj)
+            out_lines.append(out_line)
+
+    return out_lines
+
+def adjust_cfg_file(fname, adjust_cfg):
+    """Make adjustments to a .config file
+
+    Args:
+        fname (str): Filename of .config file to change
+        adjust_cfg (dict of str): Changes to make to .config file before
+                building:
+             key: str config to change, without the CONFIG_ prefix, e.g.
+                 FRED
+             value: str change to make (C is config option without prefix):
+                 C to enable C
+                 ~C to disable C
+                 C=val to set the value of C (val must have quotes if C is
+                     a string Kconfig)
+    """
+    lines = tools.ReadFile(fname, binary=False).splitlines()
+    out_lines = adjust_cfg_lines(lines, adjust_cfg)
+    out = '\n'.join(out_lines) + '\n'
+    tools.WriteFile(fname, out, binary=False)
+
+def convert_list_to_dict(adjust_cfg_list):
+    """Convert a list of config changes into the dict used by adjust_cfg_file()
+
+    Args:
+        adjust_cfg_list (list of str): List of changes to make to .config file
+            before building. Each is one of (where C is the config option with
+            or without the CONFIG_ prefix)
+
+                C to enable C
+                ~C to disable C
+                C=val to set the value of C (val must have quotes if C is
+                    a string Kconfig
+
+    Returns:
+        dict of str: Changes to make to .config file before building:
+             key: str config to change, without the CONFIG_ prefix, e.g. FRED
+             value: str change to make (C is config option without prefix):
+                 C to enable C
+                 ~C to disable C
+                 C=val to set the value of C (val must have quotes if C is
+                     a string Kconfig)
+
+    Raises:
+        ValueError: if an item in adjust_cfg_list has invalid syntax
+    """
+    result = {}
+    for cfg in adjust_cfg_list or []:
+        m_cfg = RE_CFG.match(cfg)
+        if not m_cfg:
+            raise ValueError(f"Invalid CONFIG adjustment '{cfg}'")
+        negate, _, opt, val = m_cfg.groups()
+        result[opt] = f'%s{opt}%s' % (negate or '', val or '')
+
+    return result
+
+def check_cfg_lines(lines, adjust_cfg):
+    """Check that lines do not conflict with the requested changes
+
+    If a line enables a CONFIG which was requested to be disabled, etc., then
+    this is an error. This function finds such errors.
+
+    Args:
+        lines (list of str): List of lines to process
+        adjust_cfg (dict of str): Changes to make to .config file before
+                building:
+             key: str config to change, without the CONFIG_ prefix, e.g.
+                 FRED
+             value: str change to make (C is config option without prefix):
+                 C to enable C
+                 ~C to disable C
+                 C=val to set the value of C (val must have quotes if C is
+                     a string Kconfig)
+
+    Returns:
+        list of tuple: list of errors, each a tuple:
+            str: cfg adjustment requested
+            str: line of the config that conflicts
+    """
+    bad = []
+    done = set()
+    for line in lines:
+        out_line, adj = adjust_cfg_line(line, adjust_cfg, done)
+        if out_line != line:
+            bad.append([adj, line])
+
+    for opt in adjust_cfg:
+        if opt not in done:
+            adj = adjust_cfg.get(opt)
+            out_line = make_cfg_line(opt, adj)
+            bad.append([adj, f'Missing expected line: {out_line}'])
+
+    return bad
+
+def check_cfg_file(fname, adjust_cfg):
+    """Check that a config file has been adjusted according to adjust_cfg
+
+    Args:
+        fname (str): Filename of .config file to change
+        adjust_cfg (dict of str): Changes to make to .config file before
+                building:
+             key: str config to change, without the CONFIG_ prefix, e.g.
+                 FRED
+             value: str change to make (C is config option without prefix):
+                 C to enable C
+                 ~C to disable C
+                 C=val to set the value of C (val must have quotes if C is
+                     a string Kconfig)
+
+    Returns:
+        str: None if OK, else an error string listing the problems
+    """
+    lines = tools.ReadFile(fname, binary=False).splitlines()
+    bad_cfgs = check_cfg_lines(lines, adjust_cfg)
+    if bad_cfgs:
+        out = [f'{cfg:20}  {line}' for cfg, line in bad_cfgs]
+        content = '\\n'.join(out)
+        return f'''
+Some CONFIG adjustments did not take effect. This may be because
+the request CONFIGs do not exist or conflict with others.
+
+Failed adjustments:
+
+{content}
+'''
+    return None
tools/buildman/func_test.py +2 -2
index 7edbee0652f..e09ccb742e8 100644
@@ -182,11 +182,11 @@ class TestFunctional(unittest.TestCase):
         self._buildman_pathname = sys.argv[0]
         self._buildman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
         command.test_result = self._HandleCommand
+        bsettings.Setup(None)
+        bsettings.AddFile(settings_data)
         self.setupToolchains()
         self._toolchains.Add('arm-gcc', test=False)
         self._toolchains.Add('powerpc-gcc', test=False)
-        bsettings.Setup(None)
-        bsettings.AddFile(settings_data)
         self._boards = board.Boards()
         for brd in boards:
             self._boards.AddBoard(board.Board(*brd))
tools/buildman/test.py +123 -0

134 lines not on this page · raw message

Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
#17 lore raw

PATCH v4 11/13 buildman: Provide a hint on how to debug thread crashes

In reply to Simon Glass

If a thread crashes it is helpful to try the operation again with threading disabled. Add a hint about that.

---

(no changes since v1)

 tools/buildman/builderthread.py | 2 +-
 tools/buildman/func_test.py     | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
tools/buildman/builderthread.py +1 -1
index 3e450e40670..0faa3ac9385 100644
@@ -557,6 +557,6 @@ class BuilderThread(threading.Thread):
             try:
                 self.RunJob(job)
             except Exception as e:
-                print('Thread exception:', e)
+                print('Thread exception (use -T0 to run without threads):', e)
                 self.builder.thread_exceptions.append(e)
             self.builder.queue.task_done()
tools/buildman/func_test.py +3 -1
index e09ccb742e8..c2e0b0b5c62 100644
@@ -623,4 +623,6 @@ class TestFunctional(unittest.TestCase):
         with test_util.capture_sys_output() as (stdout, stderr):
             self.assertEqual(102, self._RunControl('-o', self._output_dir,
                                                    test_thread_exceptions=True))
-        self.assertIn('Thread exception: test exception', stdout.getvalue())
+        self.assertIn(
+            'Thread exception (use -T0 to run without threads): test exception',
+            stdout.getvalue())
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
#18 lore raw

PATCH v4 12/13 buildman: Allow adjusting board config on the fly

In reply to Simon Glass

Add a -a option to specify changes to the config before the build commences. For example

buildman -a ~CONFIG_CMDLINE

disables CONFIG_CMDLINE before doing the build.

This makes it easier to try things out as well as to write tests without creating a new board or manually manging the .config file.

---

(no changes since v1)

 tools/buildman/README           | 49 +++++++++++++++++++++++++++++++++
 tools/buildman/builder.py       | 14 +++++++++-
 tools/buildman/builderthread.py | 30 ++++++++++++++++----
 tools/buildman/cmdline.py       |  2 ++
 tools/buildman/control.py       |  6 +++-
 5 files changed, 93 insertions(+), 8 deletions(-)
tools/buildman/README +49 -0
index ce277884326..bafb3b065ce 100644
@@ -1095,6 +1095,55 @@ This will write the full build into /tmp/build including object files. You must
 specify the output directory with -o when using -w.
 
 
+Changing the configuration
+==========================
+
+Sometimes it is useful to change the CONFIG options for a build on the fly. This
+can be used to build a board (or multiple) with a few changes to see the impact.
+The -a option supports this:
+
+   -a <cfg>
+
+where <cfg> is a CONFIG option (with or without the CONFIG_ prefix) to enable.
+For example:
+
+    buildman -a CMD_SETEXPR_FMT
+
+will build with CONFIG_CMD_SETEXPR_FMT enabled.
+
+You can disable options by preceding them with tilde (~). You can specify the
+-a option multiple times:
+
+    buildman -a CMD_SETEXPR_FMT -a ~CMDLINE
+
+Some options have values, in which case you can change them:
+
+    buildman -a 'BOOTCOMMAND="echo hello"' CONFIG_SYS_LOAD_ADDR=0x1000
+
+Note that you must put quotes around string options and the whole thing must be
+in single quotes, to make sure the shell leave it alone.
+
+If you try to set an option that does not exist, or that cannot be changed for
+some other reason (e.g. it is 'selected' by another option), then buildman
+shows an error:
+
+   buildman --board sandbox -a FRED
+   Building current source for 1 boards (1 thread, 32 jobs per thread)
+       0    0    0 /1       -1      (starting)errs
+   Some CONFIG adjustments did not take effect. This may be because
+   the request CONFIGs do not exist or conflict with others.
+
+   Failed adjustments:
+
+   FRED                  Missing expected line: CONFIG_FRED=y
+
+
+One major caveat with this feature with branches (-b) is that buildman does not
+name the output directories differently when you change the configuration, so
+doing the same build again with different configuration will not trigger a
+rebuild. You can use -f to work around that.
+
+
 Other options
 =============
 
tools/buildman/builder.py +13 -1
index 122f0d14065..720bbb2cf4d 100644
@@ -250,7 +250,7 @@ class Builder:
                  mrproper=False, per_board_out_dir=False,
                  config_only=False, squash_config_y=False,
                  warnings_as_errors=False, work_in_output=False,
-                 test_thread_exceptions=False):
+                 test_thread_exceptions=False, adjust_cfg=None):
         """Create a new Builder object
 
         Args:
@@ -280,6 +280,15 @@ class Builder:
             test_thread_exceptions: Uses for tests only, True to make the
                 threads raise an exception instead of reporting their result.
                 This simulates a failure in the code somewhere
+            adjust_cfg_list (list of str): List of changes to make to .config
+                file before building. Each is one of (where C is the config
+                option with or without the CONFIG_ prefix)
+
+                    C to enable C
+                    ~C to disable C
+                    C=val to set the value of C (val must have quotes if C is
+                        a string Kconfig
+
         """
         self.toolchains = toolchains
         self.base_dir = base_dir
@@ -315,6 +324,8 @@ class Builder:
         self.squash_config_y = squash_config_y
         self.config_filenames = BASE_CONFIG_FILENAMES
         self.work_in_output = work_in_output
+        self.adjust_cfg = adjust_cfg
+
         if not self.squash_config_y:
             self.config_filenames += EXTRA_CONFIG_FILENAMES
         self._terminated = False
@@ -1747,6 +1758,7 @@ class Builder:
             job.commits = commits
             job.keep_outputs = keep_outputs
             job.work_in_output = self.work_in_output
+            job.adjust_cfg = self.adjust_cfg
             job.step = self._step
             if self.num_threads:
                 self.queue.put(job)
tools/buildman/builderthread.py +24 -6
index 0faa3ac9385..ecb285c0bfa 100644
@@ -9,6 +9,7 @@ import shutil
 import sys
 import threading
 
+from buildman import cfgutil
 from patman import command
 from patman import gitutil
 
@@ -130,7 +131,8 @@ class BuilderThread(threading.Thread):
                 **kwargs)
 
     def RunCommit(self, commit_upto, brd, work_dir, do_config, config_only,
-                  force_build, force_build_failures, work_in_output):
+                  force_build, force_build_failures, work_in_output,
+                  adjust_cfg):
         """Build a particular commit.
 
         If the build is already done, and we are not forcing a build, we skip
@@ -147,6 +149,13 @@ class BuilderThread(threading.Thread):
                 failure
             work_in_output: Use the output directory as the work directory and
                 don't write to a separate output directory.
+            adjust_cfg (list of str): List of changes to make to .config file
+                before building. Each is one of (where C is either CONFIG_xxx
+                or just xxx):
+                     C to enable C
+                     ~C to disable C
+                     C=val to set the value of C (val must have quotes if C is
+                         a string Kconfig
 
         Returns:
             tuple containing:
@@ -261,7 +270,8 @@ class BuilderThread(threading.Thread):
                         os.remove(fname)
 
                 # If we need to reconfigure, do that now
-                if do_config:
+                cfg_file = os.path.join(out_dir, '.config')
+                if do_config or adjust_cfg:
                     config_out = ''
                     if self.mrproper:
                         result = self.Make(commit, brd, 'mrproper', cwd,
@@ -271,11 +281,19 @@ class BuilderThread(threading.Thread):
                             *(args + config_args), env=env)
                     config_out += result.combined
                     do_config = False   # No need to configure next time
+                    if adjust_cfg:
+                        cfgutil.adjust_cfg_file(cfg_file, adjust_cfg)
                 if result.return_code == 0:
                     if config_only:
                         args.append('cfg')
                     result = self.Make(commit, brd, 'build', cwd, *args,
                             env=env)
+                    if adjust_cfg:
+                        errs = cfgutil.check_cfg_file(cfg_file, adjust_cfg)
+                        if errs:
+                            print('errs', errs)
+                            result.stderr += errs
+                            result.return_code = 1
                 result.stderr = result.stderr.replace(src_dir + '/', '')
                 if self.builder.verbose_build:
                     result.stdout = config_out + result.stdout
@@ -486,7 +504,7 @@ class BuilderThread(threading.Thread):
                         work_dir, do_config, self.builder.config_only,
                         force_build or self.builder.force_build,
                         self.builder.force_build_failures,
-                        work_in_output=job.work_in_output)
+                        job.work_in_output, job.adjust_cfg)
                 failed = result.return_code or result.stderr
                 did_config = do_config
                 if failed and not do_config:
@@ -495,7 +513,7 @@ class BuilderThread(threading.Thread):
                     if self.builder.force_config_on_failure:
                         result, request_config = self.RunCommit(commit_upto,
                             brd, work_dir, True, False, True, False,
-                            work_in_output=job.work_in_output)
+                            job.work_in_output, job.adjust_cfg)
                         did_config = True
                 if not self.builder.force_reconfig:
                     do_config = request_config
@@ -540,8 +558,8 @@ class BuilderThread(threading.Thread):
             # Just build the currently checked-out build
             result, request_config = self.RunCommit(None, brd, work_dir, True,
                         self.builder.config_only, True,
-                        self.builder.force_build_failures,
-                        work_in_output=job.work_in_output)
+                        self.builder.force_build_failures, job.work_in_output,
+                        job.adjust_cfg)
             result.commit_upto = 0
             self._WriteResult(result, job.keep_outputs, job.work_in_output)
             self._SendResult(result)
tools/buildman/cmdline.py +2 -0
index 092a82f4e9c..8586bdf3b58 100644
@@ -13,6 +13,8 @@ def ParseArgs():
             args: command lin arguments
     """
     parser = OptionParser()
+    parser.add_option('-a', '--adjust-cfg', type=str, action='append',
+          help='Adjust the Kconfig settings in .config before building')
     parser.add_option('-A', '--print-prefix', action='store_true',
           help='Print the tool-chain prefix for a board (CROSS_COMPILE=)')
     parser.add_option('-b', '--branch', type='string',
tools/buildman/control.py +5 -1
index fd9664c85d8..eee81130663 100644
@@ -10,6 +10,7 @@ import sys
 
 from buildman import board
 from buildman import bsettings
+from buildman import cfgutil
 from buildman import toolchain
 from buildman.builder import Builder
 from patman import command
@@ -321,6 +322,8 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
             output_dir = os.path.join(options.output_dir, dirname)
         if clean_dir and os.path.exists(output_dir):
             shutil.rmtree(output_dir)
+    adjust_cfg = cfgutil.convert_list_to_dict(options.adjust_cfg)
+
     builder = Builder(toolchains, output_dir, options.git_dir,
             options.threads, options.jobs, gnu_make=gnu_make, checkout=True,
             show_unknown=options.show_unknown, step=options.step,
@@ -332,7 +335,8 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
             squash_config_y=not options.preserve_config_y,
             warnings_as_errors=options.warnings_as_errors,
             work_in_output=options.work_in_output,
-            test_thread_exceptions=test_thread_exceptions)
+            test_thread_exceptions=test_thread_exceptions,
+            adjust_cfg=adjust_cfg)
     builder.force_config_on_failure = not options.quick
     if make_func:
         builder.do_make = make_func
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
#19 lore raw

PATCH v4 13/13 test: Add some tests for kconfig.h

In reply to Simon Glass

The macros in this file are a little confusing and we currently have no tests to check that they work as expected.

Add some tests which check the macros in C code. Add a few tests which check that the build errors are generated correctly too, using buildman's -a option.

---

Changes in v4:
- Expand the series with tests and buildman changes

 test/Kconfig                  |  1 +
 test/Makefile                 |  2 +-
 test/lib/Kconfig              | 23 ++++++++++++++
 test/lib/Makefile             |  5 +++
 test/lib/kconfig.c            | 58 +++++++++++++++++++++++++++++++++++
 test/lib/kconfig_spl.c        | 44 ++++++++++++++++++++++++++
 test/py/tests/test_kconfig.py | 34 ++++++++++++++++++++
 7 files changed, 166 insertions(+), 1 deletion(-)
 create mode 100644 test/lib/Kconfig
 create mode 100644 test/lib/kconfig.c
 create mode 100644 test/lib/kconfig_spl.c
 create mode 100644 test/py/tests/test_kconfig.py
test/Kconfig +1 -0
index e15ba239eb3..4137e7eabf5 100644
@@ -97,5 +97,6 @@ config UT_UNICODE
 
 source "test/dm/Kconfig"
 source "test/env/Kconfig"
+source "test/lib/Kconfig"
 source "test/optee/Kconfig"
 source "test/overlay/Kconfig"
test/Makefile +1 -1
index b3b2902e2e7..379f1e9fda7 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_$(SPL_)CMDLINE) += cmd_ut.o
 obj-$(CONFIG_$(SPL_)CMDLINE) += command_ut.o
 obj-$(CONFIG_$(SPL_)UT_COMPRESSION) += compression.o
 obj-y += dm/
+obj-$(CONFIG_UNIT_TEST) += lib/
 obj-$(CONFIG_$(SPL_)CMDLINE) += print_ut.o
 obj-$(CONFIG_$(SPL_)CMDLINE) += str_ut.o
 obj-$(CONFIG_UT_TIME) += time_ut.o
@@ -23,7 +24,6 @@ obj-y += ut.o
 
 ifeq ($(CONFIG_SPL_BUILD),)
 obj-$(CONFIG_UNIT_TEST) += common/
-obj-$(CONFIG_UNIT_TEST) += lib/
 obj-y += log/
 obj-$(CONFIG_$(SPL_)UT_UNICODE) += unicode_ut.o
 endif
test/lib/Kconfig new file +23 -0
new file mode 100644
index 00000000000..dbb03e4a36f
@@ -0,0 +1,23 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright 2022 Google LLC
+
+if SANDBOX
+
+config TEST_KCONFIG
+	bool "Enable detection of Kconfig macro errors"
+	help
+	  This is used to test that the IF_ENABLED_INT() macro causes a build error
+	  if the value is used when the CONFIG Is not enabled.
+
+config TEST_KCONFIG_ENABLE
+	bool "Option to enable"
+	help
+	  This is the option that controls whether the value is present.
+
+config TEST_KCONFIG_VALUE
+	int "Value associated with the option"
+	depends on TEST_KCONFIG_ENABLE
+	help
+	  This is the value whgch is present if TEST_KCONFIG_ENABLE is enabled.
+
+endif # SANDBOX
test/lib/Makefile +5 -0
index d244bb431d4..7e7922fe3b4 100644
@@ -2,11 +2,13 @@
 #
 # (C) Copyright 2018
 # Mario Six, Guntermann & Drunck GmbH, [email protected]
+ifeq ($(CONFIG_SPL_BUILD),)
 obj-y += cmd_ut_lib.o
 obj-y += abuf.o
 obj-$(CONFIG_EFI_LOADER) += efi_device_path.o
 obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o
 obj-y += hexdump.o
+obj-$(CONFIG_SANDBOX) += kconfig.o
 obj-y += lmb.o
 obj-y += longjmp.o
 obj-$(CONFIG_CONSOLE_RECORD) += test_print.o
@@ -19,3 +21,6 @@ obj-$(CONFIG_UT_LIB_RSA) += rsa.o
 obj-$(CONFIG_AES) += test_aes.o
 obj-$(CONFIG_GETOPT) += getopt.o
 obj-$(CONFIG_UT_LIB_CRYPT) += test_crypt.o
+else
+obj-$(CONFIG_SANDBOX) += kconfig_spl.o
+endif
test/lib/kconfig.c new file +58 -0

58 lines not on this page · raw message

test/lib/kconfig_spl.c new file +44 -0

44 lines not on this page · raw message

test/py/tests/test_kconfig.py new file +34 -0
new file mode 100644
index 00000000000..43ab4824334
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright 2022 Google LLC
+# Written by Simon Glass <[email protected]>
+
+import pytest
+
+import u_boot_utils as util
+
[email protected]
+def test_kconfig(u_boot_console):
+    """Test build failures when IF_ENABLED_INT() option is not enabled"""
+    cons = u_boot_console
+
+    # This detects build errors in test/lib/kconfig.c
+    out = util.run_and_log(
+        cons, ['./tools/buildman/buildman', '--board', 'sandbox',
+               '-a', 'TEST_KCONFIG'], ignore_errors=True)
+    assert 'invalid_use_of_IF_ENABLED_INT' in out
+    assert 'invalid_use_of_CONFIG_IF_ENABLED_INT' in out
+
[email protected]
+def test_kconfig_spl(u_boot_console):
+    """Test build failures when IF_ENABLED_INT() option is not enabled"""
+    cons = u_boot_console
+
+    # This detects build errors in test/lib/kconfig_spl.c
+    out = util.run_and_log(
+        cons, ['./tools/buildman/buildman', '--board', 'sandbox_spl',
+               '-a', 'TEST_KCONFIG'], ignore_errors=True)
+    assert 'invalid_use_of_IF_ENABLED_INT' in out
+
+    # There is no CONFIG_SPL_TEST_KCONFIG, so the CONFIG_IF_ENABLED_INT()
+    # line should not generate an error
+    assert 'invalid_use_of_CONFIG_IF_ENABLED_INT' not in out
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog