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 pine64.org 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 http://linux-sunxi.org/Linux_mainlining_effort. 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 http://linux-sunxi.org/FEL 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 https://lists.denx.de/pipermail/u-boot/2016-November/271732.html
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.


Popular posts from this blog

gnome 3.6 and keyboard layout configuration

OLED brightness in Linux