Skip to content

Mainline kernel on bpi

Gerry Demaret edited this page Oct 22, 2018 · 53 revisions

Status: all working except LCD.

Executive summary

  • Get a vanilla Debian installer for arm.
  • Build a u-boot with specific lcd configuration applied.
    • This is a necessary (and apparently sufficient) condition for the kernel to see the lcd device.
    • This is (it appears) not a sufficient condition for the actual lcd device being used. Might require fiddling with kernel bootargs in u-boot configuration.
  • Use simplefb:

Let's get the LCD to work

Debian installer

Building a custom u-boot

  • Install essential dependencies (arm cross compile tools and more):
apt-get install bison crossbuild-essential-armhf flex gcc-arm-linux-gnueabihf libfdt-dev libpython-dev python swig
  • Clone u-boot from git:
git clone git://git.denx.de/u-boot.git
CONFIG_VIDEO_LCD_MODE="x:320,y:240,depth:24,pclk_khz:7000,le:38,ri:20,up:15,lo:4,hs:30,vs:3,sync:3,vmode:0"
CONFIG_VIDEO_LCD_POWER="PH12"
CONFIG_VIDEO_LCD_BL_EN="PH8"
CONFIG_VIDEO_LCD_BL_PWM="PB2"
  • Compile u-boot:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- Bananapi_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
  • Install it onto the SD card:
dd bs=1k seek=8 if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0

Serial console setup

Running u-boot

  • U-boot output seems to be either serial or hdmi (confusingly called "vga" in the u-boot config). See https://linux-sunxi.org/Mainline_U-boot#FB_console.
  • For testing, it is really best to use an usbserial thingie to plug into the JTAG connector. Tricky interactions where default output to HDMI instead of LCD might catch you otherwise...
  • (not recommended) If you really have no usbserial to plug into the JTAG connector available, tell u-boot to use the hdmi output as the default display instead of the serial console:
    • Interrupt u-boot from debian installer by pressing a key
    • Check the default environment variable "console":
=> env print console
console=ttyS0,115200
  • Permanently set the "console" environment variable to first screen (tty0) as opposed to serial (ttyS0)
    setenv console tty0; saveenv; reset

Let's see what the kernel says

  • Check dmesg after booting the linux kernel while using the serial console:
root@debian:~# dmesg|grep -B5 -A5 fb
[    0.203286] simple-framebuffer 7ffb5000.framebuffer: framebuffer at 0x7ffb5000, 0x4b000 bytes, mapped to 0xf0900000
[    0.203300] simple-framebuffer 7ffb5000.framebuffer: format=x8r8g8b8, mode=320x240x32, linelength=1280
[    0.205674] Console: switching to colour frame buffer device 40x30
[    0.207085] simple-framebuffer 7ffb5000.framebuffer: fb0: simplefb registered!

Clearly, the kernel sees the device. Does this mean our lcd is working, just not active? Do we still need extra kernel bootargs or other changes?

  • A look at the framebuffer properties while using the serial console might give useful feedback:
root@debian:~# cat /sys/class/graphics/fb0/modes 
U:320x240p-0

Compare to how it looks on the sunxi kernel:

root@aw1125-slides:~# cat /sys/class/graphics/fb0/modes
U:320x240p-65

The -0 in the mainline kernel should most probably not be a problem, as the hdmi screen gets driven perfectly well with a -0.

  • Let's dump the live device tree.
                                          │           
apt install device-tree-compiler
dtc -I fs -O dts /sys/firmware/devicetree/base >/tmp/dts.txt                                       │               

That yields two fairly similar files: http://glasno.st/dts_hdmi.txt and http://glasno.st/dts_nohdmi.txt . Only differences are in clocks...

Troubleshooting

Compare documented fex versus fex used

  • Get the .bin file from the working, running setup
  • Convert it to fex
apt install sunxi-tools
bin2fex lcd.bin
  • Compare it to the fex file from the LeMaker wiki.
diff lcd.fex banana_pi_35lcd.fex
  • Hm, no difference there.

Calculate fex values into u-boot compile time values

  • No difference here.

U-boot

  • Boot into u-boot. At least Gpio toggling the LCD backlight on/off works:
gpio toggle PB2
env print
setenv
saveenv
bootargs
  • TODO: Check CONFIG_VIDEO_LCD_BL_PWM_ACTIVE setting ?

  • TODO: Lots of stuff seems to be changing in both u-boot and recent kernels. Rebuild the u-boot source package from Debian.

Checking the framebuffer

  • Boot into u-boot. Switch on the backlight:
* Boot into linux. Throw random stuff at the framebuffer and see how it reacts:
cat /dev/urandom > /dev/fb0

Reading materials

Linux-sunxi.org

Lemaker 3.5" LCD specs

http://wiki.lemaker.org/BananaPro/Pi:LCD_Module

Armbian

Recent developments

General framebuffer debugging

Clone this wiki locally