[U-Boot] [PATCH v2 0/8] fdt: Allow indicating a node is for U-Boot proper only

Hi,
I create this v2 serie with:
1/ documentation update for previous patch [U-Boot,v2] dm: remove pre reloc properties in SPL and TPL device tree http://patchwork.ozlabs.org/patch/1081155/
PS: Code is already merged in commit commit c7a88dae997f ("dm: remove pre reloc properties in SPL and TPL device tree") but not the documentation.
2/ missing part for (patch 1/2) http://patchwork.ozlabs.org/project/uboot/list/?series=89846
3/ new tests for pre-reloc propertie in SPL as suggested by Simon (http://patchwork.ozlabs.org/patch/1081155/#2156621)
Tell me if is better to split the serie.
Regards Patrick
Changes in v2: - add sandbox_spl_dtb_defconfig for test - solve issue for spl sandbox with dtb - add new option for spl test: show embedded dtb - add a new test option: device tree used for compilation - move all spl test nodes in test dtb - add some test for SPL with device tree - rebase on master
Patrick Delaunay (8): sandbox: add config for SPL boot with devicetree fdt: Allow to use EMBEDDED device tree for SPL sandbox: add option show_of_embedded for spl test test: py: add option to select device tree used during compilation test: move SPL test nodes in test device tree test: check u-boot properties in SPL device tree fdt: Allow indicating a node is for U-Boot proper only dm: doc: add documentation for pre-reloc properties in SPL and TPL
arch/sandbox/cpu/spl.c | 188 +++++++++++++++++++++++++++++++++++ arch/sandbox/cpu/start.c | 9 ++ arch/sandbox/dts/sandbox.dts | 36 ------- arch/sandbox/dts/sandbox64.dts | 36 ------- arch/sandbox/dts/test.dts | 54 +++++++++++ arch/sandbox/include/asm/state.h | 1 + board/sandbox/MAINTAINERS | 1 + configs/sandbox_spl_dtb_defconfig | 199 ++++++++++++++++++++++++++++++++++++++ doc/README.SPL | 16 +++ doc/README.TPL | 4 + doc/driver-model/README.txt | 4 + drivers/core/util.c | 2 + drivers/video/video-uclass.c | 4 +- include/dm/ofnode.h | 6 +- include/dm/util.h | 6 +- lib/fdtdec.c | 6 ++ test/py/conftest.py | 12 ++- test/py/tests/test_ofplatdata.py | 53 ++++++++++ test/run | 8 +- 19 files changed, 566 insertions(+), 79 deletions(-) create mode 100644 configs/sandbox_spl_dtb_defconfig

Creates defconfig sandbox_spl_dtb_defconfig, same than sandbox_spl_defconfig but without CONFIG_SPL_OF_PLATDATA; to allow SPL compilation: - OF_HOSTFILE is changed to OF_EMBED.
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com ---
Changes in v2: - add sandbox_spl_dtb_defconfig for test
board/sandbox/MAINTAINERS | 1 + configs/sandbox_spl_dtb_defconfig | 199 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 configs/sandbox_spl_dtb_defconfig
diff --git a/board/sandbox/MAINTAINERS b/board/sandbox/MAINTAINERS index df29abe..1582a60 100644 --- a/board/sandbox/MAINTAINERS +++ b/board/sandbox/MAINTAINERS @@ -26,6 +26,7 @@ S: Maintained F: board/sandbox/ F: include/configs/sandbox_spl.h F: configs/sandbox_spl_defconfig +F: configs/sandbox_spl_dtb_defconfig
SANDBOX FLAT TREE BOARD M: Simon Glass sjg@chromium.org diff --git a/configs/sandbox_spl_dtb_defconfig b/configs/sandbox_spl_dtb_defconfig new file mode 100644 index 0000000..895af0a --- /dev/null +++ b/configs/sandbox_spl_dtb_defconfig @@ -0,0 +1,199 @@ +CONFIG_SYS_TEXT_BASE=0 +CONFIG_SPL_LIBCOMMON_SUPPORT=y +CONFIG_SPL_LIBGENERIC_SUPPORT=y +CONFIG_SPL_SERIAL_SUPPORT=y +CONFIG_SPL_DRIVERS_MISC_SUPPORT=y +CONFIG_NR_DRAM_BANKS=1 +CONFIG_SPL=y +CONFIG_SANDBOX_SPL=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_FIT_SIGNATURE=y +CONFIG_FIT_VERBOSE=y +CONFIG_SPL_LOAD_FIT=y +CONFIG_BOOTSTAGE=y +CONFIG_BOOTSTAGE_REPORT=y +CONFIG_BOOTSTAGE_FDT=y +CONFIG_BOOTSTAGE_STASH=y +CONFIG_BOOTSTAGE_STASH_ADDR=0x0 +CONFIG_BOOTSTAGE_STASH_SIZE=0x4096 +CONFIG_CONSOLE_RECORD=y +CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000 +CONFIG_SILENT_CONSOLE=y +CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_HANDOFF=y +CONFIG_SPL_BOARD_INIT=y +CONFIG_SPL_ENV_SUPPORT=y +CONFIG_CMD_CPU=y +CONFIG_CMD_LICENSE=y +CONFIG_CMD_BOOTZ=y +# CONFIG_CMD_ELF is not set +CONFIG_CMD_ASKENV=y +CONFIG_CMD_GREPENV=y +CONFIG_CMD_ENV_CALLBACK=y +CONFIG_CMD_ENV_FLAGS=y +CONFIG_LOOPW=y +CONFIG_CMD_MD5SUM=y +CONFIG_CMD_MEMINFO=y +CONFIG_CMD_MEMTEST=y +CONFIG_CMD_MX_CYCLIC=y +CONFIG_CMD_DEMO=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_GPT=y +CONFIG_CMD_IDE=y +CONFIG_CMD_I2C=y +CONFIG_CMD_OSD=y +CONFIG_CMD_PCI=y +CONFIG_CMD_REMOTEPROC=y +CONFIG_CMD_SF=y +CONFIG_CMD_SPI=y +CONFIG_CMD_USB=y +CONFIG_CMD_TFTPPUT=y +CONFIG_CMD_TFTPSRV=y +CONFIG_CMD_RARP=y +CONFIG_CMD_CDP=y +CONFIG_CMD_SNTP=y +CONFIG_CMD_DNS=y +CONFIG_CMD_LINK_LOCAL=y +CONFIG_CMD_BMP=y +CONFIG_CMD_TIME=y +CONFIG_CMD_TIMER=y +CONFIG_CMD_SOUND=y +CONFIG_CMD_QFW=y +CONFIG_CMD_BOOTSTAGE=y +CONFIG_CMD_PMIC=y +CONFIG_CMD_REGULATOR=y +CONFIG_CMD_TPM=y +CONFIG_CMD_TPM_TEST=y +CONFIG_CMD_CBFS=y +CONFIG_CMD_CRAMFS=y +CONFIG_CMD_EXT4_WRITE=y +CONFIG_MAC_PARTITION=y +CONFIG_AMIGA_PARTITION=y +CONFIG_OF_CONTROL=y +CONFIG_SPL_OF_CONTROL=y +CONFIG_OF_EMBED=y +CONFIG_DEFAULT_DEVICE_TREE="sandbox" +CONFIG_NETCONSOLE=y +CONFIG_SPL_DM=y +CONFIG_REGMAP=y +CONFIG_SPL_REGMAP=y +CONFIG_SYSCON=y +CONFIG_SPL_SYSCON=y +CONFIG_DEVRES=y +CONFIG_DEBUG_DEVRES=y +# CONFIG_SPL_SIMPLE_BUS is not set +CONFIG_ADC=y +CONFIG_ADC_SANDBOX=y +CONFIG_CLK=y +CONFIG_CPU=y +CONFIG_DM_DEMO=y +CONFIG_DM_DEMO_SIMPLE=y +CONFIG_DM_DEMO_SHAPE=y +CONFIG_BOARD=y +CONFIG_BOARD_SANDBOX=y +CONFIG_PM8916_GPIO=y +CONFIG_SANDBOX_GPIO=y +CONFIG_DM_I2C_COMPAT=y +CONFIG_I2C_CROS_EC_TUNNEL=y +CONFIG_I2C_CROS_EC_LDO=y +CONFIG_DM_I2C_GPIO=y +CONFIG_SYS_I2C_SANDBOX=y +CONFIG_I2C_MUX=y +CONFIG_SPL_I2C_MUX=y +CONFIG_I2C_ARB_GPIO_CHALLENGE=y +CONFIG_CROS_EC_KEYB=y +CONFIG_I8042_KEYB=y +CONFIG_LED=y +CONFIG_LED_BLINK=y +CONFIG_LED_GPIO=y +CONFIG_DM_MAILBOX=y +CONFIG_SANDBOX_MBOX=y +CONFIG_MISC=y +CONFIG_CROS_EC=y +CONFIG_CROS_EC_I2C=y +CONFIG_CROS_EC_LPC=y +CONFIG_CROS_EC_SANDBOX=y +CONFIG_CROS_EC_SPI=y +CONFIG_PWRSEQ=y +CONFIG_SPL_PWRSEQ=y +CONFIG_MMC_SANDBOX=y +CONFIG_SPI_FLASH_SANDBOX=y +CONFIG_SPI_FLASH=y +CONFIG_SPI_FLASH_ATMEL=y +CONFIG_SPI_FLASH_EON=y +CONFIG_SPI_FLASH_GIGADEVICE=y +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_SPI_FLASH_SPANSION=y +CONFIG_SPI_FLASH_STMICRO=y +CONFIG_SPI_FLASH_SST=y +CONFIG_SPI_FLASH_WINBOND=y +CONFIG_DM_ETH=y +CONFIG_NVME=y +CONFIG_PCI=y +CONFIG_DM_PCI=y +CONFIG_DM_PCI_COMPAT=y +CONFIG_PCI_SANDBOX=y +CONFIG_PHY=y +CONFIG_PHY_SANDBOX=y +CONFIG_PINCTRL=y +CONFIG_PINCONF=y +CONFIG_PINCTRL_SANDBOX=y +CONFIG_DM_PMIC=y +CONFIG_PMIC_ACT8846=y +CONFIG_DM_PMIC_PFUZE100=y +CONFIG_DM_PMIC_MAX77686=y +CONFIG_DM_PMIC_MC34708=y +CONFIG_PMIC_PM8916=y +CONFIG_PMIC_RK8XX=y +CONFIG_PMIC_S2MPS11=y +CONFIG_DM_PMIC_SANDBOX=y +CONFIG_PMIC_S5M8767=y +CONFIG_PMIC_TPS65090=y +CONFIG_DM_REGULATOR=y +CONFIG_REGULATOR_ACT8846=y +CONFIG_DM_REGULATOR_PFUZE100=y +CONFIG_DM_REGULATOR_MAX77686=y +CONFIG_DM_REGULATOR_FIXED=y +CONFIG_REGULATOR_RK8XX=y +CONFIG_REGULATOR_S5M8767=y +CONFIG_DM_REGULATOR_SANDBOX=y +CONFIG_REGULATOR_TPS65090=y +CONFIG_DM_PWM=y +CONFIG_PWM_SANDBOX=y +CONFIG_RAM=y +CONFIG_REMOTEPROC_SANDBOX=y +CONFIG_DM_RESET=y +CONFIG_SANDBOX_RESET=y +CONFIG_DM_RTC=y +CONFIG_SANDBOX_SERIAL=y +CONFIG_SOUND=y +CONFIG_SOUND_SANDBOX=y +CONFIG_SANDBOX_SPI=y +CONFIG_SPMI=y +CONFIG_SPMI_SANDBOX=y +CONFIG_SYSRESET=y +CONFIG_SPL_SYSRESET=y +CONFIG_TIMER=y +CONFIG_TIMER_EARLY=y +CONFIG_SANDBOX_TIMER=y +CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_USB_EMUL=y +CONFIG_USB_KEYBOARD=y +CONFIG_DM_VIDEO=y +CONFIG_CONSOLE_ROTATION=y +CONFIG_CONSOLE_TRUETYPE=y +CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y +CONFIG_VIDEO_SANDBOX_SDL=y +CONFIG_OSD=y +CONFIG_SANDBOX_OSD=y +CONFIG_FS_CBFS=y +CONFIG_FS_CRAMFS=y +CONFIG_CMD_DHRYSTONE=y +CONFIG_TPM=y +CONFIG_LZ4=y +CONFIG_ERRNO_STR=y +CONFIG_UNIT_TEST=y +CONFIG_UT_TIME=y +CONFIG_UT_DM=y

Hi Patrick,
On Mon, 20 May 2019 at 07:00, Patrick Delaunay patrick.delaunay@st.com wrote:
Creates defconfig sandbox_spl_dtb_defconfig, same than sandbox_spl_defconfig but without CONFIG_SPL_OF_PLATDATA; to allow SPL compilation:
- OF_HOSTFILE is changed to OF_EMBED.
What is this for? Each patch should have a motivation.
Is there are cover-letter for this series?
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com
Changes in v2:
- add sandbox_spl_dtb_defconfig for test
board/sandbox/MAINTAINERS | 1 + configs/sandbox_spl_dtb_defconfig | 199 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 configs/sandbox_spl_dtb_defconfig
Regards, Simon

U-boot continue to use load DT from file system, this patch avoid an error when U-Boot "Error: Out of memory" when it try to map gd->fdt_blob (EMBEDDED pointer __dtb_dt_begin is not managed).
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com ---
Changes in v2: - solve issue for spl sandbox with dtb
lib/fdtdec.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index fea44a9..d25cfd6 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1491,6 +1491,12 @@ int fdtdec_setup(void) gd->fdt_blob = __dtb_dt_spl_begin; # else gd->fdt_blob = __dtb_dt_begin; +#ifdef CONFIG_SANDBOX + if (sandbox_read_fdt_from_file()) { + puts("Failed to read control FDT\n"); + return -1; + } +#endif # endif # elif defined(CONFIG_OF_BOARD) || defined(CONFIG_OF_SEPARATE) /* Allow the board to override the fdt address. */

Hi Patrick,
On Mon, 20 May 2019 at 07:00, Patrick Delaunay patrick.delaunay@st.com wrote:
U-boot continue to use load DT from file system, this patch avoid
U-Boot
an error when U-Boot "Error: Out of memory" when it try to map gd->fdt_blob (EMBEDDED pointer __dtb_dt_begin is not managed).
What is EMBEDDED? Do you mean CONFIG_OF_EMBED?
I don't think we should be using OF_EMBED for sandbox.
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com
Changes in v2:
- solve issue for spl sandbox with dtb
lib/fdtdec.c | 6 ++++++ 1 file changed, 6 insertions(+)
Regards, Simon

Add an option show_of_embedded used in SPL to dump the used device tree.
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com ---
Changes in v2: - add new option for spl test: show embedded dtb
arch/sandbox/cpu/spl.c | 188 +++++++++++++++++++++++++++++++++++++++ arch/sandbox/cpu/start.c | 9 ++ arch/sandbox/include/asm/state.h | 1 + 3 files changed, 198 insertions(+)
diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c index 2ca4cd6..d3d9b08 100644 --- a/arch/sandbox/cpu/spl.c +++ b/arch/sandbox/cpu/spl.c @@ -46,6 +46,190 @@ static int spl_board_load_image(struct spl_image_info *spl_image, } SPL_LOAD_IMAGE_METHOD("sandbox", 0, BOOT_DEVICE_BOARD, spl_board_load_image);
+#ifdef CONFIG_OF_EMBED +/****************************************************************************/ +/* the next functions mainly copyied from cmd fdt for SPL sandbox test */ + +#include <linux/ctype.h> + +#define CMD_FDT_MAX_DUMP 64 +#define MAX_LEVEL 32 /* how deeply nested we will go */ + +/* + * Heuristic to guess if this is a string or concatenated strings. + */ + +static int is_printable_string(const void *data, int len) +{ + const char *s = data; + + /* zero length is not */ + if (len == 0) + return 0; + + /* must terminate with zero or '\n' */ + if (s[len - 1] != '\0' && s[len - 1] != '\n') + return 0; + + /* printable or a null byte (concatenated strings) */ + while (((*s == '\0') || isprint(*s) || isspace(*s)) && (len > 0)) { + /* + * If we see a null, there are three possibilities: + * 1) If len == 1, it is the end of the string, printable + * 2) Next character also a null, not printable. + * 3) Next character not a null, continue to check. + */ + if (s[0] == '\0') { + if (len == 1) + return 1; + if (s[1] == '\0') + return 0; + } + s++; + len--; + } + + /* Not the null termination, or not done yet: not printable */ + if (*s != '\0' || len != 0) + return 0; + + return 1; +} + +/* + * Print the property in the best format, a heuristic guess. Print as + * a string, concatenated strings, a byte, word, double word, or (if all + * else fails) it is printed as a stream of bytes. + */ +static void print_data(const void *data, int len) +{ + int j; + + /* no data, don't print */ + if (len == 0) + return; + + /* + * It is a string, but it may have multiple strings (embedded '\0's). + */ + if (is_printable_string(data, len)) { + puts("""); + j = 0; + while (j < len) { + if (j > 0) + puts("", ""); + puts(data); + j += strlen(data) + 1; + data += strlen(data) + 1; + } + puts("""); + return; + } + + if ((len % 4) == 0) { + if (len > CMD_FDT_MAX_DUMP) { + printf("* 0x%p [0x%08x]", data, len); + } else { + const __be32 *p; + + printf("<"); + for (j = 0, p = data; j < len / 4; j++) + printf("0x%08x%s", fdt32_to_cpu(p[j]), + j < (len / 4 - 1) ? " " : ""); + printf(">"); + } + } else { /* anything else... hexdump */ + if (len > CMD_FDT_MAX_DUMP) { + printf("* 0x%p [0x%08x]", data, len); + } else { + const u8 *s; + + printf("["); + for (j = 0, s = data; j < len; j++) + printf("%02x%s", s[j], j < len - 1 ? " " : ""); + printf("]"); + } + } +} + +/* + * Recursively print the working_fdt. + */ +static int fdt_print(const struct fdt_header *working_fdt) +{ + static char tabs[MAX_LEVEL + 1] = + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; + const void *nodep; /* property node pointer */ + int nodeoffset = 0; /* node offset from libfdt */ + int nextoffset; /* next node offset from libfdt */ + u32 tag; /* tag */ + int len; /* length of the property */ + int level = 0; /* keep track of nesting level */ + const struct fdt_property *fdt_prop; + const char *pathp; + + /* print the node and all subnodes. */ + while (level >= 0) { + tag = fdt_next_tag(working_fdt, nodeoffset, &nextoffset); + switch (tag) { + case FDT_BEGIN_NODE: + pathp = fdt_get_name(working_fdt, nodeoffset, NULL); + if (!pathp) + pathp = "/* NULL pointer error */"; + if (*pathp == '\0') + pathp = "/"; /* root is nameless */ + printf("%s%s {\n", + &tabs[MAX_LEVEL - level], pathp); + level++; + break; + case FDT_END_NODE: + level--; + printf("%s};\n", &tabs[MAX_LEVEL - level]); + if (level == 0) + level = -1; /* exit the loop */ + break; + case FDT_PROP: + fdt_prop = fdt_offset_ptr(working_fdt, nodeoffset, + sizeof(*fdt_prop)); + pathp = fdt_string(working_fdt, + fdt32_to_cpu(fdt_prop->nameoff)); + len = fdt32_to_cpu(fdt_prop->len); + nodep = fdt_prop->data; + if (len < 0) { + printf("libfdt fdt_getprop(): %s\n", + fdt_strerror(len)); + return 1; + } else if (len == 0) { + /* the property has no value */ + printf("%s%s;\n", + &tabs[MAX_LEVEL - level], + pathp); + } else { + printf("%s%s = ", + &tabs[MAX_LEVEL - level], + pathp); + print_data(nodep, len); + printf(";\n"); + } + break; + case FDT_NOP: + printf("%s/* NOP */\n", &tabs[MAX_LEVEL - level]); + break; + case FDT_END: + return 1; + default: + return 1; + } + nodeoffset = nextoffset; + } + + return 0; +} + +/***************************************************************************/ +#endif + void spl_board_init(void) { struct sandbox_state *state = state_get_current(); @@ -63,6 +247,10 @@ void spl_board_init(void) uclass_next_device(&dev)) ; } +#ifdef CONFIG_OF_EMBED + if (state->show_of_embedded) + fdt_print(gd->fdt_blob); +#endif }
void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 82828f0..8116e3c 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -293,6 +293,15 @@ static int sandbox_cmdline_cb_show_of_platdata(struct sandbox_state *state, } SANDBOX_CMDLINE_OPT(show_of_platdata, 0, "Show of-platdata in SPL");
+static int sandbox_cmdline_cb_show_of_embedded(struct sandbox_state *state, + const char *arg) +{ + state->show_of_embedded = true; + + return 0; +} +SANDBOX_CMDLINE_OPT(show_of_embedded, 0, "Show of-embedded in SPL"); + int board_run_command(const char *cmdline) { printf("## Commands are disabled. Please enable CONFIG_CMDLINE.\n"); diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 2d773d3..c8142c8 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -90,6 +90,7 @@ struct sandbox_state { bool show_test_output; /* Don't suppress stdout in tests */ int default_log_level; /* Default log level for sandbox */ bool show_of_platdata; /* Show of-platdata in SPL */ + bool show_of_embedded; /* Show of-embedded in SPL */ bool ram_buf_read; /* true if we read the RAM buffer */
/* Pointer to information for each SPI bus/cs */

Hi Patrick,
On Mon, 20 May 2019 at 07:00, Patrick Delaunay patrick.delaunay@st.com wrote:
Add an option show_of_embedded used in SPL to dump the used device tree.
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com
Changes in v2:
- add new option for spl test: show embedded dtb
arch/sandbox/cpu/spl.c | 188 +++++++++++++++++++++++++++++++++++++++ arch/sandbox/cpu/start.c | 9 ++ arch/sandbox/include/asm/state.h | 1 + 3 files changed, 198 insertions(+)
Why not use fdtdump on spl/u-boot-spl.dtb ?
Failing that, can we use the existing code for printing a DT?
Regards, Simon

Only used for spl compilation which include the device tree (with platdata or embedded device tree). For U-boot, test use config.dtb, by default : "build_dir + '/arch/sandbox/dts/test.dtb'"
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com --- I need to force o_dt = 'all' to avoid make error:
make: *** empty string invalid as file name. Stop.
But, I don't sure that it is the better solution for pytest.
Changes in v2: - add a new test option: device tree used for compilation
test/py/conftest.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/test/py/conftest.py b/test/py/conftest.py index 00d8ef8..c1fe2a8 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -74,6 +74,8 @@ def pytest_addoption(parser): help='U-Boot board identity/instance') parser.addoption('--build', default=False, action='store_true', help='Compile U-Boot before running tests') + parser.addoption('--device-tree', default=None, + help='Device tree used to compile U-Boot') parser.addoption('--gdbserver', default=None, help='Run sandbox under gdbserver. The argument is the channel '+ 'over which gdbserver should communicate, e.g. localhost:1234') @@ -101,6 +103,8 @@ def pytest_configure(config): board_identity = config.getoption('board_identity') board_identity_filename = board_identity.replace('-', '_')
+ device_tree = config.getoption('device_tree') + build_dir = config.getoption('build_dir') if not build_dir: build_dir = source_dir + '/build-' + board_type @@ -128,9 +132,15 @@ def pytest_configure(config): o_opt = 'O=%s' % build_dir else: o_opt = '' + + if device_tree: + o_dt = 'DEVICE_TREE=%s' % device_tree + else: + o_dt = 'all' + cmds = ( ['make', o_opt, '-s', board_type + '_defconfig'], - ['make', o_opt, '-s', '-j8'], + ['make', o_opt, o_dt, '-s', '-j8'], ) with log.section('make'): runner = log.get_runner('make', sys.stdout)

On 5/20/19 7:00 AM, Patrick Delaunay wrote:
Only used for spl compilation which include the device tree (with platdata or embedded device tree). For U-boot, test use config.dtb, by default : "build_dir + '/arch/sandbox/dts/test.dtb'"
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com
I need to force o_dt = 'all' to avoid make error:
make: *** empty string invalid as file name. Stop.
But, I don't sure that it is the better solution for pytest.
This feels a bit odd. What board are you compiling for? I would expect the same compilation commands to "just work" for all boards, and would initially claim that if they don't, it's a bug in the makefiles that should be fixed there.
diff --git a/test/py/conftest.py b/test/py/conftest.py
if device_tree:
o_dt = 'DEVICE_TREE=%s' % device_tree
else:
o_dt = 'all'
You might want to make o_dt be a list that's either empty or contains one string. Then ...
cmds = ( ['make', o_opt, '-s', board_type + '_defconfig'],
['make', o_opt, '-s', '-j8'],
['make', o_opt, o_dt, '-s', '-j8'], )
... you can modify that line so that it doesn't add any additional options if o_dt is empty, so there's no change to the command-line except in the case where a DT is specified, to avoid the potential for any change to the existing flow:
['make', o_opt, *o_dt, '-s', '-j8'],
or:
['make', o_opt, '-s', '-j8'] + o_dt,

Hi Stephen,
For information after the remarksSimon's remark, I simplify the test, so this part is no more needed See http://patchwork.ozlabs.org/patch/1102938/
But I will answer with my status and my tests done on the python code.
On 5/20/19 7:00 AM, Patrick Delaunay wrote:
Only used for spl compilation which include the device tree (with platdata or embedded device tree). For U-boot, test use config.dtb, by default : "build_dir + '/arch/sandbox/dts/test.dtb'"
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com
I need to force o_dt = 'all' to avoid make error:
make: *** empty string invalid as file name. Stop.
But, I don't sure that it is the better solution for pytest.
This feels a bit odd. What board are you compiling for? I would expect the same compilation commands to "just work" for all boards, and would initially claim that if they don't, it's a bug in the makefiles that should be fixed there.
Yes, it is strange.
When I compile the board I have not the problem, I have issue only when I use pytest.
For example:
./test/py/test.py --bd sandbox_spl --build --device-tree sandbox -k 'test_000_version' +make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox_spl -s sandbox_spl_defconfig +make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox_spl DEVICE_TREE=sandbox -s -j8
=> it tis OK
./test/py/test.py --bd sandbox --build -k 'test_000_version' +make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox -s sandbox_defconfig +make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox all -s -j8
=> it is OK
But if I use =
if build_dir != source_dir: o_opt = 'O=%s' % build_dir else: o_opt = 'all'
if device_tree: o_dt = 'DEVICE_TREE=%s' % device_tree else: o_dt = ''
Same result for the first command : ./test/py/test.py --bd sandbox --build -k 'test_000_version' => it is OK
But the second command I have got the next error:
./test/py/test.py --bd sandbox --build -k 'test_000_version' +make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox -s sandbox_defconfig +make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox -s -j8 make: *** empty string invalid as file name. Stop. Exit code: 2 INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "/usr/lib/python2.7/dist-packages/_pytest/main.py", line 86, in wrap_session INTERNALERROR> config._do_configure() INTERNALERROR> File "/usr/lib/python2.7/dist-packages/_pytest/config.py", line 830, in _do_configure INTERNALERROR> self.hook.pytest_configure.call_historic(kwargs=dict(config=self)) INTERNALERROR> File "/usr/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 729, in call_historic INTERNALERROR> self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) INTERNALERROR> File "/usr/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) INTERNALERROR> File "/usr/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda> INTERNALERROR> _MultiCall(methods, kwargs, hook.spec_opts).execute() INTERNALERROR> File "/usr/lib/python2.7/dist-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> File "/local/home/frq07632/views/u-boot/u-boot/test/py/conftest.py", line 148, in pytest_configure INTERNALERROR> runner.run(cmd, cwd=source_dir) INTERNALERROR> File "/local/home/frq07632/views/u-boot/u-boot/test/py/multiplexed_log.py", line 173, in run INTERNALERROR> raise exception INTERNALERROR> Exception: Exit code: 2
Moreover when I execute the command manually (without python), the compilation is accepted....
$> make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox -s sandbox_defconfig $> make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox -s -j8
I also try:
options = [] if build_dir != source_dir: options.append('O=%s ' % build_dir) if device_tree: options.append('DEVICE_TREE=%s ' % device_tree) o_opt = ' '.join(options)
cmds = ( ['make', o_opt, '-s', board_type + '_defconfig'], ['make', o_opt, '-s', '-j8'], )
Then the o_opt is correctly build but the DEVICE_TREE option is not used when the build is requested by python(it is done manually)
make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox_spl DEVICE_TREE=bad -s -j8
Device Tree Source is not correctly specified. Please define 'CONFIG_DEFAULT_DEVICE_TREE' or build with 'DEVICE_TREE=<device_tree>' argument
./test/py/test.py --bd sandbox_spl --build --device-tree bad -k 'test_000_version'
=> no error !
diff --git a/test/py/conftest.py b/test/py/conftest.py
if device_tree:
o_dt = 'DEVICE_TREE=%s' % device_tree
else:
o_dt = 'all'
You might want to make o_dt be a list that's either empty or contains one string. Then ...
cmds = ( ['make', o_opt, '-s', board_type + '_defconfig'],
['make', o_opt, '-s', '-j8'],
['make', o_opt, o_dt, '-s', '-j8'], )
... you can modify that line so that it doesn't add any additional options if o_dt is empty, so there's no change to the command-line except in the case where a DT is specified, to avoid the potential for any change to the existing flow:
['make', o_opt, *o_dt, '-s', '-j8'],
Not OK for my setup :
./test/py/test.py --bd sandbox_spl --build --device-tree sandbox -k 'test_000_version'
Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/_pytest/config.py", line 319, in _importconftest mod = conftestpath.pyimport() File "/usr/lib/python2.7/dist-packages/py/_path/local.py", line 650, in pyimport __import__(modname) File "/local/home/frq07632/views/u-boot/u-boot/test/py/conftest.py", line 143 ['make', o_opt, *o_dt, '-s', '-j8'], ^ SyntaxError: invalid syntax ERROR: could not load /local/home/frq07632/views/u-boot/u-boot/test/py/conftest.py
or:
['make', o_opt, '-s', '-j8'] + o_dt,
Also invalid (mising list and string.
So I am lost with my poor level of python.....
The only working test is :
if config.getoption('build'): if build_dir != source_dir: o_opt = 'O=%s' % build_dir else: o_opt = ''
cmds = ( ['make', o_opt, '-s', board_type + '_defconfig'], ['make', o_opt, '-s', '-j8'], ) if device_tree: cmds[1].append('DEVICE_TREE=%s' % device_tree)
So command with 'empty' string in cmds list for "make" cause the error ?
Anyway this patch is dropped in v3, I don't investigate more.
Regards
Patrick

On 5/21/19 12:32 PM, Patrick DELAUNAY wrote:
Hi Stephen,
For information after the remarksSimon's remark, I simplify the test, so this part is no more needed See http://patchwork.ozlabs.org/patch/1102938/
But I will answer with my status and my tests done on the python code.
On 5/20/19 7:00 AM, Patrick Delaunay wrote:
Only used for spl compilation which include the device tree (with platdata or embedded device tree). For U-boot, test use config.dtb, by default : "build_dir + '/arch/sandbox/dts/test.dtb'"
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com
I need to force o_dt = 'all' to avoid make error:
make: *** empty string invalid as file name. Stop.
But, I don't sure that it is the better solution for pytest.
This feels a bit odd. What board are you compiling for? I would expect the same compilation commands to "just work" for all boards, and would initially claim that if they don't, it's a bug in the makefiles that should be fixed there.
Yes, it is strange.
When I compile the board I have not the problem, I have issue only when I use pytest.
...
But if I use =
...
if device_tree: o_dt = 'DEVICE_TREE=%s' % device_tree else: o_dt = ''
...
But the second command I have got the next error:
./test/py/test.py --bd sandbox --build -k 'test_000_version' +make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox -s sandbox_defconfig +make O=/local/home/frq07632/views/u-boot/u-boot/build-sandbox -s -j8 make: *** empty string invalid as file name. Stop.
Right, o_dt is '' so there's an extra zero-length parameter between the "O=" and "-s" argument in that last command, which is what the error message complains about.
But this is all with your patch applied. I still don't understand what issue this was trying to solve in the first place, i.e. what is/was wrong with u-boot.git's master branch. I can run test/py for both sandbox and sandbox_spl with unmodified u-boot.git master branch; see logs below. Is there still some bug I need to fix, that exists without your patch series?
[swarren@swarren-lx1 u-boot]$ ./test/py/test.py --bd sandbox --build -k test_000_version +make O=/home/swarren/shared/git_wa/tegra-uboot-flasher/u-boot/build-sandbox -s sandbox_defconfig +make O=/home/swarren/shared/git_wa/tegra-uboot-flasher/u-boot/build-sandbox -s -j8 ============================= test session starts ============================== platform linux2 -- Python 2.7.12, pytest-2.8.7, py-1.4.31, pluggy-0.3.1 rootdir: /home/swarren/shared/git_wa/tegra-uboot-flasher/u-boot, inifile: collected 503 items
test/py/tests/test_000_version.py .
================= 502 tests deselected by '-ktest_000_version' ================= =================== 1 passed, 502 deselected in 0.17 seconds ===================
[swarren@swarren-lx1 u-boot]$ ./test/py/test.py --bd sandbox_spl --build -k test_000_version +make O=/home/swarren/shared/git_wa/tegra-uboot-flasher/u-boot/build-sandbox_spl -s sandbox_spl_defconfig +make O=/home/swarren/shared/git_wa/tegra-uboot-flasher/u-boot/build-sandbox_spl -s -j8 ============================= test session starts ============================== platform linux2 -- Python 2.7.12, pytest-2.8.7, py-1.4.31, pluggy-0.3.1 rootdir: /home/swarren/shared/git_wa/tegra-uboot-flasher/u-boot, inifile: collected 492 items
test/py/tests/test_000_version.py .
================= 491 tests deselected by '-ktest_000_version' ================= =================== 1 passed, 491 deselected in 0.31 seconds ===================

Moves spl-test nodes in test device tree, selected by the new build option '--device-tree'.
This patch also executes the version test (test_000_version) to check the correct start of the U-Boot after SPL execution.
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com ---
Changes in v2: - move all spl test nodes in test dtb
arch/sandbox/dts/sandbox.dts | 36 ------------------------------------ arch/sandbox/dts/sandbox64.dts | 36 ------------------------------------ arch/sandbox/dts/test.dts | 36 ++++++++++++++++++++++++++++++++++++ test/run | 3 ++- 4 files changed, 38 insertions(+), 73 deletions(-)
diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts index a41b5f0..b5bc27b 100644 --- a/arch/sandbox/dts/sandbox.dts +++ b/arch/sandbox/dts/sandbox.dts @@ -225,42 +225,6 @@ }; };
- spl-test { - u-boot,dm-pre-reloc; - compatible = "sandbox,spl-test"; - boolval; - intval = <1>; - intarray = <2 3 4>; - byteval = [05]; - bytearray = [06]; - longbytearray = [09 0a 0b 0c 0d 0e 0f 10 11]; - stringval = "message"; - stringarray = "multi-word", "message"; - }; - - spl-test2 { - u-boot,dm-pre-reloc; - compatible = "sandbox,spl-test"; - intval = <3>; - intarray = <5>; - byteval = [08]; - bytearray = [01 23 34]; - longbytearray = [09 0a 0b 0c]; - stringval = "message2"; - stringarray = "another", "multi-word", "message"; - }; - - spl-test3 { - u-boot,dm-pre-reloc; - compatible = "sandbox,spl-test"; - stringarray = "one"; - }; - - spl-test4 { - u-boot,dm-pre-reloc; - compatible = "sandbox,spl-test.2"; - }; - square { compatible = "demo-shape"; colour = "blue"; diff --git a/arch/sandbox/dts/sandbox64.dts b/arch/sandbox/dts/sandbox64.dts index a3c95f2..766d020 100644 --- a/arch/sandbox/dts/sandbox64.dts +++ b/arch/sandbox/dts/sandbox64.dts @@ -190,42 +190,6 @@ }; };
- spl-test { - u-boot,dm-pre-reloc; - compatible = "sandbox,spl-test"; - boolval; - intval = <1>; - intarray = <2 3 4>; - byteval = [05]; - bytearray = [06]; - longbytearray = [09 0a 0b 0c 0d 0e 0f 10 11]; - stringval = "message"; - stringarray = "multi-word", "message"; - }; - - spl-test2 { - u-boot,dm-pre-reloc; - compatible = "sandbox,spl-test"; - intval = <3>; - intarray = <5>; - byteval = [08]; - bytearray = [01 23 34]; - longbytearray = [09 0a 0b 0c]; - stringval = "message2"; - stringarray = "another", "multi-word", "message"; - }; - - spl-test3 { - u-boot,dm-pre-reloc; - compatible = "sandbox,spl-test"; - stringarray = "one"; - }; - - spl-test4 { - u-boot,dm-pre-reloc; - compatible = "sandbox,spl-test.2"; - }; - square { compatible = "demo-shape"; colour = "blue"; diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 8b2d645..1ac86d7 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -585,6 +585,42 @@ }; };
+ spl-test { + u-boot,dm-pre-reloc; + compatible = "sandbox,spl-test"; + boolval; + intval = <1>; + intarray = <2 3 4>; + byteval = [05]; + bytearray = [06]; + longbytearray = [09 0a 0b 0c 0d 0e 0f 10 11]; + stringval = "message"; + stringarray = "multi-word", "message"; + }; + + spl-test2 { + u-boot,dm-pre-reloc; + compatible = "sandbox,spl-test"; + intval = <3>; + intarray = <5>; + byteval = [08]; + bytearray = [01 23 34]; + longbytearray = [09 0a 0b 0c]; + stringval = "message2"; + stringarray = "another", "multi-word", "message"; + }; + + spl-test3 { + u-boot,dm-pre-reloc; + compatible = "sandbox,spl-test"; + stringarray = "one"; + }; + + spl-test4 { + u-boot,dm-pre-reloc; + compatible = "sandbox,spl-test.2"; + }; + syscon0: syscon@0 { compatible = "sandbox,syscon0"; reg = <0x10 16>; diff --git a/test/run b/test/run index 55a6649..5aceed7 100755 --- a/test/run +++ b/test/run @@ -23,7 +23,8 @@ run_test "sandbox" ./test/py/test.py --bd sandbox --build -m "${mark_expr}"
# Run tests which require sandbox_spl run_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \ - -k 'test_ofplatdata or test_handoff' + --device-tree test \ + -k 'test_000_version or test_ofplatdata or test_handoff'
# Run tests for the flat-device-tree version of sandbox. This is a special # build which does not enable CONFIG_OF_LIVE for the live device tree, so we can

Hi Patrick.
On Mon, 20 May 2019 at 07:00, Patrick Delaunay patrick.delaunay@st.com wrote:
Moves spl-test nodes in test device tree, selected by the new build option '--device-tree'.
Where is this build option?
This patch also executes the version test (test_000_version) to check the correct start of the U-Boot after SPL execution.
What is test_000_version?
Again this patch needs motivation. It is very hard for me to understand what you are trying to do.
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com
Changes in v2:
- move all spl test nodes in test dtb
arch/sandbox/dts/sandbox.dts | 36 ------------------------------------ arch/sandbox/dts/sandbox64.dts | 36 ------------------------------------ arch/sandbox/dts/test.dts | 36 ++++++++++++++++++++++++++++++++++++ test/run | 3 ++- 4 files changed, 38 insertions(+), 73 deletions(-)
Can you please check this series which creates a comment DT:
http://patchwork.ozlabs.org/project/uboot/list/?series=108546
Could you rebase on top of it? - u-boot-dm/sandbox-working
Regards, Simon

Add a test to check the management of the u-boot relocation properties (fdtgrep result) for platdata generation or device tree SPL generation: - 'dm-pre-proper' and 'dm-tpl' not included in SPL - 'dm-pre-reloc' and 'dm-spl' included in SPL
This patch also executes the version test (test_000_version) to check the correct start of the U-Boot after SPL execution.
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com ---
Changes in v2: - add some test for SPL with device tree
arch/sandbox/dts/test.dts | 18 ++++++++++++++ test/py/tests/test_ofplatdata.py | 53 ++++++++++++++++++++++++++++++++++++++++ test/run | 5 ++++ 3 files changed, 76 insertions(+)
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 1ac86d7..2d5bea3 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -621,6 +621,24 @@ compatible = "sandbox,spl-test.2"; };
+ spl-test5 { + u-boot,dm-tpl; + compatible = "sandbox,spl-test"; + stringarray = "tpl"; + }; + + spl-test6 { + u-boot,dm-pre-proper; + compatible = "sandbox,spl-test"; + stringarray = "pre-proper"; + }; + + spl-test7 { + u-boot,dm-spl; + compatible = "sandbox,spl-test"; + stringarray = "spl"; + }; + syscon0: syscon@0 { compatible = "sandbox,syscon0"; reg = <0x10 16>; diff --git a/test/py/tests/test_ofplatdata.py b/test/py/tests/test_ofplatdata.py index 98103ee..bdabc5a 100644 --- a/test/py/tests/test_ofplatdata.py +++ b/test/py/tests/test_ofplatdata.py @@ -31,6 +31,50 @@ intarray 0 0 0 0 longbytearray 00 00 00 00 00 00 00 00 00 string <NULL> stringarray "one" "" "" +of-platdata probe: +bool 0 +byte 00 +bytearray 00 00 00 +int 0 +intarray 0 0 0 0 +longbytearray 00 00 00 00 00 00 00 00 00 +string <NULL> +stringarray "spl" "" "" +''' + +OF_EMBEDDED_OUTPUT = ''' + spl-test { + compatible = "sandbox,spl-test"; + boolval; + intval = <0x00000001>; + intarray = <0x00000002 0x00000003 0x00000004>; + byteval = [05]; + bytearray = [06]; + longbytearray = [09 0a 0b 0c 0d 0e 0f 10 11]; + stringval = "message"; + stringarray = "multi-word", "message"; + }; + spl-test2 { + compatible = "sandbox,spl-test"; + intval = <0x00000003>; + intarray = <0x00000005>; + byteval = [08]; + bytearray = [01 23 34]; + longbytearray = <0x090a0b0c>; + stringval = "message2"; + stringarray = "another", "multi-word", "message"; + }; + spl-test3 { + compatible = "sandbox,spl-test"; + stringarray = "one"; + }; + spl-test4 { + compatible = "sandbox,spl-test.2"; + }; + spl-test7 { + compatible = "sandbox,spl-test"; + stringarray = "spl"; + }; '''
@pytest.mark.buildconfigspec('spl_of_platdata') @@ -40,3 +84,12 @@ def test_ofplatdata(u_boot_console): cons.restart_uboot_with_flags(['--show_of_platdata']) output = cons.get_spawn_output().replace('\r', '') assert OF_PLATDATA_OUTPUT in output + +@pytest.mark.buildconfigspec('of_embed') +@pytest.mark.buildconfigspec('spl_of_libfdt') +def test_ofembed(u_boot_console): + """Test that device-tree can be generated and used in sandbox spl""" + cons = u_boot_console + cons.restart_uboot_with_flags(['--show_of_embedded']) + output = cons.get_spawn_output().replace('\r', '') + assert OF_EMBEDDED_OUTPUT in output diff --git a/test/run b/test/run index 5aceed7..4702c4d 100755 --- a/test/run +++ b/test/run @@ -26,6 +26,11 @@ run_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \ --device-tree test \ -k 'test_000_version or test_ofplatdata or test_handoff'
+# Run tests which require sandbox_spl_dtb , with test.dtb device tree +run_test "sandbox_spl_dtb" ./test/py/test.py --bd sandbox_spl_dtb --build \ + --device-tree test \ + -k 'test_000_version or test_ofplatdata' + # Run tests for the flat-device-tree version of sandbox. This is a special # build which does not enable CONFIG_OF_LIVE for the live device tree, so we can # check that functionality is the same. The standard sandbox build (above) uses

Hi Patrick,
On Mon, 20 May 2019 at 07:00, Patrick Delaunay patrick.delaunay@st.com wrote:
Add a test to check the management of the u-boot relocation properties (fdtgrep result) for platdata generation or device tree SPL generation:
- 'dm-pre-proper' and 'dm-tpl' not included in SPL
- 'dm-pre-reloc' and 'dm-spl' included in SPL
This patch also executes the version test (test_000_version) to check the correct start of the U-Boot after SPL execution.
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com
Changes in v2:
- add some test for SPL with device tree
arch/sandbox/dts/test.dts | 18 ++++++++++++++ test/py/tests/test_ofplatdata.py | 53 ++++++++++++++++++++++++++++++++++++++++ test/run | 5 ++++ 3 files changed, 76 insertions(+)
I am starting to understand a bit now.
But I don't think we need to execute sandbox to check that fdtgrep is doing the right thing. We can check the spl/u-boot-spl/tpl.dtb file against what is expected, but running fdtdump over it, or by opening the file with pylibfdt (see dtco//fdt.py) and looking for things we expect.
Regards, Simon

This add missing parts for previous commit 06f94461a9f4 ("fdt: Allow indicating a node is for U-Boot proper only")
At present it is not possible to specify that a node should be used before relocation (in U-Boot proper) without it also ending up in SPL and TPL device trees. Add a new "u-boot,dm-pre-proper" boolean property for this.
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
drivers/core/util.c | 2 ++ drivers/video/video-uclass.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/core/util.c b/drivers/core/util.c index 96e47dc..60b939a 100644 --- a/drivers/core/util.c +++ b/drivers/core/util.c @@ -42,6 +42,8 @@ bool dm_ofnode_pre_reloc(ofnode node) #else if (ofnode_read_bool(node, "u-boot,dm-pre-reloc")) return true; + if (ofnode_read_bool(node, "u-boot,dm-pre-proper")) + return true;
/* * In regular builds individual spl and tpl handling both diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index b19bfb4..d4071c0 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -291,7 +291,9 @@ static int video_post_bind(struct udevice *dev) return 0; size = alloc_fb(dev, &addr); if (addr < gd->video_bottom) { - /* Device tree node may need the 'u-boot,dm-pre-reloc' tag */ + /* Device tree node may need the 'u-boot,dm-pre-reloc' or + * 'u-boot,dm-pre-proper' tag + */ printf("Video device '%s' cannot allocate frame buffer memory -ensure the device is set up before relocation\n", dev->name); return -ENOSPC;

Add documentation for the pre-reloc property in SPL and TPL device-tree: - u-boot,dm-pre-proper - u-boot,dm-pre-reloc - u-boot,dm-spl - u-boot,dm-tpl
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v2: - rebase on master
doc/README.SPL | 16 ++++++++++++++++ doc/README.TPL | 4 ++++ doc/driver-model/README.txt | 4 ++++ include/dm/ofnode.h | 6 ++++-- include/dm/util.h | 6 ++++-- 5 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/doc/README.SPL b/doc/README.SPL index 7a30fef..6eed83f 100644 --- a/doc/README.SPL +++ b/doc/README.SPL @@ -66,6 +66,22 @@ CONFIG_SPL_SPI_LOAD (drivers/mtd/spi/spi_spl_load.o) CONFIG_SPL_RAM_DEVICE (common/spl/spl.c) CONFIG_SPL_WATCHDOG_SUPPORT (drivers/watchdog/libwatchdog.o)
+Device tree +----------- +The U-Boot device tree is filtered by the fdtgrep tools during the build +process to generate a much smaller device tree used in SPL (spl/u-boot-spl.dtb) +with: +- the mandatory nodes (/alias, /chosen, /config) +- the nodes with one pre-relocation property: + 'u-boot,dm-pre-reloc' or 'u-boot,dm-spl' + +ftgrep is also used to remove: +- the properties defined in CONFIG_OF_SPL_REMOVE_PROPS +- all the pre-relocation properties + ('u-boot,dm-pre-reloc', 'u-boot,dm-spl' and 'u-boot,dm-tpl') + +All the nodes remaining in the SPL devicetree are bound +(see driver-model/README.txt).
Debugging --------- diff --git a/doc/README.TPL b/doc/README.TPL index 980debe..c94129f 100644 --- a/doc/README.TPL +++ b/doc/README.TPL @@ -34,6 +34,10 @@ determine which SPL options to choose based on whether CONFIG_TPL_BUILD is set. Source files can be compiled for TPL with options choosed in the board config file.
+TPL use a small device tree (u-boot-tpl.dtb), containing only the nodes with +the pre-relocation properties: 'u-boot,dm-pre-reloc' and 'u-boot,dm-tpl' +(see README.SPL for details). + For example:
spl/Makefile: diff --git a/doc/driver-model/README.txt b/doc/driver-model/README.txt index 07b120d..532a771 100644 --- a/doc/driver-model/README.txt +++ b/doc/driver-model/README.txt @@ -849,6 +849,10 @@ in the device tree node. For U-Boot proper you can use 'u-boot,dm-pre-proper' which means that it will be processed (and a driver bound) in U-Boot proper prior to relocation, but will not be available in SPL or TPL.
+To reduce the size of SPL and TPL, only the nodes with pre-relocation properties +('u-boot,dm-pre-reloc', 'u-boot,dm-spl' or 'u-boot,dm-tpl') are keept in their +device trees (see README.SPL for details); the remaining nodes are always bound. + Then post relocation we throw that away and re-init driver model again. For drivers which require some sort of continuity between pre- and post-relocation devices, we can provide access to the pre-relocation diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index d206ee2..b45da5e 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -662,12 +662,14 @@ int ofnode_read_simple_size_cells(ofnode node); * After relocation and jumping into the real U-Boot binary it is possible to * determine if a node was bound in one of SPL/TPL stages. * - * There are 3 settings currently in use - * - + * There are 4 settings currently in use + * - u-boot,dm-pre-proper: U-Boot proper pre-relocation only * - u-boot,dm-pre-reloc: legacy and indicates any of TPL or SPL * Existing platforms only use it to indicate nodes needed in * SPL. Should probably be replaced by u-boot,dm-spl for * new platforms. + * - u-boot,dm-spl: SPL and U-Boot pre-relocation + * - u-boot,dm-tpl: TPL and U-Boot pre-relocation * * @node: node to check * @return true if node is needed in SPL/TL, false otherwise diff --git a/include/dm/util.h b/include/dm/util.h index 60d3b93..348c2ac 100644 --- a/include/dm/util.h +++ b/include/dm/util.h @@ -52,12 +52,14 @@ static inline void dm_dump_devres(void) * it is possible to determine if a node was bound in one of * SPL/TPL stages. * - * There are 3 settings currently in use - * - + * There are 4 settings currently in use + * - u-boot,dm-pre-proper: U-Boot proper pre-relocation only * - u-boot,dm-pre-reloc: legacy and indicates any of TPL or SPL * Existing platforms only use it to indicate nodes needed in * SPL. Should probably be replaced by u-boot,dm-spl for * existing platforms. + * - u-boot,dm-spl: SPL and U-Boot pre-relocation + * - u-boot,dm-tpl: TPL and U-Boot pre-relocation * @node: of node * * Returns true if node is needed in SPL/TL, false otherwise.

On Mon, 20 May 2019 at 07:00, Patrick Delaunay patrick.delaunay@st.com wrote:
Add documentation for the pre-reloc property in SPL and TPL device-tree:
- u-boot,dm-pre-proper
- u-boot,dm-pre-reloc
- u-boot,dm-spl
- u-boot,dm-tpl
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com Reviewed-by: Simon Glass sjg@chromium.org
Changes in v2:
- rebase on master
doc/README.SPL | 16 ++++++++++++++++ doc/README.TPL | 4 ++++ doc/driver-model/README.txt | 4 ++++ include/dm/ofnode.h | 6 ++++-- include/dm/util.h | 6 ++++-- 5 files changed, 32 insertions(+), 4 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

Hi Patrick,
On Mon, 20 May 2019 at 07:00, Patrick Delaunay patrick.delaunay@st.com wrote:
Hi,
I create this v2 serie with:
1/ documentation update for previous patch [U-Boot,v2] dm: remove pre reloc properties in SPL and TPL device tree http://patchwork.ozlabs.org/patch/1081155/
PS: Code is already merged in commit commit c7a88dae997f ("dm: remove pre reloc properties in SPL and TPL device tree") but not the documentation.
2/ missing part for (patch 1/2) http://patchwork.ozlabs.org/project/uboot/list/?series=89846
3/ new tests for pre-reloc propertie in SPL as suggested by Simon (http://patchwork.ozlabs.org/patch/1081155/#2156621)
Tell me if is better to split the serie.
Somehow this cover letter appears in a patch, hence some of my confusion. I see what you are doing and it is a comprehensive approach.
But please see my comments about comparing the .dtb file instead of making sandbox print it out.
Regards, Simon

Hi Simon,
I will reply for the serie
Hi Patrick,
On Mon, 20 May 2019 at 07:00, Patrick Delaunay patrick.delaunay@st.com wrote:
Hi,
I create this v2 serie with:
1/ documentation update for previous patch [U-Boot,v2] dm: remove pre reloc properties in SPL and TPL device tree http://patchwork.ozlabs.org/patch/1081155/
PS: Code is already merged in commit commit c7a88dae997f ("dm: remove pre reloc properties in SPL and TPL device tree") but not the documentation.
2/ missing part for (patch 1/2) http://patchwork.ozlabs.org/project/uboot/list/?series=89846
3/ new tests for pre-reloc propertie in SPL as suggested by Simon (http://patchwork.ozlabs.org/patch/1081155/#2156621)
Tell me if is better to split the serie.
Somehow this cover letter appears in a patch, hence some of my confusion. I see what you are doing and it is a comprehensive approach.
But please see my comments about comparing the .dtb file instead of making sandbox print it out.
I will change the test to only compare the device tree : it is more simple.
=> v3 in few days
My first approach was complicated but it is to allow - check if sandbox SPL with devicetree and libfdt in working as is already done for platdata - check if sandbox SPL can start U-Boot in booth case (by executing the simple test_000_version in ./py/tests/test_000_version.py) - split test and normal device tree (I move the "spl-tests" nodes in test.dts)
But it is too complicated just the purpose of this test.
NB: the executable "u-boot-spl" for sandbox_spl_defconfig already include the devicetree information, with platdata.
Regards, Simon
Regards Patrick

Hi Patrick,
On Tue, 21 May 2019 at 10:07, Patrick DELAUNAY patrick.delaunay@st.com wrote:
Hi Simon,
I will reply for the serie
Hi Patrick,
On Mon, 20 May 2019 at 07:00, Patrick Delaunay patrick.delaunay@st.com wrote:
Hi,
I create this v2 serie with:
1/ documentation update for previous patch [U-Boot,v2] dm: remove pre reloc properties in SPL and TPL device tree http://patchwork.ozlabs.org/patch/1081155/
PS: Code is already merged in commit commit c7a88dae997f ("dm: remove pre reloc properties in SPL and TPL device tree") but not the documentation.
2/ missing part for (patch 1/2) http://patchwork.ozlabs.org/project/uboot/list/?series=89846
3/ new tests for pre-reloc propertie in SPL as suggested by Simon (http://patchwork.ozlabs.org/patch/1081155/#2156621)
Tell me if is better to split the serie.
Somehow this cover letter appears in a patch, hence some of my confusion. I see what you are doing and it is a comprehensive approach.
But please see my comments about comparing the .dtb file instead of making sandbox print it out.
I will change the test to only compare the device tree : it is more simple.
=> v3 in few days
My first approach was complicated but it is to allow
- check if sandbox SPL with devicetree and libfdt in working as is already done for platdata
- check if sandbox SPL can start U-Boot in booth case (by executing the simple test_000_version in ./py/tests/test_000_version.py)
- split test and normal device tree (I move the "spl-tests" nodes in test.dts)
Yes, certainly this is useful and it does provide an end-to-end sanity check.
But if we do this I think it should be *in addition* to smaller test.
So could we start with the simpler, smaller test and then see how far that gets us? I am not saying that the functional test is bad, but if something goes wrong with the test, there are a lot of pieces to look at to figure out what went wrong.
But it is too complicated just the purpose of this test.
NB: the executable "u-boot-spl" for sandbox_spl_defconfig already include the devicetree information, with platdata.
Yes.
Regards, Simon
participants (4)
-
Patrick DELAUNAY
-
Patrick Delaunay
-
Simon Glass
-
Stephen Warren