2008-02-05 17:19:38 ADSP-SPIADC does not work for BF537 STAMP
Myrick Monroe (UNITED STATES)
Message: 50715 After two days of rebuilding kernals I am unable to see any SPI output. I used the example code provided in the documentation but nothing seems to work. I can open SPI but there is never any output for a simple write function. I have seen this problem before without uClinux when the GPIO SPI pins are not programed for SPI.
How do I use the new driver? Do I simply flash alpha uImage-SVN-bf537-stamp ? If this is true, do I still have to modify the board file in the kernal as explained in the documentation? Which version does the spidev documentation refer to?
QuoteReplyEditDelete
2008-02-06 02:52:37 Re: ADSP-SPIADC does not work for BF537 STAMP
murti iki (GERMANY)
Message: 50724 Hello Myrick,
If I understood it correctly ADSP-SPIADC is absolute now (it is even removed off the wiki). But ofcourse this doesn't explain your problem. I used the bfin_spi_adc.c driver as a module and after loading it to the kernel with insmod. I got spi output.
About the spidev documentation, I also have some doubts, if I understood it correctly, the 2007r1.1-RC3 doesn't contain the spidev driver.
Please see the post "bfin_spi_adc.c and copy_from_user()" There Michael gives some information about this documentation and drivers.
QuoteReplyEditDelete
2008-02-06 10:06:10 Re: ADSP-SPIADC does not work for BF537 STAMP
Myrick Monroe (UNITED STATES)
Message: 50763
Thank you for the reply. I didn't use your method of loading the module with insmod. I used menuconfig to select "ADSP SPI SUPPORT" and then followed the ADSP-SPIADC documentation exactly. Last week I could still access "How to use ADSP-SPIADC driver" documentation from here and I had no idea that it was obsolete. I just noticed today that the file has been removed.
I am not familiar with the process you described ( I'm a hardware engineer and not a Computer Science type) . Is it done from the uClinux prompt after simply downloading the compiled bfin_spi_adc.c to the target?
Thanks again for helping me
Best Regards,
Myrick Monroe
QuoteReplyEditDelete
2008-02-06 16:00:45 Re: ADSP-SPIADC does not work for BF537 STAMP
murti iki (GERMANY)
Message: 50772 Hello,
I am also quite new in the linux arena but as far as I understand, you can either put these drivers (which also count as modules) either into the kernel permanently or at a later time as LKMs (loadable kernel module). Just get the bfin_spi_adc.c from the drivers/char to an empty folder and then build it with make
Below code is also in the wiki
ifneq ($(KERNELRELEASE),)
##################################################
# PASS 2 do this when called by the kernel make process
##################################################
# produce a module from a single C file
obj-m += spi_driver.o
# or produce a module from multiple C files
# obj-$(CONFIG_MYMOD) += mymod.o
# mymod-objs := mymod_main.o mymod_lib.o mymod_io.o
else
##################################################
# PASS 1 do this when called from the user make
##################################################
KDIR := /home/ti6rt/work/uClinux-dist-spi/linux-2.6.x
#change above line as necessary
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
install:
$(MAKE) -C $(KDIR) INSTALL_MOD_PATH=$(IDIR) \
SUBDIRS=$(PWD) modules_install
endif
after "make" you will end up with "spi_driver.ko" you can transfer this to the stamp board (that has already a linux running on it). Once you transfer it just type
insmod spi_driver.ko
to see if you everything went okey type
lsmod
now you can just call a userspace application program and test it,
The wiki document has all the information about it. Below is what I use
#include <stdio.h>
#include <fcntl.h>
#define SAMPLES 10
int main ()
{
int fd,wr;
int i = 0;
unsigned short data_write[SAMPLES]={14,14,14,14,1,1,10,1,1,1};
unsigned short data_read[SAMPLES];
fd = open ("/dev/spi", O_RDWR);
if (fd < 0)
{
printf("Error opening dev/spi \n");
}
while(i < 3000){
wr = write(fd, data_write, SAMPLES);
// read(fd, data_read, SAMPLES);
// zero verirse tamamdir.
if(wr < 0)
{
printf("Error writing to device dev/spi \n");
break;
}
i++;
}
close(fd);
return 0;
As I said, I am also new in this linux, uclinux stuff. So don't take anything I said for granted Yet this works in my case.
Ohh forgat to say, everything except the chip_select pin works. Probably I made something wrong in the in the resources section. I will look into it again and try to find the error.