-
Notifications
You must be signed in to change notification settings - Fork 21
Mainline kernel on bpi
Status: all working except LCD.
- 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:
- authors: Luc Verhaegen (contacted), Hans de Goede (contacted), Maxime Ripard (to be contacted)
- simplest framebuffer driver
- upstream in mainline already, present in Debian Stretch kernels too
- recent (4.15) kernel work by icenowy, signed off by Maxime Ripard (irc.freenode.net#linux-sunxi icenowy)
- Some portions based upon fbtft?
- See https://github.com/notro/fbtft/wiki/Development
- possibly relevant patches in Armbian: https://github.com/armbian/build/blob/master/patch/kernel/sun7i-default/fbtft_for_older.patch
- Debian installer for stretch
- Get it from https://www.debian.org/releases/stable/armhf/ch05s01.html.en#boot-installer-sd-image .
- Make sure to use the most recent version of the installer to avoid missing crucial udebs (kernel modules for storage!). Hint: uname -r inside the installer...
- Flash it:
time zcat firmware.BananaPi.img.gz partition.img.gz > /dev/mmcblk0
- 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
- Add the relevant lcd config from above to configs/Bananapi_defconfig. Got this from http://linux-sunxi.org/LCD :
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
- 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
- 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...
- 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.
- No difference here.
- Boot into u-boot. At least Gpio toggling the LCD backlight on/off works:
gpio toggle PB2
-
Potentially relevant recent changes to the U-Boot video code? https://github.com/u-boot/u-boot/commits/master/arch/arm/mach-sunxi/Kconfig TODO: It might make sense to use the Debian source package u-boot instead of git master...
-
http://linux-sunxi.org/Mainline_Kernel_Howto#simplefb says "Don't forget to change your console in your boot.cmd/boot.scr to console=tty1 to enable the simple framebuffer driver."
-
To generate a u-boot boot.scr from a plaintext file, run "mkimage -T script -A arm -d /srv/tftp/didaily/boot.scr.plaintext /srv/tftp/didaily/boot.scr"
-
Useful commands:
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.
- 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
- Output:
- http://gerry.safehex.be/tmp/fosdem/screen.mp4
- colored horizontal lines on the left part of the screen
- one color on the right 75% of the screen
- changes with every
cat /dev/urandom > /dev/fb0
-
A lot has been in flux the last few weeks in terms of LCD support on the banana pi, both at the u-boot and the kernel level. See:
-
u-boot video config environment variables: https://github.com/u-boot/u-boot/blob/master/doc/README.video (These config names might not be up to date anymore with the move to CONFIG_VIDEO_SUNXI!)
-
u-boot compile time variables: https://github.com/u-boot/u-boot/blob/master/arch/arm/mach-sunxi/Kconfig
http://wiki.lemaker.org/BananaPro/Pi:LCD_Module
- Armbian build scripts might contain some interesting info about the kernel bootargs: https://github.com/armbian/build/blob/master/config/bootscripts/boot-sunxi.cmd
- https://forum.armbian.com/topic/4138-migrating-bananapi-to-mainline-kernel/
- https://forum.armbian.com/topic/1905-enabling-lcd-in-u-boot-kernel-472/