driving a small TFT display via SPI on VoCore2

docbee
 
Posts: 34
Joined: Wed Nov 02, 2016 9:15 am

driving a small TFT display via SPI on VoCore2

Thu Feb 17, 2022 8:38 pm

I have a small ST7735 based TFT display I want to drive via SPI from the VoCore2. The display is connect to VoCore2 pins tagged as SPI. The kernel modules "spi_bitbang", "spi_gpio" and "spidev" are loaded, I am using OPENWRT 19.07.

My expectation was that a spi device like "/dev/spi0.0" might show up but nothing there. How can I make contact to the display?

VOCORE2.dts looks like this:
Code: Select all
/dts-v1/;

#include "VOCORE2.dtsi"

#include <dt-bindings/gpio/gpio.h>

/ {
        compatible = "vocore,vocore2", "mediatek,mt7628an-soc";
        model = "MBPRO2";

        aliases {
                led-boot = &led_status;
                led-failsafe = &led_status;
                led-running = &led_status;
                led-upgrade = &led_status;
        };

        leds {
                compatible = "gpio-leds";

                led_status: status {
                        label = "vocore2:fuchsia:status";
                        gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
                };
        };
};

&spi0 {
        status = "okay";

        m25p80@0 {
                compatible = "jedec,spi-nor";
                reg = <0>;
                spi-max-frequency = <10000000>;

                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
                        #size-cells = <1>;

                        partition@0 {
                                label = "u-boot";
                                reg = <0x0 0x30000>;
                                read-only;
                        };

                        partition@30000 {
                                label = "u-boot-env";
                                reg = <0x30000 0x10000>;
                                read-only;
                        };

                        factory: partition@40000 {
                                label = "factory";
                                reg = <0x40000 0x10000>;
                                read-only;
                        };

                        partition@50000 {
                                compatible = "denx,uimage";
                                label = "firmware";
                                reg = <0x50000 0xfb0000>;
                        };
                };
        };
};

&sdhci {
       status = "okay";
       mediatek,cd-poll;
};

Vonger
 
Posts: 896
Joined: Sun Oct 19, 2014 6:00 am

Re: driving a small TFT display via SPI on VoCore2

Tue Mar 01, 2022 4:01 pm


docbee
 
Posts: 34
Joined: Wed Nov 02, 2016 9:15 am

Re: driving a small TFT display via SPI on VoCore2

Fri Apr 08, 2022 11:56 pm

Your so called "references" do not address my question. I post dts files and ask why the device is not showing up and all I get is a link to some posts with videos of a somehow connected screen. I do not question that SPI might work somehow. But when you can't even provide a valid dts file that gives the foundation to work on, it is very hard to do anything useful with vocore2 apart from replicating your demos with precompiled kernels which is not interesting for someone who wants to build own systems on top of your vocore2.

Can you please start answering posts in a meaningful way and invest more than 20 seconds on that? This is really annoying and hardly a base to do any serious business.

Vonger
 
Posts: 896
Joined: Sun Oct 19, 2014 6:00 am

Re: driving a small TFT display via SPI on VoCore2

Wed Apr 20, 2022 1:20 am

docbee wrote:Your so called "references" do not address my question. I post dts files and ask why the device is not showing up and all I get is a link to some posts with videos of a somehow connected screen. I do not question that SPI might work somehow. But when you can't even provide a valid dts file that gives the foundation to work on, it is very hard to do anything useful with vocore2 apart from replicating your demos with precompiled kernels which is not interesting for someone who wants to build own systems on top of your vocore2.

Can you please start answering posts in a meaningful way and invest more than 20 seconds on that? This is really annoying and hardly a base to do any serious business.

Just read all the blogs, it has source code in it.
You need to add spi-dev to the spi device tree. I think this is linux question, but not vocore question. About spi-dev http://vonger.cn/?p=14881

docbee
 
Posts: 34
Joined: Wed Nov 02, 2016 9:15 am

Re: driving a small TFT display via SPI on VoCore2

Thu Apr 21, 2022 10:15 am

The link to the blog (http://vonger.cn/?p=14881) did help me. Thank you!
I was able to have the "/dev/spidev0.1" showing up after boot.
I also added the "spidev_test" tool to give the spi a first try.

Code: Select all
root@OpenWrt:/# spidev_test -s 100000 -D /dev/spidev0.1 -p "ww"
spi mode: 0x0
bits per word: 8
max speed: 100000 Hz (100 KHz)
can't send spi message: Invalid argument
Aborted


Looking at the source this message results from a failed ioctl call to the device
Code: Select all
ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
   if (ret < 1)
      pabort("can't send spi message");


Any idea what goes wrong? The SPI pins of the VoCore2 are left unconnected.

docbee
 
Posts: 34
Joined: Wed Nov 02, 2016 9:15 am

Re: driving a small TFT display via SPI on VoCore2

Thu Apr 21, 2022 8:09 pm

When I try to apply the recommended half-duplex back patch to send more than 16 bytes in a message (Link: http://vonger.cn/?p=14881) then I see that the code does not match my sources

Recommended patch to "spi-mt7621.c":
Code: Select all
static int mt7621_spi_transfer_one_message(struct spi_master *master,
                                           struct spi_message *m)
{
        struct spi_device *spi = m->spi;
/*
#ifdef CONFIG_SOC_MT7620
      int cs = spi->chip_select;

      if (cs)
              return mt7621_spi_transfer_full_duplex(master, m);
#endif
*/
        return mt7621_spi_transfer_half_duplex(master, m);
}


But my "spi-mt7621.c" looks like this:
Code: Select all
// SPDX-License-Identifier: GPL-2.0
//
// spi-mt7621.c -- MediaTek MT7621 SPI controller driver
//
// Copyright (C) 2011 Sergiy <piratfm@gmail.com>
// Copyright (C) 2011-2013 Gabor Juhos <juhosg@openwrt.org>
// Copyright (C) 2014-2015 Felix Fietkau <nbd@nbd.name>
//
// Some parts are based on spi-orion.c:
//   Author: Shadi Ammouri <shadi@marvell.com>
//   Copyright (C) 2007-2008 Marvell Ltd.


...


static int mt7621_spi_transfer_one_message(struct spi_controller *master,
                                           struct spi_message *m)
{
        struct mt7621_spi *rs = spi_controller_get_devdata(master);
        struct spi_device *spi = m->spi;
        unsigned int speed = spi->max_speed_hz;
        struct spi_transfer *t = NULL;
        int status = 0;

        mt7621_spi_wait_till_ready(rs);

        list_for_each_entry(t, &m->transfers, transfer_list)
                if (t->speed_hz < speed)
                        speed = t->speed_hz;

        if (mt7621_spi_prepare(spi, speed)) {
                status = -EIO;
                goto msg_done;
        }

        /* Assert CS */
        mt7621_spi_set_cs(spi, 1);

        m->actual_length = 0;
        list_for_each_entry(t, &m->transfers, transfer_list) {
                if ((t->rx_buf) && (t->tx_buf)) {
                        /*
                         * This controller will shift some extra data out
                         * of spi_opcode if (mosi_bit_cnt > 0) &&
                         * (cmd_bit_cnt == 0). So the claimed full-duplex
                         * support is broken since we have no way to read
                         * the MISO value during that bit.
                         */
                        status = -EIO;
                        goto msg_done;
                } else if (t->rx_buf) {
                        mt7621_spi_read_half_duplex(rs, t->len, t->rx_buf);
                } else if (t->tx_buf) {
                        mt7621_spi_write_half_duplex(rs, t->len, t->tx_buf);
                }
                m->actual_length += t->len;
        }

        /* Flush data and deassert CS */
        mt7621_spi_flush(rs);
        mt7621_spi_set_cs(spi, 0);

msg_done:
        m->status = status;
        spi_finalize_current_message(master);

        return 0;
}


Am I using the wrong file version? Did I miss a 19.07 patch for SPI?

docbee
 
Posts: 34
Joined: Wed Nov 02, 2016 9:15 am

Re: driving a small TFT display via SPI on VoCore2

Mon Apr 25, 2022 1:32 pm

I dropped the idea of of using HW SPI support on VoCore2 and succeeded to make use of "spi-gpio-custom" on free GPIOs. That works fine. Now I have to deal with the display drivers, but that is out of VoCore2 support scope and my personal challenge.

Return to VoCore2/Lite/Ultimate

Who is online

Users browsing this forum: No registered users and 43 guests