Can't get fbtft_device working (Ubilinux)

Russell
Russell New Member Posts: 20
I've followed the wiki for TFT hats, and unfortunately the fbtft modprobe is failing with the following kernel output:

[ 1371.635838] spidev spi-SPT0001:00: SPT0001 spi-SPT0001:00 1000kHz 8 bits mode=0x00
[ 1371.635844] spidev spi-SPT0001:01: SPT0001 spi-SPT0001:01 1000kHz 8 bits mode=0x00
[ 1371.635883] fbtft_device: spi_busnum_to_master(2) returned NULL
[ 1371.642558] fbtft_device: failed to register SPI device

I'm using a 2.8" piTFT and I've already run the spi-enable script

I'm not sure whats wrong :(

Cheers
Russell

Comments

  • WereCatf
    WereCatf New Member Posts: 201
    You're supplying fbtft the wrong SPI-bus number. Try 1.
  • Russell
    Russell New Member Posts: 20
    Hi,

    Thanks for the quick reply.
    I tried modifying the bus number to 1, and it now has a slightly different error:

    modprobe: ERROR: could not insert 'fbtft_device': Operation not permitted

    dmesg output
    [ 155.064625] spidev spi-SPT0001:00: SPT0001 spi-SPT0001:00 1000kHz 8 bits mode=0x00
    [ 155.064629] spidev spi-SPT0001:01: SPT0001 spi-SPT0001:01 1000kHz 8 bits mode=0x00
    [ 155.064675] pxa2xx-spi pxa2xx-spi.10: chipselect 0 already in use
    [ 155.071551] spi_master spi1: spi_new_device() returned NULL
    [ 155.077814] fbtft_device: failed to register SPI device

    I'm not sure why its saying chipselect in use, I dont have any other spi devices connected.

    Cheers
    Russell
  • WereCatf
    WereCatf New Member Posts: 201
    That's because you have used the spi-enable.zip from the Wiki -- it reserves those chip-select pins and that's why they can't be used by device-drivers. You have to delete the file /lib/firmware/acpi-upgrades/spidev1.0.aml if you want to use cs0, or /lib/firmware/acpi-upgrades/spidev1.1.aml if you want to use cs1, and run:
    sudo update-initramfs -u -k all
    
    This updates the initramfs, removing the claim on the SPI-bus, so you have to reboot afterwards.
  • Russell
    Russell New Member Posts: 20
    Great, Thanks!
    I think thats sorted the spi side of things - no more errors.
    Somethings still not quite right though :(...
    The display doesn't seem to be getting any backlight power.

    When the UP2 board boots, the display gets power and displays white for a second or so. After this, the display backlight switches off - the display seems to have no power.

    The fbtft interface seems to work, but I think for some reason the displays backlight power switches off towards the end of the UP2 boot process.

    Any ideas?

    Thanks
    Russell
  • Russell
    Russell New Member Posts: 20
    Unfortunately mine is the capacitive version which doesn't expose back light control.
    Its weird, when i power up the UP2 board, the screen lights up for a second before the boards fan comes on, then when the fan starts up, the screen light goes off and seems essentially to not receive power.

    fbtft_device itself seems to think everything is fine. I'm not sure if this is a software problem. Are there some tft display hats which are guaranteed to work on the UP2? I could try get hold of one of them just to verify.

    Are there any bios settings or extra steps required to use the 40pin hat header of the up2 that I don't know about?

    Many thanks
    Russell
  • WereCatf
    WereCatf New Member Posts: 201
    So, there isn't a trace called "Lite #18" on your display? Provide a link to the one you have.
  • Russell
    Russell New Member Posts: 20
    Hi, its this adafruit 2.8" capacitive sheild:

    https://www.adafruit.com/product/2423
  • WereCatf
    WereCatf New Member Posts: 201
    Adafruit's documents at https://learn.adafruit.com/adafruit-2-8-pitft-capacitive-touch/backlight-control do claim that there is backlight-control on that display. I mean, it quite clearly says "To enable using GPIO #18 as a backlight, solder closed the #18 backlight jumper on the PiTFT capacitive PCB!"
  • Russell
    Russell New Member Posts: 20
    Yeah, I meant that because I hadn't soldered it closed, the backlight control isn't exposed and so shouldn't cause the backlight to be controllable.

    I've eventually got it working, without soldering.

    The extra steps I needed was to make GPIO 326 an output pin with value 1.
    Perhaps this is the backlight control, although its not documented as doing that when jumper #18 is left open.

    For reference:

    sudo -i
    cd /sys/class/gpio
    echo 326 > export
    cd gpio326
    echo "out" > direction
    echo 1 > value

    The only issue I now face is doing GPIO operations without root/sudo
  • WereCatf
    WereCatf New Member Posts: 201
    The only issue I now face is doing GPIO operations without root/sudo

    I made a small script that tries to set up all you need to be able to use GPIO/SPI/I2C as a non-root user. I've attached it here, just simply unpack the script from the file and execute the script as your regular user. Don't use sudo to execute it.
  • Russell
    Russell New Member Posts: 20
    Script works great thanks.

    Found out if I export a gpio in a bash script, I had to run 'udevadm settle' afterwards before using the exported values otherwise they wouldnt be readable yet.
  • WereCatf
    WereCatf New Member Posts: 201
    edited November 2017
    In bash-scripts, a simple sleep is enough:
    #Test if we have root-permissions and, if not, sleep for 100ms
    if [ $EUID -gt 0 ]; then sleep 0.1; fi
    
    This solution is cleaner in the sense that if you're running the script as root or via sudo, it won't unnecessarily spend any time sleeping in the first place. But yes, whatever works for you and happy to hear you got it going.