diff mbox series

[4/5] arm: mvebu: Espressobin: Define console env

Message ID 20200824142502.7281-4-pali@kernel.org
State Superseded
Delegated to: Stefan Roese
Headers show
Series [1/5] arm: mvebu: Espressobin: Move env load addresses | expand

Commit Message

Pali Rohár Aug. 24, 2020, 2:25 p.m. UTC
Some distribution bootscripts append console env into boot cmdline.
So define console env correctly to have early console access.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 include/configs/mvebu_armada-37xx.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Stefan Roese Aug. 25, 2020, 7:08 a.m. UTC | #1
On 24.08.20 16:25, Pali Rohár wrote:
> Some distribution bootscripts append console env into boot cmdline.
> So define console env correctly to have early console access.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan
Andre Heider Aug. 26, 2020, 1:22 p.m. UTC | #2
Hi,

On 24/08/2020 16:25, Pali Rohár wrote:
> Some distribution bootscripts append console env into boot cmdline.
> So define console env correctly to have early console access.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> ---
>   include/configs/mvebu_armada-37xx.h | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/include/configs/mvebu_armada-37xx.h b/include/configs/mvebu_armada-37xx.h
> index 6feceda757..b473072976 100644
> --- a/include/configs/mvebu_armada-37xx.h
> +++ b/include/configs/mvebu_armada-37xx.h
> @@ -17,6 +17,7 @@
>   
>   #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, \
>   					  115200, 230400, 460800, 921600 }
> +#define CONFIG_DEFAULT_CONSOLE "console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000"
>   
>   /*
>    * For booting Linux, the board info and command line data
> @@ -99,6 +100,7 @@
>   	"kernel_addr=0x7000000\0"	\
>   	"kernel_addr_r=0x7000000\0"	\
>   	"ramdisk_addr_r=0x8000000\0"	\
> +	"console=" CONFIG_DEFAULT_CONSOLE "\0" \
>   	BOOTENV
>   
>   #endif /* _CONFIG_MVEBU_ARMADA_37XX_H */
> 

this breaks booting debian with systemd for me:
[    4.632197] systemd-udevd[90]: Starting version 241
[    4.639324] systemd-udevd[91]: Failed to create udev control event 
source: Operation not permitted

"env delete console" and it works again.

The device tree already has 'stdout-path = "serial0:115200n8";' btw.

Regards,
Andre
Pali Rohár Aug. 26, 2020, 1:31 p.m. UTC | #3
On Wednesday 26 August 2020 15:22:26 Andre Heider wrote:
> Hi,
> 
> On 24/08/2020 16:25, Pali Rohár wrote:
> > Some distribution bootscripts append console env into boot cmdline.
> > So define console env correctly to have early console access.
> > 
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> > ---
> >   include/configs/mvebu_armada-37xx.h | 2 ++
> >   1 file changed, 2 insertions(+)
> > 
> > diff --git a/include/configs/mvebu_armada-37xx.h b/include/configs/mvebu_armada-37xx.h
> > index 6feceda757..b473072976 100644
> > --- a/include/configs/mvebu_armada-37xx.h
> > +++ b/include/configs/mvebu_armada-37xx.h
> > @@ -17,6 +17,7 @@
> >   #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, \
> >   					  115200, 230400, 460800, 921600 }
> > +#define CONFIG_DEFAULT_CONSOLE "console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000"
> >   /*
> >    * For booting Linux, the board info and command line data
> > @@ -99,6 +100,7 @@
> >   	"kernel_addr=0x7000000\0"	\
> >   	"kernel_addr_r=0x7000000\0"	\
> >   	"ramdisk_addr_r=0x8000000\0"	\
> > +	"console=" CONFIG_DEFAULT_CONSOLE "\0" \
> >   	BOOTENV
> >   #endif /* _CONFIG_MVEBU_ARMADA_37XX_H */
> > 
> 
> this breaks booting debian with systemd for me:
> [    4.632197] systemd-udevd[90]: Starting version 241
> [    4.639324] systemd-udevd[91]: Failed to create udev control event
> source: Operation not permitted
> 
> "env delete console" and it works again.

This is really suspicious. Why systemd has problems with control socket
when console= parameter is specified on boot command line? And if
console= parameter is problematic on command line, why console output is
working fine? For me it looks like this variable controls something
different, not (only) console output. Maybe some bootscript sets
something more when it see u-boot env ${console} non-empty?

> The device tree already has 'stdout-path = "serial0:115200n8";' btw.

I see. But it does not initialize earlycon.
Andre Heider Aug. 26, 2020, 2 p.m. UTC | #4
On 26/08/2020 15:31, Pali Rohár wrote:
> On Wednesday 26 August 2020 15:22:26 Andre Heider wrote:
>> Hi,
>>
>> On 24/08/2020 16:25, Pali Rohár wrote:
>>> Some distribution bootscripts append console env into boot cmdline.
>>> So define console env correctly to have early console access.
>>>
>>> Signed-off-by: Pali Rohár <pali@kernel.org>
>>> ---
>>>    include/configs/mvebu_armada-37xx.h | 2 ++
>>>    1 file changed, 2 insertions(+)
>>>
>>> diff --git a/include/configs/mvebu_armada-37xx.h b/include/configs/mvebu_armada-37xx.h
>>> index 6feceda757..b473072976 100644
>>> --- a/include/configs/mvebu_armada-37xx.h
>>> +++ b/include/configs/mvebu_armada-37xx.h
>>> @@ -17,6 +17,7 @@
>>>    #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, \
>>>    					  115200, 230400, 460800, 921600 }
>>> +#define CONFIG_DEFAULT_CONSOLE "console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000"
>>>    /*
>>>     * For booting Linux, the board info and command line data
>>> @@ -99,6 +100,7 @@
>>>    	"kernel_addr=0x7000000\0"	\
>>>    	"kernel_addr_r=0x7000000\0"	\
>>>    	"ramdisk_addr_r=0x8000000\0"	\
>>> +	"console=" CONFIG_DEFAULT_CONSOLE "\0" \
>>>    	BOOTENV
>>>    #endif /* _CONFIG_MVEBU_ARMADA_37XX_H */
>>>
>>
>> this breaks booting debian with systemd for me:
>> [    4.632197] systemd-udevd[90]: Starting version 241
>> [    4.639324] systemd-udevd[91]: Failed to create udev control event
>> source: Operation not permitted
>>
>> "env delete console" and it works again.
> 
> This is really suspicious. Why systemd has problems with control socket
> when console= parameter is specified on boot command line? And if
> console= parameter is problematic on command line, why console output is
> working fine? For me it looks like this variable controls something
> different, not (only) console output. Maybe some bootscript sets
> something more when it see u-boot env ${console} non-empty?

It sounds like a bug in systemd, this may be related:
https://github.com/systemd/systemd/issues/13332

With ugly workarounds like:
https://github.com/openembedded/openembedded-core/commit/dd6ee0b06cd8df6204cf600050516d15172302ea

This is easy for to me to work around, but note that this systemd 
version is the one shipping with current debian stable.
Pali Rohár Aug. 26, 2020, 2:10 p.m. UTC | #5
On Wednesday 26 August 2020 16:00:05 Andre Heider wrote:
> On 26/08/2020 15:31, Pali Rohár wrote:
> > On Wednesday 26 August 2020 15:22:26 Andre Heider wrote:
> > > Hi,
> > > 
> > > On 24/08/2020 16:25, Pali Rohár wrote:
> > > > Some distribution bootscripts append console env into boot cmdline.
> > > > So define console env correctly to have early console access.
> > > > 
> > > > Signed-off-by: Pali Rohár <pali@kernel.org>
> > > > ---
> > > >    include/configs/mvebu_armada-37xx.h | 2 ++
> > > >    1 file changed, 2 insertions(+)
> > > > 
> > > > diff --git a/include/configs/mvebu_armada-37xx.h b/include/configs/mvebu_armada-37xx.h
> > > > index 6feceda757..b473072976 100644
> > > > --- a/include/configs/mvebu_armada-37xx.h
> > > > +++ b/include/configs/mvebu_armada-37xx.h
> > > > @@ -17,6 +17,7 @@
> > > >    #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, \
> > > >    					  115200, 230400, 460800, 921600 }
> > > > +#define CONFIG_DEFAULT_CONSOLE "console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000"
> > > >    /*
> > > >     * For booting Linux, the board info and command line data
> > > > @@ -99,6 +100,7 @@
> > > >    	"kernel_addr=0x7000000\0"	\
> > > >    	"kernel_addr_r=0x7000000\0"	\
> > > >    	"ramdisk_addr_r=0x8000000\0"	\
> > > > +	"console=" CONFIG_DEFAULT_CONSOLE "\0" \
> > > >    	BOOTENV
> > > >    #endif /* _CONFIG_MVEBU_ARMADA_37XX_H */
> > > > 
> > > 
> > > this breaks booting debian with systemd for me:
> > > [    4.632197] systemd-udevd[90]: Starting version 241
> > > [    4.639324] systemd-udevd[91]: Failed to create udev control event
> > > source: Operation not permitted
> > > 
> > > "env delete console" and it works again.
> > 
> > This is really suspicious. Why systemd has problems with control socket
> > when console= parameter is specified on boot command line? And if
> > console= parameter is problematic on command line, why console output is
> > working fine? For me it looks like this variable controls something
> > different, not (only) console output. Maybe some bootscript sets
> > something more when it see u-boot env ${console} non-empty?
> 
> It sounds like a bug in systemd, this may be related:
> https://github.com/systemd/systemd/issues/13332
> 
> With ugly workarounds like:
> https://github.com/openembedded/openembedded-core/commit/dd6ee0b06cd8df6204cf600050516d15172302ea
> 
> This is easy for to me to work around, but note that this systemd version is
> the one shipping with current debian stable.

But this looks like to be related to command line 'console=null'.

