Building Debian (Jessie) Rootfs for Quark

From ESS-WIKI
Revision as of 10:28, 5 January 2018 by Phill.liu (talk | contribs)
Jump to: navigation, search


Host OS Required

Ubuntu 14.04 LTS amd64

All procedures are verified in Ubuntu 14.04 LTS amd64.

Prerequisites

image-full-quark.ext3

extract from prebuilt image pack or build a new one

Building Procedures

first stage

SID=jessie
IMAGE=./image-$SID-quark.ext3
IMAGE_BSP=./image-full-quark.ext3
ROOTFS=~/rootfs
ROOTFS_BSP=~/rootfs_bsp
dd if=/dev/zero of=$IMAGE bs=1M count=1800
sudo mkfs.ext3 -F $IMAGE
mkdir -p $ROOTFS $ROOTFS_BSP
sudo mount -o loop,ro $IMAGE_BSP $ROOTFS_BSP
sudo mount -o loop $IMAGE $ROOTFS
tar cf - -C $ROOTFS_BSP lib/{firmware,modules} | sudo tar xvf - -C $ROOTFS
sudo umount $ROOTFS_BSP
sudo debootstrap --arch=i386 --foreign $SID $ROOTFS
sudo cp /etc/resolv.conf $ROOTFS/etc

second stage

HOME=/root sudo chroot $ROOTFS /bin/bash --login -i
SID=jessie
export LANG=C
/debootstrap/debootstrap --second-stage
cat <<EOT > /etc/apt/sources.list
deb http://ftp.uk.debian.org/debian $SID main contrib non-free
deb-src http://ftp.uk.debian.org/debian $SID main contrib non-free
deb http://ftp.uk.debian.org/debian $SID-updates main contrib non-free
deb-src http://ftp.uk.debian.org/debian $SID-updates main contrib non-free
deb http://security.debian.org/debian-security $SID/updates main contrib non-free
deb-src http://security.debian.org/debian-security $SID/updates main contrib non-free
EOT
apt-get update
apt-get install locales dialog
dpkg-reconfigure locales
dpkg-reconfigure tzdata
apt-get install ntpdate
sed -i "s/^root:[^:]\+:/root::/" /etc/shadow
echo "quark" > /etc/hostname
cat >> /etc/network/interfaces << EOT

auto eth0
iface eth0 inet dhcp
EOT

sed -i '/# "\\e\[5~": history/s/^# "\\e\[5~"/"\\e\[A"/' /etc/inputrc
sed -i '/# "\\e\[6~": history/s/^# "\\e\[6~"/"\\e\[B"/' /etc/inputrc
sed -i '/^# .*dircolors/s/^# //; /^# .*LS_OPTIONS/s/^# //;' /root/.bashrc
sed -i "s/\xf0\x0f\xb1\x8b/\x90\x0f\xb1\x8b/g" /lib/i386-linux-gnu/libpthread-2.19.so
sed -i '/\[Service\]/a Environment="TERM=xterm"' "/lib/systemd/system/serial-getty@.service"
logout

post-config

sudo rm $ROOTFS/etc/resolv.conf
sudo umount $ROOTFS

sdcard\boot\grub\grub.conf 

default <span style="color:#FF0000;">2</span>
timeout 5

color white/blue white/cyan

title Quark X1000 kernel-SPI initrd-SPI IMR-On IO-APIC/HPET NoEMU
    kernel --spi root=/dev/ram0 console=ttyS1,115200n8 earlycon=uart8250,mmio32,$EARLY_CON_ADDR_REPLACE,115200n8 reboot=efi,warm apic=debug rw
    initrd --spi

title Quark X1000 kernel-MassStorage iot-devkit on SD IMR-On IO-APIC/HPET NoEMU debug
    root (hd0,0)
    kernel /bzImage root=/dev/mmcblk0p2 rootwait console=ttyS1,115200n8 earlycon=uart8250,mmio32,$EARLY_CON_ADDR_REPLACE,115200n8 reboot=efi,warm apic=debug rw LABEL=boot debugshell=5

title Quark X1000 kernel-MassStorage initrd-MassStorage RootFS-MassStorage IMR-On IO-APIC/HPET NoEMU debug
    root (hd0,0)
    kernel /bzImage root=/dev/ram0 console=ttyS1,115200n8 earlycon=uart8250,mmio32,$EARLY_CON_ADDR_REPLACE,115200n8 reboot=efi,warm apic=debug rw LABEL=boot debugshell=5 <span style="background-color:#FFFF00;">rootimage=image-full-quark.ext3</span>
    initrd /core-image-minimal-initramfs-quark.cpio.gz