how to switch netconsole back to serial?
November 20, 2016 02: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 4.12.1, 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 02:20PM
Sorry, this should have gone to the uboot category...
Re: how to switch netconsole back to serial?
November 20, 2016 05: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 05: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
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: how to switch netconsole back to serial?
April 03, 2017 05: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 08:14PM by DonCharisma.
Re: how to switch netconsole back to serial?
September 22, 2017 03:02PM
Hello DonCharisma,
did You have any success sending the u-boot messages to both NC and serial?
After Power-on the first lines appear on my serial, then text goes to nc, then back to serial. Pretty annoying!
This is the first serial console text:
U-Boot 2016.05-tld-1 (Jun 12 2016 - 13:52:06 -0700)
ZyXEL NSA320 2-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  512 MiB
WARNING: Caches not enabled
NAND:  128 MiB
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
MV88E1318 PHY initialized on egiga0
Using egiga0 device
host 10.9.1.202 is alive
Then i get the following printed to nc (first line is my netcat invocation (on mac OSX10.11.6)
[517][dirk.Alubook17-2: /Users/dirk]$ nc  -v -v -v -k -l -u 6666

U-Boot 2016.05-tld-1 (Jun 12 2016 - 13:52:06 -0700)
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:  0

Reset IDE: Bus 0: OK Bus 1: OK
  Device 0: Model: WDC WD20EARS-00MVWB0 Firm: 51.0AB51 Ser#:  WD-WCAZA7723695
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 1907729.0 MB = 1863.0 GB (3907029168 x 512)
  Device 1: Model: WDC WD20EARS-00MVWB0 Firm: 51.0AB51 Ser#:  WD-WCAZA7719300
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 1907729.0 MB = 1863.0 GB (3907029168 x 512)

Partition Map for IDE device 0  --   Partition Type: DOS

Part	Start Sector	Num Sectors	UUID		Type
  1	2048      	6144000   	60d88db4-01	83 Boot
  2	6146048   	3900883120	60d88db4-02	83


Partition Map for IDE device 1  --   Partition Type: DOS

Part	Start Sector	Num Sectors	UUID		Type
  1	2048      	3907584   	7dbcc20b-01	83 Boot
  2	3909632   	3903119536	7dbcc20b-02	83
loading envs from ide 0 ...
147 bytes read in 50 ms (2 KiB/s)
importing envs ...
running scan_disk ...
Scan device ide

Reset IDE: Bus 0: OK Bus 1: OK
  Device 0: Model: WDC WD20EARS-00MVWB0 Firm: 51.0AB51 Ser#:  WD-WCAZA7723695
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 1907729.0 MB = 1863.0 GB (3907029168 x 512)
  Device 1: Model: WDC WD20EARS-00MVWB0 Firm: 51.0AB51 Ser#:  WD-WCAZA7719300
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 1907729.0 MB = 1863.0 GB (3907029168 x 512)
device ide 0:1
1 bytes read in 30 ms (0 Bytes/s)
Found bootable drive on ide 0
3821592 bytes read in 1378 ms (2.6 MiB/s)
7245696 bytes read in 2046 ms (3.4 MiB/s)
13691 bytes read in 29 ms (460.9 KiB/s)
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   Linux-4.12.1-kirkwood-tld-1
   Created:      2017-07-20   8:11:24 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3821528 Bytes = 3.6 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 01100000 ...
   Image Name:   initramfs-4.12.1-kirkwood-tld-1
   Created:      2017-07-24   0:18:23 UTC
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    7245632 Bytes = 6.9 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 01c00000
   Booting using the fdt blob at 0x1c00000


Starting kernel ...
after that all the following boot stuff is on the serial console.
This is my env:
root@publik2:~# fw_printenv
arcNumber=3956
bootargs=console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 orion_nand:1M(u-boot),512K(uboot_env),512K(key_store),512K(info),10M(etc),10M(kernel_1),48896K(rootfs1),10M(kernel_2),-(rootfs2)
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec
bootcmd_exec=run load_uimage; if run load_initrd; then if run load_dtb; then bootm $load_uimage_addr $load_initrd_addr $load_dtb_addr; else bootm $load_uimage_addr $load_initrd_addr; fi; else if run load_dtb; then bootm $load_uimage_addr - $load_dtb_addr; else bootm $load_uimage_addr; fi; fi
bootcmd_uenv=run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi; sleep 3
bootdelay=10
bootdev=ide
console=ttyS0,115200
devices=ide
disks=0 1
dtb_file=/boot/dts/kirkwood-nsa320.dtb
ethact=egiga0
ethaddr=b0:b2:dc:c9:a9:13
fileaddr=1c00000
filesize=357b
if_netconsole=ping $serverip
init_ide=ide reset
init_mmc=mmc rescan
init_usb=usb start
ipaddr=10.9.1.209
load_dtb_addr=0x1c00000
load_initrd_addr=0x1100000
load_uimage_addr=0x800000
mainlineLinux=yes
mtdids=nand0=orion_nand
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)
partition=nand0,2
preboot_nc=run if_netconsole start_netconsole
scan_disk=echo running scan_disk ...; scan_done=0; setenv scan_usb "usb start";  setenv scan_ide "ide reset";  setenv scan_mmc "mmc rescan"; for dev in $devices; do if test $scan_done -eq 0; then echo Scan device $dev; run scan_$dev; for disknum in $disks; do if test $scan_done -eq 0; then echo device $dev $disknum:1; if load $dev $disknum:1 $load_uimage_addr /boot/uImage 1; then scan_done=1; echo Found bootable drive on $dev $disknum; setenv device $disknum:1; setenv bootdev $dev; fi; fi; done; fi; done
scan_ide=ide reset
scan_mmc=mmc rescan
scan_usb=usb start
set_bootargs=setenv bootargs console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 $mtdparts $custom_params
start_netconsole=setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version;
uenv_addr=0x810000
uenv_import=echo importing envs ...; env import -t $uenv_addr $filesize
uenv_init_devices=setenv init_usb "usb start";  setenv init_ide "ide reset";  setenv init_mmc "mmc rescan"; for devtype in $devices; do run init_$devtype; done;
uenv_load=run uenv_init_devices; setenv uenv_loaded 0; for devtype in $devices;  do for disknum in 0; do run uenv_read_disk; done; done;
uenv_loaded=1
uenv_read=echo loading envs from $devtype $disknum ...; if load $devtype $disknum:1 $uenv_addr /boot/uEnv.txt; then setenv uenv_loaded 1; fi
uenv_read_disk=if test $devtype -eq mmc; then if $devtype part; then run uenv_read;  fi; else if $devtype part $disknum; then run uenv_read; fi;  fi
uimage=ext2load ide 0:1 0x800000 /boot/uImage
usb_boot=run load_dtb; run load_uimage; if run load_initrd; then bootm 0x800000 0x1100000 0x1c00000; else bootm 0x800000 - 0x1c00000; fi
usb_ready_retry=15
serverip=10.9.1.202
led_error=orange
led_exit=green off
led_init=green blinking
stdin=nc
stdout=nc
stderr=nc
load_uimage=ext2load ide 0:1 0x800000 /boot/uImage
load_initrd=ext2load ide 0:1 0x1100000 /boot/uInitrd
load_dtb=ext2load ide 0:1 0x1c00000 /boot/dts/kirkwood-nsa320.dtb
preboot=run preboot_nc
device=1:1
root@publik2:~#

I would love to have both (uboot and kernel) output AND input on both channels(nc and serial), if possible.
Any way of making that happen?



Edited 2 time(s). Last edit at 09/22/2017 03:20PM by shivahoj.
Re: how to switch netconsole back to serial?
September 22, 2017 04:59PM
Dirk,

If you use only one server to connect both, then you need 2 terminal sessions, one for netconsole and one for serial console.

If the serial console server is a different one from the netconsole server, then you would see both output alternatively going out to each server.


Remember that there is only 1 u-boot running. When netconsole is activated, the output switches to it. When netconsole stops, the output switches back to serial.

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



Edited 1 time(s). Last edit at 09/22/2017 05:02PM by bodhi.
Re: how to switch netconsole back to serial?
September 23, 2017 05:57AM
Hello, just to clarify:
i have a mac with a coolterm (serial terminal program) and an USB serial port hooked to the NSA320, and also a "regular" terminal window open, with an netcat that listens on UDP port 6666. Of course the mac IP matches the netcat destination IP. i set this up before powering up the NSA320.
Both program's windows are side by side, and i see messages appearing in both of them, one after another,
So right now the annoance is really minor, but i'd like to store away the NSA in some shelve, even in another room, and still get the whole boot log.
can i redirect ALL boot msgs to the netcat?


One thing i must say, as this forum has helped me learn so much about the inner workings of linux, the booting process, and the tight interlocking mechanisms of hard- and software:
I really appreciate the ongoing commitment from all users of this forum and all the qualified and swift responses.
I woudln't be where i am now if it wasn't for all of You, and especially bodhi's relentless efforts!!

2 Pieces NSA320 , u-boot 2016.05, debian 4.12.1, Several Mac and Linux boxes connected.
More into soldering than programming. Location:Hildesheim, Germany
Re: how to switch netconsole back to serial?
September 23, 2017 05:13PM
> So right now the annoance is really minor, but i'd
> like to store away the NSA in some shelve, even in
> another room, and still get the whole boot log.
> can i redirect ALL boot msgs to the netcat?

In that case, I'd suggest you disconnect serial console from the NSA320. And use netconsole only for monitoring. That way the whole log can be seen in netconsole.

Set up Debian to access netconsole as described here:
https://forum.doozan.com/read.php?2,9522

And only when you have a problem that can't be solved using netconsole, then connect serial console. It is simpler than trying to redirect the log (the rootfs must be messed with to make this happen).

Usually, serial console is the fallback way to solve problem, redirect its output might cause headache later when the network is down and you have to connect serial console to fix it.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
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: