* [PATCH 1/3] ARM: bootm: Add option boot using ATAGs
2018-06-11 20:42 [PATCH v2 0/3] kill oftree -f Sascha Hauer
@ 2018-06-11 20:42 ` Sascha Hauer
2018-06-11 20:42 ` [PATCH 2/3] commands: oftree: kill oftree -f Sascha Hauer
2018-06-11 20:42 ` [PATCH 3/3] Documentation: explain new way to boot using ATAGs Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2018-06-11 20:42 UTC (permalink / raw)
To: Barebox List
So far we can only force legacy boot using ATAGs by executing
'oftree -f'. Said command is going away as often this command
is not safe to call. Add an alternative way using the
global.bootm.boot_atag environment variable.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/lib32/bootm.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
index c8bf72f0e0..17eb78c6b2 100644
--- a/arch/arm/lib32/bootm.c
+++ b/arch/arm/lib32/bootm.c
@@ -26,6 +26,9 @@
#include <asm/armlinux.h>
#include <asm/system.h>
+/* If true, ignore device tree and boot with ATAGs */
+static int bootm_boot_atag;
+
/*
* sdram_start_and_size() - determine place for putting the kernel/oftree/initrd
*
@@ -135,8 +138,14 @@ static int __do_bootm_linux(struct image_data *data, unsigned long free_mem, int
unsigned long kernel;
unsigned long initrd_start = 0, initrd_size = 0, initrd_end = 0;
enum arm_security_state state = bootm_arm_security_state();
+ void *oftree;
int ret;
+ if (bootm_boot_atag)
+ oftree = NULL;
+ else
+ oftree = data->oftree;
+
kernel = data->os_res->start + data->os_entry;
initrd_start = data->initrd_address;
@@ -163,16 +172,18 @@ static int __do_bootm_linux(struct image_data *data, unsigned long free_mem, int
free_mem = PAGE_ALIGN(initrd_end + 1);
}
- ret = bootm_load_devicetree(data, free_mem);
- if (ret)
- return ret;
+ if (oftree) {
+ ret = bootm_load_devicetree(data, free_mem);
+ if (ret)
+ return ret;
+ }
if (bootm_verbose(data)) {
printf("\nStarting kernel at 0x%08lx", kernel);
if (initrd_size)
printf(", initrd at 0x%08lx", initrd_start);
if (data->oftree)
- printf(", oftree at 0x%p", data->oftree);
+ printf(", oftree at 0x%p", oftree);
printf("...\n");
}
@@ -188,7 +199,7 @@ static int __do_bootm_linux(struct image_data *data, unsigned long free_mem, int
if (data->dryrun)
return 0;
- start_linux((void *)kernel, swap, initrd_start, initrd_size, data->oftree,
+ start_linux((void *)kernel, swap, initrd_start, initrd_size, oftree,
state);
restart_machine();
@@ -600,8 +611,13 @@ static struct binfmt_hook binfmt_barebox_hook = {
.exec = "bootm",
};
+BAREBOX_MAGICVAR_NAMED(global_bootm_boot_atag, global.bootm.boot_atag,
+ "If true, ignore device tree and boot using ATAGs");
+
static int armlinux_register_image_handler(void)
{
+ globalvar_add_simple_bool("bootm.boot_atag", &bootm_boot_atag);
+
register_image_handler(&barebox_handler);
register_image_handler(&uimage_handler);
register_image_handler(&rawimage_handler);
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] commands: oftree: kill oftree -f
2018-06-11 20:42 [PATCH v2 0/3] kill oftree -f Sascha Hauer
2018-06-11 20:42 ` [PATCH 1/3] ARM: bootm: Add option boot using ATAGs Sascha Hauer
@ 2018-06-11 20:42 ` Sascha Hauer
2018-06-11 20:42 ` [PATCH 3/3] Documentation: explain new way to boot using ATAGs Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2018-06-11 20:42 UTC (permalink / raw)
To: Barebox List
Being able to free the live device tree seemed like a good idea in the
early days of device tree support when the first boards were brought up.
It turned out to be illusory that noone stores pointers to the live tree
which become invalid when oftree -f is executed. Enough people stumbled
upon crashed boards with this option, so remove it finally.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/oftree.c | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/commands/oftree.c b/commands/oftree.c
index 8a47c0be58..26a47bb581 100644
--- a/commands/oftree.c
+++ b/commands/oftree.c
@@ -48,7 +48,6 @@ static int do_oftree(int argc, char *argv[])
int probe = 0;
char *load = NULL;
char *save = NULL;
- int free_of = 0;
int ret;
struct device_node *root;
@@ -65,25 +64,12 @@ static int do_oftree(int argc, char *argv[])
return COMMAND_ERROR_USAGE;
}
break;
- case 'f':
- free_of = 1;
- break;
case 's':
save = optarg;
break;
}
}
- if (free_of) {
- struct device_node *root = of_get_root_node();
-
- if (root)
- of_delete_node(root);
-
- if (!load)
- return 0;
- }
-
if (!probe && !load && !save)
return COMMAND_ERROR_USAGE;
@@ -140,13 +126,12 @@ BAREBOX_CMD_HELP_TEXT("Options:")
BAREBOX_CMD_HELP_OPT ("-l <DTB>", "Load <DTB> to internal devicetree\n")
BAREBOX_CMD_HELP_OPT ("-s <DTB>", "save internal devicetree to <DTB>\n")
BAREBOX_CMD_HELP_OPT ("-p", "probe devices from stored device tree")
-BAREBOX_CMD_HELP_OPT ("-f", "free stored device tree")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(oftree)
.cmd = do_oftree,
BAREBOX_CMD_DESC("handle device trees")
- BAREBOX_CMD_OPTS("[-lspf]")
+ BAREBOX_CMD_OPTS("[-lsp]")
BAREBOX_CMD_GROUP(CMD_GRP_MISC)
BAREBOX_CMD_HELP(cmd_oftree_help)
BAREBOX_CMD_END
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] Documentation: explain new way to boot using ATAGs
2018-06-11 20:42 [PATCH v2 0/3] kill oftree -f Sascha Hauer
2018-06-11 20:42 ` [PATCH 1/3] ARM: bootm: Add option boot using ATAGs Sascha Hauer
2018-06-11 20:42 ` [PATCH 2/3] commands: oftree: kill oftree -f Sascha Hauer
@ 2018-06-11 20:42 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2018-06-11 20:42 UTC (permalink / raw)
To: Barebox List
oftree -f is gone and now global.bootm.boot_atag must be set to true
if boot using ATAGs is desired. Update the documentation accordingly.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Documentation/user/booting-linux.rst | 4 ++--
Documentation/user/devicetree.rst | 16 ++++------------
.../defaultenv-kindle-mx50/boot/mmc_kernel | 4 ++--
arch/arm/boards/radxa-rock/env/boot/mshc1 | 2 +-
arch/arm/boards/radxa-rock/env/boot/mshc1-old | 2 +-
5 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/Documentation/user/booting-linux.rst b/Documentation/user/booting-linux.rst
index 408f87d8e8..437f4e80ca 100644
--- a/Documentation/user/booting-linux.rst
+++ b/Documentation/user/booting-linux.rst
@@ -49,8 +49,8 @@ variable:
bootm
**NOTE:** it may happen that barebox is probed from the devicetree, but you have
-want to start a Kernel without passing a devicetree. In this case call ``oftree -f``
-to free the internal devicetree before calling ``bootm``
+want to start a Kernel without passing a devicetree. In this case set the
+``global.bootm.boot_atag`` variable to ``true``.
Passing Kernel Arguments
^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Documentation/user/devicetree.rst b/Documentation/user/devicetree.rst
index 17934d86e3..679cae7f00 100644
--- a/Documentation/user/devicetree.rst
+++ b/Documentation/user/devicetree.rst
@@ -71,15 +71,7 @@ work on the internal devicetree. It is possible to add/remove nodes using the
# add a property to it
of_property -s /chosen/mynode/ myproperty myvalue
-It is important to know that these commands always work on the internal
-devicetree. If you modify the internal devicetree to influence the behaviour of
-a kernel booted later, make sure that you start the kernel with the internal
-devicetree (i.e. don't pass a devicetree to the :ref:`command_bootm` command). If you
-wish to use another devicetree than the internal devicetree for starting the kernel,
-you can exchange the internal devicetree during runtime using the
-:ref:`command_oftree` command:
-
-.. code-block:: sh
-
- oftree -f
- oftree -l /new/dtb
+It is important to know that these commands normally work on the internal
+devicetree. If you want to modify the devicetree the kernel is started with
+see the -f options to of_property and of_node. This option will register the
+operation for later execution on the Kernel devicetree.
diff --git a/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/boot/mmc_kernel b/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/boot/mmc_kernel
index a43ee0cc92..4f2cabd54e 100644
--- a/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/boot/mmc_kernel
+++ b/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/boot/mmc_kernel
@@ -2,8 +2,8 @@
# Boot the Amazon factory-shipped kernel uimage stored on
# the eMMC at CONFIG_MMC_BOOTFLASH_ADDR 0x41000
-# Purge the OF tree to enable passing of ATAGs
-oftree -f
+# Force ATAG boot
+global.bootm.boot_atag=true
# The same machine type introduced with freescale ENGR00124359
armlinux_architecture=2955
diff --git a/arch/arm/boards/radxa-rock/env/boot/mshc1 b/arch/arm/boards/radxa-rock/env/boot/mshc1
index 964b6cc3eb..7393c4e63b 100644
--- a/arch/arm/boards/radxa-rock/env/boot/mshc1
+++ b/arch/arm/boards/radxa-rock/env/boot/mshc1
@@ -2,7 +2,7 @@
mount /dev/mshc1.0
-oftree -f
+global.bootm.boot_atag=true
oftree -l /mnt/mshc1.0/rk3188-radxarock.dtb
global.bootm.image=/mnt/mshc1.0/zImage
diff --git a/arch/arm/boards/radxa-rock/env/boot/mshc1-old b/arch/arm/boards/radxa-rock/env/boot/mshc1-old
index 1e1b57751d..2e43a3aafe 100644
--- a/arch/arm/boards/radxa-rock/env/boot/mshc1-old
+++ b/arch/arm/boards/radxa-rock/env/boot/mshc1-old
@@ -2,7 +2,7 @@
mount /dev/mshc1.0
-oftree -f
+global.bootm.boot_atag=true
global.bootm.image=/mnt/mshc1.0/zImage-old
global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2 rootwait"
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread