Difference between revisions of "Novena/Debian Wheezy Bootstrap"

From Studio Kousagi Wiki
Jump to: navigation, search
Line 181: Line 181:
 
sudo qemu-nbd -d /dev/nbd0
 
sudo qemu-nbd -d /dev/nbd0
 
</pre>
 
</pre>
 +
 +
Once the above is done, you will be left with a novena.img file that you can dd to an sdcard.

Revision as of 11:28, 10 July 2014

Debian Wheezy Debootstrap

A VERY ROUGH SET OF INSTRUCTIONS, RUN WITH CARE

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

sudo cp files/usr/sbin/policy-rc.d /mnt/usr/sbin/policy-rc.d
echo root:kosagi | sudo chroot /mnt /usr/sbin/chpasswd

# 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
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.