Welcome! Log In Create A New Profile

Advanced

Configure uboot to leave serial console ttyS0 to Linux

Posted by serialDeBricker 
Configure uboot to leave serial console ttyS0 to Linux
August 12, 2019 01:27PM
Hi,

I have been a regular reader on this forum for many years and might even have posted something here some years ago. But I don't remeber clearly. Anyway: Big thanks to Bodhi and other active members of this board to keep up the good work and provide constant updates for uboot, kernel and rootfs! Very much appreciated!

Back around 2010/2011 I was able to get a couple of different kirkwood devices and as far as I know I haven't bricked a single one of them yet... Fingers crossed and they will live another couple of years.

My question of this thread is: Can Linux take over the serial console that is built into the PCB of a Dockstar?

Normally, uboot grabs the serial console and does not release it. This is the result when trying to access the serial console from the Debian on the Dockstar:

#cu -l /dev/ttyS0 -s 115200
cu: open (/dev/ttyS0): Permission denied
cu: /dev/ttyS0: Line in use


Of course people can say: Why don't you grab an USB-FTDI-Adapter and plug it into the Dockstar if you want to create a serial connection? Of course I could, but I would prefer to use the built-in.

To avoid total brickage of my Dockstar I still could have netconsole enabled when I disable the classic serial console for uboot - that's what I assume at the moment.

I googled a bit and only found this: https://stackoverflow.com/questions/34356844/how-to-disable-serial-consolenon-kernel-in-u-boot

I tried to set bootdelay to value -2 and this was only possible for me using this trick:
fw_setenv --script myFile.txt
But I realized that the bootdelay parameter is also used within the netconsole scripts.

Then I played with some values on a Dockstar where I have the netconsole enabled but wasn't really successful. So I would like to ask you for help. Was my question maybe discussed at some point in the past and I just didn't find it here on the forum?

I don't need the serial console untouched by uboot - I only need uboot to release it at some point so that it is available later when Linux is booted. Anyone? Thanks in advance!
Re: Configure uboot to leave serial console ttyS0 to Linux
August 12, 2019 02:24PM
serialDeBricker,

>
> My question of this thread is: Can Linux take over
> the serial console that is built into the PCB of a
> Dockstar?

Yes. It works the same way in u-boot as well as in Debian or any other Linux distro.

For example, on Debian using picocom (same as minicom). The serial console should work the whole time upon booting the box. And you will be able to login through serial console.

picocom --b 115200 --f n --p n --d 8 /dev/ttyUSB0'

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Configure uboot to leave serial console ttyS0 to Linux
August 12, 2019 03:18PM
Thank you Bodhi, I'm playing with picocom now.

I'm just not sure if I described my project in a good way: I would like to connect a different device (in my case an Arduino) to the serial pin header of the Dockstar and then communicate with the Arduino. So the "master" would be the Dockstar connecting to the serial port of the Arduino. On the Arduino I have an application running that listens to commands via serial console.

When I use picocom in the way you have suggested I still communicate with the Dockstars console, right?
Re: Configure uboot to leave serial console ttyS0 to Linux
August 12, 2019 04:38PM
serialDeBricker,

I see what you meant. I have not tried running this configuration before.

But I think it is possible.

You could tell u-boot to use netconsole only, and that basically these variables (which are default to serial initially).
stderr=nc
stdin=nc
stdout=nc
If you are running my 2017.07-tld-1 u-boot then these are set temporarily by preboot_nc, which calls
preboot_nc=run if_netconsole start_netconsole
start_netconsole=setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version;

And you should change the bootargs temporarily in netconsole before booting to tell the kernel not to use ttyS0 for its console:
set_bootargs=setenv bootargs console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 $mtdparts $custom_params
to
setenv set_bootargs 'setenv bootargs root=LABEL=rootfs rootdelay=10 $mtdparts $custom_params'

And then you will SSH in as usual, then try the picocom command.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Configure uboot to leave serial console ttyS0 to Linux
August 13, 2019 03:05PM
Hi Bodhi,

Thank you for your very fast replies. I am playing with u-boot parameters at the moment. I tried implementing your suggestions but it doesn't silence the serial console.

I'm using your currently latest u-boot:
U-Boot 2017.07-tld-1 (Oct 24 2017 - 22:32:36 -0700)

Setting the three env-vars to nc doesn't seem to change anything:
stderr=nc
stdin=nc
stdout=nc

On the serial console I still get:
U-Boot 2017.07-tld-1 (Oct 24 2017 - 22:32:36 -0700)
Seagate FreeAgent DockStar

SoC:   Kirkwood 88F6281_A0
DRAM:  128 MiB
WARNING: Caches not enabled
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
88E1116 Initialized on egiga0
....

My test scenario is as follows: I have three terminals open on my Ubuntu box. Terminal #1 shows the serial console output, terminal #2 shows the netconsole output, terminal #3 I use for ssh into the dockstar. After changing u-boot vars via fw_setenv I do a reboot via "reboot". Maybe I should test a boot after a real shutdown.

I will continue to play and I'm also considering to try to compile my own u-boot - but I don't have the time for that at the moment.

Besides that I was thinking that the commando "fw_setenv --script xyz" could be useful for scripting a configuration script to automatically fill the u-boot environment with customized vars. I was thinking of a convenience script for users who want to enable or disable netconsole but don't want to get their hands dirty.
Re: Configure uboot to leave serial console ttyS0 to Linux
August 13, 2019 05:17PM
serialDeBricker,

1. I think I started to understand what you are trying to do :)

The setup I've suggested only silences the serial console after the netconsole starts, and also silences the serial console after that during booting kernel into Debian.

From what you showed above you also want u-boot to not grabing serial console right from starting? The fact that it is not is causing some misleading data to trigger the Arduino end?

U-boot always defaults to serial initially, only when you get to preboot phase, that you will see the console switch to nc.

Quote

My test scenario is as follows: I have three terminals open on my Ubuntu box. Terminal #1 shows the serial console output, terminal #2 shows the netconsole output, terminal #3 I use for ssh into the dockstar. After changing u-boot vars via fw_setenv I do a reboot via "reboot". Maybe I should test a boot after a real shutdown.

Does Linux print out kernel booting log to serial console, even with bootargs contain no console parameter like I suggested for set_bootargs env?

Quote

setenv set_bootargs 'setenv bootargs root=LABEL=rootfs rootdelay=10 $mtdparts $custom_params'


2.

Quote

Besides that I was thinking that the commando "fw_setenv --script xyz" could be useful for scripting a configuration script to automatically fill the u-boot environment with customized vars. I was thinking of a convenience script for users who want to enable or disable netconsole but don't want to get their hands dirty.

The above is similar to what I have implemented for uEnv.txt. But I avoided hard coding this in preboot, because it is is risky for beginners to change this behavior.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 08/13/2019 05:19PM by bodhi.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: