| 1 | [[PageOutline]] |
| 2 | |
| 3 | = Debian on Ventana = |
| 4 | Debian Linux can be run on the Ventana Single Board Computers. |
| 5 | |
| 6 | While Gateworks cannot fully support all Linux distros, it is relatively simple to overlay a Gateworks Ventana kernel onto any non-Gateworks third party Linux distro rootfs image. For a full list of Linux BSP's for Ventana see [wiki:ventana#bsp here] |
| 7 | |
| 8 | See the Gateworks Ventana [wiki:ventana#third_party_linux third party linux] page for more details on how to use other linux distor on Ventana. |
| 9 | |
| 10 | [=#debootstrap] |
| 11 | == Build your own Ubuntu rootfs via debootstrap == |
| 12 | The preferred way to create a Debian root Filesystem is to use the '''deboostrap''' utility on a Debian or Ubuntu host. This tool provides a 2-stage install where the second stage is within a chroot environment using qemu-arm. |
| 13 | |
| 14 | Debian has been supporting armhf builds since Debian 7 (aka "wheezy"). Prior to that they supported armel (software float for ARMv6 architecture). |
| 15 | |
| 16 | Requirements: |
| 17 | - Linux Ubuntu or Debian System with network connection and sudo permissions |
| 18 | - Linux Kernel (choose either Gateworks latest pre-built 3.14 kernel with full hardware support, a vanilla mainline kernel (missing full video in/out support but more up-to-date), or a kernel of your own) - see below steps for more detail |
| 19 | - Ventana target board with bootloader |
| 20 | - boot device with 300MB+ of free space (micro-SD, USB mass storage, mSATA, 2GB NAND flash) |
| 21 | |
| 22 | Important notes: |
| 23 | * we set and use '''target''' and '''distro''' env variables in step 2 and use those env variables in the remaining steps to make this tutorial more distro-agnostic. Please be aware of this and do not deviate from the steps unless or until you completely understand what you are doing. |
| 24 | |
| 25 | Steps: |
| 26 | 1. Install pre-requisites: |
| 27 | {{{ |
| 28 | #!bash |
| 29 | sudo apt-get install qemu-user-static debootstrap binfmt-support |
| 30 | }}} |
| 31 | |
| 32 | 2. Perform first stage install of minimal filesystem: |
| 33 | {{{ |
| 34 | #!bash |
| 35 | target=rootfs |
| 36 | distro=jessie # or wheezy |
| 37 | sudo debootstrap --arch=armhf --foreign $distro $target |
| 38 | # copy qemu-arm-static binary for the binfmt packages to find it and copy in resolv.conf from host |
| 39 | sudo cp /usr/bin/qemu-arm-static $target/usr/bin |
| 40 | sudo cp /etc/resolv.conf $target/etc |
| 41 | }}} |
| 42 | * See https://www.debian.org/releases/ for a list of current Debian releases - Debian has supported armhf since Debian 7 (wheezy) |
| 43 | * this minimal rootfs is appx 177MB (jessie) however it is still missing some core packages and configuration before it can be booted. These steps are taken care of in a 2nd stage install within a chroot shell |
| 44 | * the chroot shell below will provide network support (inherited from the host and why we copied /etc/resolv.conf from the host for nameservice) |
| 45 | |
| 46 | 3. we now have a minimal Debian rootfs - chroot to it and perform the 2nd stage install: |
| 47 | {{{ |
| 48 | #!bash |
| 49 | sudo chroot $target |
| 50 | # now we are in the chroot |
| 51 | distro=jessie |
| 52 | export LANG=C |
| 53 | # setup second stage |
| 54 | /debootstrap/debootstrap --second-stage |
| 55 | }}} |
| 56 | * now we have a bootable image of about 265MB |
| 57 | |
| 58 | 4. (optinal) configure apt package repos: |
| 59 | {{{ |
| 60 | #!bash |
| 61 | cat <<EOT > /etc/apt/sources.list |
| 62 | deb http://ftp.uk.debian.org/debian $distro main contrib non-free |
| 63 | deb-src http://ftp.uk.debian.org/debian $distro main contrib non-free |
| 64 | deb http://ftp.uk.debian.org/debian $distro-updates main contrib non-free |
| 65 | deb-src http://ftp.uk.debian.org/debian $distro-updates main contrib non-free |
| 66 | deb http://security.debian.org/debian-security $distro/updates main contrib non-free |
| 67 | deb-src http://security.debian.org/debian-security $distro/updates main contrib non-free |
| 68 | EOT |
| 69 | }}} |
| 70 | * you may want to add additional package feeds at this point, depending on your needs |
| 71 | |
| 72 | 5. (optional) update package database and setup locales (do not skip this step if you are needing to install any packages for the steps below or otherwise) |
| 73 | {{{ |
| 74 | #!bash |
| 75 | apt-get update |
| 76 | apt-get install locales dialog |
| 77 | dpkg-reconfigure locales |
| 78 | }}} |
| 79 | |
| 80 | 6. set hostname: |
| 81 | {{{ |
| 82 | #!bash |
| 83 | echo myname.mydomain > /etc/hostname |
| 84 | }}} |
| 85 | |
| 86 | 7. create a default fstab: |
| 87 | {{{ |
| 88 | #!bash |
| 89 | cat <<EOT > /etc/fstab |
| 90 | /dev/root / auto defaults 1 1 |
| 91 | EOT |
| 92 | }}} |
| 93 | * Note that this not required if you pass in 'rw' on the kernel cmdline. However while that is the default for the Ventana bootscripts for removeable storage it is not for NAND boot, therefore we will add a default fstab that will re-mount the kernel mounted rootfs as read-write |
| 94 | * /dev/root in /etc/fstab will refer to the rootfs mounted by the kernel, thus the above entry simply re-mounts rootfs as read-write |
| 95 | |
| 96 | 8. set a root passwd so you can login |
| 97 | {{{ |
| 98 | #!bash |
| 99 | passwd |
| 100 | }}} |
| 101 | - or consider adding a user via {{{adduser myuser}}} but if you do so you will want to install sudo and add this user to the sudo group |
| 102 | {{{ |
| 103 | #!bash |
| 104 | adduser myuser |
| 105 | usermod -a -G tty myuser # add to tty group for tty access |
| 106 | usermod -a -G dialout myuser # add to dialout group for UART access |
| 107 | usermod -a -G sudo myuser # add to sudo group for root access |
| 108 | }}} |
| 109 | |
| 110 | 9. (optional) configure networking: |
| 111 | - wired ethernet with DHCP on eth0 |
| 112 | {{{ |
| 113 | #!bash |
| 114 | cat <<EOF >> /etc/network/interfaces |
| 115 | allow-hotplug eth0 |
| 116 | iface eth0 inet dhcp |
| 117 | |
| 118 | EOF |
| 119 | }}} |
| 120 | - or static IP: |
| 121 | {{{ |
| 122 | #!bash |
| 123 | cat <<EOF >> /etc/network/interfaces |
| 124 | allow-hotplug eth0 |
| 125 | iface eth0 inet static |
| 126 | address 192.168.1.1 |
| 127 | netmask 255.255.255.0 |
| 128 | gateway 192.168.1.254 |
| 129 | |
| 130 | EOF |
| 131 | }}} |
| 132 | - or wireless (requires ~3MB of additional packages): |
| 133 | {{{ |
| 134 | #!bash |
| 135 | apt-get install wpasupplicant iw |
| 136 | cat << EOF >> /etc/network/interfaces |
| 137 | # Wireless interface |
| 138 | auto wlan0 |
| 139 | iface wlan0 inet dhcp |
| 140 | wireless_mode managed |
| 141 | wireless_essid any |
| 142 | wpa-driver nl80211 |
| 143 | wpa-conf /etc/wpa_supplicant.conf |
| 144 | |
| 145 | EOF |
| 146 | wpa_passphrase <myssid> <mypass> >> /etc/wpa_supplicant.conf |
| 147 | }}} |
| 148 | |
| 149 | 10. enable serial console for imx |
| 150 | {{{ |
| 151 | #!bash |
| 152 | echo T0:2345:respawn:/sbin/getty -L ttymxc1 115200 vt100 >> /etc/inittab |
| 153 | }}} |
| 154 | |
| 155 | 11. (optional) install some useful packages |
| 156 | {{{ |
| 157 | #!bash |
| 158 | apt-get install ntpdate # time sync with ntp server |
| 159 | apt-get install openssh-server # ssh server for remote access |
| 160 | apt-get install can-utils i2c-tools usbutils pciutils # cmdline tools for various Ventana support |
| 161 | }}} |
| 162 | * Note that by default root ssh access is disabled for security. See [#ssh below] for info on enabling it |
| 163 | * Note that at this point, prior to exiting the chroot, you could continue to configure your system by adding packages and configuration files. You could even install development tools via the '''build-essential''' meta-package and build and install sources such as the kernel below (adds appx 180MB). See [wiki:linux/kernel#building] for information on how to select and build a kernel |
| 164 | |
| 165 | 12. install a kernel and kernel support (kernel+dtbs+modules+firmware): |
| 166 | {{{ |
| 167 | #!bash |
| 168 | cd / |
| 169 | wget http://svn.gateworks.com/ventana/images/gateworks-linux-imx6-3.14.48.tar.gz |
| 170 | tar -xvf gateworks-linux-imx6-3.14.48.tar.gz |
| 171 | depmod $(ls /lib/modules/) # create module dependencies |
| 172 | rm gateworks-linux-imx6-3.14.48.tar.gz |
| 173 | }}} |
| 174 | * you can either download a pre-built kernel tarball or build one yourself with features you desire - see linux/kernel for more info |
| 175 | * exiting the chroot, you could continue to configure your system by adding packages and configuration files. You could even install development tools via the build-essential meta-package and build and install sources such as the kernel below (adds appx 180MB). See linux/kernel for information on how to select and build a kernel |
| 176 | * the depmod trick above is to run depmod with the exact kernel version (which will be the subdir in /lib/modules). An alternative is to run depmod after the first boot |
| 177 | |
| 178 | 13. exit the chroot shell and remove files we no longer need |
| 179 | {{{ |
| 180 | #!bash |
| 181 | exit |
| 182 | sudo rm $target/etc/resolv.conf |
| 183 | sudo rm $target/usr/bin/qemu-arm-static |
| 184 | }}} |
| 185 | |
| 186 | 14. install to bootable media (ie a block storage device supported by your board such as a USB Mass Storage device, a microSD, an mSATA SSD. There are many choices that could be made here. The example below will create a single ext4 rootfs partition on a removable block storage device. Ensure you set DEVICE properly for your system. We use the 'udisks' application for mount/unmount so that the mount-point is obvious - if you know what your doing you could use standard mount/unmount as well: |
| 187 | {{{ |
| 188 | #!bash |
| 189 | DEVICE=/dev/sdc |
| 190 | # unmount all auto-mounted partitions for this device |
| 191 | sudo umount ${DEVICE}? |
| 192 | # partition disk - single ext partition at 1MiB |
| 193 | printf "2048,,L,,\n" | sudo sfdisk -uS ${DEVICE} |
| 194 | sync |
| 195 | sudo mkfs.ext4 -L rootfs ${DEVICE}1 |
| 196 | # mount partition (will mount to /media/rootfs/) |
| 197 | sudo udisks --mount ${DEVICE}1 |
| 198 | # copy the root filesystem |
| 199 | sudo cp -rupv $target/* /media/rootfs/ |
| 200 | # unmount the disk |
| 201 | sudo udisks --unmount ${DEVICE}1 |
| 202 | }}} |
| 203 | |
| 204 | == See Also == |
| 205 | See Also: |
| 206 | * [wiki:/ventana/ubuntu#gstreamer-imx ventana/ubuntu#gstreamer-imx] - Adding GStreamer IPU/VPU/GPU support to Ubuntu |
| 207 | * [wiki:/ventana/ubuntu#ssh ventana/ubuntu#ssh] - ssh server config |
| 208 | * [https://www.debian.org/distrib/packages Debian Software Repositories] |