Академический Документы
Профессиональный Документы
Культура Документы
ODROID
Year One
Issue #8
Aug 2014
Magazine
INTRODUCING
THE ODROID-W
HARDKERNEL’S MICRO-SIZED PI-COMPATIBLE
BATTERY-POWERED WEARABLE COMPUTER!
MAKE YOUR
OS SPOTLIGHT: OWN ODROID
POCKET ROCKET AND
COUCH POTATO SMARTWATCH
THE ULTIMATE ANDROID
• THE NEXT-GENERATION ODROID-U3+
GAMING IMAGE WITH • STEP-BY-STEP BASICS OF LINUX KERNEL COMPILATION
1080P VIDEO PLAYBACK • INSTALL A WEB SERVER WITH NGINX AND LIGHTTPD
What we stand for.
We strive to symbolize the edge technology,
future, youth, humanity, and engineering.
Address: Max-Pollin-Straße 1
85104 Pförring Germany
We’ll be reporting more about the ODROID-XU3 in the October issue, but you
can get your XU3 now at the Hardkernel Store at http://bit.ly/1prRcPL.
In Linux kernel news, forum user @dsd gives us a report on the newest 3.17
kernel, which appears to now have ODROID support! Follow the original thread
at http://bit.ly/1s5Ov7z:
“Samsung has been doing a load of work upstreaming ODROID support into of-
ficial Linux. The first patches will go into Linux-3.17, although a load more patch-
es are needed to make this usable as a desktop system - might take a few more
releases before all patches are polished and included.
They are also working on upstreaming ODROID support into uboot, and they
have a nice feature there, they have found a way to automatically detect X2 vs
U2/U3 (by checking for the extra LED on the X2). So now uboot will automatically
pick the right device tree to load. That means one appropriately crafted “OS im-
age” will work for X2, U2 and U3.”
This issue has lots of information for hardware enthusiasts, including an in-
depth look at the different types of eMMC modules that Hardkernel makes and a
hands-on look at the powerful ODROID-SHOW. We also feature a guide to com-
piling your own kernel directly from the Hardkernel GitHub repository, a tutorial
for installing the light-weight Nginx web server on an ODROID, Nanik begins his
fascinating series on Android Application Development, and more!
ODROID Magazine, published monthly at http://magazine.odroid.com/, is your source for all things ODROIDian.
Hard Kernel, Ltd. • 704 Anyang K-Center, Gwanyang, Dongan, Anyang, Gyeonggi, South Korea, 431-815
Makers of the ODROID family of quad-core development boards and the world’s first ARM big.LITTLE architecture
based single board computer.
Join the ODROID community with members from over 135 countries, at http://forum.odroid.com/, and explore the
new technologies offered by Hardkernel at http://www.hardkernel.com/.
STAFF
ODROID Magazine
IO SHIELD DEMYSTIFIED - 34
ANDROID DEVELOPMENT:
USING THE LINUX KERNEL
A GUIDE TO THE
ANDROID-SPECIFIC
DRIVERS
by Nanik Tolaram
L
inux is the heart of Android, and
it depends heavily on it for its op-
eration, and without it Android
would not be able to run. However,
Android does not use a “plain vanilla”
Linux kernel, which means you cannot
download a kernel from www.kernel.org CONFIG_ANDROID=y
and immediately use it to run Android. CONFIG_ANDROID_BINDER_IPC=y
There are a number of drivers, code and CONFIG_ANDROID_LOGGER=y
configuration options to be added in or- CONFIG_ANDROID_RAM_CONSOLE=y
der for Android to work properly, and CONFIG_ANDROID_RAM_CONSOLE_EN-
this article will walk through those spe- ABLE_VERBOSE=y
cific drivers and configuration, as well CONFIG_ANDROID_RAM_CONSOLE_ER-
as discuss the drivers that are needed ROR_CORRECTION=y
to ‘Android’-ify the Linux kernel upon CONFIG_ANDROID_RAM_CONSOLE_ER-
which the Android framework depends. ROR_CORRECTION_DATA_SIZE=128
Most of the driver code that needs to be CONFIG_ANDROID_RAM_CONSOLE_ER-
added is located inside the kernel/driv- ROR_CORRECTION_ECC_SIZE=16
ers/staging/android folder as can be CONFIG_ANDROID_RAM_CONSOLE_ER-
seen in Figure 1. ROR_CORRECTION_SYMBOL_SIZE=8
Figure 1 – Driver list inside the /staging/
There are also a number of drivers CONFIG_ANDROID_RAM_CONSOLE_ERROR_ android directory
that are located outside the base direc- CORRECTION_POLYNOMIAL=0x11d
tory /staging/android that are already CONFIG_ANDROID_TIMED_OUTPUT=y
in the Linux Kernel mainline. This ar- CONFIG_ANDROID_TIMED_GPIO=y
binder.c
ticle is by no means an exhaustive list for CONFIG_ANDROID_LOW_MEMORY_
all of the drivers needed, but is a good KILLER=y
The binder driver is the main back-
starting point to get a better understand- CONFIG_ASHMEM=y
bone driver for applications in Android,
ing of the different drivers needed for and is the gatekeeper of communication
Android. If you look inside the Makefile, which between different processes that are run-
Below are the configuration options is located inside the drivers/staging/ ning, written in native (C/C++) or Java.
that need to be included as part of the android directory, you will see the ker-
Without this driver, Android applica-
kernel zImage. The following configura- nel drivers that are specific to Android. tions will not work at all, since it mounts
tion is taken from the file odroidu_an- In the following sections we are going to the essential /dev/binder virtual filesys-
droid_defconfig inside the kernel/ take a closer look at the different driv- tem. Android uses the binder driver
arch/arm/configs folder, as shown in ers inside this directory, starting with the extensively, and because applications
the following table. binder driver. utilize this framework, any application is
indirectly reliant on the binder driver.
ODROID MAGAZINE 6
ANDROID DEVELOPMENT
ODROID MAGAZINE 7
ANDROID DEVELOPMENT
HIDDEN_APP_MAX_ADJ
HIDDEN_APP_MIN_ADJ
SERVICE_B_ADJ
PREVIOUS_APP_ADJ
HOME_APP_ADJ
SERVICE_ADJ
BACKUP_APP_ADJ
HEAVY_WEIGHT_APP_ADJ
The wakelocks drivers area considered a Google hack by purists PERCEPTIBLE_APP_ADJ
VISIBLE_APP_ADJ
FOREGROUND_APP_ADJ
useful for troubleshooting issues such into different categories: main, events, PERSISTENT_PROC_ADJ
as kernel panic, out of memory or any radio and system. The following vir- SYSTEM_ADJ
other kind of problem that causes a tual filesystem are made available from MIN_HIDDEN_APPS
kernel panic. the driver:
Internally, the driver only accomo-
earlysuspend.c /dev/log/system dates a maximum of 6 different values,
Location: /kernel/power /dev/log/radio so the framework does an internal con-
/dev/log/events version to fit it to the available slots.
You can see this driver in action /dev/log/main The different values can be found in
when you leave your device inactive the /sys/module/lowmemorykiller/pa-
for few minutes and the screen turns Android provides a log viewer ap- rameters/adj virtual filesystem.
off by itself. It’s responsible for mak- plication called logcat that allows The settings of free available mem-
ing sure all the necessary components us to view the log in a more hu- ory threshold are linked in a 1:1 ratio
inside your device are ‘suspended’ man readable format. The screen- with the adj value, and it is stored in
to conserve energy. This driver and shot shows a sample of the content the /sys/module/lowmemorykiller/pa-
wakelock go hand-in-hand. It relies of the /dev/log/radio in its raw rameters/minfree virtual filesystem.
on Linux’s power management driver, form, which is not very easy to read The minfree value is in pages of 4k.
and can be triggered by sending state For example, if it says the free memory
information to the following /sys/ lowmemorykiller.c is 8192, it means (8192 * 4k) = 32768
power/state filesystem. which converts to 32KB (32768 /
If you have root access to your de- This driver takes care of killing pro- 1024).
vice, you can trigger the early suspend cesses from memory when the amount The way in which the minfree
by executing the following command: of free memory hits a certain threshold. threshold is mapped with the value
Every time an application is launched, from adj is explained in this chart:
echo mem > /sys/power/state it is assigned a value to indicate what
kind of application it is. This ‘marker’ Minfree threshold mapped with adj value
will indicate to the driver whether this
logger.c process can be killed. adj minfree
As an example, looks at the phone 0 8192
The logger driver is the central log- application that you use to receive and 1 10240
ging driver used by Android system, make calls. The application will be 2 12288
which is also made available to user ap- ‘marked’ to a value that indicates to 4 14336
9 16384
plications via the built-in logger API. the driver to kill the application only 15 20480
Internally, the driver splits the logging when the last low memory threshold is
ODROID MAGAZINE 8
ANDROID DEVELOPMENT TIPS AND TRICKS
MOUNT YOUR
INTERNAL SD
CARD
WHEN BOOTING FROM
EMMC IN LINUX
by @gripped and Rob Roy
W
hen booting from an eMMC
module, the SD card slot
can be used for extra storage
instead of a USB drive. To begin, insert
a EXT4-formatted SD card, then turn
on the ODROID and boot up your fa-
vorite Linux distro. Note that since the
SD slot is not hot-pluggable, the card
needs to be inserted before the system
is booted. Type the following into the
Terminal window in order to determine
the device name for the SD card:
$ sudo fdisk -l
Snapshot of the output of typing cat /dev/log/radio in Terminal Device Boot Start ...
/dev/mmcblk0p1 8192 ...
What the mapping means is that if timed GPIO drivers registration as /dev/mmcblk1p1 8192 ...
the free memory threshold is less than they happen. The timed_gpio is one of
On an X2 or U3, the /dev/
20480 (20480 x 4k = 80k), the driver the drivers that register itself to timed_
mmcblk0 device is the SD card, and
will start killing processes which have output, and the other is the vibration
/dev/mmcblk1 is the eMMC module,
value of 15 and above. The same thing driver. As you may have guessed, the but on an XU they are reversed. To
happens when the free memory avail- vibration component is responsible for mount the SD card, substitute your
able is less than 8192 (8192 x 4k = making your phone vibrate. username and device name in the fol-
32k). In that case, any process that has lowing sample script:
value larger than 0 will be killed. alarm-dev.c
Location: /kernel/drivers/rtc $ cd ~
$ mkdir sdcard
timed_gpio.c / $ sudo mount /dev/mmcblk0p1 \
timed_output.c The alarm driver relies on high res- /home/USERNAME/sdcard
$ sudo chown USERNAME:USERNAME
olution timer infrastructure provided
These combo drivers are use for in Linux. The driver has got its own Now you can store your data in
driving a particular GPIO hardware virtual filesystem, /dev/alarm, that is /home/USERNAME/sdcard and it
pins for a certain period of time, and is used by the user application to com- will reside on the SD card instead.
made available to give code running in municate with the driver. This technique can be used to mount
userspace access to the GPIO pins. In This driver is tied to the wakelock the SD card at any location, including
order to use this driver, you must know functionality, allowing the alarm to /var/www for a web server.
which pin you want to drive, high or continue working even when the de- To automatically mount the SD
low signal, and for how long. In de- vice is in sleep mode, which is the sole card at boot, add a line to /etc/fstab by
vices that have this driver enabled, it reason why the alarm driver exists. It substituting the device and username:
exposes the /sys/bus/platform/driv- provides the alarm management that is # should be on a single line
ers/timed-gpio virtual filesystem. used in our user applications or frame- /dev/mmcblk0p1
/home/USERNAME/sdcard
The timed_gpio depends on anoth- work, in order to support key services. ext4
er driver called timed_output, where Next month, we’ll take a look in- defaults,noatime,nobootwait
0 2
its main function is to keep track of side the Android APK file.
ODROID MAGAZINE 9
ODROID -W
INTRODUCING THE
ODROID-W
A MINIATURE RASPBERRY PI-COMPATIBLE
WEARABLE COMPUTER
by Justin Lee
T
he ODROID-W is a min-
iature wearable comput-
ing module which is ful-
ly compatible with all software • DC/DC step-up converter An early revision of the ODROID-W, which
available for the Raspberry Pi (RPi). for 5Volt rails (USB host and was nicknamed the ODROID-Pi
HDMI) from a Li-Polymer bat-
The W stands for: tery
ODROID MAGAZINE 10
ODROID - W
Memory card slot: Micro-SD (T- Top view of Rev. 2 ODROID-W board
We didn’t follow the instructions care-
Flash)
fully enough and got this instead.
Power: Micro-USB socket for 5V
input. Li-Polymer battery connector
(Molex 53398-0271)
ODROID MAGAZINE 11
ODROID -W
DIY Smartwatch
Example
The following page illustrates how to assemble your very own fashionable smartwatch from an ODROID-W!
For detailed schematics and software links, please refer to the original post at http://bit.ly/1rYW8LR.
ODROID MAGAZINE 12
ODROID - W
Smartwatch Assembly
Solder a disassembled USB Bluetooth module and a few buttons. Place double-sided tape on the LCD and on the ODROID-W PCB.
Assemble the watch straps. Please note that the hinge holders
Final assembly of ODROID smartwatch with screen attached.
should be soldered first.
ODROID MAGAZINE 13
TIPS AND TRICKS ODROID -W
F
or a retro-style Google experi-
ence, visit the Google BBS at
• Qt application to display the
http://bit.ly/1iXk8yF. Don’t
forget to bring your moon boots and clock and SMS / Mail / Call
walkman! notification
L
ugalabs offers an Android app • RTC Backup battery (CR2032 tion, perfect for wearable applications.
from the Google Play store with Molex 51021-0200 wired Please post any questions that you may
that can change the resolution connector) have to the ODROID forums at http://
of the desktop in order to fix HDMI forum.odroid.com.
monitor overscan issues. For more • Lithium Polymer battery
details, please visit its Google Play (3.7V/720mAh with Molex
Store page at http://bit.ly/XYfZ51. 51021-0200 wired connector)
ODROID MAGAZINE 14
EMMC MODULES
ALL ABOUT
HARDKERNEL’S
EMMC
MODULES
THE ODROID ADVANTAGE Hardkernel’s removable clip eMMC modules, which are
by Justin Lee usually soldered into the board, are unique to ODROIDs.
T
he Exynos-4412 CPU includes 330MB/sec of host bus bandwidth by a few USB memory card readers. So it
an eMMC 4.41 compatible host DDR. is worthwhile to check the compatibility
controller, with a maximum bus We’ve been selling 2 different eMMC list at http://bit.ly/1nPBE4i.
speed limited to 100MB/sec, an actual modules: The Green or Blue PCB has The chart on the following page is the
clock speed of 48Mhz with DDR. The the eMMC 4.5 chips. full list of eMMC modules we are selling
ODROID-X, X2, U2, U3, Q and Q2 The Red PCB has the eMMC 5.0 now. The round label indicates the OS
are all based on the Exynos-4412 CPU. chips. The eMMC 5.0 chip is slightly and capacity.
The Exynos-5410 CPU, which is smaller but it has the same BGA array The eMMC 4.5 Blue(or Green)
used by the the ODROID-XU, XU+E size, so that we can keep using the same PCBs will be obsolete soon except for
and XU-Lite, includes an eMMC 5.0 PCB. 8GB models.
compatible host controller. However, Most eMMC manufactures are mov- Even you have a different or
the hardware design was unable to sup- ing to eMMC 5.0. So it is hard to pur- wrong eMMC, you can use it for
port the eMMC 5.0 HS400 mode, be- chase the eMMC 4.5 chips anymore ex- your ODROID if you install a
cause there was no public specification cept for the lower capacity like 4GB and proper boot loader and OS image.
of eMMC 5.0 when we designed the 8GB. Recently, we started using 16GB
ODROID-XU. As a result, all the XU and 32GB eMMC chips from Sandisk Reference
series have the eMMC 4.5 (HS200) while we keep buying 8GB and 64GB
specification which reaches a maximum eMMC from Toshiba. The eMMC board schematics
speed of 160MB/sec since the actual When you install a new OS image http://bit.ly/1p4TX6N
clock speed is 160Mhz with SDR. onto the eMMC module, you need a
The Exynos-5422 CPU also has an USB memory card reader and an eM- The reader board schematics
eMMC 5.0 compatible host controller. MC-to-MicroSD converter board (read- http://bit.ly/1p9j0Z3.
The ODROID-XU3 is based on Exynos- er board). Please refer to the images be-
5422 and supports the eMMC HS400 low to understand how to use it. The following page is a handy guide to all
mode. The actual clock is 166Mhz and The reader board can’t be detected by of Hardkernel eMMC modules!
The eMMC reader attaches to the Top view of eMMC reader and eMMC mod- Bottom view of eMMC reader and eMMC
eMMC module with a small clip ule inserted into SD card reader module inserted into SD card reader
ODROID MAGAZINE 15
EMMC MODULES
ODROID MAGAZINE 16
LINUX KERNEL
LINUX KERNEL
COMPILATION
GET FULL CONTROL OF
YOUR OPERATING SYSTEM
LIKE A LINUX JEDI
by Venkat Bommakanti
A
s you make progress in using $ uname -a $ cat /etc/os-release
Linux, it is inevitable that you
would want to tweak your setup Linux u3-2 3.8.13.26 #1 SMP PRE- NAME=”Ubuntu”
in order to accommodate changes in EMPT Wed Jul 9 22:14:37 UTC 2014 VERSION=”14.04, Trusty Tahr”
your hardware setup, such as integrating armv7l armv7l armv7l GNU/Linux ID=ubuntu
an external device. Such tasks usually re- ID_LIKE=debian
quire modifications to the Linux kernel This output indicates the image used PRETTY_NAME=”Ubuntu 14.04 LTS”
or linking to a new driver. This article is based on the 3.8.y.z kernel, built on VERSION_ID=”14.04”
provides details on starting with natively Wed Jul 9 22:14:37 UTC 2014. HOME_URL=”http://www.ubuntu.com/”
building a pristine kernel using only the You can get additional image infor- SUPPORT_URL=”http://help.ubuntu.
ODROID itself. This article does not mation using the following commands com/”
address cross-compiling, which relates and observing the output: BUG_REPORT_URL=”http://bugs.
to building an ODROID kernel using a launchpad.net/ubuntu/”
secondary host machine such as an x86. $ cat /proc/version
Linux version 3.8.13.26 (root@ After installing a newly built kernel,
Requirements THEserver) (gcc version 4.7.2 the above information is useful for com-
(crosstool-NG 1.17.0) ) #1 SMP parison when verifying that the kernel
1. Any ODROID board, with an ap- PREEMPT Wed Jul 9 22:14:37 UTC has actually been updated.
propriate power adapter. 2014
2. A bootable 8+ GB MicroSD card or Preparing the system
eMMC module containing the lat-
$ cat /etc/lsb-release
est Lubuntu image available from the
DISTRIB_ID=Ubuntu Prior to building a kernel, you would
Hardkernel website.
3. A network where the device has ac- DISTRIB_RELEASE=14.04 need to setup the appropriate software
cess to the Internet and the ODROID DISTRIB_CODENAME=trusty environment. First, launch a terminal
forums. DISTRIB_DESCRIPTION=”Ubuntu 14.04 session and switch to the root user, using
4. Optional SSH access to the U3 via LTS” the command:
utilities like PuTTY (MS Windows 7+)
or Terminal (Mac, linux to perform the $ lsb_release -a $ sudo -s
steps from a remote host computer.
No LSB modules are available. All build related activities need to be
System basics Distributor ID: Ubuntu performed by the root user, which can
Description: Ubuntu 14.04 be enabled with the su command after
Initially, for reference, it is a good LTS typing the root password.
idea to note the version of the initial ker- Release: 14.04 Install the initial set of needed com-
nel version included with the installed Codename: trusty ponents, using the following installation
image with the following command: command:
ODROID MAGAZINE 17
LINUX KERNEL
ODROID MAGAZINE 18
LINUX KERNEL
Hardkernel maintains open-source kernel repositories that are downloadable for free.
Select a defconfig
Change to the source root directory ing command, ignoring any warnings: Novice users should review and go
using the command: through the options list but not alter any
root@u3-2:~/odroid-3.8.y# make selections. Experienced users may want
# cd odroid-3.8.y/
odroidu_defconfig to adjust the selections in the kernel con-
HOSTCC scripts/basic/fixdep figuration menu based on their in-depth
This is where all build related activi- ... knowledge of the kernel.
#
ties are launched from. Check the list of
supported defconfig files using the com- # configuration written to .config Baseline resource
mand: # usage
# ls -lsa arch/arm/configs/
Configure additional To understand the implications of
odroid*defconfig
modules the build process on resource usage, it
100 -rw-r--r-- 1 root root 101207
is useful to get a picture of the resource
Jul 14 13:11 odroidu_defconfig
In this example case, since QT4 sup- usage, before and during, the build pro-
96 -rw-r--r-- 1 root root 96792
port was added (xconfig is a QT4 UI), cess, as shown in the screenshot of the
Jul 14 13:11 odroidx2_defconfig
the xconfig module needs to be built us- command top.
96 -rw-r--r-- 1 root root 96797
ing the following command to launch an
Jul 14 13:11 odroidx_defconfig
editor for the selection of options: Build the kernel and
selected modules
# make xconfig
In our case, we will select the
odroidu_defconfig version, which con- CHECK qt To compile the kernel as fast as pos-
tains hardware configuration options MOC scripts/kconfig/qconf.moc sible, using all 4 processors available in
specific to the U3. Now, perform the HOSTCXX scripts/kconfig/qconf.o the U3, type the following command in
first build step by executing the follow- HOSTLD scripts/kconfig/qconf the Terminal window:
ODROID MAGAZINE 19
LINUX KERNEL
include/config/kernel.release`
update-initramfs: Generating /
boot/initrd.img-3.8.13.26
# cp arch/arm/boot/zImage /media/
boot/zImage Resource usage (top with P option) during build process
ODROID MAGAZINE 20
LINUX KERNEL YOUTUBE PLAYER
# cp /boot/uInitrd-`cat include/
config/kernel.release` /media/
YOUTUBE PLAYER
boot/uInitrd
# ls -lsa /boot/u*
2144 -rwxrwxrwx 1 root root
ALTERNATIVE
2195134 Jul 14 14:18 /boot/uIni- USE TAMPERMONKEY
trd
2144 -rwxrwxrwx 1 root root
TO WATCH VIDEOS
2195134 Jul 14 14:17 /boot/uIni- by Jeremy “Cartridge” Kenney
trd-3.8.13.26
Reboot
ODROID MAGAZINE 21
TIPS AND TRICKS YOUTUBE PLAYER
W
ant to see some of the fun the player theme and color.
side of Linux? Try these This script gives you access to op- The script can be disabled by clicking
commands: tions you may have never seen before on on the Tampermonkey button in the ex-
Youtube. You get to make use of Auto tension bar beside the Address bar, then
All aboard!
$ sudo apt-get install sl
$ sl
Moo
$ sudo apt-get install cowsay
$ cowsay ‘ODROIDS are cool!’
ODROID-U3 VS
ODROID-U3+
THE NEXT GENERATION IN THE
ODROID-U SERIES
by Justin Lee
W
e’ve been shipping the using an external bulky USB hub. It’s a age current on the HDMI port. It puts
ODROID-U3+ (Rev dual-use port that works both ways! the PMIC into an undefined state and
0.5) since the end it prevents the auto-power-on function.
of June 2014, with 4 main im- New USB host We moved the reverse current protection
provements over the original U3: power protector IC IC from HDMI connector side to CPU/
NCP380 PMIC side, which solved the problem-
• Micro-USB port is able to work atic auto-power-on issue. Now we can
in USB host mode.
AP2411 was used in Rev 0.2 PCB as turn on the board automatically by sim-
a USB bus power protector. However, ply inserting the DC power jack even
• The USB host power protector
IC was changed from AP2411 to some users reported that it could be when the HDMI is connected.
NCP380. damaged by an electrical shock on the
USB port. HW SPI port
• HDMI reverse-current blocking To solve this issue, we removed the
IC AP2331 was placed on the chip and added a wire, which changed it The Serial Peripheral Interface (SPI)
correct place. to more durable NCP380 that includes bus is a synchronous serial data link that
many reliable features like Under volt- operates in full duplex mode. The SPI
• HW SPI port was added. age lock-out, Built-in Soft start, Ther- bus is added on the new J5 (IO Port #2)
mal Protection, Soft turn-off, Reverse 4-pin connector on the PCB. Note that
voltage Protection, ESD Compliance to SPI ports support only master mode and
USB host mode with IEC61000-4-2 (Level 4), 8.0 kV (Con- a 1.8V interface like the other IO ports
Micro-USB port tact), and 15 kV (Air). on Exynos processor. You can use 4 pins
as GPIO mode as well as SPI mode. Af-
By adding a power control IC HDMI reverse- ter booting, the pins are in GPIO mode
RT9715, the Micro-USB port can work current blocking IC by default.
in the USB host mode as well as in USB
device mode, which we call Dual-Role- Some monitors or TVs have leak- Pin map bottom side view
Device (DRD). Just plug in an OTG-
to-Host cable and you will have another
USB host available for peripherals, so
that you can enjoy 4 USB ports without
ODROID MAGAZINE 23
ODROID-U3+
ODROID MAGAZINE 24
WEB SERVER TIPS AND TRICKS
W
ant to see some more of the
fun side of Linux? Try these
O
ne of the most common uses for commands:
or eMMC module containing the lat-
a Linux machine is to create a est U3 Lubuntu image available from
web server for the purposes of Odd name
the Hardkernel website.
hosting a website, which is an essential 3. A network where the device $ sudo apt-get install toilet
component to any business strategy or has access to the Internet and the $ toilet -f mono12 -F metal \
personal project. Whether you want to ODROID forums. ODROID Magazine
create a live production server or a per- 4. Optional SSH access to the U3
sonal one for your home intranet, this via utilities like PuTTY (MS Win-
article describes the steps involved in dows 7+) or Terminal (Mac, linux to
enabling two of the popular light-weight perform the steps from a remote host
web servers: nginx & lighttpd (aka computer.
lighty).
Although Apache server is also a pop- Server Installation
ular choice for Linux web hosting, it is The toilet command thankfully does
covered extensively on the PHP website Although it is possible to install not do what you think it does!
at http://bit.ly/1wXDju1 with specific both web servers on the U3 at the same
instructions for the ODROID located at time, the steps below assume that only
one web server is being installed. For Enter the matrix
http://bit.ly/1rIb9Te.
The instructions also include add- simultaneous use, any configurations
$ sudo apt-get install cmatrix
ing support for a secure web server conflicts, such as the use of the default
$ cmatrix
(openSSL-based HTTPS) and scriptable web port 80 by both servers, should be
web applications (PHP5-FPM). FPM, resolved first.
Chase the mouse
which stands for FastCGI Process Man-
ager, is an efficient alternative to the
$ sudo apt-get install oneko
classic FastCGI implementation. If you
$ oneko
are concerned about security related is-
sues and configuration when hosting a
Do you want to play
website, it is recommended to research it
a game?
well and implement relevant procedures
before enabling access to the Internet.
$ sudo apt-get install espeak
Periodic OS updates are also recom-
$ espeak \
mended.
‘Do you want to play a game?’
ODROID MAGAZINE 25
WEB SERVER
2 - Nginx 2 - Lighttpd
Install nginx using the command: Install lighttpd using the command:
Launch nginx using the commands: Launch lighttpd using the commands:
# sudo service nginx stop # sudo service lighttpd stop
# sudo service nginx start # sudo service lighttpd start
Launch a web-browser such as firefox and point to the ip-address of the device,
using the URL http://<u3-ip-address>
4 - Nginx 4 - Lighttpd
Install self-generated ssl keys/certificates, using the Check if SSL has been enabled in the lighttpd applica-
following (single-line) commands (use command help tion, using the command:
to get details on specified options):
# lighttpd -v
# mkdir /etc/nginx/ssl lighttpd/1.4.33 (ssl) - a light and fast webserver
# sudo openssl req -x509 -nodes -days 365 \ Build-Date: Jan 28 2014 17:19:37
-newkey rsa:2048 -keyout \
/etc/nginx/ssl/nginx.key \ Note that the output reflects that SSL is enabled. Now,
-out /etc/nginx/ssl/nginx.crt install self-generated ssl keys/certificates, using the
following (single-line) commands:
Appropriate destination directories first need to be
created, if not already present. # mkdir /etc/lighttpd/ssl
# sudo openssl req -x509 -nodes -days 365 \
When prompted for certificate information, you can -newkey rsa:2048 -keyout \
enter information such as: /etc/lighttpd/ssl/lighttpd.key \
-out /etc/lighttpd/ssl/lighttpd.crt
Country Name (2 letter code) [AU]:US
State or Province Name [Some-State]:CA Appropriate destination directories need to be cre-
Locality Name (eg, city):San Jose ated first, if not already present.
ODROID MAGAZINE 26
WEB SERVER
4 - Nginx 4 - Lighttpd
Organization Name:YourCompany Enter the certificate information as indicated for the
Organizational Unit Name:Engineering nginx case. Similarly check installed certificate.
Common Name:YourName
Email Address:you@yourcompany.com In addition, generate the corresponding .pem file using
the commands:
Check generated certificate, using the command:
# cd /etc/lighttpd/ssl
# openssl s_client -connect localhost:443 \ # cat lighttpd.key lighttpd.crt | sudo tee \
-reconnect lighttpd.pem
If the certificate information entered earlier is now This .pem file is later used in the lighttpd configuration
emitted, then it can be assumed the certificate was file.
generated properly.
Add SSL configuration to the lighttpd configuration, us-
Add SSL configuration to the nginx configuration, using ing the following steps:
the following steps:
# cd /etc/lighttpd/
# cd /etc/nginx/sites-available # cp lighttpd.conf lighttpd.conf-orig
# cp default default-orig # medit lighttpd.conf
# medit default
Add the following block:
The server block should match this example:
$SERVER[“socket”] == “:443” {
server { ssl.engine = “enable”
listen 80 default_server; ssl.pemfile = “/etc/lighttpd/ssl/lighttpd.pem”
listen [::]:80 default_server ipv6only=on; server.document-root = “/var/www”
}
# ssl support
listen 443 ssl; Check if the configuration update is ok, using the
(single-line) command:
root /usr/share/nginx/html;
index index.html index.htm; # sudo lighttpd -t -f \
/etc/lighttpd/lighttpd.conf
# Make site accessible from http://localhost/ Syntax OK
server_name localhost;
ssl_certificate /etc/nginx/ssl/nginx.crt; Relaunch lighttpd using the commands:
ssl_certificate_key /etc/nginx/ssl/nginx.key;
# sudo service lighttpd stop
location / { # sudo service lighttpd start
# First attempt to serve request as file, then
# as directory, then fall back to a 404. Relaunch firefox and point to the ip-address of the de-
try_files $uri $uri/ =404; vice, using the HTTPS URL https://<u3-ip-address>.
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules On the first access, certain dialog boxes will be prompt-
} ed seeking a response.
ODROID MAGAZINE 27
WEB SERVER
4 - Nginx 4 - Lighttpd
Relaunch Firefox and point to the ip-address of the The welcome screen should appear as shown in the
device, using the HTTPS based URL https://<u3-ip- figure below.
address>.
The circled exclamation icon indicates SSL has been
On the first access, certain dialog boxes will be prompt- configured OK. Note that the exclamation indicates
ed seeking a response. Select the following option that a self-generated certificate is in use.
buttons:
# apt-get install php5-cgi autoconf automake autotools-dev curl libapr1 libtool curl libcurl4-openssl-
dev php-pear php-xml-parser php5 php5-cli php5-common php5-curl php5-dev php5-gd php5-sqlite php5-fpm php5-
mysql
6 - Nginx 6 - Lighttpd
Configure nginx for php support, using the following Update lighttpd for php support, using the following
configuration (socket-based) options: (socket-based) configuration options:
# cd /etc/lighttpd/conf-
# cd /etc/nginx/sites-available/
available/
# medit default
# cp 15-fastcgi-php.conf 15-fastcgi-php.conf-orig
# medit 15-fastcgi-php.conf
…
index index.html index.htm index.php;
Add the following (socket-based) configuration:
fastcgi.server += ( “.php” =>
location ~ .php$ {
((
fastcgi_split_path_info ^(.+.php)(/.+)$;
“socket” => “/var/run/php5-fpm.sock”,
“broken-scriptfilename” => “enable”
fastcgi_pass unix:/var/run/php5-fpm.sock;
))
)
fastcgi_index index.php; include fastcgi_
params;
}
Enable additional fastcgi configuration, using the com-
mands:
ODROID MAGAZINE 28
WEB SERVER
6 - Lightppd
# lighttpd-enable-mod fastcgi
# lighttpd-enable-mod fastcgi-php
# ls -lsa /etc/lighttpd/conf-enabled
total 0
lrwxrwxrwx 1 root root 33 Jul 13 16:14 10-fastcgi.
conf -> ../conf-available/10-fastcgi.conf
lrwxrwxrwx 1 root root 37 Jul 13 16:15 15-fastcgi-
php.conf ->
# cd /etc/php5/fpm/pool.d/ # cd /etc/php5/fpm/
# cp www.conf www.conf-orig # medit php.ini
# medit www.conf
Add the following (socket-based) configuration: Enable the following config line:
listen = /var/run/php5-fpm.sock cgi.fix_pathinfo=1
8 - Nginx 8 - Lighttpd
Create a sample .php script file, using the commands: Create a sample .php script file, using the commands:
Additional Resources
Read more about nginx at http://wiki.nginx.org, and learn about Lighttpd at http://lighttpd.net.
ODROID MAGAZINE 29
ODROID-VU
ODROID-VU
AFFORDABLE 9” USB
HDMI TOUCH SCREEN
A PORTABLE
MULTITOUCH SCREEN
FOR ANDROID, LINUX
AND WINDOWS
by Justin Lee
Y
ou’d think that, with the massive
growth in tablet computing, it The Odroid VU - A 9 Inch 1280 x 800 Multi Touch Screen Display
should be an easy matter to:
1. Locate a small high-definition display 1920x1080, and you can buy a price tag to match! And most of
(HD) LCD screen a full-size monitor at that resolution, them have no touch screen option.
2. Connect it to an HDMI/LCD but that’s not what we’re about. We’re So we decided to develop a 9-inch uni-
driver board looking for something small and por- versal HDMI screen with 10-points ca-
3. Attach a capacitive multi touch table, which is where it gets a bit tricky. pacitive multi touch input for ODROID
screen on the LCD users. The name of display is ODROID-
4. Hook that up to your ODROID or
There are very few small, portable, VU, which is pronounced as “view”. We
other HDMI device
HDMI screens available on the mar- hope this product can be a “View point”
Unfortunately, it’s not quite that ket. Most of the ones out there have for your computer.
simple at all, or we’d all have done it al- 800x480 or 800x600 pixels. These
ready! The ODROID computers can are largely aimed at professional pho- Specifications
tographers and videographers, with
A back view of the Odroid VU components Display: 9-inch 1280 x 800 pixels
TFT LCD
Power: 5V/1A DC
ODROID MAGAZINE 30
ODROID-VU
ODROID MAGAZINE 31
PEPPER FLASH
PEPPERFLASH
CHROME PLUGIN FOR
LUBUNTU 14.04
AN EASY WAY TO WATCH
ADOBE FLASH ON YOUR
ODROID LINUX SYSTEM
by @Miltos
edited by Venkat Bommakanti
T
he Adobe Flash Player for the
Chrome web browser in Ubuntu
was discontinued by Adobe sev-
eral years ago, with no alternative avail-
able for playing Flash videos in Linux 5. PepperFlash Ver. 12.0.0.77 for the Terminal window:
until recently. Google recently released Lubuntu 14.04
an updated Flash-compatible player pl- 6. PCMan File Manager (pcman- $ sudo pcmanfm
ugin called PepperFlash, which includes fm) for Lubuntu 14.04
an ARM Ubuntu version. This article Right-click the icon for the down-
describes the steps needed to download Download loaded tarball, which should be visible
this plugin from Google and add it to the PepperFlash in the right-most pane, and selecting
Chrome web browser running Lubuntu the Extract Here menu option.
14.04 LTS on any ODROID board, in- Login to the ODROID using the The plugin will be extracted to the
cluding the X, U and XU series. default username of “odroid”, and /home/odroid/Downloads/Pepper-
download the precompiled packaged Flash directory, as shown in the second
Requirements version of the ODROID compatible screenshot.
PepperFlash by navigating to http://bit. It is easier for some users to use the
1. Any ODROID board, with an ly/1yYEDQf in the Chrome browser command-line terminal window almost
appropriate power adapter. window, which will be saved to the / entirely for these next steps. However,
2. A bootable 8+ GB MicroSD home/odroid/Downloads directory. using pcmanfm simplifies the process
card or eMMC module contain- Launch a terminal session and navi- for those who want to save some typing.
ing the latest Lubuntu image gate to the downloads directory, then In pcmanfm, copy the PepperFlash
available from the Hardkernel launch pcmanfm with root privileges directory and paste it into the /usr/lib
website. by typing the following command in directory.
3. A network where the device has
access to the Internet and the Contents of the directory after the PepperFlash tarball is extracted
ODROID forums.
4. Optional SSH access to the
ODROID via utilities like
PuTTY (MS Windows 7+) or
Terminal (Mac, linux to perform
the steps from a remote host
computer.
ODROID MAGAZINE 32
PEPPER FLASH ANDROID GAMING
Configure Pepper
Flash plugin
MUPEN64PLUS
TURN YOUR ODROID
After closing pcmanfm, launch the INTO A NINTENDO 64
medit (installed by default in Lubuntu)
editor and open the default configura-
RETRO GAMING
tion file of PepperFlash by using the CONSOLE
command: by Rob Roy
$ sudo medit \
/etc/chromium-browser/default
Copy the PepperFlash directory
Modify the CHROMIUM_FLAGS
After pasting the copied directory configuration paramete as a single line:
into the system library directory at /usr/
M
CHROMIUM_FLAGS=” --ppapi-flash-
lib/, the directory /usr/lib/PepperFlash upen64Plus is a Nin-
path=/usr/lib/PepperFlash/ \
will be created. tendo 64 emulator for
libpepflashplayer.so --ppapi-flash-
If using the command line instead, the Android platform,
version=11.7.700.225”
copy the PepperFlash directory to the and it runs great on the ODROID!
system library directory by typing the To install Mupen64plus, visit the
following command: Save the configuration file and close Mupen64Plus Play Store page at http://
medit as well as Chrome. bit.ly/YzRD1H, connect your joysticks,
$ sudo cp PepperFlash /usr/lib/ and immerse yourself in the glory that
Validate the was the Nintendo 64!
installation
Paste the PepperFlash directory From top to bottom: F-Zero-X, Mario
Verify that the PepperFlash plugin has World 64, and Mario Tennis 64
been installed correctly by re-launching
the Chrome web browser and navigat-
ing to the URL chrome://plugins. Se-
lect the PepperFlash plugin and click on
the Details option at the right side of the
webpage.
Check the details ensuring the plugin
information matches what is listed in the
screenshot. Finally, enable the Always
allowed option by checking the check-
box and close all Chrome windows.
To make sure that the plugin is in-
stalled properly, reboot the ODROID,
then launch Chrome again. Navigate to
any page with Flash content, such as the
Adobe Flash Samples website at http://
adobe.ly/UmTzrV.
For additional information or ques-
tions, please visit the original informa-
tion sources at http://bit.ly/1lstuyP.
ODROID MAGAZINE 33
IO SHIELD
IO SHIELD
DEMYSTIFIED
HOW TO CREATE AN INTERMEDIARY
BETWEEN THE HARDWARE
AND THE HUMAN
By Bohdan Lechnowsky
I
was recently contracted to work on during the fourth step, I find it necessary
a project that would require a U3 to to fine-tune the design produced during
The U3 I/O Shield is a powerful tool in an
potentially control valves, actuators the third step. Of course, the fourth step
ODROID wizard’s magic kit
and other devices and read inputs. That also involves testing and refining of the
was exciting, because I knew I’d have a design based on the results of testing.
chance to work with the U3 IO Shield -- root@odroid:/sys/class/gpio# cd
something that I’ve wanted to do since it Steps 1 and 2 gpio304
was released, but haven’t had a chance to root@odroid:/sys/class/gpio/
do because of my busy work schedule. When I first attempted to use the IO gpio304# echo out > direction
My first step when working with any Shield on Ubuntu, I had trouble find- root@odroid:/sys/class/gpio/
new hardware is to see if I can get it to ing concise instructions for getting it to gpio304# echo 1 > value ;Turns on
work using the supplied examples, and work using the method that is easiest for the pin
my second step is usually to post ques- Rebol to interface with. That took me to root@odroid:/sys/class/gpio/
tions to forum.odroid.com about setup the forums where I was eventually able gpio304# echo 0 > value ;Turns
issues I discover. This continues until I to piece together this set of basic instruc- off the pin
succeed in getting it to work. The third tions:
and fourth steps, however, are ones that Update the Ubuntu kernel by fol- This is what I needed to start devel-
I particularly enjoy. lowing instructions in the forum post at oping my IO-Shield dialect, which I de-
The challenge of the third step is http://bit.ly/1o3vMJx. cided to name gpio.
to boil down the functionality of the
new hardware to the most simple, Type the following into Terminal: Step 3
elegant, flexible and efficient form as
possible while throwing out any pre- odroid@odroid:/sys/class/gpio$ After quite a bit of thought and de-
conceived notions of how that hardware sudo su sign, here are some examples of what I
is currently designed to be accessed or root@odroid:/sys/class/gpio# mod- wanted my dialect to be able to do:
controlled. This doesn’t involve any probe gpio-pca953x
coding, but rather is a process of design- root@odroid:/sys/class/gpio# gpio [
ing a dialect to act as an intermediary modprobe i2c-gpio-custom init out P17 ;initialize pin
between the user and the hardware bus0=4,200,199 P17 as an output
while achieving all the stated goals. root@odroid:/sys/class/gpio# echo on ;turn on P17
The fourth step is to convert that tca6416 0x20 > /sys/devices/plat- wait .1 ;wait .1 seconds
dialect into code using Rebol’s power- form/i2c-gpio.4/i2c-4/new_device off ;turn off P17
ful parse feature. Amazingly, once the root@odroid:/sys/class/gpio# echo deinit P17 ;deinitialize pin
hard part of the third step is done, the 304 > export ;304 is equivalent P17
fourth part is quite simple. Most often to P17 on the IO Shield ]
ODROID MAGAZINE 34
IO SHIELD
ODROID MAGAZINE 35
ODROID-SHOW
DIGGING (INTO)
THE ODROID-SHOW
UNLOCK THE
ARDUINO
HARDWARE’S
FULL POTENTIAL
by Declan Malone
P
revious issues of ODROID Mag-
azine covered the basics of setting
up the ODROID-SHOW hard-
ware and using it as a display for vari-
ous data generated by your ODROID
or PC. While this has many useful ap- The ODROID-SHOW can do much more than display simple text data
plications, it only scratches the surface of
what’s possible with the SHOW. At the SHOW example software can be information.
heart of the device is an ATMega328p downloaded from Hardkernel’s official For this article, I’ll be concerned with
chip, which is the same kind of mi- GitHub repository: looking at contents of the “show_main/”
crocontroller that’s contained in many and “libraries/” directories, which are ex-
models of the popular Arduino plat- $ mkdir ~/src; cd ~/src plained in the block diagram shown on
form. This means that almost anything $ git clone https://github.com\ this page.
that you could imagine using an Arduino hardkernel/ODROID-SHOW
for could just as easily be made to run on $ cd ODROID-SHOW Parts explained
the ODROID-SHOW.
This series of articles aims to dig You will find directories named “ex- Terminals (meaning some kind of
below the surface, so to speak, and to ample/”, where you will find programs keyboard and display combination) have
introduce you to using the ODROID- to run on the ODROID or PC host, been around for over a century, even be-
SHOW as a programming platform in its “show_main/”, where you will find the fore the first computers were built! As
own right. In this installment, I’ll cover main program to run on the SHOW, computers became more commonplace,
the software components that come pre- and “libraries/”, where the various Ar- many of the old terminal devices were
installed on the ODROID-SHOW, how duino support libraries live. Depending put to use as dumb data entry and dis-
they work, and how you can modify on when you downloaded the sources play devices. In the early days, instead
them and upload your changes to the de- from github, you may see other direc- of personal PCs, it was much more com-
vice. I’ll use a simple example of a Man- tories, too, such as one for the weather mon to have a large and powerful com-
delbrot Set viewer to demonstrate this. module, which I won’t cover in these puter (such as a mainframe computer)
In the second article, I’ll deal with articles. connected to lots of different terminals.
some options for connecting the SHOW You may already have looked at Because of the wide variety of differ-
to some simple electronic components the programs in the “example/” direc- ent kinds of terminal devices, as well as
via the two GPIO headers. Finally, the tory. If not, now might be a good time the wide range of features that newer,
third article will look at building a com- to have a look, so that you can familiar- more sophisticated terminals offered
plete, self-contained game on the hard- ize yourself with some of the capabilities (such as coloured text, an audible bell,
ware itself. of the ODROID-SHOW. You can also ability to position the cursor or clear the
The latest version of the ODROID- check out the previous articles for more screen, etc.), some sort of standardisa-
ODROID MAGAZINE 36
ODROID-SHOW
tion was needed. The list of “ANSI es- Arduino the official software. Let’s get started by
cape code” (such as “ESC[2J;” to clear Programming Basics installing the Arduino IDE. On Debian/
the screen) was the result. Ubuntu systems this is done by typing:
While this might sound like quite an All the software components includ-
archaic system (after all, we all have PCs, ed in the official software for the SHOW $ sudo apt-get install arduino
laptops and tablets now, not terminals!), device are written in C++. If you know
actually it’s still in common use today. If C++ (or even C) already, you should have This will install a lot of other pro-
you use “xterm” or a more modern no problem starting out on program- grams besides the IDE, including a
equivalent (like “gnome-terminal”) you ming for this platform. There are some cross-compiler (“avr-gcc”) and some sup-
can still use the ANSI escape codes for minor some differences in the way C++ porting tools (“avrdude” being the main
all the things that used to be done on is used on the Arduino, and you should one). For the most part, you don’t need
dedicated terminals. be aware of them. For example: to worry about all these extra tools, since
More importantly for our discussion the Arduino IDE will call them transpar-
here, this is exactly what the “show_ • Instead of using low-level com- ently for you when it needs to. Later on,
main” program block in the diagram mands like “gcc” and “make”, all if you want to change over to using these
above is implementing by programming your editing, compilation and tools directly (with your favourite edi-
the Arduino to behave as if it was a ter- uploading of programs is done tor and Makefiles), you’ll be able to do
minal screen. in a graphical IDE (Integrated so. For these articles, however, I’ll stick
You can check out the full list of Development Environment) with the simple IDE option.
“escape codes” that the software im- named, appropriately, Arduino.
plements by referring to http://bit. There are four other important setup
ly/1nkYKUt. I’ll come back to this lat- • Programs written for the Ardu- steps:
er when I add an ANSI-like escape for ino are often called “sketches”,
drawing a single pixel on the screen. and generally have a “.ino” file 1. Tell the IDE where you will
The other box on the left is for the se- extension store your “sketches” (not where
rial connection to the PC (or ODROID) you downloaded the sources
host. It’s used both for receiving data • Programs do not have a from github!)
from the PC and also for printing de- “main()” function, since this is 2. Tell it which serial port to use to
bug information, which can be very supplied by the Arduino com- communicate with ODROID-
handy when writing Arduino/SHOW pile system SHOW (this may change if you
programs. reboot or move USB devices
On the right-hand side, we have • All initialisation is done in the around)
two libraries that were also developed program’s “setup()” function 3. Tell it which version of the
by Adafruit. The top one implements Arduino is being used
high-level graphical primitives, such as • Arduino programs also require a 4. Tell it where to find your librar-
printing a character, drawing points, “loop()” function. As the name ies
lines and circles, and filling in rectangu- suggests, this function is called
lar areas with solid colours. This can be in an infinite loop directly after All steps except Step 3 are covered
seen as the platform-independent part of the “setup()” function returns in the official ODROID wiki page at
the stack. http://bit.ly/1p8uitU, so I won’t repeat
Below that, we have the platform- These are all relatively minor differ- them here. For Step 3, select “Tools >
specific part of the graphics code. It ences to working on a “real” computer, Board > Arduino Uno”. The ODROID-
knows about how the ATMega chip is so it’s actually quite easy to dive into de- SHOW is fully compatible with the pre-
wired up to the TFT module, as well as veloping programs for the Arduino (and built Arduino Uno configuration.
the protocols needed to communicate SHOW!) platform. If you are running an older version
with the actual hardware, as shown in of the Arduino program (for example,
the box below. Development my Debian Wheezy distribution only
We won’t be delving too deeply into Environment provides version 1.0.1 of the program),
how this side works, but you may be then in Step 4 there may not be an “Add
interested in examining the code if that For our first step with programming Library ...” option under the “Sketch >
interests you. the SHOW, we’ll just compile and reinstall Import Library” menu option. If your
ODROID MAGAZINE 37
ODROID-SHOW
ODROID MAGAZINE 38
ODROID-SHOW
case ‘X’:
ODROID-SHOW displaying a Mandelbrot set
row = (row > right_edge0) ?
right_edge0 : row; software, so you can check for yourself Mandelbrot Set
where the code was added.
col = (tmpnum > bottom_edge0) ? If you can understand how the parser A common first step when checking
bottom_edge0 : tmpnum; is organised, then it should be possible out any new graphics hardware is to dis-
to add more features to it by following play the Mandlebrot Set on it. In the
tft.drawPixel(row, col, the same method as above. You could, unlikely event that you’ve never heard
foregroundColor); for example, add more escape sequences of this before, the Wikipedia page at
for drawing circles, lines or boxes, all of http://bit.ly/1mQ75y3 is a good place
break; which are available from the GFX li- to start. That page also includes pseudo-
brary but not currently exposed to the code for generating the Set, so I won’t
This does bounds-checking on the PC side. need to cover that here.
supplied row and column values then It would be quite straightforward to You can download my code from a
calls the appropriate method from the implement a set of LOGO-style primi- fork I made of the official Hardkernel
GFX object (“tft.drawPixel()”) using the tives, for example, with commands for SHOW repository by typing the follow-
current foreground colour. moving forward or backward, rotating ing commands:
These changes were since incorpo- the “turtle”, putting the pen up or down,
rated into a later version of the official and so on. $ cd ~/src
$ git clone \
ODROID-SHOW displaying a Mandelbrot set
https://github.com/declanmalone/
ODROID-SHOW.git SHOW-fork
$ cd SHOW-fork
ODROID MAGAZINE 39
ODROID-SHOW
1. It includes some code based on Native Generator data with two calls to “spi-
the official “port_open.c” pro- write()”.
gram. This code opens the USB I also wrote a version of the Mandel-
serial port and sets the baud rate brot Set program as a sketch designed to It takes the ATMega chip just over
and other important param- run independently on the ODROID- two minutes to render the full im-
eters. This means that the code SHOW, without needing any host age with a maximum iteration value of
does not need to have a separate PC. The sketch can be found in the 1000. Considering that the chip has
“port_open” program running. “duino_fractal/” directory. Compiling no floating point capability and it only
and installing is done in the same way as runs at 16MHz, this isn’t too bad. The
2. The “plot_point()” function you did for the official terminal emula- native code also has one advantage over
sends the appropriate “ESC [ tor software, as described earlier. the PC code: since it doesn’t receive any
x ; y X” string over the serial The native code is broadly similar to data over the serial connection, it doesn’t
port. It also sends a separate the version for the PC, with some dif- need to delay after writing each pixel.
“ESC 3 ? m” string to set the ferences: When I wrote the code, I had initially
colour of the point. intended to use a potentiometer and two
• It’s written in Arduino-style push buttons to allow the user to zoom
3. That function also includes C++, with a “setup()” and (an in and out on a particular screen area (in
appropriate error-checking empty) “loop()” function a similar way to the video at http://bit.
to make sure that the full ly/1yZ0UgB), but I never completed
string was actually written to • It makes use of the GFX and that part. As a result, only some of the
the device. If the send buffer ILI9340 libraries directly code to support this, such as definition
overflows, then “write()” will of hardware pins and ability to paint in-
fail and set the error value to • It sends back debug messages dividual “panels”, for easier scrolling, are
“EAGAIN”. over the serial connection with actually implemented.
The code correctly handles this “Serial.print()” calls
case by advancing the write Summary
buffer and trying the “write()” • It also uses the Arduino’s inter-
again until the full string has nal timer function “getmillis()” We’ve had a lot of ground to cover
been sent. to time how long it takes to in this article. I hope that it has served
render the screen as a good introduction to the basics of
4. There is a call to “usleep()” af- programming the ODROID-SHOW
ter every write. This is needed • It writes to the TFT screen’s and has helped to explain some of the
because the ATMega is only a memory directly rather than things that the platform is capable of. I
single-threaded computer and calling “drawPixel()”. This think you’ll agree that it’s actually not
if the PC side sends data too means that it calls “setAddrWin- that difficult to get started with writing
quickly, it is possible that some dow()” once for each “panel”, code for it. In the next article, I’ll get
of the data will be lost. Adding then write each pixel’s colour to grips with hooking up the SHOW to
a short, user-adjustable delay other components via the GPIO pins.
after every write is a simple
way of working around this.
ODROID MAGAZINE 40
OS SPOTLIGHT
OS SPOTLIGHT:
POCKET ROCKET AND Pocket Rocket and
T
he ODROID family of comput-
ers was originally marketed as an
Open Android system, offering
application programmers an alterna-
tive to purchasing an expensive Android
phone and rooting it. ODROIDs runs
Android extremely well, while including
many useful features such as hardware
video decoding and joystick drivers,
which would need to be installed sepa-
rately on a comparable Linux X11-based
system.
When I began using ODROIDs, I
set up a set-top box using an Ubuntu
desktop environment called LXDE,
which let me stream and download me-
dia files, then play them using Xine or The list of pre-installed apps for Pocket Rocket and Couch Potato
XBMC. It could render 720p videos
well, but only some 1080p videos, with U, and XU) is flawless when using MX Before purchasing my first
lots of dropped frames, and was watch- Player, and plays videos of any resolution ODROID, I had never before consid-
able but choppy. After trying several and encoding. ered using Android as my main operat-
tweaks to achieve smooth video, includ- At the time, I had also purchased an ing system, but after putting together
ing overclocking and setting kernel op- Apple TV, which has a friendly interface, the Pocket Rocket image, I learned the
tions, I reformatted my SD card and in- but I couldn’t install new applications, advantages of it. Android is an extremely
stalled Android Jelly Bean 4.1.2 on my since the iTunes store isn’t available for stable OS, and even when an app crashes
U2 instead. the Apple TV. However, an ODROID or starts to slow down, Android makes
The Jelly Bean 1080p video experi- Android system allows unrestricted in- it easy to shutdown the application. It
ence was incredible, and exactly what stallation and removal of applications also has a shallow learning curve, with
I was looking for! Using both XBMC just like an Android phone, with thou- large, friendly icons, as well as shortcut
and MX player, the ODROID could sands of applications and games available buttons that are intentionally similar to
smoothly play even the densest videos from the Google Play Store. Android is other operating systems.
on the XBMC website (such as Big Buck already rooted, so the operating system In order to use Android efficiently,
Bunny) that are known to bring other can be customized, self-writte apps can I use the built-in keyboard shortcuts,
systems to a stuttering halt. The video be installed, and administrative func- which are similar to other desktops such
decoding on every Android build (X, tions can be performed as the root user. as Windows, Ubuntu and OSX.
ODROID MAGAZINE 41
OS SPOTLIGHT
Keyboard Shortcuts
Ctrl-C
Copy
Ctrl-V
Paste
Ctrl-A
Select all
Ctrl-W
Close Window
Ctrl-Right Arrow
Move right one word
Ctrl-Left Arrow
Move left one word
XBMC is the go-to program for all of your media center needs. It supports
Ctrl-Shift-Right Arrow
video, music, addons, and even can launch other applications.
Select word to the right
Ctrl-Shift-Left Arrow
basically any task that a desktop PC can stead by depressing the left mouse but-
Select word to the left
perform, but in a different way. ton for several seconds. For example,
Alt-Tab
Switch program As an example, most desktop PCs of- in ES File Explorer, to select multiple
Alt-Esc fer a word processor, and save its files folders, long click the first folder, which
Desktop to the local hard drive. In Android, the will then bring up a checkbox interface,
Control-L software used for editing documents is where other folders can be selected with
Go to address bar called Google Drive, which stores the a single click.
information on the cloud. With Google
Drive, you can pick up any mobile de-
Android Experience vice, laptop, tablet, or desktop PC, log eMMC vs SD card
into Google Drive, and have access to all
Android is especially suitable for be-
of your documents without needing to Android is designed to run from an
ginners, or anyone that has experience
carry a USB thumb drive with you. eMMC module, and a distinct advan-
with a mobile phone interface. How-
One notable difference with Android tage of ODROID computers is that this
ever, even as an expert computer user,
is that the right mouse button is actu- module can be removed and replaced
sometimes I just want to change some-
ally used as the “Back” button. To bring easily. Although an SD card will tech-
thing without having to adjust settings,
up menus that would normally be done nically run Android, the slow speed of
navigate menus or move windows. An-
with a right click, use a “long click” in- the SD card hinders the experience be-
droid is perfect for this, and can perform
cause of the disk I/O. I stopped releas-
ing Pocket Rocket images on SD card
XBMC Gotham 13 starting up for the first time. This is the final release of because of the amount of time spent
XBMC, since they are changing the name to Kodi for version 14. clicking the Android “not responding”
popups while customizing the image.
However, I discovered that the Ice
Cream Sandwich (ICS) version of An-
droid runs smoother than Jelly Bean,
when comparing them both using an
SD card. As a result, I created a special
SD card version of Pocket Rocket called
Couch Potato that has all of the same
applications as Pocket Rocket, but uses
ICS for better disk performance.
If you don’t have the eMMC mod-
ule, then you can install Couch Po-
tato instead, and enjoy all of the same
features as Pocket Rocket. Occasion-
ODROID MAGAZINE 42
OS SPOTLIGHT
ODROID MAGAZINE 43
OS SPOTLIGHT
Who doesn’t like Angry Birds? Pocket Rocket and Couch Potato come with
3 versions of this highly addictive game.
ODROID MAGAZINE 44
OS SPOTLIGHT
ODROID MAGAZINE 45
OS SPOTLIGHT
Installing Custom
Applications
The Video menu also contains Google ES File Explorer and Ultra Explorer are
Although Pocket Rocket is loaded
Hangouts and TED Talks two full-featured Android file explorers
ODROID MAGAZINE 46
MEET AN ODROIDIAN
MEET
AN ODROIDIAN Bo Lechnowsky, one of the Editors of
BO LECHNOWSKY: the ODROID Magazine, playing his
woodwind instrument
EXPERT MAKER AND outdoors
INSPIRATIONAL INVENTOR
by Bohdan Lechnowsky
edited by Rob Roy
ODROID MAGAZINE 47
MEET AN ODROIDIAN
ODROID MAGAZINE 48
MEET AN ODROIDIAN
ODROID MAGAZINE 49