Add build tools for kernel image, modules and firmware

This commit is contained in:
Cosmin Gorgovan 2015-02-02 20:15:55 +00:00
parent ec5a86e81f
commit 67032fb131
5 changed files with 257 additions and 0 deletions

4
.gitignore vendored
View File

@ -1 +1,5 @@
rootfs rootfs
src/backports*
src/*.deb
src/firmware-okreader/lib/
src/linux-okreader-modules/lib/

123
build.sh Executable file
View File

@ -0,0 +1,123 @@
#!/bin/bash
# Copyright (c) 2015, Cosmin Gorgovan <cosmin at linux-geek dot org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
available_targets=("linux-image" "linux-modules" "firmware-okreader")
print_usage() {
echo "Usage: build.sh [TARGET]"
echo "Valid targets are: "
echo " all select all targets"
for target in ${available_targets[*]}; do
echo " $target"
done
}
is_target() {
for target in ${available_targets[*]}; do
if [ $1 == $target ] ; then
return 1
fi
done
return 0
}
parse_args() {
if [ $# -lt "1" ] ; then
print_usage
exit 1
fi
for arg in "$@"; do
if [ $arg == all ] ; then
targets=${available_targets[*]}
else
is_target $arg
if [ $? == 1 ] ; then
targets[${#targets[*]}]=$arg
else
echo "Error: Unrecognized target $arg"
echo
print_usage
exit 1
fi
fi
done
}
compile_linux_image() {
cd src/linux
make mx50_kobo_defconfig
make -j$(($(nproc)+1)) uImage
cd ../../
}
compile_linux_modules() {
cd src/linux
make -j$(($(nproc)+1)) modules
cd ../../
cd src/backports-3.14.22-1
KLIB_BUILD=../linux/ make defconfig-brcmfmac
KLIB_BUILD=../linux/ make -j$(($(nproc)+1))
cd ../
mkdir -p linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
cp backports-3.14.22-1/drivers/net/wireless/brcm80211/brcmfmac/brcmfmac.ko linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
cp backports-3.14.22-1/drivers/net/wireless/brcm80211/brcmutil/brcmutil.ko linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
cp backports-3.14.22-1/net/wireless/cfg80211.ko linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
cp backports-3.14.22-1/compat/compat.ko linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
cp linux/drivers/usb/gadget/g_file_storage.ko linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
cp linux/drivers/mmc/card/sdio_wifi_pwr.ko linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
cp linux/drivers/usb/gadget/arcotg_udc.ko linux-okreader-modules/lib/modules/2.6.35.3-850-gbc67621+/
dpkg-deb -b linux-okreader-modules .
cd ..
}
compile_firmware_okreader() {
cd src
dpkg-deb -b firmware-okreader .
cd ..
}
targets=()
parse_args $@
for target in ${targets[*]}; do
case $target in
linux-image)
compile_linux_image
;;
linux-modules)
compile_linux_modules
;;
firmware-okreader)
compile_firmware_okreader
;;
esac
done

120
fetch_sources.sh Executable file
View File

@ -0,0 +1,120 @@
#!/bin/bash
# Copyright (c) 2015, Cosmin Gorgovan <cosmin at linux-geek dot org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
available_targets=("linux-backports" "firmware-okreader")
print_usage() {
echo "Usage: fetch_sources.sh [TARGET]"
echo "Valid targets are: "
echo " all select all targets"
for target in ${available_targets[*]}; do
echo " $target"
done
}
is_target() {
for target in ${available_targets[*]}; do
if [ $1 == $target ] ; then
return 1
fi
done
return 0
}
parse_args() {
if [ $# -lt "1" ] ; then
print_usage
exit 1
fi
for arg in "$@"; do
if [ $arg == all ] ; then
targets=${available_targets[*]}
else
is_target $arg
if [ $? == 1 ] ; then
targets[${#targets[*]}]=$arg
else
echo "Error: Unrecognized target $arg"
echo
print_usage
exit 1
fi
fi
done
}
fetch_and_unpack_archive() {
if [ -d src/$3 ] ; then
echo "Warn: $2 already unpacked"
return
fi
if [ -f src/$2 ] ; then
echo "Info: $2 already downloaded"
else
wget $1 -O ./src/$2
fi
if [ $(sha256sum src/$2 | awk '{ print $1 }') != $4 ] ; then
echo "Error: wrong checksum for $2"
return
fi
tar xf src/$2 -C ./src/
}
fetch_and_verify() {
if [ -f $2 ] ; then
echo "Info: $2 already exists"
else
wget $1 -O $2
fi
if [ $(sha256sum $2 | awk '{ print $1 }') != $3 ] ; then
echo "Error: wrong checksum for $2"
rm $2
return
fi
}
targets=()
parse_args $@
for target in ${targets[*]}; do
case $target in
linux-backports)
fetch_and_unpack_archive "https://www.kernel.org/pub/linux/kernel/projects/backports/stable/v3.14.22/backports-3.14.22-1.tar.xz" "backports-3.14.22-1.tar.xz" "backports-3.14.22-1" "a1b6a03647624545d77559db7cc33027aa4dcd882b48247287697dc6a255e3ac"
;;
firmware-okreader)
mkdir -p src/firmware-okreader/lib/firmware/brcm
fetch_and_verify https://raw.githubusercontent.com/allwinner-ics/lichee_linux-3.0/e1a12df96abab1805df4e4b46b3ef7759cca0f84/modules/wifi/bcm40181/open-src/src/dhd/linux/NVRAM.txt src/firmware-okreader/lib/firmware/brcm/brcmfmac43362-sdio.txt 4542dd0adc727f56b4870e52388b47c9ae4afb9a4bbd7b7c30de9714af1aa173
fetch_and_verify https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac43362-sdio.bin?id=b794c5039dcf0b7ebfeb58929d035f7a1d4c80dd src/firmware-okreader/lib/firmware/brcm/brcmfmac43362-sdio.bin 5783fd90528cc7ae421b6a6056b1572a3840eac4559b26d299d1acae17523e42
;;
esac
done

View File

@ -0,0 +1,5 @@
Package: firmware-okreader
Version: 1.0-1
Maintainer: Cosmin Gorgovan <okreader@linux-geek.org>
Architecture: armhf
Description: firmware blobs for okreader

View File

@ -0,0 +1,5 @@
Package: linux-okreader-modules
Version: 2.6.35.3-1
Maintainer: Cosmin Gorgovan <okreader@linux-geek.org>
Architecture: armhf
Description: modules for the okreader kernel