Recently in excitement about OUYA game console, an Android based gaming console, I bought ODROID-U2. This little piece of hardware is driven by an Exynoss 4412 chip, which can be also found in Samsung Galaxy SIII. It’s specs are similar to Tegra 3 platform. I want to play a little on Android, I already have Galaxy SII phone, on which I can play games from Google Play. I wanted a game console, which I could connect to my TV and control with a game pad. I also decided, that if I want to buy such thing, then it should enable me to install other operating system, so I can develop something on it.


The company, which made ODROID-U2, is placed in Korea, so I had to wait for the package two weeks. It was my first package from such distant country. I was a little worried, because this is a little computer and that at the customs office they could hold it and say ‘No, this shit is dangerous, it has a droid icon on the box’. Finally, after two weeks and some phone calls with FedEx, it arrived.

All the stuff, which I ordered came in a small box. I bought the ODROID-U2, a power supply, a wi-fi adapter and eMMC memory module with Android preinstalled. I also bought a cheap USB game pad and a HDMI to HDMI micro cable.


After quick unboxing, I connected everything and got horrified. The output on my TV was like from an old TV, which had a very weak signal. I was kind of disappointed. At first I thought, that the ODROID board or HDMI micro is damaged. I was looking at it with a magnifying glass for over an hour. I tried to connect it one more time and this time I moved the HDMI cable, I wanted to check if the image gets better when the connector is pressed, maybe it got loose or was not properly soldered. Moving the cable produced the right result – the image was now crystal clear. Then I realized, then the ODROID hardware is fine, but the cable could be damaged. It is very cheap one, cheapest I could get. I didn’t had any other HDMI micro supporting device, so I has to find another device. It was weekend, so I had to wait until Monday.

The screenshots are done with S2, so I could capture what I saw on the monitor. Doing a screenshot on the device would produce a good image, without the noise.


I checked the faulty cable with Sony XPeria Arc S mobile phone and to my relief, the video connection was interrupted when I moved this cable. To be sure that the cable was indeed damaged I checked with a Motorola phone, the results were the same.

So now I have to buy a new HDMI cable. This time I will buy a branded and spend a little more on it.

Nevertheless, when connected at right angle, the image was correct, so first impression is great.



New e-mail address

Recently I was looking at my e-mail address and I thought to myself that, when I want to give it to someone to contact me then he or she will get the ‘funny looking face’ saying ‘what is this? seriously?’. The second thing is that I always had problems with providing it via phone call, I mean spelling the e-mail. I know that it is quite simple, but I live in Poland and when I using ‘Q’ then every time people get confused.

So I decided to create a new one. Creating e-mail address on Google servers with my name and surname wasn’t successful, all the combinations are already reserved.
I already use one ‘variation’ of my name on BitBucket and as it turned out this e-mail address wasn’t taken.

So my new, official e-mail will be:


I will still use the old one, bu this will replace it in all accounts which are important to me.

I also added this information to my contact page on this blog.

Why I like Ubuntu/Linux software repositories

At home I have Ubuntu 12.04 installed on my Toshiba and I use it most of the time. Rarely I reboot my computer to Windows 7 to play some games. At work I am using a workstation with Windows 7.

Some days ago I wanted to update my software on Windows 7 at work. I use some tools, which are available for free, for instance Freemind, a mind mapping tool. In Ubuntu I would type a proper apt-get command in the terminal, but not Windows. In Windows I have to update it manually. Even when an application does provide an update mechanism, it has to be invoked manually. There is no central place or database where you hi ‘check for update of my installed apps’ and hit accept and then the software gets updated.

Some year ago, when using Linux, yes, it was a pain the ass to use some software. Now, with Ubuntu and apt-get, that problem was solved. If an application is available free it will be probably in the software repository. So, we get another extra feature: search for software. No need to search the internet for download site. When an application isn’t in main repository it can be in another repository, which can be  added to the list of sources, which apt-get searches through.

Some packages can be downloaded via a website (deb packages) and when installed, they add it’s repository information to apt-get’s config files. Next time apt-get packages list is updated, this repository will be checked too. Google Chrome does that for example, once installed apt-get checks for new versions of the web browser along with other software.

Also the problem with dependencies. Yes, some years ago, when one had to install from source, there were mountains of problems. Now, many packages, even when one has to compile and install it from source, provide routines to generate deb or rpm packages. Or the software creator maintains his or hers own repository.

In Windows, there is no central repository, or I am not aware of such mechanism. When it comes to managing software installations, then with the built-in mechanism, Linux distros are way ahead of Windows.

Samsung Galaxy SII – Update Android to 4.0.4

My new phone came to me with 4.0.3 version of Android system. My friend told me, that there is an update to 4.0.4. Not a big version jump, but something did concern me. I didn’t receive any updates. When tried to check updates via settings menu, it responded that there are no updates. When connected to KIES PC suite, then I got a message that my current firmware does not support software update. So I started to look for the answer.

I showed the KIES message to my friend and he told me to check what CSC I have set on my device. At first I didn’t even know what it was, but a quick google search and I found it.

CSC stands for Country Sales Code. It is a preconfiguration that is installed for a target country. My phone had set KOR. This CSC is for Korea and it’s for test purposes. I live in Poland, so my CSC should be XEO.

To check out what the CSC is set on the device type in the keypad:

*#06# - to check the device's IMEI number

After the second code is typed in, a menu will show up where the preconfiguration can be set. Active radio button will indicate the current CSC.


When a new preconfig is set and install clicked, all phone data is wiped out (allmost all, but most of app data). So in order to not loose the data, make a backup before.

When new CSC is set and install clicked, the phone will restart. After reboot it will reconfigure whole device.

Changing the CSC from KOR to XEO allowed me to get updated over the air. So now, after few updates installs and reboots, I finally have Android 4.0.4. Although this isn’t a major leap, I hope the updates repaired some problems, like hanging Wi-fi. Sometimes, when I wanted to turn on the Wi-fi, it only hanged on “Turning on Wi-fi…” and most of the times a reboot was needed (a workaround was to turn on Flight Mode, but that didn’t work for some of the cases).

Programming STM32F4 Discovery Board under Linux

Some months ago I bought a STM32F4 Discovery Board. It’s a good start to ARM programming. The good thing about this starter kit is that it can be programmed with open source tools. Also ST Electronics provides a neat peripheral library, which will save me a lot of time.

I followed a great description how to get running the compilation and programming environment from mikrocontroller.net. This description is written in German. I will describe steps, which I performed to get it running.

Toolchain installtion – Sourcery CodeBench

Free toolchain can be obtained from Mentor Graphics website. It’s called Sourcery CodeBench.

To download the package with the toolchain, goto Sourcery CodeBench website. In the ‘ARM Processors’ section click on the link ‘Download the EABI Release’, fill the form. An e-mail will be sent with a download link. After entering the link from the e-mail, choose a release. I chose ‘Sourcery CodeBench Lite 2012.09-63’ and the ‘IA32 GNU/Linux TAR’ package.

Now after downloading the package with toolchain software, we can install it in a place which would be accessible for all users.

sudo mkdir -v /opt/CodeSourcery
cd /opt/CodeSourcery
sudo tar xjvf arm-2012.09-63-arm-none-eabi-i686-pc-linux-gnu.tar.bz2

Programming tool installation

Checkout from texane’s github the stlink tool. This will be needed to flash the program to the chip’s memory.

git clone git://github.com/texane/stlink.git
cd stlink

Some additional packages were needed to compile this software:

sudo apt-get install autoconf libusb-1.0-0-dev

Now we can compile:


Create installation dir and copy executables:

sudo mkdir -v /opt/stlink
sudo cp -v st-flash /opt/stlink
sudo cp -v st-util /opt/stlink

Udev rules to recognize the Discovery board when connected to the USB port.

sudo cp -v 49-stlinkv*.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules

Now add path information to /etc/environment file. It needs to be edited with root privileges. Add to the end of file:



In order to update all environment paths, a logout and login is needed. My Eclipse did not recognize new PATH variable and there were no include paths added when a new project was created.

Now, let’s test our programmer. Only a read is sufficient to check if everything works. Connect the board to PC (via the miniUSB, not the micro) and try to download the demo binary from the board:

st-flash read ~/STM32F4-Discovery.bin 0x8000000 0x100000

If this works, then everything is setup for programming from the command line. To make it easier to develop programs, there is a possibility to integrate these tools with Eclipse IDE.

Eclipse IDE configuration

The only thing right now to do is to install ARM development plugin. Once it is installed, there will be new entries in the ‘New project’ wizard. Of course, CDT (C/C++) plugin should be also installed.

