Compiling Linux Kernel modules for Synology devices
Davy 16 Jan 2012Synology NAS are very versatile. They are running a stripped version of Linux with less kernel modules, but we can overcome this by compiling and adding modules (for instance the usbserial module used by usb serial converters).
Requirements:
- a computer (or a virtual machine) running Linux (Debian, Fedora, Ubuntu, etc)
- the tool chains specific to your Synology
- the Synology NAS GPL source specific to your Synology
How to proceed:
- Unzip the tool chains in /usr/local
computer$ tar -xzf yourToolChains -C /usr/local/
- Unzip the Synology NAS GPL source inside your tool chains
computer$ tar -xzf yourNASGPLSource -C /usr/local/yourToolChains/
- Before continuing, let’s find out which Linux kernel we are running on the Synology in order to compile for the right version:
computer$ ssh -l root ipOfYourSynology
synology$ uname -a
Linux Syno youLinuxKernelVersion xxxxx yourSynologyArchi
- Open the Synology NAS GPL source folder corresponding to your Synology Linux kernel
computer$ cd /usr/local/yourToolChains/source/linux-youLinuxKernelVersion
- Copy the config file created by Synology to configure the kernel
computer$ cp synoconfigs/yourSynologyArchi .config
- Edit the Makefile to compile for the right architecture and use the right tool chains
computer$ vi Makefile
edit the variable ARCH -> ARCH = yourSynologyAchi
edit the variable CROSS_COMPILE -> CROSS_COMPILE = /usr/local/yourToolChains/bin/yourToolChains-
- Check the config file we just copied
computer$ make oldconfig
- Edit the config file through the user interface to add modules
computer$ make menuconfig
- Compile all modules
computer$ make modules
# or only a specific module: make M=./drivers/usb/serial
- Find your modules in the corresponding subfolder (in my case drivers/usb/serial/usbserial.ko)