• SoftwareC/C++Kernel
  • driving an ILI9341 display using SPI on the Bela Mini and using the GPU to draw?

hi I am trying to build a groovebox and sequencer and was wanting to use an SPI LCD as the main form of display, I was wondering if anyone knew how to set this up on the bela mini and also if it would be possible to use the GPU to render the display for the screen?

We never used the PowerVR SGX530 GPU, and in fact until very recently it was impossible to use at all. I think that recently TI has released an OpenGL interface for it, see here. While it may be possible to do what you are asking for, this is mostly uncharted territory here, and I would recommend you ask on this dedicated beagleboard forum: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!forum/beagleboard .

On BelaMini there is one full SPI bus available (spi1), so connecting a display is possible (see e.g.: here)

so how would I go about sending the data to the Display Module? I've been looking for a few days and haven't found anything about using SPI with the Bela (though Im not 100% what to be looking for, so I've probably missed something)

seeing as the GPU isn't that well supported would drawing it via software be a better option?

    AliceBlackMage seeing as the GPU isn't that well supported would drawing it via software be a better option?

    yes

    AliceBlackMage haven't found anything about using SPI with the Bela

    SPI on Bela has nothing special to it. It uses the spidev Linux driver. If your display comes with a library for Linux, that should just work. Do you have a Linux library for it?

    As far as pinout goes, it is available here. To enable the P2.25/27/29/31 pins for spi1, run:

    config-pin P2.25 spi
    config-pin P2.27 spi
    config-pin P2.29 spi_sclk
    config-pin P2.31 spi_cs

    apparently i can use FBTFT to drive this screen

    also is SPIDEV2.1 the hardware SPI bus I'd want to connect to?

    Yes. On BelaMini, the pins I outlined above are for spidev 2.1, aka McSPI1, channel 1 (I know, it's confusing).

    Note: the answer to this comes partially from this table which shows that P2.31 is the chip select for channel 1 (hence the .1). The reason why it's 2. (while the hardware is spi1) is that Linux seems to enumerate spidev devices starting from 1 instead of 0.

    4 days later

    hi Im having a small issue getting the FBTFT driver to work with the Bela? I have managed to successfully install it, but I cannot get it to talk to the SPI bus properly and the tutorial for the beaglebone is somewhat confusing as the Bela seems to lack some of the things mentioned in it
    https://github.com/notro/fbtft/wiki/BeagleBone-Black

    can you please illustrate the very steps you have undertaken so far and where you stopped?

    so I have connected up the display to the SPI, power and GPIO pins required

    I then connected the bela to the internet and downloaded the drivers from the site I linked above

    I then installed them as the tutorial instructed, I hit a problem with the device tree overlay part though, as it wouldn't build the file they supplied separately to the driver

      I am able to start the driver using Modprobe, but the output from dmesg just shows SPI bus errors

      AliceBlackMage d, I hit a problem with the device tree overlay part though, as it wouldn't build the file they supplied separately to the driver

      I copied the file NEOSEC-TINYLCD35-00A0.dts that they provide a download link for to the board, and successfully compiled it following the instructions provided: dtc -O dtb -o NEOSEC-TINYLCD35-00A0.dtbo -b 0 -@ NEOSEC-TINYLCD35-00A0.dts. What errors did you get?
      The output I get is:

      root@bela:~# dtc -O dtb -o NEOSEC-TINYLCD35-00A0.dtbo -b 0 -@ NEOSEC-TINYLCD35-00A0.dts
      NEOSEC-TINYLCD35-00A0.dtbo: Warning (unit_address_vs_reg): Node /fragment@0 has a unit name, but no reg property
      NEOSEC-TINYLCD35-00A0.dtbo: Warning (unit_address_vs_reg): Node /fragment@1 has a unit name, but no reg property
      NEOSEC-TINYLCD35-00A0.dtbo: Warning (unit_address_vs_reg): Node /fragment@2 has a unit name, but no reg property
      NEOSEC-TINYLCD35-00A0.dtbo: Warning (unit_address_vs_reg): Node /fragment@3 has a unit name, but no reg property
      NEOSEC-TINYLCD35-00A0.dtbo: Warning (unit_address_vs_reg): Node /fragment@4 has a unit name, but no reg property

      these are just warnings but the output file is actually generated. From this point on, the instructions to enable the overlay are different on BelaMini with respect to the BeagleBone Black.

      You should still run the line

      cp NEOSEC-TINYLCD35-00A0.dtbo /lib/firmware/

      to install the overlay once installed.
      On BelaMini (or the PocketBeagle), there is no capemgr , so the overlays can only be loaded at boot. following the instructions here.
      This basically means editing the file uEnv.txt in the FAT32 partition present on the SD card and add a line such as

      uboot_overlay_addr3=/lib/firmware/ NEOSEC-TINYLCD35-00A0.dtbo 

      (make sure you safely remove the disk after saving the file. If this file is corrupted, the board will not boot).

      Then reboot the board and the overlay should now attempt to load. You should be able to see in dmesg whether that actually is successful (it doesn't attempt to load for me because I don't have the driver installed). Even if it loads, this is unlikely to work yet, as the pins will have changed between the BeagleBone Black (which the tutorial refers to) and the PocketBeagle.

      Next step is finding what pins on the PB are suitable for using this display. Here is a simplified list of the pins available and those used by Bela. We want to pick some pins that are not used by the Bela core (highlighted by a green square and red overlay), and also possibly not touch the Bela digital pins (Dx in the diagram, with a light blue overlay).

      SPI: You will still want to use the spi1 bus, because spi0 is used by Bela. This is the one already in use by the device tree overlay, so there is no need to change it there. Pins to be used:

      MOSI: P2.25
      MISO: P2.27
      CLK: P2.29
      CS: P2.31

      lcd ctrl pins: these seem to be regular GPIOs. P2.05(gpio0_30) and P2.07(gpio0_31) are available, so we can pick those. We need to specify those in the device tree. Replace the lines

      				reset-gpios = <&gpio2 16 0>;
      				dc-gpios = <&gpio2 28 0>;

      with

      				reset-gpios = <&gpio0 30 0>;
      				dc-gpios = <&gpio0 31 0>;

      I am fairly confident this is correct, however there is a note here that says Note the difference in gpio index: gpio1_16 => <&gpio2 16 0>. I don't feel like trusting their advice just now, because they are talking about a kernel/dtb that is at least four year old. A quick inspection of the base device tree suggests that we should use gpio0, but I may be misinterpreting it. If this fails, try to replace gpio0 with gpio1 in the snippet above.

      backlight: it seems that this needs a PWM pin. PWM2.B is available according to the diagram on P2.3 . We need to tell the driver to use this pin in the device-tree overlay. The generic documentation suggests that the specific documentation should contain the details of the meaning of the pwms= field, but this is not actually true. Anyhow, I would guess that the right way would be to replace

      pwms = <&ehrpwm1 0 500000 0>;

      (which was for ehrpwm1A) with

      pwms = <&ehrpwm2 1 500000 0>;

      but this probably needs to be checked against the driver source.

      Note that the above changes only tell the driver which pins to use, but does not actually set the pinmuxer setting for them. Because of how the PocketBeagle works (cape_universal and config-pin, as explained here, the pinmuxer settings are easier to be set at runtime using config-pin (at least for prototyping). So, I'd suggest that for now you shall comment out the lines starting with pinctrl-0 from the device tree and set the pinmuxer settings after boot using config-pin (see below).
      Once you apply the modifications above to the NEOSEC-TINYLCD35-00A0.dts file, re-run the dtc and cp lines to compile and install it.

      Last, there is one extra gpio needed for the touchpanel. We can use P2.19 (gpio0[27]). According to the guide you are following, in our kernel (4.4) there should be device tree support for the driver for the ADS7846 touch controller (note: I have no idea what this touch controller is). Unless you find a pre-made device tree overlay around that targets your use case, you may well use the modprobe line they suggest, amended to reflect the gpio number you are using (use gpio_pendown=0).

      To set the pinmuxer at runtime using config-pin, you will have to run these:

      # for the SPI:
      config-pin P2.25 spi
      config-pin P2.27 spi
      config-pin P2.29 spi_sclk
      config-pin P2.31 spi_cs
      #for the lcd control pins
      config-pin P2.05 gpio
      config-pin P2.07 gpio
      # for the backlight pwm
      config-pin P2.03 pwm
      # for the ADS7846 (whatever it is)
      config-pin P2.19 gpio

      I don't have a display like your so I can only do so much from my side, but hopefully this helps you.