Can you check which parameter is causing problem? console=... or
earlycon=... ? Also do you have /dev/ttyMV0 in your system?
Andre Heider Aug. 26, 2020, 2:43 p.m. UTC | #6
On 26/08/2020 16:10, Pali Rohár wrote:
> On Wednesday 26 August 2020 16:00:05 Andre Heider wrote:
>> On 26/08/2020 15:31, Pali Rohár wrote:
>>> On Wednesday 26 August 2020 15:22:26 Andre Heider wrote:
>>>> Hi,
>>>>
>>>> On 24/08/2020 16:25, Pali Rohár wrote:
>>>>> Some distribution bootscripts append console env into boot cmdline.
>>>>> So define console env correctly to have early console access.
>>>>>
>>>>> Signed-off-by: Pali Rohár <pali@kernel.org>
>>>>> ---
>>>>>     include/configs/mvebu_armada-37xx.h | 2 ++
>>>>>     1 file changed, 2 insertions(+)
>>>>>
>>>>> diff --git a/include/configs/mvebu_armada-37xx.h b/include/configs/mvebu_armada-37xx.h
>>>>> index 6feceda757..b473072976 100644
>>>>> --- a/include/configs/mvebu_armada-37xx.h
>>>>> +++ b/include/configs/mvebu_armada-37xx.h
>>>>> @@ -17,6 +17,7 @@
>>>>>     #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, \
>>>>>     					  115200, 230400, 460800, 921600 }
>>>>> +#define CONFIG_DEFAULT_CONSOLE "console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000"
>>>>>     /*
>>>>>      * For booting Linux, the board info and command line data
>>>>> @@ -99,6 +100,7 @@
>>>>>     	"kernel_addr=0x7000000\0"	\
>>>>>     	"kernel_addr_r=0x7000000\0"	\
>>>>>     	"ramdisk_addr_r=0x8000000\0"	\
>>>>> +	"console=" CONFIG_DEFAULT_CONSOLE "\0" \
>>>>>     	BOOTENV
>>>>>     #endif /* _CONFIG_MVEBU_ARMADA_37XX_H */
>>>>>
>>>>
>>>> this breaks booting debian with systemd for me:
>>>> [    4.632197] systemd-udevd[90]: Starting version 241
>>>> [    4.639324] systemd-udevd[91]: Failed to create udev control event
>>>> source: Operation not permitted
>>>>
>>>> "env delete console" and it works again.
>>>
>>> This is really suspicious. Why systemd has problems with control socket
>>> when console= parameter is specified on boot command line? And if
>>> console= parameter is problematic on command line, why console output is
>>> working fine? For me it looks like this variable controls something
>>> different, not (only) console output. Maybe some bootscript sets
>>> something more when it see u-boot env ${console} non-empty?
>>
>> It sounds like a bug in systemd, this may be related:
>> https://github.com/systemd/systemd/issues/13332
>>
>> With ugly workarounds like:
>> https://github.com/openembedded/openembedded-core/commit/dd6ee0b06cd8df6204cf600050516d15172302ea
>>
>> This is easy for to me to work around, but note that this systemd version is
>> the one shipping with current debian stable.
> 
> But this looks like to be related to command line 'console=null'.
> 
> Can you check which parameter is causing problem? console=... or
> earlycon=... ? Also do you have /dev/ttyMV0 in your system?
> 

yup, it's there:
crw--w---- 1 root tty 253, 0 Aug 26 15:09 /dev/ttyMV0

But I think it's related to console=null because it ends up as invalid:
Your patch sets "console" to "console=...".
Debian's boot.scr set "bootargs" to "... console=${console}".
So we end up with with kernel args "console=console=..." :)

So we need to strip one "console=", at least for debian's boot scripts:
"setenv console ttyMV0,115200 earlycon=ar3700_uart,0xd0012000" and it 
works again, including earlycon.

Regards,
Andre
Pali Rohár Aug. 26, 2020, 3:10 p.m. UTC | #7
On Wednesday 26 August 2020 16:43:10 Andre Heider wrote:
> On 26/08/2020 16:10, Pali Rohár wrote:
> > On Wednesday 26 August 2020 16:00:05 Andre Heider wrote:
> > > On 26/08/2020 15:31, Pali Rohár wrote:
> > > > On Wednesday 26 August 2020 15:22:26 Andre Heider wrote:
> > > > > Hi,
> > > > > 
> > > > > On 24/08/2020 16:25, Pali Rohár wrote:
> > > > > > Some distribution bootscripts append console env into boot cmdline.
> > > > > > So define console env correctly to have early console access.
> > > > > > 
> > > > > > Signed-off-by: Pali Rohár <pali@kernel.org>
> > > > > > ---
> > > > > >     include/configs/mvebu_armada-37xx.h | 2 ++
> > > > > >     1 file changed, 2 insertions(+)
> > > > > > 
> > > > > > diff --git a/include/configs/mvebu_armada-37xx.h b/include/configs/mvebu_armada-37xx.h
> > > > > > index 6feceda757..b473072976 100644
> > > > > > --- a/include/configs/mvebu_armada-37xx.h
> > > > > > +++ b/include/configs/mvebu_armada-37xx.h
> > > > > > @@ -17,6 +17,7 @@
> > > > > >     #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, \
> > > > > >     					  115200, 230400, 460800, 921600 }
> > > > > > +#define CONFIG_DEFAULT_CONSOLE "console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000"
> > > > > >     /*
> > > > > >      * For booting Linux, the board info and command line data
> > > > > > @@ -99,6 +100,7 @@
> > > > > >     	"kernel_addr=0x7000000\0"	\
> > > > > >     	"kernel_addr_r=0x7000000\0"	\
> > > > > >     	"ramdisk_addr_r=0x8000000\0"	\
> > > > > > +	"console=" CONFIG_DEFAULT_CONSOLE "\0" \
> > > > > >     	BOOTENV
> > > > > >     #endif /* _CONFIG_MVEBU_ARMADA_37XX_H */
> > > > > > 
> > > > > 
> > > > > this breaks booting debian with systemd for me:
> > > > > [    4.632197] systemd-udevd[90]: Starting version 241
> > > > > [    4.639324] systemd-udevd[91]: Failed to create udev control event
> > > > > source: Operation not permitted
> > > > > 
> > > > > "env delete console" and it works again.
> > > > 
> > > > This is really suspicious. Why systemd has problems with control socket
> > > > when console= parameter is specified on boot command line? And if
> > > > console= parameter is problematic on command line, why console output is
> > > > working fine? For me it looks like this variable controls something
> > > > different, not (only) console output. Maybe some bootscript sets
> > > > something more when it see u-boot env ${console} non-empty?
> > > 
> > > It sounds like a bug in systemd, this may be related:
> > > https://github.com/systemd/systemd/issues/13332
> > > 
> > > With ugly workarounds like:
> > > https://github.com/openembedded/openembedded-core/commit/dd6ee0b06cd8df6204cf600050516d15172302ea
> > > 
> > > This is easy for to me to work around, but note that this systemd version is
> > > the one shipping with current debian stable.
> > 
> > But this looks like to be related to command line 'console=null'.
> > 
> > Can you check which parameter is causing problem? console=... or
> > earlycon=... ? Also do you have /dev/ttyMV0 in your system?
> > 
> 
> yup, it's there:
> crw--w---- 1 root tty 253, 0 Aug 26 15:09 /dev/ttyMV0
> 
> But I think it's related to console=null because it ends up as invalid:
> Your patch sets "console" to "console=...".

It is doing same thing as other boards in U-Boot, see:

$ git grep 'define.*CONFIG_DEFAULT_CONSOLE'
include/configs/arndale.h:#define CONFIG_DEFAULT_CONSOLE                "console=ttySAC2,115200n8\0"
include/configs/espresso7420.h:#define CONFIG_DEFAULT_CONSOLE   "console=ttySAC1,115200n8\0"
include/configs/odroid.h:#define CONFIG_DEFAULT_CONSOLE         "console=ttySAC1,115200n8\0"
include/configs/odroid_xu3.h:#define CONFIG_DEFAULT_CONSOLE             "console=ttySAC2,115200n8\0"
include/configs/origen.h:#define CONFIG_DEFAULT_CONSOLE         "console=ttySAC1,115200n8\0"
include/configs/peach-pi.h:#define CONFIG_DEFAULT_CONSOLE       "console=ttySAC1,115200n8\0"
include/configs/peach-pit.h:#define CONFIG_DEFAULT_CONSOLE      "console=ttySAC1,115200n8\0"
include/configs/s5p_goni.h:#define CONFIG_DEFAULT_CONSOLE       "console=ttySAC2,115200n8\0"
include/configs/s5pc210_universal.h:#define CONFIG_DEFAULT_CONSOLE              "console=ttySAC1,115200n8\0"
include/configs/smdk5250.h:#define CONFIG_DEFAULT_CONSOLE               "console=ttySAC1,115200n8\0"
include/configs/smdk5420.h:#define CONFIG_DEFAULT_CONSOLE       "console=ttySAC1,115200n8\0"
include/configs/smdk5420.h:#define CONFIG_DEFAULT_CONSOLE               "console=ttySAC1,115200n8\0"
include/configs/smdkv310.h:#define CONFIG_DEFAULT_CONSOLE               "console=ttySAC2,115200n8\0"
include/configs/snow.h:#define CONFIG_DEFAULT_CONSOLE           "console=ttySAC1,115200n8\0"
include/configs/spring.h:#define CONFIG_DEFAULT_CONSOLE         "console=ttySAC1,115200n8\0"
include/configs/trats.h:#define CONFIG_DEFAULT_CONSOLE          "console=ttySAC2,115200n8\0"
include/configs/trats2.h:#define CONFIG_DEFAULT_CONSOLE         "console=ttySAC2,115200n8\0"

and:

$ git grep 'CONFIG_DEFAULT_CONSOLE' | grep -v ':#define'
include/configs/odroid.h:       "console=" CONFIG_DEFAULT_CONSOLE \
include/configs/odroid_xu3.h:   "console=" CONFIG_DEFAULT_CONSOLE \
include/configs/s5p_goni.h:     "console=" CONFIG_DEFAULT_CONSOLE \
include/configs/s5pc210_universal.h:    "console=" CONFIG_DEFAULT_CONSOLE \
include/configs/trats.h:        "console=" CONFIG_DEFAULT_CONSOLE \
include/configs/trats2.h:       "console=" CONFIG_DEFAULT_CONSOLE \
scripts/config_whitelist.txt:CONFIG_DEFAULT_CONSOLE

> Debian's boot.scr set "bootargs" to "... console=${console}".
> So we end up with with kernel args "console=console=..." :)

So then also other U-Boot boards are broken in Debian...
Where is that Debian's boot.scr file? In which package?

Armbian has 'setenv bootargs "$console ...'
https://dl.armbian.com/espressobin/u-boot/bootscript/boot.cmd

OpenWRT has 'setenv bootargs "${bootargs} ${console}"'
https://github.com/openwrt/openwrt/blob/master/target/linux/mvebu/image/generic-arm64.bootscript

So it seems that all expects that ${console} env contains 'console=tty...'

> So we need to strip one "console=", at least for debian's boot scripts:
> "setenv console ttyMV0,115200 earlycon=ar3700_uart,0xd0012000" and it works
> again, including earlycon.
> 
> Regards,
> Andre
Andre Heider Aug. 26, 2020, 3:29 p.m. UTC | #8
On 26/08/2020 17:10, Pali Rohár wrote:
> On Wednesday 26 August 2020 16:43:10 Andre Heider wrote:
>> On 26/08/2020 16:10, Pali Rohár wrote:
>>> On Wednesday 26 August 2020 16:00:05 Andre Heider wrote:
>>>> On 26/08/2020 15:31, Pali Rohár wrote:
>>>>> On Wednesday 26 August 2020 15:22:26 Andre Heider wrote:
>>>>>> Hi,
>>>>>>
>>>>>> On 24/08/2020 16:25, Pali Rohár wrote:
>>>>>>> Some distribution bootscripts append console env into boot cmdline.
>>>>>>> So define console env correctly to have early console access.
>>>>>>>
>>>>>>> Signed-off-by: Pali Rohár <pali@kernel.org>
>>>>>>> ---
>>>>>>>      include/configs/mvebu_armada-37xx.h | 2 ++
>>>>>>>      1 file changed, 2 insertions(+)
>>>>>>>
>>>>>>> diff --git a/include/configs/mvebu_armada-37xx.h b/include/configs/mvebu_armada-37xx.h
>>>>>>> index 6feceda757..b473072976 100644
>>>>>>> --- a/include/configs/mvebu_armada-37xx.h
>>>>>>> +++ b/include/configs/mvebu_armada-37xx.h
>>>>>>> @@ -17,6 +17,7 @@
>>>>>>>      #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, \
>>>>>>>      					  115200, 230400, 460800, 921600 }
>>>>>>> +#define CONFIG_DEFAULT_CONSOLE "console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000"
>>>>>>>      /*
>>>>>>>       * For booting Linux, the board info and command line data
>>>>>>> @@ -99,6 +100,7 @@
>>>>>>>      	"kernel_addr=0x7000000\0"	\
>>>>>>>      	"kernel_addr_r=0x7000000\0"	\
>>>>>>>      	"ramdisk_addr_r=0x8000000\0"	\
>>>>>>> +	"console=" CONFIG_DEFAULT_CONSOLE "\0" \
>>>>>>>      	BOOTENV
>>>>>>>      #endif /* _CONFIG_MVEBU_ARMADA_37XX_H */
>>>>>>>
>>>>>>
>>>>>> this breaks booting debian with systemd for me:
>>>>>> [    4.632197] systemd-udevd[90]: Starting version 241
>>>>>> [    4.639324] systemd-udevd[91]: Failed to create udev control event
>>>>>> source: Operation not permitted
>>>>>>
>>>>>> "env delete console" and it works again.
>>>>>
>>>>> This is really suspicious. Why systemd has problems with control socket
>>>>> when console= parameter is specified on boot command line? And if
>>>>> console= parameter is problematic on command line, why console output is
>>>>> working fine? For me it looks like this variable controls something
>>>>> different, not (only) console output. Maybe some bootscript sets
>>>>> something more when it see u-boot env ${console} non-empty?
>>>>
>>>> It sounds like a bug in systemd, this may be related:
>>>> https://github.com/systemd/systemd/issues/13332
>>>>
>>>> With ugly workarounds like:
>>>> https://github.com/openembedded/openembedded-core/commit/dd6ee0b06cd8df6204cf600050516d15172302ea
>>>>
>>>> This is easy for to me to work around, but note that this systemd version is
>>>> the one shipping with current debian stable.
>>>
>>> But this looks like to be related to command line 'console=null'.
>>>
>>> Can you check which parameter is causing problem? console=... or
>>> earlycon=... ? Also do you have /dev/ttyMV0 in your system?
>>>
>>
>> yup, it's there:
>> crw--w---- 1 root tty 253, 0 Aug 26 15:09 /dev/ttyMV0
>>
>> But I think it's related to console=null because it ends up as invalid:
>> Your patch sets "console" to "console=...".
> 
> It is doing same thing as other boards in U-Boot, see:
> 
> $ git grep 'define.*CONFIG_DEFAULT_CONSOLE'
> include/configs/arndale.h:#define CONFIG_DEFAULT_CONSOLE                "console=ttySAC2,115200n8\0"
> include/configs/espresso7420.h:#define CONFIG_DEFAULT_CONSOLE   "console=ttySAC1,115200n8\0"
> include/configs/odroid.h:#define CONFIG_DEFAULT_CONSOLE         "console=ttySAC1,115200n8\0"
> include/configs/odroid_xu3.h:#define CONFIG_DEFAULT_CONSOLE             "console=ttySAC2,115200n8\0"
> include/configs/origen.h:#define CONFIG_DEFAULT_CONSOLE         "console=ttySAC1,115200n8\0"
> include/configs/peach-pi.h:#define CONFIG_DEFAULT_CONSOLE       "console=ttySAC1,115200n8\0"
> include/configs/peach-pit.h:#define CONFIG_DEFAULT_CONSOLE      "console=ttySAC1,115200n8\0"
> include/configs/s5p_goni.h:#define CONFIG_DEFAULT_CONSOLE       "console=ttySAC2,115200n8\0"
> include/configs/s5pc210_universal.h:#define CONFIG_DEFAULT_CONSOLE              "console=ttySAC1,115200n8\0"
> include/configs/smdk5250.h:#define CONFIG_DEFAULT_CONSOLE               "console=ttySAC1,115200n8\0"
> include/configs/smdk5420.h:#define CONFIG_DEFAULT_CONSOLE       "console=ttySAC1,115200n8\0"
> include/configs/smdk5420.h:#define CONFIG_DEFAULT_CONSOLE               "console=ttySAC1,115200n8\0"
> include/configs/smdkv310.h:#define CONFIG_DEFAULT_CONSOLE               "console=ttySAC2,115200n8\0"
> include/configs/snow.h:#define CONFIG_DEFAULT_CONSOLE           "console=ttySAC1,115200n8\0"
> include/configs/spring.h:#define CONFIG_DEFAULT_CONSOLE         "console=ttySAC1,115200n8\0"
> include/configs/trats.h:#define CONFIG_DEFAULT_CONSOLE          "console=ttySAC2,115200n8\0"
> include/configs/trats2.h:#define CONFIG_DEFAULT_CONSOLE         "console=ttySAC2,115200n8\0"
> 
> and:
> 
> $ git grep 'CONFIG_DEFAULT_CONSOLE' | grep -v ':#define'
> include/configs/odroid.h:       "console=" CONFIG_DEFAULT_CONSOLE \
> include/configs/odroid_xu3.h:   "console=" CONFIG_DEFAULT_CONSOLE \
> include/configs/s5p_goni.h:     "console=" CONFIG_DEFAULT_CONSOLE \
> include/configs/s5pc210_universal.h:    "console=" CONFIG_DEFAULT_CONSOLE \
> include/configs/trats.h:        "console=" CONFIG_DEFAULT_CONSOLE \
> include/configs/trats2.h:       "console=" CONFIG_DEFAULT_CONSOLE \
> scripts/config_whitelist.txt:CONFIG_DEFAULT_CONSOLE
> 
>> Debian's boot.scr set "bootargs" to "... console=${console}".
>> So we end up with with kernel args "console=console=..." :)
> 
> So then also other U-Boot boards are broken in Debian...
> Where is that Debian's boot.scr file? In which package?

