08-03-2017, 08:02 AM (This post was last modified: 08-03-2017, 09:08 AM by Tinker Board.
Edit Reason: insert photos into post
)
Hello,
I´m trying to use the SPI bus to communicate with some E-ink screen via SPI.
I got some communication with the screen but the communication is not accurate. In the Screen data sheet the spi clock behavior should be:
28872727-b98bc80c-778a-11e7-8a01-fa589092a183.png (10.53 KB)
But when I use a test program to check the SPI bus:
28872711-ab366438-778a-11e7-8b28-89eb8d9tf13602.jpg (289.57 KB)
Is there a way to manage the SPI clock to do 8 bits pauses?
int main(int argc, char **argv)
{
int i,fd;
char wr_buf[]={0xff,0x00,0x1f,0x0f};
char rd_buf[10];;
if (argc<2) {
printf("Usage:\n%s [device]\n", argv[0]);
exit(1);
}
fd = open(argv[1], O_RDWR);
if (fd<=0) {
printf("%s: Device %s not found\n", argv[0], argv[1]);
exit(1);
}
if (write(fd, wr_buf, ARRAY_SIZE(wr_buf)) != ARRAY_SIZE(wr_buf))
perror("Write Error");
if (read(fd, rd_buf, ARRAY_SIZE(rd_buf)) != ARRAY_SIZE(rd_buf))
perror("Read Error");
else
for (i=0;i<ARRAY_SIZE(rd_buf);i++) {
printf("0x%02X ", rd_buf[i]);
if (i%2)
printf("\n");
}
close(fd);
return 0;
}
For synchronous transfer, you can have a look at the example from Documentation/spi. It is slightly changed, as the at91-spi driver does not support to change speed or bits per word via the ioctl-transfer interface. You can cross-compile it
with your-cross-gcc -o spidev-test -I/path-to-cross-kernel-include spidev-test.c. Of course you can also use your compiler on the target board (Make sure you have the package linux-libc-dev installed). Later you can run it like this: spidev-test -D /dev/spidev1.0.
/*
* SPI testing utility (using spidev driver)
*
* Copyright (c) 2007 MontaVista Software, Inc.
* Copyright (c) 2007 Anton Vorontsov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License.
*
* Cross-compile with cross-gcc -I/path/to/cross-kernel/include
*
*/
I have reproduced this issue, and there are two informally solutions.
First, you can send command/data one byte per tr(spi_ioc_transfer) in your test program.
It's easy that call transfer() and put only one byte in .tx_buf.
BTW, if you use this solution, please remember to mark below codes in transfer():
Quote: if (ret == 1)
pabort("can't send spi message");
Second, you can add the delay time manually into the driver of SPI controller after transferring a word.
Please reference to attached patch, and enter the kernel folder of codebase to type:
Quote: git amTHE_PATCH_NAME
I have validated this solution with WaveShare 3.5" & 4" touch screen, they can work well.
Please have a try and let me know if any question~
Thank you.
PS. BTW, could you please share the E-ink product number?
Ok, I already discover how to compiler the kernel.
During the kernel compilation:
sudo make rockchip_linux_defconfig
sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
I get an error:
/tinkercustom/debian_kernel/drivers/net/ethernet/stmicro/stmmac/eth_mac_tinker.c:39: Nicht definierter Verweis auf `at24_read_eeprom'
Thanks!
The problem is that there is a DMA error and I have to disable the DMA on the SPI driver according to https://github.com/rockchip-linux/kernel/issues/19.
I already solve and the Papirus E-Ink screen is working with the TinkerBoard.
(08-18-2017, 09:51 AM)alr2000 Wrote: Thanks!
The problem is that there is a DMA error and I have to disable the DMA on the SPI driver according to https://github.com/rockchip-linux/kernel/issues/19.
I already solve and the Papirus E-Ink screen is working with the TinkerBoard.
Hi,
Did you also test the SPI clock with your test program after fixing the issue?
Because our codebase (miniarm) already merged the fixing commit before I verified this issue.
And I have checked the DMA settings, it should not be enabled.
I am surprising at the solution which is to disable DMA.
Could you please share the modified code? I would like to check again.