Mainline kernel (>=4.11.x) for WD My Cloud Gen2


#3

Should work. But to test, it is better to use an usb-stick (2.0).
It don’t need to be empty. It should have a DOS FAT 32 partition.
Make a boot directory on usb-stick in the root directory and copy your
/boot/uRamdisk and the 4.12 or 4.11.8 uImage to the usb-stick into boot
Reboot and it should boot your debian from the harddrive.

Johns


#4

Thanks, will test this in 1/2 days.


#5

Thanks for posting this information. I tried several times to get the gen2 to boot from USB. But could never get it to work. But it turns out I was using a USB 3.0. So I changed to a USB 2.0 and it booted from the USB.


#6

Great work.

Is it possible to install this debian system on USB stick?
I mean, I’d like to know if I can use MyCloud-internal drive as a whole data drive and the system can be runned from USB stick.

It would be nice if this is possible because I can backup the system to the several usb sticks just in case.
If there is any problem, I can change the boot USB stick without affecting Data.
I know that this kind of things is possbie by attaching USB HDD to wd my cloud.
But, in that case, if the system fails, I have to unbrick wdmycloud. And, it’s a very tedious work.


#7

I downloaded the files. But when I try to do the make zImage it wants to restart the config. Its been a few years since I worked with Linux builds. Not sure why is restarting the config.
Any help would be appreciated.


#8

This is how i started to test alternative firmwares on the WD My Cloud.
You need a modified uRamdisk. (https://github.com/Johns-Q/wdmc-gen2/raw/master/uRamdisk) is a already a modified uRamdisk from FoxExe.
(Many thanks for his work.)
It looks for a 2nd partition on the usb stick and boots it if possible.
When nothing is found on the 2nd partition, it boots from the harddrive
when there is already an other firmware installed and when this is not working it starts the ssh daemon.

See Clean OS (Debian), OpenMediaVault and other "firmwares", but extract the jessie-rootfs.tar.gz to /dev/sdb2.

I can make a step by step howto, if you need it.

Johns


#9

Sorry I don’t understand, what you try todo.

You try to build your own linux kernel for the WD MyCloud?

Please tell me, what you are exactly doing and planing todo.

Johns


#10

I was trying to build a kernel. I did the following:
- download kernel source from https://www.kernel.org/
- extract the kernel archive
- copy kernel-4.12.0.config to linux-4.12/.config
- copy armada-375-wdmc-gen2.dts to
linux-4.12/linux-4.12/arch/arm/boot/dts/
- ready to build the kernel (you can use build_kernel_image.sh)
```
cd linux-4.12
make -j2 zImage
After the make -j2 zImage command is run it starts to rebuild the config file. Building the kernel is not to hard. But if you don’t know what to answer when it tries to build the .config file. WD released the GPL source and you can get it to build. But for some reason unknown to me the resultant uImage is bigger that the uImage in the firmware/merge folder. I suspect that is because the .config file is different. They don’t provide a .config file in the GPL release. Actually all I want is a kernel that will allow me to run blktrace. Then gen1 kernel has BLK_DEV_IO_TRACE enabled But the gen2 does not.


#11

I hope you try to build the kernel on the device (WD My Cloud).
When you try to build the kernel on the PC you need to setup cross-compiler.
I can’t help with cross compiler, cross compiler and I aren’t friends

If you build on the device or any other armhf machine, you can use my instructions.

Have you copied kernel-4.12.0.config into linux-4.12 as .config?
When you have done this, you shouldn’t be asked any questions.

Johns


#12

Yes I did copy kernel-4.12.0.config into linux-4.12 as .config. I have a cross compile setup. I’ve built debugfs,gdb,blktrace, e2label, gawk and ar. They all work on the gen1. Doing it for the gen2 requires that you compile using -static. Because the libraries are not all available.
I guess I’ll have to keep trying. AT least now I know how to test the image.


#13

Check if you downloaded the kernel config file correct. Use this link https://raw.githubusercontent.com/Johns-Q/wdmc-gen2/master/kernel-4.12.0.config

The header of the file should look like this:

#
# Automatically generated file; DO NOT EDIT.
# Linux/arm 4.12.0 Kernel Configuration 
#

Johns


#14

Yes the file contains those three lines. While looking thru Makefile there appears to be a check for the date of .config and scripts/kconfig/conf file. Not sure if that is the reason it restarts the config build. Will check into it later today when I get time.
Thanks for the response.


#15

Think I figured it out. Was not in the chroot environment when trying to make. I put the 4.11 code in the chroot environment and its building.
Thanks for you help.


#16

I’m not familiar with this kind of things. So, if you do me a favor, it would be great.
Thnak you again for your kindness.


#17

Was finally able to build the 4.11.9 . I also built 3.2.39. Both images boot. But I need to figure how the uRamdisk works. Becasue if I use your uImage and uRamdisk if boots to a command prompt. But does not run any of the WD apps. When I use my uRamdisk the kernel panic’s
VFS: Cannot open root device “ram” or unknown-block(1,0): error -6
Please append a correct “root=” boot option; here are the available partitions:


#18

The problem is, that the boot loader sets root to /dev/ram. Very clever!
There is no way (without riisking to brick the device) to change it in the boot loader.

There are many possible workarounds.

The fastest and easiest is to set in the kernel.

edit the kernel .config

CONFIG_CMDLINE="rootwait root=what_you_want_here"
# CONFIG_CMDLINE_FROM_BOOTLOADER is not set
CONFIG_CMDLINE_EXTEND=y

This extends always the bootloader values.

The uRamdisk from me, ignores the “root=” parameter and looks for
a valid linux on usb stick and on hard drive 3rd partition.
If there is a 5th partition on the hard drive it start the installl/recovery mode

You can unpack the uRamdisk and edit it and repack it.

# Unpack uRamdisk
mkdir initrd
dd if=uRamdisk of=initrd/initrd.cpio.lzma bs=64 skip=1
cd initrd
lzma -d initrd.cpio.lzma
cpio -i < initrd.cpio
rm initrd.cpio

edit init, look where it uses root= its read from /proc/cmdline.

# Build uRamdisk
cd initrd
find . | cpio -o -H newc | lzma -7 > ../initramfs.cpio.lzma
cd ..
mkimage -A arm -O linux -T ramdisk -C lzma -a 0x00e00000 -n Ramdisk -d initramfs.cpio.lzma uRamdisk
rm initramfs.cpio.lzma

And test it.

Johns


#19

Thanks for the response. I was in the process of checking the differences between your uRamdisk and the gen2 uRamdisk. I got the gen2 uRamdisk mounted. Then noticed that your uRamdisk was different. Your was an lzma if a cpio file. So I restored the file and noticed the init file. Now I know what to look for.
I’m thinking that if I were to copy my uIMage to the third partition and it does not work. I could boot the gen2 using your uIMage. Then mount the third partition and put the correct uImage back. In fact using the USB boot process one could boot up a bricked device and mount the different partitions. Look at the logs and other items to see why the device won’t boot. The gen2 keeps a duplicate user.log on the 7th partition.


#20

Why OP’s posts are flagged, couldn’t find link to his github page.


#21

Click on the view hidden in the first post.


#22

I copied 4,12 uImage and Fox_exe’s uramdisk to /boot on a usb pendrive. After reboot mycloud starts, with blinking blue-stable yellow and stable green (just like debian) lights, but I am not able to connect with ssh or telnet. It says no route to the host. Though on router page it shows up.