Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #403 from fbelavenuto/linux5
Browse files Browse the repository at this point in the history
Linux5
  • Loading branch information
fbelavenuto authored Dec 8, 2022
2 parents d194e50 + 3010935 commit 094ad9c
Show file tree
Hide file tree
Showing 20 changed files with 162 additions and 30 deletions.
4 changes: 2 additions & 2 deletions files/board/arpl/overlayfs/opt/arpl/boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ echo -e "\033[1;37mLoading DSM kernel...\033[0m"
# Executes DSM kernel via KEXEC
if [ "${EFI_BUG}" = "yes" -a ${EFI} -eq 1 ]; then
echo -e "\033[1;33mWarning, running kexec with --noefi param, strange things will happen!!\033[0m"
kexec --noefi -l "${MOD_ZIMAGE_FILE}" --initrd "${MOD_RDGZ_FILE}" --command-line="${CMDLINE_LINE}" >"${LOG_FILE}" 2>&1 || dieLog
kexec --args-linux --noefi -l "${MOD_ZIMAGE_FILE}" --initrd "${MOD_RDGZ_FILE}" --command-line="${CMDLINE_LINE}" >"${LOG_FILE}" 2>&1 || dieLog
else
kexec -l "${MOD_ZIMAGE_FILE}" --initrd "${MOD_RDGZ_FILE}" --command-line="${CMDLINE_LINE}" >"${LOG_FILE}" 2>&1 || dieLog
kexec --args-linux -l "${MOD_ZIMAGE_FILE}" --initrd "${MOD_RDGZ_FILE}" --command-line="${CMDLINE_LINE}" >"${LOG_FILE}" 2>&1 || dieLog
fi
/sbin/swapoff -a >/dev/null 2>&1 || true
/bin/umount -a -r >/dev/null 2>&1 || true
Expand Down
Binary file not shown.
Binary file modified files/board/arpl/overlayfs/opt/arpl/kpatch
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
id: "SA6400"
synoinfo: &synoinfo
support_disk_compatibility: "no"
support_memory_compatibility: "no"
support_led_brightness_adjustment: "no"
rss_server: "https://raw.githubusercontent.com/fbelavenuto/arpl/main/rss.xml"
rss_server_ssl: "https://raw.githubusercontent.com/fbelavenuto/arpl/main/rss.xml"
rss_server_v2: "https://raw.githubusercontent.com/fbelavenuto/arpl/main/rss.json"
cmdline: &cmdline
SMBusHddDynamicPower: 1
synoboot2:
syno_ttyS0: "serial,0x3f8"
syno_ttyS1: "serial,0x2f8"
vender_format_version: 2
platform: "epyc7002"
unique: "synology_epyc7002_sa6400"
beta: true
dom: 2
serial:
prefix:
- "0000"
middle: "XXX"
suffix: "alpha"
disks: 16
dt: true
builds:
42962:
ver: "7.1.1"
kver: "5.10.55"
rd-compressed: false
efi-bug: no
cmdline:
<<: *cmdline
synoinfo:
<<: *synoinfo
pat:
url: "https://global.download.synology.com/download/DSM/release/7.1.1/42962/DSM_SA6400_42962.pat"
hash: "83fc408380ebb1381224261de6220b873d7b62a99e715557509ae9553f618a71"
ramdisk-hash: "d4efe45fc4dd71758fe365f7eb39d24982d1440b00986259cab9a03577982f68"
zimage-hash: "d5b8af848fc585695e35bd1c4f4c953fd8e54435b2799face4f8f350bac6df93"
md5-hash: "fdbbea86e280a8f754339a064f9ad2df"
patch:
- "ramdisk-common-disable-root-pwd.patch"
- "ramdisk-common-init-script.patch"
- "ramdisk-common-etc-rc.patch"
- "ramdisk-42951-post-init-script.patch"
61 changes: 40 additions & 21 deletions files/board/arpl/overlayfs/opt/arpl/vmlinux-to-bzImage.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
#!/bin/sh
# Based on code and ideas from @jumkey

. /opt/arpl/include/functions.sh

#zImage_head 16494
#payload(
# vmlinux.bin x
# padding 0xf00000-x
# vmlinux.bin size 4
#) 0xf00004
#zImage_tail(
# unknown 72
# run_size 4
# unknown 30
# vmlinux.bin size 4
# unknown 114460
#) 114570
#crc32 4
MODEL="`readConfigKey "model" "${USER_CONFIG_FILE}"`"
BUILD="`readConfigKey "build" "${USER_CONFIG_FILE}"`"
KVER="`readModelKey "${MODEL}" "builds.${BUILD}.kver"`"

# Adapted from: scripts/Makefile.lib
# Usage: size_append FILE [FILE2] [FILEn]...
Expand Down Expand Up @@ -51,12 +41,41 @@ size_le () {
SCRIPT_DIR=`dirname $0`
VMLINUX_MOD=${1}
ZIMAGE_MOD=${2}
gzip -cd "${SCRIPT_DIR}/zImage_template.gz" > "${ZIMAGE_MOD}"
if [ ${KVER:0:1} -eq 4 ]; then
# Kernel version 4.x
#zImage_head 16494
#payload(
# vmlinux.bin x
# padding 0xf00000-x
# vmlinux.bin size 4
#) 0xf00004
#zImage_tail(
# unknown 72
# run_size 4
# unknown 30
# vmlinux.bin size 4
# unknown 114460
#) 114570
#crc32 4
gzip -cd "${SCRIPT_DIR}/bzImage-template-v4.gz" > "${ZIMAGE_MOD}"

dd if="${VMLINUX_MOD}" of="${ZIMAGE_MOD}" bs=16494 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=15745134 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
dd if="${VMLINUX_MOD}" of="${ZIMAGE_MOD}" bs=16494 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=15745134 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=15745244 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog

RUN_SIZE=`objdump -h ${VMLINUX_MOD} | sh "${SCRIPT_DIR}/calc_run_size.sh"`
size_le $RUN_SIZE | dd of=$ZIMAGE_MOD bs=15745210 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=15745244 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
size_le $(($((16#`crc32 "${ZIMAGE_MOD}" | awk '{print$1}'`)) ^ 0xFFFFFFFF)) | dd of="${ZIMAGE_MOD}" conv=notrunc oflag=append >"${LOG_FILE}" 2>&1 || dieLog
RUN_SIZE=`objdump -h ${VMLINUX_MOD} | sh "${SCRIPT_DIR}/calc_run_size.sh"`
size_le ${RUN_SIZE} | dd of=${ZIMAGE_MOD} bs=15745210 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
size_le $(($((16#`crc32 "${ZIMAGE_MOD}" | awk '{print$1}'`)) ^ 0xFFFFFFFF)) | dd of="${ZIMAGE_MOD}" conv=notrunc oflag=append >"${LOG_FILE}" 2>&1 || dieLog
else
# Kernel version 5.x
gzip -cd "${SCRIPT_DIR}/bzImage-template-v5.gz" > "${ZIMAGE_MOD}"

lzma -9c ${VMLINUX_MOD} > ${TMP_PATH}/vmlinux-mod.lzma
dd if="${TMP_PATH}/vmlinux-mod.lzma" of="${ZIMAGE_MOD}" bs=15377 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=8377991 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=8420412 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog

RUN_SIZE=`objdump -h ${VMLINUX_MOD} | sh "${SCRIPT_DIR}/calc_run_size.sh"`
size_le ${RUN_SIZE} | dd of=${ZIMAGE_MOD} bs=8420408 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
size_le $(($((16#`crc32 "${ZIMAGE_MOD}" | awk '{print$1}'`)) ^ 0xFFFFFFFF)) | dd of="${ZIMAGE_MOD}" conv=notrunc oflag=append >"${LOG_FILE}" 2>&1 || dieLog
fi
Binary file added files/board/arpl/p3/addons/reducelog/all.tgz
Binary file not shown.
15 changes: 15 additions & 0 deletions files/board/arpl/p3/addons/reducelog/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 1
name: reducelog
description: "Addon to reduce DSM log"
all:
install-script: "install.sh"
available-for:
bromolow-3.10.108:
apollolake-4.4.180:
broadwell-4.4.180:
broadwellnk-4.4.180:
denverton-4.4.180:
geminilake-4.4.180:
v1000-4.4.180:
r1000-4.4.180:
epyc7002-5.10.55:
Binary file added files/board/arpl/p3/addons/remove-pma/all.tgz
Binary file not shown.
15 changes: 15 additions & 0 deletions files/board/arpl/p3/addons/remove-pma/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 1
name: remove-pma
description: "Create a cron entry to remove *.pma files from Surveillance Station (#215 issue)"
all:
install-script: "install.sh"
available-for:
bromolow-3.10.108:
apollolake-4.4.180:
broadwell-4.4.180:
broadwellnk-4.4.180:
denverton-4.4.180:
geminilake-4.4.180:
v1000-4.4.180:
r1000-4.4.180:
epyc7002-5.10.55:
Binary file modified files/board/arpl/p3/modules/apollolake-4.4.180.tgz
Binary file not shown.
Binary file modified files/board/arpl/p3/modules/broadwell-4.4.180.tgz
Binary file not shown.
Binary file modified files/board/arpl/p3/modules/broadwellnk-4.4.180.tgz
Binary file not shown.
Binary file modified files/board/arpl/p3/modules/bromolow-3.10.108.tgz
Binary file not shown.
Binary file modified files/board/arpl/p3/modules/denverton-4.4.180.tgz
Binary file not shown.
Binary file added files/board/arpl/p3/modules/epyc7002-5.10.55.tgz
Binary file not shown.
Binary file modified files/board/arpl/p3/modules/geminilake-4.4.180.tgz
Binary file not shown.
Binary file modified files/board/arpl/p3/modules/v1000-4.4.180.tgz
Binary file not shown.
Binary file added kpatch/kpatch
Binary file not shown.
51 changes: 44 additions & 7 deletions kpatch/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void errorMsg(char *fmt, ...) {
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
exit(1);
}

Expand Down Expand Up @@ -307,15 +308,39 @@ int main(int argc, char *argv[]) {
Elf_Scn *section;
GElf_Shdr sectionHeader;
char *sectionName;
char *fileIn = NULL, *fileOut = NULL;
int onlyBoot = 0, onlyRD = 0, onlyCMOS = 0, c;

if (argc != 3) {
errorMsg("Use: kpatch <vmlinux> <output>\n");
if (argc < 3) {
errorMsg("Use: kpatch (option) <vmlinux> <output>\nOptions:\n -b Only bootparams\n -r Only ramdisk\n -c Only CMOS");
}
c = 1;
while (c < argc) {
if (strcmp(argv[c], "-b") == 0) {
onlyBoot = 1;
} else if (strcmp(argv[c], "-r") == 0) {
onlyRD = 1;
} else if (strcmp(argv[c], "-c") == 0) {
onlyCMOS = 1;
} else if (fileIn == NULL) {
fileIn = argv[c];
} else {
fileOut = argv[c];
break;
}
++c;
}
if (NULL == fileIn) {
errorMsg("Please give a input filename");
}
if (NULL == fileOut) {
errorMsg("Please give a output filename");
}

if (elf_version(EV_CURRENT) == EV_NONE)
elfErrno();

if ((fd = open(argv[1], O_RDONLY)) == -1)
if ((fd = open(fileIn, O_RDONLY)) == -1)
errorNum();

if ((elfHandle = elf_begin(fd, ELF_C_READ, NULL)) == NULL)
Expand Down Expand Up @@ -367,10 +392,22 @@ int main(int argc, char *argv[]) {
printf("Found .init.text offset @ %lX\n", initTextOffs);
printf("Found .rodata address @ %lX\n", rodataAddr);
printf("Found .rodata offset @ %lX\n", rodataOffs);
patchBootParams();
patchRamdiskCheck();
patchCmosWrite();
if ((fd = open(argv[2], O_WRONLY | O_CREAT, 0644)) == -1) {
if (onlyBoot == 0 && onlyCMOS == 0 && onlyRD == 0) {
patchBootParams();
patchRamdiskCheck();
patchCmosWrite();
} else {
if (onlyBoot == 1) {
patchBootParams();
}
if (onlyRD == 1) {
patchRamdiskCheck();
}
if (onlyCMOS == 1) {
patchCmosWrite();
}
}
if ((fd = open(fileOut, O_WRONLY | O_CREAT, 0644)) == -1) {
errorNum();
}
if (fileSize != write(fd, fileData, fileSize)) {
Expand Down

0 comments on commit 094ad9c

Please sign in to comment.