Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Help with initramfs for Marvell OpenRD-Client LE
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on Alternative Architectures
View previous topic :: View next topic  
Author Message
jlpoole
Guru
Guru


Joined: 01 Nov 2005
Posts: 477
Location: Salem, OR

PostPosted: Thu Dec 09, 2010 6:31 pm    Post subject: [Solved] Help with initramfs for Marvell OpenRD-Client LE Reply with quote

I'm returning to an old project of getting Gentoo installed on the Marvell OpenRD-Client LE (a project which has been on hold for about a year). I'm using as a guide the Gentoo on the Marvell SheevaPlug (herein "Guide") located at http://dev.gentoo.org/~armin76/arm/sheevaplug/install.xml. The SheevaPlug is a very similar product having less capabilities than the OpenRD-Client.

The Guide has two binaries that its author cross-compiled for the SheevaPlug:
Code:
http://dev.gentoo.org/~armin76/arm/sheevaplug/install/uImage_kwplug
http://dev.gentoo.org/~armin76/arm/sheevaplug/install/sheevaplug.initramfs


I'm trying to create similar files for the OpenRD-Client LE so I can get a BusyBox up and running to install Gentoo. To that end, here's what I have done:

on my AMD (Phenom quadcore) workstation

1) Set up a staging area for the initramfs at /etc/usr/initramfs
Code:
mkdir /usr/src/initramfs
cd /usr/src/initramfs
mkdir -p bin lib dev etc mnt/root proc root sbin sys


2 ) created a cross-compile environment for arm-none-linux-gnueabi I did so by:

Code:
hermes initramfs # crossdev -v --target arm-none-linux-gnueabi
--------------------------------------------------------------------------------
 * crossdev version:      20100814
 * Host Portage ARCH:     amd64
 * Target Portage ARCH:   arm
 * Target System:         arm-none-linux-gnueabi
 * Stage:                 4 (C/C++ compiler)

 * binutils:              binutils-[latest]
 * gcc:                   gcc-[latest]
 * headers:               linux-headers-[latest]
 * libc:                  glibc-[latest]

 * PORTDIR_OVERLAY:       /usr/local/portage
 * PORT_LOGDIR:           /var/log/portage
 * PKGDIR:                /usr/portage/packages/cross/arm-none-linux-gnueabi
 * PORTAGE_TMPDIR:        /var/tmp/cross/arm-none-linux-gnueabi
  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -
 * Forcing the latest versions of {binutils,gcc}-config/gnuconfig ...
...
>>> Original instance of package unmerged safely.
 * Switching cross-compiler to arm-none-linux-gnueabi-4.4.5 ...           [ ok ]
>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.

 * GNU info directory index is up-to-date.                                [ ok ]
hermes initramfs #


Tested my "shiney" new cross compiler with an innocuous file, sh4-test.c:

Code:
arm-none-linux-gnueabi-gcc --version
hermes initramfs # arm-none-linux-gnueabi-gcc --version
arm-none-linux-gnueabi-gcc (Gentoo 4.4.4-r2 p1.2, pie-0.4.5) 4.4.4
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

hermes initramfs # echo 'int main(){return 0;}' > sh4-test.c
hermes initramfs # arm-none-linux-gnueabi-gcc  -Wall sh4-test.c -o sh4-test
hermes initramfs # file sh4-test
sh4-test: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
hermes initramfs #


3) cross compile a busybox (static)

Code:
USE="static"  arm-none-linux-gnueabi-emerge busybox
...
>>> Auto-cleaning packages...

>>> Using system located in ROOT tree /usr/arm-none-linux-gnueabi/

>>> No outdated packages were found on your system.

 * IMPORTANT: 1 config files in '/usr/arm-none-linux-gnueabi/etc' need updating.
 * See the CONFIGURATION FILES section of the emerge
 * man page to learn how to update config files.

 * IMPORTANT: 1 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

hermes initramfs #


Staged the cross-compiled busybox to the initramfs staging area:
Code:
cp -a /usr/arm-none-linux-gnueabi/bin/busybox /usr/src/initramfs/bin/busybox


Created a startup script:
Code:
cat >/usr/src/initramfs/init
   #!/bin/busybox sh

   # Mount the /proc and /sys filesystems.
   mount -t proc none /proc
   mount -t sysfs none /sys

   # Do your stuff here.
   echo "This script mounts rootfs and boots it up, nothing more!"

   # Mount the root filesystem.
   mount -o ro /dev/sda1 /mnt/root

   # Clean up.
   umount /proc
   umount /sys

   # Boot the real thing.
   exec switch_root /mnt/root /sbin/init
<CONTROL-D>
chmod +x /usr/src/initramfs/init

Wrap up the staging area and place in the tftp server dirctory:
Code:
hermes initramfs # cd /usr/src/initramfs/
hermes initramfs # find . -print0 | cpio --null -ov --format=newc | gzip -9 > /var/tftp/initramfs
.
./lib
./mnt
./mnt/root
./proc
./sh4-test.c
./bin
./bin/busybox
./init
./etc
./sbin
./root
./sh4-test
./sys
./dev
3730 blocks
hermes initramfs #


Fetch, compile a kernel and stage on the tfpt server (per instructions at http://groups.google.com/group/openrd/web/add-audio-video-support-to-2-6-33-kernel?pli=1, I did not apply the patches, but found most of the items in the menuconfig as I believe the instructions are out of date):
Code:
cd /var/work/openrd
git clone git://repo.or.cz/linux-2.6/linux-2.6-openrd.git openrd.git
cd openrd.git
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage
...
cp /var/work/openrd/openrd.git/arch/arm/boot/uImage uImage /var/fptf/myImage


on the OpenRD

after setting my IP and the tftp server's IP:
Code:
Marvell>> setenv bootargs console=ttyS0,115200 root=/dev/ram rw
Marvell>> tftpboot 0x2000000 myImage
Using egiga0 device
TFTP from server 192.168.168.20; our IP address is 192.168.168.16
Filename 'myImage'.
Load address: 0x2000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ################
done
Bytes transferred = 2739988 (29cf14 hex)
Marvell>> tftpboot 0x8000000 initramfs
Using egiga0 device
TFTP from server 192.168.168.20; our IP address is 192.168.168.16
Filename 'initramfs'.
Load address: 0x8000000
Loading: #################################################################
         #################################################################
         #################################################################
         ######
done
Bytes transferred = 1025503 (fa5df hex)
Marvell>> bootm 0x2000000  0x8000000
## Booting image at 02000000 ...
   Image Name:   Linux-2.6.33-rc8-00096-gf00d2b2
   Created:      2010-12-09   6:10:21 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2739924 Bytes =  2.6 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK
## Loading Ramdisk Image at 08000000 ...
Bad Magic Numberý
         __  __                      _ _
        |  \/  | __ _ _ ____   _____| | |
        | |\/| |/ _` | '__\ \ / / _ \ | |
        | |  | | (_| | |   \ V /  __/ | |
        |_|  |_|\__,_|_|    \_/ \___|_|_|
 _   _     ____              _
| | | |   | __ )  ___   ___ | |_
| | | |___|  _ \ / _ \ / _ \| __|
| |_| |___| |_) | (_) | (_) | |_
 \___/    |____/ \___/ \___/ \__|


The problem is that when the OpenRD attempts to load my initramfs, it complains "Bad Magic Number" and the resets the box. This makes me think my cross compile must not be working.

Does anyone have any suggestions on what I should try or where I have omitted something or incorrectly performed one of the tasks above?

** UPDATE ** See my posting of 12/19 below


Last edited by jlpoole on Sun Dec 19, 2010 3:27 pm; edited 1 time in total
Back to top
View user's profile Send private message
jlpoole
Guru
Guru


Joined: 01 Nov 2005
Posts: 477
Location: Salem, OR

PostPosted: Thu Dec 09, 2010 9:53 pm    Post subject: Reply with quote

I found one ommission I made: I neglected to copy over some device nodes. So I executed the following:
Code:
hermes initramfs # cp -a /dev/{null,console,tty,sda1,sda,sda2,sda3} dev
hermes initramfs # ls dev
console  null  sda  sda1  sda2  sda3  tty
hermes initramfs #


and then reran
Code:
hermes initramfs # find . -print0 | cpio --null -ov --format=newc | gzip -9 > /var/tftp/initramfs


and loaded into the OpenRD's memory:
Code:

Marvell>> tftpboot 0x8000000 initramfs
Using egiga0 device
TFTP from server 192.168.168.20; our IP address is 192.168.168.16
Filename 'initramfs'.
Load address: 0x8000000
Loading: #################################################################
         #################################################################
         #################################################################
         ######
done
Bytes transferred = 1025697 (fa6a1 hex)
Marvell>>


The results was the same:
Code:
Marvell>> bootm 0x2000000  0x8000000
## Booting image at 02000000 ...
   Image Name:   Linux-2.6.33-rc8-00096-gf00d2b2
   Created:      2010-12-09   6:10:21 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2739924 Bytes =  2.6 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK
## Loading Ramdisk Image at 08000000 ...
Bad Magic Numberý
         __  __                      _ _
        |  \/  | __ _ _ ____   _____| | |
        | |\/| |/ _` | '__\ \ / / _ \ | |
        | |  | | (_| | |   \ V /  __/ | |
        |_|  |_|\__,_|_|    \_/ \___|_|_|
 _   _     ____              _
Back to top
View user's profile Send private message
jlpoole
Guru
Guru


Joined: 01 Nov 2005
Posts: 477
Location: Salem, OR

PostPosted: Thu Dec 09, 2010 9:56 pm    Post subject: Reply with quote

The following links are helpful:

http://en.gentoo-wiki.com/wiki/Initramfs

http://www.kroah.com/lkn/ A freely downloaded version of the O'Reilly book Linux Kernel in a Nutshell
Back to top
View user's profile Send private message
jlpoole
Guru
Guru


Joined: 01 Nov 2005
Posts: 477
Location: Salem, OR

PostPosted: Fri Dec 10, 2010 2:04 am    Post subject: Reply with quote

Just for kicks, I copied the SheevaPlug sheevaplug.initramfs to by tftp server and loaded to see if the same error is triggered. My search of the web reveals that the error I've been receiving, "Bad Magic Number", can mean a lot of things and is not very descriptive. It looks like the initramfs I created does not pass muster, whereas the sheevaplug.initramfs does and then goes on to duly error out given that it was built for a different processor architecture.

Code:
Marvell>> tftpboot 0x2000000 myImage
Using egiga0 device
TFTP from server 192.168.168.20; our IP address is 192.168.168.16
Filename 'myImage'.
Load address: 0x2000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #############################################################
done
Bytes transferred = 2305892 (232f64 hex)
Marvell>> tftpboot 0x8000000 sheevaplug.initramfs
Using egiga0 device
TFTP from server 192.168.168.20; our IP address is 192.168.168.16
Filename 'sheevaplug.initramfs'.
Load address: 0x8000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #########################################
done
Bytes transferred = 3869250 (3b0a42 hex)
Marvell>> bootm 0x2000000  0x8000000
## Booting image at 02000000 ...
   Image Name:   Linux-2.6.33-rc8-00096-gf00d2b2
   Created:      2010-12-10   0:16:02 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2305828 Bytes =  2.2 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK
## Loading Ramdisk Image at 08000000 ...
   Image Name:   sheevaplug.initramfs
   Created:      2009-05-17  17:40:06 UTC
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    3869186 Bytes =  3.7 MB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

Error: unrecognized/unsupported machine ID (r1 = 0x00000939).

Available machine support:

ID (hex)        NAME
00000690        Marvell DB-88F6281-BP Development Board
00000691        Marvell RD-88F6192-NAS Development Board
00000692        Marvell RD-88F6281 Reference Board
0000078c        Marvell 88F6281 GTW GE Board
00000831        Marvell SheevaPlug Reference Board
0000085b        QNAP TS-119/TS-219
00000915        Marvell OpenRD Base Board

Please check your kernel config and/or bootloader.



What is also noteworthy is that the sheevaplug.initramfs is substantially larger than mine: 3.7 MB vs. 2.3 MB. Mine consist of a skeletal file system with busybox.
Back to top
View user's profile Send private message
shenki
n00b
n00b


Joined: 15 Dec 2010
Posts: 1

PostPosted: Wed Dec 15, 2010 1:07 pm    Post subject: Re: Help with initramfs for Marvell OpenRD-Client LE Reply with quote

jlpoole wrote:

hermes initramfs # find . -print0 | cpio --null -ov --format=newc | gzip -9 > /var/tftp/initramfs


Once creating the ramfs, did you then use uboot's mkimage to create a image suitable for loading from uboot? If you did, ensure it looked something like this:

Code:
mkimage -A arm -O linux -T ramdisk -C gzip -n "Linux 2.6.37-rc" -d initramfs initramfs.kwb


Let me know how you get on booting your own kernel. I'm having trouble where the ext2load command feezes when attempting to load my hand-built kernel (but the pre-built ones I have obtained load fine).
Back to top
View user's profile Send private message
armin76
Retired Dev
Retired Dev


Joined: 24 Apr 2006
Posts: 174

PostPosted: Sat Dec 18, 2010 5:33 pm    Post subject: Reply with quote

Hi,

Two things:
1) I used catalyst to build the initramfs. Have a look at the specs available here(sorry, i deleted the ones for arm): http://sources.gentoo.org/cgi-bin/viewvc.cgi/releng/trunk/releases/weekly/specs/alpha/netboot/

2) The initramfs needs to be in uboot format to get uboot to load it. Do what shenki said and it should work.

Your problem is the uboot format thing. If the problem was inside the initramfs, at least you'll get the kernel booting.

Btw, my initramfs should work on any ARMv5 and above. I think the kernel you've built doesn't support your device, i guess thats what the patches are for.

Anyway the current kernel.org supports the openrd, try that one.
Back to top
View user's profile Send private message
jlpoole
Guru
Guru


Joined: 01 Nov 2005
Posts: 477
Location: Salem, OR

PostPosted: Sun Dec 19, 2010 3:30 pm    Post subject: Sucess! Reply with quote

I did not know to run mkimage. Your code

Code:
mkimage -A arm -O linux -T ramdisk -C gzip -n "Linux 2.6.37-rc" -d initramfs initramfs.kwb

worked. That step combined with learning that I could use Raul's initramfs on the OpenRD has allowed me to install Gentoo. I did a basic kernel configuration and I'm up and running.

Code:
openrd ~ # uname -a
Linux openrd 2.6.35.8 #1 PREEMPT Sun Dec 19 00:55:10 PST 2010 armv5tel Feroceon 88FR131 rev 1 (v5l) Marvell OpenRD Client Board GNU/Linux
openrd ~ #


Thank you, both.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on Alternative Architectures All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum