Difference between revisions of "Novena/Debian Wheezy Bootstrap"

From Studio Kousagi Wiki
Jump to: navigation, search
 
(7 intermediate revisions by one other user not shown)
Line 2: Line 2:
  
 
'''A VERY ROUGH SET OF INSTRUCTIONS, RUN WITH CARE'''
 
'''A VERY ROUGH SET OF INSTRUCTIONS, RUN WITH CARE'''
 +
 +
See https://github.com/qbcode/novena-baseimage
  
 
This set of instructions assumes you have a functioning Novena board with Debian Wheezy. These instructions are primarily for people who want to re-create the firmware/base image. It relies on various bits and pieces of information on this wiki.
 
This set of instructions assumes you have a functioning Novena board with Debian Wheezy. These instructions are primarily for people who want to re-create the firmware/base image. It relies on various bits and pieces of information on this wiki.
Line 31: Line 33:
  
 
=== Steps ===
 
=== Steps ===
 +
 +
Be logged in as yourself.
  
 
Install at least these things...
 
Install at least these things...
Line 37: Line 41:
 
sudo apt-get install -y qemu-utils apt-cacher-ng build-essential less rsync lzop u-boot-tools git debhelper bc device-tree-compiler parted
 
sudo apt-get install -y qemu-utils apt-cacher-ng build-essential less rsync lzop u-boot-tools git debhelper bc device-tree-compiler parted
 
</pre>
 
</pre>
 +
 +
Generate a new boot script...
 +
 +
<pre>
 +
mkimage -A arm -O linux -a 0 -e 0 -T script -C none -n "Boot script" -d boot.script boot.scr
 +
</pre>
 +
 +
Where boot.script contains this...
 +
 +
<pre>
 +
mmc dev 1
 +
if fatload mmc 1 0x12000000 uImage
 +
then
 +
fatload mmc 1 0x11ff0000 uImage.dtb
 +
setenv bootargs console=${console},${baudrate} root=${mmcroot}
 +
setenv bootargs console=ttymxc1,115200 earlyprintk root=/dev/mmcblk1p2 rootwait rootfstype=ext4 splash consoleblank=0
 +
else
 +
mmc dev 0
 +
fatload mmc 0 0x12000000 uImage
 +
fatload mmc 0 0x11ff0000 uImage.dtb
 +
setenv bootargs console=ttymxc1,115200 earlyprintk root=/dev/mmcblk0p2 rootwait rootfstype=ext4 splash consoleblank=0
 +
fi
 +
 +
fdt addr 0x11ff0000; run prep_gbit; run prep_pcie; run prep_senoko; run prep_es8328; run prep_retina; run prep_pixelqi; run prep_hdmi
 +
 +
bootm 0x12000000 - 0x11ff0000
 +
</pre>
 +
 +
Generate the boot loader
 +
 +
<pre>
 +
git clone https://github.com/sutajiokousagi/u-boot-imx6.git
 +
cd u-boot-imx6 && make novena_config && make
 +
</pre>
 +
 +
Generate the kernel image
 +
 +
<pre>
 +
git clone https://github.com/xobs/novena-linux.git
 +
cd novena-linux && git checkout v3.16-rc2-novena && make novena_defconfig && make uImage LOADADDR=10008000 -j 4 && make ARCH=arm imx6q-novena.dtb
 +
</pre>
 +
 +
Generate the kernel debian packages with this shell script (run this in the novena-linux repo on the right branch)
 +
 +
<pre>
 +
#!/bin/sh
 +
make -j4 \
 +
LOADADDR=0x10008000 \
 +
LD=gold \
 +
KBUILD_DEBARCH=armhf \
 +
KBUILD_IMAGE=uImage \
 +
KBUILD_DTB=imx6q-novena.dtb \
 +
KDEB_PKGVERSION=1.2 \
 +
EMAIL="xobs@kosagi.com" \
 +
NAME="Sean Cross" \
 +
dtbs || exit 1
 +
make -j4 \
 +
LOADADDR=0x10008000 \
 +
LD=gold \
 +
KBUILD_DEBARCH=armhf \
 +
KBUILD_IMAGE=uImage \
 +
KBUILD_DTB=imx6q-novena.dtb \
 +
KDEB_PKGVERSION=1.2 \
 +
EMAIL="xobs@kosagi.com" \
 +
NAME="Sean Cross" \
 +
deb-pkg
 +
</pre>
 +
 +
Here's is a run down of all the steps needed to generate a base image
 +
 +
<pre>
 +
# create image, then map it to a nbd, create and format partitions
 +
qemu-img create novena.img 4G
 +
# might need this
 +
# sudo modprobe nbd max_part=16
 +
sudo qemu-nbd --connect=/dev/nbd0 novena.img
 +
sudo parted --script /dev/nbd0 -- mklabel msdos
 +
# there might be alignment issues -- need to test
 +
sudo parted --script /dev/nbd0 -- mkpart primary fat32 1 64
 +
#sudo parted --script /dev/nbd0 -- mkpart primary fat32 0 64
 +
sudo parted --script /dev/nbd0 -- mkpart primary ext4 64 -0
 +
#sudo parted --script /dev/nbd0 -- set 1 boot on
 +
sudo mkfs.ext4 /dev/nbd0p2
 +
sudo mkfs.vfat /dev/nbd0p1
 +
 +
# mount the ext4 partition
 +
sudo mount /dev/nbd0p2 /mnt
 +
 +
# use local apt-cacher-ng proxy
 +
sudo debootstrap --include=sudo,openssh-server,ntpdate,dosfstools,sysvinit,fbset,less,xserver-xorg-video-modesetting,task-xfce-desktop,hicolor-icon-theme,gnome-icon-theme,tango-icon-theme,i3-wm,i3status wheezy /mnt http://127.0.0.1:3142/ftp.ie.debian.org/debian/
 +
 +
# basic configuration
 +
 +
sudo mount --bind /dev/ /mnt/dev
 +
sudo mount --bind /dev/pts /mnt/dev/pts
 +
sudo chroot /mnt mount -t proc none /proc
 +
sudo chroot /mnt mount -t sysfs none /sys
 +
</pre>
 +
 +
policy-rc.d contains this
 +
<pre>
 +
#!/bin/sh
 +
echo "All runlevel operations denied by policy" >&2
 +
exit 101
 +
</pre>
 +
 +
<pre>
 +
sudo cp files/usr/sbin/policy-rc.d /mnt/usr/sbin/policy-rc.d
 +
echo root:kosagi | sudo chroot /mnt /usr/sbin/chpasswd
 +
</pre>
 +
 +
hostname contains this
 +
<pre>
 +
novena
 +
</pre>
 +
 +
 +
hosts contains this
 +
<pre>
 +
127.0.0.1 localhost
 +
::1 localhost ip6-localhost ip6-loopback
 +
fe00::0 ip6-localnet
 +
ff00::0 ip6-mcastprefix
 +
ff02::1 ip6-allnodes
 +
ff02::2 ip6-allrouters
 +
</pre>
 +
 +
fstab contains this
 +
<pre>
 +
/dev/mmcblk0p2      /                    ext4      noatime,nodiratime,errors=remount-ro    0  1
 +
proc                /proc                proc      defaults                      0  0
 +
devpts              /dev/pts            devpts    mode=0620,gid=5              0  0
 +
tmpfs                /tmp                tmpfs      defaults                      0  0
 +
/dev/mmcblk0p1      /boot/bootloader    vfat      defaults                      2  2
 +
</pre>
 +
 +
interfaces contains this
 +
<pre>
 +
auto lo
 +
iface lo inet loopback
 +
 +
# The primary network interface
 +
allow-hotplug eth0
 +
iface eth0 inet dhcp
 +
</pre>
 +
 +
sources.list contains this
 +
<pre>
 +
deb http://ftp.ie.debian.org/debian/ wheezy main
 +
deb-src http://ftp.ie.debian.org/debian/ wheezy main
 +
 +
deb http://ftp.ie.debian.org/debian/ wheezy-updates main
 +
deb-src http://ftp.ie.debian.org/debian/ wheezy-updates main
 +
 +
deb http://security.debian.org/ wheezy/updates main
 +
deb-src http://security.debian.org/ wheezy/updates main
 +
 +
deb http://ftp.ie.debian.org/debian wheezy-backports main
 +
deb-src http://ftp.ie.debian.org/debian wheezy-backports main
 +
</pre>
 +
 +
kosagi.list contains this
 +
<pre>
 +
deb http://bunniefoo.com/kosagi-deb wheezy main
 +
deb-src http://bunniefoo.com/kosagi-deb wheezy main
 +
</pre>
 +
 +
<pre>
 +
# install some basic things needed to kick of the networking etc...
 +
sudo cp files/hostname /mnt/etc/hostname
 +
sudo cp files/hosts /mnt/etc/hosts
 +
sudo cp files/fstab /mnt/etc/fstab
 +
sudo cp files/network/interfaces /mnt/etc/network/interfaces
 +
sudo cp files/etc/apt/sources.list.d/kosagi.list /mnt/etc/apt/sources.list.d/kosagi.list
 +
sudo cp files/etc/apt/sources.list /mnt/etc/apt/sources.list
 +
sudo cp files/kosagi.gpg.key /mnt/root/kosagi.gpg.key
 +
sudo chroot /mnt apt-key add /root/kosagi.gpg.key
 +
sudo chroot /mnt apt-get update -y
 +
sudo chroot /mnt env DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_FRONTEND=noninteractive apt-get install -y imx-sdma-firmware
 +
sudo chroot /mnt apt-get clean -y
 +
 +
sudo cp binaries/*.deb  /mnt/root
 +
sudo chroot /mnt dpkg -i /root/linux-firmware-image-3.16.0-rc2-28074-g8b39edb_1.2_armhf.deb
 +
sudo chroot /mnt dpkg -i /root/linux-image-3.16.0-rc2-28074-g8b39edb_1.2_armhf.deb
 +
sudo chroot /mnt dpkg -i /root/linux-headers-3.16.0-rc2-28074-g8b39edb_1.2_armhf.deb
 +
 +
sudo rm /mnt/usr/sbin/policy-rc.d
 +
</pre>
 +
 +
xorg.conf contains this
 +
<pre>
 +
Section "Device"
 +
Identifier "novena"
 +
Driver "modesetting"
 +
Option "kmsdev" "/dev/dri/card0"
 +
Option "SWCursor" "true"
 +
# the below is needed for Jessie
 +
#BusID "platform:/sys/devices/soc0/display-subsystem/drm/card0"
 +
EndSection
 +
</pre>
 +
 +
inittab is a stock config with this at the bottom
 +
<pre>
 +
T1:2345:respawn:/sbin/getty -L ttymxc1 115200 vt100
 +
</pre>
 +
 +
 +
<pre>
 +
sudo mkdir -p /mnt/etc/X11
 +
sudo cp files/etc/X11/xorg.conf /mnt/etc/X11/xorg.conf
 +
sudo cp files/etc/inittab /mnt/etc/inittab
 +
sudo cp files/etc/default/locale /mnt/etc/default/locale
 +
 +
# setup boot loader
 +
sudo mkdir -p /mnt/boot/bootloader
 +
sudo mount /dev/nbd0p1 /mnt/boot/bootloader
 +
sudo cp binaries/uImage /mnt/boot/bootloader/uImage
 +
sudo cp binaries/imx6q-novena.dtb /mnt/boot/bootloader/uImage.dtb
 +
sudo cp boot.scr  /mnt/boot/bootloader/boot.scr
 +
 +
sudo chroot /mnt umount /proc
 +
sudo chroot /mnt umount /sys
 +
sudo umount /mnt/dev/pts
 +
sudo umount /mnt/dev
 +
 +
sudo umount /mnt/boot/bootloader
 +
sudo umount /mnt
 +
sudo dd if=binaries/u-boot.imx of=/dev/nbd0 seek=2 bs=512 conv=notrunc
 +
sudo qemu-nbd -d /dev/nbd0
 +
</pre>
 +
 +
Once the above is done, you will be left with a novena.img file that you can dd to an sdcard.

Latest revision as of 06:47, 12 October 2014

Debian Wheezy Debootstrap

A VERY ROUGH SET OF INSTRUCTIONS, RUN WITH CARE

See https://github.com/qbcode/novena-baseimage

This set of instructions assumes you have a functioning Novena board with Debian Wheezy. These instructions are primarily for people who want to re-create the firmware/base image. It relies on various bits and pieces of information on this wiki.

Prerequisites

  • An existing Novena board running Debian Wheezy .
  • Root access on your board, ideally have sudo access with no password.
  • A 4gb microsd card.
  • A reasonably fast network connection.
  • Approximately 10gigs of free diskspace (more is probably better so you can cache things during testing/dev) - ideally get a SSD plugged into the board.
  • Assumes 'you as a user' has tried building a linux kernel, u-boot etc...
    • i.e. we assume you have generated the kernel debian packages, uImage, uImage.dtb, the relevant boot loader and boot scripts.

Summary

Steps

Be logged in as yourself.

Install at least these things...

sudo apt-get install -y qemu-utils apt-cacher-ng build-essential less rsync lzop u-boot-tools git debhelper bc device-tree-compiler parted

Generate a new boot script...

mkimage -A arm -O linux -a 0 -e 0 -T script -C none -n "Boot script" -d boot.script boot.scr

Where boot.script contains this...

mmc dev 1
if fatload mmc 1 0x12000000 uImage
then
	fatload mmc 1 0x11ff0000 uImage.dtb
	setenv bootargs console=${console},${baudrate} root=${mmcroot}
	setenv bootargs console=ttymxc1,115200 earlyprintk root=/dev/mmcblk1p2 rootwait rootfstype=ext4 splash consoleblank=0
else
	mmc dev 0
	fatload mmc 0 0x12000000 uImage
	fatload mmc 0 0x11ff0000 uImage.dtb
	setenv bootargs console=ttymxc1,115200 earlyprintk root=/dev/mmcblk0p2 rootwait rootfstype=ext4 splash consoleblank=0
fi

fdt addr 0x11ff0000; run prep_gbit; run prep_pcie; run prep_senoko; run prep_es8328; run prep_retina; run prep_pixelqi; run prep_hdmi

bootm 0x12000000 - 0x11ff0000

Generate the boot loader

git clone https://github.com/sutajiokousagi/u-boot-imx6.git
cd u-boot-imx6 && make novena_config && make

Generate the kernel image

git clone https://github.com/xobs/novena-linux.git
cd novena-linux && git checkout v3.16-rc2-novena && make novena_defconfig && make uImage LOADADDR=10008000 -j 4 && make ARCH=arm imx6q-novena.dtb

Generate the kernel debian packages with this shell script (run this in the novena-linux repo on the right branch)

#!/bin/sh
make -j4 \
	LOADADDR=0x10008000 \
	LD=gold \
	KBUILD_DEBARCH=armhf \
	KBUILD_IMAGE=uImage \
	KBUILD_DTB=imx6q-novena.dtb \
	KDEB_PKGVERSION=1.2 \
	EMAIL="xobs@kosagi.com" \
	NAME="Sean Cross" \
	dtbs || exit 1
make -j4 \
	LOADADDR=0x10008000 \
	LD=gold \
	KBUILD_DEBARCH=armhf \
	KBUILD_IMAGE=uImage \
	KBUILD_DTB=imx6q-novena.dtb \
	KDEB_PKGVERSION=1.2 \
	EMAIL="xobs@kosagi.com" \
	NAME="Sean Cross" \
	deb-pkg

Here's is a run down of all the steps needed to generate a base image

# create image, then map it to a nbd, create and format partitions
qemu-img create novena.img 4G
# might need this
# sudo modprobe nbd max_part=16
sudo qemu-nbd --connect=/dev/nbd0 novena.img
sudo parted --script /dev/nbd0 -- mklabel msdos
# there might be alignment issues -- need to test
sudo parted --script /dev/nbd0 -- mkpart primary fat32 1 64
#sudo parted --script /dev/nbd0 -- mkpart primary fat32 0 64
sudo parted --script /dev/nbd0 -- mkpart primary ext4 64 -0
#sudo parted --script /dev/nbd0 -- set 1 boot on
sudo mkfs.ext4 /dev/nbd0p2
sudo mkfs.vfat /dev/nbd0p1

# mount the ext4 partition
sudo mount /dev/nbd0p2 /mnt

# use local apt-cacher-ng proxy
sudo debootstrap --include=sudo,openssh-server,ntpdate,dosfstools,sysvinit,fbset,less,xserver-xorg-video-modesetting,task-xfce-desktop,hicolor-icon-theme,gnome-icon-theme,tango-icon-theme,i3-wm,i3status wheezy /mnt http://127.0.0.1:3142/ftp.ie.debian.org/debian/

# basic configuration

sudo mount --bind /dev/ /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo chroot /mnt mount -t proc none /proc
sudo chroot /mnt mount -t sysfs none /sys

policy-rc.d contains this

#!/bin/sh
echo "All runlevel operations denied by policy" >&2
exit 101
sudo cp files/usr/sbin/policy-rc.d /mnt/usr/sbin/policy-rc.d
echo root:kosagi | sudo chroot /mnt /usr/sbin/chpasswd

hostname contains this

novena


hosts contains this

127.0.0.1	localhost
::1		localhost ip6-localhost ip6-loopback
fe00::0		ip6-localnet
ff00::0		ip6-mcastprefix
ff02::1		ip6-allnodes
ff02::2		ip6-allrouters

fstab contains this

/dev/mmcblk0p2       /                    ext4       noatime,nodiratime,errors=remount-ro     0  1
proc                 /proc                proc       defaults                      0  0
devpts               /dev/pts             devpts     mode=0620,gid=5               0  0
tmpfs                /tmp                 tmpfs      defaults                      0  0
/dev/mmcblk0p1       /boot/bootloader     vfat       defaults                      2  2 

interfaces contains this

auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

sources.list contains this

deb http://ftp.ie.debian.org/debian/ wheezy main
deb-src http://ftp.ie.debian.org/debian/ wheezy main

deb http://ftp.ie.debian.org/debian/ wheezy-updates main
deb-src http://ftp.ie.debian.org/debian/ wheezy-updates main

deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main

deb http://ftp.ie.debian.org/debian wheezy-backports main
deb-src http://ftp.ie.debian.org/debian wheezy-backports main

kosagi.list contains this

deb http://bunniefoo.com/kosagi-deb wheezy main
deb-src http://bunniefoo.com/kosagi-deb wheezy main
# install some basic things needed to kick of the networking etc...
sudo cp files/hostname /mnt/etc/hostname
sudo cp files/hosts /mnt/etc/hosts
sudo cp files/fstab /mnt/etc/fstab
sudo cp files/network/interfaces /mnt/etc/network/interfaces
sudo cp files/etc/apt/sources.list.d/kosagi.list /mnt/etc/apt/sources.list.d/kosagi.list
sudo cp files/etc/apt/sources.list /mnt/etc/apt/sources.list
sudo cp files/kosagi.gpg.key /mnt/root/kosagi.gpg.key
sudo chroot /mnt apt-key add /root/kosagi.gpg.key
sudo chroot /mnt apt-get update -y
sudo chroot /mnt env DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_FRONTEND=noninteractive apt-get install -y imx-sdma-firmware
sudo chroot /mnt apt-get clean -y

sudo cp binaries/*.deb  /mnt/root
sudo chroot /mnt dpkg -i /root/linux-firmware-image-3.16.0-rc2-28074-g8b39edb_1.2_armhf.deb
sudo chroot /mnt dpkg -i /root/linux-image-3.16.0-rc2-28074-g8b39edb_1.2_armhf.deb
sudo chroot /mnt dpkg -i /root/linux-headers-3.16.0-rc2-28074-g8b39edb_1.2_armhf.deb

sudo rm /mnt/usr/sbin/policy-rc.d

xorg.conf contains this

Section "Device"
	Identifier "novena"
	Driver "modesetting"
	Option "kmsdev" "/dev/dri/card0"
	Option "SWCursor" "true"
	# the below is needed for Jessie
	#BusID "platform:/sys/devices/soc0/display-subsystem/drm/card0"
EndSection

inittab is a stock config with this at the bottom

T1:2345:respawn:/sbin/getty -L ttymxc1 115200 vt100


sudo mkdir -p /mnt/etc/X11
sudo cp files/etc/X11/xorg.conf /mnt/etc/X11/xorg.conf
sudo cp files/etc/inittab /mnt/etc/inittab
sudo cp files/etc/default/locale /mnt/etc/default/locale

# setup boot loader
sudo mkdir -p /mnt/boot/bootloader 
sudo mount /dev/nbd0p1 /mnt/boot/bootloader
sudo cp binaries/uImage /mnt/boot/bootloader/uImage
sudo cp binaries/imx6q-novena.dtb /mnt/boot/bootloader/uImage.dtb
sudo cp boot.scr  /mnt/boot/bootloader/boot.scr

sudo chroot /mnt umount /proc
sudo chroot /mnt umount /sys
sudo umount /mnt/dev/pts
sudo umount /mnt/dev

sudo umount /mnt/boot/bootloader
sudo umount /mnt
sudo dd if=binaries/u-boot.imx of=/dev/nbd0 seek=2 bs=512 conv=notrunc
sudo qemu-nbd -d /dev/nbd0

Once the above is done, you will be left with a novena.img file that you can dd to an sdcard.