wiki:ventana/debian

Version 1 (modified by trac, 7 years ago) ( diff )

--

Debian on Ventana

Debian Linux can be run on the Ventana Single Board Computers.

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 here

See the Gateworks Ventana third party linux page for more details on how to use other linux distor on Ventana.

Build your own Ubuntu rootfs via debootstrap

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.

Debian has been supporting armhf builds since Debian 7 (aka "wheezy"). Prior to that they supported armel (software float for ARMv6 architecture).

Requirements:

  • Linux Ubuntu or Debian System with network connection and sudo permissions
  • 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
  • Ventana target board with bootloader
  • boot device with 300MB+ of free space (micro-SD, USB mass storage, mSATA, 2GB NAND flash)

Important notes:

  • 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.

Steps:

  1. Install pre-requisites:
    sudo apt-get install qemu-user-static debootstrap binfmt-support
    
  1. Perform first stage install of minimal filesystem:
    target=rootfs
    distro=jessie # or wheezy
    sudo debootstrap --arch=armhf --foreign $distro $target
    # copy qemu-arm-static binary for the binfmt packages to find it and copy in resolv.conf from host
    sudo cp /usr/bin/qemu-arm-static $target/usr/bin
    sudo cp /etc/resolv.conf $target/etc
    
    • See https://www.debian.org/releases/ for a list of current Debian releases - Debian has supported armhf since Debian 7 (wheezy)
    • 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
    • the chroot shell below will provide network support (inherited from the host and why we copied /etc/resolv.conf from the host for nameservice)
  1. we now have a minimal Debian rootfs - chroot to it and perform the 2nd stage install:
    sudo chroot $target
    # now we are in the chroot
    distro=jessie
    export LANG=C
    # setup second stage
    /debootstrap/debootstrap --second-stage
    
    • now we have a bootable image of about 265MB
  1. (optinal) configure apt package repos:
    cat <<EOT > /etc/apt/sources.list
    deb http://ftp.uk.debian.org/debian $distro main contrib non-free
    deb-src http://ftp.uk.debian.org/debian $distro main contrib non-free
    deb http://ftp.uk.debian.org/debian $distro-updates main contrib non-free
    deb-src http://ftp.uk.debian.org/debian $distro-updates main contrib non-free
    deb http://security.debian.org/debian-security $distro/updates main contrib non-free
    deb-src http://security.debian.org/debian-security $distro/updates main contrib non-free
    EOT
    
    • you may want to add additional package feeds at this point, depending on your needs
  1. (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)
    apt-get update
    apt-get install locales dialog
    dpkg-reconfigure locales
    
  1. set hostname:
    echo myname.mydomain > /etc/hostname
    
  1. create a default fstab:
    cat <<EOT > /etc/fstab
    /dev/root            /                    auto       defaults              1  1
    EOT
    
    • 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
    • /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
  1. set a root passwd so you can login
    passwd
    
    • 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
      adduser myuser
      usermod -a -G tty myuser # add to tty group for tty access
      usermod -a -G dialout myuser # add to dialout group for UART access
      usermod -a -G sudo myuser # add to sudo group for root access
      
  1. (optional) configure networking:
    • wired ethernet with DHCP on eth0
      cat <<EOF >> /etc/network/interfaces
      allow-hotplug eth0
      iface eth0 inet dhcp
      
      EOF
      
    • or static IP:
      cat <<EOF >> /etc/network/interfaces
      allow-hotplug eth0
      iface eth0 inet static
      address 192.168.1.1
      netmask 255.255.255.0
      gateway 192.168.1.254
      
      EOF
      
    • or wireless (requires ~3MB of additional packages):
      apt-get install wpasupplicant iw
      cat << EOF >> /etc/network/interfaces
      # Wireless interface
      auto wlan0
      iface wlan0 inet dhcp
              wireless_mode managed
              wireless_essid any
              wpa-driver nl80211
              wpa-conf /etc/wpa_supplicant.conf
      
      EOF
      wpa_passphrase <myssid> <mypass> >> /etc/wpa_supplicant.conf
      
  1. enable serial console for imx
    echo T0:2345:respawn:/sbin/getty -L ttymxc1 115200 vt100 >> /etc/inittab
    
  1. (optional) install some useful packages
    apt-get install ntpdate # time sync with ntp server
    apt-get install openssh-server # ssh server for remote access
    apt-get install can-utils i2c-tools usbutils pciutils # cmdline tools for various Ventana support
    
    • Note that by default root ssh access is disabled for security. See below for info on enabling it
    • 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 linux/kernel for information on how to select and build a kernel
  1. install a kernel and kernel support (kernel+dtbs+modules+firmware):
    cd /
    wget http://svn.gateworks.com/ventana/images/gateworks-linux-imx6-3.14.48.tar.gz
    tar -xvf gateworks-linux-imx6-3.14.48.tar.gz
    depmod $(ls /lib/modules/) # create module dependencies
    rm gateworks-linux-imx6-3.14.48.tar.gz
    
    • you can either download a pre-built kernel tarball or build one yourself with features you desire - see linux/kernel for more info
    • 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
    • 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
  1. exit the chroot shell and remove files we no longer need
    exit
    sudo rm $target/etc/resolv.conf
    sudo rm $target/usr/bin/qemu-arm-static
    
  1. 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:
    DEVICE=/dev/sdc
    # unmount all auto-mounted partitions for this device
    sudo umount ${DEVICE}?
    # partition disk - single ext partition at 1MiB
    printf "2048,,L,,\n" | sudo sfdisk -uS ${DEVICE}
    sync
    sudo mkfs.ext4 -L rootfs ${DEVICE}1
    # mount partition (will mount to /media/rootfs/)
    sudo udisks --mount ${DEVICE}1
    # copy the root filesystem
    sudo cp -rupv $target/*  /media/rootfs/
    # unmount the disk
    sudo udisks --unmount ${DEVICE}1
    

See Also

See Also:

Note: See TracWiki for help on using the wiki.