Difference between revisions of "Debian Init Update (PVT)"

From Studio Kousagi Wiki
Jump to: navigation, search
(Copy a u-boot onto the card)
(Copy a u-boot onto the card)
Line 110: Line 110:
 
Once you have u-boot built, you need to place it at the right sector in the card for loading with this command:
 
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=u-boot.imx of=/dev/mmcblk1 seek=2
+
  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.
  
 
==Setup the u-boot script to point to the right filesystem==
 
==Setup the u-boot script to point to the right filesystem==

Revision as of 08:57, 25 March 2015

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.

Disk /dev/mmcblk1: 3965 MB, 3965190144 bytes
1 heads, 16 sectors/track, 484032 cylinders, total 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
Disk identifier: 0x00000000

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk1p1            2048       67583       32768    b  W95 FAT32
/dev/mmcblk1p2           67584     7744511     3838464   83  Linux

Build filesystems

sudo mkfs.ext4 /dev/mmcblk1p2 # make ext4 filesystem on the larger partition
sudo mkfs.vfat /dev/mmcblk1p1 # make FAT filesystem on the boot partition

Mount and bootstrap the filesystem

sudo mount /dev/mmcblk1p2 /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.

Setup the u-boot script to point to the right filesystem

Make sure the kernel args point to the right location for the filesystem you want to use.

/dev/mmcblk0p2 if you're sourcing from the internal microSD card /dev/sda2 if you're going from an external SATA drive

Also note that due to a bug in the pfuze driver boot is more reliable if you turn of early printk.

If you want console output also specify console=ttymxc1,115200 in the bootargs.

The command to generate the u-boot script (just to jog my memory) is

mkimage -T script -C none -n 'Novena Boot Script' -d <scriptname.txt> boot.scr

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.