MuffinsaurusRex
Posts: 5
Joined: Wed Aug 03, 2016 2:22 am

PiScreen and GPIO CS's

Fri Aug 12, 2016 12:59 am

Currently I am trying to get the OzzMaker PiScreeN: 3.5" TFT to work while also using another SPI device on a Raspberry Pi Zero.

The PiScreen DT overlay https://github.com/notro/fbtft/blob/mas ... verlay.dts uses CS0 for the LCD and CS1 for the Touch Screen.

I have been following PhilE on this thread Optional interfaces (I2C, I2S, SPI) and Device Tree for using GPIO's as extra CS pins.

I have done the following:
  1. 1. Create spi-gpio-cs.dtb defining CS2 and CS3 and GPIO 20 and 21

    Code: Select all

    /dts-v1/;
    /plugin/;
    
    / {
       compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";
    
       fragment@0 {
          target = <&spi0>;
          frag0: __overlay__ {
             #address-cells = <1>;
             #size-cells = <0>;
             pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
             status = "okay";
             cs-gpios = <0>, <0>, <&gpio 20 1>, <&gpio 21 1>;
    
             spidev@2{
                compatible = "spidev";
                reg = <2>;   /* CE2 */
                #address-cells = <1>;
                #size-cells = <0>;
                spi-max-frequency = <500000>;
             };
    
             spidev@3{
                compatible = "spidev";
                reg = <3>;   /* CE3 */
                #address-cells = <1>;
                #size-cells = <0>;
                spi-max-frequency = <500000>;
             };
          };
       };
    
       fragment@1 {
          target = <&gpio>;
          __overlay__ {
             spi0_cs_pins: spi0_cs_pins {
                brcm,pins = <20 21>;
                brcm,function = <1>; /* out */
             };
          };
       };
    
       __overrides__ {
          cs2_pin = <&frag0>,"cs-gpios:12", <&spi0_cs_pins>,"brcm,pins:0";
          cs3_pin = <&frag0>,"cs-gpios:24", <&spi0_cs_pins>,"brcm,pins:4";
       };
    };
  • 2. Compile and move to /boot/overlays:

    Code: Select all

    dtc -@ -I dts -O dtb -o spi-gpio-cs.dtbo spi-gpio-cs-overlay.dts 
    sudo cp spi-gpio-cs.dtbo /boot/overlays
  • 3. Add spi-gpio-cs and piscreen to config.txt:

    Code: Select all

    dtoverlay=spi-gpio-cs
    dtoverlay=piscreen
  • 4. Reboot
When I reboot I see spidev0.2 and spidev 0.3 via ls /dev. however, the PiScreen does not work. It stays a blank-white.

PiScreen will work if only dtoverlay=piscreen is present.

Any help would be greatly appreciated.

MuffinsaurusRex
Posts: 5
Joined: Wed Aug 03, 2016 2:22 am

Re: PiScreen and GPIO CS's

Fri Aug 12, 2016 4:13 pm

If anyone comes across this thread, I was able to get this resolved thanks to PhilE on this thread

Working spi-gpio-cs.dtb

Return to “Troubleshooting”