Welcome! Log In Create A New Profile

Advanced

HOWTO: Lenovo ix2-dl / Stock U-Boot, boot current kernel, access printenv from Debian, load kernel from GPT ide drive

Posted by jdwl101 
Re: Lenovo ix2-dl, boot new kernel and write and boot from flash
October 22, 2018 03:31AM
J,

I've added Eine's post to the Wiki

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

Quote

Booting Debian on Pogoplug

How to set up U-Boot for booting in multiple drives configuration
Backup and Restore NAND mtds
UART Booting HowTo for Selected Kirkwood Devices
Migrating from Arch to Debian?
How to boot new Debian rootfs using stock u-boot tftp - Pogo E02
How to boot new Debian rootfs on USB using stock u-boot - NSA325
Booting Debian rootfs on a GPT HDD with stock u-boot (with kernel files stored in HDD raw sector)

If you could clean up your post a bit to make clear what you did, I'd like to add that as a 2nd tutorial on the same topic. Thanks!

-bodhi
===========================
Forum Wiki
bodhi's corner
Below sets out how I was able to 1) configure an IX2-DL to boot from a USB Debian rootfs, with u-boot env access and then 2) from the internal GPT partitioned sata drives. Without needing to update the u-boot to something more modern and functional.

Note: you cannot go back to Stock after making these changes as the IX2’s stock partitions will be deleted. You could try making stock co-exist, I have no interest in booting stock again.

I used a serial console throughout, theoretically these steps could be completed using fw_setenv from ssh, but I'd recommend having a TTL cable available for if anything fails.

Start with USB booting to get Debian running (Bodhi’s 4.12 rootfs);
setenv load_initrd 'ext2load usb 0:1 0x2100000 /boot/uInitrd'
setenv load_uimage 'ext2load usb 0:1 0x800000 /boot/uImage'
setenv usb_boot 'usb start; run load_uimage; run load_initrd; bootm 0x800000 0x2100000'
setenv bootargs 'console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 mtdparts=orion_nand:0x80000@0(uboot),0x20000@0xa0000(env),0x20000@0xc0000(env2),0x300000@0x100000(uImage),0x400000@0x400000(initrd),0x3f800000@0x800000(boot),1024m@0x0(flash)  earlyprintk=serial'

Optional, use ar-lex’s DTS and DTB, specific to the IX2-DL (only)
IX2-DL custom DTB

This will give you a system booting Debian from USB, with USB rootfs;
** MARVELL BOARD: DB-88F6282A-BP LE

U-Boot 1.1.4 (Oct 28 2011 - 15:19:29) Marvell version: 3.6.1 - EMC

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

Soc: 88F6282 A1 CPU running @ 1600Mhz L2 running @ 533Mhz
SysClock = 533Mhz , TClock = 200Mhz

DRAM (DDR3) CAS Latency = 7 tRP = 7 tRAS = 20 tRCD=7
DRAM CS[0] base 0x00000000   size 256MB
DRAM Total size 256MB  16bit width
Addresses 8M - 0M are saved for the U-Boot usage.
Mem malloc Initialization (8M - 7M): Done
NAND:1024 MB
Found ADT7473, program PWM1 ... OK
Flash:  0 kB

Marvell Serial ATA Adapter
Integrated Sata device found
[0 0 0]: Enable DMA mode (6)
  Device 0 @ 0 0:
Model: ST2000DM001-1CH164                       Firm: CC26     Ser#:             Z2F0PEJZ
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 1907729.0 MB = 1863.0 GB (-387938128 x 512)
[0 1 0]: Enable DMA mode (6)
  Device 1 @ 0 1:
Model: ST1000DM003-9YN162                       Firm: CC9D     Ser#:             Z1D0F6TF
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 953869.7 MB = 931.5 GB (1953525168 x 512)


CPU : Marvell Feroceon (Rev 1)
Found kernel at 0x100000
Found initrd at 0x400000

Streaming disabled
Write allocate disabled


USB 0: host mode
PEX 0: interface detected no Link.
PEX 1: interface detected no Link.
Net:   egiga0 [PRIME]
Hit any key to stop autoboot:  0
Marvell>> setenv load_initrd 'ext2load usb 0:1 0x2100000 /boot/uInitrd.4.12'
Marvell>> setenv load_uimage 'ext2load usb 0:1 0x800000 /boot/uImage.4.12'
Marvell>> setenv usb_boot 'usb start; run load_uimage; run load_initrd; bootm 0x800000 0x2100000'
Marvell>> boot
(Re)start USB...
USB:   scanning bus for devices... 2 USB Device(s) found
Waiting for storage device(s) to settle before scanning...
1 Storage Device(s) found
....
.................................................................................................................................................................................................................................................................................................................................................................................

3834683 bytes read
....
..............................................................................................................................................................
.
.......................................................................................................................................................................................................................................................
.........................................................................................................................................................................................................................................................................................................................................................................................................

8268888 bytes read
## Booting image at 00800000 ...
   Image Name:   Linux-4.12.1-kirkwood-tld-1
   Created:      2018-10-20   0:48:49 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3834619 Bytes =  3.7 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK
## Loading Ramdisk Image at 02100000 ...
   Image Name:   initramfs-4.12.1-kirkwood-tld-1
   Created:      2018-10-20   0:49:12 UTC
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    8268824 Bytes =  7.9 MB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK

Starting kernel ...
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.18.4-kirkwood-tld-1 (root@tldDebian) (gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)) #1 PREEMPT Fri Aug 24 22:13:40 PDT 2018
[    0.000000] CPU: Feroceon 88FR131 [56251311] revision 1 (ARMv5TE), cr=0005397f
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] OF: fdt: Machine model: Lenovo IX2-ng

With populated MTD devices;
[    6.572050] Creating 6 MTD partitions on "orion_nand":
[    6.577335] 0x000000000000-0x000000080000 : "uboot"
[    6.583012] 0x0000000a0000-0x0000000c0000 : "env"
[    6.588430] 0x0000000c0000-0x0000000e0000 : "env2"
[    6.593955] 0x000000100000-0x000000400000 : "uImage"
[    6.599739] 0x000000400000-0x000000800000 : "initrd"
[    6.605568] 0x000000800000-0x000040000000 : "boot"
>  cat /proc/mtd
> dev:    size   erasesize  name
> mtd0: 00080000 00020000 "uboot"
> mtd1: 00020000 00020000 "env"
> mtd2: 00020000 00020000 "env2"
> mtd3: 00300000 00020000 "uImage"
> mtd4: 00400000 00020000 "initrd"
> mtd5: 3f800000 00020000 "boot"

To access u-boot variables from Debian (usually problematic with this box) add this to /etc/fw_env.config
# MTD device name       Device offset   Env. size       Flash sector size      $
/dev/mtd1 0x0000 0x20000 0x20000
/dev/mtd2 0x0000 0x20000 0x20000
Only 1 entry should be required (MTD1), on my IX2 it oddly needs both to read and write the variables, but works and doesn’t throw errors.
This means we have a 100% functional kernel and Debian install on USB, without upgrading u-boot.

Part II – booting from sata/IDE w/ GPT partition table
The IX2-DL is a dual drive NAS, so we can host rootfs and images on the sata drives. I originally planned to write the uImage and uInitrd to flash, turns out the stock partitions are too small and the mtd sizes would have to change and Bodhi doesn’t recommend flash booting anyway. So I used the sata drives to host the images instead.

This is easiest to set up if the drives are blank, if you can back up your data and start fresh that will be easiest. For drives under 2TB you could then partition using MBR and u-boot will be able to load the images off an ext2 /boot partition.
I didn’t have sufficient storage to back up the 3TB of data I have on the IX2, so took the risk.

The main issue with loading images from large sata drives, or drives partitioned by the stock install, is the old u-boot doesn’t support GPT. This means u-boot doesn’t recognise any partitions on the drives. There is a way around this though, documented by Eine here;
Booting from GPT drive on stock u-boot

This solution uses ‘ide read’ in u-boot to load the uImage and uInitrd directly from drive sectors, ignoring the partition table. To make it work you need a drive partitioned with free space at the beginning, 128MiB is sufficient.

To avoid losing any of my stored data on the drives I kept the mdadm setup for the DATA volume group, but deleted MD0, the stock raid 1 root file system. That give 20GB of free space on each drive. This has risks, be careful, if you can backup first do so.
Example Partition table:
Model: ATA ST1000DM003-9YN1 (scsi)
Disk /dev/sdc: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      128MB   21.5GB  21.4GB   ext4        rootfs
 2      21.5GB  1000GB  979GB                primary  msftdata

Partition 1 is where you extract Bodhi’s rootfs and configure using his instructions (or copy your existing USB rootfs). Partition 2 is the existing mdadm raid / LVM volume.

Next write a working uImage and uInitrd to the unpartitioned space before partition 1, avoiding the GPT table. Make sure the dd is to the drive partitioned above!

/kernels# dd if=uImage of=/dev/sdc bs=1MiB seek=10
3+1 records in
3+1 records out
4171272 bytes (4.2 MB, 4.0 MiB) copied, 3.1455 s, 1.3 MB/s

/kernels# dd if=uInitrd of=/dev/sdc bs=1MiB seek=20
9+1 records in
9+1 records out
9762728 bytes (9.8 MB, 9.3 MiB) copied, 0.196305 s, 49.7 MB/s

Reboot into u-boot to load the images from the sata drive. Key here is in Eine’s guide the uInitrd was smaller, we need to change the ide read command to load the entire image into memory by setting the size to 0x4F00 (up from 0x4000).

The ide device command sets which drive is being read from, needed as this is a 2 drive NAS.

The imi command then confirms that the loaded image is complete.
U-Boot 1.1.4 (Oct 28 2011 - 15:19:29) Marvell version: 3.6.1 - EMC

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

Soc: 88F6282 A1 CPU running @ 1600Mhz L2 running @ 533Mhz
SysClock = 533Mhz , TClock = 200Mhz

DRAM (DDR3) CAS Latency = 7 tRP = 7 tRAS = 20 tRCD=7
DRAM CS[0] base 0x00000000   size 256MB
DRAM Total size 256MB  16bit width
Addresses 8M - 0M are saved for the U-Boot usage.
Mem malloc Initialization (8M - 7M): Done
NAND:1024 MB
Found ADT7473, program PWM1 ... OK
Flash:  0 kB

Marvell Serial ATA Adapter
Integrated Sata device found
[0 0 0]: Enable DMA mode (6)
  Device 0 @ 0 0:
Model: ST2000DM001-1CH164                       Firm: CC26     Ser#:             Z2F0PEJZ
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 1907729.0 MB = 1863.0 GB (-387938128 x 512)
[0 1 0]: Enable DMA mode (6)
  Device 1 @ 0 1:
Model: ST1000DM003-9YN162                       Firm: CC9D     Ser#:             Z1D0F6TF
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 953869.7 MB = 931.5 GB (1953525168 x 512)


CPU : Marvell Feroceon (Rev 1)
Found kernel at 0x100000
Found initrd at 0x400000

Streaming disabled
Write allocate disabled


USB 0: host mode
PEX 0: interface detected no Link.
PEX 1: interface detected no Link.
Net:   egiga0 [PRIME]
Hit any key to stop autoboot:  0
Marvell>> ide device 1;ide read 0x2100000 0xA000 0x4F00

IDE device 1: Model: ST1000DM003-9YN162                       Firm: CC9D     Ser#:             Z1D0F6TF
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 953869.7 MB = 931.5 GB (1953525168 x 512)
... is now current device

IDE read: device 1 block # 40960, count 20224 ... 20224 blocks read: OK
Marvell>> imi 0x2100000

