Difference between revisions of "RK3188-SOM"

m (Debian Wheezy)
(Debian for microSD card)
 
(183 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Linux ==
+
== Overview ==
=== Booting from SD-card ===
+
 
==== Writing Rockchip loader ====
+
[[File:Rk3188-som-resized.png|650px]]
 +
 
 +
RK3188-SOM board is a very productive small beast compared to the previous Olimex board designs. If we compare RockChip RK3188 and Allwinner A20: RK3188 has 4x Cortex-A9, while A20 only 2x Cortex-A7. It runs at 1.6 GHz vs. the 1.0 GHz frequency of the A20. RK3188 reaches a total of 16000 DMPIS vs. the 3800 DMIPS for the A20 (RK3188 is 4.2 times faster). For comparison, the RaspberryPi has 965 DMIPS (RK3188 is 16.6 times faster).
 +
 
 +
The RK3188-SOM design has the following features:
 +
 
 +
*Rockchip RK3188 quad core Cortex-A9 processor, each core typically running at 1.6GHz
 +
*1GB DDR3 memory
 +
*Integrated power management unit
 +
*Optional 4GB NAND flash memory for Linux or Android boot
 +
*Micro SD-card for Linux or Android boot
 +
*Three buttons - POWER, RESET, RECOVERY
 +
*Four LEDs (one for power and three user-programmable)
 +
*UART console pins exposed for serial debug
 +
*Five GPIO connectors 2×20 pins @ 0.05" step
 +
*Dimensions: (3.2×1.8)" ~ (81×56)mm
 +
<br>
 +
 
 +
== Ready-to-use Debian images ==
 +
=== Debian for microSD card ===
 +
 
 +
'''Newest official release (recommended):'''
 +
 
 +
Direct download of Debian release #2:[https://ftp.olimex.com/Rockchip_images/sd/debian/RK3188_debian_3.0.36_SD_release2.img.7z RK3188-SOM Debian for microSD card - kernel 3.0.36+ - release #2]
 +
 
 +
In the command line interface of image you are automatically logged as root. The default superuser username/password combination in the GUI (XFCE4) is: olimex/olimex.
 +
 
 +
Build instructions and links to required files for the latest Debian images might be found below in chapter "Building Linux for RK3188-SOM".
 +
 
 +
'''Older official releases (not recommended):'''
 +
 
 +
Direct download of Debian release #1:[https://ftp.olimex.com/Rockchip_images/sd/debian/RK3188_debian_3.0.36_SD_release1.img.7z RK3188-SOM Debian for microSD card - kernel 3.0.36+ - release #1]
 +
 
 +
====How to prepare your microSD card with the suitable official Debian image?====
 +
----
 +
In order to download an official Linux image to a microSD card under Windows you can use Win32 Disk Imager: [http://sourceforge.net/projects/win32diskimager/ click here]
 +
 
 +
1. Download the latest official image suitable for a microSD card from the chapter above
 +
 
 +
2. Download Win32 Disk Imager from this link.
 +
 
 +
3. Insert card in your microSD card reader.
 +
 
 +
4. Launch the software.
 +
 
 +
5. Point the software to the image
 +
 
 +
6. Click "write"
 +
 
 +
Under Linux you can write the image image to the card with dd utility. This is how it can be done:
 +
 
 +
Let's say the name of the image is "debian_2g.img". It would be downloaded to the microSD card connected to a Linux machine using one of the following commands:
 +
 
 +
dd bs=4M oflag=sync if=debian_2g.img of=/dev/sdX
 +
 
 +
or
 +
 
 +
cp debian_2g.img /dev/sdX
 +
 
 +
where /dev/sdX is the uSD card as listed by the Linux.
 +
 
 +
=== Debian for NAND memory ===
 +
 
 +
'''Newest official release (recommended):'''
 +
 
 +
Direct download Debian for NAND release #1: [https://ftp.olimex.com/Rockchip_images/nand/debian/RK3188_debian_3.0.36_NAND_release1.img.7z|RK3188-SOM Debian for NAND memory - kernel 3.0.36+ - release #1]
 +
 
 +
Note that this image is suitable only for RK3188-SOM-4GB boards.
 +
 
 +
Build instructions and links to required files for the latest Debian images might be found below in chapter "Building Linux for RK3188-SOM"
 +
 
 +
====How to download the ready Debian image to the NAND memory of RK3188-SOM?====
 +
----
 +
 
 +
'''IMPORTANT: RK3188-SOM-4GB comes with Debian already pre-loaded on the NAND memory. No need to perform this operation initially.'''
 +
 
 +
1. You need to download the software tools for your computer provided by Rockchip. If you use Windows download “Rockchip Batch Tool”. If you use Linux use either rkflashkit or upgrade_tool. These are the tools that I recommend but there are a lot of tools available. Get the Rockchip batch tool from here: [https://drive.google.com/file/d/0BwplT87k9SCgRDB4ZGY3SnMzd00/view?usp=sharing Rockchip Batch Tool]
 +
 
 +
For Windows:
 +
 
 +
2. Install the drivers that allows your computer to recognize the board (that is already set in bootloader mode) connected to it. The installer is called "Rockchip Driver Assistant" – download it here: [https://drive.google.com/file/d/0BwplT87k9SCgbkdXX1ByUW1RSW8/view?usp=sharing Rockchip Driver Assistant]
 +
 
 +
3. You need to download and extract the latest image suitable for the NAND from our wiki. It is available as a direct download here: [https://ftp.olimex.com/Rockchip_images/nand/debian/RK3188_debian_3.0.36_NAND_release1.img.7z%7CRK3188-SOM|RK3188 Debian 3.0.36 for NAND memory]
 +
 
 +
4. You need enter bootloader mode with the board to be able to establish connection between the board and the software provided by Rockchip. You would also need a mini USB cable. To enter bootloader mode you need to press and hold down the recovery button before powering the board (then connect the board to the PC via the mini USB cable). After the board is powered you can release the button.
 +
 
 +
5. Start the tool for uploading the firmware and point it to the extracted image.
 +
 
 +
6. Click button "Upgrade".
 +
 
 +
7. Test with a serial cable.
 +
 
 +
== Ready-to-use Android images ==
 +
TODO
 +
 
 +
== Documents ==
 +
 
 +
[https://www.olimex.com/Products/SOM/RK3188/RK3188-SOM/resources/RK3188-SOM-UM.pdf OLIMEX RK3188-SOM user's manual]
 +
 
 +
[https://www.olimex.com/Products/SOM/RK3188/RK3188-SOM-EVB/resources/RK3188-SOM-EVB-UM.pdf OLIMEX RK3188-SOM-EVB user's manual]
 +
 
 +
[https://github.com/OLIMEX/OLINUXINO/raw/master/HARDWARE/RK3188-PDFs/Rockchip%20RK3188%20datasheet%20V1.0.pdf Processor (Rockchip RK3188) datasheet in pdf format]
 +
 
 +
[https://www.olimex.com/Products/SOM/RK3188/RK3188-SOM/resources/RK3188_SOM_GPIOs.pdf RK3188-SOM connectors' pinout and GPIO table]
 +
 
 +
=== CAD files ===
 +
 
 +
RK3188-SOM is considered commercial, proprietary design. The board file is not available to the customer. A pdf extracted from the original schematic is available at GitHub: [https://github.com/OLIMEX/SOM/tree/master/RK3188/RK3188-SOM RK3188-SOM schematics]
 +
 
 +
RK3188-SOM-EVB is considered Open Source Hardware, Eagle CAD files are available also at GitHub: [https://github.com/OLIMEX/SOM/tree/master/RK3188/RK3188-EVB RK3188-SOM-EVB sources]
 +
 
 +
The CAD product used to design OLinuXino is Eagle and you can download evaluation free version from their [http://www.cadsoftusa.com/ web site]. The evaluation version allows you to inspect the schematic and the board file sources.
 +
 
 +
==Board Layout==
 +
 
 +
[[File:Rk3188-som-resized-TOP-NAMED.png|650px]]
 +
 
 +
 
 +
[[File:Rk3188-som-resized-BOTTOM-NAMED.png|650px]]
 +
 
 +
== Building Linux for RK3188-SOM ==
 +
=== Building the parameter file ===
 +
----
 +
The parameter file describes many board parameters as firmware version, machine id, manufacturer name, etc.
 +
 
 +
For the user the most important parameter is '''CMDLINE'''. This is the command that is passed to the kernel. It looks something like this:
 +
CMDLINE:console=ttyFIQ0,115200 console=tty0 root=/dev/mmcblk0p1 rw rootfstype=ext4 init=/sbin/init initrd=0x62000000,0x00800000 \
 +
mtdparts=rk29xxnand:0x00008000@0x00002000(boot),-@0x0000A000(linuxroot)
 +
 
 +
Define serial port at 115200:
 +
console=ttyFIQ0,115200
 +
 
 +
Define location of the rootfs:
 +
root=/dev/mmcblk0p1
 +
 
 +
Define rootfs file system as ext4:
 +
rootfstype=ext4
 +
 
 +
Define the address of the kernel and size:
 +
0x00008000@0x00002000
 +
 
 +
Define start address of the rootfs:
 +
-@0x0000A000
 +
 
 +
Additionally, you can set static MAC address with:
 +
mac_addr=xx:xx:xx:xx:xx:xx
 +
 
 +
Once you're ready with the file, make the parameter image
 +
 
 +
* Get rkutils:
 +
https://github.com/naobsd/rkutils
 +
cd rkutils
 +
gcc rkcrc.c -o rkcrc
 +
If you're getting error try to comment ''''#include <err.h>'''' in ''''rkcrc.c''''
 +
 
 +
* Encrypt parameter file:
 +
./rkcrc -p you_parameter_file parameter
 +
 
 +
The parameter file is ready for further use.
 +
 
 +
=== Building the kernel ===
 +
----
 +
* Fist prepare the toolchain:
 +
apt-get update
 +
apt-get install gcc-4.7-arm-linux-gnueabihf ncurses-dev uboot-mkimage build-essential git
 +
 
 +
* Get the sources:
 +
git clone -b olimex/stable-3.0 https://github.com/StefanMavrodiev/RK3188-SOM.git
 +
 
 +
* Get the default configuration:
 +
cd RK3188-SOM/
 +
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- '''olimex_rk3188_defconfig'''
 +
 
 +
* You can modify defconfig with (for additional modules):
 +
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
 +
 
 +
'''Note!''' The default config will set hdmi to 1080p. You can change it from:
 +
Device Drivers --->
 +
    Graphics support --->
 +
        <*> Frame buffer support for Rockchip --->
 +
                LCD Panel Select --->
 +
                    '''''Choose one of the following:'''''
 +
                    HDMI framebuffer size and timing is 1080p    <---    '''Set HDMI to 1080p'''
 +
                    HDMI framebuffer size and timing is 720p    <---    '''Set HDMI to 720p'''
 +
                    HDMI framebuffer size and timing is 480p    <---    '''Set HDMI to 480p'''
 +
                    RGB AT070TN90    <---    [https://www.olimex.com/Products/OLinuXino/LCD/LCD-OLinuXino-7/open-source-hardware LCD-OLinuXino-7]
 +
                    RGB AR010H05N    <---    [https://www.olimex.com/Products/OLinuXino/LCD/LCD-OLinuXino-10/open-source-hardware LCD-OLinuXino-10]
 +
                    RGB BT043DCNNHHP <---    [https://www.olimex.com/Products/OLinuXino/LCD/LCD-OLinuXino-4.3TS/open-source-hardware LCD-OLinuXino-4.3TS]
 +
 
 +
* Build the kernel:
 +
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 kernel.img
 +
After the build is finish you will have '''RK3188-SOM/kernel.img''' and '''RK3188-SOM/arch/arm/boot/Image'''. The first one can be uploaded to the kernel partition (if you have one). The second file is raw binary. It can be combined with ramdisk to get boot.img.
  
<code>dd if=loader.img of=/dev/sde conv=sync,fsync </code><br \>
+
* Generate ramdisk
<code>dd if=parameter of=/dev/sde conv=sync,fsync seek=$((0x2000))</code><br \>
+
cd ../
<code>dd if=boot.img of=/dev/sde conv=sync,fsync seek=$((0x2000+0x2000))</code><br \>
+
git clone https://github.com/radxa/initrd.git
 +
cd initrd/
 +
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4
 +
cd ../
  
==== Building kernel ====
+
* Make mkbootimg
 +
git clone https://github.com/neo-technologies/rockchip-mkbootimg.git
 +
cd rockchip-mkbootimg
 +
make
 +
make install
 +
cd ../
  
<code>./mkbootimg --kernel RK3188-SOM/arch/arm/boot/Image --ramdisk initrd.img -o boot.img</code>
+
* Make boot.img
 +
mkbootimg --kernel RK3188-SOM/arch/arm/boot/Image --ramdisk initrd.img -o boot.img
  
==== Creating root filesystem ====
+
=== Creating the root filesystem ===
===== Debian Wheezy =====
+
==== Debian Wheezy ====
dd if=/dev/sdc of=parameter.img count=$((0x2000)) skip=$((0x2000))
+
----
dd if=/dev/sdc of=boot.img      count=$((0x8000)) skip=$((0x2000+0x2000))
 
 
In this post we will explain how you can create your own Debian rootfs with pre-installed packages of your choice, which to allow tiny Linux images to be created. All steps below should work on any Debian host (Debian/Ubuntu etc) and are verified with Ubuntu 12.04LTS. First of all you need to install the support packages on your pc:
 
In this post we will explain how you can create your own Debian rootfs with pre-installed packages of your choice, which to allow tiny Linux images to be created. All steps below should work on any Debian host (Debian/Ubuntu etc) and are verified with Ubuntu 12.04LTS. First of all you need to install the support packages on your pc:
  
; <code>sudo apt-get install qemu-user-static debootstrap binfmt-support</code>
+
* Install the needed packages:
 +
sudo apt-get install qemu-user-static debootstrap binfmt-support
 +
 
 +
* Define some variables:
 +
targetdir=rootfs
 +
distro=wheezy
 +
 
 +
* Build first stage:
 +
mkdir $targetdir
 +
sudo debootstrap --arch=armhf --foreign $distro $targetdir
 +
 
 +
* Copy needed files from host to the target:
 +
sudo cp /usr/bin/qemu-arm-static $targetdir/usr/bin/
 +
sudo cp /etc/resolv.conf $targetdir/etc
 +
 
 +
We should now have a minimal Debian Rootfs.
 +
* Login into the new filesystem:
 +
sudo chroot $targetdir
 +
 
 +
* Inside the chroot we need to set up the environment again:
 +
distro=wheezy
 +
export LANG=C
  
 +
* Now we would run the setup for the second stage of debootstrap needs to run install the packages downloaded earlier
 +
/debootstrap/debootstrap --second-stage
 +
 +
* Once the package installation has finished, setup some support files and apt configuration.
 +
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
 +
 +
* Update Debian package database:
 +
apt-get update
 +
 +
* Set up locales dpkg scripts since it tends to complain otherwise; note in Debian Jessie you will also need to install the dialog package as well:
 +
apt-get install locales dialog sudo
 +
dpkg-reconfigure locales
 +
 +
* Fix permission for sudo:
 +
chmod u+s /usr/bin/sudo
 +
 +
* Fix ownership of man forlder
 +
chown -R man /var/cache/man
 +
 +
* Install some useful packages inside the chroot:
 +
apt-get install openssh-server ntpdate
 +
 +
* Set a root password so you can login:
 +
passwd
 +
 +
* Build a basic network interface file:
 +
vi /etc/network/interfaces
 +
Add the following to get static ip:
 +
allow-hotplug eth0
 +
iface eth0 inet static
 +
    address 192.168.1.254
 +
    netmask 255.255.255.248
 +
    gateway 192.168.1.1
 +
Or if you want dhcp
 +
allow-hotplug eth0
 +
iface eth0 inet dhcp
 +
 +
Note: Your board will be accessible over SSH on IP address defined above!
 +
 +
* Set the hostname
 +
echo '''myhost'''> /etc/hostname
 +
echo "127.0.0.1      '''myhost'''" >> /etc/hosts
 +
 +
* Enable the serial console, Debian sysvinit way
 +
echo T0:2345:respawn:/sbin/getty -L ttyFIQ0 115200 vt100 >> /etc/inittab
 +
 +
This way you'll get login prompt at startup. By default you cannot login as root. To do this you should make another user, add him to the sudo group, login at startup and then login as root. To skip all this replace the line above with:
 +
echo T0:2345:respawn:/sbin/getty -L ttyFIQ0 -a root 115200 vt100 >> /etc/inittab
 +
 +
* We are done inside the chroot, so quit the chroot shell
 +
exit
 +
 +
* Tidy up the support files
 +
sudo rm $targetdir/etc/resolv.conf
 +
sudo rm $targetdir/usr/bin/qemu-arm-static
 +
 +
 +
===== Installing X =====
 +
----
 +
You cannot run X as root (actually it's possible, but it's a bad practice), so you have to add new user to run X.
 +
 +
* Edit default useradd settings
 +
vi /etc/default/useradd
 +
Modify '''SHELL''' variable:
 +
SHELL=/bin/bash
 +
 +
* Add new user
 +
useradd '''myuser'''
 +
 +
* Add the user to the sudo group
 +
adduser '''myuser''' sudo
 +
 +
* Make home folder
 +
mkdir /home/'''myuser'''
 +
chown -R '''myuser''':'''myuser''' /home/'''myuser'''
 +
 +
* Install xfce4 and lightdm
 +
apt-get update
 +
apt-get install lightdm xfce4
 +
 +
* Modify lightdm configuration to enable autologin:
 +
vi /etc/lightdm/lightdm.conf
 +
autologin-user='''myuser'''
 +
autologin-user-timeout=0
 +
Make sure that the right lines are uncommented. If you don't want autologin just skip the step above.
 +
 +
* Reboot the system
 +
reboot
 +
After the system loads, you should see the default desktop of xfce4.
 +
 +
==== Ubuntu ====
 +
----
 +
 +
You can download prebuild rootfs from [http://releases.linaro.org/ linaro] site or you can build it yourself.
 +
 +
===== Prebuild linaro images =====
 +
----
 +
 +
You can download prebuild images from https://releases.linaro.org/.
 +
In most cases the builds are separated in:
 +
*'''nano'''
 +
*'''developer'''
 +
*'''server'''
 +
*'''alip'''
 +
 +
You can read additional information from [https://wiki.linaro.org/Platform/DevPlatform/Rootfs here].
 +
 +
In this tutorial we will build Ubuntu 14.10 ALIP rootfs.
 +
 +
* Make empty image file:
 +
dd if=/dev/zero of=linaro_alip_rootfs.img bs=1M count=1024
 +
 +
* Format the new image file:
 +
mkfs.ext4 -F -L linuxroot linaro_alip_rootfs.img
 +
 +
* Create mount point:
 +
mkdir mnt
 +
mount -o loop linaro_alip_rootfs.img ./mnt
 +
 +
* Download prebuild image:
 +
wget https://releases.linaro.org/14.10/ubuntu/trusty-images/alip/linaro-trusty-alip-20141024-684.tar.gz
 +
 +
* Make sure that the archive is downloaded:
 +
md5sum linaro-trusty-alip-20141024-684.tar.gz
 +
 +
* Extract is into the mounted image file:
 +
tar -zxvf linaro-trusty-alip-20141024-684.tar.gz
 +
mv binary/* ./mnt
 +
 +
* Copy any modules that are generated with the kernel:
 +
cp -rvf /'''path/to/modules'''/lib/modules ./mnt/lib/
 +
 +
* Chroot into the new rootfs:
 +
cp /usr/bin/qemu-arm-static ./mnt/usr/bin
 +
cp /etc/resolv.conf ./mnt/etc
 +
chroot ./mnt
 +
 +
* Update repository
 +
apt-get update
 +
'''Note!''' If you have a problem with the update, try changing '''sources.list''' to:
 +
deb http://old-releases.ubuntu.com/ubuntu/ raring main universe restricted multiverse
 +
deb-src http://old-releases.ubuntu.com/ubuntu/ raring main universe restricted multiverse
 +
deb http://old-releases.ubuntu.com/ubuntu/ raring-security main universe restricted multiverse
 +
deb-src http://old-releases.ubuntu.com/ubuntu/ raring-security main universe restricted multiverse
 +
deb http://old-releases.ubuntu.com/ubuntu/ raring-updates main universe restricted multiverse
 +
deb-src http://old-releases.ubuntu.com/ubuntu/ raring-updates main universe restricted multiverse
 +
deb http://old-releases.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse
 +
deb-src http://old-releases.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse
 +
deb http://old-releases.ubuntu.com/ubuntu/ raring-proposed main restricted universe multiverse
 +
deb-src http://old-releases.ubuntu.com/ubuntu/ raring-proposed main restricted universe multiverse
  
Next you need to choose the version of Debian in this case we are building a wheezy image.
+
* Install some useful packages:
'''targetdir=rootfs
+
apt-get install ssh nano wpasupplicant wireless-tools
distro=wheezy
+
 
'''
+
* Set root password:
 +
passwd
 +
 
 +
Linaro prebuild images comes with default use '''linaro'''.
 +
* Set password for user:
 +
passwd linaro
 +
 
 +
* Add '''linaro''' to sudo group:
 +
adduser linaro sudo
 +
 
 +
* Configure network. Create new file for loopback, wlan and eth device:
 +
vi /etc/network/interfaces.d/lo
 +
Inside paste:
 +
auto lo
 +
iface lo inet loopback
 +
 
 +
Do the same for eth:
 +
vi /etc/network/interfaces.d/eth
 +
If you're using dhcp:
 +
auto eth0
 +
iface eth0 inet dhcp
 +
Or for static ip:
 +
auto eth0
 +
iface eth0 inet static
 +
    address <your.ip.here>
 +
    netmask <your.netmask.here>
 +
    gateway <your.gateway.here>
 +
 
 +
And another for wireless devices:
 +
vi /etc/network/interfaces.d/wlan
 +
auto wlan0
 +
iface lo inet dhcp
 +
wpa-ssid <your.router.ssid>
 +
wpa-pak <your.ssid.password>
 +
 
 +
'''Note!''' All connections are '''auto'''. If you don't want to use them all the time remove '''auto''' line.
 +
 
 +
You can do some additional work before exit.
 +
When you are ready to exit from the target filesystem:
 +
exit
 +
 
 +
Your rootfs is ready. The next step is to create image for nand or sdcard.
 +
 
 +
===== Manual build using debootstrap =====
 +
----
 +
The procedure is almost identical to the one used for the Debin image.
 +
 
 +
* First of all you need to install the support packages on your pc
 +
sudo apt-get install qemu-user-static debootstrap binfmt-support ubuntu-archive-keyring
 +
 
 +
* We will build latest trusty Ubuntu image:
 +
targetdir=ubuntu
 +
distro=trusty
 +
 
 +
* Now we will build first stage of Ubuntu rootfs:
 +
mkdir $targetdir
 +
sudo debootstrap --arch=armhf --keyring=/usr/share/keyrings/ubuntu-archive-keyring.gpg --foreign $distro $targetdir
 +
 
 +
* Login into the new filesystem
 +
sudo cp /usr/bin/qemu-arm-static $targetdir/usr/bin/
 +
sudo cp /etc/resolv.conf $targetdir/etc
 +
sudo chroot $targetdir
 +
 
 +
* Inside the chroot we need to set up the environment again
 +
distro=trusty
 +
export LANG=C
 +
 
 +
* Now we are setup the second stage of debootstrap needs to run install the packages downloaded earlier
 +
/debootstrap/debootstrap --second-stage
 +
 
 +
* Configure apt-sources:
 +
cat <<EOT > /etc/apt/sources.list
 +
###### Ubuntu Main Repos
 +
deb http://ports.ubuntu.com/ubuntu-ports/ $distro main restricted universe multiverse
 +
deb-src http://ports.ubuntu.com/ubuntu-ports/ $distro main restricted universe multiverse
 +
###### Ubuntu Update Repos
 +
deb http://ports.ubuntu.com/ubuntu-ports/ $distro-security main restricted universe multiverse
 +
deb http://ports.ubuntu.com/ubuntu-ports/ $distro-updates main restricted universe multiverse
 +
deb-src http://ports.ubuntu.com/ubuntu-ports/ $distro-security main restricted universe multiverse
 +
deb-src http://ports.ubuntu.com/ubuntu-ports/ $distro-updates main restricted universe multiverse
 +
EOT
 +
 
 +
* Update Ubuntu package database:
 +
apt-get update
 +
 
 +
* Set a root password so you can login
 +
passwd
 +
 
 +
* Set the hostname
 +
echo '''myhost'''> /etc/hostname
 +
echo "127.0.0.1      '''myhost'''" >> /etc/hosts
 +
 
 +
* Build a basic network interface file so that the board will DHCP on eth0
 +
echo <<EOT >> /etc/network/interfaces
 +
auto lo
 +
iface lo inet loopback
 +
auto eth0
 +
iface eth0 inet dhcp
 +
EOT
 +
 
 +
* Enable the serial console, Debian sysvinit way
 +
echo T0:2345:respawn:/sbin/getty -L ttyFIQ0 115200 vt100 >> /etc/inittab
 +
 
 +
This way you'll get login prompt at startup. By default you cannot login as root. To do this you should make another user,
 +
add him to the sudo group, login at startup and then login as root. To skip all this replace the line above with:
 +
echo T0:2345:respawn:/sbin/getty -L ttyFIQ0 -a root 115200 vt100 >> /etc/inittab
 +
 
 +
* We are done inside the chroot, so quit the chroot shell
 +
exit
 +
 
 +
* Tidy up the support files
 +
sudo rm $targetdir/etc/resolv.conf
 +
sudo rm $targetdir/usr/bin/qemu-arm-static
 +
 
 +
==== Make rootfs image ====
 +
----
 +
 
 +
Once you are ready with the rootfs you can make image file. Later it can be used for NAND or SD image. Go to parent directory of you rootfs.
 +
 
 +
* See how big the image should be:
 +
# du -khs <roofs_folder>
 +
For example this will return 600MB. So we will make 1GB image.
 +
 
 +
* Make empty image:
 +
# dd if=/dev/zero of=rootfs.img bs=1M count=1024
 +
 
 +
* Format the image:
 +
# mkfs.ex4 -F -L linuxroot rootfs.img
 +
 
 +
* Mount the image:
 +
# mount -o loop rootfs.img /mnt
 +
 
 +
* Copy rootfs files into the image:
 +
# cp -prf <root_folder>/* /mnt/
 +
''''Note!''' Use -p option to keep the permissions for the files and folders.
 +
 
 +
* Unmount the image:
 +
# umount /mnt
 +
 
 +
=== Booting from NAND ===
 +
----
 +
* Get rk-tools:
 +
git clone https://github.com/goodybag/rk-tools
 +
cd rk-tools
 +
make
 +
 
 +
*You will need the following files:
 +
**bootloader --> This is RockChip RK3188Loader
 +
**[[#Building parameter file|parameter]] --> Parameter file with crc encryption
 +
**[[#Building kernel|boot]] --> Kernel with ramdisk compiled as shown here
 +
**[[#Creating root filesystem|linux]] --> Rootfs image file
 +
'''CMDLINE''' in parameter file should look something like this:
 +
CMDLINE:console=ttyFIQ0,115200 console=tty0 root=/dev/block/mtd/by-name/linuxroot rw rootfstype=ext4 init=/sbin/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00008000@0x00002000(boot),-@0x0000A000(linuxroot)
 +
 
 +
* Copy all files in '''rk-tools''' folder
 +
 
 +
* Edit '''package-file'''. It should be:
 +
#nano package-file
 
   
 
   
 +
# NAME          Relative path
 +
#
 +
#HWDEF          HWDEF
 +
package-file    package-file
 +
bootloader      RK3188Loader
 +
parameter      parameter
 +
boot            boot.img
 +
linuxroot      rootfs.img
 +
backup          RESERVED
 +
update-script  update-script
 +
recover-script  recover-script
 +
 +
* Pack the image:
 +
./afptool -pack . update_tmp.img
 +
 +
* Update the image:
 +
./img_maker -rk31 RK3188Loader 1 0 0 update_tmp.img update.img
 +
 +
The image should be ready. What's left is flashing the image.
 +
 +
*Important: to flash the image the board needs to be in bootloader mode. To enter bootloader mode you need to press and hold down the recovery button before connecting the board to the PC. After the connection is established you can release the button.
 +
 +
<br>
 +
 +
=== Booting from SD-card ===
 +
----
 +
You'll need at least 512MB sd-card. Depending on rootfs needed size can grow to 4GB.
 +
 +
*You will need the following files:
 +
**sdboot_rk3188.img --> RK3188Loader for booting from SDcard
 +
**[[#Building parameter file|parameter]] --> Parameter file with crc encryption
 +
**[[#Building kernel|boot]] --> Kernel with ramdisk compiled as shown here
 +
**[[#Creating root filesystem|linux]] --> Rootfs image file
 +
 +
 +
'''CMDLINE''' in parameter file should look something like this:
 +
CMDLINE:console=ttyFIQ0,115200 console=tty0 root=/dev/mmcblk0p1 rw rootfstype=ext4 init=/sbin/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00008000@0x00002000(boot),-@0x0000A000(linuxroot)
 +
 +
Insert sd-card. Lets say that your device is '''/dev/sdc'''.
 +
 +
* Write Rockchip loader:
 +
dd if=sdboot_rk3188.img of=/dev/sdc conv=sync,fsync
 +
 +
* Write parameter file:
 +
dd if=parameter.img of=/dev/sdc conv=sync,fsync seek=$((0x2000))
 +
 +
* Write kernel:
 +
dd if=boot.img of=/dev/sdc conv=sync,fsync seek=$((0x2000+0x2000))
  
Now we will build first stage of Debian rootfs :
+
* Write rootfs:
'''mkdir $targetdir
+
dd if=rootfs.img of=/dev/sdc conv=sync,fsync seek=$((0x2000+0xA000))
sudo debootstrap --arch=armhf --foreign $distro $targetdir'''
 
  
   
+
You can do this also on image file:
 +
  dd if=/dev/zero of=sd.img bs=1M count=1024
 +
If 1GB is not enough increase count number.
 +
 
 +
* Write Rockchip loader:
 +
dd if=sdboot_rk3188.img of=sd.img conv=sync,fsync
  
Next copy the qemu-arm-static binary into the right place for the binfmt packages to find it and copy in resolv.conf from the host.
+
* Write parameter file:
'''sudo cp /usr/bin/qemu-arm-static $targetdir/usr/bin/
+
dd if=parameter.img of=sd.img conv=sync,fsync seek=$((0x2000))
sudo cp /etc/resolv.conf $targetdir/etc'''
 
  
   
+
* Write kernel:
 +
  dd if=boot.img of=sd.img conv=sync,fsync seek=$((0x2000+0x2000))
  
If everything is right we now have a minimal Debian Rootfs
+
* Write rootfs:
sudo chroot $targetdir
+
dd if=rootfs.img of=sd.img conv=sync,fsync seek=$((0x2000+0xA000))
  
 +
* Format image:
 +
fdisk sd.img << EOF
 +
n
 +
p
 +
1
 +
49152
 
   
 
   
 +
w
 +
EOF
  
Inside the chroot we need to set up the environment again
+
=== Calibrate touchscreen ===
'''distro=wheezy
+
If you want to use LCD panel with touchscreen, you should perform a screen calibration.
export LANG=C'''
 
  
+
==== Calibrate using tslib ====
 +
----
  
Now we are setup the second stage of debootstrap needs to run install the packages downloaded earlier
+
* Install the required packages:
'''/debootstrap/debootstrap --second-stage'''
+
apt-get update
 +
apt-get install xorg-dev xserver-xorg-dev x11proto-core-dev git automake make libtool
  
   
+
* Download tslib:
 +
  git clone https://github.com/kergoth/tslib.git
 +
cd tslib
  
Once the package installation has finished, setup some support files and apt configuration.
+
* Download patch:
 +
cd plugin
 +
wget https://dl.dropbox.com/u/40057/patches/input-raw.c
 +
cd ../
  
+
* Compile the library:
'''cat <<EOT > /etc/apt/sources.list
+
autoreconf -vi
deb http://ftp.uk.debian.org/debian $distro main contrib non-free
+
./configure --prefix=/usr
deb-src http://ftp.uk.debian.org/debian $distro main contrib non-free
+
make
deb http://ftp.uk.debian.org/debian $distro-updates main contrib non-free
+
make install
deb-src http://ftp.uk.debian.org/debian $distro-updates main contrib non-free
+
  ldconfig
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'''
 
   
 
  
Update Debian package database:
+
* Modify tslib configuration
'''apt-get update'''
+
vi /usr/etc/ts.conf
 +
Uncomment the following line:
 +
module_raw input
  
   
+
* Export tslib needed variables:
 +
  export TSLIB_TSEVENTTYPE=raw
 +
export TSLIB_CONSOLEDEVICE=none
 +
export TSLIB_FBDEVICE=/dev/fb0
 +
export TSLIB_TSDEVICE=/dev/input/event0
 +
export TSLIB_CALIBFILE=/usr/etc/pointercal
 +
export TSLIB_CONFFILE=/usr/etc/ts.conf
 +
export TSLIB_PLUGINDIR=/usr/lib/ts
  
set up locales dpkg scripts tend to complain otherwise, note in jessie you will also need to install the dialog package as well.
+
* Now tslib is working but still it should be set as default driver in the X:
 +
wget http://ftp.de.debian.org/debian/pool/main/x/xf86-input-tslib/xf86-input-tslib_0.0.6.orig.tar.gz
 +
tar zxfv xf86-input-tslib_0.0.6.orig.tar.gz
 +
cd xf86-input-tslib-0.0.6/
 +
Replace tslib.c file with patched one:
 +
cd src/
 +
rm -f tslib.c
 +
wget https://dl.dropbox.com/u/40057/patches/tslib.c
 +
cd ..
 +
Build and install package:
 +
./configure --prefix=/usr
 +
make
 +
make install
  
   
+
* Add tslib configuration:
'''apt-get install locales dialog
+
cd /usr/share/X11/xorg.conf.d/
dpkg-reconfigure locales'''
+
Make new file:
 +
nano 20-touchscreen.conf
 +
Add the following text inside:
 +
  Section "InputClass"
 +
        Identifier "AR1020"
 +
        MatchDevicePath "/dev/input/event0"
 +
        Driver "tslib"
 +
        Option "Device" "/dev/input/event0"
 +
        Option "ScreenNumber" "0"
 +
        Option "Rotate" "NONE"
 +
        Option "Width" "'''800'''"
 +
        Option "Height" "'''480'''"
 +
        Option "SendCoreEvents" "yes"
 +
        Option "Type" "touchscreen"
 +
EndSection
 +
Note! Resolution in this example is set for 7 inch LCD.
  
   
+
* Do the actual calibration:
 +
  service lightdm stop
 +
ts_calibrate
 +
service lightdm start
 +
After lightdm start you could check if everything is running smoothly.
  
Install some useful packages inside the chroot
+
* Save tslib variables:
apt-get install openssh-server ntpdate
+
vi /etc/environment
 +
Paste the following:
 +
TSLIB_TSEVENTTYPE=raw
 +
TSLIB_CONSOLEDEVICE=none
 +
TSLIB_FBDEVICE=/dev/fb0
 +
TSLIB_TSDEVICE=/dev/input/event0
 +
TSLIB_CALIBFILE=/etc/pointercal
 +
TSLIB_CONFFILE=/usr/etc/ts.conf
 +
TSLIB_PLUGINDIR=/usr/lib/ts
  
+
If you change the LCD panel run ts_calibrate to configure touchscreen for the new LCD.
  
Set a root password so you can login
+
==== Calibrate using AR1021 driver ====
'''passwd'''
+
TODO
  
+
=== Enabling wireless modules ===
 +
==== RTL8188CUS ====
 +
----
 +
[[File:MOD-WIFI-RTL8188-1.jpg|thumb|[https://www.olimex.com/Products/USB-Modules/MOD-WIFI-RTL8188/ MOD-WIFI-RTL8188]]]
 +
To connect OLinuXino board with wireless, you could use [https://www.olimex.com/Products/USB-Modules/MOD-WIFI-RTL8188/ MOD-WIFI-RTL8188] dongle. Also you can use another one with the same chip.
  
Build a basic network interface file so that the board will DHCP on eth0
+
[https://www.olimex.com/Products/USB-Modules/MOD-WIFI-RTL8188/ MOD-WIFI-RTL8188] has the following features:
'''echo <<EOT >> /etc/network/interfaces
+
* Has WM-294 module with RTL8188
allow-hotplug eth0
+
* Operates in 2.4 GHz frequency bands
iface eth0 inet static
+
* 1x1 MIMO technology improves effective throughput and range over existing 802.11 b/g products
address 192.168.1.254
+
* Data rates: up to 150Mbps
netmask 255.255.255.248
+
* 802.11e-compatible bursting and I standards BPSK, QPSK, 16 QAM, 64 QAM modulation schemes WEP, TKIP, and AES, WPA, WPA2 hardware encryption schemes
gateway 192.168.1.1
+
* Standard USB type A connector
EOT
+
* On-board antenna
'''
+
* 5V/3.3V operation modes via SMD jumper
+
* 4 test pads for easy tracking the supply, d-, d+, and GND
 +
* PCB: FR-4, 1.00 mm (0,039"), solder mask, silkscreen component print
 +
* Dimensions: 65.15x20.38 mm (2.56x0.80")
 +
----
  
Note: Your board will be accessible over SSH on IP address defined above !
+
The kernel module is prebuild. You should just get it loaded and then plug the dongle.
 +
* Load the module:
 +
modprobe 8192cu
  
   
+
* Plug the device and check if it is available:
 +
  ifconfig -a
  
Set the hostname
+
==== RT5370 ====
'''echo nameme > /etc/hostname
+
----
'''
+
[[File:MOD-WIFI-R5370-ANT-1.jpg|border|thumb|[https://www.olimex.com/Products/USB-Modules/MOD-WIFI-R5370-ANT/ MOD-WIFI-R5370-ANT]]]
 
  
Enable the serial console, Debian sysvinit way
+
To use one this wifi dongle (like [https://www.olimex.com/Products/USB-Modules/MOD-WIFI-R5370/ MOD-WIFI-R5370] or [https://www.olimex.com/Products/USB-Modules/MOD-WIFI-R5370-ANT/ MOD-WIFI-R5370-ANT]) additional files are required.
'''echo T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt100 >> /etc/inittab
 
'''
 
 
  
We are done inside the chroot, so quit the chroot shell
+
[https://www.olimex.com/Products/USB-Modules/MOD-WIFI-R5370-ANT/ MOD-WIFI-R5370-ANT] has the following features:
'''exit'''
 
  
+
* 2.4GHz with 150Mbps PHY data rate
 +
*External antenna for extended range
 +
*USB 2.0 interface
 +
*Security: WEP/TKIP/AES/WPA/WPA2/WAPI
 +
*CMOS single chip with RF, baseband, and MAC integration
 +
*QoS: WMM & WMM-PS support
 +
*Multiple BSSID support
 +
*Maximum likelihood decoding support
 +
*Cisco CCX 5.0 support
 +
*Low-power usage with advanced power management
 +
----
  
Tidy up the support files
+
*First a make new directory and navigate to it. This is where the module will search for files.
'''sudo rm $targetdir/etc/resolv.conf
+
mkdir -p /etc/Wireless/RT2870STA
sudo rm $targetdir/usr/bin/qemu-arm-static'''
+
cd /etc/Wireless/RT2870STA/
  
   
+
*Download the files from Github
 +
  wget https://raw.githubusercontent.com/SelfDestroyer/RK3188-SOM/olimex/stable-3.0/drivers/net/wireless/rtxx7x/RT2870STA.dat
 +
wget https://raw.githubusercontent.com/SelfDestroyer/RK3188-SOM/olimex/stable-3.0/drivers/net/wireless/rtxx7x/RT2870STACard.dat
  
Now you have your Debian rootfs. Next step is to build Kernel, Uboot and to make your SD-card as explained in our early posts and Build instructions but instead to use the rootfs in the posts you can use your own minimal rootfs which you created above. The rootfs image created above is approx 150MB, it could be made smaller if you remove more packages.
+
*Load module
 +
modprobe rt5370sta
  
 +
*Plug the device and run:
 +
ifconfig -a
 +
*You should see this:
 +
wlan0    Link encap:Ethernet  HWaddr 00:00:00:00:00:00
 +
          BROADCAST MULTICAST  MTU:1500  Metric:1
 +
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
 +
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 +
          collisions:0 txqueuelen:1000
 +
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
  
 +
*Configure your new device:
 +
vi /etc/network/interfaces
 +
*Add configuration. Here we will show DHCP configuration.
 +
iface wlan0 inet dhcp
 +
wpa-ssid "'''your ssid'''"
 +
wpa-psk "'''your password'''"
  
 +
*Save the configuration and up the interface:
 +
ifup wlan0
  
apt-get install xfce4
+
*If everything is working and this module to be loaded on boot:
apt-get install lightdm
+
echo rt5370sta >> /etc/modules
chsh -s /bin/bash username
 
  
=== Booting from NAND ===
 
=== Booting from USB-stick ===
 
 
== Android ==
 
== Android ==

Latest revision as of 03:24, 21 April 2023

Overview

Rk3188-som-resized.png

RK3188-SOM board is a very productive small beast compared to the previous Olimex board designs. If we compare RockChip RK3188 and Allwinner A20: RK3188 has 4x Cortex-A9, while A20 only 2x Cortex-A7. It runs at 1.6 GHz vs. the 1.0 GHz frequency of the A20. RK3188 reaches a total of 16000 DMPIS vs. the 3800 DMIPS for the A20 (RK3188 is 4.2 times faster). For comparison, the RaspberryPi has 965 DMIPS (RK3188 is 16.6 times faster).

The RK3188-SOM design has the following features:

  • Rockchip RK3188 quad core Cortex-A9 processor, each core typically running at 1.6GHz
  • 1GB DDR3 memory
  • Integrated power management unit
  • Optional 4GB NAND flash memory for Linux or Android boot
  • Micro SD-card for Linux or Android boot
  • Three buttons - POWER, RESET, RECOVERY
  • Four LEDs (one for power and three user-programmable)
  • UART console pins exposed for serial debug
  • Five GPIO connectors 2×20 pins @ 0.05" step
  • Dimensions: (3.2×1.8)" ~ (81×56)mm


Ready-to-use Debian images

Debian for microSD card

Newest official release (recommended):

Direct download of Debian release #2:RK3188-SOM Debian for microSD card - kernel 3.0.36+ - release #2

In the command line interface of image you are automatically logged as root. The default superuser username/password combination in the GUI (XFCE4) is: olimex/olimex.

Build instructions and links to required files for the latest Debian images might be found below in chapter "Building Linux for RK3188-SOM".

Older official releases (not recommended):

Direct download of Debian release #1:RK3188-SOM Debian for microSD card - kernel 3.0.36+ - release #1

How to prepare your microSD card with the suitable official Debian image?


In order to download an official Linux image to a microSD card under Windows you can use Win32 Disk Imager: click here

1. Download the latest official image suitable for a microSD card from the chapter above

2. Download Win32 Disk Imager from this link.

3. Insert card in your microSD card reader.

4. Launch the software.

5. Point the software to the image

6. Click "write"

Under Linux you can write the image image to the card with dd utility. This is how it can be done:

Let's say the name of the image is "debian_2g.img". It would be downloaded to the microSD card connected to a Linux machine using one of the following commands:

dd bs=4M oflag=sync if=debian_2g.img of=/dev/sdX

or

cp debian_2g.img /dev/sdX

where /dev/sdX is the uSD card as listed by the Linux.

Debian for NAND memory

Newest official release (recommended):

Direct download Debian for NAND release #1: Debian for NAND memory - kernel 3.0.36+ - release #1

Note that this image is suitable only for RK3188-SOM-4GB boards.

Build instructions and links to required files for the latest Debian images might be found below in chapter "Building Linux for RK3188-SOM"

How to download the ready Debian image to the NAND memory of RK3188-SOM?


IMPORTANT: RK3188-SOM-4GB comes with Debian already pre-loaded on the NAND memory. No need to perform this operation initially.

1. You need to download the software tools for your computer provided by Rockchip. If you use Windows download “Rockchip Batch Tool”. If you use Linux use either rkflashkit or upgrade_tool. These are the tools that I recommend but there are a lot of tools available. Get the Rockchip batch tool from here: Rockchip Batch Tool

For Windows:

2. Install the drivers that allows your computer to recognize the board (that is already set in bootloader mode) connected to it. The installer is called "Rockchip Driver Assistant" – download it here: Rockchip Driver Assistant

3. You need to download and extract the latest image suitable for the NAND from our wiki. It is available as a direct download here: Debian 3.0.36 for NAND memory

4. You need enter bootloader mode with the board to be able to establish connection between the board and the software provided by Rockchip. You would also need a mini USB cable. To enter bootloader mode you need to press and hold down the recovery button before powering the board (then connect the board to the PC via the mini USB cable). After the board is powered you can release the button.

5. Start the tool for uploading the firmware and point it to the extracted image.

6. Click button "Upgrade".

7. Test with a serial cable.

Ready-to-use Android images

TODO

Documents

OLIMEX RK3188-SOM user's manual

OLIMEX RK3188-SOM-EVB user's manual

Processor (Rockchip RK3188) datasheet in pdf format

RK3188-SOM connectors' pinout and GPIO table

CAD files

RK3188-SOM is considered commercial, proprietary design. The board file is not available to the customer. A pdf extracted from the original schematic is available at GitHub: RK3188-SOM schematics

RK3188-SOM-EVB is considered Open Source Hardware, Eagle CAD files are available also at GitHub: RK3188-SOM-EVB sources

The CAD product used to design OLinuXino is Eagle and you can download evaluation free version from their web site. The evaluation version allows you to inspect the schematic and the board file sources.

Board Layout

Rk3188-som-resized-TOP-NAMED.png


Rk3188-som-resized-BOTTOM-NAMED.png

Building Linux for RK3188-SOM

Building the parameter file


The parameter file describes many board parameters as firmware version, machine id, manufacturer name, etc.

For the user the most important parameter is CMDLINE. This is the command that is passed to the kernel. It looks something like this:

CMDLINE:console=ttyFIQ0,115200 console=tty0 root=/dev/mmcblk0p1 rw rootfstype=ext4 init=/sbin/init initrd=0x62000000,0x00800000 \
mtdparts=rk29xxnand:0x00008000@0x00002000(boot),-@0x0000A000(linuxroot)

Define serial port at 115200:

console=ttyFIQ0,115200

Define location of the rootfs:

root=/dev/mmcblk0p1

Define rootfs file system as ext4:

rootfstype=ext4

Define the address of the kernel and size:

0x00008000@0x00002000

Define start address of the rootfs:

-@0x0000A000

Additionally, you can set static MAC address with:

mac_addr=xx:xx:xx:xx:xx:xx 

Once you're ready with the file, make the parameter image

  • Get rkutils:
https://github.com/naobsd/rkutils
cd rkutils
gcc rkcrc.c -o rkcrc

If you're getting error try to comment '#include <err.h>' in 'rkcrc.c'

  • Encrypt parameter file:
./rkcrc -p you_parameter_file parameter

The parameter file is ready for further use.

Building the kernel


  • Fist prepare the toolchain:
apt-get update
apt-get install gcc-4.7-arm-linux-gnueabihf ncurses-dev uboot-mkimage build-essential git
  • Get the sources:
git clone -b olimex/stable-3.0 https://github.com/StefanMavrodiev/RK3188-SOM.git
  • Get the default configuration:
cd RK3188-SOM/
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- olimex_rk3188_defconfig
  • You can modify defconfig with (for additional modules):
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Note! The default config will set hdmi to 1080p. You can change it from:

Device Drivers --->
    Graphics support --->
        <*> Frame buffer support for Rockchip --->
                LCD Panel Select --->
                    Choose one of the following:
                    HDMI framebuffer size and timing is 1080p    <---    Set HDMI to 1080p
                    HDMI framebuffer size and timing is 720p     <---    Set HDMI to 720p
                    HDMI framebuffer size and timing is 480p     <---    Set HDMI to 480p
                    RGB AT070TN90    <---    LCD-OLinuXino-7
                    RGB AR010H05N    <---    LCD-OLinuXino-10
                    RGB BT043DCNNHHP <---    LCD-OLinuXino-4.3TS
  • Build the kernel:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 kernel.img

After the build is finish you will have RK3188-SOM/kernel.img and RK3188-SOM/arch/arm/boot/Image. The first one can be uploaded to the kernel partition (if you have one). The second file is raw binary. It can be combined with ramdisk to get boot.img.

  • Generate ramdisk
cd ../
git clone https://github.com/radxa/initrd.git
cd initrd/
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 
cd ../
  • Make mkbootimg
git clone https://github.com/neo-technologies/rockchip-mkbootimg.git
cd rockchip-mkbootimg
make
make install
cd ../
  • Make boot.img
mkbootimg --kernel RK3188-SOM/arch/arm/boot/Image --ramdisk initrd.img -o boot.img

Creating the root filesystem

Debian Wheezy


In this post we will explain how you can create your own Debian rootfs with pre-installed packages of your choice, which to allow tiny Linux images to be created. All steps below should work on any Debian host (Debian/Ubuntu etc) and are verified with Ubuntu 12.04LTS. First of all you need to install the support packages on your pc:

  • Install the needed packages:
sudo apt-get install qemu-user-static debootstrap binfmt-support
  • Define some variables:
targetdir=rootfs
distro=wheezy
  • Build first stage:
mkdir $targetdir
sudo debootstrap --arch=armhf --foreign $distro $targetdir
  • Copy needed files from host to the target:
sudo cp /usr/bin/qemu-arm-static $targetdir/usr/bin/
sudo cp /etc/resolv.conf $targetdir/etc

We should now have a minimal Debian Rootfs.

  • Login into the new filesystem:
sudo chroot $targetdir 
  • Inside the chroot we need to set up the environment again:
distro=wheezy
export LANG=C 
  • Now we would run the setup for the second stage of debootstrap needs to run install the packages downloaded earlier
/debootstrap/debootstrap --second-stage
  • Once the package installation has finished, setup some support files and apt configuration.
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 
  • Update Debian package database:
apt-get update
  • Set up locales dpkg scripts since it tends to complain otherwise; note in Debian Jessie you will also need to install the dialog package as well:
apt-get install locales dialog sudo
dpkg-reconfigure locales
  • Fix permission for sudo:
chmod u+s /usr/bin/sudo
  • Fix ownership of man forlder
chown -R man /var/cache/man
  • Install some useful packages inside the chroot:
apt-get install openssh-server ntpdate 
  • Set a root password so you can login:
passwd
  • Build a basic network interface file:
vi /etc/network/interfaces

Add the following to get static ip:

allow-hotplug eth0
iface eth0 inet static
    address 192.168.1.254
    netmask 255.255.255.248
    gateway 192.168.1.1

Or if you want dhcp

allow-hotplug eth0
iface eth0 inet dhcp

Note: Your board will be accessible over SSH on IP address defined above!

  • Set the hostname
echo myhost> /etc/hostname
echo "127.0.0.1       myhost" >> /etc/hosts
  • Enable the serial console, Debian sysvinit way
echo T0:2345:respawn:/sbin/getty -L ttyFIQ0 115200 vt100 >> /etc/inittab

This way you'll get login prompt at startup. By default you cannot login as root. To do this you should make another user, add him to the sudo group, login at startup and then login as root. To skip all this replace the line above with:

echo T0:2345:respawn:/sbin/getty -L ttyFIQ0 -a root 115200 vt100 >> /etc/inittab
  • We are done inside the chroot, so quit the chroot shell
exit
  • Tidy up the support files
sudo rm $targetdir/etc/resolv.conf
sudo rm $targetdir/usr/bin/qemu-arm-static


Installing X

You cannot run X as root (actually it's possible, but it's a bad practice), so you have to add new user to run X.

  • Edit default useradd settings
vi /etc/default/useradd

Modify SHELL variable:

SHELL=/bin/bash
  • Add new user
useradd myuser
  • Add the user to the sudo group
adduser myuser sudo
  • Make home folder
mkdir /home/myuser
chown -R myuser:myuser /home/myuser
  • Install xfce4 and lightdm
apt-get update
apt-get install lightdm xfce4
  • Modify lightdm configuration to enable autologin:
vi /etc/lightdm/lightdm.conf
autologin-user=myuser
autologin-user-timeout=0

Make sure that the right lines are uncommented. If you don't want autologin just skip the step above.

  • Reboot the system
reboot

After the system loads, you should see the default desktop of xfce4.

Ubuntu


You can download prebuild rootfs from linaro site or you can build it yourself.

Prebuild linaro images

You can download prebuild images from https://releases.linaro.org/. In most cases the builds are separated in:

  • nano
  • developer
  • server
  • alip

You can read additional information from here.

In this tutorial we will build Ubuntu 14.10 ALIP rootfs.

  • Make empty image file:
dd if=/dev/zero of=linaro_alip_rootfs.img bs=1M count=1024
  • Format the new image file:
mkfs.ext4 -F -L linuxroot linaro_alip_rootfs.img
  • Create mount point:
mkdir mnt
mount -o loop linaro_alip_rootfs.img ./mnt
  • Download prebuild image:
wget https://releases.linaro.org/14.10/ubuntu/trusty-images/alip/linaro-trusty-alip-20141024-684.tar.gz
  • Make sure that the archive is downloaded:
md5sum linaro-trusty-alip-20141024-684.tar.gz
  • Extract is into the mounted image file:
tar -zxvf linaro-trusty-alip-20141024-684.tar.gz
mv binary/* ./mnt
  • Copy any modules that are generated with the kernel:
cp -rvf /path/to/modules/lib/modules ./mnt/lib/
  • Chroot into the new rootfs:
cp /usr/bin/qemu-arm-static ./mnt/usr/bin
cp /etc/resolv.conf ./mnt/etc
chroot ./mnt
  • Update repository
apt-get update

Note! If you have a problem with the update, try changing sources.list to:

deb http://old-releases.ubuntu.com/ubuntu/ raring main universe restricted multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ raring main universe restricted multiverse
deb http://old-releases.ubuntu.com/ubuntu/ raring-security main universe restricted multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ raring-security main universe restricted multiverse
deb http://old-releases.ubuntu.com/ubuntu/ raring-updates main universe restricted multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ raring-updates main universe restricted multiverse
deb http://old-releases.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ raring-proposed main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ raring-proposed main restricted universe multiverse
  • Install some useful packages:
apt-get install ssh nano wpasupplicant wireless-tools
  • Set root password:
passwd

Linaro prebuild images comes with default use linaro.

  • Set password for user:
passwd linaro
  • Add linaro to sudo group:
adduser linaro sudo
  • Configure network. Create new file for loopback, wlan and eth device:
vi /etc/network/interfaces.d/lo

Inside paste:

auto lo
iface lo inet loopback

Do the same for eth:

vi /etc/network/interfaces.d/eth

If you're using dhcp:

auto eth0
iface eth0 inet dhcp

Or for static ip:

auto eth0
iface eth0 inet static
    address <your.ip.here>
    netmask <your.netmask.here>
    gateway <your.gateway.here>

And another for wireless devices:

vi /etc/network/interfaces.d/wlan
auto wlan0
iface lo inet dhcp
wpa-ssid <your.router.ssid>
wpa-pak <your.ssid.password>

Note! All connections are auto. If you don't want to use them all the time remove auto line.

You can do some additional work before exit. When you are ready to exit from the target filesystem:

exit

Your rootfs is ready. The next step is to create image for nand or sdcard.

Manual build using debootstrap

The procedure is almost identical to the one used for the Debin image.

  • First of all you need to install the support packages on your pc
sudo apt-get install qemu-user-static debootstrap binfmt-support ubuntu-archive-keyring
  • We will build latest trusty Ubuntu image:
targetdir=ubuntu
distro=trusty
  • Now we will build first stage of Ubuntu rootfs:
mkdir $targetdir
sudo debootstrap --arch=armhf --keyring=/usr/share/keyrings/ubuntu-archive-keyring.gpg --foreign $distro $targetdir 
  • Login into the new filesystem
sudo cp /usr/bin/qemu-arm-static $targetdir/usr/bin/
sudo cp /etc/resolv.conf $targetdir/etc
sudo chroot $targetdir
  • Inside the chroot we need to set up the environment again
distro=trusty
export LANG=C
  • Now we are setup the second stage of debootstrap needs to run install the packages downloaded earlier
/debootstrap/debootstrap --second-stage
  • Configure apt-sources:
cat <<EOT > /etc/apt/sources.list
###### Ubuntu Main Repos
deb http://ports.ubuntu.com/ubuntu-ports/ $distro main restricted universe multiverse 
deb-src http://ports.ubuntu.com/ubuntu-ports/ $distro main restricted universe multiverse 
###### Ubuntu Update Repos
deb http://ports.ubuntu.com/ubuntu-ports/ $distro-security main restricted universe multiverse 
deb http://ports.ubuntu.com/ubuntu-ports/ $distro-updates main restricted universe multiverse 
deb-src http://ports.ubuntu.com/ubuntu-ports/ $distro-security main restricted universe multiverse 
deb-src http://ports.ubuntu.com/ubuntu-ports/ $distro-updates main restricted universe multiverse 
EOT
  • Update Ubuntu package database:
apt-get update
  • Set a root password so you can login
passwd
  • Set the hostname
echo myhost> /etc/hostname
echo "127.0.0.1       myhost" >> /etc/hosts
  • Build a basic network interface file so that the board will DHCP on eth0
echo <<EOT >> /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
EOT
  • Enable the serial console, Debian sysvinit way
echo T0:2345:respawn:/sbin/getty -L ttyFIQ0 115200 vt100 >> /etc/inittab

This way you'll get login prompt at startup. By default you cannot login as root. To do this you should make another user, add him to the sudo group, login at startup and then login as root. To skip all this replace the line above with:

echo T0:2345:respawn:/sbin/getty -L ttyFIQ0 -a root 115200 vt100 >> /etc/inittab
  • We are done inside the chroot, so quit the chroot shell
exit
  • Tidy up the support files
sudo rm $targetdir/etc/resolv.conf
sudo rm $targetdir/usr/bin/qemu-arm-static

Make rootfs image


Once you are ready with the rootfs you can make image file. Later it can be used for NAND or SD image. Go to parent directory of you rootfs.

  • See how big the image should be:
# du -khs <roofs_folder>

For example this will return 600MB. So we will make 1GB image.

  • Make empty image:
# dd if=/dev/zero of=rootfs.img bs=1M count=1024
  • Format the image:
# mkfs.ex4 -F -L linuxroot rootfs.img
  • Mount the image:
# mount -o loop rootfs.img /mnt
  • Copy rootfs files into the image:
# cp -prf <root_folder>/* /mnt/

'Note! Use -p option to keep the permissions for the files and folders.

  • Unmount the image:
# umount /mnt

Booting from NAND


  • Get rk-tools:
git clone https://github.com/goodybag/rk-tools
cd rk-tools
make
  • You will need the following files:
    • bootloader --> This is RockChip RK3188Loader
    • parameter --> Parameter file with crc encryption
    • boot --> Kernel with ramdisk compiled as shown here
    • linux --> Rootfs image file

CMDLINE in parameter file should look something like this:

CMDLINE:console=ttyFIQ0,115200 console=tty0 root=/dev/block/mtd/by-name/linuxroot rw rootfstype=ext4 init=/sbin/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00008000@0x00002000(boot),-@0x0000A000(linuxroot)
  • Copy all files in rk-tools folder
  • Edit package-file. It should be:
#nano package-file

# NAME          Relative path
#
#HWDEF          HWDEF
package-file    package-file
bootloader      RK3188Loader
parameter       parameter
boot            boot.img
linuxroot       rootfs.img
backup          RESERVED
update-script   update-script
recover-script  recover-script
  • Pack the image:
./afptool -pack . update_tmp.img
  • Update the image:
./img_maker -rk31 RK3188Loader 1 0 0 update_tmp.img update.img

The image should be ready. What's left is flashing the image.

  • Important: to flash the image the board needs to be in bootloader mode. To enter bootloader mode you need to press and hold down the recovery button before connecting the board to the PC. After the connection is established you can release the button.


Booting from SD-card


You'll need at least 512MB sd-card. Depending on rootfs needed size can grow to 4GB.

  • You will need the following files:
    • sdboot_rk3188.img --> RK3188Loader for booting from SDcard
    • parameter --> Parameter file with crc encryption
    • boot --> Kernel with ramdisk compiled as shown here
    • linux --> Rootfs image file


CMDLINE in parameter file should look something like this:

CMDLINE:console=ttyFIQ0,115200 console=tty0 root=/dev/mmcblk0p1 rw rootfstype=ext4 init=/sbin/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00008000@0x00002000(boot),-@0x0000A000(linuxroot)

Insert sd-card. Lets say that your device is /dev/sdc.

  • Write Rockchip loader:
dd if=sdboot_rk3188.img of=/dev/sdc conv=sync,fsync
  • Write parameter file:
dd if=parameter.img of=/dev/sdc conv=sync,fsync seek=$((0x2000))
  • Write kernel:
dd if=boot.img of=/dev/sdc conv=sync,fsync seek=$((0x2000+0x2000))
  • Write rootfs:
dd if=rootfs.img of=/dev/sdc conv=sync,fsync seek=$((0x2000+0xA000))

You can do this also on image file:

dd if=/dev/zero of=sd.img bs=1M count=1024

If 1GB is not enough increase count number.

  • Write Rockchip loader:
dd if=sdboot_rk3188.img of=sd.img conv=sync,fsync
  • Write parameter file:
dd if=parameter.img of=sd.img conv=sync,fsync seek=$((0x2000))
  • Write kernel:
dd if=boot.img of=sd.img conv=sync,fsync seek=$((0x2000+0x2000))
  • Write rootfs:
dd if=rootfs.img of=sd.img conv=sync,fsync seek=$((0x2000+0xA000))
  • Format image:
fdisk sd.img << EOF
n
p
1
49152

w
EOF

Calibrate touchscreen

If you want to use LCD panel with touchscreen, you should perform a screen calibration.

Calibrate using tslib


  • Install the required packages:
apt-get update
apt-get install xorg-dev xserver-xorg-dev x11proto-core-dev git automake make libtool
  • Download tslib:
git clone https://github.com/kergoth/tslib.git
cd tslib
  • Download patch:
cd plugin
wget https://dl.dropbox.com/u/40057/patches/input-raw.c
cd ../
  • Compile the library:
autoreconf -vi
./configure --prefix=/usr
make
make install
ldconfig
  • Modify tslib configuration
vi /usr/etc/ts.conf

Uncomment the following line:

module_raw input
  • Export tslib needed variables:
export TSLIB_TSEVENTTYPE=raw
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_CALIBFILE=/usr/etc/pointercal
export TSLIB_CONFFILE=/usr/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/lib/ts
  • Now tslib is working but still it should be set as default driver in the X:
wget http://ftp.de.debian.org/debian/pool/main/x/xf86-input-tslib/xf86-input-tslib_0.0.6.orig.tar.gz
tar zxfv xf86-input-tslib_0.0.6.orig.tar.gz
cd xf86-input-tslib-0.0.6/

Replace tslib.c file with patched one:

cd src/
rm -f tslib.c 
wget https://dl.dropbox.com/u/40057/patches/tslib.c
cd ..

Build and install package:

./configure --prefix=/usr
make
make install
  • Add tslib configuration:
cd /usr/share/X11/xorg.conf.d/

Make new file:

nano 20-touchscreen.conf

Add the following text inside:

Section "InputClass"
       Identifier "AR1020"
       MatchDevicePath "/dev/input/event0"
       Driver "tslib"
       Option "Device" "/dev/input/event0"
       Option "ScreenNumber" "0"
       Option "Rotate" "NONE"
       Option "Width" "800"
       Option "Height" "480"
       Option "SendCoreEvents" "yes"
       Option "Type" "touchscreen"
EndSection

Note! Resolution in this example is set for 7 inch LCD.

  • Do the actual calibration:
service lightdm stop
ts_calibrate
service lightdm start

After lightdm start you could check if everything is running smoothly.

  • Save tslib variables:
vi /etc/environment

Paste the following:

TSLIB_TSEVENTTYPE=raw
TSLIB_CONSOLEDEVICE=none
TSLIB_FBDEVICE=/dev/fb0
TSLIB_TSDEVICE=/dev/input/event0
TSLIB_CALIBFILE=/etc/pointercal
TSLIB_CONFFILE=/usr/etc/ts.conf
TSLIB_PLUGINDIR=/usr/lib/ts

If you change the LCD panel run ts_calibrate to configure touchscreen for the new LCD.

Calibrate using AR1021 driver

TODO

Enabling wireless modules

RTL8188CUS


To connect OLinuXino board with wireless, you could use MOD-WIFI-RTL8188 dongle. Also you can use another one with the same chip.

MOD-WIFI-RTL8188 has the following features:

  • Has WM-294 module with RTL8188
  • Operates in 2.4 GHz frequency bands
  • 1x1 MIMO technology improves effective throughput and range over existing 802.11 b/g products
  • Data rates: up to 150Mbps
  • 802.11e-compatible bursting and I standards BPSK, QPSK, 16 QAM, 64 QAM modulation schemes WEP, TKIP, and AES, WPA, WPA2 hardware encryption schemes
  • Standard USB type A connector
  • On-board antenna
  • 5V/3.3V operation modes via SMD jumper
  • 4 test pads for easy tracking the supply, d-, d+, and GND
  • PCB: FR-4, 1.00 mm (0,039"), solder mask, silkscreen component print
  • Dimensions: 65.15x20.38 mm (2.56x0.80")

The kernel module is prebuild. You should just get it loaded and then plug the dongle.

  • Load the module:
modprobe 8192cu
  • Plug the device and check if it is available:
ifconfig -a

RT5370


To use one this wifi dongle (like MOD-WIFI-R5370 or MOD-WIFI-R5370-ANT) additional files are required.

MOD-WIFI-R5370-ANT has the following features:

  • 2.4GHz with 150Mbps PHY data rate
  • External antenna for extended range
  • USB 2.0 interface
  • Security: WEP/TKIP/AES/WPA/WPA2/WAPI
  • CMOS single chip with RF, baseband, and MAC integration
  • QoS: WMM & WMM-PS support
  • Multiple BSSID support
  • Maximum likelihood decoding support
  • Cisco CCX 5.0 support
  • Low-power usage with advanced power management

  • First a make new directory and navigate to it. This is where the module will search for files.
mkdir -p /etc/Wireless/RT2870STA
cd /etc/Wireless/RT2870STA/
  • Download the files from Github
wget https://raw.githubusercontent.com/SelfDestroyer/RK3188-SOM/olimex/stable-3.0/drivers/net/wireless/rtxx7x/RT2870STA.dat
wget https://raw.githubusercontent.com/SelfDestroyer/RK3188-SOM/olimex/stable-3.0/drivers/net/wireless/rtxx7x/RT2870STACard.dat
  • Load module
modprobe rt5370sta
  • Plug the device and run:
ifconfig -a
  • You should see this:
wlan0     Link encap:Ethernet  HWaddr 00:00:00:00:00:00
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
  • Configure your new device:
vi /etc/network/interfaces
  • Add configuration. Here we will show DHCP configuration.
iface wlan0 inet dhcp
wpa-ssid "your ssid"
wpa-psk "your password"
  • Save the configuration and up the interface:
ifup wlan0
  • If everything is working and this module to be loaded on boot:
echo rt5370sta >> /etc/modules

Android