Welcome! Log In Create A New Profile

Advanced

help flashing u-boot onto ix4-200d NAND

Posted by mgx 
mgx
help flashing u-boot onto ix4-200d NAND
February 02, 2021 01:51PM
Hello,

i have bought a faulty iomega ix4-200d which got the NAND flash erased. long story short, following this topic https://forum.doozan.com/read.php?3,25120 I have now fully working iomega ix4-200d grandpa. Problem was, that SHEEVAPLUG U-Boot could not be booted off the flash and the mtd0.bin file I have found in that thread did not recognize USB devices, so current status is:

kernel: Linux iomega 5.2.9-kirkwood-tld-1 #1 PREEMPT Sat Aug 17 15:00:56 PDT 2019 armv5tel GNU/Linux
rootfs: Debian-5.2.9-kirkwood-tld-1-rootfs-bodhi.tar.bz2
dtb: kirkwood-iomega_ix4_200d.dtb (DTB file embedded in the kernel image)

the only option that worked for me was kernel + initrd are stored in 32MB NAND just after u-boot, I can post details if needed. RootFS is on the first SATA disk on first ext2 partition labeled as rootfs.

My problem (i knew it has to come but did not expect that early) is that the initrd image does not contain for example e2fsck or fuse. apt-get tries to generate new initrd image but that is being ignored because my NAS is booting kernel and ramdisk from NAND.

I have tried to replace ramdisk in NAND with the one generated by apt, but got "Bad magic number"


I'm not a master in linux, I'm happy to get this far, but is there anyone who could help me with following?

WHAT I NEED IS: I would like to get u-boot to boot Kernel and Ramdisk from either SATA disk or USB storage and not NAND, because I would like to update the kernel. . Sheevaplug u-boot loaded from UART works perfectly. But when flashed to NAND the box hangs right after power-on with no output on UART. Seems it does not find u-boot in NAND even when I used the same address to flash it.

would be anyone so kind and go through this nightmare with me?

I have the NAS attached on UART and can do kwboot and tftp, that's how I managed to get it working.

thanks
martin



Edited 3 time(s). Last edit at 02/03/2021 05:45AM by mgx.
Re: help flashing Sheevaplug u-boot onto ix4-200d NAND
February 02, 2021 04:55PM
martin,

> Sheevaplug u-boot loaded
> from UART works perfectly. But when flashed to
> NAND the box hangs right after power-on with no
> output on UART.

It is good that it can be used to rescue your box with kwboot. But Sheevaplug u-boot is not the correct u-boot for this box. So don't flash it.

> off the flash and the mtd0.bin file I have found
> in that thread did not recognize USB devices,

Still it is the correct u-boot, so it should be flashed to NAND to make the box completely unbricked first.

Usually, I would build new u-boot for it, if I have the GPL source for stock u-boot. But ATM, I don't have enough free time to embark on a time consuming project.

> boot Kernel and Ramdisk from either SATA disk or
> USB storage and not NAND, because I would like to
> update the kernel.

You can boot kernel and initrd from raw sectors on HDD. See the ix2-dl instruction:

https://forum.doozan.com/read.php?2,70294,70794#msg-70794

Other than that HDD raw sectors option, you can also boot the kernel and initrd from a tftp server, if you have another Linux NAS running permamently in your network. That way you don't have to worry about wearing NAND.

And don't worry, I'll help to make it work.

-bodhi
===========================
Forum Wiki
bodhi's corner
mgx
Re: help flashing Sheevaplug u-boot onto ix4-200d NAND
February 03, 2021 12:37AM
Hi bodhi,

thanks for the response.

Well, now I have only one problem I cannot live with: initrd does not contain fuse and e2fsck and I don't really know how I could produce new initrd that could be used for booting.

I have followed your instructions to build the kernel image and initrd here: https://forum.doozan.com/read.php?2,12096

I used method 4B, to include DTB file in the kernel image. That works good.


but when I install e2fsprogs (which kernel expects to be in initrd), new initrd is being produced in /boot folder. When I use that initrd for booting in u-boot, I get Bad magic. Is there any way to use this initrd? or maybe create new initrd with fuse and e2fsprogs included?

I'd really like to know how to fix it myself, but anything would help :)

thanks a lot
Re: help flashing Sheevaplug u-boot onto ix4-200d NAND
February 03, 2021 04:07AM
mgx,

> but when I install e2fsprogs (which kernel expects
> to be in initrd), new initrd is being produced in
> /boot folder. When I use that initrd for booting
> in u-boot, I get Bad magic. Is there any way to
> use this initrd? or maybe create new initrd with
> fuse and e2fsprogs included?

Whenever a new initrd is generated by the Debian, you need to recreate uInitrd so that it can be used for booting.

When you have question like this, you need to post the log of what you did, so I know where you are. For example, did you dd the kernel files to HDD raw sectors? what is the bootlog looks like?

-bodhi
===========================
Forum Wiki
bodhi's corner
mgx
Re: help flashing Sheevaplug u-boot onto ix4-200d NAND
February 03, 2021 04:11AM
yah understood. Now I'm preparing 5.10.7-kirkwood-tld-1 kernel and initrd for booting and once I have it ready I will paste here what I'm doing. Thanks a lot for response, I appreciate
mgx
Re: help flashing Sheevaplug u-boot onto ix4-200d NAND
February 03, 2021 05:37AM
okay so here is a bit longer post. Here is what I did. It does not really matter how the device is booting at the beginning. On the end it will boot linux from NAND.

so as I said the main goal was to install e2fsprogs and fuse. But that generated new initrd, so let's start with this

#install fuse and e2fsprogs will generate new initramfs

root@iomega:~# sudo apt install --reinstall fuse e2fsprogs
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 2 reinstalled, 0 to remove and 65 not upgraded.
Need to get 616 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://ftp.us.debian.org/debian buster/main armel e2fsprogs armel 1.44.5-1+deb10u3 [546 kB]
Get:2 http://ftp.us.debian.org/debian buster/main armel fuse armel 2.9.9-1+deb10u1 [70.0 kB]
Fetched 616 kB in 1s (580 kB/s)
(Reading database ... 27990 files and directories currently installed.)
Preparing to unpack .../e2fsprogs_1.44.5-1+deb10u3_armel.deb ...
Preparing to unpack .../fuse_2.9.9-1+deb10u1_armel.deb ...0u3) ...
Unpacking fuse (2.9.9-1+deb10u1) over (2.9.9-1+deb10u1) ...
Setting up fuse (2.9.9-1+deb10u1) ...
update-initramfs: deferring update (trigger activated)
Setting up e2fsprogs (1.44.5-1+deb10u3) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for initramfs-tools (0.133) ...
update-initramfs: Generating /boot/initrd.img-5.10.7-kirkwood-tld-1
I: The initramfs will attempt to resume from /dev/sda3
I: (UUID=82901f44-1a2b-40c4-96c5-087eb009f471)
I: Set the RESUME variable to override this.



then regenerate new initrd, but let's do the kernel too

root@iomega# cd ~/_newkernel

#copy the newly generated initrd to current dir and continue following guide on Kirkwood Debian page https://forum.doozan.com/read.php?2,12096
root@iomega:~/_newkernel# cp /boot/initrd.img-5.10.7-kirkwood-tld-1 ./

root@iomega:~/_newkernel# cp -a zImage-5.10.7-kirkwood-tld-1  zImage.fdt

root@iomega:~/_newkernel# cat dts/kirkwood-iomega_ix4_200d.dtb >> zImage.fdt

root@iomega:~/_newkernel# mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n 5.10.7-kirkwood-tld-1 -d zImage.fdt  uImage-5.10.7-v2
  initrd.img-5.10.7-kirkwood-tld-1
  0 -e 0x00008000 -n 5.10.7-kirkwood-tld-1 -d zImage.fdt  uImage-5.10.7-v2x00008000
  Image Name:   5.10.7-kirkwood-tld-1
  Created:      Wed Feb  3 11:58:40 2021
  Image Type:   ARM Linux Kernel Image (uncompressed)
  Data Size:    5325730 Bytes = 5200.91 KiB = 5.08 MiB
  Load Address: 00008000
  Entry Point:  00008000

root@iomega:~/_newkernel# mkimage -A arm -O linux -T ramdisk -C gzip -a 0x00000000 -e 0x00000000 -n initramfs-5.10.7-kirkwood-tld-1 -d initrd.img-5.10.7-kirkwood-tld-1 uInitrd-5.10.7-v2
  Image Name:   initramfs-5.10.7-kirkwood-tld-1
  Created:      Wed Feb  3 11:58:47 2021
  Image Type:   ARM Linux RAMDisk Image (gzip compressed)
  Data Size:    9567229 Bytes = 9343.00 KiB = 9.12 MiB
  Load Address: 00000000
  Entry Point:  00000000


now we have uInitrd-5.10.7-v2 and uImage-5.10.7-v2, let's upload them to TFTP server and interrupt U-Boot


__  __                      _ _
        |  \/  | __ _ _ ____   _____| | |
        | |\/| |/ _` | '__\ \ / / _ \ | |
        | |  | | (_| | |   \ V /  __/ | |
        |_|  |_|\__,_|_|    \_/ \___|_|_|
 _   _     ____              _
| | | |   | __ )  ___   ___ | |_ 
| | | |___|  _ \ / _ \ / _ \| __| 
| |_| |___| |_) | (_) | (_) | |_ 
 \___/    |____/ \___/ \___/ \__|  ** uboot_ver:v1.1.1 **

 ** MARVELL BOARD: IX4-110 LE 

U-Boot 1.1.4 (Mar 10 2011 - 15:01:57) Marvell version: 3.4.18

U-Boot code: 00600000 -> 0067FFF0  BSS: -> 006CF600

Soc: 88F6281 A1 (DDR2)
CPU running @ 1200Mhz L2 running @ 400Mhz
SysClock = 400Mhz , TClock = 200Mhz 

DRAM CAS Latency = 5 tRP = 5 tRAS = 18 tRCD=6
DRAM CS[0] base 0x00000000   size 256MB 
DRAM CS[1] base 0x10000000   size 256MB 
DRAM Total size 512MB  16bit width
Found 0x20 i2c device
Set Power State as Always On
Addresses 8M - 0M are saved for the U-Boot usage.
Mem malloc Initialization (8M - 7M): Done
NAND:32 MB
Found ADT7473, program LED ...(led_volt=90)  OK
Found ADT7473, program thermal/Fan ...(pwm_min=0) (pwm_max=130) (therm=67) (temp_min=60)  OK

Marvell Serial ATA Adapter
Integrated Sata device found


CPU : Marvell Feroceon (Rev 1)
Found initrd at 0x1000000

Streaming disabled 
Write allocate disabled

Module 0 is RGMII
Module 1 is RGMII

USB 0: host mode
PEX 0: PCI Express Root Complex Interface
PEX interface detected Link X1
SCSI:  AHCI 0001.0000 32 slots 3 ports 3 Gbps 0x7 impl IDE mode
flags: 64bit ncq stag led pmp slum part 
scanning bus for devices...
  Device 0: (0:0) Vendor: ATA Prod.: WDC WD30EFRX-68E Rev: 82.0
            Type: Hard Disk
            Capacity: 764436.4 MB = 746.5 GB (1565565872 x 512)
  Device 1: (1:0) Vendor: ATA Prod.: WDC WD30EFRX-68E Rev: 82.0
            Type: Hard Disk
            Capacity: 764436.4 MB = 746.5 GB (1565565872 x 512)
Net:   egiga0 [PRIME], egiga1
Hit any key to stop autoboot:  0 
Marvell>> 
Marvell>>

now load uImage-5.10.7-v2 to 0x2000000

Marvell>> tftpboot 0x2000000 uImage-5.10.7-v2
Using egiga0 device
TFTP from server 10.0.0.238; our IP address is 10.0.0.5
Filename 'uImage-5.10.7-v2'.
Load address: 0x2000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #
done
Bytes transferred = 5325794 (5143e2 hex)
and note the transferred HEX bytes 5143e2

do the same with uInitrd-5.10.7-v2, but load it into 0x12000000
Marvell>> tftpboot 0x12000000 uInitrd-5.10.7-v2
Using egiga0 device
TFTP from server 10.0.0.238; our IP address is 10.0.0.5
Filename 'uInitrd-5.10.7-v2'.
Load address: 0x12000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################
done
Bytes transferred = 9567293 (91fc3d hex)
and note the HEX size 91fc3d

here is the printenv
Marvell>> printenv
bootdelay=1
baudrate=115200
loads_echo=0
rootpath=/mnt/ARM_FS/
run_diag=yes
CASset=min
MALLOC_len=1
ethprime=egiga0
bootargs_end=:::DB88FXX81:eth0:none
image_name=uImage
console=console=ttyS0,115200 mtdparts=nand_mtd:0xa0000@0x0(uboot),0x00010000@0x000a0000(param),32m@0x0(flash) 
uboot_start=0x0
uboot_size=0xa0000
env_start=0xa0000
env_size=0x10000
kernel_start=0xb0000
flash_load=run make_boot_args;nand read.e 0x2000000 $(kernel_start) $(kernel_size);nand read.e 0x12000000 $(initrd_start) $(initrd_size);bootm 0x2000000 0x12000000;
bootcmd=run flash_load;
standalone=fsload 0x2000000 $(image_name);setenv bootargs $(console) root=/dev/mtdblock0 rw ip=$(ipaddr):$(serverip)$(bootargs_end); bootm 0x2000000;
ethmtu=1500
mvNetConfig=mv_net_config=(00:11:88:0f:62:81,0:1:2:3),mtu=1500
usb0Mode=host
nandEcc=1bit
netretry=no
rcvrip=169.254.100.100
loadaddr=0x02000000
autoload=no
uboot_ver=v1.1.1
kernel_size=0x4be192
initrd_size=0x943910
rootfs=LABEL=rootfs
bootargs=console=ttyS0,115200 root=LABEL=rootfs rootdelay=10
bootargs_root=root=LABEL=rootfs
make_boot_args=setenv bootargs console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 mtdparts=nand_mtd:0xa0000@0x0(uboot),0x10000@0xa0000(env),0x4be192@0xb0000(zImage),0x943910@0x1000000(initrd),32m@0x0(flash)
ethaddr=00:50:43:86:1a:36
stdin=serial
stdout=serial
stderr=serial
mainlineLinux=no
enaMonExt=no
enaCpuStream=no
enaWrAllo=no
pexMode=RC
disL2Cache=no
setL2CacheWT=yes
disL2Prefetch=yes
enaICPref=yes
enaDCPref=yes
sata_dma_mode=yes
netbsd_en=no
vxworks_en=no
initrd_start=0x1000000
disaMvPnp=no
eth1addr=00:50:43:86:1a:37
enaAutoRecovery=yes
pcieTune=no
ethact=egiga0
filesize=91fc3d
fileaddr=12000000
netmask=255.255.255.0
ipaddr=10.0.0.5
serverip=10.0.0.238

Environment size: 1720/16380 bytes

note that there is rootfs reference, without the initramfs will stop. there MUST be a disk detected, which has root partition labeled as "rootfs"

try to boot from loaded kernel and initrd
Marvell>> bootm 0x2000000 0x12000000
## Booting image at 02000000 ...
   Image Name:   5.10.7-kirkwood-tld-1
   Created:      2021-02-03  10:58:40 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    5325730 Bytes =  5.1 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK
## Loading Ramdisk Image at 12000000 ...
   Image Name:   initramfs-5.10.7-kirkwood-tld-1
   Created:      2021-02-03  10:58:47 UTC
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    9567229 Bytes =  9.1 MB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.


blablabla.
...
...
...


Debian GNU/Linux 10 iomega ttyS0

iomega login: root
Password: 
Last login: Wed Feb  3 11:45:07 CET 2021 on ttyS0
Linux iomega 5.10.7-kirkwood-tld-1 #1.0 PREEMPT Thu Jan 14 20:28:12 PST 2021 armv5tel

root@iomega:~# e2
e2freefrag   e2fsck       e2image      e2label      e2mmpstatus  e2undo
#works, it booted without provblems, e2fsck is there, so let's burn the initrd and kernel into NAND

reboot and interrupt u-boot and load the uImage and initrd again, same addresses

Marvell>> tftpboot 0x2000000 uImage-5.10.7-v2
Using egiga0 device
TFTP from server 10.0.0.238; our IP address is 10.0.0.5
Filename 'uImage-5.10.7-v2'.
Load address: 0x2000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #
done
Bytes transferred = 5325794 (5143e2 hex)
Marvell>> tftpboot 0x12000000 uInitrd-5.10.7-v2
Using egiga0 device
TFTP from server 10.0.0.238; our IP address is 10.0.0.5
Filename 'uInitrd-5.10.7-v2'.
Load address: 0x12000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################
done
Bytes transferred = 9567293 (91fc3d hex)


# target NAND address to put new kernel is 0xb0000 with length 0x5143e2 (note you made when tftpbooting uImage)
# target NAND address to put new kernel is 0x1000000 with length 0x91fc3d (note you made when tftpbooting uInitrd)
# now erase the areas first

Marvell>> nand erase 0xb0000 0x5143e2

NAND erase: device 0 offset 0xb0000, size 0x5143e2
Erasing at 0x5c4000 -- 100% complete.
OK
Marvell>> nand erase 0x1000000 0x91fc3d

NAND erase: device 0 offset 0x1000000, size 0x91fc3d
Erasing at 0x191c000 -- 100% complete.
OK

then write

Marvell>> nand write.e 0x2000000 0x0b0000 0x5143e2

NAND write: device 0 offset 0xb0000, size 0x5143e2

Writing data at 0x5c4200 -- 100% complete.
 5325794 bytes written: OK
Marvell>> nand write.e 0x12000000 0x1000000 0x91fc3d

NAND write: device 0 offset 0x1000000, size 0x91fc3d

Writing data at 0x191fc00 -- 100% complete.
 9567293 bytes written: OK


Don't forget to set new envs that tell the u-boot how much data to read from NAND. use values noted when TFTPing
Marvell>> setenv kernel_size 0x5143e2
Marvell>> setenv initrd_size 0x91fc3d
Marvell>> saveenv
Saving Environment to NAND...
Erasing Nand...Writing to Nand... done



it's done. Now type either reset or boot, or plug out the cable and reinsert. New kernel and Initrd is in NAND and it's booting properly. The only ugly thing is, that if I want to boot new kernel, I have to reflash that again.

I would still be happy if anyone could compile an u-boot that allows me to use Devicetree files from ext2 or ext3 drive (USB, SATA). The stock one does not support loadint DTB file so I have to include it in the kernel that is loading. That's all this thread is about really

thanks for the guidance bodhi, you directed me and I have now what I wanted. thanks again



Edited 1 time(s). Last edit at 02/03/2021 05:48AM by mgx.
Re: help flashing Sheevaplug u-boot onto ix4-200d NAND
February 03, 2021 03:42PM
mgx,

Well done!

> The only ugly thing is, that if I want to boot new kernel, I have to reflash that again

Yeah. That's why the HDD raw sectors approach is better in that you can regularly upgrade Debian and kernel.


> I would still be happy if anyone could compile an
> u-boot that allows me to use Devicetree files from
> ext2 or ext3 drive (USB, SATA). The stock one does
> not support loadint DTB file so I have to include
> it in the kernel that is loading. That's all this
> thread is about really

Usually I would build it, but ATM I don't have enough free time.

Glad you got it working well.

-bodhi
===========================
Forum Wiki
bodhi's corner
mgx
Re: help flashing Sheevaplug u-boot onto ix4-200d NAND
February 03, 2021 03:46PM
Thanks bodhi,

Just one question: is it possible the latest kernel does not include support for cifs? Cannot map any smb
Can I fix it somehow on my end?

Thanks a lot
Re: help flashing Sheevaplug u-boot onto ix4-200d NAND
February 03, 2021 03:53PM
mgx,

> Just one question: is it possible the latest
> kernel does not include support for cifs? Cannot
> map any smb

It does supports CIFS, but as a loadable module (to save space). So try to load it on the fly:
modprobe cifs

And to make cifs available during boot, add it to the list in /etc/initramfs-tools/modules. And regenerate initramfs
update-initramfs -u

and then recreate uInitrd.

-bodhi
===========================
Forum Wiki
bodhi's corner
mgx
Re: help flashing Sheevaplug u-boot onto ix4-200d NAND
February 03, 2021 03:54PM
Aaaah yes, that's perfect, thanks a lot! You are the king!

but there is a problem with module:
root@iomega:~# modprobe cifs
modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/5.10.7-kirkwood-tld-1/modules.dep.bin'
modprobe: FATAL: Module cifs not found in directory /lib/modules/5.10.7-kirkwood-tld-1
root@iomega:~# cd /lib/modules/
root@iomega:/lib/modules# ls
.  ..  5.2.9-kirkwood-tld-1
root@iomega:/lib/modules# ln -s ./5.2.9-kirkwood-tld-1/ ./5.10.7-kirkwood-tld-1
root@iomega:/lib/modules# ls -la
total 12
drwxr-xr-x  3 root root 4096 Feb  3 23:04 .
drwxr-xr-x 13 root root 4096 Aug 25  2019 ..
lrwxrwxrwx  1 root root   23 Feb  3 23:04 5.10.7-kirkwood-tld-1 -> ./5.2.9-kirkwood-tld-1/
drwxr-xr-x  3 root root 4096 Aug 25  2019 5.2.9-kirkwood-tld-1
root@iomega:/lib/modules# modprobe cifs
modprobe: ERROR: could not insert 'cifs': Exec format error


let me try to solve it, it has to go okay. Most probably I need to prepare everything for kernel update and then it will find the modules



Edited 2 time(s). Last edit at 02/03/2021 04:09PM by mgx.
mgx
Re: help flashing Sheevaplug u-boot onto ix4-200d NAND
February 03, 2021 04:13PM
yeah all sorted, thanks :)
Re: help flashing Sheevaplug u-boot onto ix4-200d NAND
February 03, 2021 10:23PM
Cool!

-bodhi
===========================
Forum Wiki
bodhi's corner
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: