NEW boot config
cover NEW boot config
Hi,
This is a frist attempt to implement a new boot config management that will allow us to have more complex config and a boot menu
so for small boot loader we will be able to drop the shell
Jean-Christophe PLAGNIOL-VILLARD (2):
add boot_config command support
add boot_menu command support
Documentation/bootsec.dtb | Bin 0 -> 2198 bytes Documentation/bootsec/bootsec.cfg | 104 +++++++++ commands/Kconfig | 16 ++ commands/Makefile | 2 + commands/boot_config.c | 262 ++++++++++++++++++++++ commands/boot_menu.c | 234 ++++++++++++++++++++ common/Kconfig | 5 + common/Makefile | 1 + common/boot_config.c | 438 +++++++++++++++++++++++++++++++++++++ common/boot_config_dts.c | 256 ++++++++++++++++++++++ include/boot_config.h | 158 +++++++++++++ 11 files changed, 1476 insertions(+), 0 deletions(-) create mode 100644 Documentation/bootsec.dtb create mode 100644 Documentation/bootsec/bootsec.cfg create mode 100644 Documentation/bootsec/splash_installer.bmp create mode 100644 Documentation/bootsec/splash_menu.bmp create mode 100644 commands/boot_config.c create mode 100644 commands/boot_menu.c create mode 100644 common/boot_config.c create mode 100644 common/boot_config_dts.c create mode 100644 include/boot_config.h
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/2 add boot_config command support
this just contain the bootmenu and dtb parsing can not yet boot for real
this will allow to create a boot config from a dtb file that can be provided by the OS to show a list a boot option
an example a file is in Documentation/bootsec.cfg
you can test using sandbox
# ./barebox -i Documentation/bootsec.dtb add file Documentation/bootsec.dtb()
barebox 2011.10.0-00119-gad62fdb-dirty (Oct 15 2011 - 11:38:46)
Board: sandbox
Malloc space: 0x7f679f24b010 -> 0x7f679fa4b010 (size 8 MB) Open /dev/env0 No such file or directory
no valid environment found on /dev/env0. Using default environment running /env/bin/init...
barebox:/ boot_config -f /dev/fd0 -d
--- Documentation/bootsec.dtb | Bin 0 -> 2198 bytes Documentation/bootsec/bootsec.cfg | 104 +++++++++ commands/Kconfig | 11 + commands/Makefile | 1 + commands/boot_config.c | 262 ++++++++++++++++++++++ common/Kconfig | 5 + common/Makefile | 1 + common/boot_config.c | 438 +++++++++++++++++++++++++++++++++++++ common/boot_config_dts.c | 256 ++++++++++++++++++++++ include/boot_config.h | 158 +++++++++++++ 10 files changed, 1236 insertions(+), 0 deletions(-) create mode 100644 Documentation/bootsec.dtb create mode 100644 Documentation/bootsec/bootsec.cfg create mode 100644 Documentation/bootsec/splash_installer.bmp create mode 100644 Documentation/bootsec/splash_menu.bmp create mode 100644 commands/boot_config.c create mode 100644 common/boot_config.c create mode 100644 common/boot_config_dts.c create mode 100644 include/boot_config.h
Documentation/bootsec.dtb new file binary +0 -0
Documentation/bootsec/bootsec.cfg new file +104 -0
104 lines not on this page · raw message
Documentation/bootsec/splash_installer.bmp new file +0 -0
Documentation/bootsec/splash_menu.bmp new file +0 -0
commands/Kconfig +11 -0
@@ -69,6 +69,17 @@ config CMD_MENU_MANAGEMENT depends on CMD_MENU prompt "menu scripts management" +config CMD_BOOT_CONFIG + tristate + depends on BOOT_CONFIG + select FDT + prompt "boot config" + +config CMD_BOOT_CONFIG_MANAGEMENT + bool + depends on CMD_BOOT_CONFIG + prompt "boot config management" + config CMD_LOGIN tristate select PASSWORD
commands/Makefile +1 -0
@@ -58,3 +58,4 @@ obj-$(CONFIG_CMD_LED_TRIGGER) += trigger.o obj-$(CONFIG_CMD_USB) += usb.o obj-$(CONFIG_CMD_TIME) += time.o obj-$(CONFIG_CMD_OFTREE) += oftree.o +obj-$(CONFIG_CMD_BOOT_CONFIG) += boot_config.o
commands/boot_config.c new file +262 -0
262 lines not on this page · raw message
common/Kconfig +5 -0
@@ -306,6 +306,11 @@ config AUTO_COMPLETE depends on CMDLINE_EDITING prompt "Enable auto completion" +config BOOT_CONFIG + bool + prompt "Boot Configuration Framework" + help + config MENU bool prompt "Menu Framework"
common/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-y += misc.o obj-y += memsize.o obj-$(CONFIG_MENU) += menu.o obj-$(CONFIG_PASSWORD) += password.o +obj-$(CONFIG_BOOT_CONFIG) += boot_config.o boot_config_dts.o obj-$(CONFIG_MODULES) += module.o extra-$(CONFIG_MODULES) += module.lds
common/boot_config.c new file +438 -0
438 lines not on this page · raw message
common/boot_config_dts.c new file +256 -0
256 lines not on this page · raw message
include/boot_config.h new file +158 -0
158 lines not on this page · raw message
Signature · 7 lines
1.7.7 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/2 add boot_menu command support
this just contain the bootmenu for boot_config can not yet boot for real
this will allow to create a boot menu from a dtb file that can be provided by the OS to show a list a boot option
an example a file is in Documentation/bootsec.cfg
you can test using sandbox
# ./barebox -i Documentation/bootsec.dtb add file Documentation/bootsec.dtb()
barebox 2011.10.0-00119-gad62fdb-dirty (Oct 15 2011 - 11:38:46)
Board: sandbox
Malloc space: 0x7f679f24b010 -> 0x7f679fa4b010 (size 8 MB) Open /dev/env0 No such file or directory
no valid environment found on /dev/env0. Using default environment running /env/bin/init...
barebox:/ boot_config -f /dev/fd0
barebox:/ boot_menu
--- commands/Kconfig | 5 + commands/Makefile | 1 + commands/boot_menu.c | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 240 insertions(+), 0 deletions(-) create mode 100644 commands/boot_menu.c
commands/Kconfig +5 -0
@@ -80,6 +80,11 @@ config CMD_BOOT_CONFIG_MANAGEMENT depends on CMD_BOOT_CONFIG prompt "boot config management" +config CMD_BOOT_MENU + tristate + depends on BOOT_CONFIG + prompt "boot menu" + config CMD_LOGIN tristate select PASSWORD
commands/Makefile +1 -0
@@ -59,3 +59,4 @@ obj-$(CONFIG_CMD_USB) += usb.o obj-$(CONFIG_CMD_TIME) += time.o obj-$(CONFIG_CMD_OFTREE) += oftree.o obj-$(CONFIG_CMD_BOOT_CONFIG) += boot_config.o +obj-$(CONFIG_CMD_BOOT_MENU) += boot_menu.o
commands/boot_menu.c new file +234 -0
234 lines not on this page · raw message
Signature · 7 lines
1.7.7 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] add boot_config command support
In reply to Jean-Christophe PLAGNIOL-VILLARDHi Jean-Christophe,
Quoted 61 lines · Jean-Christophe PLAGNIOL-VILLARD
this just contain the bootmenu and dtb parsing can not yet boot for real
this will allow to create a boot config from a dtb file that can be provided by the OS to show a list a boot option
an example a file is in
Documentation/bootsec.cfgyou can test using sandbox
Documentation/bootsec/bootsec.cfg new file +46
-0@@ -0,0 +1,104 @@ +/dts-v1/; + +/ { + data { + kernel@1 { + format = "uimage"; + dev = "sda1"; + fs = "ext3"; + path = "/boot/uImage-2.6.36"; + }; + initrd@1 { + dev = "sda1"; + fs = "ext3"; + path = "/boot/initrd-2.6.36"; + }; + + kernel@2 { + format = "zimage"; + dev = "sda1"; + fs = "ext3"; + path = "/boot/zImage-2.6.39"; + }; + initrd@2 { + dev = "sda1"; + fs = "ext3"; + path = "/boot/initrd-2.6.39"; + }; + + kernel@3 { + format = "uimage"; + dev = "sda1"; + fs = "ext3"; + path = "/boot/uImage-3.0.0"; + }; + initrd@3 { + dev = "sda1"; + fs = "ext3"; + path = "/boot/inird-3.0.0"; + }; + fdt@3 { + dev = "sda1"; + fs = "ext3"; + path = "boot/usb_a9g20.dtb"; + }; + + kernel@4 {
Documentation/bootsec/bootsec.cfg line 56
Quoted 10 lines
Documentation/bootsec/bootsec.cfg new file +10
-0+ format = "uimage"; + dev = "sda3"; + fs = "squashfs"; + path = "/boot/uImage-installer-3.0.0"; + }; + initrd@4 { + dev = "sda3"; + fs = "squashfs"; + path = "/boot/initrd-installer-3.0.0"; + };
Why do you describe the device/fstype in each and every node? a reference to a partition descriptions would be more convenient here. Also it's strange that the patch is an absolute path and not a path relative to the mountpoint.
Documentation/bootsec/bootsec.cfg line 68
Quoted 12 lines
Documentation/bootsec/bootsec.cfg new file +12
-0+ }; + + configuration { + description = "Welcome on Barebox Boot Sequence"; + default = "linux_3_0_0"; + altboot = "installer"; + bootdelay = <5>; + splash = /incbin/("splash_menu.bmp"); + + linux_2_6_36 { + description = "Linux 2.6.36"; + cmdline = "mem=64M console=ttyS0,115200 root=/dev/sda2 rw rootfstype=ext3";
We should be able to build the commandline out of its parts. A monolithic string seems not very flexible.
Documentation/bootsec/bootsec.cfg line 70
Quoted 2 lines
Documentation/bootsec/bootsec.cfg new file +2
-0+ kernel = "kernel@1"; + initrd = "initrd@1";
phandles instead?
Quoted 24 lines
Documentation/bootsec/bootsec.cfg new file +24
-0+ }; + + linux_2_6_39 { + description = "Linux 2.6.39"; + cmdline = "mem=64M console=ttyS0,115200 root=/dev/sda2 rw rootfstype=ext3"; + kernel = "kernel@2"; + initrd = "initrd@2"; + }; + + linux_3_0_0_bad { + description = "Linux 3.0.0"; + cmdline = "mem=64M console=ttyS0,115200 root=/dev/sda2 rw rootfstype=ext3"; + kernel = "kernel@3"; + initrd = "initrd@3"; + fdt = "fdt@4"; + }; + + linux_3_0_0 { + description = "Linux 3.0.0"; + cmdline = "mem=64M console=ttyS0,115200 root=/dev/sda2 rw rootfstype=ext3"; + kernel = "kernel@3"; + initrd = "initrd@3"; + fdt = "fdt@3"; + };
Documentation/bootsec/bootsec.cfg
Quoted 10 lines
Documentation/bootsec/bootsec.cfg new file +10
-0+ + installer { + description = "Installer Linux 3.0.0"; + cmdline = "mem=64M console=ttyS0,115200 root=/dev/sda4 ro rootfstype=squashfs"; + splash = /incbin/("splash_installer.bmp"); + kernel = "kernel@4"; + initrd = "initrd@4"; + }; + +#define OPTS "f:dlc:b:"
This is used only once. It would be clearer to just use the string instead.
Documentation/bootsec/bootsec.cfg
Quoted 9 lines
Documentation/bootsec/bootsec.cfg new file +9
-0+ +static void print_entries(void) +{ + struct boot_config_data *bed; + + printf("[Kernel]\n"); + + list_for_each_entry(bed, boot_config_get_kernels(), list) + printf("%s\n", bed->name);
So instead of the list_head directly you export it via boot_config_get_kernels() which basically has the same effect but is harder to read. Please do not do that.
Documentation/bootsec/bootsec.cfg
Quoted 13 lines
Documentation/bootsec/bootsec.cfg new file +13
-0+ printf("[Initrd]\n"); + + list_for_each_entry(bed, boot_config_get_initrds(), list) + printf("%s\n", bed->name); + + printf("[FDT]\n"); + + list_for_each_entry(bed, boot_config_get_fdts(), list) + printf("%s\n", bed->name); + +} + +static void print_boot_config_data(struct boot_config_data *bed)
What's a bed? Supposedly the thing I should go now.
Quoted 4 lines
Documentation/bootsec/bootsec.cfg new file +4
-0+{ + printf("name = '%s'\n", bed->name); + printf("dev = '%s'\n", bed->dev); + printf("fs = '%s'\n", bed->fs);
Documentation/bootsec/bootsec.cfg
Quoted 10 lines
Documentation/bootsec/bootsec.cfg new file +10
-0+ printf("path = '%s'\n", bed->path); +} + +static void print_boot_config(struct boot_config *e) +{ + struct boot_config_var *v; + + printf("Config '%s'\n\n", e->name); + + v = boot_config_var_get_by_name(e, "description");
You have a mechanism to attach arbitrary key/value pairs to a struct boot_config. Still you do not iterate over all over all variables in the corresponding devicetree node, but instead only handle the variables explicitely that you now about.
This does not make sense. struct boot_config should simply have a char *description, char *cmdline and whatever else you need. Then you can remove this boot_config_var_get_by_name() cruft.
Quoted 24 lines
Documentation/bootsec/bootsec.cfg new file +24
-0+ printf("description = %s\n", v->value); + v = boot_config_var_get_by_name(e, "cmdline"); + printf("cmdline = '%s'\n", v->value); + v = boot_config_var_get_by_name(e, "splash"); + if (v) + printf("splash = '%s'\n", v->value); + + printf("[Kernel]\n"); + print_boot_config_data(e->kernel); + + if (e->initrd) { + printf("[Initrd]\n"); + print_boot_config_data(e->initrd); + } + + if (e->fdt) { + printf("[fdt]\n"); + print_boot_config_data(e->fdt); + } +} + +/* + * boot_config -l [-c config] + */
[...]
Quoted 20 lines
Documentation/bootsec/bootsec.cfg new file +20
-0+ +static int do_boot_config(struct command *cmdtp, int argc, char *argv[]) +{ + struct cmd_bood_config cbc; + int opt; + int ret = COMMAND_ERROR_USAGE; + + memset(&cbc, 0, sizeof(struct cmd_bood_config)); + + while((opt = getopt(argc, argv, OPTS)) > 0) { + switch(opt) { + case 'f': + cbc.action = action_load; + cbc.filename = optarg; + break; + case 'd': + boot_config_unload(); + break; + case 'l': + cbc.action = action_list;
Documentation/bootsec/bootsec.cfg
Quoted 10 lines
Documentation/bootsec/bootsec.cfg new file +10
-0+ break; + case 'b': + cbc.action = action_boot; + case 'c': + cbc.config = optarg; + break; + } + } + + switch(cbc.action) {
What's this cbc.action thing about? It is only ever used in this function.
Quoted 4 lines
Documentation/bootsec/bootsec.cfg new file +4
-0+ case action_list: + ret = do_boot_config_list(&cbc); + break; + case action_load:
Documentation/bootsec/bootsec.cfg
Quoted 10 lines
Documentation/bootsec/bootsec.cfg new file +10
-0+ ret = do_boot_config_load(&cbc); + break; + case action_boot: + ret = do_boot_config_boot(&cbc); + break; + + }; + + if (ret) + return COMMAND_ERROR_USAGE;
I don't know what errors you expect from above, but for sure it does not necessarily mean that it's a usage error.
Documentation/bootsec/bootsec.cfg
Quoted 4 lines
Documentation/bootsec/bootsec.cfg new file +4
-0+ + return 0; +} +
[,..]
Quoted 110 lines
common/boot_config.c new file +103
-0@@ -0,0 +1,438 @@ +/* +* (C) Copyright 2011 Jean-Christophe PLAGNIOL-VILLARD <[email protected]> +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; version 2 of +* the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +#include <common.h> +#include <command.h> +#include <readkey.h> +#include <errno.h> +#include <linux/err.h> +#include <boot_config.h> +#include <environment.h> + +int boot_config_debug; +static char *description; +static struct boot_config *default_boot; +static uint32_t bootdelay =-1 ; + +static LIST_HEAD (kernels); +static LIST_HEAD (initrds); +static LIST_HEAD (fdts); +static LIST_HEAD (configs); + +char *boot_config_get_description (void ) +{ +return description; +} + +struct boot_config *boot_config_get_default_boot (void ) +{ +return default_boot; +} + +uint32_t boot_config_get_bootdelay (void ) +{ +return bootdelay; +} + +int boot_config_set_description (const char *s) +{ +if (!s) +return -EINVAL ; +free (description); + description =strdup (s); + +if (!description) +return -ENOMEM ; + +return 0 ; +} + +int boot_config_set_default_boot (struct boot_config *b) +{ + default_boot = b; + +return 0 ; +} + +int boot_config_set_default_boot_by_name (const char *s) +{ +struct boot_config *b; + + b =boot_config_get_by_name (s); + +if (!b) +return -EINVAL ; + +return boot_config_set_default_boot (b); +} + +int boot_config_set_bootdelay (uint32_t v) +{ + bootdelay = v; + +return 0 ; +} + +struct list_head *boot_config_get_configs (void ) +{ +return &configs; +} + +struct list_head *boot_config_get_kernels (void ) +{ +return &kernels; +}
common/boot_config.c line 113
Quoted 10 lines
common/boot_config.c new file +10
-0+ +struct list_head *boot_config_get_initrds (void ) +{ +return &initrds; +} + +struct list_head *boot_config_get_fdts (void ) +{ +return &fdts; +}
So much code just to handle some global data. You should collect this in a struct and pass it around where you need it instead,
Quoted 81 lines
common/boot_config.c new file +81
-0+ +int boot_config_item_init (struct boot_config *e) +{ +struct boot_config_var *v; +int ret; + +if (!e) +return -EINVAL ; + + v =boot_config_var_get_by_name (e,"kernel" ); +if (!v) { + ret = -EINVAL ; +eprintf ("Config %s: Missing kernel\n" , e->name); + goto err; + } + e->kernel =bed_list_get_by_name (&kernels, v->value); +if (!e->kernel) { + ret = -EINVAL ; +eprintf ("Config %s: kernel '%s' not found\n" , e->name, v->value); + goto err; + } + + v =boot_config_var_get_by_name (e,"initrd" ); +if (v) { + e->initrd =bed_list_get_by_name (&initrds, v->value); +if (!e->initrd) { + ret = -EINVAL ; +eprintf ("Config %s: initrd '%s' not found\n" , e->name, v->value); + goto err; + } + } + + v =boot_config_var_get_by_name (e,"fdt" ); +if (v) { + e->fdt =bed_list_get_by_name (&fdts, v->value); +if (!e->fdt) { + ret = -EINVAL ; +eprintf ("Config %s: fdt '%s' not found\n" , e->name, v->value); + goto err; + } + } + +return 0 ; +err: +return ret; +} + +int boot_config_add_by_name (const char *name,const char *desc, +const char *kernel,const char *cmdline, +const char *initrd,const char *fdt) +{ +struct boot_config *e =boot_config_alloc (); +int ret; + +if (!e) +return -ENOMEM ; + +if (boot_config_debug) +printf ("Boot '%s'\n" , name); + +if (boot_config_get_by_name (name)) +return -EEXIST ; + + e->name =strdup (name); +if (!e->name) { + ret = -ENOMEM ; + goto err_free; + } + + ret =boot_config_var_add (e,"description" , desc); +if (ret) + goto err_free; + ret =boot_config_var_add (e,"cmdline" , cmdline); +if (ret) + goto err_free; + + ret =boot_config_var_add (e,"kernel" , kernel); +if (ret) + goto err_free; + +if (initrd) {
common/boot_config.c line 310
Quoted 10 lines
common/boot_config.c new file +10
-0+ ret =boot_config_var_add (e,"initrd" , initrd); +if (ret) + goto err_free; + } + +if (fdt) { + ret =boot_config_var_add (e,"fdt" , fdt); +if (ret) + goto err_free; + }
I am not going to read further. Every struct boot_config seems to have a clearly defined set of variables but instead of adding the corresponding pointers to struct boot_config you have this strange attach-key-value-pairs-to-c-struct in place.
Supposedly this is some leftover from earlier versions. Sending non-finished patches as a RFC is perfectly fine, but in this case it's sometimes really hard to see where you're heading to.
If you want to get this in someday it's going to be a long way. Communicating with the Linux userspace using a devicetree means creating an API which also means that we have to have the nice feeling that this API can be stable. Right now it more looks to me as if the devicetree format is an adhoc implementation of what you needed for your example.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] add boot_config command support
Quoted 18 lines
Quoted 18 lines
Documentation/bootsec/bootsec.cfg new file +18
-0+ dev = "sda1"; + fs = "ext3"; + path = "/boot/inird-3.0.0"; + }; + fdt@3 { + dev = "sda1"; + fs = "ext3"; + path = "boot/usb_a9g20.dtb"; + }; + + kernel@4 { + format = "uimage"; + dev = "sda3"; + fs = "squashfs"; + path = "/boot/uImage-installer-3.0.0"; + }; + initrd@4 { + dev = "sda3";
Quoted 8 lines
Documentation/bootsec/bootsec.cfg line 56
Quoted 3 lines
Documentation/bootsec/bootsec.cfg new file +3
-0+ fs = "squashfs"; + path = "/boot/initrd-installer-3.0.0"; + };Why do you describe the device/fstype in each and every node? a reference to a partition descriptions would be more convenient here. Also it's strange that the patch is an absolute path and not a path relative to the mountpoint.
becasue we need to known the fs to mont it
the fs could a real fs or nfs or tftp the path is absolute mount the mountpoint
Quoted 16 lines
Documentation/bootsec/bootsec.cfg line 68
Quoted 13 lines
Documentation/bootsec/bootsec.cfg new file +12
-0+ }; + + configuration { + description = "Welcome on Barebox Boot Sequence"; + default = "linux_3_0_0"; + altboot = "installer"; + bootdelay = <5>; + splash = /incbin/("splash_menu.bmp"); + + linux_2_6_36 { + description = "Linux 2.6.36"; + cmdline = "mem=64M console=ttyS0,115200 root=/dev/sda2 rw rootfstype=ext3";We should be able to build the commandline out of its parts. A monolithic string seems not very flexible.
the idea is to put var inside and after you will use this cmdline as a based to construct the finall one
Quoted 5 lines
Documentation/bootsec/bootsec.cfg line 70
Quoted 3 lines
Documentation/bootsec/bootsec.cfg new file +2
-0+ kernel = "kernel@1"; + initrd = "initrd@1";phandles instead?
more code in the c code and mre difficult to handle when modifying the dtb from barebox
Quoted 12 lines
Documentation/bootsec/bootsec.cfg
Quoted 9 lines
Documentation/bootsec/bootsec.cfg new file +8
-0+ description = "Installer Linux 3.0.0"; + cmdline = "mem=64M console=ttyS0,115200 root=/dev/sda4 ro rootfstype=squashfs"; + splash = /incbin/("splash_installer.bmp"); + kernel = "kernel@4"; + initrd = "initrd@4"; + }; + +#define OPTS "f:dlc:b:"This is used only once. It would be clearer to just use the string instead.
as done on menu framework we will have tehe management part so 2 OPTS the code is not finished or even enough advanced to publixh it
Quoted 14 lines
commands/boot_config.c line 50
Quoted 10 lines
commands/boot_config.c new file +9
-0+ +static void print_entries (void ) +{ +struct boot_config_data *bed; + +printf ("[Kernel]\n" ); + +list_for_each_entry (bed,boot_config_get_kernels (), list) +printf ("%s\n" , bed->name);So instead of the
list_headdirectly you export it viaboot_config_get_kernels()which basically has the same effect but is harder to read. Please do not do that.
realy don't like to export it
Quoted 16 lines
Quoted 4 lines
commands/boot_config.c new file +3
-0+printf ("[Initrd]\n" ); + +list_for_each_entry (bed,boot_config_get_initrds (), list)commands/boot_config.c line 63
Quoted 10 lines
commands/boot_config.c new file +10
-0+printf ("%s\n" , bed->name); + +printf ("[FDT]\n" ); + +list_for_each_entry (bed,boot_config_get_fdts (), list) +printf ("%s\n" , bed->name); + +} + +static void print_boot_config_data (struct boot_config_data *bed)What's a bed? Supposedly the thing I should go now.
I like it :P
it was supposed to mean boot env data
but switch to boot_config_data
Quoted 21 lines
Quoted 5 lines
commands/boot_config.c new file +4
-0+{ +printf ("name = '%s'\n" , bed->name); +printf ("dev = '%s'\n" , bed->dev); +printf ("fs = '%s'\n" , bed->fs);commands/boot_config.c line 77
Quoted 10 lines
commands/boot_config.c new file +10
-0+printf ("path = '%s'\n" , bed->path); +} + +static void print_boot_config (struct boot_config *e) +{ +struct boot_config_var *v; + +printf ("Config '%s'\n\n" , e->name); + + v =boot_config_var_get_by_name (e,"description" );You have a mechanism to attach arbitrary key/value pairs to a struct
boot_config. Still you do not iterate over all over all variables in the corresponding devicetree node, but instead only handle the variables explicitely that you now about.
Quoted 3 lines
This does not make sense. struct
boot_configshould simply have a char *description, char *cmdline and whatever else you need. Then you can remove thisboot_config_var_get_by_name()cruft.
I knwon this version is not switch to new one I finish it
Quoted 53 lines
Quoted 25 lines
commands/boot_config.c new file +24
-0+printf ("description = %s\n" , v->value); + v =boot_config_var_get_by_name (e,"cmdline" ); +printf ("cmdline = '%s'\n" , v->value); + v =boot_config_var_get_by_name (e,"splash" ); +if (v) +printf ("splash = '%s'\n" , v->value); + +printf ("[Kernel]\n" ); +print_boot_config_data (e->kernel); + +if (e->initrd) { +printf ("[Initrd]\n" ); +print_boot_config_data (e->initrd); + } + +if (e->fdt) { +printf ("[fdt]\n" ); +print_boot_config_data (e->fdt); + } +} + +/* +* boot_config -l [-c config] +*/ [...]
Quoted 25 lines
commands/boot_config.c new file +25
-0+ +static int do_boot_config (struct command *cmdtp,int argc,char *argv[]) +{ +struct cmd_bood_config cbc; +int opt; +int ret =COMMAND_ERROR_USAGE ; + +memset (&cbc,0 ,sizeof (struct cmd_bood_config )); + +while ((opt =getopt (argc, argv,OPTS )) >0 ) { +switch (opt) { +case 'f' : + cbc.action = action_load; + cbc.filename = optarg; +break ; +case 'd' : +boot_config_unload (); +break ; +case 'l' : + cbc.action = action_list; +break ; +case 'b' : + cbc.action = action_boot; +case 'c' : + cbc.config = optarg;
Quoted 8 lines
commands/boot_config.c line 215
Quoted 5 lines
commands/boot_config.c new file +5
-0+break ; + } + } + +switch (cbc.action) {What's this cbc.action thing about? It is only ever used in this function.
is to specify what to do based on the option as you can have alots of option see menu framwork
Quoted 54 lines
Quoted 5 lines
commands/boot_config.c new file +4
-0+case action_list: + ret =do_boot_config_list (&cbc); +break ; +case action_load:commands/boot_config.c line 229
Quoted 10 lines
commands/boot_config.c new file +10
-0+ ret =do_boot_config_load (&cbc); +break ; +case action_boot: + ret =do_boot_config_boot (&cbc); +break ; + + }; + +if (ret) +return COMMAND_ERROR_USAGE ;I don't know what errors you expect from above, but for sure it does not necessarily mean that it's a usage error.
commands/boot_config.c line 118
Quoted 4 lines
commands/boot_config.c new file +4
-0+ +return 0 ; +} +[,..]
common/boot_config.c line 113
Quoted 10 lines
common/boot_config.c new file +5
-1--- /dev/null + +struct list_head *boot_config_get_fdts (void ) +{ +return &fdts; +}So much code just to handle some global data. You should collect this in a struct and pass it around where you need it instead,
Quoted 1 line
+
+
common/boot_config.c line 310
Quoted 11 lines
common/boot_config.c new file +11
-0+if (initrd) { + ret =boot_config_var_add (e,"initrd" , initrd); +if (ret) + goto err_free; + } + +if (fdt) { + ret =boot_config_var_add (e,"fdt" , fdt); +if (ret) + goto err_free; + }
Quoted 7 lines
I am not going to read further. Every struct
boot_configseems to have a clearly defined set of variables but instead of adding the corresponding pointers to structboot_configyou have this strange attach-key-value-pairs-to-c-struct in place.
Supposedly this is some leftover from earlier versions. Sending non-finished patches as a RFC is perfectly fine, but in this case it's sometimes really hard to see where you're heading to.
Yas you have miniamal set of variable but the code is more generic and support to have more var.
As example for network or complex system the idea is to have no limit of which var you can add, you just need to specify the mandatory one.
And the Framework is not DTB only but generic other format will have other var.
Quoted 6 lines
If you want to get this in someday it's going to be a long way. Communicating with the Linux userspace using a devicetree means creating an API which also means that we have to have the nice feeling that this API can be stable. Right now it more looks to me as if the devicetree format is an adhoc implementation of what you needed for your example.
The point is the DTB is one format , we can use ant format for the boot_config.
THe DTB match the need to describe the boot config and will not impact the boot laoder size but we can use a grub config file too or PXE boot
so the DTB is just a format to support to demonstrate the boot_config framework
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] add boot_config command support
Quoted 26 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 18 lines
Quoted 18 lines
Documentation/bootsec/bootsec.cfg new file +18
-0+ dev = "sda1"; + fs = "ext3"; + path = "/boot/inird-3.0.0"; + }; + fdt@3 { + dev = "sda1"; + fs = "ext3"; + path = "boot/usb_a9g20.dtb"; + }; + + kernel@4 { + format = "uimage"; + dev = "sda3"; + fs = "squashfs"; + path = "/boot/uImage-installer-3.0.0"; + }; + initrd@4 { + dev = "sda3";Quoted 8 lines
Documentation/bootsec/bootsec.cfg line 56
Quoted 3 lines
Documentation/bootsec/bootsec.cfg new file +3
-0+ fs = "squashfs"; + path = "/boot/initrd-installer-3.0.0"; + };Why do you describe the device/fstype in each and every node? a reference to a partition descriptions would be more convenient here. Also it's strange that the patch is an absolute path and not a path relative to the mountpoint.
Quoted 4 lines
becasue we need to known the fs to mont it
the fs could a real fs or nfs or tftp the path is absolute mount the mountpoint
Linux normally mounts the boot partition to /boot. The information you need to describe is: sda3:initrd-installer-3.0.0. What shall the /boot mean above?
Quoted 20 lines
Quoted 16 lines
Documentation/bootsec/bootsec.cfg line 68
Quoted 13 lines
Documentation/bootsec/bootsec.cfg new file +12
-0+ }; + + configuration { + description = "Welcome on Barebox Boot Sequence"; + default = "linux_3_0_0"; + altboot = "installer"; + bootdelay = <5>; + splash = /incbin/("splash_menu.bmp"); + + linux_2_6_36 { + description = "Linux 2.6.36"; + cmdline = "mem=64M console=ttyS0,115200 root=/dev/sda2 rw rootfstype=ext3";We should be able to build the commandline out of its parts. A monolithic string seems not very flexible.
the idea is to put var inside and after you will use this cmdline as a based to construct the finall one
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Documentation/bootsec/bootsec.cfg line 70
Quoted 2 lines
Documentation/bootsec/bootsec.cfg new file +2
-0+ kernel = "kernel@1"; + initrd = "initrd@1";phandles instead?
more code in the c code and mre difficult to handle when modifying the dtb from barebox
I don't buy that. Other than that it seems to justify my point that the dtb format you chose is driven by your adhoc needs and not by some concept.
Quoted 5 lines
Quoted 4 lines
So instead of the
list_headdirectly you export it viaboot_config_get_kernels()which basically has the same effect but is harder to read. Please do not do that.realy don't like to export it
You already do, by taking the indirection over a function.
Quoted 41 lines
Quoted 16 lines
Quoted 4 lines
commands/boot_config.c new file +3
-0+printf ("[Initrd]\n" ); + +list_for_each_entry (bed,boot_config_get_initrds (), list)commands/boot_config.c line 63
Quoted 10 lines
commands/boot_config.c new file +10
-0+printf ("%s\n" , bed->name); + +printf ("[FDT]\n" ); + +list_for_each_entry (bed,boot_config_get_fdts (), list) +printf ("%s\n" , bed->name); + +} + +static void print_boot_config_data (struct boot_config_data *bed)What's a bed? Supposedly the thing I should go now.
I like it :P
it was supposed to mean boot env databut switch to
boot_config_dataQuoted 21 lines
Quoted 5 lines
commands/boot_config.c new file +4
-0+{ +printf ("name = '%s'\n" , bed->name); +printf ("dev = '%s'\n" , bed->dev); +printf ("fs = '%s'\n" , bed->fs);commands/boot_config.c line 77
Quoted 10 lines
commands/boot_config.c new file +10
-0+printf ("path = '%s'\n" , bed->path); +} + +static void print_boot_config (struct boot_config *e) +{ +struct boot_config_var *v; + +printf ("Config '%s'\n\n" , e->name); + + v =boot_config_var_get_by_name (e,"description" );You have a mechanism to attach arbitrary key/value pairs to a struct
boot_config. Still you do not iterate over all over all variables in the corresponding devicetree node, but instead only handle the variables explicitely that you now about.
Quoted 4 lines
Quoted 3 lines
This does not make sense. struct
boot_configshould simply have a char *description, char *cmdline and whatever else you need. Then you can remove thisboot_config_var_get_by_name()cruft.I knwon this version is not switch to new one I finish it
-ENOPARSE
Quoted 6 lines
Quoted 4 lines
commands/boot_config.c line 215
Quoted 1 line
commands/boot_config.c new file +1
-0+switch (cbc.action) {What's this cbc.action thing about? It is only ever used in this function.
is to specify what to do based on the option as you can have alots of option see menu framwork
Look again. This variable is used only locally in this function and it would be a bug if the functions below would interpret it.
Quoted 24 lines
Quoted 17 lines
Quoted 5 lines
commands/boot_config.c new file +4
-0+case action_list: + ret =do_boot_config_list (&cbc); +break ; +case action_load:commands/boot_config.c line 229
Quoted 10 lines
commands/boot_config.c new file +10
-0+ ret =do_boot_config_load (&cbc); +break ; +case action_boot: + ret =do_boot_config_boot (&cbc); +break ; + + }; + +if (ret) +return COMMAND_ERROR_USAGE ;Quoted 7 lines
I am not going to read further. Every struct
boot_configseems to have a clearly defined set of variables but instead of adding the corresponding pointers to structboot_configyou have this strange attach-key-value-pairs-to-c-struct in place.
Supposedly this is some leftover from earlier versions. Sending non-finished patches as a RFC is perfectly fine, but in this case it's sometimes really hard to see where you're heading to.
Quoted 8 lines
Yas you have miniamal set of variable but the code is more generic and support to have more var.
As example for network or complex system the idea is to have no limit of which var you can add, you just need to specify the mandatory one.
And the Framework is not DTB only but generic other format will have other var.
When other formats have other variables then you end up with a system where barebox does not know its own internal format. No. It does not make sense to translate from dtb or whatever format to another nonnative format which then has to be translated into soemthing else which barebox understands.
Quoted 6 lines
Quoted 6 lines
If you want to get this in someday it's going to be a long way. Communicating with the Linux userspace using a devicetree means creating an API which also means that we have to have the nice feeling that this API can be stable. Right now it more looks to me as if the devicetree format is an adhoc implementation of what you needed for your example.
Quoted 7 lines
The point is the DTB is one format , we can use ant format for the
boot_config.
THe DTB match the need to describe the boot config and will not impact the boot laoder size but we can use a grub config file too or PXE bootso the DTB is just a format to support to demonstrate the
boot_configframework
This 'just a format' is exported to Linux and thus should be more thought about.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox