embedded-常用的编译命令

uboot

使用 海思的 3531 芯片举例

在线更新 u-boot

# 设置server ip
setenv serverip 192.168.0.147
# 通过tftp载入镜像
# tftp <内存地址> <文件名>
tftp 82000000 u-boot_SK4102_hi3531_RTL8363.bin
tftp 82000000 u-boot_KMD3832_rtl8211F.bin
tftp 82000000 u-boot_KMD3864_rtl8211e.bin
# 先在ram中调试运行,OK了在重新ftp下载,写入flash
go 0x82000000

# 测试 ok 后,写入 nand,注意要重新载入一次,因为运行后有变化
tftp 82000000 u-boot_KMD4101_hi3531_1000m.bin
nand erase 0 200000
nand write 82000000 0 200000

编译脚本

#! /bin/sh

make clean
make distclean
make ARCH=arm CROSS_COMPILE=arm-hisiv100nptl-linux- godnet_config
make ARCH=arm CROSS_COMPILE=arm-hisiv100nptl-linux-

tftpdir=/tftpboot
cfgfile=reg_info_930_310_620_ddr0_ddr1_slow.cfg
ubootfile=u-boot.bin
targetfile=u-boot_KMD3832_rtl8211F.bin

if [ ! -d ${tftpdir} ]; then
mkdir ${tftpdir}
fi

if [ ! -f ${cfgfile} ]; then
echo "no reg info file"

exit 1
fi

if [ ! -f ${ubootfile} ]; then
echo "no u-boot.bin"

exit 1
fi

if [ ! -f mkboot.sh ]; then
echo "no mkboot.sh"

exit 1
fi

chmod u+x mkboot.sh

./mkboot.sh ${cfgfile} ${targetfile}

if [ -f ${tftpdir}/${targetfile} ]; then
rm -f ${tftpdir}/${targetfile}

echo "${tftpdir}/${targetfile} deleted"
fi

cp ${targetfile} ${tftpdir}

echo "${targetfile} copied to ${tftpdir}"

文件系统

hisi3531举例
nand flash使用yaffs2格式的镜像,制作yaffs2镜像时,需要用到nand flash的pagesize和ecc。这些信息会在uboot启动时会打印出来。建议使用时先直接运行mkyaffs2image工具,根据打印信息填写相关参数。下面以2KB pagesize、1bit ecc为例:

osdrv/pub/bin/pc/mkyaffs2image osdrv/pub/rootfs_uclibc osdrv/pub/rootfs_uclibc_2k_1bit.yaffs2 1 1
# 或者
osdrv/pub/bin/pc/mkyaffs2image osdrv/pub/rootfs_glibc osdrv/pub/rootfs_glibc_2k_1bit.yaffs2 1 1

需要对应的 mkyaffs2image 程序
使用下面的编译脚本, 执行:makerootfs

#! /bin/sh

tftpdir=/tftpboot
rootfsdir=$1
rootfsfile=$1.yaffs2

if [ -f ${rootfsfile} ]; then
rm -f ${rootfsfile}
fi

./mkyaffs2image ${rootfsdir} ${rootfsfile} 1 1

chmod 755 ${rootfsfile}

if [ ! -d ${tftpdir} ]; then
mkdir ${tftpdir}
fi

if [ -f ${tftpdir}/${rootfsfile} ]; then
rm -f ${tftpdir}/${rootfsfile}

echo "${tftpdir}/${rootfsfile} deleted"
fi

cp ${rootfsfile} ${tftpdir}

echo "${rootfsfile} copied to ${tftpdir}"

# 烧录
tftp 82000000 KMD3864_rootfs_main_v10041621_audio_ok.yaffs2
tftp 82000000 rootfs_4102.yaffs2
tftp 82000000 KI_4101_nologo_V10x022217.yaffs2
nand erase 700000
nand write.yaffs 82000000 700000 1c323c0

tftp <address> filename
nand write.yaffs <address> <partition> <filesize>
# 这里的 filesize 可以根据 tftp 传输获得

kernel

cp arch/arm/configs/godnet_defconfig .config
make ARCH=arm CROSS_COMPILE=arm-hisiv100nptl-linux- clean
make ARCH=arm CROSS_COMPILE=arm-hisiv100nptl-linux- menuconfig
make ARCH=arm CROSS_COMPILE=arm-hisiv100nptl-linux- uImage
; 生成 ko 驱动模块
make ARCH=arm CROSS_COMPILE=arm-hisiv100nptl-linux- modules

// 更新
tftp 82000000 kernel_4102_8211f
tftp 82000000 uImage4102_audio_ok
tftp 82000000 KMD3832_kernel_RTL8211E
nand erase 200000 500000
nand write 82000000 200000 500000

kernel build 脚本

#! /bin/sh

tftpdir=/tftpboot

imagefile=uImage
targetimagefile=kernel_4102_8211f

make ARCH=arm CROSS_COMPILE=arm-hisiv100nptl-linux- uImage

if [ ! -d ${tftpdir} ]; then
mkdir ${tftpdir}
fi

cd arch/arm/boot

if [ ! -f ${imagefile} ]; then
echo "no ${imagefile} file"
exit 1
fi

if [ -f ${tftpdir}/${targetimagefile} ]; then
rm -f ${tftpdir}/${targetimagefile}
echo "${tftpdir}/${targetimagefile} deleted"
fi

cp ${imagefile} ${tftpdir}/${targetimagefile}

echo "${imagefile} copied to ${tftpdir}/${targetimagefile}"

cd - >/dev/null

模块b uild 脚本

#! /bin/sh

tftpdir=/tftpboot

imagefile=stmmac.ko
targetimagefile=stmmac_4102_8211f

make ARCH=arm CROSS_COMPILE=arm-hisiv100nptl-linux- modules

if [ ! -d ${tftpdir} ]; then
mkdir ${tftpdir}
fi

cd drivers/net/stmmac

if [ ! -f ${imagefile} ]; then
echo "no ${imagefile} file"
exit 1
fi

if [ -f ${tftpdir}/${targetimagefile} ]; then
rm -f ${tftpdir}/${targetimagefile}
echo "${tftpdir}/${targetimagefile} deleted"
fi

cp ${imagefile} ${tftpdir}/${targetimagefile}

echo "${imagefile} copied to ${tftpdir}/${targetimagefile}"

cd - >/dev/null

修改 mac 地址

/usr/app/updateMac 00:50:56:C2:00:06