Message ID | 20190925145750.200592-24-sjg@chromium.org |
---|---|
State | Accepted |
Commit | 189882c9337bd4fa0a6b2c5de3031cd6f4b8e262 |
Delegated to: | Bin Meng |
Headers | show |
Series | x86: Add initial support for apollolake | expand |
On Wed, Sep 25, 2019 at 10:58 PM Simon Glass <sjg@chromium.org> wrote: > > U-Boot already supports using -D to indicate that it should use the normal > device tree. It is sometimes useful to run with the test device tree, e.g. > when running a test. Add a -T option for this along with some > documentation. > > It can be used like this: > > /tmp/b/sandbox/u-boot -T -c "ut dm pci_busdev" > > (this will use /tmp/b/sandbox/arch/sandbox/dts/test.dtb as the DT) > > Signed-off-by: Simon Glass <sjg@chromium.org> > --- > > arch/sandbox/cpu/start.c | 25 +++++++++++++++++++++++++ > doc/arch/sandbox.rst | 9 +++++++++ > 2 files changed, 34 insertions(+) > Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com>
On Sat, Oct 5, 2019 at 11:13 AM Bin Meng <bmeng.cn@gmail.com> wrote: > > On Wed, Sep 25, 2019 at 10:58 PM Simon Glass <sjg@chromium.org> wrote: > > > > U-Boot already supports using -D to indicate that it should use the normal > > device tree. It is sometimes useful to run with the test device tree, e.g. > > when running a test. Add a -T option for this along with some > > documentation. > > > > It can be used like this: > > > > /tmp/b/sandbox/u-boot -T -c "ut dm pci_busdev" > > > > (this will use /tmp/b/sandbox/arch/sandbox/dts/test.dtb as the DT) > > > > Signed-off-by: Simon Glass <sjg@chromium.org> > > --- > > > > arch/sandbox/cpu/start.c | 25 +++++++++++++++++++++++++ > > doc/arch/sandbox.rst | 9 +++++++++ > > 2 files changed, 34 insertions(+) > > > > Reviewed-by: Bin Meng <bmeng.cn@gmail.com> > Tested-by: Bin Meng <bmeng.cn@gmail.com> applied to u-boot-x86/next, thanks!
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 82828f0c1d4..cfc542c8066 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -147,6 +147,31 @@ static int sandbox_cmdline_cb_default_fdt(struct sandbox_state *state, SANDBOX_CMDLINE_OPT_SHORT(default_fdt, 'D', 0, "Use the default u-boot.dtb control FDT in U-Boot directory"); +static int sandbox_cmdline_cb_test_fdt(struct sandbox_state *state, + const char *arg) +{ + const char *fmt = "/arch/sandbox/dts/test.dtb"; + char *p; + char *fname; + int len; + + len = strlen(state->argv[0]) + strlen(fmt) + 1; + fname = os_malloc(len); + if (!fname) + return -ENOMEM; + strcpy(fname, state->argv[0]); + p = strrchr(fname, '/'); + if (!p) + p = fname + strlen(fname); + len -= p - fname; + snprintf(p, len, fmt, p); + state->fdt_fname = fname; + + return 0; +} +SANDBOX_CMDLINE_OPT_SHORT(test_fdt, 'T', 0, + "Use the test.dtb control FDT in U-Boot directory"); + static int sandbox_cmdline_cb_interactive(struct sandbox_state *state, const char *arg) { diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst index 5c0caebcbf0..54933b56759 100644 --- a/doc/arch/sandbox.rst +++ b/doc/arch/sandbox.rst @@ -103,6 +103,8 @@ A device tree binary file can be provided with -d. If you edit the source (it is stored at arch/sandbox/dts/sandbox.dts) you must rebuild U-Boot to recreate the binary file. +To use the default device tree, use -D. To use the test device tree, use -T. + To execute commands directly, use the -c option. You can specify a single command, or multiple commands separated by a semicolon, as is normal in U-Boot. Be careful with quoting as the shell will normally process and @@ -499,6 +501,13 @@ run natively on your board if desired (and enabled). To run all tests use "make check". +To run a single test in an existing sandbox build, you can use -T to use the +test device tree, and -c to select the test: + + /tmp/b/sandbox/u-boot -T -c "ut dm pci_busdev" + +This runs dm_test_pci_busdev() which is in test/dm/pci.c + Memory Map ----------
U-Boot already supports using -D to indicate that it should use the normal device tree. It is sometimes useful to run with the test device tree, e.g. when running a test. Add a -T option for this along with some documentation. It can be used like this: /tmp/b/sandbox/u-boot -T -c "ut dm pci_busdev" (this will use /tmp/b/sandbox/arch/sandbox/dts/test.dtb as the DT) Signed-off-by: Simon Glass <sjg@chromium.org> --- arch/sandbox/cpu/start.c | 25 +++++++++++++++++++++++++ doc/arch/sandbox.rst | 9 +++++++++ 2 files changed, 34 insertions(+)