Welcome to our website.

How to Compile redpill.ko for DSM 6.2.4 and DSM 7

There are two practical ways to build redpill.ko. One uses Synology’s published Linux source code, and the other uses Synology’s toolkit. The RedPill documentation recommends compiling against the official Linux source when possible. However, since DSM 7 source code was not publicly available at the time referenced here (as of 2021/10/5), the toolkit method is the workable option for DSM 7.

Ubuntu 20.04 is a suitable build environment and is the system used for the process shown here.

The examples below use the DS3615xs platform in line with the RedPill readme.md, but the same approach also applies to DS918+ where noted.

Install the required dependencies

Only a minimal example is shown here. If your build fails because of missing packages, install whatever the error messages indicate.

apt update
apt install make gcc

Method 1: Compile with Synology Linux source

This method can be used to build redpill.ko for DSM 6.2.4 on DS918+ and DS3615xs.

Clone the RedPill repository

Use git clone to fetch the latest RedPill repository:

git clone https://github.com/RedPill-TTG/redpill-lkm

image

Prepare the Linux source code

Download the source package that matches your platform and extract it into the redpill-lkm directory. You can unpack it with tar xvf xxx.txz.

Platform mapping:

  • DS918+: download the apollolake source
  • DS3615xs: download the bromolow source

Download the toolchain

The GCC version bundled with Ubuntu may be too new and can cause the build to fail.

image

To avoid that, use Synology’s official toolchain. When compiling with it, add the following CROSS_COMPILE prefix to your make commands:

CROSS_COMPILE=[your toolchain path]/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-

Prepare the kernel tree for building redpill.ko

First, change into the root directory of your Linux source tree.

If you are using Linux v3 (bromolow), run:

cp synoconfigs/bromolow .config

If you are using Linux v4 (apollolake), run:

cp synoconfigs/apollolake .configecho '+' > .scmversion

Then run:

In newer lkm versions, you must specify a build type:

  • dev-v6, dev-v7
  • test-v6, test-v7
  • prod-v6, prod-v7

The differences are in debug output only:

  • dev: prints all debug messages, including info, warning, and error
  • test: prints warning and error, but not info
  • prod: prints no debug information

These options do not appear to affect the module’s actual functionality.

make oldconfig CROSS_COMPILE=[你的工具链的路径]/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-
make modules_prepare CROSS_COMPILE=[你的工具链的路径]/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu- [生成类型]

After this finishes, return to the redpill-lkm directory.

Build redpill.ko

Run:

make LINUX_SRC=<你Linux源代码的路径> CROSS_COMPILE=[你工具链的路径]/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-

image

Post-process the module

Once the build succeeds, redpill.ko will appear in the root of the redpill-lkm directory.

Before using it, strip the module with:

strip -S *.ko

After that, redpill-load can be used to create the loader.

image

Method 2: Compile with Synology toolkit

This method is intended for DSM 7 and later when Synology has not published the corresponding Linux source code. It can be used for DS918+ and DS3615xs.

Clone the RedPill repository

Fetch the latest RedPill source:

git clone https://github.com/RedPill-TTG/redpill-lkm

Download the toolkit

Download the toolkit package that matches your platform, place it inside the redpill-lkm directory, and extract it with tar xvf xxx.txz.

Platform mapping:

  • DS918+: download the apollolake toolkit
  • DS3615xs: download the bromolow toolkit

An example package name would be ds.bromolow-7.0.dev.txz.

Download the toolchain

As with the source-based build, Ubuntu’s default GCC may be too new and may trigger compilation errors.

image

Use Synology’s official toolchain and pass this prefix to make:

CROSS_COMPILE=[your toolchain path]/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-

Build redpill.ko

Run:

As with the other method, newer lkm versions require a build type:

  • dev-v6, dev-v7
  • test-v6, test-v7
  • prod-v6, prod-v7

Debug output behavior is as follows:

  • dev: info, warning, and error
  • test: warning and error only
  • prod: no debug output

These settings do not seem to change the module’s behavior itself.

make LINUX_SRC=[你的toolkit位置]/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/modules/DSM-7.0/build CROSS_COMPILE=[你的工具链位置]/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu- [生成类型]

Post-process the module

If the build completes successfully, redpill.ko will be generated in the root of the redpill-lkm directory.

Then run:

strip -S *.ko

After that, the module can be used together with redpill-load to build the loader.

Related Posts