LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-19-2012, 11:28 AM   #1
dennisdd
Member
 
Registered: Oct 2011
Posts: 37

Rep: Reputation: Disabled
How to debug SPI driver on ubuntu?


Hi,

I am following this on how to develop SPI driver:
http://www.jumpnowtek.com/index.php?...d=57&Itemid=62

I am running a PC ubuntu to develop my SPI driver, I am thinking is it possible to load my SPI on my PC's ubuntu?

my idea is to develop a generic SPI driver then only port to my devkit8000. So, I am thinking to "insmod" the driver to my ubuntu.

if possible, how do I set the following SPI device information for my pc?:

static struct spi_board_info spidev_board _info {
.modalias = "spidev",
.max_speed_hz = 48000000,
.bus_num = 1,
.chips_select = 0,
.mode = SPI_MODE_0,
};

thanks
 
Old 02-19-2012, 01:35 PM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 207Reputation: 207Reputation: 207
Look at the git project associated with that tutorial:

https://github.com/scottellis/spike/blob/master/spike.c

The approach there should be sufficient to load a kernel module into a PC's kernel, however, that's of limited utility unless you have access to the SPI hardware itself.
 
Old 02-19-2012, 09:36 PM   #3
dennisdd
Member
 
Registered: Oct 2011
Posts: 37

Original Poster
Rep: Reputation: Disabled
jhwilliams,

I did tried that, when I insmod it,

insmod: error inserting 'spike.ko': -1 Operation not permitted
 
Old 02-20-2012, 03:13 AM   #4
dennisdd
Member
 
Registered: Oct 2011
Posts: 37

Original Poster
Rep: Reputation: Disabled
I think my question to ask is this, do we need to following?

1. spi_busnum_to_master()
2. spi_alloc_device()
3. spi_device->chip_select = SPI_BUS_CS1;
4. bus_find_device_by_name();

I we do not boot this dynamically then there is no need?
inside the overo-source.txt
Code:
MACHINE=overo

# export an alternative OETMP before sourcing this file if you
# don't want the default
if [[ -z "${OETMP}" ]]; then
	OETMP=${OVEROTOP}/tmp
fi

SYSROOTSDIR=${OETMP}/sysroots
STAGEDIR=${SYSROOTSDIR}/`uname -m`-linux/usr

export KERNELDIR=${SYSROOTSDIR}/${MACHINE}-angstrom-linux-gnueabi/kernel

PATH=${PATH}:${STAGEDIR}/bin:${STAGEDIR}/armv7a/bin

unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE

export ARCH="arm"
export CROSS_COMPILE="arm-angstrom-linux-gnueabi-"
export CC="arm-angstrom-linux-gnueabi-gcc"
export LD="arm-angstrom-linux-gnueabi-ld"
export STRIP="arm-angstrom-linux-gnueabi-strip"
From the site, is the author running on pc linux then compile with angstrom then insmod it on the pc linux(which i assume not angstrom)?
How do I configure my make file to point to my android kernel?
 
Old 02-20-2012, 04:03 AM   #5
dennisdd
Member
 
Registered: Oct 2011
Posts: 37

Original Poster
Rep: Reputation: Disabled
This is what I am getting from my ubuntu PC terminal:

xxx@xxx-laptop:~/spike$ source overo-source-me.txt
xxx@xxx-laptop:~/spike$ make
make -C /tmp/sysroots/overo-angstrom-linux-gnueabi/kernel M=/home/xxx/spike modules
make: *** /tmp/sysroots/overo-angstrom-linux-gnueabi/kernel: No such file or directory. Stop.
make: *** [default] Error 2
xxx@xxx-laptop:~/spike$ sudo -s
[sudo] password for xxx:
root@xxx-laptop:~/spike# make
Makefile:10: *** "KERNELDIR is undefined!". Stop.
root@xxx-laptop:~/spike# make
Makefile:10: *** "KERNELDIR is undefined!". Stop.
root@xxx-laptop:~/spike# make
Makefile:10: *** "KERNELDIR is undefined!". Stop.
root@xxx-laptop:~/spike#
 
Old 02-20-2012, 08:50 AM   #6
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 207Reputation: 207Reputation: 207
Hi Dennis,

You should set KERNELDIR to wherever your kernel source is. Where is that? I guess it's not here, which is why you're seeing the error:

Quote:
make: *** /tmp/sysroots/overo-angstrom-linux-gnueabi/kernel: No such file or directory. Stop.
Also, re the insmod error -- look at the output of dmesg. It will show you what's going wrong with the initialization. If it doesn't show anything valuable, add more printk()s. dmesg and printk() are your best friends.

You are correct, you can remove those dynamic calls and put them in the board setup code, statically. They are nice to have for quick debugging purposes, though.

HTH
Jameson
 
Old 02-20-2012, 09:18 AM   #7
dennisdd
Member
 
Registered: Oct 2011
Posts: 37

Original Poster
Rep: Reputation: Disabled
should I be pointing my make file to ubuntu kernel or arm's?
 
Old 02-20-2012, 11:17 AM   #8
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 207Reputation: 207Reputation: 207
In the event you want to compile this for the Host system (again, I'm not sure you really do), then you'd point it at your Ubuntu kernel.

Code:
obj-m += spike.o

all:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
Also, don't source the overo crap since you're developing for the host, in that case.

If you're compiling for the ARM target, then you should point the KERNELDIR to the target's kernel sources.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with SPI driver and spidev asmeti Linux - Software 2 11-11-2011 09:08 PM
SPI Driver for Remote Control? NSS Linux - Embedded & Single-board computer 1 09-26-2011 03:09 PM
Communication with SPI driver Mactub Linux - Software 2 03-16-2010 02:17 AM
My SPI driver not working in u-boot. sunr2007 Linux - Embedded & Single-board computer 1 10-24-2009 07:17 AM
how to write spi driver for mpc8247 saheelahamed Linux - Software 1 02-20-2008 12:27 AM


All times are GMT -5. The time now is 09:38 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration