Monday, September 18, 2017

Hacking u-boot for Pinebook. Part #1 - using FEL

It's been a while since I posted to my blog. A lot of things happened since then, I guess the most important is -- I moved to Canada. I've been living in Vancouver (OK, Greater Vancouver) with my wife and cat for more than 2 years now. But enough about me, let's get back to the topic.

Recently I've got a Pinebook, mostly for hacking purposes. It's pretty nice device - quad-core Allwinner A64 CPU, 2GB LPDDR3 RAM, eMMC storage, etc, etc. See for full specs. But unfortunately it comes with BSP kernel from Allwinner which is pretty ancient - 3.10 (released in 2013, more than 4 years ago!)

Hopefully, mainline support for A64 is in pretty decent shape, see Sure some things are missing - LCD, sound, power management, and that's not all. But it's good - there's something to hack on, right?

So I decided to start with u-boot. Hopefully, Allwinner SoCs support boot over USB - it's called FEL, see for details. So basically it's possible to load and execute SPL to configure DRAM, and then load and start u-boot. That's very convenient for development - you don't have to do SD-card juggling, just connect your laptop to the board using USB cable (USB-A to USB-A in my case), load your card with special image and you're good to go.

Unfortunately, 64-bit SPL doesn't support jumping back into FEL which is 32-bit code. To overcome this issue, it's possible to build SPL in 32-bit mode. It's not supported in mainline u-boot at the moment, but there're patches on the list, see
So it works like this:

  • Load and executre 32-bit SPL using FEL, which jumps back to FEL code after it's done
    • sunxi-fel spl sunxi-spl.bin
  • Load ATF (ARM trust firmware)
    • sunxi-fel write 0x44000 bl31.bin
  • Load u-boot
    • sunxi-fel write 0x4a000000
  • Jump into 64-bit ATF, which jumps to u-boot after it's done:
    • sunxi-fel reset64 0x44000
Don't try to flash your card with 32-bit SPL and 64-bit u-boot - that won't work. 32-bit SPL doesn't know how to switch to 64-bit mode, use it only with FEL.

That's it for today. In part #2 I'll be talking about PMIC and LCD on Pinebook.

Sunday, August 11, 2013

Access point with Raspberry Pi and rtl8192cu dongle

On Thursday ethernet ports (WAN and LAN1-4) in my Asus WL500GPv1 router have completely died, so I needed a replacement. Hopefully, recently I've got Raspberry Pi, so I decided to use it as a router. I've got TP-LINK TL-WN821NC USB stick from local store which is based on RTL8192CU chipset. Unfortunately, its driver doesn't work with vanilla hostapd, but requires patched ancient version of hostapd from Realtek.

I'm using Archlinux on my rpi and I've found manual how to setup AP using this USB stick here, but I don't want to overwrite binaries from repository packages, since it's not a sane way, and it can (and will) be broken by hostapd update.

So I prepared a package, here's source package (just unpack it and build with makepkg directly on rpi), and here's binary package for armv6h (you can install it with pacman -U). I can't put PKGBUILD in AUR, since there's no stable hosting for Realtek's hostapd. If anyone is willing to host it somewhere and put PKGBUILD in AUR - you're welcome!

You need to replace driver=nl80211 with driver=rtl871xdrv in your /etc/hostapd/hostapd.conf in order to make it work.

Monday, April 29, 2013

topIcons extension for gnome-3.8

Well, I dislike gnome devs decision about putting legacy tray icons to the attic (message tray), and prior to gnome 3.8 there was an extension to move all tray icons to the top panel. But after upgrade to gnome-3.8 subj extension didn't work properly (tray icons disappear after locking/unlocking screen). I've waited for a fix about a week, and then I decided to fix it by myself, result is on github.

Saturday, January 5, 2013

Wayland and software rendering

Recently I spent few evenings for hacking wayland. I like idea of wayland - rendering is done completely on client (in whatever way), compositor (server part) is responsible in rendering buffers from clients on the screen. Issue for me was rendering part of weston (reference compositor for wayland) - it uses GLES for compositing, but I want to try wayland and weston on devices without hw acceleration (pure software rendering), and running software GL on PXA270@312MHz does not sound like a good idea, does it? :)

So I asked on if it possible to implement software renderer, Kristian Høgsberg (khr) responded that in master branch of weston repo there's a nice abstraction of renderer, so it's possible to implement pixman renderer. So I did :)

weston with x11-backend and pixman renderer

khr and pq from #wayland were very helpful, and described place of renderer in wayland architecture, here're some points

  • renderer just performs rendering of surface in order passed by compositor (compositor::surfaces_list)
  • each surface has opaque (surface::opaque region) and non-opaque regions, for performance optimization it makes sense to render them differently (with different composite operators, PIXMAN_OP_SRC and PIXMAN_OP_OVER respectively)
  • surface::opaque region is in surface coordinates, and damage region is in global coordinates, so one needs to translate surface::opaque region into global coordinates before compositing
I've also added MIT-SHM support to x11-backend to test pixman renderer, it's activated by passing "--use-shm" argument to weston.

I plan to add 16bpp formats support to wayland (currently it supports only 32bpp) and implement fbdev backend. As one maybe guessed, then I want to try wayland on my PDAs: Zipit Z2 and iPAQs :)

As usual, code is on github, I'll submit it upstream tomorrow.

Wednesday, October 31, 2012

gnome 3.6 and keyboard layout configuration

Gnome 3 devs are stupid enough to remove features before some replacement is implemented. Simplified nautilus and (what's much more important for me!) broken keyboard layout configuration. Well, you still can configure what layouts to use, but you can't choose usual shortcut to switch layout, and you can't configure led to indicate alternative layout.

Well, I still can use setxkbmap (setxkbmap -layout "us,ru" -option "grp:caps_toggle,grp_led:scroll"), but that's f***ing ridiculous to remove things that were working here for years and propose nothing for replacement! They broke core functionality (who can work without a keyboard?!), and it makes me sick!

Update: more haterays to gnome-devs! Gnome 3 overrides xkbmap settings somewhere, I wonder if there's a way to prevent it...

Update-2: you can remove gnome-settings-daemon keyboard plugin as a workaround (sudo rm /usr/lib/gnome-settings-daemon-3.0/

Wednesday, October 24, 2012

ArchLinux and broken gnome-settings-daemon

Just another post of hate. This time rays of hate go to maintainers of archlinux Gnome 3  packages. In short words:

  • global hotkeys are broken in Gnome-3.4 when using it with recent xorg-server
  • upstream patch exists, however no tarball was released (who cares!)
  • ArchLinux Gnome 3 package maintainers are lazy enough to import this patch and rebuild package
  • bug was reported and closed as "won't fix" because they're waiting for gnome-3.6.1 to stabilize and enter into extra repo.
Users suffer from bug for ~3 weeks! They even do not need to investigate what causes problem, patch exists. Btw, I've even created a source package and sent them a link. Some user from archlinux bbs created package in aur

I'm still wondering why they do not respect their users...

Tuesday, October 9, 2012

Hacking on fingerprinting again or AES2550/AES2810 driver for libfprint

Back in 2007 I participated in driver development for AuthenTec AES2501 scanner, driver was later merged into libfprint project. I didn't hack much on libfprint, just sent few bugfixes, but recently AuthenTec announced that they're willing to send fingerprint scanners for opensource enthusiasts who wants to develop driver for those scanners. So far, so good... I've wrote a letter to AuthenTec and they proposed to send AES2550 or AES2810 scanner to me. I chose AES2550. Actually, AES2550 and AES2810 are pretty same (AES2550 driver should work with AES2810), the only difference is missing crypto engine on AES2550 (who needs cryptography anyway? :))

So, I've got parcel with scanner in August, but unfortunately had no spare time for hacking, I only coded driver stub and read datasheet from AuthenTec.

So, in September/October I've spent few (5-6?) nights hacking on this driver, and finally got it working on my AES2550. Image quality is much better then on my AES2501. Driver lacks crypto features for AES2810 and external flash support for both devices. Anyway, libfprint has no external flash API yet, so there's some space for hacking :)

As usual, code is on my github page, branch aes2550-v2. Some testing is appreciated :)

P.S. Thanks to AuthenTec for opened specs and provided hardware! AuthenTec rocks!

Update: driver was merged into upstream, so you can use upstream libfprint repo