Welcome! Log In Create A New Profile

Advanced

My Cloud Gen2 u-boot

Posted by osa 
osa
My Cloud Gen2 u-boot
January 24, 2020 09:46AM
Hi all!
We have working new box - WD My Cloud (Gen2)
But there's also big issue with u-boot. There's Default CRC is messed and default values are always used, saveenv is not availiable. Maybe i'ts hard coded or maybe just bugged. For example reset button clears env so mac address is cleared causing network not usable.

I think there are some ways to fix this without WD's sourcecode. There's my list of ideas
- build current u-boot from source
- try to kwboot u-boot for other armada-375 based machines- i don't have any working u-boot and could not find them in the internet
- compare dumps from other WD armada based nands to find out if there is also any CRC and try to overwrite env setting in chip - i don't have other files, co please help by providing such nand dumps

I don't have nand programmer and probability of bricking box is very high so working kwb is very important for me
Re: My Cloud Gen2 u-boot
January 24, 2020 01:03PM
osa,


> But there's also big issue with u-boot. There's
> Default CRC is messed and default values are
> always used, saveenv is not availiable.

CRC error is not an issue with u-boot. The CRC error is because we need to define the MTD correctly in the rootfs. Most likely, I should be able to figure out this. There should be no need for new u-boot.

If the command saveenv is not available then it is likely hardcoded in u-boot.


> Maybe i'ts
> hard coded or maybe just bugged. For example reset
> button clears env so mac address is cleared
> causing network not usable.

Was the reset button pressed while in stock OS, u-boot, or Debian?

===============


To start investigate this, please post

- Power up, inerrupt serial console and

printenv
boot

And post the entire serial stock bootlog up until the Debian logging prompt.

- In stock OS

cat /proc/mtd
cat /etc/fw_env.config
fw_printenv

And post the above log.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
osa
Re: My Cloud Gen2 u-boot
January 24, 2020 01:54PM
Hi

CRC is an issue, because when if CRC corruption is detected u-boot uses default values.
NAND env is cleared when board is started with button pressed.

But i made some progress again ;-)
We can use mkenvimage from u-boot to create valid but empty env and then overwrite last sector of NAND and ... now fw_setenv allows us to set env variables!
Downside of this is no MAC set (and serial number) and network is not working. But it could be fixed by patching mkenvimage to use 2 parameters and calculate CRC with them
Re: My Cloud Gen2 u-boot
January 24, 2020 02:05PM
osa,

> CRC is an issue, because when if CRC corruption is
> detected u-boot uses default values.

I don't think CRC is corrupted. The way the mtd inside fw_env.config is defined is important. If it is not correctly defined, then fw_printenv will show a CRC error (because the envs are actually in a different region in NAND).

Think about this fact: If the CRC is really corrupted, then you cannot do printenv in u-boot at all.

As I mentioned, if you want me to help, then please post the info. If you think you are doing OK, then no need to!

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
osa
Re: My Cloud Gen2 u-boot
January 24, 2020 02:50PM
It seems boot order, commands and adressess are hardcoded in uboot, but uses bootargs env
If crc is corrupted default bootargs is used

If i set manually root partition with bootargs (using mkenvimage) I can boot debian from HDD!!!
Funny thing is that kernel overlaps initrd and it is disabled (like previously posted in other thread) and it allows kernel to boot

I can't remember what happens when kernel is missing on hdd ( some kind of recovery) and it could be used as workaround to set own boot commands.

I'll post you bootlogs later
osa
Re: My Cloud Gen2 u-boot
January 24, 2020 05:14PM
So, i verified reset button and i think i was wrong. It does not clear env when booting with button pressed (maybe sets other boot order?? can't confirm)
But resetenv does and fills last 64K of nand with zeros (and clearing checksum)

See log below - just after resetenv
I use fox-exe kernel and initrd because it fits into 0xa00000/0xf00000 adresses
BootROM - 1.51

Booting from SPI flash



General initialization - Version: 1.0.0

High speed PHY - Version: 0.1.1 (COM-PHY-V20) 

USB2 UTMI PHY initialized succesfully

USB2 UTMI PHY initialized succesfully

High speed PHY - Ended Successfully


DDR3 Training Sequence - Ver 5.7.1

DDR3 Training Sequence - Run with PBS.

DDR3 Training Sequence - Ended Successfully 

BootROM: Image checksum verification PASSED


 ** LOADER **


U-Boot 2013.01_v1.03 (Nov 20 2014 - 16:39:45) Marvell version: 2014_T2.0p3

Board: WD_Glacier_DB-88F6720-V2
SoC:   MV88F6720 Rev A0
       running 2 CPUs
CPU:   ARM Cortex A9 MPCore (Rev 1) LE
       CPU 0
       CPU    @ 800 [MHz]
       L2     @ 400 [MHz]
       TClock @ 200 [MHz]
       DDR    @ 534 [MHz]
       DDR 16Bit Width, FastPath Memory Access, DLB Enabled
DRAM:  512 MiB

Map:   Code:0x1fed6000:0x1ff92c90
       BSS:0x1ffefa20
       Stack:0x1f9c5f20
       Heap:0x1f9c6000:0x1fed6000

SF: Detected MX25L8006E with page size 64 KiB, total 1 MiB
*** Warning - bad CRC, using default environment

PCI-e 0: Detected No Link.
PCI-e 1: Detected No Link.
SF: Detected MX25L8006E with page size 64 KiB, total 1 MiB
### Loading Firmware from USB 3.0 Disk ###
USB2.0 0: Host Mode
USB2.0 1: Device Mode
USB3.0 0: Host Mode
Board configuration detected:
GE-PHY-0 on MAC0
SERDES configuration:
Lane #0: PCIe0
Lane #1: PCIe1
Lane #2: SATA0
Lane #3: USB3
Net:   egiga0 [PRIME]
*** ERROR: ping address not given
Hit any key to stop autoboot:  1  0 
(Re)start USB...
USB0:   Port (usbActive) : 0Interface (usbType = 3) : USB XHCI 1.00
scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
** Bad device usb 0 **
** Bad device usb 0 **
## Booting image at 00a00000 ...
### Loading Firmware from USB 2.0 Disk ###
(Re)start USB...
USB0:   Port (usbActive) : 1Interface (usbType = 2) : USB EHCI 1.00
scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
** Bad device usb 0 **
** Bad device usb 0 **
## Booting image at 00a00000 ...
### Loading Firmware from Disk ###

Reset IDE: 
Marvell Serial ATA Adapter
Integrated Sata device found
  Device 0 @ 0 0:
Model: WDC WD800JD-22JNC0                       Firm: 05.01C05 Ser#:      WD-WCAM9A844714
            Type: Hard Disk
            Capacity: 76319.0 MB = 74.5 GB (156301488 x 512)

3635207 bytes read in 130 ms (26.7 MiB/s)
2679902 bytes read in 102 ms (25.1 MiB/s)
## Booting image at 00a00000 ...
## Booting kernel from Legacy Image at 00a00000 ...
   Image Name:   armada-375-wdmc-gen2
   Created:      2018-01-08   8:40:26 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3635143 Bytes = 3.5 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 00f00000 ...
   Image Name:   Ramdisk
   Created:      2016-05-22  11:44:54 UTC
   Image Type:   ARM Linux RAMDisk Image (lzma compressed)
   Data Size:    2679838 Bytes = 2.6 MiB
   Load Address: 00e00000
   Entry Point:  00e00000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...
fw_printenv shows
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 end of nand is zeroed
root@wdmc:~# dd if=/dev/mtd0 bs=64K skip=15 |hexdump -C

00000000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*

u-boot's printenv
SF: Detected MX25L8006E with page size 64 KiB, total 1 MiB
*** Warning - bad CRC, using default environment

PCI-e 0: Detected No Link.
PCI-e 1: Detected No Link.
SF: Detected MX25L8006E with page size 64 KiB, total 1 MiB
### Loading Firmware from USB 3.0 Disk ###
USB2.0 0: Host Mode
USB2.0 1: Device Mode
USB3.0 0: Host Mode
Board configuration detected:
GE-PHY-0 on MAC0
SERDES configuration:
Lane #0: PCIe0
Lane #1: PCIe1
Lane #2: SATA0
Lane #3: USB3
Net:   egiga0 [PRIME]
*** ERROR: ping address not given
Hit any key to stop autoboot:  1  0 
Marvell>>  printenv
CASset=max
MALLOC_len=5
MPmode=SMP
autoload=no
baudrate=115200
boot_order=hd_scr usb_scr mmc_scr hd_img usb_img mmc_img pxe net_img net_scr
bootargs=root=/dev/ram console=ttyS0,115200
bootargs_dflt=$console $nandEcc $mtdparts $bootargs_root nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip$bootargs_end $mvNetConfig video=dovefb:lcd0:$lcd0_params clcd.lcd0_enable=$lcd0_enable clcd.lcd_panel=$lcd_panel
bootargs_end=:10.4.50.254:255.255.255.0:Armada375:eth0:none
bootargs_root=root=/dev/nfs rw
bootcmd=usb reset; fatload usb 0:1 0xa00000 /boot/uImage; fatload usb 0:1 0xf00000 /boot/uRamdisk; bootm 0xa00000 0xf00000
bootcmd_auto=stage_boot $boot_order
bootcmd_fdt=tftpboot 0x2000000 $image_name;tftpboot $fdtaddr $fdtfile;setenv bootargs $console $nandEcc $mtdparts $bootargs_root nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip$bootargs_end $mvNetConfig video=dovefb:lcd0:$lcd0_params clcd.lcd0_enable=$lcd0_enable clcd.lcd_panel=$lcd_panel; bootz 0x2000000 - $fdtaddr;
bootcmd_fdt_boot=tftpboot 0x2000000 $image_name; setenv bootargs $console $nandEcc $mtdparts $bootargs_root nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip$bootargs_end $mvNetConfig video=dovefb:lcd0:$lcd0_params clcd.lcd0_enable=$lcd0_enable clcd.lcd_panel=$lcd_panel; bootz 0x2000000 - $fdtaddr;
bootcmd_fdt_edit=tftpboot $fdtaddr $fdtfile; fdt addr $fdtaddr; setenv bootcmd $bootcmd_fdt_boot
bootcmd_lgcy=tftpboot 0x2000000 $image_name; setenv bootargs $bootargs_dflt; bootm 0x2000000; 
bootdelay=1
cacheShare=no
console=console=ttyS0,115200
device_partition=0:1
disL2Cache=yes
disL2Prefetch=yes
disaMvPnp=no
eeeEnable=no
enaClockGating=no
enaCpuStream=no
enaDCPref=yes
enaFPU=yes
enaICPref=yes
enaMonExt=no
enaWrAllo=no
eth1addr=00:50:43:00:02:23
eth1mtu=1500
eth2addr=00:50:43:00:00:23
eth2mtu=1500
eth3addr=00:50:43:02:00:00
eth3mtu=1500
ethact=egiga0
ethaddr=00:50:43:00:02:23
ethmtu=1500
ethprime=egiga0
fdt_addr=2040000
fdt_skip_update=no
fdtaddr=0x1000000
fdtfile=armada-375-db.dtb
ide_path=/
image_name=uImage
initrd_name=uInitrd
ipaddr=2.76.78.201
kernel_addr_r=2080000
lcd0_enable=0
lcd0_params=640x480-16@60
lcd_panel=0
loadaddr=0x02000000
loads_echo=0
mtdids=spi0=spi_flash
mtdparts=mtdparts=spi_flash:4m(boot),-(spi-rootfs)
mvNetConfig=mv_net_config=4,(00:50:43:11:11:11,0:1:2:3),mtu=1500
mv_pon_addr=00:50:43:23:00:00
netbsd_en=no
netmask=255.0.0.0
netretry=no
pcieTune=no
pexMode=RC
pxe_files_load=:default.arm-armadaxp-db:default.arm-armadaxp:default.arm
pxefile_addr_r=3100000
ramdisk_addr_r=2880000
rootpath=/srv/nfs/
sata_delay_reset=0
sata_dma_mode=yes
script_addr_r=3000000
script_name=boot.scr
serverip=192.168.1.1
setL2CacheWT=no
standalone=fsload 0x2000000 $image_name;setenv bootargs $console $nandEcc $mtdparts root=/dev/mtdblock0 rw ip=$ipaddr:$serverip$bootargs_end; bootm 0x2000000;
stderr=serial
stdin=serial
stdout=serial
usb0Mode=host
usbActive=0
usbType=3
vxworks_en=no
yuk_ethaddr=00:00:00:EE:51:81

Environment size: 3077/65532 bytes
if i set MAC and serial number, u-boot complains on CRC
but if i set anything using fw_setenv
fw_setenv user osa
Warning: Bad CRC, using default environment
envs are set successfully
fw_printenv
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
user=osa
Now, uboot can merge some of this envs
SF: Detected MX25L8006E with page size 64 KiB, total 1 MiB
MAC addr: 00:90:A9:E9:64:60
### Loading Firmware from USB 3.0 Disk ###
USB2.0 0: Host Mode
USB2.0 1: Device Mode
USB3.0 0: Host Mode
Board configuration detected:
GE-PHY-0 on MAC0
SERDES configuration:
Lane #0: PCIe0
Lane #1: PCIe1
Lane #2: SATA0
Lane #3: USB3
Net:   egiga0 [PRIME]
*** ERROR: ping address not given
Hit any key to stop autoboot:  2  0 
Marvell>> printenv
CASset=max
MALLOC_len=5
MPmode=SMP
autoload=no
baudrate=115200
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_order=hd_scr usb_scr mmc_scr hd_img usb_img mmc_img pxe net_img net_scr
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=host1 host0 
bootargs_dflt=$console $nandEcc $mtdparts $bootargs_root nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip$bootargs_end $mvNetConfig video=dovefb:lcd0:$lcd0_params clcd.lcd0_enable=$lcd0_enable clcd.lcd_panel=$lcd_panel
bootargs_end=:10.4.50.254:255.255.255.0:Armada375:eth0:none
bootargs_root=root=/dev/nfs rw
bootcmd=usb reset; fatload usb 0:1 0xa00000 /boot/uImage; fatload usb 0:1 0xf00000 /boot/uRamdisk; bootm 0xa00000 0xf00000
bootcmd_auto=stage_boot $boot_order
bootcmd_fdt=tftpboot 0x2000000 $image_name;tftpboot $fdtaddr $fdtfile;setenv bootargs $console $nandEcc $mtdparts $bootargs_root nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip$bootargs_end $mvNetConfig video=dovefb:lcd0:$lcd0_params clcd.lcd0_enable=$lcd0_enable clcd.lcd_panel=$lcd_panel; bootz 0x2000000 - $fdtaddr;
bootcmd_fdt_boot=tftpboot 0x2000000 $image_name; setenv bootargs $console $nandEcc $mtdparts $bootargs_root nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip$bootargs_end $mvNetConfig video=dovefb:lcd0:$lcd0_params clcd.lcd0_enable=$lcd0_enable clcd.lcd_panel=$lcd_panel; bootz 0x2000000 - $fdtaddr;
bootcmd_fdt_edit=tftpboot $fdtaddr $fdtfile; fdt addr $fdtaddr; setenv bootcmd $bootcmd_fdt_boot
bootcmd_host0=setenv devnum 0; run host_boot
bootcmd_host1=setenv devnum 1; run host_boot
bootcmd_lgcy=tftpboot 0x2000000 $image_name; setenv bootargs $bootargs_dflt; bootm 0x2000000; 
bootdelay=2
bootm_size=0x10000000
cacheShare=no
console=console=ttyS0,115200
device_partition=0:1
disL2Cache=yes
disL2Prefetch=yes
disaMvPnp=no
distro_bootcmd=setenv scsi_need_init; for target in ${boot_targets}; do run bootcmd_${target}; done
eeeEnable=no
enaClockGating=no
enaCpuStream=no
enaDCPref=yes
enaFPU=yes
enaICPref=yes
enaMonExt=no
enaWrAllo=no
eth1addr=00:00:11:22:33:45
eth1mtu=1500
eth2addr=00:50:43:ee:86:26
eth2mtu=1500
eth3addr=00:00:11:22:33:46
eth3mtu=1500
eth5addr=00:00:11:22:33:47
ethact=egiga0
ethaddr=00:90:A9:E9:64:60
ethmtu=1500
ethprime=egiga0
fdt_addr=2040000
fdt_addr_r=0xc00000
fdt_skip_update=no
fdtaddr=0x1000000
fdtfile=armada-375-db.dtb
host_boot=if host dev ${devnum}; then setenv devtype host; run scan_dev_for_boot_part; fi
ide_path=/
image_name=uImage
initrd_name=uInitrd
ipaddr=1.2.3.4
kernel_addr_r=0x1000000
lcd0_enable=0
lcd0_params=640x480-16@60
lcd_panel=0
loadaddr=0x02000000
mtdids=spi0=spi_flash
mtdparts=mtdparts=spi_flash:4m(boot),-(spi-rootfs)
mvNetConfig=mv_net_config=4,(00:50:43:11:11:11,0:1:2:3),mtu=1500
mv_pon_addr=00:50:43:26:86:ee
netbsd_en=no
netretry=no
pcieTune=no
pexMode=RC
pxe_files_load=:default.arm-armadaxp-db:default.arm-armadaxp:default.arm
pxefile_addr_r=0x2000
ramdisk_addr_r=0x2000000
sata_boot=if sata dev ${devnum}; then setenv devtype sata; run scan_dev_for_boot_part; fi
sata_delay_reset=0
sata_dma_mode=yes
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
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
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
script_addr_r=3000000
script_name=boot.scr
scriptaddr=0x1000
scsi_boot=run scsi_init; if scsi dev ${devnum}; then setenv devtype scsi; run scan_dev_for_boot_part; fi
scsi_init=if ${scsi_need_init}; then setenv scsi_need_init false; scsi scan; fi
setL2CacheWT=no
standalone=fsload 0x2000000 $image_name;setenv bootargs $console $nandEcc $mtdparts root=/dev/mtdblock0 rw ip=$ipaddr:$serverip$bootargs_end; bootm 0x2000000;
stderr=serial
stdin=serial
stdout=serial
usb0Mode=host
usbActive=0
usbType=3
user=osa
virtio_boot=if virtio dev ${devnum}; then setenv devtype virtio; run scan_dev_for_boot_part; fi
vxworks_en=no
yuk_ethaddr=00:00:00:EE:51:81

Environment size: 5002/65532 bytes

If i set bootargs
fw_setenv bootargs 'root=/dev/sda3 console=ttyS0,115200'
it will overwrite bootargs and will be persistent - i need it to boot debian without initrd

root@wdmc:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00100000 00010000 "u-boot"
root@wdmc:~# cat /etc/fw_env.config
# MTD device name   Device offset   Env. size   Flash sector size  Number of sectors
/dev/mtd0           0xf0000        0x10000     0x10000            1

Edit: using fw_setenv is safe for MAC and SN ;-)



