Skip to content

Commit

Permalink
test arch kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
sehraf committed May 11, 2024
1 parent 485539b commit 59f49e9
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 162 deletions.
300 changes: 150 additions & 150 deletions 1_compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,153 +87,153 @@ if [ ! -f "${OUT_DIR}/u-boot-sunxi-with-spl.bin" ]; then
cp ${DIR}/u-boot-sunxi-with-spl.bin "${OUT_DIR}"
fi

if [ ! -f "${OUT_DIR}/Image" ] || [ ! -f "${OUT_DIR}/Image.gz" ]; then
# build kernel
DIR='linux'
clean_dir ${DIR}
clean_dir ${DIR}-build
clean_dir ${DIR}-modules

curl -O -L ${SOURCE_KERNEL}
tar -xf "v${VERSION_KERNEL}.tar.gz"
rm "v${VERSION_KERNEL}.tar.gz"
mv linux-${VERSION_KERNEL} ${DIR}
cd ${DIR}

# fix kernel version
touch .scmversion

case "$KERNEL" in
'defconfig')
# generate default config
make ARCH="${ARCH}" O=../linux-build defconfig

# patch necessary options
# patch_config LOCALVERSION_AUTO n #### not necessary with a release kernel

# enable WiFi
patch_config CFG80211 m

# There is no LAN, so let there be USB-LAN
patch_config USB_NET_DRIVERS m
patch_config USB_CATC m
patch_config USB_KAWETH m
patch_config USB_PEGASUS m
patch_config USB_RTL8150 m
patch_config USB_RTL8152 m
patch_config USB_LAN78XX m
patch_config USB_USBNET m
patch_config USB_NET_AX8817X m
patch_config USB_NET_AX88179_178A m
patch_config USB_NET_CDCETHER m
patch_config USB_NET_CDC_EEM m
patch_config USB_NET_CDC_NCM m
patch_config USB_NET_HUAWEI_CDC_NCM m
patch_config USB_NET_CDC_MBIM m
patch_config USB_NET_DM9601 m
patch_config USB_NET_SR9700 m
patch_config USB_NET_SR9800 m
patch_config USB_NET_SMSC75XX m
patch_config USB_NET_SMSC95XX m
patch_config USB_NET_GL620A m
patch_config USB_NET_NET1080 m
patch_config USB_NET_PLUSB m
patch_config USB_NET_MCS7830 m
patch_config USB_NET_RNDIS_HOST m
patch_config USB_NET_CDC_SUBSET_ENABLE m
patch_config USB_NET_CDC_SUBSET m
patch_config USB_ALI_M5632 y
patch_config USB_AN2720 y
patch_config USB_BELKIN y
patch_config USB_ARMLINUX y
patch_config USB_EPSON2888 y
patch_config USB_KC2190 y
patch_config USB_NET_ZAURUS m
patch_config USB_NET_CX82310_ETH m
patch_config USB_NET_KALMIA m
patch_config USB_NET_QMI_WWAN m
patch_config USB_NET_INT51X1 m
patch_config USB_IPHETH m
patch_config USB_SIERRA_NET m
patch_config USB_VL600 m
patch_config USB_NET_CH9200 m
patch_config USB_NET_AQC111 m
patch_config USB_RTL8153_ECM m

# enable systemV IPC (needed by fakeroot during makepkg)
patch_config SYSVIPC y
patch_config SYSVIPC_SYSCTL y

# enable swap
patch_config SWAP y
patch_config ZSWAP y

# enable Cedrus VPU Drivers
patch_config MEDIA_SUPPORT y
patch_config MEDIA_CONTROLLER y
patch_config MEDIA_CONTROLLER_REQUEST_API y
patch_config V4L_MEM2MEM_DRIVERS y
patch_config VIDEO_SUNXI_CEDRUS y

# enable binfmt_misc
patch_config BINFMT_MISC y

# debug options
if [ $DEBUG = 'y' ]; then
patch_config DEBUG_INFO y
fi

# default anything new
make ARCH="${ARCH}" O=../linux-build olddefconfig

;;

'arch')
# generate default config (and directory)
make ARCH="${ARCH}" O=../linux-build defconfig

# deploy Arch's confi
# TODO keep this up to date automatically somehow
cp ../../6.3.5-arch1.config ../linux-build/.config

# THIS DOESN'T WORK RIGHT NOW
# TODO

# default anything new
make ARCH="${ARCH}" O=../linux-build olddefconfig

;;

*)
echo "Unknown kernel option '$KERNEL'"
exit 1
;;
esac

# compile it!
cd ..
make CROSS_COMPILE="${CROSS_COMPILE}" ARCH="${ARCH}" -j "${NPROC}" -C ${DIR}-build

KERNEL_RELEASE=$(make ARCH="${ARCH}" -C ${DIR}-build -s kernelversion)
echo "compiled kernel version '$KERNEL_RELEASE'"

cp ${DIR}-build/arch/riscv/boot/Image.gz "${OUT_DIR}"
cp ${DIR}-build/arch/riscv/boot/Image "${OUT_DIR}"

# prepare modules
mkdir ${DIR}-modules
make ARCH="${ARCH}" INSTALL_MOD_PATH="../${DIR}-modules" KERNELRELEASE="${KERNEL_RELEASE}" -C ${DIR}-build modules_install
mv ${DIR}-modules/lib/modules "${OUT_DIR}"
fi

if [ ! -f "${OUT_DIR}/8723ds.ko" ]; then
# build WiFi driver
DIR='rtl8723ds'
clean_dir ${DIR}

git clone "${SOURCE_RTL8723}"
cd ${DIR}
make CROSS_COMPILE="${CROSS_COMPILE}" ARCH="${ARCH}" KSRC=../linux-build -j "${NPROC}" modules || true
cd ..
cp ${DIR}/8723ds.ko "${OUT_DIR}"
fi
# if [ ! -f "${OUT_DIR}/Image" ] || [ ! -f "${OUT_DIR}/Image.gz" ]; then
# # build kernel
# DIR='linux'
# clean_dir ${DIR}
# clean_dir ${DIR}-build
# clean_dir ${DIR}-modules

# curl -O -L ${SOURCE_KERNEL}
# tar -xf "v${VERSION_KERNEL}.tar.gz"
# rm "v${VERSION_KERNEL}.tar.gz"
# mv linux-${VERSION_KERNEL} ${DIR}
# cd ${DIR}

# # fix kernel version
# touch .scmversion

# case "$KERNEL" in
# 'defconfig')
# # generate default config
# make ARCH="${ARCH}" O=../linux-build defconfig

# # patch necessary options
# # patch_config LOCALVERSION_AUTO n #### not necessary with a release kernel

# # enable WiFi
# patch_config CFG80211 m

# # There is no LAN, so let there be USB-LAN
# patch_config USB_NET_DRIVERS m
# patch_config USB_CATC m
# patch_config USB_KAWETH m
# patch_config USB_PEGASUS m
# patch_config USB_RTL8150 m
# patch_config USB_RTL8152 m
# patch_config USB_LAN78XX m
# patch_config USB_USBNET m
# patch_config USB_NET_AX8817X m
# patch_config USB_NET_AX88179_178A m
# patch_config USB_NET_CDCETHER m
# patch_config USB_NET_CDC_EEM m
# patch_config USB_NET_CDC_NCM m
# patch_config USB_NET_HUAWEI_CDC_NCM m
# patch_config USB_NET_CDC_MBIM m
# patch_config USB_NET_DM9601 m
# patch_config USB_NET_SR9700 m
# patch_config USB_NET_SR9800 m
# patch_config USB_NET_SMSC75XX m
# patch_config USB_NET_SMSC95XX m
# patch_config USB_NET_GL620A m
# patch_config USB_NET_NET1080 m
# patch_config USB_NET_PLUSB m
# patch_config USB_NET_MCS7830 m
# patch_config USB_NET_RNDIS_HOST m
# patch_config USB_NET_CDC_SUBSET_ENABLE m
# patch_config USB_NET_CDC_SUBSET m
# patch_config USB_ALI_M5632 y
# patch_config USB_AN2720 y
# patch_config USB_BELKIN y
# patch_config USB_ARMLINUX y
# patch_config USB_EPSON2888 y
# patch_config USB_KC2190 y
# patch_config USB_NET_ZAURUS m
# patch_config USB_NET_CX82310_ETH m
# patch_config USB_NET_KALMIA m
# patch_config USB_NET_QMI_WWAN m
# patch_config USB_NET_INT51X1 m
# patch_config USB_IPHETH m
# patch_config USB_SIERRA_NET m
# patch_config USB_VL600 m
# patch_config USB_NET_CH9200 m
# patch_config USB_NET_AQC111 m
# patch_config USB_RTL8153_ECM m

# # enable systemV IPC (needed by fakeroot during makepkg)
# patch_config SYSVIPC y
# patch_config SYSVIPC_SYSCTL y

# # enable swap
# patch_config SWAP y
# patch_config ZSWAP y

# # enable Cedrus VPU Drivers
# patch_config MEDIA_SUPPORT y
# patch_config MEDIA_CONTROLLER y
# patch_config MEDIA_CONTROLLER_REQUEST_API y
# patch_config V4L_MEM2MEM_DRIVERS y
# patch_config VIDEO_SUNXI_CEDRUS y

# # enable binfmt_misc
# patch_config BINFMT_MISC y

# # debug options
# if [ $DEBUG = 'y' ]; then
# patch_config DEBUG_INFO y
# fi

# # default anything new
# make ARCH="${ARCH}" O=../linux-build olddefconfig

# ;;

# 'arch')
# # generate default config (and directory)
# make ARCH="${ARCH}" O=../linux-build defconfig

# # deploy Arch's confi
# # TODO keep this up to date automatically somehow
# cp ../../6.3.5-arch1.config ../linux-build/.config

# # THIS DOESN'T WORK RIGHT NOW
# # TODO

# # default anything new
# make ARCH="${ARCH}" O=../linux-build olddefconfig

# ;;

# *)
# echo "Unknown kernel option '$KERNEL'"
# exit 1
# ;;
# esac

# # compile it!
# cd ..
# make CROSS_COMPILE="${CROSS_COMPILE}" ARCH="${ARCH}" -j "${NPROC}" -C ${DIR}-build

# KERNEL_RELEASE=$(make ARCH="${ARCH}" -C ${DIR}-build -s kernelversion)
# echo "compiled kernel version '$KERNEL_RELEASE'"

# cp ${DIR}-build/arch/riscv/boot/Image.gz "${OUT_DIR}"
# cp ${DIR}-build/arch/riscv/boot/Image "${OUT_DIR}"

# # prepare modules
# mkdir ${DIR}-modules
# make ARCH="${ARCH}" INSTALL_MOD_PATH="../${DIR}-modules" KERNELRELEASE="${KERNEL_RELEASE}" -C ${DIR}-build modules_install
# mv ${DIR}-modules/lib/modules "${OUT_DIR}"
# fi

# if [ ! -f "${OUT_DIR}/8723ds.ko" ]; then
# # build WiFi driver
# DIR='rtl8723ds'
# clean_dir ${DIR}

# git clone "${SOURCE_RTL8723}"
# cd ${DIR}
# make CROSS_COMPILE="${CROSS_COMPILE}" ARCH="${ARCH}" KSRC=../linux-build -j "${NPROC}" modules || true
# cd ..
# cp ${DIR}/8723ds.ko "${OUT_DIR}"
# fi
28 changes: 19 additions & 9 deletions 2_create_sd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ check_root_fs
for FILE in 8723ds.ko u-boot-sunxi-with-spl.bin Image.gz Image; do
check_required_file "${OUT_DIR}/${FILE}"
done
# shellcheck disable=SC2043
for DIR in modules; do
check_required_folder "${OUT_DIR}/${DIR}"
done
Expand Down Expand Up @@ -86,18 +87,27 @@ ${SUDO} mount "${DEVICE}${PART_IDENTITYFIER}1" "${MNT}/boot"
${SUDO} tar -xv --zstd -f "${ROOT_FS}" -C "${MNT}"

# install kernel and modules
# KERNEL_RELEASE=$(make ARCH="${ARCH}" -s kernelversion -C build/linux-build)
KERNEL_RELEASE=$(ls output/modules)
${SUDO} cp "${OUT_DIR}/Image.gz" "${OUT_DIR}/Image" "${MNT}/boot/"
if [ "${USE_CHROOT}" != 0 ]; then
${SUDO} arch-chroot "${MNT}" pacman -Sy
${SUDO} arch-chroot "${MNT}" pacman -S linux
else
# # KERNEL_RELEASE=$(make ARCH="${ARCH}" -s kernelversion -C build/linux-build)
# KERNEL_RELEASE=$(ls output/modules)
# ${SUDO} cp "${OUT_DIR}/Image.gz" "${OUT_DIR}/Image" "${MNT}/boot/"

${SUDO} mkdir -p "${MNT}/lib/modules"
${SUDO} cp -a "${OUT_DIR}/modules/${KERNEL_RELEASE}" "${MNT}/lib/modules"
${SUDO} install -D -p -m 644 "${OUT_DIR}/8723ds.ko" "${MNT}/lib/modules/${KERNEL_RELEASE}/kernel/drivers/net/wireless/8723ds.ko"
# ${SUDO} mkdir -p "${MNT}/lib/modules"
# ${SUDO} cp -a "${OUT_DIR}/modules/${KERNEL_RELEASE}" "${MNT}/lib/modules"
# ${SUDO} install -D -p -m 644 "${OUT_DIR}/8723ds.ko" "${MNT}/lib/modules/${KERNEL_RELEASE}/kernel/drivers/net/wireless/8723ds.ko"

${SUDO} rm "${MNT}/lib/modules/${KERNEL_RELEASE}/build"
${SUDO} rm "${MNT}/lib/modules/${KERNEL_RELEASE}/source"
# ${SUDO} rm "${MNT}/lib/modules/${KERNEL_RELEASE}/build"
# ${SUDO} rm "${MNT}/lib/modules/${KERNEL_RELEASE}/source"

${SUDO} depmod -a -b "${MNT}" "${KERNEL_RELEASE}"
# ${SUDO} depmod -a -b "${MNT}" "${KERNEL_RELEASE}"

curl -O -L ${PKG_KERNEL}
# tar -zxvf <package>.tar.gz
${SUDO} pacman --arch 'riscv64' --sysroot "${MNT}" ${PKG_KERNEL_FILE}
fi
echo '8723ds' >>8723ds.conf
${SUDO} mv 8723ds.conf "${MNT}/etc/modules-load.d/"

Expand Down
10 changes: 7 additions & 3 deletions consts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ export USE_CHROOT=1
export BOOT_METHOD='extlinux'

export VERSION_OPENSBI='1.4'
export VERSION_KERNEL='6.8'
export VERSION_KERNEL='6.8.5'
export VERSION_KERNEL_ARCH="${VERSION_KERNEL}.arch1-1"

export PKG_KERNEL_FILE="linux-${VERSION_KERNEL_ARCH}-1-riscv64.pkg.tar.zst"
export PKG_KERNEL="https://riscv.mirror.pkgbuild.com/repo/core/${PKG_KERNEL_FILE}"

export SOURCE_OPENSBI="https://github.com/riscv-software-src/opensbi/releases/download/v${VERSION_OPENSBI}/opensbi-${VERSION_OPENSBI}-rv-bin.tar.xz"
export SOURCE_UBOOT='https://github.com/smaeul/u-boot'
export SOURCE_KERNEL="https://github.com/torvalds/linux/archive/refs/tags/v${VERSION_KERNEL}.tar.gz"
export SOURCE_RTL8723='https://github.com/lwfinger/rtl8723ds.git'
# export SOURCE_KERNEL="https://github.com/torvalds/linux/archive/refs/tags/v${VERSION_KERNEL}.tar.gz"
# export SOURCE_RTL8723='https://github.com/lwfinger/rtl8723ds.git'
# https://github.com/karabek/xradio

# pinned commits (no notice when things change)
Expand Down

0 comments on commit 59f49e9

Please sign in to comment.