element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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 3658 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 4 years ago in reply to zaahir

    Could you boot up ubuntu 18 or a newer version ubuntu than 14?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • zaahir
    zaahir over 6 years ago

    Hi,

    Thanks for your post.

    I am trying to port riotboard linux 4.2 from buildroot build on ubuntu 18.XX. My problem might sound silly but not able to flash compiled uboot image to baord.

    Bootup logs:

    U-Boot 2009.08-00695-g055df3a (Dec 25 2013 - 09:56:12)

    CPU: Freescale i.MX6 family TO1.1 at 792 MHz

    Thermal sensor with ratio = 181

    Temperature:   30 C, calibration data 0x57b5025f

    mx6q pll1: 792MHz

    mx6q pll2: 528MHz

    mx6q pll3: 480MHz

    mx6q pll8: 50MHz

    ipg clock     : 66000000Hz

    ipg per clock : 66000000Hz

    uart clock    : 80000000Hz

    cspi clock    : 60000000Hz

    ahb clock     : 132000000Hz

    axi clock   : 198000000Hz

    emi_slow clock: 99000000Hz

    ddr clock     : 396000000Hz

    usdhc1 clock  : 198000000Hz

    usdhc2 clock  : 198000000Hz

    usdhc3 clock  : 198000000Hz

    usdhc4 clock  : 198000000Hz

    nfc clock     : 24000000Hz

    Board: i.MX6DL/Solo-SABRESD: unknown-board Board: 0x61011 [POR ]

    Boot Device: SD

    I2C:   ready

    DRAM:   1 GB

    MMC:   FSL_USDHC: 0,FSL_USDHC: 1,FSL_USDHC: 2,FSL_USDHC: 3

    In:    serial

    Out:   serial

    Err:   serial

    Net:   got MAC address from IIM: 00:00:00:00:00:00

    ----enet_board_init: phy reset

    FEC0 [PRIME]

    Hit any key to stop autoboot:  0

    mmc1 is current device

    MMC read: dev # 1, block # 2048, count 8192 ... 8192 blocks read: OK

    Wrong Image Format for bootm command

    ERROR: can't get kernel image!

    MX6Solo RIOT U-Boot >

     

     

    It always bootup probably with default(pre-compiled) uboot (Dec 25 2013 - 09:56:12) . Boot device selected is SD card. But not picking new uboot image from SD card.

    Board will bootup even formatted SD card is connected. But board didn't bootup if SD is not connected.

    Not understanding from where its executing uboot image & why? (May be SPI flash.. not sure). How the board will execute new compiled uboot image from SD card.

    Appreciate your comments & feedback.

     

    Thanks,

    Zahir

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • gereds
    gereds over 6 years ago

    Hi,

    Thanks for your very nice post.

    Just a mention, in your description of creating the boot script you should replace line 6:

    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

    with this one:

    setenv bootargs console=ttymxc1,115200 nosmp video=mxcfb0:dev=hdmi,1280x720M@60,bpp=32 video=mxcfb1:off fbmem=10M vmalloc=400M rootwait root=/dev/mmcblk${DEVICE}p1

     

    Thank you

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • epsylon67
    epsylon67 over 7 years ago

    You shoud download the basic rootfs http://s3.armhf.com/dist/basefs/ubuntu-trusty-14.04-armhf.com-20140603.tar.xz not from wandboard!

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

    hi...

     

    i had followed your steps of creating sdcard image. i only changed the rootfs to http://s3.armhf.com/dist/wand/ubuntu-trusty-14.04-rootfs-3.10.17.1-wand-armhf.com.tar.xz bcoz ur rootfs path was unavailable..

     

    now i am getting following resullts with no package can be downloaded or no application can be installed after booting.

     

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

     

    keys:

    The disk drive for /tmp is not ready yet or not present.

    keys:Continue to wait, or Press S to skip mounting or M for manual recovery

     

    keys:

    An error occurred while mounting /.

    keys:Press S to skip mounting or M for manual recovery

     

    keys:

    * Starting Signal sysvinit that local filesystems are mounted[ OK ]

    * Starting configure network device security[ OK ]

    * Stopping Mount filesystems on boot[ OK ]

    * Starting Failsafe Boot Delay[ OK ]

    * Starting flush early job output to logs[ OK ]

    * Starting flush early job output to logs[fail]

    * Starting configure virtual network devices[ OK ]

    * Starting system logging daemon[ OK ]

    * Starting Bridge file events into upstart[ OK ]

    Waiting for network configuration...

    Waiting up to 60 more seconds for network configuration...

     

    Ubuntu 14.04 LTS riotboard ttymxc1

     

    riotboard login: root

    Password:

     

    Login incorrect

    riotboard login:

    Password:

     

    Login incorrect

    riotboard login:

    Password:

     

    Login incorrect

    riotboard login: Password:

     

    Login incorrect

    riotboard login:

    Password:

     

    Login incorrect

    Maximum number of tries exceeded (5)

     

    Ubuntu 14.04 LTS riotboard ttymxc1

     

    riotboard login: ubuntu

    Password:

    Welcome to Ubuntu 14.04 LTS (GNU/Linux 4.1.0 armv7l)

     

    * Documentation:  https://help.ubuntu.com/

     

    The programs included with the Ubuntu system are free software;

    the exact distribution terms for each program are described in the

    individual files in /usr/share/doc/*/copyright.

     

    Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by

    applicable law.

     

     

    The programs included with the Ubuntu system are free software;

    the exact distribution terms for each program are described in the

    individual files in /usr/share/doc/*/copyright.

     

    Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by

    applicable law.

     

    ubuntu@riotboard:~$ ls

    ubuntu@riotboard:~$ gcc

    -bash: gcc: command not found

    ubuntu@riotboard:~$ apt-get

    apt 1.0.1ubuntu2 for armhf compiled on Apr 10 2014 13:06:10

    Usage: apt-get [options] command

           apt-get [options] install|remove pkg1 [pkg2 ...]

           apt-get [options] source pkg1 [pkg2 ...]

     

    apt-get is a simple command line interface for downloading and

    installing packages. The most frequently used commands are update

    and install.

     

    Commands:

       update - Retrieve new lists of packages

       upgrade - Perform an upgrade

       install - Install new packages (pkg is libc6 not libc6.deb)

       remove - Remove packages

       autoremove - Remove automatically all unused packages

       purge - Remove packages and config files

       source - Download source archives

       build-dep - Configure build-dependencies for source packages

       dist-upgrade - Distribution upgrade, see apt-get(8)

       dselect-upgrade - Follow dselect selections

       clean - Erase downloaded archive files

       autoclean - Erase old downloaded archive files

       check - Verify that there are no broken dependencies

       changelog - Download and display the changelog for the given package

       download - Download the binary package into the current directory

     

    Options:

      -h  This help text.

      -q  Loggable output - no progress indicator

      -qq No output except for errors

      -d  Download only - do NOT install or unpack archives

      -s  No-act. Perform ordering simulation

      -y  Assume Yes to all queries and do not prompt

      -f  Attempt to correct a system with broken dependencies in place

      -m  Attempt to continue if archives are unlocatable

      -u  Show a list of upgraded packages as well

      -b  Build the source package after fetching it

      -V  Show verbose version numbers

      -c=? Read this configuration file

      -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp

    See the apt-get(8), sources.list(5) and apt.conf(5) manual

    pages for more information and options.

                           This APT has Super Cow Powers.

    ubuntu@riotboard:~$ apt-get install mjpg streamer

    W: Not using locking for read only lock file /var/lib/dpkg/lock

    E: Unable to write to /var/cache/apt/

    E: The package lists or status file could not be parsed or opened

    • 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 © 2025 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