## Checking Image at 02100000 ...
   Image Name:   initramfs-4.18.4-kirkwood-tld-1
   Created:      2018-10-20  19:08:21 UTC
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    9762664 Bytes =  9.3 MB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK

If the images check out set bootcmd to load both the uImage and uInitrd and boot.
Marvell>> setenv bootcmd 'ide device 1; ide read 0x40000 0x5000 0x2000; ide read 0x2100000 0xA000 0x4F00; bootm 0x40000 0x2100000'
Marvell>> boot

IDE device 1: Model: ST1000DM003-9YN162                       Firm: CC9D     Ser#:             Z1D0F6TF
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 953869.7 MB = 931.5 GB (1953525168 x 512)
... is now current device

IDE read: device 1 block # 20480, count 8192 ... 8192 blocks read: OK

IDE read: device 1 block # 40960, count 20224 ... 20224 blocks read: OK
## Booting image at 00040000 ...
   Image Name:   Linux-4.18.4-kirkwood-tld-1
   Created:      2018-10-21   2:09:48 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4171208 Bytes =  4 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK
## Loading Ramdisk Image at 02100000 ...
   Image Name:   initramfs-4.18.4-kirkwood-tld-1
   Created:      2018-10-20  19:08:21 UTC
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    9762664 Bytes =  9.3 MB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK

Starting kernel ...

If all went to plan save the new bootcmd using fw_setenv in Debian, or write the new bootcmd from u-boot.

Enjoy your upgraded IX2-DL, all without needing any u-boot change.

Any questions let me know.
Thanks! added to the Wiki thread.

-bodhi
===========================
Forum Wiki
bodhi's corner
Some additional info;

Server Performance for the Ix2-DL on Debian Squeeze / Kernel 4.18;
- NFS ~65MB per second
- Samba ~63MB per second

That is around double the stock performance, see SNB Review

Format of the Flash boot partition is UBIFS, easily mounted using UBI Attach;
Dmesg of mounting
[ 2915.192097] ubi0: attaching mtd5
[ 2915.902529] ubi0: scanning is finished
[ 2915.918166] ubi0 warning: ubi_eba_init: cannot reserve enough PEBs for bad PEB handling, reserved 81, need 157
[ 2915.930989] ubi0: attached mtd5 (name "boot", size 1016 MiB)
[ 2915.937018] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
[ 2915.943928] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[ 2915.951180] ubi0: VID header offset: 512 (aligned 512), data offset: 2048
[ 2915.958955] ubi0: good PEBs: 8125, bad PEBs: 3, corrupted PEBs: 0
[ 2915.965269] ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
[ 2915.973484] ubi0: max/mean erase counter: 13/7, WL threshold: 4096, image sequence number: 0
[ 2915.982434] ubi0: available PEBs: 0, total reserved PEBs: 8125, PEBs reserved for bad PEB handling: 81
[ 2915.992009] ubi0: background thread "ubi_bgt0d" started, PID 3672
[ 3035.353687] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 3681
[ 3035.371253] UBIFS (ubi0:0): recovery needed
[ 3035.448165] UBIFS (ubi0:0): recovery completed
[ 3035.452716] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "boot"
[ 3035.460296] UBIFS (ubi0:0): LEB size: 129024 bytes (126 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 3035.470439] UBIFS (ubi0:0): FS size: 1035159552 bytes (987 MiB, 8023 LEBs), journal size 33546240 bytes (31 MiB, 260 LEBs)
[ 3035.481705] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
[ 3035.488519] UBIFS (ubi0:0): media format: w4/r0 (latest is w5/r0), UUID ED69950E-9378-442B-BA6C-7D1BA8FE474E, small LPT model



Edited 1 time(s). Last edit at 10/23/2018 03:13PM by jdwl101.
Further details on the ix2-dl should anyone need them, I've added some useful items to my Google Drive share;

- the recovery usb creator
- uboot GPL sources
- 'Lifeline' GPL sources
- ix2-dl specific DTB

Available here; IX2-DL software

I also have a copy of the images on the UBIFS flash, nothing particular of note that isn't explained in the posts above.
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: