RedPill

最後更新: 2021-09-20

介紹

redpill 項目有3個子項目, 分別係

目錄

  • Compile RedPill LKM
  • 建立 Bootable Image

 


Compile RedPill LKM

 

DSM 6.2.4 = Kernel v3  <= 要用 GCC v4.8/v4.9 去 compile, 否認會失敗 !

下載 DSM 的 Linux Kernel Source

HW: ds3514 => bromolow

DSM Version 6.2.4 => 25426

Linux Kernel => 3.10.x

# linux kernel source

$link=https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source

$link/25426branch/bromolow-source/linux-3.10.x.txz

Complie redpill on Centos 7

# gcc version 4.8.5

yum groupinstall "Development Tools"

tar -Jxf linux-3.10.x.txz

unzip redpill-lkm-master.zip

cd linux-3.10.x

cp synoconfigs/bromolow .config

make oldconfig ; make modules_prepare

cd redpill-lkm-master

make LINUX_SRC=../linux-3.10.x prod-v6

ls -lh redpill.ko

-rw-r--r-- 1 root root 108K Sep 23 04:35 redpill.ko

 


建立 Bootable Image

 

# 在 Centos 7 compile 它

yum install jq         # v1.6 epel

compile bash 5.0    # 系統上的 bash 太舊, 行 build-loader.sh 會出 error

compile bsdiff         # 系統沒有它, 亦要人手 compile

# Config

user_config.json

{
  "extra_cmdline": {
    "pid": "",
    "vid": "",
    "sn": "1330Lxxxxx",
    "mac1": "0011xxxxxx"
  },
  "synoinfo": {
    "supportsystemperature": "no",
    "supportsystempwarning": "no"
  }
}

config/DS3615xs/6.2.4-25556/config.json

...

# Kernel module

# ext/rp-lkm/redpill-linux-<VERSION>.ko

cp redpill-lkm-master/redpill.ko redpill-load-master/ext/rp-lkm/redpill-linux-v3.10.105.ko

# 下載 pat 到  cache folder

cd redpill-load-master

DSM_DS3615xs_25556.pat -> cache/ds3615xs_25556.pat

# Build

Run ./build-loader.sh <hw_version> <os_version> [output-file]

e.g.

export PATH=/opt/bash/bin:$PATH              # 設定要 bash 5.0

./build-loader.sh 'DS3615xs' '6.2.4-25556' redpill.img

# 修改 loader

losetup /dev/loop0 redpill.img

partprobe /dev/loop0

mkdir /mnt/tmp

mount /dev/loop0p1 /mnt/tmp

/mnt/tmp/boot/grub/grub.cfg

...
set default="1"
...
menuentry 'RedPill DS3615xs v6.2.4-25556 (SATA, Verbose)' {
        savedefault
        set root=(hd0,msdos1)
        echo Loading Linux...
        linux /zImage ... SataPortMap=16 DiskIdxMap=1000

umount /mnt/tmp; losetup -d loop0

build-loader.sh 在做什麼

  • 下載 DSM 的 pat 到 cache Folder (ds3615xs_25556.pat)
  • Verified checksum of a known kernel & ramdisk files
    (config/DS3615xs/6.2.4-25556/config.json)
  • Unpack pat 到 build 目錄
  • Patches the kernel zImage using included patches [direct mode]
    (zImage-001-3615xs-25556-ramdisk-and-header.bsp)
  • Unpacks ramdisk
    Applies common patches (disable root pw, add RP LKM loading etc)
    Generates synoinfo replacements based on the platform requirements AND user configuration
    Patches synoinfo in etc & etc.defaults in the ramdisk image
    Adds dynamic patching routines to post-init script (so that synoinfo is patched in the booted OS too)
    Copies missing VirtIO modules (original DSM script supports them but they're not included in non-VDSM builds)
  • Reassembles ramdisk(rd.gz)
  • 在 images 目錄建立 image 檔(redpill-DS3615xs_6.2.4-25556_b1632107909.img)

Patching the kernel mothod:

  • direct (default)
  • repack (BRP_LINUX_PATCH_METHOD=repack)

In the repack mode the kernel is NOT patched using direct binary patches between original and final

 


Troubleshoot

 

安 DSM 時出 Error

Failed to install the file. The file is probably corrupted. (13)

在 bootloader 選 'RedPill DS3615xs v6.2.4-25556 (SATA, Verbose)'

Solution to fix update fail from 6.2.4 to 6.2.4-2

cat /var/log/junior_reason

Exit on error [7] root not matched with junior...

cat /var/log/messages

... findhostd: ninstaller.c:224 Mount partion /dev/md0 /tmpRoot
... findhostd: ninstaller.c:967 Executing /tmpRoot//.syno/patch/updater -a /tmpRoot [255]
... findhostd: ninstaller.c:969 Recover patch is not available.

1. login the console with root (without password)

2. mount /dev/md0 /mnt

3. rm -rf /mnt/.syno

4. http://NAS-IP:5000

Select "Migration: Keep my data and most of the settings"

Install original pat (DSM_DS3615xs_25556.pat) # 271 MB