Fun with Rakuten Kobo Nia and LK8000

Linux GPS

When I was looking for a decent hardware for a paragliding instrument I came across the E-Book readers from Rakuten called Kobo.These machines provide a decent e-ink display together with a pretty capable hardware running Linux. The main reason they are so popular among paragliding pilots is the combination of hacker friendly software and easily accessible UART port. I own an e-book reader from the past - the Hanlin, I've read hundreds on book on that, but it's getting old, the battery is almost dead and I'm missing some cool features like a backlight, decent dictionary, etc. So why not to combine the need of a paragliding instrument and a new e-book reader? I've ordered the newest and cheapest (~100 USD) Kobo model, the Kobo Nia.

reader

Backup

The Kobo keeps the system and data on an internal SD card. It's probably cheaper than a directly soldered flash chip and that's good for us - the SD card is much more easy to "hack" and there's almost no way to brick the device by software as long as you have backup of the original data.

Therefore the first step before any hacking is prying the case open, pulling out the card and backing up the original firmware. The case is held together with a plastics buckles, just take a piece of a thin sturdy plastic and pry it open.

inside

The Linux users can backup the data by running the following command, the Windows users will need to google a bit. Simple copy-paste of the stored data won't work.

  • dd if=/dev/mmcblk0 of=kobo_backup.img

To increase the available storage space, I've cloned the image to a bigger SD card and extended the data partition:

  • dd if=kobo_backup.img of=/dev/mmcblk0
  • cfdisk /dev/mmcblk0 - select the latest partition and extend it to take all the available space
  • fatresize -s max /dev/mmcblk0p2

Stock Firmware

The stock firmware is called Nickel, it's working pretty well. There are only two major annoying "features":

  • Horrible PDF support - no reasonable support for text reflow or automated cropping, my ancient Hanlin has a much better PDF reader
  • Required registering the reader online (can be bypassed, see below)
  • Occasional freezes - at least in 2023 firmwares

The registration on the first boot can be bypassed:

  • Select Don't have a WiFi on the setup screen
  • Connect Kobo to PC
  • Run a sqlite3 KoboReader.sqlite inside .kobo folder on the reader USB storage
  • Register the user by running INSERT INTO user(UserID,UserKey) VALUES('1','');

The kobo is extremely hacker friendly due to a way the firmware upgrade process is designed. Anything inside KoboRoot.tgz archive placed to the .kobo folder on the USB storage exported by the kobo will be copied to the system partition once the Kobo is disconnected from the PC.

There's a forum with many alternative firmwares, software modifications and other stuff on the mobileread, it should be the first webpage to visit after buying the Kobo.

Startup script and factory reset

During the experiments with Kobo, it occasionally freezed. This can be solved by holding the power button for a while, but once in a while, this resulted in factory reset, wiping all the data and custom applications. This was quite annoying, so I've started digging.

The SDCard contains a complete linux filesystem, there are several notable areas:

  • U-Boot - the bootloader, stored in first few kB of the card, it doesn't show up as a partition, but it's there.
  • recovery - the Linux root filesystem, similar to the following rootfs partition, but the only reason of existence for this partition is to replace the rootfs with factory defaults when needed (factory reset, main fw not booting,...).
  • rootfs - the Linux root filesystem, all the software, libraries, kernel, config files, etc. is stored here. The content can be modified from the KoboRoot.tgz upgrade archives.
  • user data - this partition is where all the books are stored, it's the only partition accessible without removing the SD Card, simply connect Kobo to computer and it appears as a flash disk.

The boot process is straightforward:

  • The U-Boot loads kernel from rootfs.
  • The kernel starts /sbin/init process, which reads the /etc/inittab.
  • The inittab defines what shall be started next, in our case, the important lines is ::sysinit:/etc/init.d/rcS.
  • The /etc/init.d/rcS bash script is executed, does its magic and finally launches the /usr/local/Kobo/nickel reader software.

The problem lies in the /etc/init.d/rcS content, to be more precise, in following lines:

FORCE_FACTORY_RESET=0
FS_CORRUPT=0
dosfsck -a -w $ONBOARD_PARTITION || dosfsck -a -w $ONBOARD_PARTITION || dosfsck -a -w $ONBOARD_PARTITION || dosfsck -a -w $ONBOARD_PARTITION || FS_CORRUPT=1
[ ! -s /usr/local/Kobo/pickel ] && FORCE_FACTORY_RESET=1
/usr/local/Kobo/pickel should-factory-reset
if [ $? != 0 ] || [ $FS_CORRUPT == 1 ] || [ $FORCE_FACTORY_RESET == 1 ]; then
    case $PRODUCT in
            ....
    esac
    sleep 5
    zcat /etc/images/$PREFIX\factory-reset.raw.gz | /usr/local/Kobo/pickel showpic
    /usr/local/Kobo/pickel wait-for-hit $COORDINATES

    write_uboot_env $PLATFORM $UBOOT_RECOVERY
    reboot
    exit
fi

As you can see, the reader checks the partition consistency/corruption, runs some software to decide if factory reset is necessary and if any of this matches, an image is shown and the follwing code changes the default boot target to recovery: write_uboot_env $PLATFORM $UBOOT_RECOVERY.

The recovery partition boots in a same way as the rootfs, now the important part of the init script of the recovery partition is:

mkfs.ext4 -L rootfs -m 0 $ROOTFS_PARTITION && sync && sync
mkfs.vfat -n KOBOeReader $ONBOARD_PARTITION && sync && sync

mount -o norelatime,noatime,nodiratime $ROOTFS_PARTITION /mnt/root
echo 3 > /proc/sys/vm/drop_caches; sleep 2
( gunzip -t /upgrade/fs.tgz && tar zvxf /upgrade/fs.tgz -C /mnt/root ) || reboot

As you can see, the recovery partition formats both the rootfs and user partitions and fills the rootfs with data from /upgrade/fs.tgz.

To get rid of the unexpected factory reset, simply comment out or delete the part of rcS in the rootfs that I mentioned few lines above.

The rcS script is a very powerful tool. You can e.g. completely skip starting the nickel and run your own binary - e.g. launch the KOReader (see below) without NickelMenu or Nickel at all. With this knowledge, you are master of your device. But be beware, that any firmware upgrade from Nickel can overwrite your custom changes (check the rcS content, you can disable upgrades from KoboRoot.tgz too).

Alternative reader software

NickelMenu

The NickelMenu is a nice addition to the original Nickel firmware, it adds a customizable menu that can launch other tools.

  • Download latest release - KoboRoot.tgz and copy it to .kobo directory on the reader.
  • Reboot the reader and here you go!
  • There's a nice documentation, practical use will be shown in KOReader section below.

KOReader

The KOReader is an alternative reader software to the original Nickel from Kobo. It handles rendering PDFs much better and is much more customizable than the original one. The best way to install and launch it is to use the NickelMenu. To install the KOReader under NickelMenu:

  • Download release for kobo and extract it to .adds folder on your reader
  • Locate the .kobo/Kobo/Kobo eReader.conf and add two lines to the end of this file:
    [FeatureSettings]
    ExcludeSyncFolders=\\.(?!kobo|adobe).*?
  • Make sure you have the NickelMenu installed and add a new menu item - add following text to .adds/nm/koreader:
    menu_item:main:KOReader:cmd_spawn:quiet:exec /mnt/onboard/.adds/koreader/koreader.sh

Plato

The Plato is another alternative reader software. It's not customizable, but it's a bit faster and seems to be more stable (no freezes so far) than KOReader. Also the amount of supported formats is lower.

To install it:

  • Download release package - https://github.com/baskerville/plato/releases and extract it to .adds folder on your reader
  • Make sure you have the NickelMenu installed and add a new menu item - add following text to .adds/nm/plato:
    menu_item:main:Plato:cmd_spawn:quiet:exec /mnt/onboard/.adds/plato/plato.sh

Dictionaries can be downloaded from https://dictinfo.com, get one in dictd format and unpack it to the .adds/plato/dictionaries

Chess, calculator and others

There's a nice collection of tools from vlasovsoft, - download kobo version and extract to .adds folder. The archive contains a launcher, but that's not necessary, you can run the specific tools directly in a same way as the KOReader, just check the directory content and select an appropriate script file. E.g. to launch chess, add file .adds/nm/chess with:

menu_item:main:KOReader:cmd_spawn:quiet:exec /mnt/onboard/.adds/vlasovsoft/chess.sh

Quill-OS

The Quill-OS, originally called InkBox is a one man show Linux distribution and reader software for the Kobo. The author put a lot of effort into this, currently there's a second major release out there and the development continues. I had some issues running it on my Kobo Nia, that led me to this issue that mentions two hw variants of the Kobo Nia. In a nutshell, if you've bought the reader in second half of 2023 and later, you probably have the latter version, the N306c.

Kobo as flying instrument

The Kobo readers become quite popular with the pilots thanks to the high quality/resolution e-ink screen and a hackable design. There are two commonly used gliding computer softwares, that can run on the Kobo: the XCSoar and the LK8000.

The UART port is easily accessible on the reader and a GPS receiver or dedicated variometer like the bluefly can be therefore easily connected. Sometimes the USB port of the kobo is used to feed the data. Or I've even seen a bluetooth module connected to the Kobo UART to provide some wireless connectivity and I guess the WiFi could be used too.

Adding a GPS/vario

There's a 4 pin SMD footprint ready for soldering the cables on the Kobo PCB, the pins are even marked with their function, so it's quite easy to connect some UART device there.

wires

To avoid "permanently" changing the reader to flight instrument, I've drilled an opening in the case to tightly fit 2x3 pin SMD header, this way, it's easy to disconnect the vario/GPS and use the reader with the original case and nobody will have any idea there's some connector hidden in there...

wires

A simple experiment showed that the power pin is 3.3 V and is powered only when the reader is powered on. Nice!

I've started with a GPS module modification, the tiny L96 seemed to be a perfect choice, unfortunately after some experiments, I came to a conclusion it needs a good ground plate to function at all, the module itself placed on non-conductive surface with very good visibility to the sky was not able to get a reliable fix after a full hour... Therefore I've switched to more bulky but more suitable LC86G GPS module, it usually gets fix in matter of seconds and the fix is rock stable even indoors. With upgrade to bluefly in the near future (was already being shipped), I've glued a pin header to bottom of the module, wired RXD, TXD, GND and 3.3 V (through a switch to avoid sending any data to UART before the reader boots to OS, see the section below for more details).

gps

This setup worked pretty well. Or worked well before I've lost the GPS module during packing my gear after landing, it's probably still lying somewhere on the field in KruĊĦevo... A piece of sticky tape or maybe a Velcro would be a good idea. Anyway, my BlueFly vario arrived in the meanwhile, so I've used the same connector and piece of a Velcro to fix it to the reader.

XCSoar

The XCSoar is a well known and popular navigation software for cross country flying, it was originally created by glider pilots, but it's still quite usable for the paragliding. It runs on a wide variety of platforms with Android being the most popular today.

There's a direct support for the Kobo, download the installer, copy the KoboRoot.tgz to .kobo directory on the reader and reboot. The XCSoar overwrites the Nicker launcher, when the reader boots a custom launcher is shown and Nickel or XCSoar can be selected - you won't loose the e-reader abilities, so don't forget to download some books for long travels back from unfinished XC flights.

The XCSoar requires at least a GPS position to be usable, so I've hooked up an old GPS module I've found in my stock pile. There's a little drawback to the Kobo UART - the U-Boot is using it during booting, if any characters are received before the Kobo boots, the boot process is aborted - either connect you GPS after the Kobo boots, or make some power-on delay circuit for GPS.

To use the connected GPS in XCSoar, configure the device like:

  • Port: ttymxc0
  • Driver: Generic (NOT NMEA Output!)
  • Baud rate: 9600 (some more recent GPS modules use 115200)

The XCSoar release I've used didn't have the ttymxc0 listed in the menu, I had to set a different port, connect the reader to computer and rewrite it in the config file manually (check the XCSoarData/default.prf).

Here are some useful links:

  • Install guide - how to connect vario and install the XCSoar
  • Maps
  • Map generator - generator of custom maps forXCSoar
  • Waypoints - Airports and stuff to be shown on the map
  • OpenAip - Airports, Notams and other data
  • Airspaces - Airspaces for various countries, use .sua or .txt format.
  • Airspaces from XContest - Daily updated list of currently active airspaces, need to download valid data every day

The config files, maps, airspaces and other data live in the user partition inside the XCSoarData folder, right next to your books.

I've had some stability issues with the version 7.36 (that was the latest one), the XCSoar occasionally froze while clicking some menu item. Sometimes it was running smoothly for few hours, sometimes it froze without touching anything. People reported XCSoar version 6 to run smoothly without issues, but that was probably for the first Kobo Nia hw version, I had same issues on version 6 as on 7. As you are reading this article, the issue might already be fixed, who knows...

Anyway, I've decided to use the direct competition, the LK8000 as it was stable and I quite liked the way it's controlled (by touching of screen regions instead of small icons/buttons).

Custom launch menu of XCSoar

The XCSoar launch menu has a nice feature of custom items. I was using it to launch the KOReader directly without launching the Nickel. To add a new item, e.g. KOReader in our case, create a new file XCSoarData/kobo/scripts/koreader.sh with following content:

!/bin/bash
exec /mnt/onboard/.adds/koreader/koreader.sh

The new menu item appears and launches koreader upon touching. As the script is just a plain bash, anything can be done here (configure the external vario, connect over wifi to something,...).

LK8000

The LK8000 shares a lot with the XCSoar. They have the same origins, the LK8000 was forked from the XCSoar many years ago. The author was not happy with the XCSoar UI and some other stuff. Although the codebase changes a bit since forking, the set of features are almost same as in the XCSoar, there are even some features the XCSoar misses - quite impressive as the LK8000 is mostly one man show.

The install process and wiring is almost the same as for LK8000, just download the update archive and proceed as usual.

Here are some important links:

  • LK8000 basic tutorial - the UI needs some guidance at first, but it's not that hard to learn.
  • Map Generator - the original maps are far from perfect, this can generate map for any area in any level of details.
  • BlueFly vario configuration - how to add a custom menu to change vario configuration from Kobo.

Conclusion

When testing on table, the LK8000 was perfectly stable, no freezes at all. However in flight, the Kobo probably overheated on a direct sunlight and restarted after few minutes of flight. It came back online after few seconds, but this rendered Kobo unusable for flying as it happened at almost every flight. It might be issue of my piece of hardware and other Kobo Nias would work just well, I don't know.

I've switched to a different harness with a sun shade over the "instrument panel" and started using the XCTrack running on my old Android phone with Bluetooth tethering (from my current phone) for internet access. The color display helps a bit with reading the map and the ability to download the currently active airspaces automatically is just amazing, I can no longer live without it (this could be added to Kobo too, but the amount of work would be non-trivial).

Previous Post