Improved image making for debugging

This commit is contained in:
Hal Emmerich 2019-02-27 13:20:11 -06:00
parent af34a0f98f
commit b1e036e50c
9 changed files with 127 additions and 28 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
linux-* linux-*
open-ath9k-htc-firmware open-ath9k-htc-firmware
PrawnOS-Alpha-c201-libre-2GB.img PrawnOS-Alpha-c201-libre-2GB*
tmp.* tmp.*
PrawnOS-Alpha-c201-libre-2GB-git*.img PrawnOS-Alpha-c201-libre-2GB-git*.img

View File

@ -13,12 +13,29 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with PrawnOS. If not, see <https://www.gnu.org/licenses/>. # along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
KVER=4.17.19
OUTNAME=PrawnOS-Alpha-c201-libre-2GB.img
BASE=$(OUTNAME)-BASE
#Usage:
#run make image
#this will generate two images named OUTNAME and OUTNAME-BASE
#-BASE is only the filesystem with no kernel.
#if you make any changes to the kernel or kernel config with make kernel_config
#run kernel_inject
.PHONY: clean .PHONY: clean
clean: clean:
@echo "Enter one of:" @echo "Enter one of:"
@echo " clean_kernel - which deletes the untar'd kernel folder from build" @echo " clean_kernel - which deletes the untar'd kernel folder from build"
@echo " clean_ath - which deletes the untar'd ath9k driver folder from build" @echo " clean_ath - which deletes the untar'd ath9k driver folder from build"
@echo " clean_img - which deletes the built PrawnOS images, this is ran when make image is ran" @echo " clean_img - which deletes the built PrawnOS image, this is ran when make image is ran"
@echo " clean_fs - which deletes the built PrawnOS base image"
@echo " clean_all - which does all of the above" @echo " clean_all - which does all of the above"
@echo " in most cases none of these need to be used manually as most cleanup steps are handled automatically" @echo " in most cases none of these need to be used manually as most cleanup steps are handled automatically"
@ -32,33 +49,48 @@ clean_ath:
.PHONY: clean_img .PHONY: clean_img
clean_img: clean_img:
rm -f PrawnOS-*-c201-libre-*GB.img rm -f $(OUTNAME)
.PHONY: clean_fs
clean_fs:
rm -r $(BASE)
.PHONY: clean_all .PHONY: clean_all
clean_all: clean_all:
make clean_kernel make clean_kernel
make clean_ath make clean_ath
make clean_img make clean_img
make clean_fs
.PHONY: kernel .PHONY: kernel
kernel: kernel:
scripts/buildKernel.sh scripts/buildKernel.sh $(KVER)
#makes the base filesystem image, no kernel only if the base image isnt present
.PHONY: filesystem .PHONY: filesystem
filesystem: filesystem:
make clean_img [ -f $(BASE) ] || scripts/buildFilesystem.sh $(KVER)
scripts/buildDebianFs.sh
.PHONY: kernel_inject .PHONY: kernel_inject
kernel_inject: #Targets an already built .img and swaps the old kernel with the newly compiled kernel kernel_inject: #Targets an already built .img and swaps the old kernel with the newly compiled kernel
scripts/buildNewKernelIntoFS.sh scripts/injectKernelIntoFS.sh $(KVER) $(OUTNAME)
.PHONY: injected_image
injected_image: #makes a copy of the base image with a new injected kernel
make kernel
cp PrawnOS-Alpha-c201-libre-2GB.img-BASE PrawnOS-Alpha-c201-libre-2GB.img
make kernel_inject
.PHONY: image .PHONY: image
image: image:
make clean_img make clean_img
scripts/buildKernel.sh make kernel
scripts/buildDebianFs.sh make filesystem
#Make a new copy of the filesystem image
cp $(BASE) $(OUTNAME)
make kernel_inject
.PHONY: live_image .PHONY: live_image
live_image: live_image:
@ -66,4 +98,8 @@ live_image:
.PHONY: kernel_config .PHONY: kernel_config
kernel_config: kernel_config:
scripts/crossmenuconfig.sh scripts/crossmenuconfig.sh $(KVER)
.PHONY: patch_kernel
patch_kernel:
scripts/patchKernel.sh

View File

@ -1,6 +1,6 @@
# #
# Automatically generated file; DO NOT EDIT. # Automatically generated file; DO NOT EDIT.
# Linux/arm 4.17.2-gnu Kernel Configuration # Linux/arm 4.17.19-gnu Kernel Configuration
# #
CONFIG_ARM=y CONFIG_ARM=y
CONFIG_ARM_HAS_SG_CHAIN=y CONFIG_ARM_HAS_SG_CHAIN=y

View File

@ -0,0 +1,9 @@
#! /bin/bash
#Connect to wifi
wpa_passphrase PotatoMuncher gimmethosetots > wpa.conf
wpa_supplicant -i wlan0 -c wpa.conf &
dhclient wlan0
#download the debian image
wget https://cdimage.debian.org/debian-cd/current/armhf/iso-dvd/debian-9.8.0-armhf-DVD-1.iso

View File

@ -19,7 +19,6 @@
# along with PrawnOS. If not, see <https://www.gnu.org/licenses/>. # along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
KVER=4.17.19
#Ensure Sudo #Ensure Sudo
if [ ! $UID = "0" ] if [ ! $UID = "0" ]
@ -29,11 +28,18 @@ then
exit 1 exit 1
fi fi
if [ -z "$1" ]
then
echo "No kernel version supplied"
exit 1
fi
KVER=$1
[ ! -d build ] && echo "No build folder found, is the kernel built?" && exit [ ! -d build ] && echo "No build folder found, is the kernel built?" && exit
outmnt=$(mktemp -d -p `pwd`) outmnt=$(mktemp -d -p `pwd`)
outdev=/dev/loop4 outdev=/dev/loop5
install_resources=resources/InstallResources install_resources=resources/InstallResources
build_resources=resources/BuildResources build_resources=resources/BuildResources
@ -76,7 +82,7 @@ create_image() {
} }
# create a 3GB image with the Chrome OS partition layout # create a 3GB image with the Chrome OS partition layout
create_image PrawnOS-Alpha-c201-libre-2GB.img $outdev 50M 40 $outmnt create_image PrawnOS-Alpha-c201-libre-2GB.img-BASE $outdev 50M 40 $outmnt
# use default debootstrap mirror if none is specified # use default debootstrap mirror if none is specified
if [ "$PRAWNOS_DEBOOTSTRAP_MIRROR" = "" ] if [ "$PRAWNOS_DEBOOTSTRAP_MIRROR" = "" ]
@ -97,6 +103,11 @@ cp scripts/InstallScripts/* $outmnt/InstallResources/
cp scripts/InstallScripts/InstallToInternal.sh $outmnt/ cp scripts/InstallScripts/InstallToInternal.sh $outmnt/
chmod +x $outmnt/*.sh chmod +x $outmnt/*.sh
#Copy in the test script
cp scripts/InstallScripts/wifi-test.sh $outmnt/wifi-test.sh
chmod +x $outmnt/wifi-test.sh
#Setup the chroot for apt #Setup the chroot for apt
#This is what https://wiki.debian.org/EmDebian/CrossDebootstrap suggests #This is what https://wiki.debian.org/EmDebian/CrossDebootstrap suggests
cp /etc/hosts $outmnt/etc/ cp /etc/hosts $outmnt/etc/
@ -134,14 +145,6 @@ chroot $outmnt apt-get -t testing install -d -y firefox-esr
rm -rf $outmnt/etc/hosts #This is what https://wiki.debian.org/EmDebian/CrossDebootstrap suggests rm -rf $outmnt/etc/hosts #This is what https://wiki.debian.org/EmDebian/CrossDebootstrap suggests
echo -n "127.0.0.1 PrawnOS-Alpha" > $outmnt/etc/hosts echo -n "127.0.0.1 PrawnOS-Alpha" > $outmnt/etc/hosts
# put the kernel in the kernel partition, modules in /lib/modules and AR9271
# firmware in /lib/firmware
dd if=build/linux-$KVER/vmlinux.kpart of=${outdev}p1 conv=notrunc
make -C build/linux-$KVER ARCH=arm INSTALL_MOD_PATH=$outmnt modules_install
rm -f $outmnt/lib/modules/3.14.0/{build,source}
install -D -m 644 build/open-ath9k-htc-firmware/target_firmware/htc_9271.fw $outmnt/lib/firmware/ath9k_htc/htc_9271-1.4.0.fw
install -D -m 644 build/open-ath9k-htc-firmware/target_firmware/htc_7010.fw $outmnt/lib/firmware/ath9k_htc/htc_7010-1.4.0.fw
umount -l $outmnt > /dev/null 2>&1 umount -l $outmnt > /dev/null 2>&1
rmdir $outmnt > /dev/null 2>&1 rmdir $outmnt > /dev/null 2>&1
losetup -d $outdev > /dev/null 2>&1 losetup -d $outdev > /dev/null 2>&1

View File

@ -18,8 +18,12 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with PrawnOS. If not, see <https://www.gnu.org/licenses/>. # along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
if [ -z "$1" ]
KVER=4.17.19 then
echo "No kernel version supplied"
exit 1
fi
KVER=$1
TEST_PATCHES=false TEST_PATCHES=false
ROOT_DIR=`pwd` ROOT_DIR=`pwd`

View File

@ -19,20 +19,33 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with PrawnOS. If not, see <https://www.gnu.org/licenses/>. # along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
KVER=4.17.19 if [ -z "$1" ]
then
echo "No kernel version supplied"
exit 1
fi
KVER=$1
TEST_PATCHES=false
ROOT_DIR=`pwd` ROOT_DIR=`pwd`
RESOURCES=$ROOT_DIR/resources/BuildResources RESOURCES=$ROOT_DIR/resources/BuildResources
[ ! -d build ] && mkdir build [ ! -d build ] && mkdir build
cd build cd build
# build Linux-libre, with ath9k_htc
[ ! -f linux-libre-$KVER-gnu.tar.lz ] && wget https://www.linux-libre.fsfla.org/pub/linux-libre/releases/$KVER-gnu/linux-libre-$KVER-gnu.tar.lz [ ! -f linux-libre-$KVER-gnu.tar.lz ] && wget https://www.linux-libre.fsfla.org/pub/linux-libre/releases/$KVER-gnu/linux-libre-$KVER-gnu.tar.lz
[ ! -d linux-$KVER ] && tar --lzip -xvf linux-libre-$KVER-gnu.tar.lz [ ! -d linux-$KVER ] && tar --lzip -xvf linux-libre-$KVER-gnu.tar.lz && FRESH=true
cd linux-$KVER cd linux-$KVER
make clean make clean
make mrproper make mrproper
#Apply the usb and mmc patches if unapplied #Apply the usb and mmc patches if unapplied
[ "$FRESH" = true ] && for i in $RESOURCES/patches-tested/DTS/*.patch; do patch -p1 < $i; done [ "$FRESH" = true ] && for i in $RESOURCES/patches-tested/DTS/*.patch; do patch -p1 < $i; done
[ "$FRESH" = true ] && for i in $RESOURCES/patches-tested/kernel/*.patch; do patch -p1 < $i; done [ "$FRESH" = true ] && for i in $RESOURCES/patches-tested/kernel/*.patch; do patch -p1 < $i; done
#Apply all of the rockMyy patches that make sense
[ "$TEST_PATCHES" = true ] && for i in $RESOURCES/patches-untested/kernel/*.patch; do patch -p1 < $i; done
[ "$TEST_PATCHES" = true ] && for i in $RESOURCES/patches-untested/DTS/*.patch; do patch -p1 < $i; done
cp $RESOURCES/config .config cp $RESOURCES/config .config
make menuconfig ARCH=arm CROSS_COMPILE=arm-none-eabi- .config make menuconfig ARCH=arm CROSS_COMPILE=arm-none-eabi- .config
cp .config $RESOURCES/config cp .config $RESOURCES/config

View File

@ -15,8 +15,18 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with PrawnOS. If not, see <https://www.gnu.org/licenses/>. # along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
KVER=4.17.2 if [ -z "$1" ]
then
echo "No kernel version supplied"
exit 1
fi
KVER=$1
if [ -z "$2" ]
then
echo "No image filesystem image supplied"
exit 1
fi
outmnt=$(mktemp -d -p `pwd`) outmnt=$(mktemp -d -p `pwd`)
outdev=/dev/loop7 outdev=/dev/loop7
@ -42,7 +52,7 @@ trap cleanup INT TERM EXIT
#Mount the build filesystem image #Mount the build filesystem image
losetup -P $outdev PrawnOS-*-c201-libre-2GB* losetup -P $outdev $2
mount -o noatime ${outdev}p2 $outmnt mount -o noatime ${outdev}p2 $outmnt
# put the kernel in the kernel partition, modules in /lib/modules and AR9271 # put the kernel in the kernel partition, modules in /lib/modules and AR9271

24
scripts/patchKernel.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh -xe
if [ -z "$1" ]
then
echo "No kernel version supplied"
exit 1
fi
KVER=$1
ROOT_DIR=`pwd`
RESOURCES=$ROOT_DIR/resources/BuildResources
[ ! -d build ] && mkdir build
cd build
# build Linux-libre, with ath9k_htc
cd linux-$KVER
make clean
make mrproper
#Apply the usb and mmc patches if unapplie
for i in $RESOURCES/patches-tested/DTS/*.patch; do patch -p1 < $i; done
for i in $RESOURCES/patches-tested/kernel/*.patch; do patch -p1 < $i; done
cd $ROOT_DIR