Welcome! Log In Create A New Profile

Advanced

how to switch netconsole back to serial?

Posted by shivahoj 
how to switch netconsole back to serial?
November 20, 2016 03:18PM
Hello, i have two nsa320's, that i both want to update to latest u-Boot.
The process went fine on one NSA, but on the other one i have some issues:
Right now there are no harddrives installed, but i could take the HD containing the rootfs from the other working NSA.
Unfortunately, all stdin, stout, stderr are set to nc,(which works fine). But i need to have it set to serial to be able to kwboot the latest u-boot. kwboot-updating worked fine on my other NSA(see my signature)
Below is my environment:
U-Boot 2015.10-tld-1 (Nov 06 2015 - 16:12:51 -0800)
ZyXEL NSA320 2-Bay Power Media Server
gcc (Debian 4.9.2-10) 4.9.2
GNU ld (GNU Binutils for Debian) 2.25
Hit any key to stop autoboot:  9
NSA320> print
print
arcNumber=3956
baudrate=115200
boot_sata1=mw 0x800000 0 1; setenv bootargs console=ttyS0,115200 root=/dev/sda1 rootdelay=10 $mtdparts; ide reset; ext2load ide 0:1 0x800000 /boot/uImage; ext2load ide 0:1 0x01100000 /boot/uInitrd; bootm 0x00800000 0x01100000
boot_sata2=mw 0x800000 0 1; setenv bootargs console=ttyS0,115200 root=/dev/sdb1 rootdelay=10 $mtdparts; ide reset; ext2load ide 1:1 0x800000 /boot/uImage; ext2load ide 1:1 0x01100000 /boot/uInitrd; bootm 0x00800000 0x01100000
bootcmd=run boot_sata1; run boot_sata2; run bootcmd_usb; usb stop; run bootcmd_rescue; reset
bootcmd_usb=run usb_init; run usb_load_uimage; run set_bootargs_usb; run usb_boot;
bootdelay=10
console=ttyS0,115200
ethact=egiga0
ethaddr=b0:b2:dc:ee:d4:f2
if_netconsole=ping $serverip
ipaddr=10.9.1.208
load_dtb=ext2load usb 0:1 0x1c00000 /boot/dts/kirkwood-nsa320.dtb
load_initrd=ext2load usb 0:1 0x1100000 /boot/uInitrd
load_uimage=ext2load usb 0:1 0x800000 /boot/uImage
mainlineLinux=yes
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:1M(u-boot),512K(uboot_env),512K(key_store),512K(info),10M(etc),10M(kernel_1),48896K(rootfs1),10M(kernel_2),-(rootfs2)
nc_ready=1
ncip=10.9.1.200
netmask=255.255.255.0
partition=nand0,2
preboot=run preboot_nc
preboot_nc=setenv nc_ready 0; for pingstat in 1 2 3 4 5; do; sleep 1; if run if_netconsole; then setenv nc_ready 1; fi; done; if test $nc_ready -eq 1; then run start_netconsole; fi
serverip=10.9.1.200
set_bootargs_usb=setenv bootargs console=$console root=$usb_root rootdelay=$usb_rootdelay rootfstype=$usb_rootfstype $mtdparts
start_netconsole=setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version;
stderr=nc
stdin=nc
stdout=nc
usb_boot=run load_dtb; run load_uimage; if run load_initrd; then bootm 0x800000 0x1100000 0x1c00000; else bootm 0x800000 - 0x1c00000; fi
usb_device=0:1
usb_init=usb start
usb_load_uimage=mw 0x800000 0 1; ext2load usb $usb_device 0x800000 /boot/uImage
usb_root=LABEL=USBROOT
usb_rootdelay=10
usb_rootfstype=ext2

Environment size: 2095/131068 bytes
NSA320>
From what i understand i pings my netcat server(10.9.1.200) up to five times, if it responds,it runs start_netconsole.
First i tried to switch the netconsole to serial like this:
 setenv start_netconsole'setenv ncip $serverip; setenv bootdelay 5;setenv stdin serial;setenv stdout serial;setenv stderr serial; version;'
but to no avail,when i executed this command, it just printed it(without error), but the environment stays unchanged.
Then i did:
NSA320> setenv serverip 10.9.1.201
setenv serverip 10.9.1.201
saveenv
Saving Environment to NAND...
Erasing NAND...
Erasing at 0xc0000 -- 100% complete.
Writing to NAND... OK
NSA320> reset
reset
Now it seems i've locked myself out, since nc doesnt come up(10.9.1.201 isnt pingable right now), and also the serial console doesnt react. The NSA is in a reboot loop.
Of course i could help myself by setting up my machine to the 10.9.1.201 address, but thats not the point.
What did i do wrong?
Whats the difference between serverip and ncip ?
Which other / better ways are there to set the stdin/-out/-err to serial?
should i maybe opt to install the new uboot from a working linux system?

2 Pieces NSA320 , u-boot 2016.05, debian with Kernel 4.8.3, Several Mac and Linux boxes connected.
More into soldering than programming. Location:Hildesheim, Germany
Re: how to switch netconsole back to serial?
November 20, 2016 03:20PM
Sorry, this should have gone to the uboot category...
Re: how to switch netconsole back to serial?
November 20, 2016 06:33PM
I'll try to help, but keep in mind that I'm no expert and I don't have a NSA320 (not that I think that part matters).

shivahoj Wrote:
-------------------------------------------------------
> Whats the difference between serverip and ncip ?

This one is easy - nothing. Well not really, but one gets set to the other:
serverip=10.9.1.200
This sets the value of serverip to 10.9.1.200. It gets used in the following line:
start_netconsole=setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version;
So in this line, the value of ncip gets set to the value of serverip. You get the value of an environment variable (which serverip and ncip both are) by preceding the variable name with a $:
setenv ncip $serverip
This sets the value of ncip to 10.9.1.200

> Which other / better ways are there to set the stdin/-out/-err to serial?

I think your problem lies in these lines:
stderr=nc
stdin=nc
stdout=nc
I think you've permanently assigned stderr/in/out to netconsole. The point of
start_netconsole=setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version;
is to only set stdin and stdout to nc if you're using netconsole

Now this is where my knowledge gets a little shaky. I'm not sure how to unset those environment variables and I'm not able to experiment right now. I think to erase a variable you just do:
setenv stdin
but I'm not sure. You'll want to try it and then print out your uboot environment again to ensure they're gone before you do the saveenv.

Hope this helps and doesn't screw up anything!
-JT
Re: how to switch netconsole back to serial?
November 20, 2016 06:57PM
shivahoj ,

JT has the right idea ... almost!

This problem due to the confusion that you had about the serverip and ipadr.

This is the NSA320 IP address
ipaddr=10.9.1.208

This is the netconsole server (where you run nc)
serverip=10.9.1.200


So since you have done this

NSA320> setenv serverip 10.9.1.201
setenv serverip 10.9.1.201
saveenv
Saving Environment to NAND...
Erasing NAND...
Erasing at 0xc0000 -- 100% complete.
Writing to NAND... OK
NSA320> reset
reset

Now you need to set the netconsole server static IP to 10.9.1.201.

And run nc at that box (which now matches the serverip=10.9.1.201)
nc -lup 6666 10.9.1.208 6666

After booted into Debian, you can proceed to set the console back to serial and clear netconsole booting:
fw_setenv stderr serial
fw_setenv stdin serial
fw_setenv stdout serial
fw_setenv preboot

Aftter this serial console should be back. And in the future you can enable it by

fw_setenv preboot 'run preboot_nc'

-bodhi
===========================
Wiki
latest Kirkwood kernel builds and rootfs
latest u-boot-kirkwood builds
latest Oxnas kernel builds and rootfs
latest u-boot-oxnas builds
latest MVEBU Armada kernel builds and rootfs
U-Boot & Kernel Booting process
bodhi's u-boot GitHub
bodhi's corner
Re: how to switch netconsole back to serial?
April 03, 2017 06:46PM
Sorry to dig up an old thread, but ...

It seems when starting netconcole as "preboot" in uboot, serial console is disconnected, which as I'm prefering serial these days I lost all the messages on serial coming from uboot. But I do get the serial console back when kernel starts.

My solution was to set the uboot variable "preboot" to empty (ie blank), now I don't have netconsole, but I am getting a full serial console including uboot messages.

Just wondered whether it's possible with uboot to tie the standard pipes (stdin, stdout, stderr) to two place concurrently ... ie that serial console is still connected ... It's certainly possible in bash, but I don't where to find syntax (or if it's possible) in uboot ... any ideas ?

EDIT :

It looks like console multiplexing is included in uboot, but I was unable to get both netcat and serial to both display what's coming out of uboot ... my idea :

fw_setenv start_netconsole 'setenv ncip $serverip; setenv bootdelay 5; setenv stdin serial,nc; setenv stdout serial,nc; setenv stderr serial,nc; version;'

Don Charisma ... because anything is possible with Charisma

My blog - http://DonCharisma.org
Our commercial site - http://DonCharisma.com



Edited 1 time(s). Last edit at 04/03/2017 09:14PM by DonCharisma.
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: