Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spiTransfer() only transmits 16 bytes at maximum #3

Open
gamer-cndg opened this issue Oct 15, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@gamer-cndg
Copy link

commented Oct 15, 2017

I'm currently working on a SPI display driver and I have hit a roadblock with your SPI implementation. In my case, I'd like to transmit my whole framebuffer (176*220*2 bytes) at once.

However, once I go over 16 bytes of length in the spiTransfer() function, the function just returns an error.

[+] Trying to write length 16.
onion-spi:: Trasferring 0xff, 16 bytes
   Received: 0x00, ioctl status: 16
[+] Write 16 bytes okay
[+] Trying to write length 17.
onion-spi:: Trasferring 0xff, 17 bytes
ERROR: SPI transfer failed

Test code:

	//test max size
	int err = EXIT_SUCCESS;
	int len = 1;
        static uint8_t dummyRXBuf[176*220*2];
	while(err == EXIT_SUCCESS) {
		printf("[+] Trying to write length %d.\n", len);
		uint8_t* testBuf = malloc(len);
		memset(testBuf, 0xff, len);
		err = spiTransfer(&params, testBuf, dummyRXBuf, len);
		if(err == EXIT_SUCCESS) {
			printf("[+] Write %d bytes okay\n", len);
			len++;
		}
		free(testBuf);
	}

SPI params initialization:

	spiParamInit(&params);
	params.mosiGpio = initParams->mosi;
	params.sckGpio = initParams->sclk;
	params.csGpio = initParams->cs;
	params.speedInHz = initParams->speedInHz; //20 mhz
	params.modeBits = SPI_MODE_0; //only SPIMODE_0, no dual TX or RX as "default"..
	params.busNum = 1; //this comes from my local machine. no idea if it works elsewhere.. (ls /dev/spi*)
	params.deviceId = 32766;

All I can see in (https://github.com/OnionIoT/spi-gpio-driver/blob/master/src/onion-spi.c#L182) is a call to ioctl, so I think the fault must be with the kernel module.

Can you please correct this error? With your implementation, transmitting in blocks of 16 bytes with a bit-banged driver yields a display FPS of about 2.5 FPS. Also, what's the maximum speed with this implementation? Is this implementation backed by DMA?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.