Welcome! Log In Create A New Profile

Advanced

Setting GPIOs in serial console (Kirkwood SoCs)

Posted by bodhi 
Setting GPIOs in serial console (Kirkwood SoCs)
March 18, 2021 09:41PM
GPIOs are memory mapped. Mavell boards use GPIOs to control peripherals (eg. power off, turn on LED, power up HDDs and USBs..). And also MPPs (multiplexing pins). A pin could be configured for one of multiple functions. See Reference Manual Marvell_FS_88F6180_9x_6281_OpenSource.pdf.

Power up the box, interrupt serial console. At the u-boot prompt.

First, dump the memory content of these 2 memory banks: GPIO0 address 0xF1010100 and GPIO1 address 0xF1010140

There are 32 GPIOs in each bank.
md.l 0xF1010100 1
md.l 0xF1010140 1

In the below example, we will set USB Power GPIO on the a Kirkwood box: for example GPIO 21. Note that each Kirkwood box likely has a different GPIO assigned to this USB Power, event though they are all in the same Kirkwodd SoCs family (the MPP pins are multiplex).

So we use the hex output of the first command (because GPIO 21 is in the 1st bank, GPIO0). We'll call it xxx.
md.l 0xF1010100 1

And then modify xxx to turn on the bit 21 (right to left, 0 to 31).

Set that bit 21 to 1. Do this temporarily on a notepad, and the result is yyy (in hex). See the end of this post for the bit mask layout in binary.

And then write the result yyy back to the memory address 0xF1010100

mw.l 0xF1010100 yyy

======

This example shows the layout of the bit pattern. The arrow below points to GPIO 29 being set.

GPIO0:

xxx = 0000 0000 0100 0010 0000 0000 0000 0000
yyy = 0010 0000 0100 0010 0000 0000 0000 0000
        ^

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



Edited 4 time(s). Last edit at 03/05/2023 06:28PM by bodhi.
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 19, 2021 09:29AM
I have done this:
Hit any key to stop autoboot:  0
NSA320>> md.l 0xF1010100 1
f1010100: 10029000    ....
NSA320>> mw.l 0xF1010100 10229000
NSA320>> usb start
(Re)start USB...
USB:   scanning bus for devices... 2 USB Device(s) found
       scanning bus for storage devices... 0 Storage Device(s) found
NSA320>> md.l 0xF1010100 1
f1010100: 10229000
NSA320>> ext2ls usb 0:1 /
** Bad partition - usb 0:1 **
NSA320>> usb reset
(Re)start USB...
USB:   scanning bus for devices... 1 USB Device(s) found
       scanning bus for storage devices... 0 Storage Device(s) found
NSA320>> md.l 0xF1010100 1
f1010100: 10229000    ..".
NSA320>> ext2ls usb 0:1 /
** Bad partition - usb 0:1 **

So I checked whether a start or reset did not change the gpio 21 by displaying it with md.l and checked with ext2ls if it could read the partition (ext3), but it is still not working.

My calculation is right I think, it is basically (10029000 + 1<<21).

It should not affect it, but I am going to try it anyway and turn on gpio 15 as well (usb led), see if that will help. (EDIT: gpio 15 was already on, but the LED was not?!, is there some main switch in a gpio somewhere?)



Edited 6 time(s). Last edit at 03/19/2021 10:18AM by bandicoot.
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 19, 2021 03:50PM
scanning bus for storage devices... 0 Storage Device(s) found

It could be either: the USB power is not on, or this specific USB thumb drive is not recognized by this u-boot.

=======

It's been a long time ago that we worked on this box, it came back to me now certain GPIO on this box also needs to be controlled with clock (unlike most other Kirkwood boxes).


See the Wiki thread for how to set GPIO in Linux

https://forum.doozan.com/read.php?2,23630

Quote

Sensors & Fan & WOL

OWFSPlug : 1-Wire File System + Motion Detection Software in a NAND Package
OWFS & Motion Detection (external link)
How to control GPIO in Linux userspace for GPIO-enable fan
Zyxel NSA 310S/320S/325/326 CPU Temperature and Fan Speed reading
Zyxel NAS326 WOL
Zyxel NAS326 Auto-Power Up
Zyxel NAS326 WOL and Auto-Power Up I2C commands
Zyxel NSA320 Auto-Power Up

In Debian, try poking GPIO 21 to see if it is the correct one.

==========

Somewhere in the Debian working thread, we have specific example for this NSA320 box (I'll see if I can find it, or you can do advance search for all date).

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



Edited 1 time(s). Last edit at 03/19/2021 08:38PM by bodhi.
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 20, 2021 05:34PM
I am getting this:
root@NSA320:~# /bin/echo 21 > /sys/class/gpio/export
/bin/echo: write error: Device or resource busy

If I read the link you gave well then it looks like gpio21 is not defined in the dts file, i am not able to write to this file. Do I have to create a .dts file somehow? I have looked for a .dts file that looks relevant for the NSA320, but I could not find one.
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 20, 2021 06:35PM
bandicoot,

Perhaps now is the appropriate time to install new u-boot and solve your problems once for all?

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 21, 2021 08:50AM
Would I install the latest then?:
2017.07 U-Boot Kirkwood - GoFlexNet, GoFlexHome, PogoE02, Dockstar, iConnect, NetgearStora, PogoV4/Mobile, Sheevaplug, NSA325, NSA320, NSA310S, NSA320S, NSA310, HP T5325, Dreamplug ==> https://forum.doozan.com/read.php?3,12381
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 21, 2021 04:19PM
> Would I install the latest then?:
> 2017.07 U-Boot Kirkwood - GoFlexNet, GoFlexHome,
> PogoE02, Dockstar, iConnect, NetgearStora,
> PogoV4/Mobile, Sheevaplug, NSA325, NSA320,
> NSA310S, NSA320S, NSA310, HP T5325, Dreamplug ==>
> https://forum.doozan.com/read.php?3,12381

Right, and remember to run kwboot witht the new u-boot image first to make sure there is a rescue mechanism, before starting the installation.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 22, 2021 05:33PM
The kwboot worked, I tried a boot as well, but that did not work because I had two rootfs's, one on ide and one on usb, it did find the usb-stick though ;), I only had to add -b to kwboot, because I used 64 version within fedora:
[root@localhost-live kwboot-tool]# ./kwboot -t -B 115200 /dev/ttyUSB0 -b uboot.2017.07-tld-1.nsa320.mtd0.kwb -p 
Sending boot message. Please reboot the target...\
Sending boot image...
  0 % [......................................................................]
  1 % [......................................................................]
  3 % [......................................................................]
  5 % [......................................................................]
  6 % [......................................................................]
  8 % [......................................................................]
 10 % [......................................................................]
 11 % [......................................................................]
 13 % [......................................................................]
 15 % [......................................................................]
 17 % [......................................................................]
 18 % [......................................................................]
 20 % [......................................................................]
 22 % [......................................................................]
 23 % [......................................................................]
 25 % [......................................................................]
 27 % [......................................................................]
 29 % [......................................................................]
 30 % [......................................................................]
 32 % [......................................................................]
 34 % [......................................................................]
 35 % [......................................................................]
 37 % [......................................................................]
 39 % [......................................................................]
 41 % [......................................................................]
 42 % [......................................................................]
 44 % [......................................................................]
 46 % [......................................................................]
 47 % [......................................................................]
 49 % [......................................................................]
 51 % [......................................................................]
 53 % [......................................................................]
 54 % [......................................................................]
 56 % [......................................................................]
 58 % [......................................................................]
 59 % [......................................................................]
 61 % [......................................................................]
 63 % [......................................................................]
 64 % [......................................................................]
 66 % [......................................................................]
 68 % [......................................................................]
 70 % [......................................................................]
 71 % [......................................................................]
 73 % [......................................................................]
 75 % [......................................................................]
 76 % [......................................................................]
 78 % [......................................................................]
 80 % [......................................................................]
 82 % [......................................................................]
 83 % [......................................................................]
 85 % [......................................................................]
 87 % [......................................................................]
 88 % [......................................................................]
 90 % [......................................................................]
 92 % [......................................................................]
 94 % [......................................................................]
 95 % [......................................................................]
 97 % [......................................................................]
 99 % [....................................]
[Type Ctrl-\ + c to quit]


U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:46:11 -0700)
ZyXEL NSA320 2-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  512 MiB
WARNING: Caches not enabled
NAND:  128 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   egiga0
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0 
NSA320> printenv
arcNumber=3956
baudrate=115200
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec; reset
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
bootdelay=10
bootdev=usb
console=console=ttyS0,115200
device=0:1
devices=usb ide
disks=0 1 2 3
dtb_file=/boot/dts/kirkwood-nsa320.dtb
ethact=egiga0
ethaddr=52:3b:20:9c:11:51
if_netconsole=ping $serverip
ipaddr=192.168.0.231
led_error=orange blinking
led_exit=green off
led_init=green blinking
load_dtb=echo loading DTB $dtb_file ...; load $bootdev $device $load_dtb_addr $dtb_file
load_dtb_addr=0x1c00000
load_initrd=echo loading uInitrd ...; load $bootdev $device $load_initrd_addr /boot/uInitrd
load_initrd_addr=0x1100000
load_uimage=echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage
load_uimage_addr=0x800000
mainlineLinux=yes
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:0x100000(uboot),0x80000(stock_uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(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
serverip=192.168.0.220
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;
stderr=serial
stdin=serial
stdout=serial
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_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
usb_ready_retry=15

Environment size: 3016/131068 bytes

NSA320> boot
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 3 USB Device(s) found
       scanning usb for storage devices... 
Use USB retry period from the environment: 15 second(s)
1 Storage Device(s) found

Reset IDE: Bus 0: OK Bus 1: .........OK 
  Device 0: Model: SAMSUNG HD103UJ  Firm: 1AA01113 Ser#: S13PJ1BQ731099
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 953869.7 MB = 931.5 GB (1953525168 x 512)
  Device 1: Model: ST4000DM005-2DP166 Firm: 0001 Ser#: ZDH0CSKF
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 3815447.8 MB = 3726.0 GB (7814037168 x 512)

Partition Map for USB device 0  --   Partition Type: EFI

Part	Start LBA	End LBA		Name
	Attributes
	Type GUID
	Partition GUID
  1	0x00000800	0x00ef7fdd	""
	attrs:	0x0000000000000000
	type:	0fc63daf-8483-4772-8e79-3d69d8477de4
	type:	linux
	guid:	4b7abcb5-ab7a-e54d-bcb9-3dca1ef2c384

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0

## Unknown partition table type 0
loading envs from usb 0 ...
** File not found /boot/uEnv.txt **

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

Part	Start Sector	Num Sectors	UUID		Type
  1	2048      	1953523120	0fb90fb8-01	83


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

Part	Start LBA	End LBA		Name
	Attributes
	Type GUID
	Partition GUID
  1	0x00000800	0x000f3fff	"mitraswap"
	attrs:	0x0000000000000000
	type:	0657fd6d-a4ab-43c4-84e5-0933c84b4f4f
	type:	swap
	guid:	0ced66c6-0d6d-4333-bff6-d64b37dce7f8
  2	0x000f4000	0x1d1c0b7ff	"eexxtt44"
	attrs:	0x0000000000000000
	type:	ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
	type:	data
	guid:	8406160e-0e36-4e5c-8d1f-840a7e4cf754
running scan_disk ...
Scan device usb
device usb 0:1
1 bytes read in 692 ms (0 Bytes/s)
Found bootable drive on usb 0
loading uImage ...
4976833 bytes read in 1077 ms (4.4 MiB/s)
loading uInitrd ...
9713936 bytes read in 1087 ms (8.5 MiB/s)
loading DTB /boot/dts/kirkwood-nsa320.dtb ...
13153 bytes read in 2722 ms (3.9 KiB/s)
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   Linux-5.2.9-kirkwood-tld-1
   Created:      2021-03-11  14:28:13 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4976769 Bytes = 4.7 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 01100000 ...
   Image Name:   initramfs-5.2.9-kirkwood-tld-1
   Created:      2019-08-25   2:22:50 UTC
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    9713872 Bytes = 9.3 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 01c00000
   Booting using the fdt blob at 0x1c00000
   Loading Kernel Image ... OK
   Loading Ramdisk to 0f6bc000, end 0ffff8d0 ... OK
   Loading Device Tree to 0f6b5000, end 0f6bb360 ... OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
[    0.000000][    T0] Booting Linux on physical CPU 0x0
[    0.000000][    T0] Linux version 5.2.9-kirkwood-tld-1 (root@tldDebian) (gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)) #1 PREEMPT Sat Aug 17 15:00:56 PDT 2019
[    0.000000][    T0] CPU: Feroceon 88FR131 [56251311] revision 1 (ARMv5TE), cr=0005397f
[    0.000000][    T0] CPU: VIVT data cache, VIVT instruction cache
[    0.000000][    T0] OF: fdt: Machine model: Zyxel NSA320
[    0.000000][    T0] Memory policy: Data cache writeback
[    0.000000][    T0] Built 1 zonelists, mobility grouping on.  Total pages: 130048
[    0.000000][    T0] Kernel command line: console=ttyS0,115200
[    0.000000][    T0] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000][    T0] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000][    T0] Memory: 504168K/524288K available (9216K kernel code, 868K rwdata, 3400K rodata, 1024K init, 301K bss, 20120K reserved, 0K cma-reserved)
[    0.000000][    T0] random: get_random_u32 called from cache_alloc_refill+0x38c/0x928 with crng_init=0
[    0.000000][    T0] rcu: Preemptible hierarchical RCU implementation.
[    0.000000][    T0] 	Tasks RCU enabled.
[    0.000000][    T0] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000][    T0] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000][    T0] clocksource: orion_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 9556302233 ns
[    0.000009][    T0] sched_clock: 32 bits at 200MHz, resolution 5ns, wraps every 10737418237ns
[    0.000047][    T0] Switching to timer-based delay loop, resolution 5ns
[    0.000796][    T0] Console: colour dummy device 80x30
[    0.000847][    T0] Calibrating delay loop (skipped), value calculated using timer frequency.. 400.00 BogoMIPS (lpj=2000000)
[    0.000873][    T0] pid_max: default: 32768 minimum: 301
[    0.001252][    T0] LSM: Security Framework initializing
[    0.001436][    T0] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.001464][    T0] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.002396][    T0] *** VALIDATE proc ***
[    0.002668][    T0] *** VALIDATE cgroup1 ***
[    0.002694][    T0] *** VALIDATE cgroup2 ***
[    0.002795][    T0] CPU: Testing write buffer coherency: ok
[    0.004464][    T1] Setting up static identity map for 0x100000 - 0x100058
[    0.004785][    T1] mvebu-soc-id: MVEBU SoC ID=0x6281, Rev=0x3
[    0.005066][    T1] rcu: Hierarchical SRCU implementation.
[    0.008262][    T1] devtmpfs: initialized
[    0.014241][    T1] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.014274][    T1] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.014516][    T1] xor: measuring software checksum speed
[    0.110113][    T1]    arm4regs  :  1047.600 MB/sec
[    0.210077][    T1]    8regs     :   654.000 MB/sec
[    0.310074][    T1]    32regs    :   950.800 MB/sec
[    0.310094][    T1] xor: using function: arm4regs (1047.600 MB/sec)
[    0.310115][    T1] prandom: seed boundary self test passed
[    0.314292][    T1] prandom: 100 self tests passed
[    0.314304][    T1] pinctrl core: initialized pinctrl subsystem
[    0.315724][    T1] NET: Registered protocol family 16
[    0.316171][    T1] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.316971][    T1] audit: initializing netlink subsys (disabled)
[    0.318217][   T14] audit: type=2000 audit(0.310:1): state=initialized audit_enabled=0 res=1
[    0.318337][    T1] cpuidle: using governor ladder
[    0.318413][    T1] cpuidle: using governor menu
[    0.318862][    T1] Feroceon L2: Enabling L2
[    0.318912][    T1] Feroceon L2: Cache support initialised.
[    0.325204][    T1] No ATAGs?
[    2.560054][    C0] random: fast init done
[    6.251939][   T71] alg: No test for lzo-rle (lzo-rle-generic)
[    6.252301][   T73] alg: No test for lzo-rle (lzo-rle-scomp)
[    6.430652][    T1] raid6: int32x8  gen()   128 MB/s
[    6.600319][    T1] raid6: int32x8  xor()    86 MB/s
[    6.770264][    T1] raid6: int32x4  gen()   129 MB/s
[    6.940242][    T1] raid6: int32x4  xor()    84 MB/s
[    7.110155][    T1] raid6: int32x2  gen()   133 MB/s
[    7.280192][    T1] raid6: int32x2  xor()    94 MB/s
[    7.450399][    T1] raid6: int32x1  gen()   100 MB/s
[    7.620407][    T1] raid6: int32x1  xor()    69 MB/s
[    7.620418][    T1] raid6: using algorithm int32x2 gen() 133 MB/s
[    7.620427][    T1] raid6: .... xor() 94 MB/s, rmw enabled
[    7.620435][    T1] raid6: using intx1 recovery algorithm
[    7.620689][    T1] vgaarb: loaded
[    7.621197][    T1] SCSI subsystem initialized
[    7.621692][    T1] usbcore: registered new interface driver usbfs
[    7.621756][    T1] usbcore: registered new interface driver hub
[    7.621850][    T1] usbcore: registered new device driver usb
[    7.622028][    T1] pps_core: LinuxPPS API ver. 1 registered
[    7.622040][    T1] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    7.622067][    T1] PTP clock support registered
[    7.623279][    T1] clocksource: Switched to clocksource orion_clocksource
[    8.654441][    T1] VFS: Disk quotas dquot_6.6.0
[    8.654537][    T1] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    8.664374][    T1] NET: Registered protocol family 2
[    8.665191][    T1] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes)
[    8.665228][    T1] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    8.665286][    T1] TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
[    8.665339][    T1] TCP: Hash tables configured (established 4096 bind 4096)
[    8.665436][    T1] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    8.665464][    T1] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    8.665694][    T1] NET: Registered protocol family 1
[    8.666332][    T1] RPC: Registered named UNIX socket transport module.
[    8.666347][    T1] RPC: Registered udp transport module.
[    8.666355][    T1] RPC: Registered tcp transport module.
[    8.666364][    T1] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    8.666378][    T1] PCI: CLS 0 bytes, default 32
[    8.666699][    T1] NetWinder Floating Point Emulator V0.97 (double precision)
[    8.667824][    T1] Initialise system trusted keyrings
[    8.667878][    T1] Key type blacklist registered
[    8.668107][    T1] workingset: timestamp_bits=30 max_order=17 bucket_order=0
[    8.668195][    T1] zbud: loaded
[    8.669279][    T1] NFS: Registering the id_resolver key type
[    8.669327][    T1] Key type id_resolver registered
[    8.669337][    T1] Key type id_legacy registered
[    8.669357][    T1] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    8.669374][    T1] Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
[    8.669671][    T1] jffs2: version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
[    8.669907][    T1] fuse: init (API version 7.31)
[    8.670287][    T1] orangefs_debugfs_init: called with debug mask: :none: :0:
[    8.670484][    T1] orangefs_init: module version upstream loaded
[    8.670497][    T1] SGI XFS with ACLs, security attributes, realtime, scrub, no debug enabled
[    8.673700][    T1] async_tx: api initialized (async)
[    8.673721][    T1] Key type asymmetric registered
[    8.673731][    T1] Asymmetric key parser 'x509' registered
[    8.673789][    T1] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 246)
[    8.675189][    T1] kirkwood-pinctrl f1010000.pin-controller: registered pinctrl driver
[    8.677152][    T1] mvebu-pcie mbus@f1000000:pcie@82000000: PCI host bridge to bus 0000:00
[    8.677175][    T1] pci_bus 0000:00: root bus resource [bus 00-ff]
[    8.677191][    T1] pci_bus 0000:00: root bus resource [mem 0xe0000000-0xefffffff]
[    8.677206][    T1] pci_bus 0000:00: root bus resource [io  0x1000-0xeffff]
[    8.677332][    T1] pci 0000:00:01.0: [11ab:6281] type 01 class 0x060400
[    8.677373][    T1] pci 0000:00:01.0: reg 0x38: [mem 0x00000000-0x000007ff pref]
[    8.678904][    T1] PCI: bus0: Fast back to back transfers disabled
[    8.678932][    T1] pci 0000:00:01.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[    8.680382][    T1] PCI: bus1: Fast back to back transfers enabled
[    8.680409][    T1] pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
[    8.680612][    T1] pci 0000:00:01.0: BAR 6: assigned [mem 0xe0000000-0xe00007ff pref]
[    8.680630][    T1] pci 0000:00:01.0: PCI bridge to [bus 01]
[    8.681265][    T1] mv_xor f1060800.xor: Marvell shared XOR driver
[    8.744072][    T1] mv_xor f1060800.xor: Marvell XOR (Registers Mode): ( xor cpy intr )
[    8.746053][    T1] mv_xor f1060900.xor: Marvell shared XOR driver
[    8.804118][    T1] mv_xor f1060900.xor: Marvell XOR (Registers Mode): ( xor cpy intr )
[    8.806347][    T1] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[    8.807628][    T1] printk: console [ttyS0] disabled
[    8.807696][    T1] f1012000.serial: ttyS0 at MMIO 0xf1012000 (irq = 26, base_baud = 12500000) is a 16550A
[    9.628875][    T1] printk: console [ttyS0] enabled
[    9.641356][    T1] loop: module loaded
[    9.645830][    T1] sata_mv f1080000.sata: slots 32 ports 2
[    9.654259][    T1] scsi host0: sata_mv
[    9.658713][    T1] scsi host1: sata_mv
[    9.662872][    T1] ata1: SATA max UDMA/133 irq 33
[    9.667749][    T1] ata2: SATA max UDMA/133 irq 33
[    9.673600][    T1] nand: device found, Manufacturer ID: 0xec, Chip ID: 0xf1
[    9.680779][    T1] nand: Samsung NAND 128MiB 3,3V 8-bit
[    9.686149][    T1] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    9.694485][    T1] Scanning device for bad blocks
[    9.723654][    T1] Bad eraseblock 253 at 0x000001fa0000
[    9.738254][    T1] Bad eraseblock 350 at 0x000002bc0000
[    9.778395][    T1] Bad eraseblock 713 at 0x000005920000
[    9.788594][    T1] Bad eraseblock 764 at 0x000005f80000
[    9.801290][    T1] Bad eraseblock 841 at 0x000006920000
[    9.824185][    T1] 9 fixed-partitions partitions found on MTD device orion_nand
[    9.831613][    T1] Creating 9 MTD partitions on "orion_nand":
[    9.837502][    T1] 0x000000000000-0x000000100000 : "uboot"
[    9.844444][    T1] 0x000000100000-0x000000180000 : "uboot_env"
[    9.851625][    T1] 0x000000180000-0x000000200000 : "key_store"
[    9.858848][    T1] 0x000000200000-0x000000280000 : "info"
[    9.865641][    T1] 0x000000280000-0x000000c80000 : "etc"
[    9.872339][    T1] 0x000000c80000-0x000001680000 : "kernel_1"
[    9.879520][    T1] 0x000001680000-0x000004640000 : "rootfs1"
[    9.886731][    T1] 0x000004640000-0x000005040000 : "kernel_2"
[    9.893927][    T1] 0x000005040000-0x000008000000 : "rootfs2"
[    9.902362][    T1] libphy: Fixed MDIO Bus: probed
[    9.908042][    T1] libphy: orion_mdio_bus: probed
[    9.914162][    T1] mv643xx_eth: MV-643xx 10/100/1000 ethernet driver version 1.4
[    9.922204][    T1] mv643xx_eth_port mv643xx_eth_port.0: DMA mask not set
[    9.929652][    T1] mv643xx_eth: Set the PHY to fix link down
[    9.930452][    T1] mv643xx_eth_port mv643xx_eth_port.0 eth0: port 0 with MAC address 52:3b:20:9c:11:51
[    9.945925][    T1] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    9.953243][    T1] ehci-pci: EHCI PCI platform driver
[    9.958550][    T1] ehci-orion: EHCI orion driver
[    9.963518][    T1] orion-ehci f1050000.ehci: EHCI Host Controller
[    9.969814][    T1] orion-ehci f1050000.ehci: new USB bus registered, assigned bus number 1
[    9.978433][    T1] orion-ehci f1050000.ehci: irq 30, io mem 0xf1050000
[   10.013306][    T1] orion-ehci f1050000.ehci: USB 2.0 started, EHCI 1.00
[   10.020335][    T1] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.02
[   10.029371][    T1] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[   10.037354][    T1] usb usb1: Product: EHCI Host Controller
[   10.042953][    T1] usb usb1: Manufacturer: Linux 5.2.9-kirkwood-tld-1 ehci_hcd
[   10.050315][    T1] usb usb1: SerialNumber: f1050000.ehci
[   10.056361][    T1] hub 1-0:1.0: USB hub found
[   10.060867][    T1] hub 1-0:1.0: 1 port detected
[   10.066266][    T1] usbcore: registered new interface driver usb-storage
[   10.073414][    T1] mousedev: PS/2 mouse device common for all mice
[   10.080269][    T1] rtc-mv f1010300.rtc: registered as rtc0
[   10.086189][    T1] i2c /dev entries driver
[   10.096984][    T1] rtc-pcf8563 0-0051: registered as rtc1
[   10.104171][    T1] device-mapper: uevent: version 1.0.3
[   10.109800][    T1] device-mapper: ioctl: 4.40.0-ioctl (2019-01-18) initialised: dm-devel@redhat.com
[   10.119430][    T1] device-mapper: multipath round-robin: version 1.2.0 loaded
[   10.126761][    T1] device-mapper: multipath queue-length: version 0.2.0 loaded
[   10.134155][    T1] device-mapper: multipath service-time: version 0.3.0 loaded
[   10.141560][    T1] device-mapper: dm-log-userspace: version 1.3.0 loaded
[   10.148413][    T1] device-mapper: raid: Loading target version 1.14.0
[   10.157007][    T1] hidraw: raw HID events driver (C) Jiri Kosina
[   10.163488][    T1] drop_monitor: Initializing network drop monitor service
[   10.170797][    T1] NET: Registered protocol family 17
[   10.176079][  T112] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl F300)
[   10.183679][    T1] Key type dns_resolver registered
[   10.189536][    T1] registered taskstats version 1
[   10.194389][    T1] Loading compiled-in X.509 certificates
[   10.199985][    T1] zswap: loaded using pool lzo/zbud
[   10.213612][  T112] ata1.00: ATA-7: SAMSUNG HD103UJ, 1AA01113, max UDMA7
[   10.220355][  T112] ata1.00: 1953525168 sectors, multi 0: LBA48 NCQ (depth 31/32)
[   10.234891][    T1] Key type big_key registered
[   10.243226][    T1] Key type encrypted registered
[   10.250015][    T1] rtc-mv f1010300.rtc: setting system clock to 2021-03-22T22:01:08 UTC (1616450468)
[   10.263701][  T112] ata1.00: configured for UDMA/133
[   10.279218][    T7] scsi 0:0:0:0: Direct-Access     ATA      SAMSUNG HD103UJ  1113 PQ: 0 ANSI: 5
[   10.289075][  T116] sd 0:0:0:0: [sda] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB)
[   10.298193][  T116] sd 0:0:0:0: [sda] Write Protect is off
[   10.303924][  T116] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[   10.317954][  T116]  sda: sda1
[   10.322444][  T116] sd 0:0:0:0: [sda] Attached SCSI disk
[   10.443310][   T15] usb 1-1: new high-speed USB device number 2 using orion-ehci
[   10.645065][   T15] usb 1-1: New USB device found, idVendor=05e3, idProduct=0608, bcdDevice=77.63
[   10.654013][   T15] usb 1-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[   10.661899][   T15] usb 1-1: Product: USB2.0 Hub
[   10.667348][   T15] hub 1-1:1.0: USB hub found
[   10.672187][   T15] hub 1-1:1.0: 4 ports detected
[   10.803321][  T114] ata2: SATA link up 3.0 Gbps (SStatus 123 SControl F300)
[   10.835640][  T114] ata2.00: ATA-10: ST4000DM005-2DP166, 0001, max UDMA/133
[   10.842640][  T114] ata2.00: 7814037168 sectors, multi 0: LBA48 NCQ (depth 31/32)
[   10.857061][  T114] ata2.00: configured for UDMA/133
[   10.872531][   T23] scsi 1:0:0:0: Direct-Access     ATA      ST4000DM005-2DP1 0001 PQ: 0 ANSI: 5
[   10.882374][  T116] sd 1:0:0:0: [sdb] 7814037168 512-byte logical blocks: (4.00 TB/3.64 TiB)
[   10.891237][  T116] sd 1:0:0:0: [sdb] 4096-byte physical blocks
[   10.897373][  T116] sd 1:0:0:0: [sdb] Write Protect is off
[   10.903086][  T116] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[   10.962058][  T116]  sdb: sdb1 sdb2
[   10.967316][  T116] sd 1:0:0:0: [sdb] Attached SCSI disk
[   10.972756][    T1] md: Waiting for all devices to be available before autodetect
[   10.980347][    T1] md: If you don't use raid, use raid=noautodetect
[   10.987450][    T1] md: Autodetecting RAID arrays.
[   10.992270][    T1] md: autorun ...
[   10.995855][    T1] md: ... autorun DONE.
[   11.000098][    T1] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[   11.008370][    T1] Please append a correct "root=" boot option; here are the available partitions:
[   11.017534][   T15] usb 1-1.3: new high-speed USB device number 3 using orion-ehci
[   11.025196][    T1] 1f00            1024 mtdblock0 
[   11.025200][    T1]  (driver?)
[   11.033164][    T1] 1f01             512 mtdblock1 
[   11.033166][    T1]  (driver?)
[   11.041224][    T1] 1f02             512 mtdblock2 
[   11.041227][    T1]  (driver?)
[   11.049312][    T1] 1f03             512 mtdblock3 
[   11.049316][    T1]  (driver?)
[   11.057376][    T1] 1f04           10240 mtdblock4 
[   11.057380][    T1]  (driver?)
[   11.065396][    T1] 1f05           10240 mtdblock5 
[   11.065399][    T1]  (driver?)
[   11.073385][    T1] 1f06           48896 mtdblock6 
[   11.073388][    T1]  (driver?)
[   11.081360][    T1] 1f07           10240 mtdblock7 
[   11.081363][    T1]  (driver?)
[   11.089386][    T1] 1f08           48896 mtdblock8 
[   11.089389][    T1]  (driver?)
[   11.097431][    T1] 0800       976762584 sda 
[   11.097435][    T1]  driver: sd
[   11.105035][    T1]   0801       976761560 sda1 0fb90fb8-01
[   11.105039][    T1] 
[   11.112860][    T1] 0810      3907018584 sdb 
[   11.112863][    T1]  driver: sd
[   11.120417][    T1]   0811          498688 sdb1 0ced66c6-0d6d-4333-bff6-d64b37dce7f8
[   11.120420][    T1] 
[   11.130418][    T1]   0812      3906518016 sdb2 8406160e-0e36-4e5c-8d1f-840a7e4cf754
[   11.130421][    T1] 
[   11.140413][    T1] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[   11.149419][    T1] CPU: 0 PID: 1 Comm: swapper Not tainted 5.2.9-kirkwood-tld-1 #1
[   11.157104][    T1] Hardware name: Marvell Kirkwood (Flattened Device Tree)
[   11.164125][    T1] [<c010f6ac>] (unwind_backtrace) from [<c010bb00>] (show_stack+0x10/0x14)
[   11.172616][    T1] [<c010bb00>] (show_stack) from [<c0119fa0>] (panic+0xe0/0x30c)
[   11.180237][    T1] [<c0119fa0>] (panic) from [<c0e01628>] (mount_block_root+0x1bc/0x2a4)
[   11.188463][    T1] [<c0e01628>] (mount_block_root) from [<c0e017f8>] (mount_root+0xe8/0x154)
[   11.197034][    T1] [<c0e017f8>] (mount_root) from [<c0e019b0>] (prepare_namespace+0x14c/0x18c)
[   11.205780][    T1] [<c0e019b0>] (prepare_namespace) from [<c0e011c8>] (kernel_init_freeable+0x270/0x2dc)
[   11.215400][    T1] [<c0e011c8>] (kernel_init_freeable) from [<c09dcee0>] (kernel_init+0x8/0x10c)
[   11.224318][    T1] [<c09dcee0>] (kernel_init) from [<c01010e0>] (ret_from_fork+0x14/0x34)
[   11.232621][    T1] Exception stack(0xdf48bfb0 to 0xdf48bff8)
[   11.238395][    T1] bfa0:                                     00000000 00000000 00000000 00000000
[   11.247309][    T1] bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[   11.256220][    T1] bfe0: 00000000 00000000 00000000 00000000 00000013 00000000
[   11.263570][    T1] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 23, 2021 12:40AM
bandicoot,

Your rootfs is still set up tp boot with stock u-boot. To boot the new u-boot (which is what you are booting with kwboot), the rootfs must be the original out of the box.

Quote
https://forum.doozan.com/read.php?2,12096

4. Create uImage with embedded DTB for booting with older u-boots (2012 or earlier). Do not do this step if you have installed the latest U-Boot for Kirkwood (or are installing this u-boot at the same time).

So the uImage must be reversed

cp -a uImage.orig uImage

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 23, 2021 04:58PM
I am getting confused in what the output of fw_printenv should be, it is a huge difference with the printenv from stock uboot.

I know the ethaddr should be set in the env, but I do not inderstand in which env, in the stock uboot or in where fw_printenv gets its settings from.

Also fw_printenv warns continuously the following: "Warning: Bad CRC, using default environment"

Is this default environment in the warning the one I should use? And should I somehow set ethaddr to the 'real' one which I find in stock uboot env?

I also did a a saveenv to get the stock uboot to boot my ide disk, this my current state.

If I flash the new uboot to mtd0, where do I save the env then?

Here is some output I collected:
# cat /etc/fw_env.config
# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
/dev/mtd0 0xc0000 0x20000 0x20000

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00100000 00020000 "uboot"
mtd1: 00080000 00020000 "uboot_env"
mtd2: 00080000 00020000 "key_store"
mtd3: 00080000 00020000 "info"
mtd4: 00a00000 00020000 "etc"
mtd5: 00a00000 00020000 "kernel_1"
mtd6: 02fc0000 00020000 "rootfs1"
mtd7: 00a00000 00020000 "kernel_2"
mtd8: 02fc0000 00020000 "rootfs2"

# dmesg |grep -i bad
[   10.405197] Scanning device for bad blocks
[   10.434297] Bad eraseblock 253 at 0x000001fa0000
[   10.448872] Bad eraseblock 350 at 0x000002bc0000
[   10.488882] Bad eraseblock 713 at 0x000005920000
[   10.499066] Bad eraseblock 764 at 0x000005f80000
[   10.511736] Bad eraseblock 841 at 0x000006920000

# fw_printenv ethaddr
Warning: Bad CRC, using default environment
ethaddr=00:00:11:22:33:44

# fw_printenv
Warning: Bad CRC, using default environment
bootcmd=run distro_bootcmd
bootdelay=2
baudrate=115200
stdin=serial,cros-ec-keyb,usbkbd
stdout=serial,vidconsole
stderr=serial,vidconsole
ethaddr=00:00:11:22:33:44
eth1addr=00:00:11:22:33:45
eth3addr=00:00:11:22:33:46
eth5addr=00:00:11:22:33:47
ipaddr=1.2.3.4
host_boot=if host dev ${devnum}; then setenv devtype host; run scan_dev_for_boot_part; fi
sata_boot=if sata dev ${devnum}; then setenv devtype sata; run scan_dev_for_boot_part; fi
scsi_init=if ${scsi_need_init}; then setenv scsi_need_init false; scsi scan; fi
scsi_boot=run scsi_init; if scsi dev ${devnum}; then setenv devtype scsi; run scan_dev_for_boot_part; fi
virtio_boot=if virtio dev ${devnum}; then setenv devtype virtio; run scan_dev_for_boot_part; fi
boot_prefixes=/ /boot/
boot_scripts=boot.scr.uimg boot.scr
boot_script_dhcp=boot.scr.uimg
boot_targets=host1 host0
boot_syslinux_conf=extlinux/extlinux.conf
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done
bootcmd_host1=setenv devnum 1; run host_boot
bootcmd_host0=setenv devnum 0; run host_boot
distro_bootcmd=setenv scsi_need_init; for target in ${boot_targets}; do run bootcmd_${target}; done
bootm_size=0x10000000
kernel_addr_r=0x1000000
fdt_addr_r=0xc00000
ramdisk_addr_r=0x2000000
scriptaddr=0x1000
pxefile_addr_r=0x2000

And this is my saveenv and then printenv in my current env in stock uboot:
NSA320>> saveenv
Saving Environment to NAND...
Erasing Nand...Writing to Nand... done
NSA320>> printenv
bootargs=console=ttyS0,115200 mtdparts=nand_mtd:0x100000(uboot),0x80000(uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2) root=/dev/nfs rw init=/init
bootdelay=2
baudrate=115200
loads_echo=0
eth1addr=00:19:CB:00:51:82
ipaddr=10.4.50.165
serverip=10.4.50.5
rootpath=/mnt/ARM_FS/
netmask=255.255.255.0
nandEcc=1bit
MODEL_ID=DD01
PRODUCT_NAME=NSA-320
FEATURE_BIT=00
CONTRY_TYPE=FF
VENDOR_NAME=ZyXEL Communications Corp.
run_diag=yes
ethaddr=B0:B2:DC:F0:FF:12
stdin=serial
stdout=serial
stderr=serial
console=console=ttyS0,115200 mtdparts=nand_mtd:0xc0000@0(uboot)ro,0x7f00000@0x100000(root)
mainlineLinux=no
CASset=min
enaMonExt=no
enaCpuStream=no
enaWrAllo=no
pexMode=RC
disL2Cache=no
setL2CacheWT=yes
disL2Prefetch=yes
enaICPref=yes
enaDCPref=yes
sata_dma_mode=yes
ethprime=egiga1
netbsd_en=no
vxworks_en=no
bootargs_root=root=/dev/nfs rw
bootargs_end=:::DB88FXX81:eth0:none
image_name=uImage
standalone=fsload 0x2000000 $(image_name);setenv bootargs $(console) root=/dev/mtdblock0 rw ip=$(ipaddr):$(serverip)$(bootargs_end) $(mvPhoneConfig); bootm 0x2000000;
disaMvPnp=no
ethmtu=1500
eth1mtu=1500
mvPhoneConfig=mv_phone_config=dev0:fxs,dev1:fxs
mvNetConfig=mv_net_config=(00:11:88:0f:62:81,0:1:2:3),mtu=1500
usb0Mode=host
yuk_ethaddr=00:00:00:EE:51:81
hddPowerCtrl=no
netretry=no
rcvrip=169.254.100.100
loadaddr=0x02000000
autoload=no
enaAutoRecovery=yes
kernel_addr=0x4640000
pcieTune=no
ethact=egiga1
ide_set_bootargs=setenv bootargs console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 earlyprintk=serial init=/bin/systemd
load_uimage=ext2load ide 0:1 0x800000 /boot/uImage
load_uinitrd=ext2load ide 0:1 0x2100000 /boot/uInitrd
ide_boot=mw 0x800000 0 1; run load_uimage; run load_uinitrd; bootm 0x800000 0x2100000
ide_bootcmd=run ide_set_bootargs; run ide_boot
bootcmd=ide reset; ide start; run ide_bootcmd; ide stop; reset

Environment size: 1910/131068 bytes

Could you help me in what my next step shouldbe next to restoring the original uImage?

Cheers
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 23, 2021 07:05PM
bandicoot,

> I am getting confused in what the output of
> fw_printenv should be, it is a huge difference
> with the printenv from stock uboot.

Because what you listed was the stock u-boot envs.

> Also fw_printenv warns continuously the following:
> "Warning: Bad CRC, using default environment"

Ignore this, the rootfs is looking for the envs in a diiferent location from the stock envs location.

> Is this default environment in the warning the one
> I should use? And should I somehow set ethaddr to
> the 'real' one which I find in stock uboot env?

Find the real ethaddr either from stock envs, or on the box label (usually the bottom or back of the enclosure)

>
> I also did a a saveenv to get the stock uboot to
> boot my ide disk, this my current state.

That was the stock envs location that you've saved to in serial console.

>
> If I flash the new uboot to mtd0, where do I save
> the env then?

Step 8 in u-boot installation is when you will flash the default envs:

Quote

8. Flashing default u-boot envs image (if you are upgrading from 2016.05-tld-1 u-boot, you can skip this step 8).

After the default envs image was flashed, the fw_printenv and fw_setenv should work correctly. And within Step 8, some envs are adjusted further.

> Could you help me in what my next step shouldbe
> next to restoring the original uImage?

cd /boot
cp -a uImage uImage.with_DTB
cp -a uImage.orig uImage
sync

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 24, 2021 04:08PM
bodhi,

I did the copying in /boot end continued with the steps:

1.
# cat /etc/fw_env.config
# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
/dev/mtd0 0xc0000 0x20000 0x20000

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00100000 00020000 "uboot"
mtd1: 00080000 00020000 "uboot_env"
mtd2: 00080000 00020000 "key_store"
mtd3: 00080000 00020000 "info"
mtd4: 00a00000 00020000 "etc"
mtd5: 00a00000 00020000 "kernel_1"
mtd6: 02fc0000 00020000 "rootfs1"
mtd7: 00a00000 00020000 "kernel_2"
mtd8: 02fc0000 00020000 "rootfs2"

2.
did the fw_printenv, but his was showing the default new uboot env fake ethadr.
But I do have the real ethaddr, I will add that later

3.
I did the nanddump to save mtd0

I also did the following:
# fw_printenv > current_envs.txt

But because of the default it is missing the mtdparts value (default new uboot env again), which is needed later on:
# cat current_envs.txt
bootcmd=run distro_bootcmd
bootdelay=2
baudrate=115200
stdin=serial,cros-ec-keyb,usbkbd
stdout=serial,vidconsole
stderr=serial,vidconsole
ethaddr=00:00:11:22:33:44
eth1addr=00:00:11:22:33:45
eth3addr=00:00:11:22:33:46
eth5addr=00:00:11:22:33:47
ipaddr=1.2.3.4
host_boot=if host dev ${devnum}; then setenv devtype host; run scan_dev_for_boot_part; fi
sata_boot=if sata dev ${devnum}; then setenv devtype sata; run scan_dev_for_boot_part; fi
scsi_init=if ${scsi_need_init}; then setenv scsi_need_init false; scsi scan; fi
scsi_boot=run scsi_init; if scsi dev ${devnum}; then setenv devtype scsi; run scan_dev_for_boot_part; fi
virtio_boot=if virtio dev ${devnum}; then setenv devtype virtio; run scan_dev_for_boot_part; fi
boot_prefixes=/ /boot/
boot_scripts=boot.scr.uimg boot.scr
boot_script_dhcp=boot.scr.uimg
boot_targets=host1 host0
boot_syslinux_conf=extlinux/extlinux.conf
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done
bootcmd_host1=setenv devnum 1; run host_boot
bootcmd_host0=setenv devnum 0; run host_boot
distro_bootcmd=setenv scsi_need_init; for target in ${boot_targets}; do run bootcmd_${target}; done
bootm_size=0x10000000
kernel_addr_r=0x1000000
fdt_addr_r=0xc00000
ramdisk_addr_r=0x2000000
scriptaddr=0x1000
pxefile_addr_r=0x2000

What should I set mtdparts to then later on?

4.
I did not have bad blocks in that range

5.
Done that

6.
# flash_erase /dev/mtd0 0 4
Erasing 128 Kibyte @ 60000 -- 100 % complete

7.
# nandwrite /dev/mtd0 uboot.2017.07-tld-1.nsa320.mtd0.kwb
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
Writing data to block 2 at offset 0x40000
Writing data to block 3 at offset 0x
60000


8.a Did that

8.b Did that

8.c
fw_printenv does not give other output as in step 3, so missing the mtdparts, what value should I use for this?

8.d
# /usr/sbin/flash_erase /dev/mtd0 0xc0000 1
Erasing 128 Kibyte @ c0000 -- 100 % complete

# /usr/sbin/nandwrite -s 786432 /dev/mtd0 uboot.2016.05-tld-1.environment.img
Writing data to block 6 at offset 0xc0000

# fw_printenv
arcNumber=2097
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=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec
bootcmd_uenv=run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi
bootdelay=10
bootdev=usb
device=0:1
devices=usb ide mmc
disks=0 1 2 3
ethact=egiga0
ethaddr=52:3b:20:9c:11:51
if_netconsole=ping $serverip
ipaddr=192.168.0.231
led_error=orange blinking
led_exit=green off
led_init=green blinking
dtb_file=/boot/dts/kirkwood-pogo_e02.dtb
load_dtb_addr=0x1c00000
load_initrd_addr=0x1100000
load_uimage_addr=0x800000
load_dtb=echo loading DTB $dtb_file ...; load $bootdev $device $load_dtb_addr $dtb_file
load_initrd=echo loading uInitrd ...; load $bootdev $device $load_initrd_addr /boot/uInitrd
load_uimage=echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage
machid=0x831
mainlineLinux=yes
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:1M(u-boot),4M(uImage),32M(rootfs),-(data)
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
serverip=192.168.0.220
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;
stderr=serial
stdin=serial
stdout=serial
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_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
uenv_read=echo loading envs from $devtype $disknum ...; if load $devtype $disknum:1 $uenv_addr /boot/uEnv.txt; then setenv uenv_loaded 1; fi
usb_ready_retry=15

8.e.1
# fw_setenv arcNumber 3956
# fw_setenv machid

8.e.2
# fw_setenv ethaddr '0B:B2:DC:F0:FF:21'

What should I use here?:
# fw_setenv mtdparts ???????????? (MISSING IN STEP 8C, BECAUSE OF TAKING DEFAULT NEW BOOT ENV)

8.e.3
Did this:
# fw_setenv uenv_init_devices 'echo Initializing 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'
# fw_setenv uenv_read 'echo Loading envs from $device_type $disk_number...; if load $device_type  $disk_number:1 $uenv_addr /boot/uEnv.txt; then setenv uenv_loaded 1; echo ... envs loaded; fi'
# fw_setenv uenv_load 'run uenv_init_devices; setenv uenv_loaded 0; for devtype in $devices; do for disknum in $disks; do if test $uenv_loaded -eq 0; then setenv device_type $devtype; setenv disk_number $disknum; run uenv_read; fi; done; done;'
# fw_setenv uenv_read_disk

!!! SHOULD I RUN THIS FOR NSA320 WHICH HAS SATA, BUT I RUN STOCK BOOT WITH IDE CURRENTLY:
fw_setenv bootcmd_uenv 'run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi; sleep 3'

8.f
# fw_setenv dtb_file '/boot/dts/kirkwood-nsa320.dtb'

8.h
# fw_printenv
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=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec
bootcmd_uenv=run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi
bootdelay=10
bootdev=usb
device=0:1
devices=usb ide mmc
disks=0 1 2 3
ethact=egiga0
if_netconsole=ping $serverip
ipaddr=192.168.0.231
led_error=orange blinking
led_exit=green off
led_init=green blinking
load_dtb_addr=0x1c00000
load_initrd_addr=0x1100000
load_uimage_addr=0x800000
load_dtb=echo loading DTB $dtb_file ...; load $bootdev $device $load_dtb_addr $dtb_file
load_initrd=echo loading uInitrd ...; load $bootdev $device $load_initrd_addr /boot/uInitrd
load_uimage=echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage
mainlineLinux=yes
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:1M(u-boot),4M(uImage),32M(rootfs),-(data)
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
serverip=192.168.0.220
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;
stderr=serial
stdin=serial
stdout=serial
uenv_addr=0x810000
uenv_import=echo importing envs ...; env import -t $uenv_addr $filesize
usb_ready_retry=15
arcNumber=3956
ethaddr=0B:B2:DC:F0:FF:21
uenv_init_devices=echo Initializing 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_read=echo Loading envs from $device_type $disk_number...; if load $device_type  $disk_number:1 $uenv_addr /boot/uEnv.txt; then setenv uenv_loaded 1; echo ... envs loaded; fi
uenv_load=run uenv_init_devices; setenv uenv_loaded 0; for devtype in $devices; do for disknum in $disks; do if test $uenv_loaded -eq 0; then setenv device_type $devtype; setenv disk_number $disknum; run uenv_read; fi; done; done;
dtb_file=/boot/dts/kirkwood-nsa320.dtb


So all in all I have four questions:
- What should I set mtdparts to?
- Should I do the setting for SATA at step 8.e.3?
- Are values in /boot/uEnv.txt overriding existing values in flash?
- Can you see anything else that is blocking me from continuing with the next steps?



Edited 1 time(s). Last edit at 03/24/2021 04:17PM by bandicoot.
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 24, 2021 05:04PM
bandicoot,

Excellent!

> - What should I set mtdparts to?

mtdparts should have been in stock u-boot envs (it should show in printenv in serial console).

In Debian:
fw_setenv mtdparts 'mtdparts=orion_nand:0x100000(uboot),0x80000(uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2)'

Note that the mtdparts is not important for booting. It's only used when you list and modifiy envs in Debian later.


> - Should I do the setting for SATA at step 8.e.3?

No need to do anything. It is optional. Only later when you want to use uEnv.txt then you would want to use this correcttion for the uEnv related envs. But of course it does not hurt to do it now.

The uEnv processing apply to all disks. But sometime SATA is a bit slow in reset the second time, that's why I suggested a "sleep 3" to make it go smoother.

> - Are values in /boot/uEnv.txt overriding existing
> values in flash?

Yes, but only temporary in RAM (not saved to flash). And you shoud not have uEnv.txt file in /boot unless you need to use it to change envs (whether just for experiment or really need to).

> - Can you see anything else that is blocking me
> from continuing with the next steps?

All look good.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 24, 2021 05:24PM
bodhi,

Thanks for your quick reply.

I do have the mtdparts from stock uboot printenv in the following line, will these do then?:
bootargs=console=ttyS0,115200 mtdparts=nand_mtd:0x100000(uboot),0x80000(uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2) root=/dev/nfs rw init=/init

then probably only this bit:
mtdparts=nand_mtd:0x100000(uboot),0x80000(uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2)

And this was from my new uboot UART/serial kwboot, before I did all the steps 1 to 8.e.3 (steps ran with stock uboot boot into debian):
U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:46:11 -0700)
ZyXEL NSA320 2-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  512 MiB
WARNING: Caches not enabled
NAND:  128 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   egiga0
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0 
NSA320> printenv
arcNumber=3956
baudrate=115200
bootcmd=run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec; reset
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
bootdelay=10
bootdev=usb
console=console=ttyS0,115200
device=0:1
devices=usb ide
disks=0 1 2 3
dtb_file=/boot/dts/kirkwood-nsa320.dtb
ethact=egiga0
ethaddr=52:3b:20:9c:11:51
if_netconsole=ping $serverip
ipaddr=192.168.0.231
led_error=orange blinking
led_exit=green off
led_init=green blinking
load_dtb=echo loading DTB $dtb_file ...; load $bootdev $device $load_dtb_addr $dtb_file
load_dtb_addr=0x1c00000
load_initrd=echo loading uInitrd ...; load $bootdev $device $load_initrd_addr /boot/uInitrd
load_initrd_addr=0x1100000
load_uimage=echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage
load_uimage_addr=0x800000
mainlineLinux=yes
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:0x100000(uboot),0x80000(stock_uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(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
serverip=192.168.0.220
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;
stderr=serial
stdin=serial
stdout=serial
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_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
usb_ready_retry=15

Environment size: 3016/131068 bytes

A bit stange that the line says:
mtdparts=mtdparts=orion_nand:0x100000(uboot),0x80000(stock_uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2)



Edited 2 time(s). Last edit at 03/24/2021 05:38PM by bandicoot.
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 24, 2021 10:14PM
bandicoot,

Stock mtdparts:
mtdparts=nand_mtd:0x100000(uboot),0x80000(uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2)

My mtdparts:
mtdparts=mtdparts=orion_nand:0x100000(uboot),0x80000(stock_uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2)

They are the same, as far as the size and locaton are concerned. orion_nand is the new name for this flash driver in the latest kernel and stock_uboot_env is my naming convention to make clear what it is for furture reference. We don't use stock u-boot envs.

So use

mtdparts=mtdparts=orion_nand:0x100000(uboot),0x80000(stock_uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2)

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 25, 2021 04:22PM
bodhi,

Thanks so much! I do have a working NSA320 with the new uboot now.
I did put the mtdparts definition into /boot/uEnv.txt and that is working fine.

My /boot/uEnv.txt nowlooks like this:
mtdparts=orion_nand:0x100000(uboot),0x80000(stock_uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2)
devices=usb ide mmc
customparams=init=/bin/systemd


On to the next project, I would like to be able to turn on the fan, I already searched the forum and I could not find a working solution.

Is it default for the fan to be on? But then I don't know why mine is not.

I was able to turn off/on the led's, it looks like kirkwood-nsa320.dts caters for that. But the places where I could find the file, i was not able to find anything in it, nor in the inluded files, on traces of being able to turn the fan on or off using i2c or sensors.

Do you have any idea what I could try or maybe where else I could look for this?

It looks also that I fount a i2cset to be able to set auto-power-on after powerloss in:
https://forum.doozan.com/read.php?2,109139,109139
i2cset -y 0x0 0x50 0x06 0x01 b

Also I used wake-on-lan in stock firmware a lot, is there a way to set that too?

Cheers



Edited 2 time(s). Last edit at 03/25/2021 04:25PM by bandicoot.
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 25, 2021 06:56PM
bandicoot,

> My /boot/uEnv.txt nowlooks like this:
>
> mtdparts=orion_nand:0x100000(uboot),0x80000(stock_uboot_env),0x80000(key_store),0x80000(info),0xA00000(etc),0xA00000(kernel_1),0x2FC0000(rootfs1),0xA00000(kernel_2),0x2FC0000(rootfs2)
> devices=usb ide mmc
> customparams=init=/bin/systemd
>

That's quite clean, exactly how one should use this uEnv.txt!

For the mtdparts, you should set it permanently using fw_setenv, since it is not supposed to change.

> On to the next project, I would like to be able to
> turn on the fan, I already searched the forum and
> I could not find a working solution.

I answered this on the other thread.

> I was able to turn off/on the led's, it looks like
> kirkwood-nsa320.dts caters for that. But the
> places where I could find the file, i was not able
> to find anything in it, nor in the inluded files,
> on traces of being able to turn the fan on or off
> using i2c or sensors.
>

The i2c sensor reading/writing is not in the DTS. It's a Zyxel specific quirks.

> It looks also that I fount a i2cset to be able to
> set auto-power-on after powerloss in:
> https://forum.doozan.com/read.php?2,109139,109139
>
> i2cset -y 0x0 0x50 0x06 0x01 b
>
>
> Also I used wake-on-lan in stock firmware a lot,
> is there a way to set that too?
>

Yes, see the Wiki thread

https://forum.doozan.com/read.php?2,23630

Quote

Sensors & Fan & WOL

OWFSPlug : 1-Wire File System + Motion Detection Software in a NAND Package
OWFS & Motion Detection (external link)
How to control GPIO in Linux userspace for GPIO-enable fan
Zyxel NSA 310S/320S/325/326 CPU Temperature and Fan Speed reading
Zyxel NAS326 WOL
Zyxel NAS326 Auto-Power Up
Zyxel NAS326 WOL and Auto-Power Up I2C commands
Zyxel NSA320 Auto-Power Up

The Zyxel NAS 3xx have the same i2c command sets.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Setting GPIOs in serial console (Kirkwood SoCs)
March 26, 2021 09:53AM
bodhi,

I am continuing here, because this thread is about setting gpio's, only my case is not in serial.

I am able to run on my NSA320:
i2cset -y 0x0 0x50 0x06 0x01 b

But the ones for NSA326 I can't use, write error's:

According to https://forum.doozan.com/read.php?2,27108,106644#msg-106644
[WOL + AUTO RESUME]
If you want WOL + auto turn on after power loss:
/usr/sbin/i2cset -y 0x0 0xa 0xa 0x0006 w (ENABLE WOL)
/usr/sbin/i2cset -y 0x0 0x0a 0x0a 0x0107 w (ENABLE AUTO RESUME)

If I run it:
# /usr/sbin/i2cset -y 0x0 0xa 0xa 0x0006 w
Error: Write failed
/usr/sbin/i2cset -y 0x0 0x0a 0x0a 0x0107 w
Error: Write failed

So these NSA326 addresses are not for the NSA320.

Can I somehow convert the NSA326 commands to the NSA320? And could you point me in the right direction?

Cheers



Edited 1 time(s). Last edit at 03/26/2021 09:53AM by bandicoot.
Re: Setting GPIOs in serial console (Kirkwood SoCs)
October 10, 2023 01:53PM
led status when nothing is done:

lan - nothing
hdd 1-4 - all lit orange
power - blinks/chiping blue
status - nothing
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: