Created
February 28, 2016 19:41
-
-
Save paulc/7ec463d2f10e43c8aa6a to your computer and use it in GitHub Desktop.
MT7620 Build File
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export BUILDDIR="${BUILDDIR:-$(pwd)}" | |
export SRCDIR="${SRCDIR:-/usr/src}" | |
export MAKEOBJDIRPREFIX="${MAKEOBJDIRPREFIX:-${BUILDDIR}/obj}" | |
export DESTDIR="${DESTDIR:-${BUILDDIR}/dest}" | |
export KERNCONF="${KERNCONF:-MT7620}" | |
export ARCH="${ARCH:-mips}" | |
export TARGET_ARCH="${TARGET_ARCH:-mipsel}" | |
export MAKEFLAGS="${MAKEFLAGS:-}" | |
# make kernel-toolchain | |
# MT7620 # printenv | |
# bootcmd=tftp | |
# bootdelay=5 | |
# baudrate=57600 | |
# ethaddr="00:AA:BB:CC:DD:10" | |
# autostart=no | |
# filesize=5676d8 | |
# fileaddr=80010000 | |
# ipaddr=10.0.1.200 | |
# serverip=10.0.1.135 | |
# stdin=serial | |
# stdout=serial | |
# stderr=serial | |
# bootfile=kernel.bin.uboot | |
# mkimage -A mips -O linux -T kernel -C lzma -a 0x80010120 -e 0x80010120 -n FreeBSD -d kernel.oldlzma kernel.oldlzma.uboot | |
set -e | |
buildworld() { | |
( | |
cd ${SRCDIR} | |
make -j$(sysctl -n hw.ncpu) "${MAKEFLAGS}" buildworld ARCH="${ARCH}" TARGET_ARCH="${TARGET_ARCH}" | |
) | |
} | |
buildkernel() { | |
( | |
cd ${SRCDIR} | |
make -j$(sysctl -n hw.ncpu) "${MAKEFLAGS}" buildkernel ARCH="${ARCH}" TARGET_ARCH="${TARGET_ARCH}" KERNCONF="${KERNCONF}" | |
) | |
} | |
buildimage() { | |
( | |
cd "${MAKEOBJDIRPREFIX}/${ARCH}.${TARGET_ARCH}/usr/src/sys/${KERNCONF}" | |
readelf -h kernel | grep 'Entry point address:' | |
"${MAKEOBJDIRPREFIX}/${ARCH}.${TARGET_ARCH}/usr/src/tmp/usr/bin/objcopy" -O binary kernel kernel.bin | |
mkimage -A mips -O linux -T kernel -C none -a 0x80010100 -e 0x80010100 -n FreeBSD -d kernel.bin kernel.bin.uboot | |
cp kernel.bin.uboot /tftpboot | |
) | |
} | |
buildcompressedimage() { | |
( | |
cd "${MAKEOBJDIRPREFIX}/${ARCH}.${TARGET_ARCH}/usr/src/sys/${KERNCONF}" | |
gzip -cf kernel.bin > kernel.bin.gz | |
lzma -cf kernel.bin > kernel.bin.lzma | |
oldlzma -cf kernel.bin > kernel.bin.oldlzma | |
mkimage -A mips -O linux -T kernel -C gzip -a 0x80010100 -e 0x80010100 -n FreeBSD -d kernel.bin.gz kernel.gz.uboot | |
mkimage -A mips -O linux -T kernel -C lzma -a 0x80010100 -e 0x80010100 -n FreeBSD -d kernel.bin.lzma kernel.lzma.uboot | |
mkimage -A mips -O linux -T kernel -C lzma -a 0x80010100 -e 0x80010100 -n FreeBSD -d kernel.bin.oldlzma kernel.oldlzma.uboot | |
cp kernel.gz.uboot /tftpboot | |
cp kernel.lzma.uboot /tftpboot | |
cp kernel.oldlzma.uboot /tftpboot | |
) | |
} | |
buildtestimage() { | |
dd if=/dev/urandom of=test.bin bs=1k count=1 | |
gzip -cf test.bin > test.bin.gz | |
lzma -cf test.bin > test.bin.lzma | |
oldlzma -cf test.bin > test.bin.oldlzma | |
mkimage -A mips -O linux -T kernel -C none -a 0x80010100 -e 0x80010100 -n FreeBSD -d test.bin test.bin.uboot | |
mkimage -A mips -O linux -T kernel -C gzip -a 0x80010100 -e 0x80010100 -n FreeBSD -d test.bin.gz test.gz.uboot | |
mkimage -A mips -O linux -T kernel -C lzma -a 0x80010100 -e 0x80010100 -n FreeBSD -d test.bin.lzma test.lzma.uboot | |
mkimage -A mips -O linux -T kernel -C lzma -a 0x80010100 -e 0x80010100 -n FreeBSD -d test.bin.oldlzma test.oldlzma.uboot | |
cp test.*.uboot /tftpboot | |
rm -f test.* test.*.uboot | |
} | |
install() { | |
( | |
cd "${SRCDIR}" | |
sudo -E make -j$(sysctl -n hw.ncpu) installworld TARGET_ARCH="${TARGET_ARCH}" DESTDIR="${DESTDIR}" | |
sudo -E make -j$(sysctl -n hw.ncpu) distribution TARGET_ARCH="${TARGET_ARCH}" DESTDIR="${DESTDIR}" | |
sudo -E make -j$(sysctl -n hw.ncpu) installkernel TARGET_ARCH="${TARGET_ARCH}" KERNCONF="${KERNCONF}" DESTDIR="${DESTDIR}" | |
) | |
} | |
targets() { | |
echo | |
echo -n "Usage: $0 " | |
sed -ne '/targets/d' -e 's/\(^[a-zA-Z][^(]*\)().*/\1/p' $0 | tr '\n' '|' | sed -e 's/.$//' | |
echo | |
echo | |
echo " CC=${CC}" | |
echo " BUILDDIR=${BUILDDIR}" | |
echo " SRCDIR=${SRCDIR}" | |
echo " MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}" | |
echo " DESTDIR=${DESTDIR}" | |
echo " KERNCONF=${KERNCONF}" | |
echo " TARGET_ARCH=${TARGET_ARCH}" | |
echo " MAKEFLAGS=${MAKEFLAGS}" | |
echo | |
} | |
if [ -z "$1" ] | |
then | |
targets | |
else | |
$1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can you share KERNCONF and .dts ?