iMX233-OLinuXino get started – making the ARCH Linux SD card


Image

In several articles we will make step-by-step guide how first to build ARCH Linux distribution with the necessary tools for development and how then you can write simple HELLO WORLD code and later how to interface our UEXT modules by iMX233-OLinuXino.

I. ย First to Get started we need Linux SD card with ARCH Linux.

Why ARCH? Because thanks to Kiril Zyapkov this is the most complete Linux distribution for iMX233-OLinuXino for the moment. It have support for the TV console, I2C, UART, USB, web cameras and different WIFI adapters.

Note that from September 1st we ship ARCH Linux on the iMX233-OLinuXino-SD cards, so if you have one of these you can skip the instructions below, if you do not have you can easily build one, for this purpose you will need computer with running LINUX, we got several messages asking how to build the Linux SD card under Windows and the simple answer is – there is no way you can do this under Windows, if you have Windows the best solution is to download Ubuntu and to install it as second OS, Ubuntu will keep your Windows and you can boot your computer either with Linux either with Windows OS so you do not lose anything (just learn something new ๐Ÿ˜‰ ).

So we assume you have computer running LINUX for the steps below. To write the SD card of course your computer should have also card reader/writer.

1. First you need to download some Linux images from our Gdrive. Put these files in some folder like /home/user/Archlinux for instance.

The files you need are:

Linux-alarm-2.6.35-6-ARCH.img ( https://docs.google.com/open?id=0B-bAEPML8fwlZS0wcFNyLTFpX2M )โ€“ this is the kernel image patched with the latest version 2.6.35-6;

–ย ArchLinuxARM-olinuxino-latest-rootfs-clean.tar.gz ( https://docs.google.com/open?id=0B-bAEPML8fwlLXlxblQxWTVvZVU )โ€“ the root file system, only the basics, no extra packages; our recommendation is to get this only if you are familiar with ARCH and you want to add packages by your choice, if you are beginner do not use these but download next file:

–ย ArchLinuxARM-olinuxino-latest-rootfs.tar.bz2(ย https://docs.google.com/open?id=0B-bAEPML8fwlNDFUYkx0ZkNWV3cย )โ€“ the root file system with installed packages and their corresponding dependencies:ย ย mplayer โ€“ very powerful media tool to play audio and video;ย alsi-utils โ€“ a tool that can successfully manage the headphone output and line-in input;ย basedevel โ€“ a big and mighty package for every developer;ย fbset โ€“ simple frame buffer ;

2. Insert the card-reader into the Linux host machine.

IMPORTANT NOTE – this example is given with “sdb1โ€ and โ€œsdb2” devices but it could enumerate differently on your host (sdc, sdd, sde etc.), so confirm what it enumerates as before running fdisk!

TIP – Before inserting the card-reader type in the console without pressing Enter:

$ ls /dev/sd

and press the TAB key twice. This should display all of the available devices. Insert the card-reader and press TAB again. Now you should see a new device โ€“ the SD-card.

3.ย Unmount the card-reader:

$ sudo umount /dev/sdb1

NOTE – Some systems doesn’t auto-mount devices so this step may be unnecessary.

4.ย Format the SD-card using fdisk:

$ sudo fdisk /dev/sdb

5. With the help of the menu create two partitions. The steps are the following:

NOTE – We recommend fist to type โ€œmโ€ to see what does each one of the following operations.

5.1. Type โ€œpโ€ to view existing partitions on the SD-card
5.1. Type โ€œoโ€ to delete all partitions
5.2. Type โ€œnโ€ to create new one
5.3. Set โ€œ1โ€ as partition number
5.4. Type โ€œpโ€ to select primary partition
5.5. Press Enter to select default beginning sector
5.6. Type โ€œ+32Mโ€ to create 32MB partition
5.7. Type โ€œtโ€ to change partition type
5.8. Type โ€œ53โ€
5.9. Type โ€œnโ€ to create another partition
5.10. Set โ€œ2โ€ as partition number
5.11. Type โ€œpโ€ to set partition as primary
5.12. Press Enter to set default size of the partition
5.13. Type โ€œwโ€ to write partitions to the SD-card

6. Format the second partition with ext3 file system:

$ sudo mkfs.ext3 /dev/sdb2

7. Mount the second partition:

$ sudo mount /dev/sdb2 /mnt/mmc

NOTE – If you don’t have mount-point you should create one. Just type:

$ sudo mkdir /mnt/<dir>

8. Log-in as root for the next operations:

$ sudo su

IMPORTANT NOTE: It is necessary to log-in as root, not as super-user!

9. Extract the downloaded tarball into the second partitions:

# cd /mnt/mmc
# tar -jxvf /home/User/Archlinux/ArchLinuxARM-olinuxino-latest-rootfs.tar.bz2

IMPORTANT NOTE: If you want the clean file system change the second command:

# tar -zxvf /home/User/Archlinux/ArchLinuxARM-olinuxino-latest-rootfs-clean.tar.gz

10. The next step is to to write the boot-loader and kernel image to the first partition.

# dd if=/Archlinux/Linux-alarm-2.6.35-6-ARCH.img of=/dev/sdb1

11. Unmount the SD-card, it should be ready for use.

# cd
# sync
# umount /dev/sdb2

IMPORTANT NOTE: The default log-in is : root, and the password is also: root.

II. Setup Internet

NOTE – This is working example, but you may read some additional information, if this doesn’t work for you.

With every reboot the device is assigned with different MAC address. To change this use these commands:

# ip link set dev usb0 down
# ip link set dev usb0 address aa:bb:cc:dd:ee:ff
# ip link set dev usb0 up

To set an IP address enter:
# ifconfig usb0 192.168.0.249

or whatever address you want.

After that add default gateway:
# route add default gw 192.168.0.1 usb0

Finally you should add DNS-server. You should modify /etc/resolv.conf with vi, or other program. For example:
# vi /etc/resolv.conf

Press d several times to remove all lines. Press I to enter insert mode. Type:
# nameserver 192.168.0.1

(Again this is example. You should add you DNS-server.)
After you finish entering this press Esc. This will set the program in command mode. In command mode press:
:wq

This should do the work. To check connection use ping. If it doesn’t, check your configuration again and router settings. You can use ifconfig to see OLinuXino settings.

III. Hello World!

Now we have all tools to make our first program for iMX233-OLinuXino:

using vi editor you can type this code:

#include <stdio.h>

int main (int argc, char *argv[])ย {
if (argc > 1)
printf(“\r\n Hello %s.\r\n\r\n”, argv[1]);
else
printf(“\r\n Hello World.\r\n\r\n”);

return 0 ;
}

if you are lazy to do this in the /home/examples directory this example is already written ๐Ÿ™‚

to compile the code use:

# gcc hello_world.c -o hello

then make hello executable with

# chmod +x hello

and you can test the code with

# ./hello <your name>

the code should display

Hello <your name>.

IV. Blinking LED

Now when we made our first C code for iMX233-OLinuXino is time to make our first shell script.

with vi editor again you can write this code :

echo out > /sys/class/gpio/gpio65/direction
while [ 1 -eq 1 ]
do
echo 1 > /sys/class/gpio/gpio65/value
sleep 1
echo 0 > /sys/class/gpio/gpio65/value
sleep 1
done

this is simple endless loop to blink the green LED next to the power connector, if we want it to be executed at every board boot we can add it to the rc.local

# vi /etc/rc.local

Add the path to the script file:

/home/examples/led_blink/led_blink &

The “&” means that the script will be running in background.

Now every time when the board boot will execute this script and the green LED will start blinking which proves the board works correctly.

I hope this is good start for beginners, tomorrow I will post how you can talk to I2C devices connected to UEXT connector like MOD-MAG 3 axis magnetometer for instance.

56 Comments (+add yours?)

  1. tERBO
    Sep 06, 2012 @ 21:32:24

    Getting this error when decompressing bzip:

    usr/share/man/man3/gnutls_x509_crl_get_crt_count.3.gz
    usr/share/man/man3/fopen.3p.gz
    tar: Skipping to next header

    bzip2: Data integrity error when decompressing.
    Input file = (stdin), output file = (stdout)

    It is possible that the compressed file(s) have become corrupted.
    You can use the -tvv option to test integrity of such files.

    You can use the `bzip2recover’ program to attempt to recover
    data from undamaged sections of corrupted files.

    tar: Child returned status 2
    tar: Exiting with failure status due to previous errors

    Tried twice on different machines…

    Reply

  2. Darkman
    Sep 06, 2012 @ 21:32:51

    Please write how to build all no only how to put prepared images on SD, where can I get source code for kernel?, thanks for images, but please share source code with all patches. Olinuxino support is very poor …. do you provide python lib for GPIO, similar to raspberry pi lib?

    Reply

  3. tERBO
    Sep 06, 2012 @ 21:42:36

    And when I put SD card in to Olinuxino I’ve got error 0x80501003

    Reply

  4. Kris
    Sep 07, 2012 @ 00:11:45

    Same here … failes to decompress … just like in tERBO message.

    Can you guys upload md5 hash … or post the files somwhere elese..

    Reply

  5. Cb
    Sep 11, 2012 @ 15:36:17

    Are the files still corrupt or have new ones been posted ?

    Reply

  6. Cosmin
    Sep 12, 2012 @ 16:34:09

    Do this images include any graphics interface? If no, can anyone tell me where I can find an linux image with graphics interface compatibile with olinuxino, and how to install it?

    Reply

  7. LucaF
    Sep 12, 2012 @ 16:46:02

    Dear guys
    still corrupted file.
    When extracting the clean version at ./usr/include/ksba.h –crc error

    Reply

  8. jamodio
    Sep 14, 2012 @ 23:55:17

    Why file system type 53 ?
    All docs I found seem to have the same information, Linux is 83

    Reply

    • OLIMEX Ltd
      Sep 15, 2012 @ 12:00:39

      I’m still learning Linux, but brief google search told me that type 53 is for Master Boot Record to keep the kernel image, type 83 is Linux file system to hold the rootfs

      Reply

      • jamodio
        Sep 15, 2012 @ 14:55:03

        Yes 83 is for the root file system but many of the SD images being put together for boards like this one have the boot partition as type “c” that is a bootable WIN95 FAT32 like for beagleboard, beaglebone, raspberry pi, etc.

        I’m still trying to put together a working SD card without having to build the entire thing, instructions on different places are not consistent and it would be nice to have a tested working complete image of a SD card (perhaps like the one used on the card offered in your site at least as a reference and to permit to test the board.
        A full image with both partitions that can be written with Win32 Disk Imager will be a plus.

        Is there any document that shows what the hex debug messages represent at boot ?

        Anyway great job with the board and looking forward to get it up and running.

        Cheers
        Jorge

      • OLIMEX Ltd
        Sep 15, 2012 @ 15:27:08

        the boot messages are in the iMX233 user manual

  9. jamodio
    Sep 15, 2012 @ 17:02:44

    Do you mind telling what file and where ? I”m looking at the 50 pages of Revision H and there is no table or references to the boot messages.

    BTW, I was able to put together the SD card image and the board is up and running, very cool stuff.

    Jorge

    Reply

  10. Luca F
    Sep 15, 2012 @ 21:41:39

    Sorry,

    anybody else have problems during root fs extraction for bad crc?
    The version with more packets works well but the clean version give me errors at file ./usr/include/ksba.h

    Thanks in advance

    Reply

  11. Trackback: iMX233-OLinuXino development – do not wear your SD-card flash « olimex
  12. Bogdan
    Sep 22, 2012 @ 00:30:36

    Tryed few times with “clear” and “full” versions. The result UART code is:

    0x80502008
    0x80501003

    Black screen on video output.
    What I am doing wrong?

    Reply

  13. Bogdan
    Sep 23, 2012 @ 00:20:20

    Today I’v tested two other sd card images: open embeded an old archlinux (july version almost withought soft). Both are working correctly. So the problem seems in ths build of images.

    Reply

  14. Witek
    Sep 23, 2012 @ 22:07:05

    I have exactly the same error code: 0ร—80501003. The problem is in the kernel image. Files from https://www.olimex.com/Products/OLinuXino/iMX233/_resources/OPEN-EMBEDDED-README.TXT works fine. I will try: http://archlinuxarm.org/platforms/armv5/olinuxino.
    My board is iMX233-OLinuXino-MICRO.

    Reply

  15. Bogdan
    Sep 24, 2012 @ 13:44:31

    Is it possible to use olinuxino micro with my WiFi module? :

    150M Wireless 5370 USB Adapter Network LAN Card Wifi Dongle Adaptor Dynamode
    WIFI-WWK00334
    Standarts: n,g,b.

    http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=180948868527

    Reply

  16. Reppad
    Sep 24, 2012 @ 14:57:37

    Thank you for this tutorial, the installation works.
    Archlinux boots but the image is cropped.
    The image is cut to the left and bottom (I do not see the beginning of the lines nor the last line).
    I tried with several screen and the problem is the same.
    Is there a setting available to adjust the display ?

    Reply

  17. Bogdan
    Sep 24, 2012 @ 19:25:42

    Reloaded images of ArchLinux.No checksum error, but linux boot halts on:

    mount: unknown filesystem type ‘devtmpfs’
    :: Mounting Root Read-Only [DONE]
    :: Adjusting system time and setting kernel timezone [DONE]
    :: Starting UDev Daemon [DONE]
    :: Triggering UDev uevents [DONE]
    :: Loading User-specified Modules [DONE]
    :: Waiting for UDev uevents to be processed [DONE]
    :: Configuring Virtual Consoles [FAIL]
    :: Bringing up loopback interface [DONE]
    :: Unlocking encrypted volumes [DONE]
    :: Checking Filesystems [BUSY] /etc/rc.sysinit: line 100: /dev/stdout: Read-only file system
    [DONE]
    :: Remounting Root and API filesystems [BUSY] EXT3-fs (mmcblk0p2): using internal journal
    [DONE]
    :: Mounting Local Filesystems [DONE]
    :: Activating Swap [DONE]
    :: Configuring Time Zone [DONE]
    :: Initializing Random Seed [FAIL]
    :: Removing Leftover Files [DONE]
    :: Setting Hostname: alarm [DONE]
    :: Saving dmesg Log [BUSY] install: cannot stat รขโ‚ฌหœ/dev/fd/63รขโ‚ฌโ„ข: No such file or directory
    [FAIL]
    INIT: Entering runlevel: 3
    mount: mount point /proc/sys/fs/binfmt_misc does not exist
    :: Starting Syslog-NG [DONE]
    :: Starting Network [BUSY]
    Error: unknown interface in /etc/rc.conf: `usb0′
    [DONE]
    :: Mounting Network Filesystems [DONE]
    :: Starting crond daemon [DONE]
    :: Starting Secure Shell Daemon [BUSY] PRNG is not seeded
    PRNG is not seeded
    [FAIL]

    Reply

  18. Kevin Patino
    Sep 28, 2012 @ 00:56:55

    I create the image of kernel with steps at this page http://www.jann.cc/2012/08/23/building_a_kernel_3_x_for_the_olinuxino_from_sources.html#id12 and download the file system OLinuXino_Debian_FS.tgz. I think it works good but i don’t understand how to organize the file system i don’t find the directory /sys/class/gpio/gpio65 i find another /sys/class/gpio/ gpiochip0 gpiochip32 and others

    Somebody help me to find gpio archives. i want to run blinker example.

    Reply

  19. fly_pt
    Oct 08, 2012 @ 08:22:07

    Hello,
    I’m just starting using Olinuxino, I got my Olinuxino-Maxi board and the pre-loaded linux image (Linux version 2.6.35.3_OLinuXinoR4) uSD as well. So far I was able to connect to the board using a ssh terminal.
    I followed all the steps to set up a new uSD card with the new image (2.6.35.6). I see is booting because the LED is flashing after a while, but I can’t see anything using a TV set, I can’t connect through a serial port neither, so i’m not able to configure anything, what can I do ??

    Reply

    • OLIMEX Ltd
      Oct 08, 2012 @ 17:50:47

      Arch Linux image and Open Embedded image have TV console enabled, can you connect serial cable to the console and check what is your kernel log?

      Reply

      • fly_pt
        Oct 08, 2012 @ 20:26:22

        Thanks for your reply, unfortunally I did not get the USB-serial cable from olimex, but I tryied using a TRENDnet TU-S9 (PL2303) converter, I followed all directions how to connect GND, TX, and RX lines as well, config as 115200 8N1, but in either case I only got information as it would be the wrong baud speed set, nothing legible.
        That happened with original uSD Linux and the one I created.
        I will try to use another USB-serial converted in case this one is wrong. I will post after I test it.

      • OLIMEX Ltd
        Oct 08, 2012 @ 20:28:08

        you can do simple test if your Cable is OK by connecting RX and TX together then when you type something to the keyboard you have to see it in the terminal

      • fly_pt
        Oct 08, 2012 @ 20:30:48

        That was fast !,
        I already did that, cable was ok. Do you have any clue what can be wrong ??

      • fly_pt
        Oct 10, 2012 @ 07:20:46

        I finally got the serial working, it was a rookie mistake, After I posted I have a USB-serial converter from TRENDnet I realize that this is RS232 +/- 12v voltage level, and the olinuxino works at 3V level so I’m happy I did not burn the board out….
        Now I have both images working ok….

  20. Kishore
    Oct 18, 2012 @ 12:22:39

    I bought ARM-USB-TINY-H and I want to connect to imx233-olimax maxi board
    but I could not able to find document how to connect 20 pin connector
    can you please guide me? or refer a document explaining connection?

    Reply

  21. Trackback: Hands on olimex olinuxino board
  22. Zdenek Valek
    Oct 28, 2012 @ 22:59:42

    Corrupted files!
    Incredible, after all the complains here, the files linked are still corrupt. The rootfs-clean has both data–crc error and data–length error. You REALLY SHOULD CONSIDER USING DIFFERENT STORAGE and verify your uploads. The bigger rootfs seems to be OK, but how can I be sure about the linux image? Where is the checksum? Maybe the incredible file corruptions are the number one reason of boot failures I read about everywhere.

    Reply

  23. Andre
    Feb 06, 2013 @ 18:53:19

    I’m trying to use Gparted to create both partitions, what type of partition is 53? I know the second partitions is ext3. but the first partition I have no idea how to created with gparted

    Reply

  24. LH
    Apr 01, 2013 @ 03:43:31

    I fixed the macaddress (after which my DHCP server now always assigns the same IP address and putty does no longer ask permission for the new mac address after each reboot ๐Ÿ™‚ as follows:

    Edit /etc/rc.conf and add a line (e.g. on line 88) with the desired MAC address:
    interface=usb0
    address=
    macaddress=aa:cc:aa:bb:aa:bb
    netmask=
    broadcast=
    gateway=

    (so just add one line with macaddress= underneath the address= line)

    Then in /etc/rc.d/network I changed line 41:
    network_up() {
    have_interface “$interface” || return 1

    ip link set dev $interface up address $macaddress || return 1

    I added behind the ‘up’: address $macaddress
    so each time this script brings the ethernet adapter up it’ll first set the desired MAC address!

    You can test the network script while still on the olinuxino console:
    ./network stop
    ./network start
    and check that you did not make any errors.
    After restart you can check the new MAC address and IP address assigned by your DHCP server with:
    ifconfig -a

    Not sure this is the best way to solve it but just rebooted 3 times and it seems to work fine for me ๐Ÿ™‚

    Reply

  25. KaGO
    May 11, 2013 @ 13:43:15

    Hello,

    I followed the steps above, and successfully partitioned the sd card and loaded the images into the sd card, but when I power up the board I get no indication of successful booting or loading image. I can’t find any thing on Terminal or screen.

    I have OlinuXino-Micro

    Any suggestions?

    Reply

  26. Marcin
    Apr 21, 2014 @ 19:21:11

    Hi.
    I have just set up mu Olinuxino Mini Wifi with procedure above and have two problems:
    1. On Composite video console, first 1-3 characters are out of the screen.
    2. Can not start WiFi interface. There is no usb0 dvice files.
    What I should do to have what is on board working: Video, Sound, WiFi GPIO.

    Reply

  27. ben
    Aug 27, 2014 @ 07:13:01

    Have Arm Distro supplied by Olimex, Linux-alarm-2.6.35-6-ARCH.

    I have this board, iMX233-OLinuXino-MINI-WiFi

    I cannot record with arecord alsa tool from line input.

    Is line input audio supported with this kernel? or do i need to load a Kernel Module for recording sound?

    Alsa and Alsamixer is working for playing audio out.

    BEN

    Reply

  28. AmitMqtt
    Jul 20, 2020 @ 13:34:04

    Image files are not available , could you please share updated path for both images.

    โ€“ Linux-alarm-2.6.35-6-ARCH.img ( https://docs.google.com/open?id=0B-bAEPML8fwlZS0wcFNyLTFpX2M )
    โ€“ ArchLinuxARM-olinuxino-latest-rootfs.tar.bz2( https://docs.google.com/open?id=0B-bAEPML8fwlNDFUYkx0ZkNWV3c )

    Thanks
    Amit

    Reply

Leave a comment