From eb7df3c222932ad8bce79c346af4e5a5287551d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=BC=E7=A0=BC?= Date: Sat, 12 Mar 2022 06:20:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20DVA3221=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 23 ++++-- README.md | 42 +++++++---- README_EN.md | 11 ++- docker/Dockerfile | 2 +- global_config.json | 27 +++++++ redpill_tool_chain.sh | 12 +++- serialnumbergen.sh | 139 +++++++++++++++++++++++++++++++++++++ 7 files changed, 234 insertions(+), 22 deletions(-) create mode 100755 serialnumbergen.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5d02e41..a0304d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,6 +33,8 @@ jobs: version: 7.0.1-42218 - platform: ds1621p version: 7.0.1-42218 + - platform: dva3221 + version: 7.0.1-42218 steps: - name: 检出项目文件 @@ -58,20 +60,33 @@ jobs: sed -i -e 's\0x0001\0x0002\g' -e 's\0x46f4\0x0002\g' ${{matrix.platform}}_user_config.json # 调整SN和MAC 最好使用 actions secrets 引入 - sed -i -e 's\1234XXX123\0123456789\g' -e 's\XXYYXXYYXXYY\00AAAAAAAAAA\g' ${{matrix.platform}}_user_config.json + sntext=`./redpill_tool_chain.sh sn ${{matrix.platform}}` + use_sn=`echo ${sntext} | grep 'Serial Number' | awk '{print $3}'` + use_mac=`echo ${sntext} | grep 'Mac Address' | awk '{print $3}' | sed 's\:\\g'` + echo ${sntext} + sed -i -e "s\1234XXX123\${use_sn}\g" -e 's\XXYYXXYYXXYY\0011323D47F7\g' ${{matrix.platform}}_user_config.json # 添加第二张网卡mac并设置网卡数量 - sed -i -e 's/00AAAAAAAAAA"/&,\n\t"mac2": "00BBBBBBBBBB",\n\t"netif_num": 2/' ${{matrix.platform}}_user_config.json + sed -i -e 's/0011323D47F7"/&,\n\t"mac2": "0011323D47F8",\n\t"netif_num": 2/' ${{matrix.platform}}_user_config.json # 调整synoinfo sed -i -e 's/"synoinfo": {},/"synoinfo": {\n\t"maxlanport": "2"\n },/' ${{matrix.platform}}_user_config.json - # 添加扩展驱动 + - name: 添加扩展驱动[非dva3221] + if: matrix.platform != 'dva3221' + run: | ./redpill_tool_chain.sh add https://github.com/jumkey/redpill-load/raw/develop/redpill-acpid/rpext-index.json ./redpill_tool_chain.sh add https://github.com/jumkey/redpill-load/raw/develop/redpill-virtio/rpext-index.json + - name: 添加扩展驱动[dva3221] + if: matrix.platform = 'dva3221' + run: | + # ./redpill_tool_chain.sh add https://github.com/pocopico/rp-ext/raw/main/redpill/rpext-index.json + ./redpill_tool_chain.sh add https://github.com/pocopico/rp-ext/raw/main/redpill/rpext-index.json + ./redpill_tool_chain.sh add https://github.com/orpheegt/redpill-load/raw/develop/redpill-virtio/rpext-index.json + - name: 添加 jumkey.misc - if: endsWith(matrix.version,'42218') + if: endsWith(matrix.version,'42218') && matrix.platform != 'dva3221' run: | ./redpill_tool_chain.sh add https://github.com/jumkey/redpill-load/raw/develop/redpill-misc/rpext-index.json diff --git a/README.md b/README.md index ccd02f7..1b5b6cf 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,9 @@ ## 关于项目? - 基于[RedPill-TTG](https://github.com/RedPill-TTG)源码制作 -- 为`DS918+`提供适当的支持 ( 感谢 [@jumkey](https://github.com/jumkey) ) -- 为`DS3617xs`提供适当的支持 ( 感谢 [@jimmyGALLAND](https://github.com/jimmyGALLAND) ) +- 为`DS918+`提供DSM7适配支持 ( 感谢 [@jumkey](https://github.com/jumkey) ) +- 为`DS3617xs`提供DSM7适配支持 ( 感谢 [@jimmyGALLAND](https://github.com/jimmyGALLAND) ) +- 为`DVA3221`提供DSM7适配支持 ( 感谢 [@dogodefi](https://github.com/dogodefi) ) - 整理社区扩展驱动 ( 感谢 [@pocopico](https://github.com/pocopico) ) - `redpill_lkm_make_target`字段的可选值有 `dev-v6`, `dev-v7`, `test-v6`, `test-v7`, `prod-v6` 或者 `prod-v7`, 需要注意后缀为`-v6`的值用于 DSM6 版本构建, 需要注意后缀为`-v7`的值用于 DSM7 版本构建. 默认使用的是 `dev-v6` 和 `dev-v7`。 @@ -22,20 +23,20 @@ 如果您发现工具链的构建方式有问题或者有改进的想法,请让我知道。 -对于所有其他问题:请向社区提出——我知道的并不比其他人多。 +对于所有其他问题:请向[社区ddr](https://xpenology.com/forum/forum/35-developer-discussion-room/)提出——我知道的并不比其他人多。 ## 如何使用? 1. 复制`sample_user_config.json`为`ds3615xs_user_config.json`或者`ds918p_user_config.json` 1. 编辑`_user_config.json`比如 918+ 就编辑 `ds918p_user_config.json` 文件 1. 添加扩展驱动: - 比如 `redpill_tool_chain.sh add https://raw.githubusercontent.com/pocopico/rp-ext/master/mpt3sas/rpext-index.json` + 比如 `./redpill_tool_chain.sh add https://raw.githubusercontent.com/pocopico/rp-ext/master/mpt3sas/rpext-index.json` 1. 为你想要的平台和版本构建编译镜像: - 比如 `redpill_tool_chain.sh build ds918p-7.0-41890` + 比如 `./redpill_tool_chain.sh build ds918p-7.0-41890` 1. 为你想要的平台和版本构建引导: - 比如 `redpill_tool_chain.sh auto ds918p-7.0-41890` + 比如 `./redpill_tool_chain.sh auto ds918p-7.0-41890` -`redpill_tool_chain.sh auto`运行结束之后,将会在宿主机的`./image`文件夹中生成 RedPill引导镜像。 +`./redpill_tool_chain.sh auto`运行结束之后,将会在宿主机的`./image`文件夹中生成 RedPill引导镜像。 `_user_config.json`文件中的`extensions`字段保持为空,会自动打包所有已安装的自定义驱动。 自定义驱动请按需添加,尽量不要加载无关驱动,否则会因为扩展驱动太大导致打包失败。 @@ -45,9 +46,9 @@ ## 快捷说明 - `docker/Dockerfile` 中补入了阿里云镜像 -- `redpill_tool_chain.sh add `添加扩展驱动 -- `redpill_tool_chain.sh del `删除扩展驱动 -- `redpill_tool_chain.sh run `自定义引导构建过程 +- `./redpill_tool_chain.sh add `添加扩展驱动 +- `./redpill_tool_chain.sh del `删除扩展驱动 +- `./redpill_tool_chain.sh run `自定义引导构建过程 - 使用`synoboot.sh`写入引导 ### 自定义扩展驱动管理 @@ -70,19 +71,25 @@ - `./redpill_tool_chain.sh auto ds3615xs-6.2.4-25556` - `./redpill_tool_chain.sh auto ds918p-7.0.1-42218` -### Clean old redpill bootloader images and build cache +### 清除旧的引导镜像和缓存 - `./redpill_tool_chain.sh clean ds3615xs-6.2.4-25556` - `./redpill_tool_chain.sh clean ds918p-7.0.1-42218` - `./redpill_tool_chain.sh clean all` +### 生成指定平台的序列号和MAC地址 + +- `./redpill_tool_chain.sh sn ds918p` +- `./redpill_tool_chain.sh sn dva3221` + ### 查看帮助文本 +`./redpill_tool_chain.sh` + ```txt -./redpill_tool_chain.sh Usage: ./redpill_tool_chain.sh -Actions: build, auto, run, clean +Actions: build, auto, run, clean, add, del, sn - build: Build the toolchain image for the specified platform version. @@ -101,6 +108,10 @@ Actions: build, auto, run, clean - del: To remove an already installed extension you need to know its ID. eg: del 'example_dev.some_extension' +- sn: Generates a serial number and mac address for the following platforms + DS3615xs DS3617xs DS916+ DS918+ DS920+ DS3622xs+ FS6400 DVA3219 DVA3221 DS1621+ + eg: sn ds920p + Available platform versions: --------------------- ds3615xs-6.2.4-25556 @@ -113,12 +124,17 @@ ds3617xs-7.0.1-42218 ds3622xsp-7.0.1-42218 ds920p-7.0.1-42218 ds1621p-7.0.1-42218 +dva3221-7.0.1-42218 Custom Extensions: --------------------- +jumkey.acpid2 pocopico.mpt3sas +pocopico.vmxnet3 thethorgroup.boot-wait thethorgroup.virtio + +Check global_settings.json for settings. ``` ## 更多细节 diff --git a/README_EN.md b/README_EN.md index 2af05b2..05f29e7 100644 --- a/README_EN.md +++ b/README_EN.md @@ -58,7 +58,7 @@ Examples: ./redpill_tool_chain.sh Usage: ./redpill_tool_chain.sh -Actions: build, auto, run, clean +Actions: build, auto, run, clean, add, del, sn - build: Build the toolchain image for the specified platform version. @@ -77,6 +77,10 @@ Actions: build, auto, run, clean - del: To remove an already installed extension you need to know its ID. eg: del 'example_dev.some_extension' +- sn: Generates a serial number and mac address for the following platforms + DS3615xs DS3617xs DS916+ DS918+ DS920+ DS3622xs+ FS6400 DVA3219 DVA3221 DS1621+ + eg: sn ds920p + Available platform versions: --------------------- ds3615xs-6.2.4-25556 @@ -89,12 +93,17 @@ ds3617xs-7.0.1-42218 ds3622xsp-7.0.1-42218 ds920p-7.0.1-42218 ds1621p-7.0.1-42218 +dva3221-7.0.1-42218 Custom Extensions: --------------------- +jumkey.acpid2 pocopico.mpt3sas +pocopico.vmxnet3 thethorgroup.boot-wait thethorgroup.virtio + +Check global_settings.json for settings. ``` ### Custom extended driver management diff --git a/docker/Dockerfile b/docker/Dockerfile index 8d37718..abd1f78 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -53,7 +53,7 @@ ENV ARCH=x86_64 \ ARG EXTRACTED_KSRC COPY --from=extract ${EXTRACTED_KSRC} ${LINUX_SRC} -RUN if [ "apollolake" = "$TARGET_PLATFORM" ] || [ "broadwellnk" = "$TARGET_PLATFORM" ] || [ "geminilake" = "$TARGET_PLATFORM" ] || [ "v1000" = "$TARGET_PLATFORM" ]; then echo '+' > ${LINUX_SRC}/.scmversion; fi && \ +RUN if [ "apollolake" = "$TARGET_PLATFORM" ] || [ "broadwellnk" = "$TARGET_PLATFORM" ] || [ "geminilake" = "$TARGET_PLATFORM" ] || [ "v1000" = "$TARGET_PLATFORM" ] || [ "denverton" = "$TARGET_PLATFORM" ]; then echo '+' > ${LINUX_SRC}/.scmversion; fi && \ if [ "$COMPILE_WITH" = "kernel" ]; then \ cp ${LINUX_SRC}/synoconfigs/${TARGET_PLATFORM} ${LINUX_SRC}/.config && \ make -C ${LINUX_SRC} oldconfig && \ diff --git a/global_config.json b/global_config.json index 5db4dcb..f2def97 100644 --- a/global_config.json +++ b/global_config.json @@ -288,6 +288,33 @@ "source_url": "https://github.com/jumkey/redpill-load.git", "branch": "develop" } + }, + { + "id": "dva3221-7.0.1-42218", + "platform_name": "DVA3221", + "platform_version": "denverton-7.0.1-42218", + "user_config_json": "dva3221_user_config.json", + "docker_base_image": "debian:10-slim", + "compile_with": "toolkit_dev", + "redpill_lkm_make_target": "dev-v7", + "downloads": { + "kernel": { + "url": "https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/25426branch/denverton-source/linux-4.4.x.txz/download", + "sha256": "ac532ebb221d9c55f78236d57288ac31d410dde01f1453f60b0c502333fdf107" + }, + "toolkit_dev": { + "url": "https://sourceforge.net/projects/dsgpl/files/toolkit/DSM7.0/ds.denverton-7.0.dev.txz/download", + "sha256": "6108f9f7b7f0a13ee985314aef9419303375ab7ded4112be991590339b66ecd1" + } + }, + "redpill_lkm": { + "source_url": "https://github.com/dogodefi/redpill-lkm.git", + "branch": "develop" + }, + "redpill_load": { + "source_url": "https://github.com/dogodefi/redpill-load.git", + "branch": "develop" + } } ] } diff --git a/redpill_tool_chain.sh b/redpill_tool_chain.sh index 29d59a6..c933818 100755 --- a/redpill_tool_chain.sh +++ b/redpill_tool_chain.sh @@ -191,7 +191,7 @@ function showHelp(){ cat << EOF Usage: ${0} -Actions: build, auto, run, clean +Actions: build, auto, run, clean, add, del, sn - build: Build the toolchain image for the specified platform version. @@ -210,6 +210,10 @@ Actions: build, auto, run, clean - del: To remove an already installed extension you need to know its ID. eg: del 'example_dev.some_extension' +- sn: Generates a serial number and mac address for the following platforms + DS3615xs DS3617xs DS916+ DS918+ DS920+ DS3622xs+ FS6400 DVA3219 DVA3221 DS1621+ + eg: sn ds920p + Available platform versions: --------------------- ${AVAILABLE_IDS} @@ -272,7 +276,7 @@ fi ACTION=${1} ID=${2} -if [[ "${ACTION}" != "del" && "${ACTION}" != "add" && "${ID}" != "all" ]]; then +if [[ "${ACTION}" != "del" && "${ACTION}" != "add" && "${ACTION}" != "sn" && "${ID}" != "all" ]]; then BUILD_CONFIG=$(getValueByJsonPath ".build_configs[] | select(.id==\"${ID}\")" "${CONFIG}") if [ -z "${BUILD_CONFIG}" ];then echo "Error: Platform version ${ID} not specified in global_config.json" @@ -312,7 +316,7 @@ if [[ "${ACTION}" != "del" && "${ACTION}" != "add" && "${ID}" != "all" ]]; then EXTRACTED_KSRC="/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/modules/DSM-${DSM_VERSION}/build/" fi else - if [[ "${ACTION}" != "del" && "${ACTION}" != "add" && "${ACTION}" != "clean" ]]; then + if [[ "${ACTION}" != "del" && "${ACTION}" != "add" && "${ACTION}" != "sn" && "${ACTION}" != "clean" ]]; then echo "All is not supported for action \"${ACTION}\"" exit 1 fi @@ -341,6 +345,8 @@ case "${ACTION}" in ;; clean) clean ;; + sn) ./serialnumbergen.sh `echo "${2}" | tr 'a-z' 'A-Z' | tr 'P' '+'` + ;; *) if [ ! -z ${ACTION} ];then echo "Error: action ${ACTION} does not exist" echo "" diff --git a/serialnumbergen.sh b/serialnumbergen.sh new file mode 100755 index 0000000..ccf08bb --- /dev/null +++ b/serialnumbergen.sh @@ -0,0 +1,139 @@ +#!/bin/bash + +# form https://github.com/pocopico/tinycore-redpill/blob/main/serialnumbergen.sh + +function beginArray() { + case $1 in + DS3615xs) + permanent="LWN" + serialstart="1130 1230 1330 1430" + ;; + DS3617xs) + permanent="ODN" + serialstart="1130 1230 1330 1430" + ;; + DS916+) + permanent="NZN" + serialstart="1130 1230 1330 1430" + ;; + DS918+) + permanent="PDN" + serialstart="1780 1790 1860 1980" + ;; + DS920+) + permanent="SBR" + serialstart="2030 2040 20C0 2150" + ;; + DS3622xsp) + permanent="SQR" + serialstart="2030 2040 20C0 2150" + ;; + FS6400) + permanent="PSN" + serialstart="1960" + ;; + DVA3219) + permanent="RFR" + serialstart="1930 1940" + ;; + DVA3221) + permanent="SJR" + serialstart="2030 2040 20C0 2150" + ;; + esac +} + + +function random() { + printf "%06d" $(($RANDOM %30000 +1 )) +} +function randomhex() { + val=$(( $RANDOM %255 +1)) + echo "obase=16; $val" | bc +} + +function generateRandomLetter() { + for i in a b c d e f g h j k l m n p q r s t v w x y z + do echo $i + done | sort -R|tail -1 +} + + +function generateRandomValue() { + for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f g h j k l m n p q r s t v w x y z + do echo $i + done | sort -R|tail -1 +} + +function toupper() { + echo $1 | tr 'a-z' 'A-Z' +} + +function generateMacAddress() { + #toupper "Mac Address: 00:11:32:$(randomhex):$(randomhex):$(randomhex)" + printf '00:11:32:%02X:%02X:%02X' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] +} + +function generateSerial(){ + beginArray $1 + case $1 in + DS3615xs) + serialnum="`echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1`$permanent"$(random) + ;; + DS3617xs) + serialnum="`echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1`$permanent"$(random) + ;; + DS916+) + serialnum="`echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1`$permanent"$(random) + ;; + DS918+) + serialnum="`echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1`$permanent"$(random) + ;; + FS6400) + serialnum="`echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1`$permanent"$(random) + ;; + DS920+) + serialnum=$(toupper "`echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1`$permanent"$(generateRandomLetter)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomLetter)) + ;; + DS3622xsp) + serialnum=$(toupper "`echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1`$permanent"$(generateRandomLetter)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomLetter)) + ;; + DVA3219) + serialnum=$(toupper "`echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1`$permanent"$(generateRandomLetter)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomLetter)) + ;; + DVA3221) + serialnum=$(toupper "`echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1`$permanent"$(generateRandomLetter)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomLetter)) + ;; + esac + echo $serialnum +} + + +function showhelp() { + +cat << EOF +$(basename ${0}) +---------------------------------------------------------------------------------------- +Usage: ${0} +Available platforms : +---------------------------------------------------------------------------------------- +DS3615xs DS3617xs DS916+ DS918+ DS920+ DS3622xsp FS6400 DVA3219 DVA3221 +e.g. $(basename ${0}) DS3615xs +---------------------------------------------------------------------------------------- +EOF + +} + +if [ -z "$1" ] ; then + showhelp +else + if [ "$1" = "DS3615xs" ] || [ "$1" = "DS3617xs" ] || [ "$1" = "DS916+" ] || [ "$1" = "DS918+" ] || [ "$1" = "DS920+" ] || [ "$1" = "DS3622xsp" ] || [ "$1" = "FS6400" ] || [ "$1" = "DVA3219" ] || [ "$1" = "DVA3221" ]; then + echo -e "Model:\t\t\t$1" + echo -e "Mac Address:\t\t$(generateMacAddress)" + echo -e "Serial Number:\t\t$(generateSerial $1)" + else + echo "Error : $1 is not an available model for serial number generation. " + echo "Available Models : DS3615xs DS3617xs DS916+ DS918+ DS920+ DS3622xsp DVA3219 DVA3221" + exit 1 + fi +fi