Changes between Initial Version and Version 1 of ventana/debian


Ignore:
Timestamp:
10/22/2017 05:28:45 AM (7 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ventana/debian

    v1 v1  
     1[[PageOutline]]
     2
     3= Debian on Ventana =
     4Debian Linux can be run on the Ventana Single Board Computers.
     5
     6While 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
     8See 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 ==
     12The 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
     14Debian has been supporting armhf builds since Debian 7 (aka "wheezy"). Prior to that they supported armel (software float for ARMv6 architecture).
     15
     16Requirements:
     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
     22Important 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
     25Steps:
     261. Install pre-requisites:
     27{{{
     28#!bash
     29sudo apt-get install qemu-user-static debootstrap binfmt-support
     30}}}
     31
     322. Perform first stage install of minimal filesystem:
     33{{{
     34#!bash
     35target=rootfs
     36distro=jessie # or wheezy
     37sudo 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
     39sudo cp /usr/bin/qemu-arm-static $target/usr/bin
     40sudo 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
     463. we now have a minimal Debian rootfs - chroot to it and perform the 2nd stage install:
     47{{{
     48#!bash
     49sudo chroot $target
     50# now we are in the chroot
     51distro=jessie
     52export LANG=C
     53# setup second stage
     54/debootstrap/debootstrap --second-stage
     55}}}
     56 * now we have a bootable image of about 265MB
     57
     584. (optinal) configure apt package repos:
     59{{{
     60#!bash
     61cat <<EOT > /etc/apt/sources.list
     62deb http://ftp.uk.debian.org/debian $distro main contrib non-free
     63deb-src http://ftp.uk.debian.org/debian $distro main contrib non-free
     64deb http://ftp.uk.debian.org/debian $distro-updates main contrib non-free
     65deb-src http://ftp.uk.debian.org/debian $distro-updates main contrib non-free
     66deb http://security.debian.org/debian-security $distro/updates main contrib non-free
     67deb-src http://security.debian.org/debian-security $distro/updates main contrib non-free
     68EOT
     69}}}
     70 * you may want to add additional package feeds at this point, depending on your needs
     71
     725. (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
     75apt-get update
     76apt-get install locales dialog
     77dpkg-reconfigure locales
     78}}}
     79
     806. set hostname:
     81{{{
     82#!bash
     83echo myname.mydomain > /etc/hostname
     84}}}
     85
     867. create a  default fstab:
     87{{{
     88#!bash
     89cat <<EOT > /etc/fstab
     90/dev/root            /                    auto       defaults              1  1
     91EOT
     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
     968. set a root passwd so you can login
     97{{{
     98#!bash
     99passwd
     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
     104adduser myuser
     105usermod -a -G tty myuser # add to tty group for tty access
     106usermod -a -G dialout myuser # add to dialout group for UART access
     107usermod -a -G sudo myuser # add to sudo group for root access
     108}}}
     109
     1109. (optional) configure networking:
     111 - wired ethernet with DHCP on eth0
     112{{{
     113#!bash
     114cat <<EOF >> /etc/network/interfaces
     115allow-hotplug eth0
     116iface eth0 inet dhcp
     117
     118EOF
     119}}}
     120 - or static IP:
     121{{{
     122#!bash
     123cat <<EOF >> /etc/network/interfaces
     124allow-hotplug eth0
     125iface eth0 inet static
     126address 192.168.1.1
     127netmask 255.255.255.0
     128gateway 192.168.1.254
     129
     130EOF
     131}}}
     132 - or wireless (requires ~3MB of additional packages):
     133{{{
     134#!bash
     135apt-get install wpasupplicant iw
     136cat << EOF >> /etc/network/interfaces
     137# Wireless interface
     138auto wlan0
     139iface wlan0 inet dhcp
     140        wireless_mode managed
     141        wireless_essid any
     142        wpa-driver nl80211
     143        wpa-conf /etc/wpa_supplicant.conf
     144
     145EOF
     146wpa_passphrase <myssid> <mypass> >> /etc/wpa_supplicant.conf
     147}}}
     148
     14910. enable serial console for imx
     150{{{
     151#!bash
     152echo T0:2345:respawn:/sbin/getty -L ttymxc1 115200 vt100 >> /etc/inittab
     153}}}
     154
     15511. (optional) install some useful packages
     156{{{
     157#!bash
     158apt-get install ntpdate # time sync with ntp server
     159apt-get install openssh-server # ssh server for remote access
     160apt-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
     16512. install a kernel and kernel support (kernel+dtbs+modules+firmware):
     166{{{
     167#!bash
     168cd /
     169wget http://svn.gateworks.com/ventana/images/gateworks-linux-imx6-3.14.48.tar.gz
     170tar -xvf gateworks-linux-imx6-3.14.48.tar.gz
     171depmod $(ls /lib/modules/) # create module dependencies
     172rm 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
     17813. exit the chroot shell and remove files we no longer need
     179{{{
     180#!bash
     181exit
     182sudo rm $target/etc/resolv.conf
     183sudo rm $target/usr/bin/qemu-arm-static
     184}}}
     185
     18614. 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
     189DEVICE=/dev/sdc
     190# unmount all auto-mounted partitions for this device
     191sudo umount ${DEVICE}?
     192# partition disk - single ext partition at 1MiB
     193printf "2048,,L,,\n" | sudo sfdisk -uS ${DEVICE}
     194sync
     195sudo mkfs.ext4 -L rootfs ${DEVICE}1
     196# mount partition (will mount to /media/rootfs/)
     197sudo udisks --mount ${DEVICE}1
     198# copy the root filesystem
     199sudo cp -rupv $target/*  /media/rootfs/
     200# unmount the disk
     201sudo udisks --unmount ${DEVICE}1
     202}}}
     203
     204== See Also ==
     205See 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]