Link to Eclipse installation site: http://gnuarmeclipse.sourceforge.net/updates

Let’s test out new development environment

1. Open Eclipse IDE
2. File > New > C Project
3. ARM Cross Target Application > Empty Project
4. Toolchains = ARM Linux GCC (Sourcery G++ Lite)
5. Type in “Project name”
6. Finish

If the PATH variable is properly recognized by Eclipse, after creating a new project, there will be automatically added include paths:


Now we have to download a libraries package from ST Electronics: STM32F4 Standard Peripheral Library. Download it and extract it. Now we will add include paths to this library.

1. Project -> Properties
2. C/C++ General > Paths and Symbols
3. Configuration = [All configurations]
4. Includes tab, Languages = GNU C
5. Add -> File system…


The last one type in manually.

Now we will add a link source path.
1. Source location tab.
2. Link folder…
3. Name: StdPeriph
4. Check: Link to folder in the filesystem
5. Browse…


Next we have to add some symbols.
1. Symbols tab.
4. Add… -> HSE_VALUE = 8000000

Also the linker script has to be setup.
1. C/C++ Build > Settings
2. Configuration = [All configurations]
3. ARM Sourcery Linux GCC Linker > General
4. Script File (-T) = ${ProjDirPath}/stm32_flash.ld
5. ARM Sourcery Linux GNU Create Flash Image -> Output
6. Output file format (-O) -> binary

In order to have all the symbols indexed, we have to setup some last things.
1. C/C++ General > Indexer
2. Check the following:
– Enable project specific settings
– Store settings with project
– Enable indexer
– Index source files not included in the build
– Index unused headers
– Index source and header files opened in editor
– Allow heuristic resolution of includes

Now we can close the project properties and proceed. To start develop, we have to copy from the standard peripheral library directory four files.

<path_to_extracted_lib_files>/home/user/eclipse/STM32/STM32F4xx StdPeriphLib V1.0.0/Project/STM32F4xx_StdPeriph_Templates/TrueSTUDIO/STM324xG_EVAL/stm32_flash.ld
<path_to_extracted_lib_files>/home/user/eclipse/STM32/STM32F4xx StdPeriphLib V1.0.0/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
<path_to_extracted_lib_files>/home/user/eclipse/STM32/STM32F4xx StdPeriphLib V1.0.0/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/TrueSTUDIO/startup_stm32f4xx.s

Change the extension of ‘startup_stm32f4xx.s’ to capital ‘S’ and comment out:

/* Call static constructors */
//    bl __libc_init_array

In the stm32f4xx_conf.h comment out all the includes except for:

#include "stm32f4xx_gpio.h"
#include "stm32f4xx_rcc.h"

main.c source file content:

#include "stm32f4xx_conf.h"
#include "stm32f4xx.h"
GPIO_InitTypeDef  GPIO_InitStructure;
void Delay(__IO uint32_t nCount) {
  while(nCount--) {
int main(void) {
  /* GPIOD Periph clock enable */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
  /* Configure PD12, 13, 14 and PD15 in output pushpull mode */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOD, &GPIO_InitStructure);
  while (1) {
    /* Set PD12 Green */
    GPIOD->BSRRL = GPIO_Pin_12;
    /* Reset PD13 Orange, PD14 Red, PD15 Blue */
    GPIOD->BSRRH = GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
    /* Set PD13 Orange */
    GPIOD->BSRRL = GPIO_Pin_13;
    /* Reset PD12 Green, PD14 Red, PD15 Blue */
    GPIOD->BSRRH = GPIO_Pin_12 | GPIO_Pin_14 | GPIO_Pin_15;
    /* Set PD14 Red */
    GPIOD->BSRRL = GPIO_Pin_14;
    /* Reset PD12 Green, PD13 Orange, PD15 Blue */
    GPIOD->BSRRH = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_15;
    /* Set PD15 Blue */
    GPIOD->BSRRL = GPIO_Pin_15;
    /* Reset PD12 Green, PD13 Orange, PD14 Red */
    GPIOD->BSRRH = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14;

The above code will turn on and off four LEDs on the board. They are placed in the middle of the board. One diode will be turned at a time.

So if everything was setup properly, we can build the project and flash it into the board’s chips memory:

st-flash write Debug/STM32F4Test.hex 0x8000000

2012-11-25T21:24:20 INFO src/stlink-usb.c: -- exit_dfu_mode
2012-11-25T21:24:20 INFO src/stlink-common.c: Loading device parameters....
2012-11-25T21:24:20 INFO src/stlink-common.c: Device connected is: F4 device, id 0x20006411
2012-11-25T21:24:20 INFO src/stlink-common.c: SRAM size: 0x30000 bytes (192 KiB), Flash: 0x100000 bytes (1024 KiB) in pages of 16384 bytes
2012-11-25T21:24:20 INFO src/stlink-common.c: Attempting to write 56836 (0xde04) bytes to stm32 address: 134217728 (0x8000000)
EraseFlash - Sector:0x0 Size:0x4000
Flash page at addr: 0x08000000 erasedEraseFlash - Sector:0x1 Size:0x4000
Flash page at addr: 0x08004000 erasedEraseFlash - Sector:0x2 Size:0x4000
Flash page at addr: 0x08008000 erasedEraseFlash - Sector:0x3 Size:0x4000
Flash page at addr: 0x0800c000 erased
2012-11-25T21:24:22 INFO src/stlink-common.c: Finished erasing 4 pages of 16384 (0x4000) bytes
2012-11-25T21:24:22 INFO src/stlink-common.c: Starting Flash write for F2/F4
2012-11-25T21:24:22 INFO src/stlink-common.c: Successfully loaded flash loader in sram
size: 32768
size: 24068
2012-11-25T21:24:23 INFO src/stlink-common.c: Starting verification of write complete
2012-11-25T21:24:24 INFO src/stlink-common.c: Flash written and verified! jolly good!

USB to Serial Converter

I recently bought two USB to Serial converters. This little devices are based on the CP2102 chip from Silicon Labs.

I am now using Linux as my development environment, so I did not have to install any drivers. I just plugged the device in and it worked. There was only one thing with device permissions. In order to use is I had to be root. To avoid this situation I created a file with udev rule to set proper permissions next time the device will be plugged in, so then I could use it as a normal user:

File: /etc/udev/rules.d/50-usb-serial.rules


Now, using the screen program I can open this serial port as a normal user.

The serial port is under /dev/ttyUSB0, we can see it from /var/log/syslog, when plugging in the device:

kernel: [35849.009413] usb 2-1.3.4: cp210x converter now attached to ttyUSB0

To test the converter just loop the RX to TX and open the serial port with the command:

screen /dev/ttyUSB0 115200

The two arguments to the screen command are: serial port device and baud rate (speed of transmission). When the loop is closed (TX is connected to RX), then every character sent will be immediately received, so when a key on the keyboard is pressed a corresponding character symbol should appear on the console. When the loop isn’t closed, only the transmit diode on the device blinks, but no characters appear on the console.

The USB to Serial converter is a simple device but very useful in embedded programming. Until now I could only blink with LEDs when I was programming my miniSUMO robot. Now I can sent at least one character, so I can trace what is the state of the robot. Also I have two radio receiver/transmitter, one for PC and one for the robot, but I couldn’t configure then properly, I always received garbage. With help of a SUB2Serial converter I can now attach both communications devices to the PC and try to figure it out how they should be configured. Without this I had to flash a new binary file to the miniSUMO robot whenever I wanted to test new configuration.

New phone – Samsung Galaxy S II

I changed my phone. I bought a Samsung Galaxy S II. This phone isn’t the newest on the market, but still it is a powerful device. I wanted to have a device, which could handle the latest Android system. I received it with Android ICS (version 4.0.4) preinstalled, but I read on the Internet that in November it will be an official update to Jelly Bean.

S2 is much better than my previous phone, Samsung Galaxy Ace. Ace is a level or two lower than S2. Now I feel how technology went ahead. Not only the hardware is great, but also Android 4 is very different than Android version 2, which I have installed on Ace. The look and feel is much better.

As a smartphone it is inevitable that the battery life will be not so good. All the hardware needs power. I turned off all connectivity except GSM, set brightness to lowest possible value. Still I sometimes turned on Wi-fi and played games and the phone went 3 days and 2 hours on the first full charge.

Additionally, experienced by my previous phones, I bought an etui made out of rubber and a foil for the screen. The screen is made out of Gorilla Glass, which is advertised as no-scratchable. Knowing me I probably would scratch anyway. So an extra foil won’t hurt.