That would be flash-kernel:
https://packages.qa.debian.org/f/flash-kernel.html

bootscript/all/bootscr.uboot-generic:  setenv bootargs "${bootargs} 
console=${console}"
bootscript/arm64/bootscr.uboot-generic:  setenv bootargs "${bootargs} 
console=${console}"
bootscript/armhf/bootscr.cubox:setenv bootargs 
@@LINUX_KERNEL_CMDLINE_DEFAULTS@@ console=${console} 
@@LINUX_KERNEL_CMDLINE@@
bootscript/armhf/bootscr.sunxi:  setenv bootargs "${bootargs} 
console=${console}"
debian/changelog:    - If ${console} is set then add 
"console=${console}" to the bootargs.

The last entry points to:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=783074

Which has:
 > I suppose hush doesn't have sufficient power to check for an existing
 > console= in bootargs?
Not that I'm aware of.

So yeah...

Regards,
Andre
> 
> Armbian has 'setenv bootargs "$console ...'
> https://dl.armbian.com/espressobin/u-boot/bootscript/boot.cmd
> 
> OpenWRT has 'setenv bootargs "${bootargs} ${console}"'
> https://github.com/openwrt/openwrt/blob/master/target/linux/mvebu/image/generic-arm64.bootscript
> 
> So it seems that all expects that ${console} env contains 'console=tty...'
> 
>> So we need to strip one "console=", at least for debian's boot scripts:
>> "setenv console ttyMV0,115200 earlycon=ar3700_uart,0xd0012000" and it works
>> again, including earlycon.
>>
>> Regards,
>> Andre
Andre Heider Aug. 27, 2020, 4:51 a.m. UTC | #9
On 26/08/2020 17:10, Pali Rohár wrote:
> On Wednesday 26 August 2020 16:43:10 Andre Heider wrote:
>> On 26/08/2020 16:10, Pali Rohár wrote:
>>> On Wednesday 26 August 2020 16:00:05 Andre Heider wrote:
>>>> On 26/08/2020 15:31, Pali Rohár wrote:
>>>>> On Wednesday 26 August 2020 15:22:26 Andre Heider wrote:
>>>>>> Hi,
>>>>>>
>>>>>> On 24/08/2020 16:25, Pali Rohár wrote:
>>>>>>> Some distribution bootscripts append console env into boot cmdline.
>>>>>>> So define console env correctly to have early console access.
>>>>>>>
>>>>>>> Signed-off-by: Pali Rohár <pali@kernel.org>
>>>>>>> ---
>>>>>>>      include/configs/mvebu_armada-37xx.h | 2 ++
>>>>>>>      1 file changed, 2 insertions(+)
>>>>>>>
>>>>>>> diff --git a/include/configs/mvebu_armada-37xx.h b/include/configs/mvebu_armada-37xx.h
>>>>>>> index 6feceda757..b473072976 100644
>>>>>>> --- a/include/configs/mvebu_armada-37xx.h
>>>>>>> +++ b/include/configs/mvebu_armada-37xx.h
>>>>>>> @@ -17,6 +17,7 @@
>>>>>>>      #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, \
>>>>>>>      					  115200, 230400, 460800, 921600 }
>>>>>>> +#define CONFIG_DEFAULT_CONSOLE "console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000"
>>>>>>>      /*
>>>>>>>       * For booting Linux, the board info and command line data
>>>>>>> @@ -99,6 +100,7 @@
>>>>>>>      	"kernel_addr=0x7000000\0"	\
>>>>>>>      	"kernel_addr_r=0x7000000\0"	\
>>>>>>>      	"ramdisk_addr_r=0x8000000\0"	\
>>>>>>> +	"console=" CONFIG_DEFAULT_CONSOLE "\0" \
>>>>>>>      	BOOTENV
>>>>>>>      #endif /* _CONFIG_MVEBU_ARMADA_37XX_H */
>>>>>>>
>>>>>>
>>>>>> this breaks booting debian with systemd for me:
>>>>>> [    4.632197] systemd-udevd[90]: Starting version 241
>>>>>> [    4.639324] systemd-udevd[91]: Failed to create udev control event
>>>>>> source: Operation not permitted
>>>>>>
>>>>>> "env delete console" and it works again.
>>>>>
>>>>> This is really suspicious. Why systemd has problems with control socket
>>>>> when console= parameter is specified on boot command line? And if
>>>>> console= parameter is problematic on command line, why console output is
>>>>> working fine? For me it looks like this variable controls something
>>>>> different, not (only) console output. Maybe some bootscript sets
>>>>> something more when it see u-boot env ${console} non-empty?
>>>>
>>>> It sounds like a bug in systemd, this may be related:
>>>> https://github.com/systemd/systemd/issues/13332
>>>>
>>>> With ugly workarounds like:
>>>> https://github.com/openembedded/openembedded-core/commit/dd6ee0b06cd8df6204cf600050516d15172302ea
>>>>
>>>> This is easy for to me to work around, but note that this systemd version is
>>>> the one shipping with current debian stable.
>>>
>>> But this looks like to be related to command line 'console=null'.
>>>
>>> Can you check which parameter is causing problem? console=... or
>>> earlycon=... ? Also do you have /dev/ttyMV0 in your system?
>>>
>>
>> yup, it's there:
>> crw--w---- 1 root tty 253, 0 Aug 26 15:09 /dev/ttyMV0
>>
>> But I think it's related to console=null because it ends up as invalid:
>> Your patch sets "console" to "console=...".
> 
> It is doing same thing as other boards in U-Boot, see:
> 
> $ git grep 'define.*CONFIG_DEFAULT_CONSOLE'
> include/configs/arndale.h:#define CONFIG_DEFAULT_CONSOLE                "console=ttySAC2,115200n8\0"
> include/configs/espresso7420.h:#define CONFIG_DEFAULT_CONSOLE   "console=ttySAC1,115200n8\0"
> include/configs/odroid.h:#define CONFIG_DEFAULT_CONSOLE         "console=ttySAC1,115200n8\0"
> include/configs/odroid_xu3.h:#define CONFIG_DEFAULT_CONSOLE             "console=ttySAC2,115200n8\0"
> include/configs/origen.h:#define CONFIG_DEFAULT_CONSOLE         "console=ttySAC1,115200n8\0"
> include/configs/peach-pi.h:#define CONFIG_DEFAULT_CONSOLE       "console=ttySAC1,115200n8\0"
> include/configs/peach-pit.h:#define CONFIG_DEFAULT_CONSOLE      "console=ttySAC1,115200n8\0"
> include/configs/s5p_goni.h:#define CONFIG_DEFAULT_CONSOLE       "console=ttySAC2,115200n8\0"
> include/configs/s5pc210_universal.h:#define CONFIG_DEFAULT_CONSOLE              "console=ttySAC1,115200n8\0"
> include/configs/smdk5250.h:#define CONFIG_DEFAULT_CONSOLE               "console=ttySAC1,115200n8\0"
> include/configs/smdk5420.h:#define CONFIG_DEFAULT_CONSOLE       "console=ttySAC1,115200n8\0"
> include/configs/smdk5420.h:#define CONFIG_DEFAULT_CONSOLE               "console=ttySAC1,115200n8\0"
> include/configs/smdkv310.h:#define CONFIG_DEFAULT_CONSOLE               "console=ttySAC2,115200n8\0"
> include/configs/snow.h:#define CONFIG_DEFAULT_CONSOLE           "console=ttySAC1,115200n8\0"
> include/configs/spring.h:#define CONFIG_DEFAULT_CONSOLE         "console=ttySAC1,115200n8\0"
> include/configs/trats.h:#define CONFIG_DEFAULT_CONSOLE          "console=ttySAC2,115200n8\0"
> include/configs/trats2.h:#define CONFIG_DEFAULT_CONSOLE         "console=ttySAC2,115200n8\0"
> 
> and:
> 
> $ git grep 'CONFIG_DEFAULT_CONSOLE' | grep -v ':#define'
> include/configs/odroid.h:       "console=" CONFIG_DEFAULT_CONSOLE \
> include/configs/odroid_xu3.h:   "console=" CONFIG_DEFAULT_CONSOLE \
> include/configs/s5p_goni.h:     "console=" CONFIG_DEFAULT_CONSOLE \
> include/configs/s5pc210_universal.h:    "console=" CONFIG_DEFAULT_CONSOLE \
> include/configs/trats.h:        "console=" CONFIG_DEFAULT_CONSOLE \
> include/configs/trats2.h:       "console=" CONFIG_DEFAULT_CONSOLE \
> scripts/config_whitelist.txt:CONFIG_DEFAULT_CONSOLE

Looking at this again, CONFIG_DEFAULT_CONSOLE with "console=" doesn't 
look like a de facto standard to me:

$ ll include/configs/|wc -l
712

$ git grep CONFIG_DEFAULT_CONSOLE|grep define|wc -l
18

Only 18 out of +700 boards use it, and all of them ttySAC*, so probably 
just copy pasta.
CONFIG_DEFAULT_CONSOLE looks like a leftover, it's not used anywhere 
except in those config headers. Some boards even define it, but don't 
use it, making it effectively dead.

On the other hand, check "git grep 'console='". So why not just add the 
earlycon to bootargs directly so it works everywhere?

Regards,
Andre
Andre Heider Aug. 27, 2020, 5:25 a.m. UTC | #10
On 26/08/2020 17:10, Pali Rohár wrote:
> On Wednesday 26 August 2020 16:43:10 Andre Heider wrote:

>> Debian's boot.scr set "bootargs" to "... console=${console}".
>> So we end up with with kernel args "console=console=..." :)
> 
> So then also other U-Boot boards are broken in Debian...

fyi: I opened a bug for this:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=969070

Regards,
Andre
Pali Rohár Aug. 27, 2020, 10:29 a.m. UTC | #11
On Thursday 27 August 2020 06:51:57 Andre Heider wrote:
> On the other hand, check "git grep 'console='". So why not just add the
> earlycon to bootargs directly so it works everywhere?

The only useful thing about CONFIG_DEFAULT_CONSOLE and ${console} env is
to propagate earlycon argument to kernel. As console kernel argument is
already set via chosen/stdout in DTS.

Setting earlycon directly to ${bootargs} env does not work as basically
all distribution scripts set/overwrite ${bootargs} on their own.

So we need to store earlycon argument into some other uboot env and then
teach these distribution scripts to append that new uboot env into their
bootargs...

Or is there any other way?
Andre Heider Aug. 27, 2020, 2:34 p.m. UTC | #12
On 27/08/2020 12:29, Pali Rohár wrote:
> On Thursday 27 August 2020 06:51:57 Andre Heider wrote:
>> On the other hand, check "git grep 'console='". So why not just add the
>> earlycon to bootargs directly so it works everywhere?
> 
> The only useful thing about CONFIG_DEFAULT_CONSOLE and ${console} env is
> to propagate earlycon argument to kernel. As console kernel argument is
> already set via chosen/stdout in DTS.
> 
> Setting earlycon directly to ${bootargs} env does not work as basically
> all distribution scripts set/overwrite ${bootargs} on their own.
> 
> So we need to store earlycon argument into some other uboot env and then
> teach these distribution scripts to append that new uboot env into their
> bootargs...
> 
> Or is there any other way?

I don't know the answer to that, but as we've seen with $console, it's 
hard to get everyone on the same page.

But maybe it's not worth the hassle, since console works, and earlycon 
may only be interesting to ppl who know how to enable it anyway.

Regards,
Andre
diff mbox series

Patch

diff --git a/include/configs/mvebu_armada-37xx.h b/include/configs/mvebu_armada-37xx.h
index 6feceda757..b473072976 100644
--- a/include/configs/mvebu_armada-37xx.h
+++ b/include/configs/mvebu_armada-37xx.h
@@ -17,6 +17,7 @@ 
 
 #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, \
 					  115200, 230400, 460800, 921600 }
+#define CONFIG_DEFAULT_CONSOLE "console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000"
 
 /*
  * For booting Linux, the board info and command line data
@@ -99,6 +100,7 @@ 
 	"kernel_addr=0x7000000\0"	\
 	"kernel_addr_r=0x7000000\0"	\
 	"ramdisk_addr_r=0x8000000\0"	\
+	"console=" CONFIG_DEFAULT_CONSOLE "\0" \
 	BOOTENV
 
 #endif /* _CONFIG_MVEBU_ARMADA_37XX_H */