代码拉取完成,页面将自动刷新
#!/bin/bash
source ./envsetup
#set -v
usage() {
echo "Usage:"
echo " [CONFIG=<config>] ./build_linux.sh [-h] [-d] [-c | -a | -m]"
echo " -h: display usage"
echo " -d: enable debug"
echo " -c: checkdtb"
echo " -a: make distclean"
echo " -m: make menuconfig"
}
while getopts ":hdcam" opt
do
case $opt in
h)
O_HELP=y
;;
d)
O_DEBUG=y
;;
c)
O_CHKDTB=y
;;
a)
O_MAKE_ALL=y
;;
m)
O_MAKE_MENUCFG=y
;;
?)
echo "there is unrecognized parameter."
usage
exit 1
;;
esac
done
#echo "O_HELP = $O_HELP"
#echo "O_DEBUG = $O_DEBUG"
#echo "O_CHKDTB = $O_CHKDTB"
#echo "O_MAKE_ALL = $O_MAKE_ALL"
#echo "O_MAKE_MENUCFG = $O_MAKE_MENUCFG"
if [ "$O_HELP" = "y" ]; then
usage
exit 0
fi
# default config
if [[ -z "${CONFIG}" ]]; then
CONFIG=defconfig
fi
if [[ ${CONFIG} = "defconfig" ]]; then
OUT=$WS_LINUX/out-linux
elif [[ ${CONFIG} = "defconfig 32-bit.config" ]]; then
OUT=$WS_LINUX/out-linux32
elif [[ ${CONFIG} = "sophgo_mango_normal_defconfig" ]]; then
OUT=$WS_LINUX/out-linuxboot
elif [[ ${CONFIG} = "sophgo_mango_ubuntu_defconfig" ]]; then
OUT=$WS_LINUX/out-ubuntu
fi
if [ "$O_DEBUG" = "y" ]; then
OUT=$OUT-debug
fi
export OUT
echo "======> CONFIG=$CONFIG"
echo "======> OUT=$OUT"
export ARCH=riscv
echo "======> ARCH=$ARCH"
#export CROSS_COMPILE=riscv64-linux-
export CROSS_COMPILE=riscv64-buildroot-linux-gnu-
#export CROSS_COMPILE=riscv64-unknown-linux-gnu-
echo "======> CROSS_COMPILE=$CROSS_COMPILE"
#exit
# FIXME: just to make code simple
# "-c" only take effective when CONFIG=defconfig, don't use it for other CONFIGs
if [ "$O_CHKDTB" == "y" ] && [ "$CONFIG" == "defconfig" ]; then
echo "======> Start checking dtb ......"
pushd $PATH_LINUX
rm -f $OUT/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dtb
make -j$(nproc) O=$OUT CHECK_DTBS=y W=1 sophgo/sg2042-milkv-pioneer.dtb
popd
exit
fi
if [ "$O_MAKE_MENUCFG" = "y" ]; then
echo "======> Start making menuconfig ......"
pushd $PATH_LINUX
make O=$OUT menuconfig
popd
exit
fi
echo "======> Start building ......"
pushd $PATH_LINUX
if [ "$O_MAKE_ALL" = "y" ]; then
echo "======> Cleanup for FULLY building ......"
rm -rf $OUT
mkdir $OUT
make O=$OUT $CONFIG
# ./scripts/config --file $OUT/.config -e DYNAMIC_DEBUG
# enable kernel debug, so we can get more info when dump_stack
# default comment out to make image size small, enable it when requierd
<< COMMENT
./scripts/config --file $OUT/.config -e CONFIG_DEBUG_INFO
./scripts/config --file $OUT/.config -d CONFIG_DEBUG_INFO_NONE
./scripts/config --file $OUT/.config -e CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
./scripts/config --file $OUT/.config -d CONFIG_DEBUG_INFO_REDUCED
./scripts/config --file $OUT/.config -e CONFIG_DEBUG_INFO_COMPRESSED_NONE
./scripts/config --file $OUT/.config -d CONFIG_DEBUG_INFO_COMPRESSED_ZLIB
./scripts/config --file $OUT/.config -d CONFIG_DEBUG_INFO_SPLIT
./scripts/config --file $OUT/.config -d CONFIG_DEBUG_INFO_BTF
./scripts/config --file $OUT/.config -e CONFIG_PAHOLE_HAS_SPLIT_BTF
./scripts/config --file $OUT/.config -e CONFIG_PAHOLE_HAS_LANG_EXCLUDE
./scripts/config --file $OUT/.config -d CONFIG_GDB_SCRIPTS
COMMENT
# for sdmmc
# MMC_SDHCI_OF_DWCMSHC already in defconfig
# NLS_ISO8859_1 is enabled as module in defconfig, enabled as built-in
./scripts/config --file $OUT/.config -e NLS_ISO8859_1
# for gpio
./scripts/config --file $OUT/.config -e CONFIG_GPIO_DWAPB
# for poweroff/reboot by command
./scripts/config --file $OUT/.config -e CONFIG_SENSORS_SG2042_MCU
if [ "$O_DEBUG" = "y" ]; then
echo "======> Adding DEBUG info ......"
./scripts/config --file $OUT/.config \
-d CONFIG_COMPILE_TEST \
-e CONFIG_DEBUG_KERNEL \
-e CONFIG_DEBUG_INFO \
-d CONFIG_DEBUG_INFO_NONE \
-e CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT \
-d CONFIG_DEBUG_INFO_REDUCED \
-e CONFIG_DEBUG_INFO_COMPRESSED_NONE \
-d CONFIG_DEBUG_INFO_COMPRESSED_ZLIB \
-d CONFIG_DEBUG_INFO_SPLIT \
-d CONFIG_DEBUG_INFO_BTF \
-d CONFIG_GDB_SCRIPTS
fi
fi
make -j$(nproc) O=$OUT W=1
if [[ ${CONFIG} = "sophgo_mango_ubuntu_defconfig" ]]; then
rm -rf $WS_LINUX/linux-*.deb
rm -rf $WS_LINUX/linux-*.changes
rm -rf $WS_LINUX/linux-*.buildinfo
make -j$(nproc) O=$OUT bindeb-pkg
fi
popd
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。