bsp/bootloader/build.sh | ●●●●● patch | view | raw | blame | history | |
bsp/bootloader/igkboard.json | ●●●●● patch | view | raw | blame | history | |
bsp/build.sh | ●●●●● patch | view | raw | blame | history | |
bsp/kernel/build.sh | ●●●●● patch | view | raw | blame | history | |
bsp/kernel/igkboard.json | ●●●●● patch | view | raw | blame | history | |
bsp/rootfs/build.sh | ●●●●● patch | view | raw | blame | history | |
bsp/rootfs/extra_apps.json | ●●●●● patch | view | raw | blame | history | |
bsp/rootfs/rootfs.json | ●●●●● patch | view | raw | blame | history | |
bsp/scripts/setup_env.sh | ●●●●● patch | view | raw | blame | history | |
bsp/tarball/build.sh | ●●●●● patch | view | raw | blame | history |
bsp/bootloader/build.sh
@@ -1,63 +1,39 @@ #!/bin/bash # This shell script used auto download bootloader source code and do cross compile PRJ_PATH=`pwd` PRJ_NAME=`basename ${PRJ_PATH}` # update by top build.sh BOARD=igkboard BSP_BRANCH=lf-5.10.52-2.1.0 CROSS_TOOL=/opt/buildroot/cortexA7/bin/arm-linux- TAR_PATH=${PRJ_PATH}/../tarball IMG_PATH=${PRJ_PATH}/../images/ source ../scripts/setup_env.sh UBOOT_SRC=uboot-imx IMG_NAME=u-boot-${BOARD}.imx PATCH_FILE=${PRJ_PATH}/patch/${UBOOT_SRC}-${BOARD}.patch CONF_FILE=configs/${BOARD}_defconfig JOBS=`cat /proc/cpuinfo | grep processor | wc -l` patch_file=$(eval echo `jq -r ".UBOOT_SRC.PATCH" $JSON_CONF`) arch=$(eval echo `jq -r ".CONFIG.ARCH" $JSON_CONF`) defconf=$(eval echo `jq -r ".CONFIG.DEFCONF" $JSON_CONF`) set -u set -e STAGE=0 function msg_banner() { STAGE=`expr $STAGE + 1` echo "" echo "+---------------------------------------------+" printf " Stage $STAGE: $1\n" echo "+---------------------------------------------+" echo "" } function do_fetch() { msg_banner "Fetch ${UBOOT_SRC} source code" if [ -d ${UBOOT_SRC} ] ; then printf "\n\n -- ${UBOOT_SRC} fetched already -- \n\n" if [ -d $UBOOT_SRC ] ; then pr_warn "$UBOOT_SRC fetched already." return 0; fi printf "\n -- decompress ${UBOOT_SRC}-${BSP_BRANCH}.tar.xz now ... -- \n\n" tar -xJf ${TAR_PATH}/${UBOOT_SRC}-${BSP_BRANCH}.tar.xz do_fetch_json $JSON_CONF UBOOT_SRC $UBOOT_SRC rm -rf *.tar* } function do_patch() { msg_banner "Patch for ${UBOOT_SRC} source code" cd ${UBOOT_SRC} if [ ! -s $CONF_FILE -a -s $PATCH_FILE ] ; then patch -p1 < $PATCH_FILE if [ ! -s configs/$defconf -a -s $patch_file ] ; then pr_warn "Patch for ${UBOOT_SRC} source code" patch -p1 < $patch_file fi printf "\n\nModify cross compiler in Makefile: $CROSS_TOOL\n\n" pr_warn "Modify cross compiler in Makefile: $CROSS_TOOL\n" sed -i -e "s|^CROSS_COMPILE=.*|CROSS_COMPILE?=${CROSS_TOOL}|g" Makefile cd ${PRJ_PATH} @@ -65,12 +41,13 @@ function do_build() { msg_banner "Build for ${UBOOT_SRC} source code" pr_warn "Build for ${UBOOT_SRC} source code" cd ${UBOOT_SRC} make ${BOARD}_defconfig make $defconf make -j ${JOBS} cp u-boot-dtb.imx ${IMG_NAME} chmod a+x ${IMG_NAME} @@ -80,20 +57,18 @@ function do_install() { msg_banner "Install $IMG_NAME" pr_warn "Install bootloader $IMG_NAME" cd ${UBOOT_SRC} mkdir -p ${IMG_PATH} cp ${IMG_NAME} ${IMG_PATH} cp ${IMG_NAME} /tftp do_install_json $JSON_CONF "INSTALL" cd ${PRJ_PATH} } function do_clean() { msg_banner "Clean ${UBOOT_SRC} source code" pr_warn "Clean ${UBOOT_SRC} source code" cd ${UBOOT_SRC} @@ -104,21 +79,23 @@ function gen_patch() { msg_banner "Clean ${UBOOT_SRC} source code" pr_warn "Clean ${UBOOT_SRC} source code" cd ${UBOOT_SRC} make savedefconfig mv defconfig ${CONF_FILE} mv defconfig configs/$defconf make distclean cd - mv ${UBOOT_SRC} ${UBOOT_SRC}-${BOARD} pr_warn "Fetch orignal source code" do_fetch msg_banner "Generate ${UBOOT_SRC} patch file" pr_warn "Generate ${UBOOT_SRC} patch file" set +e diff -Nuar ${UBOOT_SRC} ${UBOOT_SRC}-${BOARD} > ${UBOOT_SRC}-${BOARD}.patch diff -Nuar ${UBOOT_SRC} ${UBOOT_SRC}-${BOARD} > $patch_file rm -rf ${UBOOT_SRC} mv ${UBOOT_SRC}-${BOARD} ${UBOOT_SRC} @@ -128,7 +105,7 @@ { echo "" echo "Usage:" echo " $0 [-b] [p] [-c] [-h]" echo " $0 [-b] [-p] [-c] [-h]" echo " -b: download and build $PRJ_NAME" echo " -p: generate $PRJ_NAME patch file" echo " -c: clean the source code" @@ -154,6 +131,11 @@ exit; ;; "h") do_usage exit; ;; "*") do_usage exit; bsp/bootloader/igkboard.json
New file @@ -0,0 +1,14 @@ { "UBOOT_SRC": { "URL": "${SRC_URL}/uboot-imx-${BSP_VER}.tar.xz", "PROTOCAL": "wget", "PATCH": "${PRJ_PATH}/patch/uboot-imx-${BOARD}.patch" }, "CONFIG": { "ARCH":"arm", "DEFCONF":"${BOARD}_defconfig" }, "INSTALL": { "u-boot-${BOARD}.imx":"${PRJ_PATH}/../images/" } } bsp/build.sh
@@ -3,7 +3,6 @@ PRJ_PATH=`pwd` BOARD=igkboard BSP_BRANCH="lf-5.10.52-2.1.0" CROSS_TOOL=/opt/buildroot/cortexA7/bin/arm-linux- # SYSTEM should be: buildroot, yocto or debian @@ -13,38 +12,23 @@ DISTRO=2021.02 SYSTEM=`echo $SYSTEM | tr 'A-Z' 'a-z'` if [ $SYSTEM == "debian" ] ; then SYSNAME=${DISTRO} else SYSNAME=${SYSTEM} fi DISTRO=`echo $DISTRO | tr 'A-Z' 'a-z'` set -u set -e function do_modify_build() { DIR=$1 cd $PRJ_PATH sed -i "s|^BOARD.*|BOARD=${BOARD}|g" ${DIR}/build.sh sed -i "s|^BSP_BRANCH.*|BSP_BRANCH=${BSP_BRANCH}|g" ${DIR}/build.sh sed -i "s|^CROSS_TOOL.*|CROSS_TOOL=${CROSS_TOOL}|g" ${DIR}/build.sh sed -i "s|^SYSTEM=.*|SYSTEM=${SYSTEM}|g" ${DIR}/build.sh sed -i "s|^DISTRO=.*|DISTRO=${DISTRO}|g" ${DIR}/build.sh sed -i "s|^SYSNAME=.*|SYSNAME=${SYSNAME}|g" ${DIR}/build.sh } function do_modify() { do_modify_build tarball do_modify_build bootloader do_modify_build kernel do_modify_build drivers do_modify_build rootfs do_modify_build images cd $PRJ_PATH FILE=scripts/setup_env.sh sed -i "s|^BOARD.*|BOARD=${BOARD}|g" $FILE sed -i "s|^CROSS_TOOL.*|CROSS_TOOL=${CROSS_TOOL}|g" $FILE sed -i "s|^SYSTEM=.*|SYSTEM=${SYSTEM}|g" $FILE sed -i "s|^DISTRO=.*|DISTRO=${DISTRO}|g" $FILE } function do_root() @@ -66,6 +50,10 @@ folder=$1 action=$2 if [ ! -f $PRJ_PATH/$folder/build.sh ] ;then return ; fi cd $PRJ_PATH/$folder if [ $action == "build" ] ; then @@ -76,7 +64,6 @@ cd $PRJ_PATH } function do_usage() { @@ -89,7 +76,8 @@ echo "" echo " WARNNING: build/clean image need run as sudo" echo "" echo " Example: $0 -b bsp && sudo $0 -b image" echo " Build Example: $0 -b bsp && sudo $0 -b image" echo " Clean Example: $0 -c bsp && sudo $0 -c image" echo "" exit; } @@ -122,7 +110,6 @@ if [ $action == "build" ] ; then do_modify cd tarball && ./build.sh && cd - fi if [ $1 == "bsp" ] ; then @@ -131,7 +118,7 @@ fi do_action bootloader $action do_action kernel $action do_action drivers $action #do_action drivers $action elif [ $1 == "image" ] ; then do_root "yes" do_action rootfs $action bsp/kernel/build.sh
@@ -1,64 +1,39 @@ #!/bin/bash # This shell script used auto download bootloader source code and do cross compile PRJ_PATH=`pwd` source ../scripts/setup_env.sh # update by top build.sh BOARD=igkboard BSP_BRANCH=lf-5.10.52-2.1.0 CROSS_TOOL=/opt/buildroot/cortexA7/bin/arm-linux- KERNEL_SRC=linux-imx INST_DRIVER=1 TAR_PATH=${PRJ_PATH}/../tarball IMG_PATH=${PRJ_PATH}/../images/boot BOOT=emmc LINUX_SRC=linux-imx PATCH_FILE=${PRJ_PATH}/patch/${LINUX_SRC}-${BOARD}.patch CONF_FILE=arch/arm/configs/${BOARD}_defconfig JOBS=`cat /proc/cpuinfo | grep processor | wc -l` patch_file=$(eval echo `jq -r ".KERNEL_SRC.PATCH" $JSON_CONF`) arch=$(eval echo `jq -r ".CONFIG.ARCH" $JSON_CONF`) defconf=$(eval echo `jq -r ".CONFIG.DEFCONF" $JSON_CONF`) drvpath=$(eval echo `jq -r ".CONFIG.DRVPATH" $JSON_CONF`) set -u set -e STAGE=0 function msg_banner() { STAGE=`expr $STAGE + 1` echo "" echo "+---------------------------------------------+" printf " Stage $STAGE: $1\n" echo "+---------------------------------------------+" echo "" } function do_fetch() { msg_banner "Fetch ${LINUX_SRC} source code" if [ -d ${LINUX_SRC} ] ; then printf "\n\n -- ${LINUX_SRC} fetched already -- \n\n" if [ -d $KERNEL_SRC ] ; then pr_warn "$KERNEL_SRC fetched already." return 0; fi printf "\n -- decompress ${LINUX_SRC}-${BSP_BRANCH}.tar.xz now ... -- \n\n" tar -xJf ${TAR_PATH}/${LINUX_SRC}-${BSP_BRANCH}.tar.xz do_fetch_json $JSON_CONF KERNEL_SRC $KERNEL_SRC rm -rf *.tar* } function do_patch() { msg_banner "Patch for ${LINUX_SRC} source code" cd ${KERNEL_SRC} cd ${LINUX_SRC} if [ ! -s $CONF_FILE -a -s $PATCH_FILE ] ; then patch -p1 < $PATCH_FILE if [ ! -s arch/arm/configs/$defconf -a -s $patch_file ] ; then pr_warn "Patch for ${KERNEL_SRC} source code" patch -p1 < $patch_file fi printf "\n\nModify cross compiler in Makefile: $CROSS_TOOL\n\n" pr_warn "Modify cross compiler in Makefile: $CROSS_TOOL\n" sed -i -e "s|^CROSS_COMPILE=.*|CROSS_COMPILE?=${CROSS_TOOL}|g" Makefile cd ${PRJ_PATH} @@ -66,12 +41,13 @@ function do_build() { msg_banner "Build for ${LINUX_SRC} source code" pr_warn "Build for ${KERNEL_SRC} source code" cd ${LINUX_SRC} cd ${KERNEL_SRC} make ${BOARD}_defconfig make $defconf make -j ${JOBS} make modules_install INSTALL_MOD_PATH=$drvpath INSTALL_MOD_STRIP=1 cd ${PRJ_PATH} } @@ -79,33 +55,20 @@ function do_install() { msg_banner "Install linux kernel image" pr_warn "Install linux kernel image" cd ${LINUX_SRC} cd ${KERNEL_SRC} mkdir -p ${IMG_PATH} set -x cp arch/arm/boot/zImage ${IMG_PATH} cp arch/arm/boot/dts/${BOARD}-${BOOT}.dtb ${IMG_PATH}/ cp arch/arm/boot/zImage /tftp cp arch/arm/boot/dts/${BOARD}-${BOOT}.dtb /tftp/ set +x if [ $INST_DRIVER != 0 ] ;then rm -rf ${PRJ_PATH}/../rootfs/driver make modules_install INSTALL_MOD_PATH=${PRJ_PATH}/../rootfs/driver INSTALL_MOD_STRIP=1 fi do_install_json $JSON_CONF "INSTALL" cd ${PRJ_PATH} } function do_clean() { msg_banner "Clean ${LINUX_SRC} source code" pr_warn "Clean ${KERNEL_SRC} source code" cd ${LINUX_SRC} cd ${KERNEL_SRC} make distclean @@ -114,32 +77,33 @@ function gen_patch() { msg_banner "Clean ${LINUX_SRC} source code" cd ${LINUX_SRC} pr_warn "Clean ${KERNEL_SRC} source code" cd ${KERNEL_SRC} make savedefconfig mv defconfig ${CONF_FILE} mv defconfig arch/arm/configs/$defconf make distclean cd - mv ${LINUX_SRC} ${LINUX_SRC}-${BOARD} mv ${KERNEL_SRC} ${KERNEL_SRC}-${BOARD} pr_warn "Fetch orignal source code" do_fetch msg_banner "Generate ${LINUX_SRC} patch file" pr_warn "Generate ${KERNEL_SRC} patch file" set +e diff -Nuar -x "include-prefixes" -x logo_linux_clut224.ppm ${KERNEL_SRC} ${KERNEL_SRC}-${BOARD} > $patch_file diff -Nuar -x "include-prefixes" -x logo_linux_clut224.ppm ${LINUX_SRC} ${LINUX_SRC}-${BOARD} > ${LINUX_SRC}-${BOARD}.patch rm -rf ${LINUX_SRC} mv ${LINUX_SRC}-${BOARD} ${LINUX_SRC} rm -rf ${KERNEL_SRC} mv ${KERNEL_SRC}-${BOARD} ${KERNEL_SRC} } function do_usage() { echo "" echo "Usage:" echo " $0 [-b] [p] [-c] [-h]" echo " $0 [-b] [-p] [-c] [-h]" echo " -b: download and build $PRJ_NAME" echo " -p: generate $PRJ_NAME patch file" echo " -c: clean the source code" @@ -165,6 +129,11 @@ exit; ;; "h") do_usage exit; ;; "*") do_usage exit; @@ -172,7 +141,7 @@ esac done # Default do build action #defualt do build action do_fetch do_patch bsp/kernel/igkboard.json
New file @@ -0,0 +1,16 @@ { "KERNEL_SRC": { "URL": "${SRC_URL}/linux-imx-${BSP_VER}.tar.xz", "PROTOCAL": "wget", "PATCH": "${PRJ_PATH}/patch/linux-imx-${BOARD}.patch" }, "CONFIG": { "ARCH":"arm", "DEFCONF":"${BOARD}_defconfig", "DRVPATH":"${PRJ_PATH}/../images/drivers" }, "INSTALL": { "arch/arm/boot/zImage":"${PRJ_PATH}/../images/boot/", "arch/arm/boot/dts/*igkboard*.dtb":"${PRJ_PATH}/../images/boot/" } } bsp/rootfs/build.sh
@@ -1,28 +1,13 @@ #!/bin/bash PRJ_PATH=`pwd` PRJ_NAME=`basename ${PRJ_PATH}` source ../scripts//setup_env.sh # update by top build.sh BOARD=igkboard SYSTEM=buildroot DISTRO=2021.02 SYSNAME=buildroot JSON_CONF=rootfs.json ROOTFS_DIR=rootfs_${SYSNAME} TAR_PATH=${PRJ_PATH}/../tarball # rootfs configuration DEBIAN_URL=http://ftp.cn.debian.org/debian/ ARCH=armhf DEF_USER=lingyun DEF_PASSWD=12345 DEF_USER=`jq -r ".SYS_CONF.DEF_USER" $JSON_CONF` DEF_PASSWD=`jq -r ".SYS_CONF.DEF_PASSWD" $JSON_CONF` DEF_HOSTNAME=${BOARD} APPS_CONF=extra_apps.json set -u set -e trap 'exit_handler' EXIT @@ -32,53 +17,14 @@ umount ${ROOTFS_DIR}/{sys,proc,dev/pts,dev} 2>/dev/null || true } STAGE=0 function msg_banner() function do_debian_fetch() { STAGE=`expr $STAGE + 1` echo "" echo "+---------------------------------------------+" printf " Stage $STAGE: $1\n" echo "+---------------------------------------------+" echo "" } function do_unpack() { if [ -d ${ROOTFS_DIR} ] ; then printf "\n\n -- ${ROOTFS_DIR} fetched already, skip it -- \n\n" if [ $SYSTEM != debian -o -d $ROOTFS_DIR ] ; then return; fi if [ -s ${TAR_PATH}/${ROOTFS_DIR}.tar.bz2 ] ; then printf "\n\n -- decompress ${ROOTFS_DIR}.tar.bz2 -- \n\n" mkdir -p ${ROOTFS_DIR} tar -xjf ${TAR_PATH}/${ROOTFS_DIR}.tar.bz2 -C ${ROOTFS_DIR} fi return; } # decompress rootfs packet or debootstrap fetch debian rootfs function do_fetch() { msg_banner " ${ROOTFS_DIR} do fetch " # try to decompress packet first. do_unpack # Yocto and buildroot rootfs decompress only if [ -d ${ROOTFS_DIR} ] ; then return ; else if [ $SYSTEM != "debian" ] ; then echo " ERROR: miss ${SYSTEM}(${DISTRO}) rootfs, exit now. " echo "" exit; fi fi debian_src=$1 ARCH=$2 # debootstrap fetch debian rootfs export DEBIAN_FRONTEND=noninteractive @@ -87,51 +33,39 @@ export LANGUAGE=C export LANG=C printf "\n\n -- debootstrap fetch start --\n\n" echo "debootstrap --arch=${ARCH} --foreign ${DISTRO} ${ROOTFS_DIR} ${DEBIAN_URL}" debootstrap --arch=${ARCH} --foreign ${DISTRO} ${ROOTFS_DIR} ${DEBIAN_URL} pr_warn "debootstrap fetch start" pr_info "debootstrap --arch=${ARCH} --foreign ${DISTRO} ${ROOTFS_DIR} ${debian_src}" debootstrap --arch=${ARCH} --foreign ${DISTRO} ${ROOTFS_DIR} ${debian_src} chroot ${ROOTFS_DIR} debootstrap/debootstrap --second-stage printf "\n\n -- debootstrap config start --\n\n" pr_warn "debootstrap fetch done" chroot ${ROOTFS_DIR} dpkg --configure -a printf "\n\n -- debootstrap fetch done -- \n\n" # Clear the MD5 value to install extra apps sed -i -e "s|.*md5apt.*|\t\"md5apt\":\"MD5_Auto_Generate_Here\"|g" $APPS_CONF cd ${ROOTFS_DIR} tar -cjf ../${ROOTFS_DIR}.orig.tar.bz2 * cd - } # Install extra apps defined in extra_apps.conf function do_extra_apt() # Install extra apps defined in configure file function do_debian_apt() { if [ ! -f $APPS_CONF ] ; then return ; if [ $SYSTEM != debian ] ; then return; fi extra_apps=$(eval jq -r .extra_debian_apps[] $APPS_CONF ) md5_file=$(eval jq -r .md5apt $APPS_CONF) md5_calc=$(eval echo $extra_apps | md5sum | awk '{print $1}') if [ $md5_file == $md5_calc ] ; then printf "\n\n -- debootstrap apt install already, skip it! --\n\n" return ; apt_install=$(eval echo `jq -r .SYS_DEBIAN.INSTALL_APT $JSON_CONF` | tr 'A-Z' 'a-z') if [ $apt_install != yes ] ; then pr_warn "skip debootstrap apt install extra apps" return; fi msg_banner " debootstrap apt install " pr_warn "debootstrap apt install extra apps" export DEBIAN_FRONTEND=noninteractive export DEBCONF_NONINTERACTIVE_SEEN=true export LC_ALL=C export LANGUAGE=C export LANG=C extra_apps=`eval jq -r .SYS_DEBIAN.APT_APPS[] $JSON_CONF` cp -f /usr/bin/qemu-arm-static ${ROOTFS_DIR}/usr/bin/ mount -o bind /proc ${ROOTFS_DIR}/proc mount -o bind /dev ${ROOTFS_DIR}/dev mount -o bind /dev/pts ${ROOTFS_DIR}/dev/pts @@ -142,90 +76,32 @@ chroot ${ROOTFS_DIR} apt autoremove umount ${ROOTFS_DIR}/{sys,proc,dev/pts,dev} pr_warn "debootstrap apt install done" } function do_debian_conf() { if [ $SYSTEM != debian ] ; then return; fi sed -i -e "s|.*md5apt.*|\t\"md5apt\":\"$md5_calc\"|g" $APPS_CONF printf "\n\n -- debootstrap apt install done --\n\n" # modify root password chroot ${ROOTFS_DIR} sh -c "echo root:${DEF_PASSWD} | chpasswd" pr_warn "update debian system configuration" # add default user account set +e grep "$DEF_USER" ${ROOTFS_DIR}/etc/passwd > /dev/null 2>&1 if [ $? != 0 ] ; then printf "\n\n -- setup default user account --\n\n" pr_info "setup default user account" cp -f /usr/bin/qemu-arm-static ${ROOTFS_DIR}/usr/bin/ chroot ${ROOTFS_DIR} chmod 4755 /usr/bin/sudo chroot ${ROOTFS_DIR} sh -c "useradd -m -s /bin/bash ${DEF_USER}" chroot ${ROOTFS_DIR} sh -c "echo ${DEF_USER}:${DEF_PASSWD} | chpasswd" chroot ${ROOTFS_DIR} sh -c "usermod -aG video,audio,sudo ${DEF_USER}" fi set -e } function install_file() { if [ $# != 1 ] ; then return ; fi # parser the source file and destination install path src=`echo $1 | cut -d: -f1` dst=${ROOTFS_DIR}/`echo $1 | cut -d: -f2` echo "install $src => $dst" mkdir -p ${dst} # parser to get .tar.gz .tar.bz2 .tar.xz fname=`basename ${src}` suffix=`echo "${fname#*.}"` case $suffix in tar.gz) tar -xzf ${src} -C ${dst} ;; tar.bz2) tar -xjf ${src} -C ${dst} ;; tar.xz) tar -xJf ${src} -C ${dst} ;; *) rm -rf ${dst}/${fname} cp -rf ${src} ${dst} ;; esac } function do_install() { # apt install extra packet for debian rootfs if [ $SYSTEM == "debian" ] ; then do_extra_apt fi # install common files for all the system for row in $( jq -r '.extra_common_files | keys[] as $k | "\($k):\(.[$k])"' $APPS_CONF ) ; do install_file $row done # install extra files for custom system jq_args=".extra_${SYSTEM}_files | keys[] as \$k | \"\(\$k):\(.[\$k])\"" for row in $( jq -r "${jq_args}" $APPS_CONF ) ; do install_file $row done } function update_debian() { if [ $SYSTEM != debian ] ; then return; fi # modify root password chroot ${ROOTFS_DIR} sh -c "echo root:${DEF_PASSWD} | chpasswd" # update PATH environment in /etc/profile sed -i 's|PATH=.*|PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"|g' ${ROOTFS_DIR}/etc/profile @@ -235,20 +111,93 @@ # enable ping command for all user chmod 4755 ${ROOTFS_DIR}/usr/bin/ping* # enable root login on serial port MOD_FILE=${ROOTFS_DIR}/etc/securetty set +e grep ttyLP1 ${MOD_FILE} > /dev/null 2>&1 if [ $? != 0 ] ; then echo "" >> ${MOD_FILE} echo "# i.MX8ULP serial console" >> ${MOD_FILE} echo "ttyLP1" >> ${MOD_FILE} echo "ttyLP2" >> ${MOD_FILE} echo "ttyLP3" >> ${MOD_FILE} fi set -e } function do_modify() function do_fetch() { msg_banner " modify rootfs environment" if [ -d $ROOTFS_DIR ] ; then pr_warn "rootfs tree for $SYSTEM($DISTRO) fetch already" return; fi pr_warn "start fetch rootfs tree for $SYSTEM($DISTRO) " if [ -f $ROOTFS_DIR.tar.bz2 ] ; then do_unpack $ROOTFS_DIR.tar.bz2 $ROOTFS_DIR return; fi if [ $SYSTEM == "yocto" ] ; then mkdir -p $ROOTFS_DIR do_fetch_json $JSON_CONF SYS_YOCTO $ROOTFS_DIR do_unpack $ROOTFS_DIR.tar.bz2 $ROOTFS_DIR elif [ $SYSTEM == "buildroot" ] ; then mkdir -p $ROOTFS_DIR do_fetch_json $JSON_CONF SYS_BUILDROOT $ROOTFS_DIR do_unpack $ROOTFS_DIR.tar.bz2 $ROOTFS_DIR elif [ $SYSTEM == "debian" ] ; then protocal=`jq -r ".SYS_DEBIAN.PROTOCAL" $JSON_CONF` if [ $protocal != "debootstrap" ] ; then mkdir -p $ROOTFS_DIR do_fetch_json $JSON_CONF SYS_DEBIAN $ROOTFS_DIR do_unpack $ROOTFS_DIR.tar.bz2 $ROOTFS_DIR else debian_src=`jq -r ".SYS_DEBIAN.URL" $JSON_CONF` arch=`jq -r ".SYS_DEBIAN.ARCH" $JSON_CONF` do_debian_fetch $debian_src $arch fi fi rm -f *.tar.* } function do_install() { # apt install extra packet for debian rootfs if [ $SYSTEM == "debian" ] ; then do_debian_apt do_debian_conf do_install_json $JSON_CONF SYS_DEBIAN.INSTALL_FILES elif [ $SYSTEM == "yocto" ] ; then do_install_json $JSON_CONF SYS_YOCTO.INSTALL_FILES elif [ $SYSTEM == "buildroot" ] ; then do_install_json $JSON_CONF SYS_BUILDROOT.INSTALL_FILES fi } function do_config() { pr_warn "start configure for $SYSTEM($DISTRO) rootfs" set +e # update hostnmae and issue echo "Welcome to LingYun IoT Gateway Kit Board GNU/Linux ${SYSTEM}(${DISTRO}) system, default password '$DEF_PASSWD'." > ${ROOTFS_DIR}/etc/issue echo "Welcome to ${BOARD} Board GNU/Linux ${SYSTEM}(${DISTRO}) system, default password '$DEF_PASSWD'." > ${ROOTFS_DIR}/etc/issue echo $DEF_HOSTNAME > ${ROOTFS_DIR}/etc/hostname grep "$BOARD" ${ROOTFS_DIR}/etc/hosts > /dev/null 2>&1 grep "${DEF_HOSTNAME}" ${ROOTFS_DIR}/etc/hosts > /dev/null 2>&1 if [ $? != 0 ] ; then echo "127.0.0.1 ${BOARD}" >> ${ROOTFS_DIR}/etc/hosts echo "127.0.0.1 ${DEF_HOSTNAME}" >> ${ROOTFS_DIR}/etc/hosts fi # update dns server @@ -266,48 +215,36 @@ fi # permit root ssh login sed -i "s|^#PermitRootLogin.*|PermitRootLogin yes|g" ${ROOTFS_DIR}/etc/ssh/sshd_config sed -i "s|^#PasswordAuthentication.*|PasswordAuthentication yes|g" ${ROOTFS_DIR}/etc/ssh/sshd_config update_debian # add vim alias for buildroot and yocto if [ $SYSTEM != "debian" ] ; then grep "alias vim=" ${ROOTFS_DIR}/etc/profile > /dev/null 2>&1 if [ $? != 0 ] ; then echo "alias vim='vi'" >> ${ROOTFS_DIR}/etc/profile fi if [ -f ${ROOTFS_DIR}/etc/ssh/sshd_config ] ; then sed -i "s|^#PermitRootLogin.*|PermitRootLogin yes|g" ${ROOTFS_DIR}/etc/ssh/sshd_config sed -i "s|^#PasswordAuthentication.*|PasswordAuthentication yes|g" ${ROOTFS_DIR}/etc/ssh/sshd_config fi set -e printf "\n\n -- modify rootfs done --\n\n" pr_warn "configure for $SYSTEM($DISTRO) rootfs done" } function do_pack() { if [ -f ${ROOTFS_DIR}.tar.bz2 ] ; then msg_banner " rootfs already generate, skip it" pr_warn "rootfs already generate, skip it" return ; else msg_banner " generate rootfs packet " fi pr_warn "start generate $SYSTEM($DISTRO) rootfs packet" cd ${ROOTFS_DIR} tar -cjf ../${ROOTFS_DIR}.tar.bz2 * cd ${PRJ_PATH} printf "\n\n -- generate rootfs packet done --\n\n" pr_warn "generate $SYSTEM($DISTRO) rootfs packet done" } function do_distclean() { printf "\n\n -- do distclean in $PRJ_NAME --\n\n" pr_warn "clean rootfs source tree" rm -rf driver rm -rf $ROOTFS_DIR rm -rf $ROOTFS_DIR* rootfs_* exit; } @@ -316,7 +253,7 @@ { do_fetch do_install do_modify do_config do_pack } @@ -360,7 +297,7 @@ do_distclean ;; "*") "h") do_usage ;; esac bsp/rootfs/extra_apps.json
File was deleted bsp/rootfs/rootfs.json
New file @@ -0,0 +1,39 @@ { "SYS_CONF": { "DEF_USER":"lingyun", "DEF_PASSWD":"12345" }, "SYS_DEBIAN": { "URL":"http://ftp.debian.cn.org/debian/", "PROTOCAL": "debootstrap", "ARCH":"arm64", "INSTALL_APT": "yes", "APT_APPS": { "basic": "wget sudo curl tree file parted locales lsb-release tzdata", "admin": "net-tools network-manager wireless-tools openssh-server", "dev": "v4l-utils vim" }, "INSTALL_FILES": { "${PRJ_PATH}/../images/drivers/lib/modules/": "$ROOTFS_DIR/lib/", "files/expand_rootfs": "$ROOTFS_DIR/usr/sbin" } }, "SYS_YOCTO": { "URL":"${SRC_URL}/$ROOTFS_DIR.tar.bz2", "PROTOCAL": "wget", "INSTALL_FILES": { "${PRJ_PATH}/../images/drivers/lib/modules/*": "$ROOTFS_DIR/lib/", "files/expand_rootfs": "$ROOTFS_DIR/usr/sbin" } }, "SYS_BUILDROOT": { "URL":"${SRC_URL}/$ROOTFS_DIR.tar.bz2", "PROTOCAL": "wget", "INSTALL_FILES": { "${PRJ_PATH}/../images/drivers/lib/modules/*": "$ROOTFS_DIR/lib/", "files/expand_rootfs": "$ROOTFS_DIR/usr/sbin", "files/S30WpaSupplicant": "$ROOTFS_DIR/etc/init.d/", "files/wpa_supplicant.conf": "$ROOTFS_DIR/etc/" } } } bsp/scripts/setup_env.sh
New file @@ -0,0 +1,189 @@ #!/bin/bash PRJ_PATH=`pwd` PRJ_NAME=`basename $PRJ_PATH` # update by top build.sh BOARD=igkboard CROSS_TOOL=/opt/buildroot/cortexA7/bin/arm-linux- # Source code download address SRC_URL=http://weike-iot.com:2211/imx6ull/bsp SRC_URL=http://127.0.0.1:2211/imx6ull/bsp BSP_VER=lf-5.10.52-2.1.0 # SYSTEM should be: yocto, buildroot or debian # DISTRO should be: hardknott, 2021.02 or bullseye SYSTEM=buildroot DISTRO=2021.02 if [ $SYSTEM == "debian" ] ; then SYSNAME=${DISTRO} else SYSNAME=${SYSTEM} fi ROOTFS_DIR=rootfs_${SYSNAME} JSON_CONF=${PRJ_PATH}/${BOARD}.json JOBS=`cat /proc/cpuinfo | grep processor | wc -l` set -u set -e # display in red function pr_error() { echo -e "\033[40;31m --E-- $1 \033[0m" } # display in yellow function pr_warn() { echo -e "\033[40;33m --W-- $1 \033[0m" } # display in green function pr_info() { echo -e "\033[40;32m --I-- $1 \033[0m" } # decompress a packet to destination path function do_unpack() { tarball=$1 dstpath=`pwd` if [[ $# == 2 ]] ; then dstpath=$2 fi pr_info "decompress $tarball" mkdir -p $dstpath case $tarball in *.tar.gz) tar -xzf $tarball -C $dstpath ;; *.tar.bz2) tar -xjf $tarball -C $dstpath ;; *.tar.xz) tar -xJf $tarball -C $dstpath ;; *.tar) tar -xf $tarball -C $dstpath ;; *) pr_error "decompress Unsupport packet: $tarball" return 1; ;; esac } # copy a file and decompress it if needed function install_file() { # parameters maybe got variable, use eval to fix it. src=`eval echo $1` dst=`eval echo $2` pr_info "install $src => $dst" mkdir -p $dst if [[ $src =~ .tar ]] ; then do_unpack $src ${dst} else rm -rf ${dst}/`basename ${src}` cp -rf `eval ls -d ${src}` ${dst} fi } # install all the files specified in JSON configure file function do_install_json() { json_conf=$1 json_id=$2 jq_args=".$json_id | keys[] as \$k | \"\(\$k):\(.[\$k])\"" for row in $( jq -r "${jq_args}" $json_conf ) ; do # parser the source file and destination install path src=`echo $row | cut -d: -f1` dst=`echo $row | cut -d: -f2` # $src maybe got * to match all the files, use eval to extend it for f in `eval ls -d $src` ; do install_file $f $dst done done } # fetch source code by git function do_fetch_git() { url=$1 branch=$2 dirname=$3 if [ $branch != "null" ] ; then pr_info "git clone -b ${branch} ${url} ${dirname}" git clone -b ${branch} ${url} ${dirname} else pr_info "git clone ${url} ${dirname}" git clone ${url} ${dirname} fi } # fetch source code by wget function do_fetch_wget() { url=`eval echo $1` dirname=$2 tarfile=`basename $url` if [ ! -f $tarfile ] ; then pr_info "wget $url" wget $url > /dev/null 2>&1 fi if [ ! -d $dirname ] ; then do_unpack $tarfile fi } # fetch source code by copy function do_fetch_file() { url=`eval echo $1` dirname=$2 tarfile=`basename $url` cp -rf $url $tarfile if [[ "$tarfile" =~ ".tar" ]] ; then do_unpack $tarfile $dirname fi } # parser JSON configure file to find the way to fetch source code function do_fetch_json() { json_conf=$1 node_src=$2 dirname=$3 pr_info "start fetch $dirname source code." method=`jq -r ".$node_src.PROTOCAL" $json_conf` url=`jq -r ".$node_src.URL" $json_conf` if [[ "$method" =~ "git" ]] ; then branch=`jq -r ".$node_src.BRANCH" $json_conf` do_fetch_git $url $branch $dirname elif [[ "$method" =~ "wget" ]] ; then do_fetch_wget $url $dirname elif [[ "$method" =~ "file" ]] ; then do_fetch_file $url $dirname fi } bsp/tarball/build.sh
File was deleted