Compiling MyBook Live modules

There are 2 main different ways to compile modules for the MyBook Live.
You can either do it
- on the MyBook Live itself
- or via cross-compiling. (compiling on another computer)

To cross-compile with the tool-chain or to compile kernel modules on the MyBook Live itself, you will need to download the WD MyBook Live GPL source code file.
Download the one concerning your firmware:
WD My Book Live GPL Source Code

Prerequisites

Find your firmware version:

# cat /etc/version

kernel version: normally kernel-release is 2.6.32.11 and kernel local-version is -svn21605
# uname -r
2.6.32.11-svn21605

and compiler's version: README-sdk that comes with the GPL contains a line like
Link: http://ftp.denx.de/pub/eldk/4.2/ppc-linux-x86/iso/ppc-2008-04-01_amcc.iso

this tells you which gcc version should be used to compile modules natively (here: 4.2)1

or you can use this command to find out the compiler version:

# cat /proc/version
Linux version 2.6.32.11-svn21605 (steveh@steveh-desktop) (gcc version 4.2.2) #1 Fri Oct 15 17:13:23 PDT 2010

showing gcc version 4.2.2.

Compiling directly on the MyBook Live (performance is quite good)

1. Install the following packages using 'aptitude' or 'apt-get'

. gcc version according to the prerequisites (here: 4.2)2:

# aptitude update
# aptitude install gcc-4.2
# update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.2 42 --slave /usr/bin/cpp cpp /usr/bin/cpp-4.2

if you get the following message, then do: # apt-get install --reinstall coreutils and redo #update-alternatives ...

/opt/bin/update-alternatives: line 100: /usr/bin/sort: cannot execute binary file
update-alternatives: removing //usr/bin/gcc as no more alternatives exist for it

this problem can occur if you have installed optware with outdated corrupted instructions, which include installing sort and dirname binaries for whitelight's architecture. If you followed instructions provided on the Optware page, you won't have to do this.

. libncurses-devel:

# aptitude install libncurses-dev # needed for make menuconfig

. patch:

# aptitude install patch # utility to patch files, we'll need it here to fix some Makefile's

.make

#  aptitude install make

2. Installation of the GPL Source Code

copy the GPL Source Code archive to /CacheVolume/gpl # you need 3GB (/tmp is too small)
DO NOT extract to /shares or /DataVolume/shares, this will trigger the multimedia indexing services and the kernel contains over 100,000 files!
(current version at 07. march 2011 : wget http://download.wdc.com/gpl/gpl-source-mybooklive-010303.zip)
(current version at 28. august 2011 : wget http://download.wdc.com/gpl/gpl-source-mybooklive-020106.zip)

# cd /CacheVolume
# mkdir -p gpl
# unzip gpl*.zip -d gpl      # unzip the file
# cd /CacheVolume/gpl/kernel*
# wget http://mybookworld.wikidot.com/local--files/compiling-mybook-live-modules/kernel_2.6.32-11-crtsavres-v2.patch
# patch -bp0 < kernel_2.6.32-11-crtsavres.patch     # needed to fix the 'ld: arch/powerpc/lib/crtsavres.o: No such file: No such file or directory' error
## note that if your kernel version is different, you'll probably to apply the changes manually: google a bit to learn patch files' syntax

3. Configure the kernel:3

# make 44x/apollo_3G_nas_defconfig
# make menuconfig    # you will enter an easy screen application

Set "General setup -> Local version" according to your working kernel's local version (run # uname -r on your drive - you'll get <version><local version>)
(here: -svn21605)

and enable building whatever modules you need. Examples:
- for loop: Block devices —> <M> Loopback device support, and <M> Cryptoloop support
- for fuse: File systems —> <M> FUSE (Filesystem in Userspace support), and <M> Character device in Userpace support (NEW)

4. Build, install and insert the modules

# make modules # (2mn 30s for 7 modules)

On the NAS, you can install the modules like this:

# make modules_install

will install the kernel modules in /lib/modules/*/kernel
Beware: this will install all the modules you've built, including the old ones, so if you've disabled building some of them in the config, they'll be missing from your system (or you will have to do a manual install of the new ones - see the §5 in the cross-compile How To)

Now you can modprobe the modules

# modprobe -av <list_of_modules>     # example: 'modprobe -av loop fuse'

Cross-compiling on your favourite Linux based computer (note that only x86 linux is supported)

(this assumes WD's GPL source code is unziped in your home dir)

1. Install the toolchain as described in the README-sdk:

Instructions: http://www.denx.de/wiki/DULG/ELDK

Link: http://ftp.denx.de/pub/eldk/4.2/ppc-linux-x86/iso/ppc-2008-04-01_amcc.iso

Use the ppc_4xxFP.

(if a README for your firmware's version says to use a different toolchain, adjust the following instructions accordingly)

# cd ~
# wget http://ftp.denx.de/pub/eldk/4.2/ppc-linux-x86/iso/ppc-2008-04-01_amcc.iso
# mkdir ppc-2008-04-01_amcc-image
# sudo mount -o loop,exec ppc-2008-04-01_amcc.iso ~/ppc-2008-04-01_amcc-image
# mkdir ppc-2008-04-01_amcc-sdk
# cd ppc-2008-04-01_amcc-image
# ./install -d ~/ppc-2008-04-01_amcc-sdk ppc_4xxFP

2. Add path to the installed toolchain to the PATH env variable:

# export PATH=$PATH:~/ppc-2008-04-01_amcc-sdk/usr/bin

3. Configure the kernel

# cd ~/gpl-source-mybooklive-010203/kernel_2.6.32-11
# wget http://mybookworld.wikidot.com/local--files/compiling-mybook-live-modules/kernel_2.6.32-11-crtsavres-v2.patch
# patch -bp0 < kernel_2.6.32-11-crtsavres.patch     # needed to fix the 'ld: arch/powerpc/lib/crtsavres.o: No such file: No such file or directory' error
## note that if your kernel version is different, you'll probably to apply the changes manually: google a bit to learn patch files' syntax
# make ARCH=powerpc 44x/apollo_3G_nas_defconfig
# make ARCH=powerpc menuconfig

Set "General setup -> Local version" according to your working kernel's local version (run # uname -r on your drive - you'll get <version><local version>)
(for 010203 firmware it's -svn21605)
enable building loop as a module: press "M" against 'Device Drivers -> Block devices -> Loopback device support'
I also suggest to build fuse, it's pretty useful (e.g., you can't use ntfs-3g without it): press "M" against 'File systems -> FUSE (Filesystem in Userspace) support'

4. Build the modules:

# make CROSS_COMPILE=ppc_4xxFP- ARCH=powerpc modules

5. Install the modules. Examples for loop and fuse modules:

i) copy ~/gpl-source-mybooklive-010203/kernel_2.6.32-11/drivers/block/*.ko and ~/gpl-source-mybooklive-010203/kernel_2.6.32-11/fs/fuse/*.ko to /lib/modules/*/kernel/drivers/block and /lib/modules/*/kernel/fs/fuse respectively on the NAS (create the dirs if needed).
ii) on the NAS, run # /sbin/depmod -a
iii) to insert the modules run # /sbin/modprobe -av loop fuse

That's about it. Pretty simple, imho…

___

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License