Compile drivers xpenology DSM 6.1 with windows 10 and build in bash

I’m going to show you today how to compile drivers for dsm 6.1-15047 (bromolow) with windows and bash.

First you need to get the anniversary update of windows 10. Click here for instructions to enable this update.

When you already have the update, you need to install bash shell command line (It’s ubuntu)
Read here how to enable Bash

When you are finished installing the anniversary update and you enabled bash, proceed with the tutorial.

1)  Start bash for windows. Type bash in the search field and start it.

2) When your shell is open update and upgrade your distribution.

apt-get update && apt-get upgrade

3) Install some packages needed.

apt-get install mc make gcc build-essential kernel-wedge libncurses5 libncurses5-dev libelf-dev binutils-dev kexec-tools makedumpfile fakeroot lzma

4) Get the source and Tool Chains.

wget https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/15047branch/bromolow-source/linux-3.10.x.txz/download -O linux-3.10.x.txz
wget https://sourceforge.net/projects/dsgpl/files/DSM%206.1%20Tool%20Chains/Intel%20x86%20linux%203.10.102%20%28Bromolow%29/bromolow-gcc493_glibc220_linaro_x86_64-GPL.txz/download -O bromolow-gcc493_glibc220_linaro_x86_64-GPL.txz

5) Unpack both archives. It could take some time..

tar xvf linux-3.10.x.txz
tar xvf bromolow-gcc493_glibc220_linaro_x86_64-GPL.txz

6) We now make an alias so we don’t have to type the whole thing over and over again. PS. We unpacked the archives in folder /root so if you put it somewhere else do not forget to change the path in the command below.

alias dsm6make='make ARCH=x86_64 CROSS_COMPILE=/root/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-'

7) cd into the linux-3.10.x directory.

cd linux-3.10.x

8) We now need to copy a new config so we can configure the drivers we want.

cp synoconfigs/bromolow .config

9) When the config is copied we can start the compile menu. We use the alias we created.

dsm6make menuconfig

The menu looks like this. You can navigate with the arrow keys and select with the spacebar.

To compile a driver, lookup your hardware and press the M key. If you see a M before the name of the hardware, the driver is going to be compiled.

When you are finished press save and write the config. When that’s done,  Exit the menu. (press ESC couple of times)

10) We now can compile the drivers you selected.

dsm6make modules

This can take a while..

11) When compiling is finished you have *.ko files in the /root/linux-3.10.x/<dirs>  directories. To get all *.ko files in one directory run 2 commands:

mkdir newmodules
find ./linux-3.10.x/ -iname "*.ko" -type f -exec cp -p {} ./newmodules/ \;

All your compiled modules are now in the directory newmodules.

In Ubuntu Userspace for Windows, the Ubuntu file system root directory is at

C:\Users\%username%\AppData\Local\lxss\root\

There you can find the directory newmodules with all your compiled drivers.

12) The next step is to create a new extra.lzma with your new drivers.

Download OSFMount here and mount the synoboot.img

Icon

OSF Mount 0.00 KB 12403 downloads

...

Select Mount New


Select the image file synoboot.img. Now select partition 1 (30 MB). Click Ok.

Then at the bottom of the window make sure to un-tick the “Read only drive”. Click Ok.

The partition of the image file should now be mounted in file explorer.

13) Go to your usb disk partition and copy the extra.lzma to your c: drive.

(I copied the file to C:\Users\%username%\AppData\Local\lxss\root\ but that doesn’t work. File is not there..)

14) Run the following commands in /root

mkdir extract
cd /mnt/c
mv extra.lzma /root/extract
cd /root/extract

14) Decompress “extra.lzma” to “extra” on the ubuntu command line:

lzma -d extra.lzma

15) Extract the extra file

cpio -idv < extra

16) Delete the extra file

rm -rf extra

17) In directory /root/extract you have 3 directories:

etc
init
usr

Copy your new /root/newmodules/*.ko files into

usr/lib/modules

18) Edit the file

etc/rc.modules

And add your new modules. You need to add the name of the module without the extension .ko in the rc.modules file.

Network drivers etc. under EXTRA_MODULES
Storage drivers under DISK_MODULES 
Firmwares under EXTRA_FIRMWARES

if your controller or nic needs a firmware, you add the firmware file under usr/lib/modules/firmware/ and add the appropriate line in EXTRA_FIRMWARES, if there is a extra directory inside “firmware”  we need to add it into the rc.modules file. The directory is added to the name, see the bnx2 firmware files in rc.modules for an example.

19) If everything is in place run the following command to create a new extra.lzma. We recreate the cpio file, re-compress it as lzma and write it one directory up as “extra.lzma”

(find . -name modprobe && find . \! -name modprobe) | cpio --owner root:root -oH newc | lzma -8 > ../extra.lzma

 

20) We now copy “extra.lzma” from C:\Users\%username%\AppData\Local\lxss\root\ to synoboot.img

Open OSFmount once again and open the 30mb partition. Replace the “extra.lzma” with the new one, dismount the image and close OSFmount.

Burn the synoboot.img to usb with Win32diskimager because our new synoboot.img is ready to test.

 

28 thoughts on “Compile drivers xpenology DSM 6.1 with windows 10 and build in bash

  1. Schwarzes Tigerle

    Are there some modules missing, before loading virtio_net?
    Seems the loading order should be:
    virtio
    virtio_ring
    virtio_pci
    virtio_net
    Last Wednesday i had the same problem (but with err 2), i came to this page but saddly got no answer…
    After digging and pocking around for several hours, visiting a couple of pages, i managed to get the driver loaded without errors,
    but there were no ethernetinterfaces found/searched, took an other hour to know the virtio_net requires virtio_pci
    (you must enable the pci driver to get the net driver displayed in menuconfig)…

    Hope this info helps some one, to prevent wasting time (why are most things so badly dokumented?)

    Reply
  2. Patrick

    Hi,
    thank you for this gread howto.. I tried to compile nct6775.ko of hwmon for my DS918+ baremetal.
    Therefore I used:
    https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/24922branch/apollolake-source/linux-4.4.x.txz/download
    https://sourceforge.net/projects/dsgpl/files/Tool%20Chain/DSM%206.2.3%20Tool%20Chains/Intel%20×86%20Linux%204.4.59%20%28Apollolake%29/apollolake-gcc493_glibc220_linaro_x86_64-GPL.txz/download

    Compilation worked without any problems, and modinfo says now:
    root@debian:~/linux-4.4.x/drivers/hwmon# modinfo nct6775.ko
    filename: /root/linux-4.4.x/drivers/hwmon/nct6775.ko
    license: GPL
    description: Driver for NCT6775F and compatible chips
    author: Guenter Roeck
    depends: hwmon-vid
    intree: Y
    vermagic: 4.4.59 SMP preempt mod_unload
    parm: force_id:Override the detected device ID (ushort)
    parm: fan_debounce:Enable debouncing for fan RPM signal (ushort)

    When I type uname -r at my Synology, I have 4.4.59+ => Everything should be fine.

    But when I try to insert the module:
    insmod: ERROR: could not insert module nct6775.ko: Invalid module format

    Why?
    🙁 🙁 🙁 🙁

    Reply
  3. Dorin

    Running this command:

    root:/liniux-3.10.x# find ./linux-3.10.x/ -iname “*.ko” -type f -exec cp -p {} ./newmodules/ \;

    returns: find: ‘./linux-3.10.x/’: No such file or directory

    Directory is there, but is empty, everything ran fine so far.
    than I tried ” find ./newmodules/ -iname “*.ko” -type f -exec cp -p {} ./newmodules/ \;” but I don’t think it does something..

    Reply
  4. charles

    I think you had skipped step #6. You need to use this command before you use “dsm6make”:

    alias dsm6make=’make ARCH=x86_64 CROSS_COMPILE=/root/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-‘

    Reply
  5. Error Code oxc0000225

    I just passed this onto a colleague who was doing a little research on this topic. And he actually bought me lunch because I found it for him. So I should thank you for the free lunch I got.

    Reply
  6. Pritam

    I want to insert Drivers for the rtl8192eu chipset for wireless adapters in Jun’s mod but it is not available in the list can anyone help me to compile the same for me.

    Reply
  7. Che

    Hi!

    I think this area is long since dead, but still worth a shot!

    I’m trying to compile dsm 6.2 for broadwell with the drm intel graphics (goal is to get intel quick going for hardware transcoding on plex).

    The build is failing though, any ideas anyone?

    CC [M] drivers/gpu/drm/drm_drv.o
    drivers/gpu/drm/drm_drv.c: In function ‘drm_stub_open’:
    drivers/gpu/drm/drm_drv.c:861:2: error: implicit declaration of function ‘replace_fops’ [-Werror=implicit-function-declaration]
    replace_fops(filp, new_fops);
    ^
    cc1: some warnings being treated as errors
    scripts/Makefile.build:308: recipe for target ‘drivers/gpu/drm/drm_drv.o’ failed
    make[3]: *** [drivers/gpu/drm/drm_drv.o] Error 1
    scripts/Makefile.build:455: recipe for target ‘drivers/gpu/drm’ failed
    make[2]: *** [drivers/gpu/drm] Error 2
    scripts/Makefile.build:455: recipe for target ‘drivers/gpu’ failed
    make[1]: *** [drivers/gpu] Error 2
    Makefile:800: recipe for target ‘drivers’ failed
    make: *** [drivers] Error 2

    Cheers!

    Reply
  8. audioborg

    Getting stuck on step #9.

    dsm6make menuconfig returns: “dsm6make: command not found”

    Was originally in the linux.3.10.x directory, but have looked in a few others and can’t find it. Don’t have a lot of experience with Linux Bash, so not sure how to resolve this.

    Reply
    1. Charles

      Hi audioborg, I guess you missed step #6. You need to use following command first, then you can use “dsm6make” as command:

      alias dsm6make=’make ARCH=x86_64 CROSS_COMPILE=/root/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-‘

      Hope this can resolve your problem.

      Reply
  9. Karol

    Hi, im trying to compile drivers for netbook with realtek drivers. With DSM 5.2 its working fine [and expenoboot for 5644].
    Fallowing this tutorial I met “Permission denied”
    I checked drivers, saved config but later on command:

    make: execvp: /root/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-gcc: Permission denied

    When i tried with sudo on begining its says:

    $ sudo dsm6make modules
    sudo: dsm6make: command not found

    :/
    Also i dont have this folder:
    C:\Users\%username%\AppData\Local\lxss\root\

    Reply
    1. Charles

      Hi Karol, I think you also missed step #6. Please try following command before you use “dsm6make” as command:

      alias dsm6make=’make ARCH=x86_64 CROSS_COMPILE=/root/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-‘

      About the second question, you can try this folder first:

      C:\Users\%username%\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu16.04onWindows_79rhkp1fndgsc\LocalState\rootfs

      If you still cannot find this folder, you can try type ‘\\wsl$’ (without single quotation marks) in the run box(WIN + R) or in File Explorer when your ubuntu is running.

      Hope this can help you.

      Reply
    1. Err0r Post author

      Works fine!

      Permission denied is on your side:

      romolow-source/linux-3.10.x.txz
      Herleiden van netcologne.dl.sourceforge.net (netcologne.dl.sourceforge.net)… 78.35.24.46, 2001:4dd0:1234:6::5f
      Verbinding maken met netcologne.dl.sourceforge.net (netcologne.dl.sourceforge.net)|78.35.24.46|:443… verbonden.
      HTTP-verzoek is verzonden; wachten op antwoord… 200 OK
      Lengte: 78140360 (75M) [application/octet-stream]
      Wordt opgeslagen als: ‘linux-3.10.x.txz’

      100%[==============================================================================>] 78.140.360 20,4MB/s in 3,8s

      2018-02-04 10:34:24 (19,7 MB/s) – ‘‘linux-3.10.x.txz’’ opgeslagen [78140360/78140360]

      Reply
  10. Matthew Purnell

    I did find some Intel drivers in the menu that I thought were worth trying to add – but not the exact model. I was hoping I would find how to add new drivers..

    I wasn’t able to successfully add the ‘almost’ drivers either, as I didn’t find anything that looked familiar while looking through the .ko files. So basically I am down several hours with no progress 🙁

    Reply
  11. medric

    I would like to get the Hyper-v synthetic drivers i have the dsm6make modules part but i dont know where to go to add this type of drivers? any thoughts

    Reply
  12. toto

    useful.
    It’s same method to compil the kernel ?
    I would like to compil my own kernel and bzimage for DSM.

    Reply
  13. Arm4dello

    i’ve bin reading the whole forum by now finding more aboutn this subject, but i cannot find any post regarding this subject. people have expenology working but with hdd as sata and with the net adapter e1000, wich is slow as hell and also uses more cpu wich isnt very effcient when running multiple other vm’s and containers.

    I started digging in the expenoloy vm and found this in dmesg for al virtio related drivers:

    22.572386] virtio_net: Unknown symbol register_virtio_driver (err 0)
    [ 22.572395] virtio_net: Unknown symbol virtqueue_enable_cb_prepare (err 0)
    [ 22.572403] virtio_net: Unknown symbol virtqueue_detach_unused_buf (err 0)
    [ 22.572408] virtio_net: Unknown symbol virtqueue_poll (err 0)
    [ 22.572430] virtio_net: Unknown symbol unregister_virtio_driver (err 0)
    [ 22.572439] virtio_net: Unknown symbol virtqueue_get_vring_size (err 0)
    [ 22.572448] virtio_net: Unknown symbol virtqueue_disable_cb (err 0)
    [ 22.572456] virtio_net: Unknown symbol virtqueue_add_sgs (err 0)
    [ 22.572462] virtio_net: Unknown symbol virtqueue_get_buf (err 0)
    [ 22.572467] virtio_net: Unknown symbol virtqueue_add_outbuf (err 0)
    [ 22.572474] virtio_net: Unknown symbol virtqueue_kick (err 0)
    [ 22.572482] virtio_net: Unknown symbol virtqueue_add_inbuf (err 0)
    [ 22.572488] virtio_net: Unknown symbol virtio_check_driver_offered_feature (e rr 0)
    [ 22.572494] virtio_net: Unknown symbol virtqueue_enable_cb_delayed (err 0)

    did i compile it wrong ?

    Reply
  14. arm4dello

    Nice !!. I could provide some logging, i still have the VM, and if i can help/assist please let me know.

    I also tested XPEnoboot 5.2-5544.5, and with this version in can see the virt_net NIC and the virt_scsi DISK inside the VM.

    Reply
  15. arm4dello

    I followed your steps on by one. I got zero errors and ceated an new (syno)boot.img

    I load it up in a vm on proxmox 5.0

    vm:
    net0 = virtio
    hdd(scsi0) = scsi
    hdd2(virtio) = virtio

    When in boot up the vm nothing shows up when in search for a station with Synology assistent. But when i change net0 to e1000 (so no virtio driver is needed and use a default driver already buildin the (syno)boot.img) it show up in Synology assistent, but then it says no disk found.

    So the drivers do not work ?

    when i dmesg in the syno i can seee an Qemu hard disk showing up (this is after an install with a sata disk, and the connecting an extra hdd as virtio_scsi)

    I’ve double check the newly created (syno)boot.img but the drivers are listed in th rc.modules and visible in de etc/lib/modules folder.

    Im trying to inject/compile virtio drivers (especially virtio_net and virtio_scsi )

    Reply
    1. Err0r Post author

      Hi Arm4dello,

      I have no idea why it doesn’t work. I will install proxmox server myself and will try it out. Will make a tutorial about it..

      Regards,

      Err0r

      Reply
      1. arm4dello

        Nice !!. I could provide some logging, i still have the VM, and if i can help/assist please let me know.

        I also tested XPEnoboot 5.2-5544.5, and with this version in can see the virt_net NIC and the virt_scsi DISK inside the VM.

        Reply
        1. Err0r Post author

          I installed proxmox in a vm. And i get it to boot correct but its not working that well. VM in a VM.
          So i need to build a dedicated machine with proxmox on it so i can test further..

          I recommend to read this topic on xpenology.com but i just noticed you already did..

          Reply
          1. Arm4dello

            i’ve bin reading the whole forum by now finding more aboutn this subject, but i cannot find any post regarding this subject. people have expenology working but with hdd as sata and with the net adapter e1000, wich is slow as hell and also uses more cpu wich isnt very effcient when running multiple other vm’s and containers.

            I started digging in the expenoloy vm and found this in dmesg for al virtio related drivers:

            22.572386] virtio_net: Unknown symbol register_virtio_driver (err 0)
            [ 22.572395] virtio_net: Unknown symbol virtqueue_enable_cb_prepare (err 0)
            [ 22.572403] virtio_net: Unknown symbol virtqueue_detach_unused_buf (err 0)
            [ 22.572408] virtio_net: Unknown symbol virtqueue_poll (err 0)
            [ 22.572430] virtio_net: Unknown symbol unregister_virtio_driver (err 0)
            [ 22.572439] virtio_net: Unknown symbol virtqueue_get_vring_size (err 0)
            [ 22.572448] virtio_net: Unknown symbol virtqueue_disable_cb (err 0)
            [ 22.572456] virtio_net: Unknown symbol virtqueue_add_sgs (err 0)
            [ 22.572462] virtio_net: Unknown symbol virtqueue_get_buf (err 0)
            [ 22.572467] virtio_net: Unknown symbol virtqueue_add_outbuf (err 0)
            [ 22.572474] virtio_net: Unknown symbol virtqueue_kick (err 0)
            [ 22.572482] virtio_net: Unknown symbol virtqueue_add_inbuf (err 0)
            [ 22.572488] virtio_net: Unknown symbol virtio_check_driver_offered_feature (e rr 0)
            [ 22.572494] virtio_net: Unknown symbol virtqueue_enable_cb_delayed (err 0)

            did i compile it wrong ?

Leave a Reply

Your email address will not be published. Required fields are marked *

*