RK3188-SOM

Revision as of 00:27, 20 November 2014 by StefanM (talk | contribs) (Booting from SD-card)

Overview

This one is little beast comparing to A20 it have 4x Cortex-A9 vs 2x Cortex-A7 and runs on 1.6GHz vs. 1GHz so RK3188 makes total 16000 DMPIS vs. 3800 DMIPS for A20 (4.2 times faster) and vs. 965 DMIPS for RaspberryPi (16.6 times faster).

On the SOM there is:

  • RK3188 running at 1.6Ghz
  • 1GB DDR3 memory
  • Power Managment Unit IC
  • Optional 4GB NAND Flash
  • Micro SD-card to boot Llinux or Android
  • Three buttons
  • Four status LEDs (one for power and three programmable)
  • Debug UART console
  • Five GPIO connectors 2×20 pins 0.05″ step

Linux

Booting from SD-card

Preparing the SD-cadr

dd if=sdboot_rk3188.img of=sd.img conv=notrunc dd if=parameter.img of=sd.img conv=notrunc seek=$((0x2000)) dd if=boot-linux.img of=sd.img conv=notrunc seek=$((0x2000+0x2000)) dd if=rootfs.img of=sd.img conv=notrunc seek=$((0x2000+0xA000))


Next, as you expect the rootfs to be the first partition of the disk (cf. parameter root=/dev/mmcblk0p1), then you must create this partition. You can use fdisk for that purpose. $ fdisk sd.img

Command (m for help):


Type n to create a new partition. Partition type

  p   primary (0 primary, 0 extended, 4 free)
  e   extended (container for logical partitions)

Select (default p):


Press enter to use the default type (primary). Partition number (1-4, default 1):


Just press enter again (the default is partition 1). First sector (2048-..., default 2048):


For the first sector, you have to calculate the offset of the rootfs. On the SD image, it's located at address 0x2000 + 0xA000 = 0xC000. That's 49152 in decimal. So, just type 49152 and press enter. Last sector, +sectors or +size{K,M,G,T,P} (49152-..., default ...):


For the last sector, just press enter to use the default value. Created a new partition 1 of type 'Linux' and of size ... MiB.


Finally, type w to write the partition on the disk image. Command (m for help): w The partition table has been altered. Syncing disks.

Writing Rockchip loader

dd if=loader.img of=/dev/sde conv=sync,fsync
dd if=parameter of=/dev/sde conv=sync,fsync seek=$((0x2000))
dd if=boot.img of=/dev/sde conv=sync,fsync seek=$((0x2000+0x2000))

Building kernel

./mkbootimg --kernel RK3188-SOM/arch/arm/boot/Image --ramdisk initrd.img -o boot.img

Creating 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 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

If everything is right we 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 are setup 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 tend to complain otherwise, note in jessie you will also need to install the dialog package as well.
apt-get install locales dialog sudo
dpkg-reconfigure locales
chmod u+s /usr/bin/sudo 
  • 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 so that the board will DHCP on eth0
echo <<EOT >> /etc/network/interfaces
allow-hotplug eth0
iface eth0 inet static
    address 192.168.1.254
    netmask 255.255.255.248
    gateway 192.168.1.1
EOT 

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

Calibrate touchscreen

If you want to use LCD panel with touchscreen a calibration should be done.

Calibrate using tslib


  • Install required packages:
apt-get update
apt-get install xorg-dev xserver-xorg-dev x11proto-core-dev git automake make libtool
apt-get install libts-0.0-0 libts-bin libts-dev tsconf


  • Download tslib:
git clone https://github.com/kergoth/tslib.git
cd tslib


  • Compile the library:
autoreconf -vi
./configure --prefix=/usr
make
make install


  • Run
ldconfig


  • Modify tslib configuration
vi /usr/etc/ts.conf

Uncomment the following line:

module_raw input

Before the actual calibration invert the Y axis of the touchscreen. This can be done with:

echo 1 > /sys/kernel/ar1020/invertY

To do this every time on boot add the previous line in /etc/rc.local:

vi /etc/rc.local

The line should be inserted above exit 0 or otherwise it won't be executed:

.....
echo 1 > /sys/kernel/ar1020/invertY
.....
exit 0


  • Export tslib needed variables:
export TSLIB_TSEVENTTYPE=raw
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event1
export TSLIB_CALIBFILE=/usr/etc/pointercal
export TSLIB_CONFFILE=/usr/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/lib/ts


  • 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/event1
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


Wireless

RTL8188CUS


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

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. You can skip this procedure if you're using Olimex prebuild image.


  • Make new directory
mkdir -p /etc/Wireless/RT2870STA
cd /etc/Wireless/RT2870STA/

This is the directory where the module will search for files.


  • 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