I thought that as I've spent a bit of time on this, it could be useful for others…
Task: Enable USB-based CD/DVD reader/writer on MBWE.
Basically I wanted this feature in order to burn files directly from MBWE onto CDs/DVDs (e.g. backups, \ipped moves), as doing that via a home PC takes quite a while because all the stuff effectively moves back from MBWE over the ethernet/Wifi which slows things down.
Problem: When plugged into the USB socket of MBWE with standard firmware (I use a WL with 2GB), nothing happens. I.e. USB flashdisks and external HDDs are connected automatically, but when it comes to USB CD/DVD burner (mine is ASUS usb CD/DVD burner, SDRW-08D1S), it is ignored.
Solution - summary
I must say that this was my first experience with Linux, so please bear this in mind if you notice noobie things… but any comments are appreciated! There is one problem which I haven't resolved: my solution does not allow for hotplug to identify the device, so "mount" command needs to be used each time the drive is connected/ disk is changed.
Below are key steps to get a USB CD/DVD drive work with MBWE:
1. Kernel re-compilation is required. The standard MBWE kernel (220.127.116.11) does not contain several modules necessary for CD/DVD operations (sr_mod, cdrom, sg) and modules for relevant FS support (isofs, udf).
When I started to study the Linux kernel compilation procedure, I initially thought I would get by with just additional modules compiled (as MBWE kernel seems to support dynamic modules). However, once I have compiled and uploaded all the necessary modules, the kernel consistently produced "segmentation fault" error which I could only solve by re-compiling and re-installing the entire kernel. I used native compiling as at the time when I started I did not have a proper Linux installation on my PC and I could not manage to create a cross-compiler under Windows7… In the end I did the whole thing "natively" on my MBWE box, not just the kernel but also cdrtools v3.01 (below).
2. New cdrtools package (v3.0) is required. The cdrtools package which comes with optware is v.2.0 and apparently does not support DVD operations/ udf system. So I needed to compile the newest cdrtools from source ([http://cdrecord.berlios.de/private/cdrecord.html]). This was also done natively: the source distribution uses a non-standard Makefile system suitable for "smake" (not sure which one is standard, but this one is clearly not the same as the Makefile system included within the kernel source..), and I could not force this source to cross-compile under Ubuntu (which I had already installed by then). So I used native compilation on MBWE even though this required some messing about with the scripts and a couple of ".c" sources due to various errors.
3. It finally worked! Not sure that I'll actually use it that often to recover the time spent…. ;)
Solution - details
Kernel - compiling
To enable native compiling on MBWE, I followed this link: native compiling on MBWE . This required installing a few optware packages, including those from a different source [http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/unstable/] - gcc itself plus a bunch of various libraries (e.g. coreutils, textutils, gzip/bzip2, tar etc etc). I did it through trial and error adding new packages until compilation worked.
A couple of very useful optware packages are 'screen' (to enable multi-window terminal), and 'mc' (a classic commander which makes file searching/ editing thousand times more simple…)
To compile the kernel I used the source provided by WD WD GPL source, version 1.02.04. All I used from that distribution is "kernel-0.4.6" folder. At a very late moment I also found that a patch is needed to enable UDF2.5, so apply it here to get the kernel and all necessary modules done in one go (patch for UDF)
The kernel configuration file (.config) was built through a bit of trial. I did "make CROSS_COMPILE= oxnas_810_eabi_wd_prod_defconfig" (see below for cross-compile option) to build the initial .config, and then manually changed lines to switch on the modules needed for CD-rom support. The main options which i used were:
CONFIG_CC_OPTIMIZE_FOR_SIZE=y #Not sure this one is really needed
One other important option is CONFIG_LOCALVERSION="XXXX" (adds a suffix to your kernel version). If you are going to recompile the kernel, it is avisable to use this so that you can differentiate the native kernel and its modules with your custom one.
Installing kernel modules
You can install the additional modules right after you've done the compilation. Use "make modules_install CROSS_COMPILE=" to place them into /lib/modules/[kernel-version]. Then you need to update/create "dependencies", to do that use "depmod" from module-init-tools optware package (and if you used LOCALVERSION then depmod needs to be run wiht an option for "other/non-current kernel" to produce modules.dep in the right directory).
Also, if you used "LOCALVERSION", then you must modify your "inittab" (in /etc) and "rcS" (/etc/init.d) to replace kernel-specific paths used by "insmod" to version-independend "modprobe" command (installs in the same package with "depmod"). My module-loading lines now look like this:
You may want to put all the necessary new modules (sr_mod, sg, isofs etc) into inittab and rcS. I did that, maybe they would have loaded automatically upon request anyway.
MBWE's original kernel will probably not work with your new modules: I got "segmentation fault" every time I wanted to mount a CD with file structure on it, in numerous combinations/ with various options, with no result.
So if you face the same problem, you need to get the new kernel installed. After compilation, "make" produced zImage, but what you need is "uImage" as MBWE uses Uboot as the loader: U-boot documentation. To create 'uImage' a command called 'mkimage' is needed. Uboot source comes together with all WD GPL sources and is located in ../vendor/u-boot/tools. I can't remember whether I had to compile it from this source or it already came pre-compiled. You should place path to executable 'mkimage' in the PATH and then run "make uImage CROSS_COMPILE=" in your kernel compilation directory to get 'uImage'.
To actually install the new kernel, I used very helpful guidance from here: installing new kernel. That page has all the right guidance, except the offset numbers for dd command. To find out offset numbers on your machine, you should use /usr/local/wdc/uboot_env on your MBWE. Run "mac_get.sh" there, this will create two data files (not sure what disk1_2 is for as my box only has 1 disk), where you will find the necessary offset numbers. There is also useful info on [http://mbwe.wikidot.com/].
I recorded my custom kernel as the "alternate" (load2) as follows:
dd if=uImage of=/dev/sda seek=32478(YOUR OFFSET) bs=512 count=5700
(both "seek" and "count" parameters can be seen in disk1_1 produced by mac_get.sh, don' forget to translate them from HEX to Dec).
Then you need to change Uboot load sequence by modifying 'disk1_1' datafile and burning it back with "mac_set.sh" (need to supply MAC as argument). I change the first line as follows:
bootcmd=run select0 load2 boot || select0 load boot ||….
Not sure if the "alternative" status would save me if the kernel failed to load but presumably if "load2" fails then the "||" command would use "load". But I obviously hoped for that when the breathtaking moment of rebooting came… :-)
You will need to create scsi devices for your CD-ROM with "mknod": sr0 (11,0), sr1 (11,1), sg0(21,0).
After this, you should be able to mount a CD/DVD drive with a readable disk in it!
Compiling cdrtools v3.01 for ARM
To enable recording you need cdrtools. I am not sure if there are other good packages (eg dvd+rw-tools), I went for cdrtools (and besided I haven' been able to compile/cross-compile dvd+rw-tools for ARM from its source…)
Get the most recent cdrtools source. The task is simple: to compile it for ARM architecture, however the road to it proved a bit troublesome… (again, it was my first experience with Linux which may explain things :-)). Basically, I followed native compiling and used "make" command on my MBWE. The author recommends his own "smake" but I could not compile that one for ARM either (and "make" worked just as well).
You need to run "make" in the "cdrtools" source directory and see what happens. Mine didn't work just like that and the key problem as I understood it is that the configuration scripts cannot correctly identify the machine/arch/processor/system type on MBWE: they use "uname -m (etc)" and that produces a lot of cr*p on MBWE. So, I had to mess around with the scripts (I guess changing the actual scripts may have been unnecessary if I used "export" for all necessary vars and then ran "make -e", but this is the way I did it):
autoconf/config.guess: at the very beginning of the file, I replaced the original var defs with the following:
Then added a few lines further down:
exit 0 ;;
Then also did "search for string in files" for any "uname" commands in the source: I think the rest was within the ../RULES/ directory, and basically all I did was to replace "uname -m" with "arm" so that in the end when launching "make" it determined my machine as "arm-unknown-linux-gnu". It took a while as there is a bunch of sub-scripts and for whatever reason the automation didn't quite work on MBWE… the source compiles correctly under Ubuntu, but I could not make it cross-compile :(
Another thing was to create the following symlinks in the ../RULES/: arm-linux-cc.rul and arm-linux-gcc.rul (both pointing at "cc-gcc.rul")
One other problem was that "make" could not find certain ".h" headers during compilation: to avoid wasting time on getting around the scripts, I just searched/ copied the necessary headers where needed.
At last it got going: "make" started to run okay and to make dependancies/ compile and do linking. There was another problem at the end: a function definition ("dlerror" I think) seemed to have been included into two headers (dlfcn.h) so I commented out a line with definition from one of the '.h' files.
Finally cdrtools compiled! Once you have that, remove the old version ("ipkg remove cdrtools") and then do "make install" for the newly compiled ones. By default this is placed into /opt/schily/bin, so to avoid too many dirs in PATH I just created symlinks in the /opt/bin folder pointing where needed.
That is pretty much it! Hope some will find this useful…