[Arm-netbook] CONFIG_CMDLINE, override uboot parameters
Peter Steenbergen
p.steenbergen at j1nx.nl
Thu Feb 21 09:25:42 GMT 2013
I guess you guys are right as the fourth option indeed does not exist nor
has been discussed in the past.
I am developing on multiple Amlogic Meson3 devices at the moment. As it is
still unclear which uboot sources the Chinese used and I do not want to
brick people their devices by flashing a custom firmware. I simply do not
want to touch the whole uboot environment. I just flash the kernel to the
same partition on the NAND, so uboot starts it. From that point I want to
take over full control.
By using the FORCE option we also loose the MAC variable which is set in
hardware and passed by uboot (+ any other strange params, they Chinese put
in for whatever reason?). I just want to overwrite the root= and
rootfstype= parameter, and use the rest from uboot. That way, I do not have
to touch the uboot stuff on the nand, which can hardbrick the devices as
they are not as well protected as the Allwinner for instance.
Anyway, the fourth option has been created;
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index c824452..4c5a7ab 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1481,6 +1481,12 @@ config CMDLINE_FORCE
command-line options your boot loader passes to the kernel.
If unsure, say N.
+
+config CMDLINE_APPEND
+ bool "Append default kernel command string to bootloader kernel
arguments"
+ help
+ The default kernel command string will be appended to the
+ command-line arguments provided by the boot loader.
endchoice
config XIP_KERNEL
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index b0c25fa..418308e 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -652,6 +652,10 @@ static int __init parse_tag_cmdline(const struct tag
*tag)
strlcat(default_command_line, tag->u.cmdline.cmdline,
COMMAND_LINE_SIZE);
#elif defined(CONFIG_CMDLINE_FORCE)
pr_warning("Ignoring tag cmdline (using the default kernel command
line)\n");
+#elif defined(CONFIG_CMDLINE_APPEND)
+ strlcpy(default_command_line, tag->u.cmdline.cmdline,
COMMAND_LINE_SIZE);
+ strlcat(default_command_line, " ", COMMAND_LINE_SIZE);
+ strlcat(default_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
#else
strlcpy(default_command_line, tag->u.cmdline.cmdline,
COMMAND_LINE_SIZE);
#endif
Was just suprised I am the first one that only want to override some of the
uboot parameters. But guess, that what I want is to "hacky" as you would
normally just change the uboot parameters.
Thanks guys
On Wed, Feb 20, 2013 at 11:26 AM, Liviu Dudau <liviu at dudau.co.uk> wrote:
> Hi Peter,
>
> The 4th option that you want doesn't exist.
>
> Thing is, if you want to overwrite some of u-boot options then the
> following
> two things are true:
>
> a. you know the u-boot parameters
> b. you know one (or many) of them are wrong
>
> Most people in that case use option 2) and overwrite the bootloader command
> line with the one they want. If you are worried about someone going into
> u-boot and adding another useful command line parameter that you might be
> missing if you use option 2) then you need to explain to them what they
> also need to correct in that command line that is currently broken.
>
> Best regards,
> Liviu
>
>
> On Wed, Feb 20, 2013 at 10:17:31AM +0100, Peter Steenbergen wrote:
> > Thanks Piyush,
> >
> > I know about the uboot saved parameters. The whole point is that I do not
> > want to touch the by the factory flashed uboot. There are now three
> > CONFIG_CMDLINE options
> > 1) CONFIG_CMDLINE_BOOTLOADER == Always use the ones passed by the
> bootloader
> > 2 CONFIG_CMDLINE_FORCE == Always use the under CMDLINE defined
> parameters,
> > ignore the ones passed by the bootloader
> > 3) CONFIG_EXTEND == Insert parameters and APPEND the ones passed by the
> > bootloader. This is designed such, that you can define missing parameters
> > not defined by the bootloader.
> >
> > With the latter, if you define a parameter which is also passed by the
> > bootloader, the by CMDLINE configured one wil be overwritten by the one
> > passed from the bootloader. This is simply because the function to fill
> for
> > instance the rootfstype parameter is called twice.
> >
> > What I am basically are looking for is a fourth config option,
> > CONFIG_CMDLINE_OVERRIDE, where the by the bootloader passed parameters
> are
> > being appended by the ones defined in the CMDLINE. It is basically the
> > EXTEND, but then the other way around. It still EXTENDS the ones not
> > defined by the bootloader, but if you define a parameter in the kernel
> > which is also set by the CMDLINE the ones from the bootloader are
> > overwritten by the ones defined in the kernel.
> >
> > At this moment, a quick hack has been applied to set a boolean for the
> > rootfstype one;
> >
> https://github.com/j1nx/buildroot-linux-kernel-m3/commit/52476f9f911ee9c08acda0976331aa5465ff16a7
> > But a fourth CONFIG parameter will solve the same issue for any other
> > possible parameters. The thing is; I can't believe I am the only one that
> > wants to override uboot parameters. It might be already out there...
> >
> > Cheers
> >
> >
> > On Wed, Feb 20, 2013 at 3:32 AM, Piyush Verma <piyush.pv at gmail.com>
> wrote:
> >
> > > While booting we can stop at uboot prompt.
> > >
> > > there we can see all environment variable with printenv.
> > > we can change it by setenv. don't forget to save it by saveenv after
> > > changing environment variable.
> > >
> > > bootargs is the environment variable where we can pass all rootfs
> details.
> > >
> > > Does it solve ur issue ?
> > >
> > > On Wed, Feb 20, 2013 at 4:01 AM, Peter Steenbergen <
> p.steenbergen at j1nx.nl>wrote:
> > >
> > >> I am running into an issue with my Amlogic XBMC development. Before I
> go
> > >> out searching the dark secrets of the linux kernel, I thought why not
> ask
> > >> you guys first.
> > >>
> > >> There is this patch;
> > >>
> > >>
> http://lists.infradead.org/pipermail/linux-arm-kernel/2011-April/047506.html
> > >> Which is used often. It adds the CONFIG_CMDLINE_EXTEND to the possible
> > >> CMDLINE options. It is designed to prepend the cmdline parameters in
> case
> > >> there are missing values. The passed parameters by uboot are then
> appended
> > >> to the ones from CONFIG_CMDLINE.
> > >>
> > >> This all works fine if you indeed are missing parameters, but what if
> i
> > >> want to overwrite/override an already by uboot passed parameter? (like
> > >> root= and rootfstype=)
> > >>
> > >> I don't want to FORCE everything, because I then have to take over the
> > >> complete line as passed by uboot. If I do that I will loose the
> parameters
> > >> set by variables within uboot (MAC)
> > >>
> > >> If I set them in CMDLINE, then the ones passed from uboot are appended
> > >> and overriding the ones from CMDLINE.
> > >>
> > >> I also do not want to change uboot as that is still kind of tricky on
> the
> > >> Amlogic boxes.
> > >>
> > >> Do anyone of you guys have some tips and/or directions?
> > >>
> > >> thanks
> > >>
> > >> _______________________________________________
> > >> arm-netbook mailing list arm-netbook at lists.phcomp.co.uk
> > >> http://lists.phcomp.co.uk/mailman/listinfo/arm-netbook
> > >> Send large attachments to arm-netbook at files.phcomp.co.uk
> > >>
> > >
> > >
> > >
> > > --
> > > Thanks & Regards
> > >
> > > Piyush Verma
> > >
> > >
> > > _______________________________________________
> > > arm-netbook mailing list arm-netbook at lists.phcomp.co.uk
> > > http://lists.phcomp.co.uk/mailman/listinfo/arm-netbook
> > > Send large attachments to arm-netbook at files.phcomp.co.uk
> > >
>
> > _______________________________________________
> > arm-netbook mailing list arm-netbook at lists.phcomp.co.uk
> > http://lists.phcomp.co.uk/mailman/listinfo/arm-netbook
> > Send large attachments to arm-netbook at files.phcomp.co.uk
>
>
> --
> -------------------
> .oooO
> ( )
> \ ( Oooo.
> \_) ( )
> ) /
> (_/
>
> One small step
> for me ...
>
>
> _______________________________________________
> arm-netbook mailing list arm-netbook at lists.phcomp.co.uk
> http://lists.phcomp.co.uk/mailman/listinfo/arm-netbook
> Send large attachments to arm-netbook at files.phcomp.co.uk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.phcomp.co.uk/pipermail/arm-netbook/attachments/20130221/0589d879/attachment.html
More information about the arm-netbook
mailing list