目录
|
Introduction
This guide describes how to work on RK3036 Kylin Board with Ubuntu. RK3036 Kylin board support Ubuntu, Android, Brillo, Chromium OS, Tizen. If you want to develop your own application, drivers on RK3036 Kylin board, you're in the right place.
Target audience
The target audience of this guide is anyone who wants to obtain, build, or contribute to RK3036 SDK. That includes new developers who are interested in the project and who simply want to browse through the RK3036 SDK source code, as well as developers who have been working on RK3036 for a long time.
Prerequisites
You must have Linux to develop on RK3036 Kylin board. Any recent or up-to-date distribution should work. However, we can't support everyone and Linux distro, so the only official supported environment is Ubuntu Linux (version 14.04 - Trusty). If you encounter issues with other setups, patches are generally welcomed, but please do not expect us to figure out your distro.
- Ubuntu Linux (version 14.04 - Trusty)
- Most developers working on RK3036 are using Trusty (the LTS version of Ubuntu). It is possible that things will work if you're running a different Linux distribution, but you will probably find life easier if you're on this one.
- an x86_64 64-bit system for performing the build
- an account with sudo access
- You need root access to run the chroot command, modify the mount table, flash images. NOTE: Do not run any of the commands listed in this document as root – the commands themselves will run sudo to get root access when needed.
- 4 GB of RAM
- While it may be technically possible to build with less, but swapping to disk will make the build prohibitively slow.
You will have a much nicer time if you also have:
- a fast multi-processor machine with lots of memory
- The build system is optimized to make good use of all processors, and an 8 core machine will build nearly 8x faster than a single core machine.
- a good Internet connection
- This will help for the initial download and any further updates.
Setting up a Linux build environment
On your host PC
$ sudo apt-get install git-core gitk git-gui subversion curl gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip vim-gtk ctags minicom cmake android-tools-adb android-tools-fastboot gcc-arm-linux-gnueabi u-boot-tools device-tree-compiler libusb-1.0-0-dev phablet-tools openjdk-7-jdk libssl-dev
Configure git. Replace "you@example.com" and "Your Name" with your information:
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
Download the source code
The RK3036 Kylin source tree is located in multi Git repository hosted by Github, Google. We uses repo to sync down source code. repo is a wrapper for the git that helps deal with a large number of git repositories. You already installed repo when you setup Linux build enviroment.
Create an empty directory to hold your working files.
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
Initialize Linux source tree
$ repo init -u https://github.com/rockchip-linux/manifests
Synchronize the source code
$ repo sync
The source files will be located in your working directory under their project names. The initial sync operation will take a while to complete.
Build image
Build rkflashtool. In your your working directory.
$ cd rkflashtool
$ make
Build U-boot. In your your working directory.
$ ./build/mkuboot
image/kylin-uboot.bin is the u-boot image. Please read mkuboot if you want to know more about it.
Build kernel. In your your working directory.
$ ./build/mkkernel
image/kylin-kernel.img is the kernel image. Please read mkkernel if you want to know more about it.
Make a ubuntu core rootfs
$ ./build/mkrootfs
image/kylin-rootfs.img is the ubuntu rootfs image. Please read mkrootfs if you want to know more about it.
Flash image
We are using GPT as partition table. The U-boot will make partition when first time boot up. Please read partition table if you want to know more about it.
Flash U-boot
Enter maskrom mode First. Then go to your your working directory.
$ ./rkflashtool/rkflashloader
Flash kernel
Enter fastboot mode first. Then go to your your working directory.
sudo fastboot -i 0x2207 flash boot_a ./image/kylin-kernel.img
Flash ubuntu core image
Enter fastboot mode first. Then go to your your working directory.
sudo fastboot -i 0x2207 flash userdata ./image/kylin-rootfs.img
The board will automatic reboot when finish flashing image. Now you can read the debug message from minicom.
Start working on your board
Now you can start to work on your board.
Login Ubuntu
When Ubuntu boot up to console. It will stop at something like below.
Ubuntu 15.10 localhost.localdomain ttyS2
localhost login:
There are two preset user in the system. "root" and "rockchip". Both of them use "rockchip" as password. We have to login as root when the first time boot up to setup Ethernet. Then you should use rockchip to login. Or you can "useradd" command to create non-administrators user after that. Now login as root
localhost login: root
Password: rockchip
Add group and user
You can skip this step if you only use rockchip user to do your work. But we highly recommend you add a normal user.
Add admin group
groupadd admin
Add user
useradd -m yourname -s /bin/bash -G admin
Set the password
passwd yourname
Enter new UNIX password:
Retype new UNIX password:
Let systemd-networkd service manager networking
At very beginning, we want to setup the network.
systemctl enable systemd-networkd
systemctl enable systemd-resolved
# Create link of resolv.conf
rm /etc/resolv.conf
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
Config ethernet eth0 for systemd networkd manager. Copy the following scripts and paste to kylin console,
cat >> /etc/systemd/network/eth.network << EOF
[Match]
# Match eth0, eth1, ... ethN
Name=eth*
[Network]
DHCP=yes
EOF
Please connect kylin board with network cable, and restart systemd service by,
systemctl restart systemd-networkd
systemctl restart systemd-resolved
Ethernet should work. Test it with ‘ping’,
busybox ping www.yahoo.com
Install necessary toolkit packages
Use below command to install packages from your minicom console.
apt-get update
apt-get install net-tools iputils-ping wpasupplicant alsa-utils vim sudo
Wireless
If the name of wireless interface is something hard to read rather that "wlan0" that everybody used to. You may want to read this.
Config network interface wlan0 as eth0 did above,
cat >> /etc/systemd/network/wlan0.network << EOF
[Match]
Name=wlan0
[Network]
DHCP=yes
EOF
Assume that we have wireless SSID "wifi_ssid" with password "wifi_pass", save the SSID and password as a config file,
SSID="wifi_ssid"
PASSWD="wifi_pass"
wpa_passphrase $SSID $PASSWD > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
Multiple SSID configs can be append to /etc/wpa_supplicant/wpa_supplicant-wlan0.conf, like
wpa_passphrase "SSID_2" "passwd_2" >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
wpa_passphrase "SSID_3" "passwd_3" >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
Create ecivres.0nalw|tnacilppus_apw#ecivres.0nalw|tnacilppus_apw that will associate with Wifi AP for wlan0,
cat >> /lib/systemd/system/wpa_supplicant@.service << EOF
[Unit]
Description=WPA supplicant daemon (interface-specific version)
Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
Before=network.target
Wants=network.target
# NetworkManager users will probably want the dbus version instead.
[Service]
Type=simple
ExecStart=/sbin/wpa_supplicant -u -s -O/run/wpa_supplicant/ -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -i%I
[Install]
Alias=multi-user.target.wants/wpa_supplicant@%i.service
EOF
Enable systemd-networkd.service and ecivres.0nalw|tnacilppus_apw#ecivres.0nalw|tnacilppus_apw
systemctl enable wpa_supplicant@wlan0.service
systemctl start wpa_supplicant@wlan0.service
Restart service and changes will take effect,
systemctl restart systemd-networkd
systemctl restart systemd-resolved
Now wlan0 should get its ip, try ‘ifconfig wlan0’ and check outputs.
If you want to disable wlan0, trying by,
systemctl stop wpa_supplicant@wlan0.service
Reboot and login with your own user name
Reboot your board. Your ethernet/wireless should work now.
reboot
Use your just created user name to login.
localhost login: yourname
Password: yourpasswd
Ping a website to test your network connection.
$ ping www.baidu.com
PING www.a.shifen.com (112.80.248.73) 56(84) bytes of data.
64 bytes from 112.80.248.73: icmp_seq=1 ttl=54 time=47.3 ms
Alsa
Tune the RT5616 codec for playback and record,
# For playback
amixer cset name="HP Playback Switch" 1
amixer cset name="HP Playback Volume" 8
amixer cset name="HPO MIX DAC1 Switch" 1
amixer cset name="OUT MIXR DAC R1 Switch" 1
amixer cset name="OUT MIXL DAC L1 Switch" 1
amixer cset name="Stereo DAC MIXR DAC R1 Switch" 1
amixer cset name="Stereo DAC MIXL DAC L1 Switch" 1
# For record
amixer cset name="IN2 Boost Volume" 1
amixer cset name="ADC Boost Volume" 3 3
amixer cset name="DAC MIXR INF1 Switch" 1
amixer cset name="DAC MIXL INF1 Switch" 1
amixer cset name="Stereo1 ADC MIXR ADC1 Switch" 1
amixer cset name="Stereo1 ADC MIXL ADC1 Switch" 1
amixer cset name="RECMIXR INR1 Switch" 1
amixer cset name="RECMIXR BST1 Switch" 1
amixer cset name="RECMIXL INL1 Switch" 1
amixer cset name="RECMIXL BST1 Switch" 1
# Store the asound.store
alsactl -E HOME=/var/run/alsa store
Use ‘aplay’ ‘arecord’ to play/record.
# recording
arecord -f cd -d 10 /tmp/audio.wav
# playback
aplay /tmp/audio.wav
Xorg
For display system, there are many choices and some of them may be complicate. Since we use Ubuntu Core 15.10, it's simple and quick to install them through ubuntu-desktop, apt will take case of its dependencies.
Note that these packages are huge and would occupy 2.5GB. Before installing, check the root partition size. At least 3GB is needed.
sudo apt-get install ubuntu-desktop
Depending on your networking, it may take 2 hours to install tons of packages.
Clean up your tempoary file
sudo apt-get clean