notro / fbtft

Linux Framebuffer drivers for small TFT LCD display modules. Development has moved to https://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/tree/drivers/staging/fbtft?h=staging-testing
1.85k stars 494 forks source link

trying to get boot-console working on Gumstix Overo #76

Closed erazor83 closed 10 years ago

erazor83 commented 10 years ago

Hi there,

I just hope thats the right place to ask.

Currently I'm trying to get a boot-console working with fbtft and fbcon.

Compiling fbtft as a module, loading it after boot and playing with fbv works nicely. However, I tried to compile everything into the kernel and am not getting an fb-device anymore.

My syslog looks like this:

[    0.228363] fbtft_device:  SPI devices registered:
[    0.228393] fbtft_device:  'fb' Platform devices registered:
[    0.228607] fbtft_device:  GPIOS used by 'sainsmart18':
[    0.228607] fbtft_device:    'reset' = GPIO17
[    0.228637] fbtft_device:    'dc' = GPIO19
...
[    0.410461] vads7846: 3300 mV 
...
[    1.776519] omap2_mcspi omap2_mcspi.1: can't create new device for fb_st7735r
[    1.776519] omap2_mcspi omap2_mcspi.1: can't create new device for fb_st7735r
[    9.430694] ads7846 spi1.0: touchscreen, irq 210
[    9.438934] ads7846 spi1.0: no device detected, test read result was 0x00000000

I've given module-parameters via kernel command-line:

console=ttyO2,115200 mpurate=500 vram=12M root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait i2c_bus=3,100 fbtft_device.name=sainsmart18 fbtft_device.busnum=1 fbtft_device.gpios=reset:17,dc:19

So, since mcspi.1 complains it seems like fbtft_device got the parameters correctly.

I'm a bit stuck on how to continue and debug this issue, maybe the SPI is not ready and the probing of fbtft_device does not work?

Thanks for any hints.

notro commented 10 years ago

Since you don't specify which chipselect to use for fbtft_device, the default will be 0. In other words, with busnum=1 it will be spi1.0. But this is what ads7846 is using... Are they trying to use the same chipselect?

erazor83 commented 10 years ago

I removed the ads7846 which was compiled as a module but still: [ 1.776519] omap2_mcspi omap2_mcspi.1: can't create new device for fb_st7735r

I started to add some lines to the board file which now looks like this

...
    {
        .modalias = "fb_st7735r",
        .max_speed_hz = 32000000,
        .bus_num = 1,
        .chip_select = 0,
        .mode = SPI_MODE_0,
        .platform_data = &(struct fbtft_platform_data) {
            .gpios = (const struct fbtft_gpio []) {
                    { "reset", 17 },
                    { "dc", 19 },
             },
        }
    },
#endif
    {
        .modalias       = "spidev",
        .bus_num        = 1,
        .chip_select        = 0,
        .max_speed_hz       = 48000000,
        .mode           = SPI_MODE_0,
    },
#endif
...

But except the display went black and I got a device listed in /proc/fb nothing else happens.

It's probably some missing parameters or wrong module name.

Also the driver don't know about the display type. How can I add this to the board file?

notro commented 10 years ago

I removed the ads7846 which was compiled as a module but still

I'm talking devices here, not modules/drivers. Removing the module wouldn't help on a device conflict.

The board file looks fine to me. If the display goes black, it has been initialized. Meaning the driver has been probed. You should have a line in your kernel log when the driver is loaded, like this (this is for a different display):

graphics fb1: fb_ili9341 frame buffer, 320x240, 150 KiB video memory, 16 KiB buffer memory, fps=20, spi0.0 at 32 MHz

And you should get /dev/fbX

Do you have more framebuffers in your system (/dev/fb0, /dev/fb1) ?

erazor83 commented 10 years ago

no other framebuffers

[    0.227203] fbtft_device:  SPI devices registered:
[    0.227233] fbtft_device:  'fb' Platform devices registered:
[    0.227447] fbtft_device:  GPIOS used by 'sainsmart18':
[    0.227447] fbtft_device:    'reset' = GPIO17
[    0.227478] fbtft_device:    'dc' = GPIO19
[    0.281860] bio: create slab  at 0
[    1.734985] fb_st7735r spi1.0: no default functions for regwidth=8 and buswidth=0
[    2.839538] Console: switching to colour frame buffer device 16x20
[    2.846984] graphics fb0: fb_st7735r frame buffer, 128x160, 40 KiB video memory, 4 KiB buffer memory, fps=21, spi1.0 at 32 MHz
[    2.859436] omap2_mcspi omap2_mcspi.1: chipselect 0 already in use
[    2.866210] omap-dma-engine omap-dma-engine: freeing channel for 36
[    2.872955] omap-dma-engine omap-dma-engine: freeing channel for 35
[    2.880096] omap2_mcspi omap2_mcspi.1: can't create new device for spidev
[    2.887451] omap-dma-engine omap-dma-engine: allocating channel for 38
[    2.894409] omap-dma-engine omap-dma-engine: allocating channel for 37
[    2.906616] omap2_mcspi omap2_mcspi.1: chipselect 0 already in use
[    2.913330] omap2_mcspi omap2_mcspi.1: can't create new device for fb_st7735r
[    2.922637] Unable to handle kernel NULL pointer dereference at virtual address 00000000

So how does he know about sainsmart18? Do I still have to use the command line args for the kernel?

notro commented 10 years ago

You need to specify buswidth as well in the board file. That's why you get that NULL pointer exception. From fbtft_device:

        .name = "sainsmart18",
        .spi = &(struct spi_board_info) {
            .modalias = "fb_st7735r",
            .max_speed_hz = 32000000,
            .mode = SPI_MODE_0,
            .platform_data = &(struct fbtft_platform_data) {
                .display = {
                    .buswidth = 8,
                },
                .gpios = (const struct fbtft_gpio []) {
                    { "reset", 25 },
                    { "dc", 24 },
                    {},
                },
            }
        }

You can drop the fbtft_device parameters from the kernel command line when you specify the SPI device in the board file. That's why you get some of the errors at least. If fbtft_device doesn't find a 'name' argument it just does nothing.

erazor83 commented 10 years ago

is this part of a platform_device ? I'm wondering because of .spi and .name. I only added some lines to the spi part of the board:

static struct spi_board_info overo_spi_board_info[] __initdata = {
#if !defined(CONFIG_TOUCHSCREEN_ADS7846) && \
    !defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) && \
    (defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE))
#if defined(CONFIG_FB_TFT_ST7735R)
    {
        .modalias = "fb_st7735r",
        .max_speed_hz = 32000000,
        .bus_num = 1,
        .chip_select = 0,
        .mode = SPI_MODE_0,
        .platform_data = &(struct fbtft_platform_data) {
            .display = {
                    .buswidth = 8,
            },
            .gpios = (const struct fbtft_gpio []) {
                    { "reset", 17 },
                    { "dc", 19 },
                    {},
             },
        }
    },
#endif
    {
        .modalias       = "spidev",
        .bus_num        = 1,
        .chip_select        = 0,
        .max_speed_hz       = 48000000,
        .mode           = SPI_MODE_0,
    },
#endif
...
notro commented 10 years ago

is this part of a platform_device

No. When the SPI master is registered, all the spi_board_info's that has been added, will be registered as spi_device's on that SPI master. It happens here: http://lxr.free-electrons.com/source/drivers/spi/spi.c#L1383

erazor83 commented 10 years ago

Ok, removed the kernel params and added .buswidth. Still kernel errors:

Overo ~ # dmesg | grep fb
[    2.806762] graphics fb0: fb_st7735r frame buffer, 128x160, 40 KiB video memory, 4 KiB buffer memory, fps=21, spi1.0 at 32 MHz
Overo ~ # dmesg | grep spi
[    2.806762] graphics fb0: fb_st7735r frame buffer, 128x160, 40 KiB video memory, 4 KiB buffer memory, fps=21, spi1.0 at 32 MHz
[    2.819244] omap2_mcspi omap2_mcspi.1: chipselect 0 already in use
[    2.839477] omap2_mcspi omap2_mcspi.1: can't create new device for spidev
[    2.901580] PC is at omap2_mcspi_transfer_one_message+0x570/0xc68
[    2.908020] LR is at omap2_mcspi_transfer_one_message+0x3d8/0xc68
[    2.959869] Process spi1 (pid: 554, stack limit = 0xdfadc2f8)
[    3.048645] [] (omap2_mcspi_transfer_one_message+0x570/0xc68) from [] (spi_pump_messages+0x118/0x13c)
[    3.060302] [] (spi_pump_messages+0x118/0x13c) from [] (kthread_worker_fn+0xd8/0x130)

I posted my board-overo.c here: http://pastebin.com/s3Vz9HbD

notro commented 10 years ago

[ 2.819244] omap2_mcspi omap2_mcspi.1: chipselect 0 already in use [ 2.839477] omap2_mcspi omap2_mcspi.1: can't create new device for spidev

Because you have this

        {
                .modalias               = "spidev",
                .bus_num                = 1,
                .chip_select            = 0,
                .max_speed_hz           = 48000000,
                .mode                   = SPI_MODE_0,
        },

The same bus_num and chip_select as fb_st7735r

Do you have console output now?

erazor83 commented 10 years ago

Works perfectly thanks a lot notro!

notro commented 10 years ago

You're welcome. Please close the issue if your done.