Debian Init Update (PVT)
Contents
- 1 Bootstrapping Debian
- 1.1 Make partitions
- 1.2 Build filesystems
- 1.3 Mount and bootstrap the filesystem
- 1.4 Add Kosagi package server
- 1.5 Set a password
- 1.6 FIXME Install novena-eeprom
- 1.7 Add SDMA firmware
- 1.8 Enable login via console
- 1.9 Enable eth0 interface
- 1.10 Copy a kernel and device tree onto the card
- 1.11 Copy a u-boot onto the card
- 1.12 Boot into the native environment
- 1.13 Configure your machine type
- 1.14 Run tasksel to populate packages
- 1.15 Add packages
Bootstrapping Debian
Assumes you are initializing a single SD card for booting. You can also do SD card + SATA SSD, the procedure is similar except the boot partition is on the SD card and the data partition on the SSD. It's recommended to still keep the VFAT boot partition on the SSD even though it's not used at the moment, for forward compatibility reasons.
Assumes you have a debian host (in particular, another Novena...) to bootstrap a new card first.
Make partitions
Build two partitions. Partition 1 should be 32M in size and of type W95 FAT32 and holds the kernel and device tree. Partition 2 should fill the rest of the disk and should be type Linux. The card signature should be 'NovM' for an MMC card, and 'NovS' for an SSD.
xobs@xobs-novena-laptop:~/Code/kernels/linux-dev$ sudo fdisk /dev/mmcblk0 Welcome to fdisk (util-linux 2.25.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): x Expert command (m for help): i Enter the new disk identifier: 0x4e6f764d Disk identifier changed from 0x00000000 to 0x4e6f764d. Expert command (m for help): r Command (m for help): p Disk /dev/mmcblk0: 3.7 GiB, 3965190144 bytes, 7744512 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x4e6f764d Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 2048 67583 65536 32M b W95 FAT32 /dev/mmcblk0p2 67584 133119 65536 32M 82 Linux swap / Solaris /dev/mmcblk0p3 133120 7744511 7611392 3.6G 83 Linux Command (m for help): w
Build filesystems
sudo mkfs.ext4 /dev/mmcblk1p3 # make ext4 filesystem on the larger partition sudo mkswap /dev/mmcblk1p2 # make small swap partition sudo mkfs.vfat /dev/mmcblk1p1 # make FAT filesystem on the boot partition
Mount and bootstrap the filesystem
sudo mount /dev/mmcblk1p3 /mnt
sudo debootstrap wheezy /mnt http://bunniefoo.com/debian # replace URL with your favorite mirror
Several minutes pass. You become sleepy.
Add Kosagi package server
While you are waiting, you grab these files:
wget http://bunniefoo.com/novena/debian/sources.list # contains the bunniefoo mirror for novena local packages wget http://bunniefoo.com/novena/debian/trusted.gpg # contains public keys
These contain links so you can grab the novena-specific packages, which for now we're serving as we're still in development mode.
Once debian is done initializing the filesystem, install the new sources and key files:
sudo cp ./sources.list /mnt/etc/apt/ sudo cp ./trusted.gpg /mnt/etc/apt/
If you need to add keys, run this:
wget -q http://ftp-master.debian.org/keys/archive-key-7.0.asc -O- | sudo apt-key add -
Now run an update to grab the new packages, but in a chroot environment:
sudo chroot /mnt apt-get update
Set a password
You should probably set a root password on the new image. Make sure you don't forget to chroot or else you'll set it on your own machine!
sudo chroot /mnt/ passwd
FIXME Install novena-eeprom
novena-eeprom is a utility to manipulate the hardware configuration template stored in the on-board EEPROM. As of the writing of this guide, novena-eeprom is not yet a package in debian. That's why this section is a FIXME. It's quite possible by the time you read this, this step will be fixed.
wget http://bunniefoo.com/novena/debian/novena-eeprom
chmod a+x novena-eeprom
sudo cp novena-eeprom /mnt/usr/sbin/
Add SDMA firmware
sudo chroot /mnt/ apt-get install imx-sdma-firmware
You will need this to boot.
Enable login via console
sudo emacs /mnt/etc/inittab # or whatever your favorite editor is
Add this to the end of the file:
T1:2345:respawn:/sbin/getty -L ttymxc1 115200 vt100
Enable eth0 interface
Edit /mnt/etc/network/interfaces and add the following lines:
# The primary network interface allow-hotplug eth0 iface eth0 inet dhcp
Edit /mnt/etc/udev/rules.d/70-persistent-net.rules and add the following lines:
# Unknown net device (/devices/soc0/soc.0/2100000.aips-bus/2188000.ethernet/net/eth0) (fec) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:22:c6:87:72:06", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
Copy a kernel and device tree onto the card
The kernel and device tree are a bit of a moving target at the moment, so no link is provided; but basically, you need a boot.scr, a uImage, and a uImage.dtb file on the win32 partition of the card.
You can build your own kernel by following directions here: http://www.kosagi.com/w/index.php?title=Building_novena_firmware#Making_kernel_changes
Copy a u-boot onto the card
You'll need a u-boot. You can build from source
Once you have u-boot built, you need to place it at the right sector in the card for loading with this command:
sudo dd if=SPL of=/dev/mmcblk1 seek=2
Then, copy u-boot.img to the first partition of the SD card. Make sure the partition is formatted as FAT.
Boot into the native environment
Install the initialized card into the target platform, and boot it. It should come up to a shell.
But wait, you're not done yet. Make sure you have a net connection on the target and you'll need to execute the following commands on the *new* machine.
Configure your machine type
Configure the hardware options using novena-eeprom. You will also need to set a MAC address for eth0 if you want to use it, and a serial number.
The recommended options are es8328,retina,pcie,gbit,hdmi
Run tasksel to populate packages
Then, run
tasksel
to configure the machine beyond the basic debian minimum.
Add packages
Here's some recommended packages:
sudo apt-get install build-essential openssh-server
You'll want systemd so login prompt comes faster (e.g. scripts are blocking the console login). You'll want SSH so you can log into your machine via net. build-essential will be needed for you to compile stuff.
You have to install ssh and systemd from the native environment and not a chroot environment.
From there, the machine is pretty much primed and ready for use.