Edited 1 time(s). Last edit at 01/24/2020 05:18PM by osa.
Re: My Cloud Gen2 u-boot
January 24, 2020 07:55PM
osa,

I'm glad it works for you!

However, the way you did it was not very good :) too hackish.

Advice: you should approach it more methodically. There is no need to examine what's in NAND. Here are the steps that I would do.

=========

When you boot with serial console the first time and see this

SF: Detected MX25L8006E with page size 64 KiB, total 1 MiB
*** Warning - bad CRC, using default environment

Then you know it was the stock default. It was a lazy decision by WD to use the internal envs inside u-boot code (i.e. the envs were not saved in flash properly, so CRC checksum was never saved, and booting must use default values).

At this point you would boot into stock OS to ensure that the internal envs are used in booting successfully.

And then reboot back to serial console, do saveenv ot resetenv to create the CRC checksum properly.

And then boot into stock OS to check fw_env.config to see where the envs are located.

And then boot Debian. Modify the /etc/fw_env.config to match stock definition.

And then do fw_printenv to see the envs are listed correctly. If they are, then proceed to do fw_setenv for whatever new envs you want to save (i.e. fw_setenv user osa) as a test.

Done.

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



Edited 1 time(s). Last edit at 01/24/2020 07:56PM by bodhi.
osa
Re: My Cloud Gen2 u-boot
January 28, 2020 07:25AM
Hi

Original software has no fw_setenv or fw_printenv so only overwriting parts of nand is an option to set or reset env.

WD's software do not use nand for storing setting - configs are stored on one of drives partitions and can be reset to defaults with reset button pressed for some time. One thing i can do more to confirm this, is to resetenv and check if firmware can set MAC and write it to nand
Maybe there are some wd's tools for nand with stupid names but i couldn't find them so far

So it needs more hacking and test to make install easier ;-)
Re: My Cloud Gen2 u-boot
January 28, 2020 12:28PM
osa,

> Original software has no fw_setenv or fw_printenv
> so only overwriting parts of nand is an option to
> set or reset env.

In that case, with serial console connected, boot up, define the mtds, boot into Debian (Debian-5.2.9-mvebu-tld-1-rootfs-bodhi.tar.bz2),

>
> WD's software do not use nand for storing setting
> - configs are stored on one of drives partitions
> and can be reset to defaults with reset button
> pressed for some time. One thing i can do more to
> confirm this, is to resetenv and check if firmware
> can set MAC and write it to nand
> Maybe there are some wd's tools for nand with
> stupid names but i couldn't find them so far
>
> So it needs more hacking and test to make install
> easier ;-)

That's what I've asked for :) we need serial console log that has printenv output, and boot log. And cat /proc/mtd. Once I see the info I can verify that the DTS is correct or not. The DTS will make the envs adjustment possible.

And then edit fw_env.config. And use fw_printenv/setenv to modify the envs.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
osa
Re: My Cloud Gen2 u-boot
January 31, 2020 06:21PM
Hi

Sorry for delay
bootlogt
Re: My Cloud Gen2 u-boot
February 01, 2020 04:00PM
osa,

Could you attach the log to your post, or pastebin it!

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: My Cloud Gen2 u-boot
June 23, 2020 08:42AM
I apparently did something stupid :-(. Which after a two day search lead me to this thread. So let me explain why I think I needed to kick it...

I was also annoyed with the bad CRC warning. A said the saveenv is missing, so I tried the setenv and printenv to check if my new one was found. Of course after a reboot it was gone again. Then I found the fw_setenv and fw_printenv commands in Debian (which I successfully installed with debootstrap). I found the correct values for fw_env.config and fw_printenv returned the same as I saw in U-Boot. Then I used the fw_setenv which seemed to work . However it nuked the flash as seen through the serial connection in the next boot:
BootROM - 1.51
Booting from SPI flash
BootROM: Bad header at offset D4000000
BootROM: Bad header at offset D4200000
BootROM: Bad header at offset D4400000
BootROM: Bad header at offset D4600000
BootROM: Bad header at offset D4800000
BootROM: Bad header at offset D4A00000
BootROM: Bad header at offset D4C00000
BootROM: Bad header at offset D4E00000

Trying Uart

I have another WD My Cloud Gen2, but (for now) not with a serial connection. I can use dd to get the content of the flash. I also found the GPL code WD released, however this only cotains a u-boot.bin without any source code. However I did find the source code on the Marvell git. It also explains that the U-Boot alone is not enough. The git however contains the source code for this extra part as far as I can see. It is probably also present in the found u-boot.bin because binwalk doesn't recognize it as a U-Boot image.

I ordered a flash programmer in China, but that takes probably a month or two to arrive.

I think that I've everything I need to use the Kirkwood boot and test if I can get it to boot again. I'm not sure if I can dd it to the flash chip, but if everything works it is just waiting for the programmer. If you guys have suggestions or questions, let me know. Further research could take a while because I've other things to do as well. This is for now just a project to fill spare time. I hope it will work in the end...
Re: My Cloud Gen2 u-boot
June 23, 2020 04:45PM
hvdkamer,

When you see this:

BootROM - 1.51
Booting from SPI flash
BootROM: Bad header at offset D4000000
BootROM: Bad header at offset D4200000
BootROM: Bad header at offset D4400000
BootROM: Bad header at offset D4600000
BootROM: Bad header at offset D4800000
BootROM: Bad header at offset D4A00000
BootROM: Bad header at offset D4C00000
BootROM: Bad header at offset D4E00000

Trying Uart

You don't need a flash programmer.

You only need to boot with kwboot using serial console. I'll look for my instruction for the MVEBU boxes here somewhere and suggest what to do.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: My Cloud Gen2 u-boot
June 23, 2020 04:55PM
See here:

https://forum.doozan.com/read.php?3,51739,51919#msg-51919

The post describes how to unbrick with kwboot for different box. For your box, you need the original mtd0 backup,

Quote

I have another WD My Cloud Gen2, but (for now) not with a serial connection. I can use dd to get the content of the flash. I also found the GPL code WD released, however this only cotains a u-boot.bin without any source code. However I did find the source code on the Marvell git. It also explains that the U-Boot alone is not enough. The git however contains the source code for this extra part as far as I can see. It is probably also present in the found u-boot.bin because binwalk doesn't recognize it as a U-Boot image.

Either your backup mtd0, or that u-boot.bin is probably the correct one to use with kwboot.

For modern u-boot, there is an SPL that used with u-boot proper. But for older Marvell u-boot, there is no need for SPL. That u-boot.bin is the older version.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: My Cloud Gen2 u-boot
June 24, 2020 03:46AM
Quote
bodhi
You don't need a flash programmer.

That was my plan B :-). I hoped:

Quote
bodhi
You only need to boot with kwboot using serial console.

that this was also possible. Thanks for the confirmation. The flash programmer is ordered, but it should be usefull for other projects as well.

Quote
bodhi
Either your backup mtd0

I think it should be possible with dd and then for if this bloeck device. However I also found manuals with nanddump. Not sure which one or both are correct. Will figure this out.

Quote
bodhi
For modern u-boot, there is an SPL that used with u-boot proper. But for older Marvell u-boot, there is no need for SPL. That u-boot.bin is the older version.

I have bootlogs before the earsing and this had a SPL:

BootROM - 1.51
Booting from SPI flash


General initialization - Version: 1.0.0
High speed PHY - Version: 0.1.1 (COM-PHY-V20)
USB2 UTMI PHY initialized succesfully
USB2 UTMI PHY initialized succesfully
High speed PHY - Ended Successfully

DDR3 Training Sequence - Ver 5.7.1
DDR3 Training Sequence - Run with PBS.
DDR3 Training Sequence - Ended Successfully
BootROM: Image checksum verification PASSED

 ** LOADER **


U-Boot 2013.01_v1.03 (Nov 20 2014 - 16:39:45) Marvell version: 2014_T2.0p3

The first part is the Marvell code for initialization and that source code is probably in the git I mentioned earlier. The second part is as far as I understand now the SPL. But this is my first time messing with U-Boot, so I'm not 100% sure...

I have the feeling that the u-boot.bin is old rubbish because it is different from what I found in a dd from the still working WD My Cloud. But with kwboot it should be safe to test all kind of things. Plus this board is for now toast anyway, so more harm shouldn't be possible :-).

The coming weeks I've other things to do. First is finishing installing and configuring Debian Buster on the still working WD My Cloud and then the same for a Seagate Personal Cloud. But any interesting results on the bricked one will be reported here. Unless someone objects to that :-).
Re: My Cloud Gen2 u-boot
June 24, 2020 04:53AM
hvdkamer,

> I have bootlogs before the earsing and this had a SPL:

> The first part is the Marvell code for
> initialization and that source code is probably in
> the git I mentioned earlier. The second part is as
> far as I understand now the SPL. But this is my
> first time messing with U-Boot, so I'm not 100%
> sure...

If it has SPL then it is not stock u-boot. Only modern u-boot for this box has SPL and u-boot images (the 1st part is SPL which contains the training code and u-boot is the 2nd part).

> I think it should be possible with dd and then for
> if this bloeck device. However I also found
> manuals with nanddump. Not sure which one or both
> are correct. Will figure this out.

Use nanddump to dump mtds. Don't use dd (that's not a good way to backup NAND).


> I have the feeling that the u-boot.bin is old
> rubbish because it is different from what I found
> in a dd from the still working WD My Cloud.

That's not a valid comparison. Even the same source code can produce different types of u-boot image.

> But
> with kwboot it should be safe to test all kind of
> things. Plus this board is for now toast anyway,
> so more harm shouldn't be possible :-).

Yes. Does not hurt to try kwboot that.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: My Cloud Gen2 u-boot
June 24, 2020 08:15AM
Quote
bodhi
If it has SPL then it is not stock u-boot. Only modern u-boot for this box has SPL and u-boot images (the 1st part is SPL which contains the training code and u-boot is the 2nd part).

I'm not sure if I understand you correctly. I feel like the first part of the second line contradicts the first? Or may be I'm misunderstanding some things. This is all pretty new for me...

Stock U-Boot has incomplete support for the Marvell Armada series. You can load a stock U-Boot through the Marvell U-Boot as said in the U-Boot patches for the Marvell Armada series in 2016. The missing part in stock U-Boot is initialization of the SerDes, DDR3 training and some other hardware. There is a git from Marvell which uses U-Boot 2013.01 with an extra tool for creating the initialization and training of DDR3. This part is missing in the stock U-Boot, although they could integrate it if I understand the licenses correctly.

If I understand the article on Wikipedia correctly, the SPL is the U-Boot code? Anyway, for the WD My Cloud I need the Marvell part, followed by the U-Boot. Or could U-Boot initialize this hardware on its own?

Quote
bodhi
Yes. Does not hurt to try kwboot that.

Ok, kwboot it is. And then a lot of experimenting to see what is needed. And hopefully get a stock U-Boot plus possible the Marvell part running. That should eliminate the many problems with the default version.
Re: My Cloud Gen2 u-boot
June 24, 2020 04:32PM
hvdkamer,

> The
> missing part in stock U-Boot is initialization of
> the SerDes, DDR3 training and some other hardware.

In stock Marvell u-boot for Armada, all these training code is in the u-boot header.

> If I understand the
> article
> on Wikipedia correctly, the SPL is the U-Boot
> code?

No, not u-boot code. In the current (ie. modern) Armada u-boot, there are 2 parts. SPL and U-Boot. What used to be inside stock U-Boot header now is in the SPL (the functionality only, in a completely different SW architecture, but it serves the same purpose).

>Anyway, for the WD My Cloud I need the
> Marvell part, followed by the U-Boot. Or could
> U-Boot initialize this hardware on its own?

It will work with stock u-boot.

So the bottom line is whether the image is old stock u-boot, or a new image built with SPL and u-boot combined, they both should be able to work with kwboot.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: My Cloud Gen2 u-boot
June 25, 2020 05:10AM
Quote
bodhi
they both should be able to work with kwboot.

I had some time, so I did some experiments with the still working WD My Cloud. This one boots Debian Buster with my own kernel. Your much newer kernel boots, bu no network connectivity. Something has changed between 4.18 and 4.19. I already have the rgmii patch in the .dts and this works up until 4.19. I see that the LED with indicates a up link doesn't come on in kernel 4.19 and higher. For now I use kernel 4.14.185 which is still maintained.

First I did a nanddump and repeated my dd experiment:

root@wdmc-archief:~# nanddump -f wdmc_2tb_mtd0.bin /dev/mtd0
ECC failed: 0
ECC corrected: 0
Number of bad blocks: 0
Number of bbt blocks: 0
Block size 65536, page size 1, OOB size 0
Dumping data starting at 0x00000000 and ending at 0x00100000...

Afterwards I compared al three versions:

root@wdmc-archief:~# md5sum wdmc_2tb_mtd*
8bb401517964db08dc4ab9b7de519676  wdmc_2tb_mtd0.bin
8bb401517964db08dc4ab9b7de519676  wdmc_2tb_mtd0.dd
8bb401517964db08dc4ab9b7de519676  wdmc_2tb_mtdblock0.dd

On OpenWrt I saw a warning that for NAND flash it is essential to use nanddump. However AFAIK this device uses a NOR flash. My experiment shows that both utilities give the same output.

However this and the u-boot.bin in the GPL tarball from WD can't be uploaded through kwboot. Further investigation learns that it needs a patch
because of a slightly different output from the BROM in newer Marvell SOCs. That will be the next experiment...
Re: My Cloud Gen2 u-boot
June 25, 2020 06:01AM
> from WD can't be uploaded through kwboot. Further
> investigation learns that it needs a
> patch
> because of a slightly different output from the
> BROM in newer Marvell SOCs.

That's hmartin.

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

And the kwboot patch was Kevin Smith's fallback patch. It works for WD EX2100, so it might or might not work for this box.

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



Edited 1 time(s). Last edit at 06/25/2020 06:07AM by bodhi.
Re: My Cloud Gen2 u-boot
June 25, 2020 04:55PM
The ethernet issue was fixed by osa, since kernel 5.3.5-mvebu-tld-1:

https://forum.doozan.com/read.php?2,94839,95014#msg-95014

Kernel linux-5.6.9-mvebu-tld-1 has this patch.

-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: