element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
RIoTboard
  • Products
  • Dev Tools
  • Single-Board Computers
  • RIoTboard
  • More
  • Cancel
RIoTboard
Blog Linux 4.1 + Ubuntu 14.04 on RIoTboard
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join RIoTboard to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Former Member
  • Date Created: 13 Sep 2015 5:15 AM Date Created
  • Views 3903 views
  • Likes 3 likes
  • Comments 14 comments
Related
Recommended

Linux 4.1 + Ubuntu 14.04 on RIoTboard

Former Member
Former Member
13 Sep 2015

Intro

I was inspired by Otto's blog series of getting Debian Linux on the RIoTboard: Linux on the RIoTBoard Part 1: U-Boot. However I need Ubuntu instead.

 

Following are the steps to get a current Linux kernel (4.1) with Ubuntu 14.04 (should work with a more current version one too).

 

Requirements

I used Ubuntu 14.04 x86_64 to implement these instructions (actually it was a Virtual machine on VirtualBox).

 

Install Build dependencies:

sudo apt-get install git build-essential fakeroot kernel-package u-boot-tools lzop zlib1g-dev libncurses5-dev gcc-4.7-arm-linux-gnueabihf
sudo ln -s arm-linux-gnueabihf-gcc-4.7 /usr/bin/arm-linux-gnueabihf-gcc

Please note the specific install of gcc 4.7.  This is because the current version (as of 09/2015) in 14.04 of gcc 4.8 has a bug when building the Linux Kernel.  Feel free to try 4.9 or a fixed 4.8.

The following is needed to chroot to arm based rootfs.

sudo apt-get install qemu-user-static

This is needed to help in the steps to create an sdcard image.

sudo apt-get install qemu-utils kpartx

 

Environment Variables

Here are environment variables used in the scripts that follow.

export ARCH=arm
export CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf-
export RIOT_PATH=~/riotboard
export RIOT_OUTPUT=$RIOT_PATH/output
mkdir -p $RIOT_OUTPUT

 

U-Boot

Here are the steps to build version 2015.07 of U-boot:

cd $RIOT_PATH
wget ftp://ftp.denx.de/pub/u-boot/u-boot-2015.07.tar.bz2
tar xjf u-boot-2015.07.tar.bz2
cd u-boot-2015.07
make riotboard_defconfig
make
cp u-boot.imx $RIOT_OUTPUT/.
cd $RIOT_PATH

If you prefer to use the latest U-Boot or a different version see: SourceCode < U-Boot < DENX

 

Bootscript

The boot.scr is used by U-Boot to give it the boot arguments to pass to the kernel as well as were to find the kernel and DTB.

Please note this script is very basic and needs to know where you will be booting from.  Change the DEVICE= line if you will be booting from eMMC or MicroSD instead.  My eMMC is busted so I have to boot from uSD or SD.

mkdir -p $RIOT_PATH/bootscript
cd $RIOT_PATH/bootscript
# Device 0=SD, 1=MicroSD, 2=eMMC
DEVICE=0
cat <<EOF > bootscript
setenv bootargs console=ttymxc1,115200 nosmp video=mxcfb0:dev=hdmi,1280x720M@60,bpp=32 video=mxcfb1:off fbmem=10M vmalloc=400M rootwait root=/dev/mmcblk0p1
mmc dev $DEVICE
ext4load mmc $DEVICE:1 10800000 /boot/zImage
ext4load mmc $DEVICE:1 16800000 /boot/imx6dl-riotboard.dtb
bootz 10800000 - 16800000
EOF
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "boot script" -d bootscript boot.scr
cp boot.scr $RIOT_OUTPUT/.
cd $RIOT_PATH

 

Kernel

I decided to use a specific released version (i.e. v4.1) of the kernel rather than the tip.  Feel free to change the tag to switch to a different version or remove the -b option if you want to build the tip.  I have not fully tested 4.1 but so far seems to work ok on the RIoTboard.

For detail on each step below see Otto's blog.

cd $RIOT_PATH
git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git -b v4.1
cd linux
make imx_v6_v7_defconfig
# Do this next step if you need to change kernel config.
make menuconfig
# this next step will take a long time.  You can try -j option to parallelize.
make bzImage
mkdir -p $RIOT_OUTPUT/boot
sudo cp arch/arm/boot/zImage $RIOT_OUTPUT/boot/zImage
make dtbs
sudo cp arch/arm/boot/dts/imx6dl-riotboard.dtb $RIOT_OUTPUT/boot/imx6dl-riotboard.dtb
make modules
make modules_install INSTALL_MOD_PATH=$RIOT_OUTPUT
make headers_install INSTALL_HDR_PATH=$RIOT_OUTPUT/usr
cd $RIOT_OUTPUT
tar -czf linux-kernel.tgz boot lib usr
rm -rf boot lib usr

 

Root Filesystem

For the rootfs I decided to start from the official ubuntu release and customize it as opposed to building it completely like Otto showed in his blog for Debian.  You can browse here: Index of /ubuntu-core/releases if you would like to pick a different ubuntu release.  If you do, make sure to use an armhf one and update the customizations below in case they are different for your distro.

Unlike other steps above I am going to break this one down:

Get a starting rootfs

cd $RIOT_PATH
mkdir -p $RIOT_OUTPUT/rootfs
wget http://cdimage.ubuntu.com/ubuntu-core/releases/trusty/release/ubuntu-core-14.04-core-armhf.tar.gz
sudo tar --numeric-owner -xzpf ubuntu-core-14.04-core-armhf.tar.gz -C $RIOT_OUTPUT/rootfs

Customize the rootfs

We will chroot to the arm rootfs to make some of the customizations.

# to enable arm emulation
sudo cp /usr/bin/qemu-arm-static $RIOT_OUTPUT/rootfs/usr/bin/
# to enable dns lookups to work
sudo cp /etc/resolv.conf $RIOT_OUTPUT/rootfs/etc
sudo chroot $RIOT_OUTPUT/rootfs

Do your customizations.  Feel free to adjust the stuff below to your needs.  Please note not all of what I am doing below needs to be done from chroot (e.g the file editing and creations).

# setup a locale
locale-gen en_US en_US.UTF-8
# Install any packages you want that are not in the core rootfs from Ubuntu.com
apt-get -y install openssh-server ntpdate
# Create users. The following adds usr/pw: ubuntu/ubuntu
PASSWD=`openssl passwd -crypt ubuntu`
/usr/sbin/useradd ubuntu -m -s /bin/bash -p $PASSWD
# The stuff below can be done outside of chroot. Just make sure to adjust destination files if you do.
# Enable the user to sudo without the need for pw.
echo -e 'ubuntu\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
# Configure your network
cat <<EOF >> /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
EOF
# Set the hostname
echo riotboard > /etc/hostname
# Enable login from the serial console
cat <<EOF > /etc/init/serial-console.conf
# serial-console - getty
#
# This service maintains a getty on console from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345]

stop on runlevel [!2345]

respawn
exec /sbin/getty -L 115200 ttymxc1 vt100
EOF
#setup fstab to mount the rootfs
echo '/dev/mmcblk0p1  /  auto  errors=remount-ro  0  1' >> /etc/fstab

Clean up apt, exit chroot and remove the chroot setup files

# Clean up apt
apt-get clean
exit
# Clean up files we added to enable chroot and dns
sudo rm $RIOT_OUTPUT/rootfs/usr/bin/qemu-arm-static
sudo rm $RIOT_OUTPUT/rootfs/etc/resolv.conf

 

Bundle up the rootfs:

cd $RIOT_OUTPUT/rootfs
sudo tar -czpf ubuntu-trusty.tgz *
sudo mv ubuntu-trusty.tgz $RIOT_OUTPUT/.

 

Create SD Card Image

Now we create the SD Card image that we will write to an SD card.  You could even write this to the eMMC device (don't forget to change the boot script to load from device 2 if you do this).  If you prefer you can use /dev/sdX instead of sdcard.img below if you want to write direct to the SD card instead of an image first.

cd $RIOT_OUTPUT
# Create a file to hold the disk image
qemu-img create sdcard.img 3600M
# Partition the disk image leaving some room (10mb) for u-boot in front of the first partition.
sfdisk --force -uM sdcard.img << EOF
10,,83
EOF
# create devices from the disk image
sudo kpartx -av sdcard.img
# format the partition. Make sure to use the correct device from the previous command.
mkfs.ext4 -j /dev/mapper/loop0p1
# create a mount point
sudo mkdir -p /mnt/sdcard
# Mount the partition we formatted.
sudo mount -t ext4 /dev/mapper/loop0p1 /mnt/sdcard
# Unpack the root fs and kernel
sudo tar --numeric-owner -C /mnt/sdcard -zxpf ubuntu-trusty.tgz
sudo tar --numeric-owner -C /mnt/sdcard -zxpf linux-kernel.tgz
# Copy the boot script to the top level
sudo cp boot.scr /mnt/sdcard/boot.scr
# Unmount and clean up devices
sudo umount /mnt/sdcard
sudo kpartx -dv sdcard.img
# put u-boot 2 blocks into the disk image.  Don't leave out the notrunc option.
dd if=u-boot.imx of=sdcard.img bs=512 seek=2 conv=notrunc

Now you can use dd or whatever tool you want to write the disk image to an SD card. Eg: sudo dd if=sdcard.img of=/dev/sdd bs=1m

 

Boot your SD Card

Plug the SD Card into the SD card slot.  Set the switches 2,4,5,7 to OFF and the rest to ON to boot from SD.

If you are using a MicroSD, make sure to change the boot script to use device 1 instead of 0 and set the dip switches to 2,4,5,8 OFF and the rest ON.

 

Notes

See Otto's blog post mentioned above for how to use the MfgTool to write the above files to the eMMC flash from Windows as well as more detailed explanations to some of the stuff above..

  • Sign in to reply
  • szempy
    szempy over 10 years ago

    I would like to thank you for this article. I could compile and start up the board with the latest ubuntu.

    Thank you again.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to joesgarage

    If startx is not working then not sure what the problem is.  Any chance it is already running but on a different "display"?  Only thing I could think of is the /etc/init/serial-console.conf file we created as that may be taking over the console.  Try "Ctrl+Alt+F7" when you get the cli login prompt (or other fX keys).  If it does then the serial-console.con file is likely the problem.  You could delete it to see what happens.

    grub is not used by this.  The boot arguments are passed from u-boot to the kernel via the boot script we created.

    Chroot is used to run linux from a different root, in this particular case from the arm based root file system that we are creating.  Since the executables in this root fs are arm binaries and not x86 that is why we had to install qemu-user-static.  So that they run emulated.  That is why we are able to run apt-get install and have it run in arm mode from within the new filesystem we are creating.

    I'll see if in the next week or so I can try to build a gui version.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • joesgarage
    joesgarage over 10 years ago in reply to Former Member

    Hi, 

    no matter what I do - it always boots to TTY1.  I installed your version, then "apt-get update" (worked fine with no errors), then "apt-get -y install openssh-server ntpdate ubuntu-desktop" (this took a LONG time, finished no errors). The system still boots to command line.  I noticed there was no GRUB file so I copied one into /etc/default/grub, thinking this would help boot into GUI - no luck. Then tried to manually start with "startx" - no luck.

    I don't know what to do with the chroot command you mentioned, and just dont know enough about Linux to understand what makes it boot to the GUI.

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to joesgarage

    Hi Joe, lines 1-7 are to boot the riotboard with a base OS that can be used to execute the steps from 9 on.  That base OS comes with the MfgTool and its files are in the "Profiles/MX6DL Linux Update/OS Firmware". In the MfgTool I downloaded that is what the u-boot file was called.  If you like, here is a link to a stripped down version of the MfgTool where I mostly just left the riotboard related files and removed the docs: https://www.dropbox.com/s/hp503ip1jrwpnoa/mfgtools-rel-custom.zip?dl=0 it is only 9.2MB.  The "Profiles/MX6DL Linux Update/OS Firmware/files" folder is empty.  That is were you will have to put the files created in this blog entry.  The ucl2.xml file should already contain the above config.

     

    The ubuntu distribution in my example is VERY basic and command line only.  I tried looking on the cdimage.ubuntu.com site but could not find an arm desktop version of 14.04.  Instead what you could do is in the "Customize Root FS" section above you could install ubuntu-desktop with apt-get once you have chroot.  So the line "apt-get -y install openssh-server ntpdate" would read "apt-get -y install openssh-server ntpdate ubuntu-desktop" instead or you could do that afterwords once you flash the board with my basic version.

     

    One other thing, so that you don't get stuck later.  The file /etc/apt/sources.list in this distribution is very basic.  You will want to uncomment some of the other sources in that file otherwise apt-get will not be able to find software you may be trying to install.  You may even have to do that once you chroot and before installing ubuntu-desktop but not sure as I have not tried that.  Don't forget to apt-get update prior to trying to install anything after editing the sources.list file.

     

    good luck

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • joesgarage
    joesgarage over 10 years ago in reply to Former Member

    Hi,    In line 2 shouldn't it be file ="u-boot-mx6solo-riot.bin"   not riotboard.bin ?

    Also, is this version a full version with a gui interface ? or command line only?

    If command line only, how do one make a version with a GUI ?  I'm very new, trying to work my way thru.

    Thank you in advance.

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
<>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube