├── .gitignore ├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── build-alpine.sh ├── build-archlinux.sh ├── build-armbian.sh ├── build-lakka.sh ├── build-libreelec.sh ├── dtbs └── 4.4-bsp │ ├── box │ └── rk3328-beikeyun.dtb │ └── headless │ └── rk3328-beikeyun.dtb ├── flash.sh ├── input └── .gitignore ├── loader ├── armbian-5.75 │ ├── idbloader.bin │ ├── trust.bin │ └── uboot.img ├── libreelec │ └── u-boot.bin └── rk3328_loader_v1.14.249.bin ├── output └── .gitignore └── tools ├── alpine ├── init.sh ├── resizemmc └── resizemmc.sh ├── archlinux ├── init.sh ├── resizemmc.service └── resizemmc.sh └── qemu └── qemu-aarch64-static /.gitignore: -------------------------------------------------------------------------------- 1 | tmp 2 | !/loader/** 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | #if: tag IS present 2 | dist: xenial 3 | language: minimal 4 | sudo: required 5 | addons: 6 | apt: 7 | packages: 8 | - p7zip-full 9 | - mtools 10 | - jq 11 | - u-boot-tools 12 | - html-xml-utils 13 | - squashfs-tools 14 | - bsdtar 15 | - axel 16 | script: 17 | - make build_armbian=y build_libreelec=y build_archlinux=y build 18 | - ls -l output 19 | deploy: 20 | provider: releases 21 | api_key: 22 | secure: DtKpcwr08uKZn4DfajyknVfMTO9rJ38ASWqokZFl3LcjZdQhd8lAiPSkq1GMmU1QmlKqHXEJFcYsv9lDR3NSC/03N2NE1DzUp6Xvl0QX3A/Xtd54RbP0RK3/SXaeJKAz1UsNLXYEi5D+q2yz3pkAhdH3IyNTeMUm2E/7k7R95mjVkF6wPTnwmF0avSfrwud2MYo8EroezQXg+nJYRGLNLdAX+zyF2FDIcxFI8s3Z/WBQN6u5BXX0cy//C+J+M/M7Apf9zaMqhibmypnB0YJkhM+Of/C90BTxgQSTDVHwBFTn9cHIgH/Ox1yCCQ8fv/olhf/G4jKakEf1V4kJ8BIfGY0M6b1XqFMtxa84vcXGW5L+TXpVkJOfw06YNtLJLeLuqfqqGqRCuRra80NuoBwRo+JUHpnCZAMxDIHfhVLD8jKkzzL0S4pUykppPlxUgudbkNVLXkOIOEdcn6/G8V0NgjVd2o/Pr9ZUCuZGl5HoJpLhleYPss9/0Pba+aBbAFq8TufmjPsC6IaivVC1pRWz2dLJ/2eoNQOAX72D9HRuRLFjDSVIdUojkv7DNH85iJM4zGUZTzC/+Nf0HizXH7peYNPlPiPdyvIfxPdBED+AVxt5jleNIdovnEiB3DoQQfmqnw1/R3t0ichxZKpNnJFcWUTH8t6gqgWFjrs68lAHQvM= 23 | skip_cleanup: true 24 | overwrite: true 25 | file_glob: true 26 | file: output/*.xz 27 | on: 28 | repo: hanwckf/build-beikeyun 29 | tags: true 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 hanwckf 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | DTB_HEADLESS := dtbs/4.4-bsp/headless/rk3328-beikeyun.dtb 2 | DTB_BOX := dtbs/4.4-bsp/box/rk3328-beikeyun.dtb 3 | 4 | DL := input 5 | WGET := wget -P $(DL) 6 | AXEL := axel -a -n4 -o $(DL) 7 | 8 | OUTPUT := output 9 | TARGETS := armbian libreelec alpine archlinux lakka 10 | 11 | .PHONY: help build clean 12 | 13 | help: 14 | @echo "Usage: make build_[system1]=y build_[system2]=y build" 15 | @echo "available system: $(TARGETS)" 16 | 17 | build: $(TARGETS) 18 | 19 | clean: $(TARGETS:%=%_clean) 20 | rm -f $(OUTPUT)/*.img $(OUTPUT)/*.xz 21 | 22 | ARMBIAN_PKG_UBUNTU := Armbian_5.90_Rock64_Ubuntu_bionic_default_4.4.182.7z 23 | ARMBIAN_PKG_DEBIAN := Armbian_5.91_Rock64_Debian_buster_default_4.4.184.7z 24 | ARMBIAN_PKG_DEBIAN_STRETCH := Armbian_5.90_Rock64_Debian_stretch_default_4.4.182.7z 25 | 26 | ifneq ($(TRAVIS),) 27 | ARMBIAN_URL_BASE := https://dl.armbian.com/rock64/archive 28 | else 29 | ARMBIAN_URL_BASE := https://mirrors.tuna.tsinghua.edu.cn/armbian-releases/rock64/archive 30 | endif 31 | 32 | ARMBIAN_PKG_%: 33 | @( if [ ! -f "$(DL)/$($(@))" ]; then \ 34 | $(WGET) $(ARMBIAN_URL_BASE)/$($(@)) ; \ 35 | fi ) 36 | 37 | ARMBIAN_PKG_%_CLEAN: 38 | rm -f $(DL)/$($(@:_CLEAN=)) 39 | 40 | ifeq ($(build_armbian),y) 41 | ARMBIAN_TARGETS := ARMBIAN_PKG_UBUNTU ARMBIAN_PKG_DEBIAN ARMBIAN_PKG_DEBIAN_STRETCH 42 | 43 | armbian: $(ARMBIAN_TARGETS) 44 | ( for pkg in $(foreach n,$^,$($(n))); do \ 45 | sudo ./build-armbian.sh release $(DL)/$$pkg $(DTB_HEADLESS) ; \ 46 | done ) 47 | 48 | armbian_clean: $(ARMBIAN_TARGETS:%=%_CLEAN) 49 | 50 | else 51 | armbian: 52 | armbian_clean: 53 | endif 54 | 55 | ifeq ($(build_libreelec),y) 56 | #LIBREELEC_URL := http://archive.libreelec.tv 57 | LIBREELEC_URL := http://www.gtlib.gatech.edu/pub/LibreELEC 58 | 59 | LIBREELEC_PKG := $(shell basename "`hxwls "$(LIBREELEC_URL)/?C=M;O=D" |grep 'rock64.img.gz$$' |head -1`") 60 | libreelec: libreelec_dl libreelec_release 61 | 62 | libreelec_clean: 63 | ( if [ -n "$(LIBREELEC_PKG)" ]; then \ 64 | rm -f $(DL)/$(LIBREELEC_PKG) ; \ 65 | fi ) 66 | 67 | libreelec_dl: 68 | @( if [ -n "$(LIBREELEC_PKG)" ]; then \ 69 | if [ ! -f $(DL)/$(LIBREELEC_PKG) ]; then \ 70 | $(WGET) "$(LIBREELEC_URL)/$(LIBREELEC_PKG)" ; \ 71 | fi \ 72 | else \ 73 | echo "fetch libreelec dl url fail" ; exit 1 ; \ 74 | fi ) 75 | 76 | libreelec_release: libreelec_dl 77 | ./build-libreelec.sh release $(DL)/$(LIBREELEC_PKG) $(DTB_BOX) 78 | 79 | else 80 | libreelec: 81 | libreelec_clean: 82 | endif 83 | 84 | ifeq ($(build_lakka),y) 85 | LAKKA_URL := http://le.builds.lakka.tv/Rockchip.ROCK64.arm 86 | LAKKA_PKG := $(shell basename "`hxwls "$(LAKKA_URL)/?C=M&O=D" |grep 'img.gz$$' |head -1`") 87 | LAKKA_IDB := loader/armbian-5.75/idbloader.bin 88 | LAKKA_UBOOT_PATCH := loader/libreelec/u-boot.bin 89 | 90 | lakka: lakka_dl lakka_release 91 | 92 | lakka_clean: 93 | ( if [ -n "$(LAKKA_PKG)" ]; then \ 94 | rm -f $(DL)/$(LAKKA_PKG); \ 95 | fi ) 96 | 97 | lakka_dl: 98 | ( if [ -n "$(LAKKA_PKG)" ]; then \ 99 | if [ ! -f $(DL)/$(LAKKA_PKG) ]; then \ 100 | #$(WGET) "$(LAKKA_URL)/$(LAKKA_PKG)" ; \ 101 | $(AXEL) -q "$(LAKKA_URL)/$(LAKKA_PKG)" ; \ 102 | fi \ 103 | else \ 104 | echo "fetch lakka dl url fail" ; exit 1 ; \ 105 | fi ) 106 | 107 | lakka_release: lakka_dl 108 | ./build-lakka.sh release $(DL)/$(LAKKA_PKG) $(DTB_BOX) $(LAKKA_IDB) $(LAKKA_UBOOT_PATCH) 109 | 110 | else 111 | lakka: 112 | lakka_clean: 113 | endif 114 | 115 | ifeq ($(build_alpine),y) 116 | ALPINE_BRANCH := v3.10 117 | ALPINE_VERSION := 3.10.0 118 | ALPINE_PKG := alpine-minirootfs-$(ALPINE_VERSION)-aarch64.tar.gz 119 | 120 | ifneq ($(TRAVIS),) 121 | ALPINE_URL_BASE := http://dl-cdn.alpinelinux.org/alpine/$(ALPINE_BRANCH)/releases/aarch64 122 | else 123 | ALPINE_URL_BASE := https://mirrors.tuna.tsinghua.edu.cn/alpine/$(ALPINE_BRANCH)/releases/aarch64 124 | endif 125 | 126 | alpine: alpine_dl alpine_release 127 | 128 | alpine_dl: $(DL)/$(ALPINE_PKG) 129 | 130 | $(DL)/$(ALPINE_PKG): 131 | $(WGET) $(ALPINE_URL_BASE)/$(ALPINE_PKG) 132 | 133 | alpine_release: ARMBIAN_PKG_UBUNTU alpine_dl 134 | sudo ./build-alpine.sh release $(DL)/$(ARMBIAN_PKG_UBUNTU) $(DTB_HEADLESS) $(DL)/$(ALPINE_PKG) 135 | 136 | alpine_clean: ARMBIAN_PKG_UBUNTU_CLEAN 137 | rm -f $(DL)/$(ALPINE_PKG) 138 | 139 | else 140 | alpine: 141 | alpine_clean: 142 | endif 143 | 144 | ifeq ($(build_archlinux),y) 145 | ARCHLINUX_PKG := ArchLinuxARM-aarch64-latest.tar.gz 146 | 147 | ifneq ($(TRAVIS),) 148 | ARCHLINUX_URL_BASE := http://os.archlinuxarm.org/os 149 | else 150 | ARCHLINUX_URL_BASE := https://mirrors.tuna.tsinghua.edu.cn/archlinuxarm/os 151 | endif 152 | 153 | archlinux: archlinux_dl archlinux_release 154 | 155 | archlinux_dl: $(DL)/$(ARCHLINUX_PKG) 156 | 157 | $(DL)/$(ARCHLINUX_PKG): 158 | $(WGET) $(ARCHLINUX_URL_BASE)/$(ARCHLINUX_PKG) 159 | 160 | archlinux_release: ARMBIAN_PKG_UBUNTU archlinux_dl 161 | sudo ./build-archlinux.sh release $(DL)/$(ARMBIAN_PKG_UBUNTU) $(DTB_HEADLESS) $(DL)/$(ARCHLINUX_PKG) 162 | 163 | archlinux_clean: ARMBIAN_PKG_UBUNTU_CLEAN 164 | rm -f $(DL)/$(ARCHLINUX_PKG) 165 | 166 | else 167 | archlinux: 168 | archlinux_clean: 169 | endif 170 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # build-beikeyun 2 | 3 | [![Build Status](https://travis-ci.com/hanwckf/build-beikeyun.svg?branch=master)](https://travis-ci.com/hanwckf/build-beikeyun) 4 | [![release](https://img.shields.io/github/release/hanwckf/build-beikeyun.svg)](https://github.com/hanwckf/build-beikeyun/releases) 5 | 6 | ### scripts for build beikeyun firmware 7 | 8 | - armbian 9 | - default root password: 1234 10 | - LibreELEC 11 | - default root password: libreelec 12 | - Lakka 13 | - default root password: root 14 | - alpine 15 | - default root password: admin 16 | - archlinuxarm 17 | - default root password: admin 18 | - run `pacman-key --init && pacman-key --populate archlinuxarm` to init keyring 19 | -------------------------------------------------------------------------------- /build-alpine.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # requirements: sudo jq sfdisk u-boot-tools qemu bimfmt_misc parted 3 | # require armbian kernel and u-boot 4 | 5 | [ "$EUID" != "0" ] && echo "please run as root" && exit 1 6 | 7 | armbian_mount_point="/mnt/armbian_rootfs" 8 | rootfs_mount_point="/mnt/alpine_rootfs" 9 | 10 | tmpdir="tmp" 11 | output="output" 12 | 13 | origin="minirootfs" 14 | target="beikeyun" 15 | 16 | rootsize=700 17 | ROOTOFFSET=32768 18 | 19 | qemu_static="./tools/qemu/qemu-aarch64-static" 20 | 21 | func_umount_armbian() { 22 | umount $armbian_mount_point 23 | } 24 | 25 | func_mount_armbian() { 26 | local img=$1 27 | local mount_point=$2 28 | [ ! -f "$img" ] && echo "img file not found!" && return 1 29 | start=$(sfdisk -J $img | jq .partitiontable.partitions[0].start) 30 | offset=$((start * 512)) 31 | mkdir -p $mount_point 32 | mount -o loop,offset=$offset $1 $mount_point 33 | } 34 | 35 | func_generate() { 36 | local armbian_img=$1 37 | local dtb=$2 38 | local rootfs=$3 39 | local img_new=${4:-alpine.img} 40 | 41 | [ ! -f "$dtb" ] && echo "dtb file not found!" && return 1 42 | [ ! -f "$rootfs" ] && echo "alpine rootfs file not found!" && return 1 43 | [ ! -f "$armbian_img" ] && echo "armbian img file not found!" && return 1 44 | 45 | # create ext4 rootfs img 46 | mkdir -p ${tmpdir} 47 | echo "create ext4 rootfs, size: ${rootsize}M" 48 | dd if=/dev/zero bs=1M status=none count=$rootsize of=$tmpdir/rootfs.img 49 | mkfs.ext4 -q -m 2 $tmpdir/rootfs.img 50 | 51 | # mount rootfs 52 | mkdir -p $rootfs_mount_point 53 | mount -o loop $tmpdir/rootfs.img $rootfs_mount_point 54 | 55 | # extract alpine rootfs 56 | echo "extract alpine rootfs($rootfs) to $rootfs_mount_point" 57 | tar xpf $rootfs -C $rootfs_mount_point 58 | 59 | # mount armbian rootfs 60 | func_mount_armbian $armbian_img $armbian_mount_point 61 | 62 | # get /boot /lib/modules /lib/firmware 63 | echo "copy /boot,/lib/modules,/lib/firmware from armbian" 64 | cp -rf $armbian_mount_point/boot $rootfs_mount_point/boot 65 | cp -rf $armbian_mount_point/lib/modules $rootfs_mount_point/lib/modules 66 | rm -rf $rootfs_mount_point/lib/firmware && cp -rf $armbian_mount_point/lib/firmware $rootfs_mount_point/lib/firmware 67 | 68 | #umount armbian rootfs 69 | func_umount_armbian 70 | 71 | # patch /boot 72 | echo "patch /boot" 73 | cp -f $dtb $rootfs_mount_point/boot/ 74 | sed -i '/^verbosity/cverbosity=7' $rootfs_mount_point/boot/armbianEnv.txt 75 | sed -i '/^rootdev/crootdev=\/dev\/mmcblk0p1' $rootfs_mount_point/boot/armbianEnv.txt 76 | if [ -z "`grep fdtfile $rootfs_mount_point/boot/armbianEnv.txt`" ]; then 77 | echo "fdtfile=$(basename $dtb)" >> $rootfs_mount_point/boot/armbianEnv.txt 78 | fi 79 | if [ -z "`grep extraargs $rootfs_mount_point/boot/armbianEnv.txt`" ]; then 80 | echo "extraargs=rw console=ttyFIQ0,1500000" >> $rootfs_mount_point/boot/armbianEnv.txt 81 | fi 82 | sed -i 's#${prefix}dtb/${fdtfile}#${prefix}/${fdtfile}#' $rootfs_mount_point/boot/boot.cmd 83 | mkimage -C none -T script -d $rootfs_mount_point/boot/boot.cmd $rootfs_mount_point/boot/boot.scr 84 | 85 | # change mirrors 86 | if [ -z "$TRAVIS" ]; then 87 | sed -i 's#http://dl-cdn.alpinelinux.org#https://mirrors.tuna.tsinghua.edu.cn#' $rootfs_mount_point/etc/apk/repositories 88 | echo "nameserver 119.29.29.29" > $rootfs_mount_point/etc/resolv.conf 89 | else 90 | echo "nameserver 8.8.8.8" > $rootfs_mount_point/etc/resolv.conf 91 | fi 92 | 93 | # chroot to alpine rootfs 94 | echo "configure binfmt to chroot" 95 | modprobe binfmt_misc 96 | if [ -e /proc/sys/fs/binfmt_misc/register ]; then 97 | echo -1 > /proc/sys/fs/binfmt_misc/status 98 | echo ":arm64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-aarch64-static:OC" > /proc/sys/fs/binfmt_misc/register 99 | echo "copy $qemu_static to $rootfs_mount_point/usr/bin/" 100 | cp $qemu_static $rootfs_mount_point/usr/bin/qemu-aarch64-static 101 | else 102 | echo "Could not configure binfmt for qemu!" && exit 1 103 | fi 104 | 105 | cp ./tools/alpine/init.sh $rootfs_mount_point/init.sh 106 | echo "chroot to alpine rootfs" 107 | chroot $rootfs_mount_point /init.sh 108 | rm -f $rootfs_mount_point/init.sh 109 | [ -n "$qemu" ] && rm -f $rootfs_mount_point/$qemu || rm -f $rootfs_mount_point/usr/bin/qemu-aarch64-static 110 | 111 | if [ -z "$TRAVIS" ]; then 112 | sed -i 's/https/http/' $rootfs_mount_point/etc/apk/repositories 113 | else 114 | sed -i 's#http://dl-cdn.alpinelinux.org#http://mirrors.tuna.tsinghua.edu.cn#' $rootfs_mount_point/etc/apk/repositories 115 | fi 116 | 117 | # add resize script 118 | cp ./tools/alpine/resizemmc.sh $rootfs_mount_point/sbin/resizemmc.sh 119 | cp ./tools/alpine/resizemmc $rootfs_mount_point/etc/init.d/resizemmc 120 | ln -sf /etc/init.d/resizemmc $rootfs_mount_point/etc/runlevels/default/resizemmc 121 | touch $rootfs_mount_point/root/.need_resize 122 | 123 | # generate img 124 | umount $rootfs_mount_point 125 | echo "copy boot header from armbian img" 126 | dd if=$armbian_img bs=512 count=$ROOTOFFSET status=none of=${output}/${img_new} 127 | cat $tmpdir/rootfs.img >> ${output}/${img_new} 128 | parted -s ${output}/${img_new} -- mklabel msdos 129 | parted -s ${output}/${img_new} -- mkpart primary ext4 ${ROOTOFFSET}s -1s 130 | sync 131 | rm -f $tmpdir/rootfs.img 132 | } 133 | 134 | func_release() { 135 | local dlpkg=$1 136 | local dtb=$2 137 | local rootfs=$3 138 | 139 | [ ! -f "$dlpkg" ] && echo "dlpkg not found!" && return 1 140 | rm -rf ${tmpdir} 141 | echo "Extract 7zpkg and checksum..." 142 | 7z x -y -o${tmpdir} $dlpkg >/dev/null && cd ${tmpdir} && sha256sum -c sha256sum.sha && cd - > /dev/null || exit 1 143 | 144 | armbian_img="$(ls ${tmpdir}/*.img)" 145 | echo "alpine rootfs: $rootfs" 146 | echo "armbian image file: $armbian_img" 147 | echo "dtb file: $dtb" 148 | 149 | imgname_new="`basename $rootfs | sed "s/${origin}/${target}/" | sed 's/.tar.gz$/.img/'`" 150 | 151 | func_generate $armbian_img $dtb $rootfs $imgname_new 152 | echo "new image file: $imgname_new" 153 | 154 | if [ -n "$TRAVIS_TAG" ]; then 155 | xz -f -T0 -v ${output}/${imgname_new} 156 | fi 157 | rm -rf ${tmpdir} 158 | } 159 | 160 | case "$1" in 161 | generate) 162 | func_generate "$2" "$3" "$4" 163 | ;; 164 | release) 165 | func_release "$2" "$3" "$4" 166 | ;; 167 | *) 168 | echo "Usage: $0 { generate [armbian-img] [dtb] [rootfs] | release [armbian-7zpkg] [dtb] [rootfs] }" 169 | exit 1 170 | ;; 171 | esac 172 | -------------------------------------------------------------------------------- /build-archlinux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # requirements: sudo jq sfdisk u-boot-tools qemu bimfmt_misc parted bsdtar 3 | # require armbian kernel and u-boot 4 | 5 | # run following command to init pacman keyring: 6 | # pacman-key --init 7 | # pacman-key --populate archlinuxarm 8 | 9 | [ "$EUID" != "0" ] && echo "please run as root" && exit 1 10 | 11 | armbian_mount_point="/mnt/armbian_rootfs" 12 | rootfs_mount_point="/mnt/arch_rootfs" 13 | 14 | tmpdir="tmp" 15 | output="output" 16 | 17 | origin="latest" 18 | target="beikeyun-$(date +%Y-%m-%d)" 19 | 20 | rootsize=1500 21 | ROOTOFFSET=32768 22 | 23 | qemu_static="./tools/qemu/qemu-aarch64-static" 24 | 25 | func_umount_armbian() { 26 | umount $armbian_mount_point 27 | } 28 | 29 | func_mount_armbian() { 30 | local img=$1 31 | local mount_point=$2 32 | [ ! -f "$img" ] && echo "img file not found!" && return 1 33 | start=$(sfdisk -J $img | jq .partitiontable.partitions[0].start) 34 | offset=$((start * 512)) 35 | mkdir -p $mount_point 36 | mount -o loop,offset=$offset $1 $mount_point 37 | } 38 | 39 | func_generate() { 40 | local armbian_img=$1 41 | local dtb=$2 42 | local rootfs=$3 43 | local img_new=${4:-archlinux.img} 44 | 45 | [ ! -f "$dtb" ] && echo "dtb file not found!" && return 1 46 | [ ! -f "$rootfs" ] && echo "archlinux rootfs file not found!" && return 1 47 | [ ! -f "$armbian_img" ] && echo "armbian img file not found!" && return 1 48 | 49 | # create ext4 rootfs img 50 | mkdir -p ${tmpdir} 51 | echo "create ext4 rootfs, size: ${rootsize}M" 52 | dd if=/dev/zero bs=1M status=none count=$rootsize of=$tmpdir/rootfs.img 53 | mkfs.ext4 -q -m 2 $tmpdir/rootfs.img 54 | 55 | # mount rootfs 56 | mkdir -p $rootfs_mount_point 57 | mount -o loop $tmpdir/rootfs.img $rootfs_mount_point 58 | 59 | # extract archlinux rootfs 60 | echo "extract archlinux rootfs($rootfs) to $rootfs_mount_point" 61 | bsdtar -xpf $rootfs -C $rootfs_mount_point 62 | 63 | # chroot to archlinux rootfs 64 | echo "configure binfmt to chroot" 65 | modprobe binfmt_misc 66 | if [ -e /proc/sys/fs/binfmt_misc/register ]; then 67 | echo -1 > /proc/sys/fs/binfmt_misc/status 68 | echo ":arm64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-aarch64-static:OC" > /proc/sys/fs/binfmt_misc/register 69 | echo "copy $qemu_static to $rootfs_mount_point/usr/bin/" 70 | cp $qemu_static $rootfs_mount_point/usr/bin/qemu-aarch64-static 71 | else 72 | echo "Could not configure binfmt for qemu!" && exit 1 73 | fi 74 | 75 | cp ./tools/archlinux/init.sh $rootfs_mount_point/init.sh 76 | echo "chroot to archlinux rootfs" 77 | LANG=C LC_ALL=C chroot $rootfs_mount_point /init.sh 78 | 79 | rm -f $rootfs_mount_point/init.sh 80 | [ -n "$qemu" ] && rm -f $rootfs_mount_point/$qemu || rm -f $rootfs_mount_point/usr/bin/qemu-aarch64-static 81 | 82 | # mount armbian rootfs 83 | func_mount_armbian $armbian_img $armbian_mount_point 84 | 85 | # get /boot /lib/modules /lib/firmware 86 | echo "copy /boot,/lib/modules,/lib/firmware from armbian" 87 | rm -rf $rootfs_mount_point/boot && cp -rf $armbian_mount_point/boot $rootfs_mount_point/boot 88 | rm -rf $rootfs_mount_point/lib/modules && cp -rf $armbian_mount_point/lib/modules $rootfs_mount_point/lib/modules 89 | rm -rf $rootfs_mount_point/lib/firmware && cp -rf $armbian_mount_point/lib/firmware $rootfs_mount_point/lib/firmware 90 | 91 | #umount armbian rootfs 92 | func_umount_armbian 93 | 94 | # patch /boot 95 | echo "patch /boot" 96 | cp -f $dtb $rootfs_mount_point/boot/ 97 | sed -i '/^verbosity/cverbosity=7' $rootfs_mount_point/boot/armbianEnv.txt 98 | sed -i '/^rootdev/crootdev=\/dev\/mmcblk0p1' $rootfs_mount_point/boot/armbianEnv.txt 99 | if [ -z "`grep fdtfile $rootfs_mount_point/boot/armbianEnv.txt`" ]; then 100 | echo "fdtfile=$(basename $dtb)" >> $rootfs_mount_point/boot/armbianEnv.txt 101 | fi 102 | if [ -z "`grep extraargs $rootfs_mount_point/boot/armbianEnv.txt`" ]; then 103 | echo "extraargs=rw console=ttyFIQ0,1500000 audit=0" >> $rootfs_mount_point/boot/armbianEnv.txt 104 | fi 105 | sed -i 's#${prefix}dtb/${fdtfile}#${prefix}/${fdtfile}#' $rootfs_mount_point/boot/boot.cmd 106 | mkimage -C none -T script -d $rootfs_mount_point/boot/boot.cmd $rootfs_mount_point/boot/boot.scr 107 | 108 | # add resize script 109 | echo "add resize mmc script" 110 | cp ./tools/archlinux/resizemmc.service $rootfs_mount_point/lib/systemd/system/ 111 | cp ./tools/archlinux/resizemmc.sh $rootfs_mount_point/sbin/ 112 | mkdir -p $rootfs_mount_point/etc/systemd/system/basic.target.wants 113 | ln -sf /lib/systemd/system/resizemmc.service $rootfs_mount_point/etc/systemd/system/basic.target.wants/resizemmc.service 114 | touch $rootfs_mount_point/root/.need_resize 115 | 116 | # generate img 117 | umount $rootfs_mount_point 118 | echo "copy boot header from armbian img" 119 | dd if=$armbian_img bs=512 count=$ROOTOFFSET status=none of=${output}/${img_new} 120 | cat $tmpdir/rootfs.img >> ${output}/${img_new} 121 | parted -s ${output}/${img_new} -- mklabel msdos 122 | parted -s ${output}/${img_new} -- mkpart primary ext4 ${ROOTOFFSET}s -1s 123 | sync 124 | rm -f $tmpdir/rootfs.img 125 | } 126 | 127 | func_release() { 128 | local dlpkg=$1 129 | local dtb=$2 130 | local rootfs=$3 131 | 132 | [ ! -f "$dlpkg" ] && echo "dlpkg not found!" && return 1 133 | rm -rf ${tmpdir} 134 | echo "Extract 7zpkg and checksum..." 135 | 7z x -y -o${tmpdir} $dlpkg >/dev/null && cd ${tmpdir} && sha256sum -c sha256sum.sha && cd - > /dev/null || exit 1 136 | 137 | armbian_img="$(ls ${tmpdir}/*.img)" 138 | echo "archlinux rootfs: $rootfs" 139 | echo "armbian image file: $armbian_img" 140 | echo "dtb file: $dtb" 141 | 142 | imgname_new="`basename $rootfs | sed "s/${origin}/${target}/" | sed 's/.tar.gz$/.img/'`" 143 | 144 | func_generate $armbian_img $dtb $rootfs $imgname_new 145 | echo "new image file: $imgname_new" 146 | 147 | if [ -n "$TRAVIS_TAG" ]; then 148 | xz -f -T0 -v ${output}/${imgname_new} 149 | fi 150 | rm -rf ${tmpdir} 151 | } 152 | 153 | case "$1" in 154 | generate) 155 | func_generate "$2" "$3" "$4" 156 | ;; 157 | release) 158 | func_release "$2" "$3" "$4" 159 | ;; 160 | *) 161 | echo "Usage: $0 { generate [armbian-img] [dtb] [rootfs] | release [armbian-7zpkg] [dtb] [rootfs] }" 162 | exit 1 163 | ;; 164 | esac 165 | -------------------------------------------------------------------------------- /build-armbian.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # requirements: sudo jq sfdisk u-boot-tools 3 | 4 | [ "$EUID" != "0" ] && echo "please run as root" && exit 1 5 | 6 | mount_point="/mnt/tmp" 7 | tmpdir="tmp" 8 | output="output" 9 | 10 | origin="Rock64" 11 | target="beikeyun" 12 | 13 | func_umount() { 14 | umount $mount_point 15 | } 16 | 17 | func_mount() { 18 | local img=$1 19 | [ ! -f "$img" ] && echo "img file not found!" && return 1 20 | mkdir -p $mount_point 21 | start=$(sfdisk -J $img | jq .partitiontable.partitions[0].start) 22 | offset=$((start * 512)) 23 | mount -o loop,offset=$offset $1 $mount_point 24 | } 25 | 26 | func_modify() { 27 | local dtb=$1 28 | [ ! -f "$dtb" ] && echo "dtb file not found!" && return 1 29 | 30 | # patch /boot 31 | echo "patch /boot" 32 | cp -f $dtb $mount_point/boot/ 33 | sed -i '/^verbosity/cverbosity=7' $mount_point/boot/armbianEnv.txt 34 | if [ -z "`grep fdtfile $mount_point/boot/armbianEnv.txt`" ]; then 35 | echo "fdtfile=$(basename $dtb)" >> $mount_point/boot/armbianEnv.txt 36 | fi 37 | sed -i 's#${prefix}dtb/${fdtfile}#${prefix}/${fdtfile}#' $mount_point/boot/boot.cmd 38 | mkimage -C none -T script -d $mount_point/boot/boot.cmd $mount_point/boot/boot.scr 39 | 40 | # patch rootfs 41 | echo "patch rootfs" 42 | sed -i 's#http://ports.ubuntu.com#https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports#' $mount_point/etc/apt/sources.list 43 | sed -i 's#http://httpredir.debian.org#https://mirrors.tuna.tsinghua.edu.cn#' $mount_point/etc/apt/sources.list 44 | sed -i 's#http://security.debian.org#https://mirrors.tuna.tsinghua.edu.cn/debian-security#' $mount_point/etc/apt/sources.list 45 | sed -i 's#http://apt.armbian.com#https://mirrors.tuna.tsinghua.edu.cn/armbian#' $mount_point/etc/apt/sources.list.d/armbian.list 46 | 47 | sed -i 's/ENABLED=true/#ENABLED=true/' $mount_point/etc/default/armbian-zram-config 48 | sed -i 's/ENABLED=true/#ENABLED=true/' $mount_point/etc/default/armbian-ramlog 49 | 50 | rm -f $mount_point/etc/systemd/system/getty.target.wants/serial-getty\@ttyS2.service 51 | ln -sf /usr/share/zoneinfo/Asia/Shanghai $mount_point/etc/localtime 52 | 53 | sync 54 | } 55 | 56 | func_release() { 57 | local dlpkg=$1 58 | [ ! -f "$dlpkg" ] && echo "dlpkg not found!" && return 1 59 | rm -rf ${tmpdir} 60 | echo "Extract 7zpkg and checksum..." 61 | 7z x -y -o${tmpdir} $dlpkg >/dev/null && cd ${tmpdir} && sha256sum -c sha256sum.sha && cd - > /dev/null || exit 1 62 | 63 | local dtb=$2 64 | imgfile="$(ls ${tmpdir}/*.img)" 65 | echo "origin image file: $imgfile" 66 | echo "dtb file: $dtb" 67 | func_mount $imgfile && func_modify $dtb && func_umount 68 | 69 | imgname_new=`basename $imgfile | sed "s/${origin}/${target}/"` 70 | echo "new image file: $imgname_new" 71 | 72 | mv $imgfile ${output}/${imgname_new} 73 | if [ -n "$TRAVIS_TAG" ]; then 74 | xz -f -T0 -v ${output}/${imgname_new} 75 | fi 76 | rm -rf ${tmpdir} 77 | } 78 | 79 | case "$1" in 80 | umount) 81 | func_umount 82 | ;; 83 | mount) 84 | func_mount "$2" 85 | ;; 86 | modify) 87 | func_mount "$2" && func_modify "$3" && func_umount 88 | ;; 89 | release) 90 | func_release "$2" "$3" 91 | ;; 92 | *) 93 | echo "Usage: $0 { mount | umount [img] | modify [img] [dtb] | release [7zpkg] [dtb] }" 94 | exit 1 95 | ;; 96 | esac 97 | -------------------------------------------------------------------------------- /build-lakka.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # requirements: sfdisk mtools jq axel 3 | 4 | TMPDIR="tmp" 5 | origin="ROCK64" 6 | target="beikeyun" 7 | output="output" 8 | 9 | func_modify() { 10 | local DISK="$1" 11 | local DTB="$2" 12 | local IDB="$3" 13 | local UBOOT="$4" 14 | [ ! -f "$DISK" -o ! -f "$DTB" ] && echo "file not found!" && exit 1 15 | 16 | # get offset of 1st partition 17 | SYSTEM_PART_START=$(sfdisk -J ${DISK} |jq .partitiontable.partitions[0].start) 18 | OFFSET=$(( ${SYSTEM_PART_START} * 512 )) 19 | 20 | echo "SYSTEM_PART_START: $SYSTEM_PART_START" 21 | echo "OFFSET: $OFFSET" 22 | mkdir -p ${TMPDIR} 23 | 24 | # patch extlinux.conf 25 | mcopy -no -i ${DISK}@@${OFFSET} ::/extlinux/extlinux.conf ./${TMPDIR} || { echo "extlinux.conf dump failed!"; exit 1; } 26 | sed -i "/^ fdt/c\ \ \ \ fdt \/$(basename ${DTB})" ./${TMPDIR}/extlinux.conf 27 | sed -i '/^ append/s/quiet//' ./${TMPDIR}/extlinux.conf 28 | if [ -z "`grep panic ./${TMPDIR}/extlinux.conf`" ]; then 29 | sed -i '/^ append/s/$/ panic=10/' ./${TMPDIR}/extlinux.conf 30 | fi 31 | 32 | echo "extlinux.conf:" 33 | echo "#################" 34 | cat ./${TMPDIR}/extlinux.conf 35 | echo "#################" 36 | mcopy -no -i ${DISK}@@${OFFSET} ./${TMPDIR}/extlinux.conf ::/extlinux/extlinux.conf && \ 37 | echo "extlinux.conf patched!" || { echo "extlinux.conf patch failed!"; exit 1; } 38 | 39 | # copy dtb 40 | mcopy -no -i ${DISK}@@${OFFSET} ${DTB} ::/ && echo "dtb patched: ${DTB}" || { echo "dtb patch failed!"; exit 1; } 41 | 42 | # replace u-boot and idbloader from libreelec 43 | dd if=${IDB} of=${DISK} seek=64 bs=512 conv=notrunc status=none && echo "idb patched: ${IDB}" || { echo "idb patch failed!"; exit 1; } 44 | dd if=${UBOOT} of=${DISK} seek=16384 bs=512 conv=notrunc status=none && echo "u-boot patched: ${UBOOT}" || { echo "u-boot patch failed!"; exit 1; } 45 | sync 46 | rm -rf ${TMPDIR} 47 | } 48 | 49 | func_release() { 50 | local PKG="$1" 51 | local DTB="$2" 52 | local IDB="$3" 53 | local UBOOT="$4" 54 | [ ! -f "$PKG" -o ! -f "$DTB" ] && echo "file not found!" && exit 1 55 | IMG="$(sed 's/.gz//' <<< $PKG)" 56 | gzip -d -k "$PKG" 57 | func_modify $IMG $DTB $IDB $UBOOT 58 | IMG_NEW=$(basename $IMG |sed "s/${origin}/${target}/") 59 | echo "IMG_NEW: $IMG_NEW" 60 | mv $IMG $output/$IMG_NEW 61 | if [ -n "$TRAVIS_TAG" ]; then 62 | xz -f -T0 -v $output/$IMG_NEW 63 | fi 64 | } 65 | 66 | case "$1" in 67 | modify) 68 | func_modify "$2" "$3" "$4" "$5" 69 | ;; 70 | release) 71 | func_release "$2" "$3" "$4" "$5" 72 | ;; 73 | *) 74 | echo "Usage: $0 { modify [img] [dtb] [idb] [u-boot] | release [archive] [dtb] [idb] [u-boot] }" 75 | exit 1 76 | ;; 77 | esac 78 | -------------------------------------------------------------------------------- /build-libreelec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # requirements: sfdisk mtools jq squashfs-tools 3 | 4 | TMPDIR="tmp" 5 | origin="rock64" 6 | target="beikeyun" 7 | output="output" 8 | 9 | func_modify() { 10 | local DISK="$1" 11 | local DTB="$2" 12 | [ ! -f "$DISK" -o ! -f "$DTB" ] && echo "file not found!" && exit 1 13 | 14 | # get offset of 1st partition 15 | SYSTEM_PART_START=$(sfdisk -J ${DISK} |jq .partitiontable.partitions[0].start) 16 | OFFSET=$(( ${SYSTEM_PART_START} * 512 )) 17 | 18 | echo "SYSTEM_PART_START: $SYSTEM_PART_START" 19 | echo "OFFSET: $OFFSET" 20 | mkdir -p ${TMPDIR} 21 | 22 | # patch extlinux.conf 23 | mcopy -no -i ${DISK}@@${OFFSET} ::/extlinux/extlinux.conf ./${TMPDIR} || { echo "extlinux.conf dump failed!"; exit 1; } 24 | sed -i "/^ FDT/c\ \ FDT \/$(basename ${DTB})" ./${TMPDIR}/extlinux.conf 25 | sed -i '/^ APPEND/s/quiet//' ./${TMPDIR}/extlinux.conf 26 | if [ -z "`grep panic ./${TMPDIR}/extlinux.conf`" ]; then 27 | sed -i '/^ APPEND/s/$/ panic=10/' ./${TMPDIR}/extlinux.conf 28 | fi 29 | 30 | echo "extlinux.conf:" 31 | echo "#################" 32 | cat ./${TMPDIR}/extlinux.conf 33 | echo "#################" 34 | mcopy -no -i ${DISK}@@${OFFSET} ./${TMPDIR}/extlinux.conf ::/extlinux/extlinux.conf && \ 35 | echo "extlinux.conf patched!" || { echo "extlinux.conf patch failed!"; exit 1; } 36 | 37 | # copy dtb 38 | mcopy -no -i ${DISK}@@${OFFSET} ${DTB} ::/ && echo "dtb patched: ${DTB}" || { echo "dtb patch failed!"; exit 1; } 39 | 40 | # add /opt to SYSTEM.squashfs for entware 41 | mcopy -no -i ${DISK}@@${OFFSET} ::/SYSTEM ./${TMPDIR} || { echo "SYSTEM.squashfs dump failed!"; exit 1; } 42 | mkdir -p ./${TMPDIR}/new/opt && mksquashfs ./${TMPDIR}/new ./${TMPDIR}/SYSTEM -all-root -no-progress 43 | # recalc md5sum 44 | md5sum ${TMPDIR}/SYSTEM | sed "s#${TMPDIR}/SYSTEM#target/SYSTEM#" > ${TMPDIR}/SYSTEM.md5 45 | mcopy -no -i ${DISK}@@${OFFSET} ./${TMPDIR}/SYSTEM ::/ 46 | mcopy -no -i ${DISK}@@${OFFSET} ./${TMPDIR}/SYSTEM.md5 ::/ 47 | echo "SYSTEM.squashfs patched!" 48 | 49 | sync 50 | rm -rf ${TMPDIR} 51 | } 52 | 53 | func_release() { 54 | local PKG="$1" 55 | local DTB="$2" 56 | [ ! -f "$PKG" -o ! -f "$DTB" ] && echo "file not found!" && exit 1 57 | IMG="$(sed 's/.gz//' <<< $PKG)" 58 | gzip -d -k "$PKG" 59 | func_modify $IMG $DTB 60 | IMG_NEW=$(basename $IMG |sed "s/${origin}/${target}/") 61 | echo "IMG_NEW: $IMG_NEW" 62 | mv $IMG $output/$IMG_NEW 63 | if [ -n "$TRAVIS_TAG" ]; then 64 | xz -f -T0 -v $output/$IMG_NEW 65 | fi 66 | } 67 | 68 | case "$1" in 69 | modify) 70 | func_modify "$2" "$3" 71 | ;; 72 | release) 73 | func_release "$2" "$3" 74 | ;; 75 | *) 76 | echo "Usage: $0 { modify [img] [dtb] | release [archive] [dtb] }" 77 | exit 1 78 | ;; 79 | esac 80 | -------------------------------------------------------------------------------- /dtbs/4.4-bsp/box/rk3328-beikeyun.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanwckf/build-beikeyun/332d1d999eb24dc8b5c62e6998133db3e45705ec/dtbs/4.4-bsp/box/rk3328-beikeyun.dtb -------------------------------------------------------------------------------- /dtbs/4.4-bsp/headless/rk3328-beikeyun.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanwckf/build-beikeyun/332d1d999eb24dc8b5c62e6998133db3e45705ec/dtbs/4.4-bsp/headless/rk3328-beikeyun.dtb -------------------------------------------------------------------------------- /flash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | [ -z "$1" ] && echo "please specify img" && exit 1 4 | [ ! -f "$1" ] && echo "img not found!" && exit 1 5 | 6 | rkdeveloptool db loader/rk3328_loader_v1.14.249.bin && \ 7 | sleep 1 && rkdeveloptool wl 0x0 $1 && \ 8 | sleep 1 && rkdeveloptool rd 9 | -------------------------------------------------------------------------------- /input/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /loader/armbian-5.75/idbloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanwckf/build-beikeyun/332d1d999eb24dc8b5c62e6998133db3e45705ec/loader/armbian-5.75/idbloader.bin -------------------------------------------------------------------------------- /loader/armbian-5.75/trust.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanwckf/build-beikeyun/332d1d999eb24dc8b5c62e6998133db3e45705ec/loader/armbian-5.75/trust.bin -------------------------------------------------------------------------------- /loader/armbian-5.75/uboot.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanwckf/build-beikeyun/332d1d999eb24dc8b5c62e6998133db3e45705ec/loader/armbian-5.75/uboot.img -------------------------------------------------------------------------------- /loader/libreelec/u-boot.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanwckf/build-beikeyun/332d1d999eb24dc8b5c62e6998133db3e45705ec/loader/libreelec/u-boot.bin -------------------------------------------------------------------------------- /loader/rk3328_loader_v1.14.249.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanwckf/build-beikeyun/332d1d999eb24dc8b5c62e6998133db3e45705ec/loader/rk3328_loader_v1.14.249.bin -------------------------------------------------------------------------------- /output/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tools/alpine/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export PATH=/usr/sbin:/usr/bin:/bin:/sbin 4 | 5 | add_svc(){ 6 | runlevel="$1" 7 | svcs="$2" 8 | for svc in ${svcs}; do 9 | if [ -f ./etc/init.d/${svc} ]; then 10 | ln -sf /etc/init.d/${svc} ./etc/runlevels/${runlevel}/${svc} 11 | fi 12 | done 13 | } 14 | 15 | apk update --no-progress && \ 16 | apk add --no-progress alpine-base haveged dropbear parted e2fsprogs-extra dropbear-scp tzdata 17 | 18 | echo "root:admin" | chpasswd 19 | 20 | add_svc "boot" "networking urandom swclock sysctl modules" 21 | 22 | add_svc "default" "crond dropbear haveged ntpd" 23 | 24 | add_svc "shutdown" "killprocs mount-ro savecache" 25 | 26 | sed -i '/^tty[2-6]/d' ./etc/inittab 27 | 28 | [ -z "`grep ttyFIQ0 ./etc/inittab`" ] && echo "ttyFIQ0::respawn:/sbin/getty -L ttyFIQ0 1500000 vt100" >> ./etc/inittab 29 | [ -z "`grep ttyFIQ0 ./etc/securetty`" ] && echo "ttyFIQ0" >> ./etc/securetty 30 | 31 | sed -i 's/pool.ntp.org/time1.aliyun.com/' ./etc/conf.d/ntpd 32 | ln -sf /usr/share/zoneinfo/Asia/Shanghai ./etc/localtime 33 | 34 | echo "alpine" > ./etc/hostname 35 | 36 | cat > ./etc/network/interfaces < ./etc/sysctl.d/01-random.conf 47 | -------------------------------------------------------------------------------- /tools/alpine/resizemmc: -------------------------------------------------------------------------------- 1 | #!/sbin/openrc-run 2 | 3 | description="Resize rootfs partition." 4 | 5 | start() { 6 | if [ -e /root/.need_resize ] ; then 7 | ebegin "Resize rootfs, please reboot after finish" 8 | /sbin/resizemmc.sh > /dev/null 2>&1 9 | eend $? 10 | rm -f /root/.need_resize 11 | fi 12 | } 13 | -------------------------------------------------------------------------------- /tools/alpine/resizemmc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | parted /dev/mmcblk0 resizepart 1 Yes 100% && resize2fs /dev/mmcblk0p1 && echo "resize done, please reboot" || echo "resize failed!" 4 | -------------------------------------------------------------------------------- /tools/archlinux/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export PATH=/usr/sbin:/usr/bin:/bin:/sbin 4 | 5 | # remove kernel packages 6 | pacman -Rn --noconfirm linux-aarch64 linux-firmware 7 | 8 | # set securetty 9 | [ -z "`grep ttyFIQ0 ./etc/securetty`" ] && echo "ttyFIQ0" >> ./etc/securetty 10 | 11 | # set /etc/fstab 12 | [ -z "`grep mmcblk0p1 ./etc/fstab`" ] && echo "/dev/mmcblk0p1 / ext4 defaults,noatime,nodiratime,errors=remount-ro 0 1" >> ./etc/fstab 13 | 14 | # set ntp server 15 | sed -i '/^#NTP/cNTP=time1.aliyun.com 2001:470:0:50::2' ./etc/systemd/timesyncd.conf 16 | 17 | # set sshd_config to allow root login 18 | sed -i '/^#PermitRootLogin/cPermitRootLogin yes' ./etc/ssh/sshd_config 19 | 20 | # set locale 21 | echo 'en_US.UTF8 UTF-8' > ./etc/locale.gen 22 | locale-gen 23 | echo 'LANG=en_US.utf8' > ./etc/locale.conf 24 | echo 'KEYMAP=us' > ./etc/vconsole.conf 25 | ln -sf ../usr/share/zoneinfo/Asia/Shanghai ./etc/localtime 26 | 27 | # change mirrors 28 | echo 'Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxarm/$arch/$repo' > ./etc/pacman.d/mirrorlist 29 | 30 | echo "root:admin" |chpasswd 31 | 32 | # clean 33 | pacman -Sc --noconfirm 34 | rm -rf ./var/log/journal 35 | rm -rf ./lib/modules ./lib/firmware ./boot 36 | 37 | -------------------------------------------------------------------------------- /tools/archlinux/resizemmc.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=filesystem resize 3 | Before=basic.target 4 | After=sysinit.target local-fs.target 5 | DefaultDependencies=no 6 | 7 | [Service] 8 | Type=oneshot 9 | RemainAfterExit=yes 10 | ExecStart=/sbin/resizemmc.sh 11 | TimeoutStartSec=1min 12 | 13 | [Install] 14 | WantedBy=basic.target 15 | -------------------------------------------------------------------------------- /tools/archlinux/resizemmc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -e /root/.need_resize ]; then 4 | echo "d 5 | n 6 | p 7 | 1 8 | 32768 9 | -0 10 | w" | fdisk /dev/mmcblk0 && resize2fs /dev/mmcblk0p1 && echo "resize done, please reboot" || echo "resize failed!" 11 | rm -f /root/.need_resize 12 | fi 13 | -------------------------------------------------------------------------------- /tools/qemu/qemu-aarch64-static: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanwckf/build-beikeyun/332d1d999eb24dc8b5c62e6998133db3e45705ec/tools/qemu/qemu-aarch64-static --------------------------------------------------------------------------------