Commit f4a511b4 authored by Angus Ainslie's avatar Angus Ainslie Committed by Gogs

Merge branch 'master' of guido.gunther/debian_qemuscripts into master

parents e0c005ee ea8ed8ca
kernel
bootmp.img
bootmp.img.log
files/
u-boot/
*.deb
*.img
*.img.xz
*.img.log
files/*.changes
files/*.deb
files/*.debian.tar.gz
files/*.dsc
files/*.orig.tar.gz
# SPDX-License-Identifier: GPL-3.0+
BOARD=imx6
IMAGE=$(BOARD).img
COMPRESSED=$(IMAGE).xz
all: $(COMPRESSED)
$(IMAGE): lava.sh root.sh
./lava.sh -b $(BOARD)
%.img.xz: %.img
xz -T0 --stdout $< > $@
clean:
rm -f files/ *.img *.img.*
check:
bash -n lava.sh root.sh
publish: $(COMPRESSED)
build/publish.sh
# debian_qemuscripts
debian_qemuscripts
==================
debian rootfs scripts to create a bootable SD card image
Create a bootable SD Card image for the [Boundary Devices Nitrogen6max][1].
These are WIP scripts.
These are WIP scripts tested on the Nit6QP_MAX.
Run lava.sh.
To build the image run
./lava.sh -b <board type>
make
"board type" can be selected from imx5, imx6, imx8 and qemu. "board type" defaults to imx6.
untested for imx8 and qemu
The resulting image will be name imx6.img.
# To copy the SD card image
Must be larger than 3G. Replace <x> with the SD card device.
sudo dd if=bootmp.img of=/dev/sd<x> bs=4M
sudo dd if=imx6.img of=/dev/sd<x> bs=4M
[1]: https://boundarydevices.com/product/nitrogen6max/
......@@ -2,24 +2,15 @@ To build the kernel on x86 there are some prerequisits, a crosscompile and build
sudo apt-get install gcc-arm-linux-gnueabihf build-essential crossbuild-essential-armhf
Checkout the fslc kernel
Checkout the mainline kernel
git clone https://github.com/Freescale/linux-fslc.git
cp kernel_dot_config linux-fslc/.config
cd linux-fslc
git checkout 4.14.x+fslc
git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cp kernel_dot_config linux/.config
cd linux
git checkout v4.15-rc2
Build it
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../../kernel
Copy the files needed for the SD card image
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../../kernel modules_install
mkdir -p ../../dtbs
cp arch/arm/boot/dts/imx53-qsb.dtb ../../dtbs
cp arch/arm/boot/dts/imx6q-nitrogen6*.dtb ../../dtbs
cp zImage ../../zImage-4.14.2+
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- deb-pkg
Copy the generated deb in to the folder you invoke ./lava.sh from.
This diff is collapsed.
......@@ -5,22 +5,19 @@
# SPDX-License-Identifier: GPL-3.0+
#
DATE=`date +"%Y-%m-%d"`
set -e
ssh -p 3376 librem5@storage.puri.sm "mkdir ~/librem5/binaries/unstable/$DATE"
DATE=$(date --iso)
TARGET="librem5/binaries/unstable/$DATE"
if [ -e kernel.tgz ]; then
scp -P 3376 kernel_git.txt librem5@storage.puri.sm:~/librem5/binaries/unstable/$DATE
scp -P 3376 kernel.tgz librem5@storage.puri.sm:~/librem5/binaries/unstable/$DATE
ssh -p 3376 librem5@storage.puri.sm "cd ~/librem5/binaries/unstable/; ln -fs $DATE/kernel.tgz latest_kernel.tgz "
fi
ssh -p 3376 librem5@storage.puri.sm "mkdir -p ${TARGET}"
UBOOTS=`ls u-boot-*.imx`
# Publish all files needed to build the image
scp -P 3376 files/* "librem5@storage.puri.sm:${TARGET}/"
for UBOOT in ${UBOOTS}; do
NAME=`basename ${UBOOT} .imx`
scp -P 3376 ${NAME}-git.txt librem5@storage.puri.sm:~/librem5/binaries/unstable/$DATE
scp -P 3376 ${UBOOT} librem5@storage.puri.sm:~/librem5/binaries/unstable/$DATE
ssh -p 3376 librem5@storage.puri.sm "cd ~/librem5/binaries/unstable/; ln -fs $DATE/${UBOOT} latest-${UBOOT} "
done
# Publish built images if present
if ls *.img.xz >& /dev/null; then
scp -P 3376 *.img.xz "librem5@storage.puri.sm:${TARGET}/"
fi
ssh -p 3376 librem5@storage.puri.sm "ln -nsf ${DATE} ${TARGET}/../latest"
......@@ -6,6 +6,7 @@
#
set -e
set -u
usage() {
echo "Usage : $1 "
......@@ -14,16 +15,15 @@ usage() {
echo " -d <distro> optional select the puros distro"
}
user=`whoami`
cwd=`pwd`
distro=${DIST:-buster}
mirror=${MIRROR:-"http://httpredir.debian.org/debian"}
arch=${ARCH:-armhf}
pureos_board=${PUREOS_BOARD:-imx6}
uboot="u-boot-imx6.imx"
bootimg="bootmp.img"
mirror=${MIRROR:-"http://deb.debian.org/debian"}
arch=armhf
pureos_board=imx6
kernel_version=4.15.0-rc5_4.15.0-rc5-1
kernel_url=https://storage.puri.sm/librem5/binaries/unstable/latest/
NULL=
while getopts ":hb:d:" opt; do
case ${opt} in
......@@ -46,22 +46,12 @@ while getopts ":hb:d:" opt; do
done
case ${pureos_board} in
imx5)
uboot=u-boot-imx5.imx
arch=armhf
;;
imx6)
uboot=u-boot-imx6.imx
imx5|imx6|qemu)
arch=armhf
;;
imx8)
uboot=u-boot-imx8.imx
arch=aarch64
;;
qemu)
uboot=u-boot-imx8.imx
arch=armhf
;;
\?)
echo "unrecognized board type ${pureos_board}"
exit 1
......@@ -71,6 +61,7 @@ esac
export distro
export pureos_board
bootimg="${pureos_board}.img"
# these packages must be in the main achive contrib and non-free
# can be handled by the customization script
PACKAGES="
......@@ -85,10 +76,12 @@ done
echo "Installing extra packages ${PACKAGES}"
sudo pureos_board=${pureos_board} distro=${distro} vmdebootstrap \
kernel_deb=linux-image-${kernel_version}_${arch}.deb
[ -f "files/${kernel_deb}" ] || wget -Pfiles/ "${kernel_url}/${kernel_deb}"
sudo pureos_board=${pureos_board} distro=${distro} arch=${arch} vmdebootstrap \
--enable-dhcp --no-kernel \
--verbose --image $bootimg --log $bootimg.log --size 3G \
--bootoffset 1M \
--mirror "${mirror}" \
--arch=${arch} \
--foreign=/usr/bin/qemu-arm-static \
......@@ -99,15 +92,10 @@ sudo pureos_board=${pureos_board} distro=${distro} vmdebootstrap \
--serial-console-command "/sbin/getty -L ttymxc0 115200 vt100" \
--root-password='root' --hostname='pureos' --user=purism/purism --sudo \
--customize $cwd/root.sh \
--no-update-initramfs
if [ ! -e u-boot/$uboot ]; then
mkdir -p u-boot
wget https://storage.puri.sm/librem5/binaries/unstable/latest-$uboot -O u-boot/$uboot
fi
--no-update-initramfs \
--bootsize 200M \
--boottype ext2 \
--custom-package "files/${kernel_deb}" \
--owner $(whoami) \
${NULL}
sudo losetup -P /dev/loop0 $bootimg
sudo dd if=u-boot/$uboot of=/dev/loop0 seek=2 bs=512
sudo losetup -d /dev/loop0
sync
sync
#!/bin/sh
#!/bin/bash
#
# Copyright (C) 2017 Purism SPC
#
......@@ -8,43 +8,30 @@
# distro and basedir set by calling script
basedir=$1
image_name=$2
env
cwd=`pwd`
kernel_dir=${KERNEL_DIR:-"${cwd}/kernel/"}
version=4.14.x+
kernel=zImage-$version
set -e
mirror=httpredir.debian.org
set -u
if [ -z ${pureos_board} ]; then
echo "\${pureos_board} not set, giving up" 1>&2
exit 1
fi
mirror=deb.debian.org
echo "Configuring ${distro} in ${basedir} for board ${pureos_board}"
case ${pureos_board} in
imx5)
uboot=u-boot-imx5.imx
arch=armhf
fdt_file=imx53-qsb.dtb
;;
imx6)
uboot=u-boot-imx6.imx
arch=armhf
fdt_file=imx6q-nitrogen6_max.dtb
fdt_file=imx6qp-nitrogen6_max.dtb
;;
imx8)
uboot=u-boot-imx8.imx
arch=aarch64
echo "board type ${pureos_board} not configured yet"
;;
qemu)
uboot=u-boot-imx8.imx
arch=armhf
echo "board type ${pureos_board} not configured yet"
exit 1
;;
......@@ -54,19 +41,18 @@ case ${pureos_board} in
;;
esac
arm="abootimg cgpt fake-hwclock ntpdate u-boot-tools vboot-utils vboot-kernel-utils"
base="e2fsprogs initramfs-tools pureos-defaults pureos-menu parted sudo usbutils"
desktop="fonts-croscore fonts-crosextra-caladea fonts-crosextra-carlito gnome-theme-kali gtk3-engines-xfce pureos-desktop-xfce pureos-root-login lightdm network-manager network-manager-gnome xfce4 xserver-xorg-video-fbdev"
tools="aircrack-ng ethtool hydra john libnfc-bin mfoc nmap passing-the-hash sqlmap usbutils winexe wireshark"
services="apache2 haveged openssh-server"
extras="iceweasel xfce4-terminal wpasupplicant gnome"
packages="${arm} ${base} ${desktop} ${services} ${extras}"
architecture="armhf"
function setup_kernel()
{
local link="$(basename $basedir/boot/vmlinuz-*)"
rm -f "${basedir}/boot/zImage"
ln -s "${link}" "${basedir}/boot/zImage"
mkdir -p "${basedir}/boot/dtbs"
cp "${basedir}"/usr/lib/linux-image-*/${fdt_file} "${basedir}/boot/dtbs/"
}
#sudo cp /usr/bin/qemu-arm-static $basedir/usr/bin/
#LANG=C chroot $basedir /debootstrap/debootstrap --second-stage
# create the directories so that this script can be tested without the generated filesystem
mkdir -p $basedir/etc/apt/apt.conf.d/
mkdir -p $basedir/etc/network
......@@ -100,14 +86,9 @@ EOF
cat << EOF > $basedir/etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp
hwaddress 76:92:d4:85:f3:0f
# This prevents NetworkManager from attempting to use this
# device to connect to wifi, since NM doesn't show which device is which.
# Unfortunately, it still SHOWS the device, just that it's not managed.
iface p2p0 inet manual
EOF
......@@ -133,41 +114,145 @@ console-common console-data/keymap/policy select Select keymap from full list
console-common console-data/keymap/full select en-latin1-nodeadkeys
EOF
if [ ! -e $kernel_dir ]; then
mkdir -p $kernel_dir
cd $kernel_dir
wget https://storage.puri.sm/librem5/binaries/unstable/latest_kernel.tgz
tar -zxf latest_kernel.tgz
rm latest_kernel.tgz
cd $cwd
setup_kernel
cat > $basedir/boot/boot.txt <<EOF
setenv bootargs ''
setenv initrd_high 0xffffffff
a_base=0x10000000
if itest.s x51 == "x\${cpu}" ; then
a_base=0x90000000
elif itest.s x53 == "x\${cpu}"; then
a_base=0x70000000
elif itest.s x6SX == "x\${cpu}" || itest.s x7D == "x\${cpu}"; then
a_base=0x80000000
fi
setexpr a_script \${a_base} + 0x00800000
setexpr a_zImage \${a_base} + 0x00800000
setexpr a_fdt \${a_base} + 0x03000000
setexpr a_ramdisk \${a_base} + 0x03800000
setexpr a_initrd \${a_base} + 0x03a00000
setexpr a_reset_cause_marker \${a_base} + 0x80
setexpr a_reset_cause \${a_base} + 0x84
if itest.s "x" == "x\${board}" ; then
echo "!!!! Error: Your u-boot is outdated. Please upgrade.";
exit;
fi
cp -r $kernel_dir/* $basedir
dtbname=${fdt_file}
cat > $basedir/boot/boot.txt <<EOF
setenv mmcroot /dev/mmcblk0p1 ro
setenv mmcrootfstype ext4 rootwait fixrtc
if load \${dtype} \${disk}:1 \${a_script} uEnv.txt ; then
env import -t \${a_script} \${filesize}
fi
setenv console ttymxc0,115200n8
if itest.s x == x\${bootdir} ; then
bootdir=/
fi
setenv kernel_file /boot/$kernel
setenv fdtfile /boot/dtbs/$fdt_file
if itest.s x\${bootpart} == x ; then
bootpart=1
fi
setenv loadaddr 0x70010000
setenv fdtaddr 0x71ff0000
if load \${dtype} \${disk}:\${bootpart} \${a_fdt} \${bootdir}dtbs/\${dtbname} ; then
fdt addr \${a_fdt}
setenv fdt_high 0xffffffff
else
echo "!!!! Error loading \${bootdir}dtbs/\${dtbname}";
exit;
fi
setenv initrd_high 0xffffffff
setenv fdt_high 0xffffffff
fdt resize
if itest.s "x" != "x\${cmd_custom}" ; then
run cmd_custom
fi
setenv loadkernel load mmc \${mmcdev}:\${mmcpart} \${loadaddr} \${kernel_file}
setenv loadinitrd load mmc \${mmcdev}:\${mmcpart} \${initrd_addr} \${initrd_file}; setenv initrd_size \${filesize}
setenv loadfdt load mmc \${mmcdev}:\${mmcpart} \${fdtaddr} \${fdtfile}
## HDMI ##
if itest.s "xoff" == "x\$fb_hdmi" ; then
setenv bootargs \$bootargs video=HDMI-A-1:d
else
if itest.s "x" != "x\$force_edid" ; then
echo "------ forcing EDID to /lib/firmware/\$force_edid"
setenv bootargs \$bootargs drm_kms_helper.edid_firmware=\$force_edid
fi
fi
setenv loadfiles run loadkernel; run loadfdt
setenv mmcargs setenv bootargs console=tty0 console=\${console} root=\${mmcroot} rootfstype=\${mmcrootfstype}
## LVDS ##
if itest.s "xoff" == "x\$fb_lvds" ; then
setenv bootargs \$bootargs video=LVDS-1:d
elif itest.s "xhannstar7" == "x\$fb_lvds" ; then
fdt set /panel-lvds0 compatible "hannstar,hsd070pww1"
elif itest.s "xtm070jdhg30" == "x\$fb_lvds" ; then
fdt set /panel-lvds0 compatible "tianma,tm070jdhg30"
elif itest.s "xdt070btft" == "x\$fb_lvds" ; then
fdt set /panel-lvds0 compatible "innolux,zj070na-01p"
fi
run loadfiles; run mmcargs; bootz \${loadaddr} - \${fdtaddr}
if itest.s "xoff" == "x\$fb_lvds2" ; then
setenv bootargs \$bootargs video=LVDS-2:d
elif itest.s "xhannstar7" == "x\$fb_lvds2" ; then
fdt set /panel-lvds1 compatible "hannstar,hsd070pww1"
elif itest.s "xtm070jdhg30" == "x\$fb_lvds2" ; then
fdt set /panel-lvds1 compatible "tianma,tm070jdhg30"
elif itest.s "xdt070btft" == "x\$fb_lvds2" ; then
fdt set /panel-lvds1 compatible "innolux,zj070na-01p"
fi
## LCD ##
if itest.s "xoff" == "x\$fb_lcd" ; then
setenv bootargs \$bootargs video=VGA-1:d
fi
if itest.s x\${rfspart} == x ; then
rfspart=2
fi
if itest.s "x" == "x\${root}"; then
part uuid \${dtype} \${disk}:\${rfspart} uuid
if itest.s "x" != "x\${uuid}"; then
root=PARTUUID=\${uuid}
elif test "sata" = "\${dtype}" || test "usb" = "\${dtype}" ; then
root=/dev/sda\${rfspart}
else
root=/dev/mmcblk\${disk}p\${rfspart}
fi
fi
if itest.s "x" == "x\$cma" ; then
cma=256M
fi
if itest.s "x" == "x\$vmalloc" ; then
vmalloc=400M
fi
if itest.s "x" != "x\$show_fdt" ; then
fdt print /
fi
if itest.s "x" != "x\$show_env" ; then
printenv
fi
setenv bootargs "\$bootargs console=\${console},115200 vmalloc=\${vmalloc}"
setenv bootargs "\$bootargs cma=\${cma} consoleblank=0 root=\${root} rootwait"
if itest.s "x" != "x\${loglevel}" ; then
setenv bootargs \${bootargs} loglevel=\${loglevel}
fi
if itest *\${a_reset_cause_marker} == 12345678 ; then
setexpr.l reset_cause *\${a_reset_cause}
setenv bootargs \$bootargs reset_cause=0x\${reset_cause}
fi
if load \${dtype} \${disk}:\${bootpart} \${a_zImage} \${bootdir}zImage; then
bootz \${a_zImage} - \${a_fdt}
fi
echo "Error loading kernel image"
EOF
mkimage -A arm -T script -O linux -d $basedir/boot/boot.txt $basedir/boot.scr
mkimage -A arm -T script -O linux -d $basedir/boot/boot.txt $basedir/boot/6x_bootscript
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment