Reg: SPI and I2C on Mini2440

Tom
1) SPI:

I am trying to include SPI in mini2440 kernel, i have selected all the
option in make menuconfig of kernel, even though there so SPI device is
showing up in the "/dev folder of the board. Should i do anything more to
show it up..where as some empty folder of spi_master and spidev have been
created in "/sys/class/" area. SO please guide me how to display and write
a simple program in Qt


2) I2c:

Can anyone help a sample program to interface a I2C Device with Mini2440, i
am trying to write the program in Qt creator. Any sample will help me a
lot...thank you

davef
I recently reposted a SPI kernel driver that I managed to get working with
a test program.

Try searching "SPI davef"

The kernel still needs patching for mini2440 SPI ... I believe.

Good luck!

Tom
Hi Dave

No success,searched but cant find it..can u pls repost it here..also may i
know how to patch it for mini2440 SPI..thanks

Tom
Hi can u pls also post or guide me through simple i2c driver program to be
written in Qtcreator

Tom
Hi Dave

thanks..got the SPI driver for mini2440 doc by you..will try to implement
it today...pls also provide any help over i2c as i have to interface both
of the devices..thank you

davef
Haven't done I2C, sorry.

davef
An I2C driver will be in the kernel, similar to SPI.  You might then write
a program (application) in QtCreator to access the I2C.

Meher
Attachment: DS1621.c (9.61 KB)
Hi davef
I have attached ds1621 to mini2440 and it is working fine with i2ctools. I
got a kernel driver code for the ds1621.Can you pls help me with the step
by step approach to build it? The file is attached here.

davef
http://www.friendlyarm.net/forum/topic/6560

https://www.cyberciti.biz/faq/compiling-c-program-and-creating-executabl...

These are for a user application.

I'd look for "The Linux Module Programming Guide" and in Chapter 2 they
talk about the differences and how to compile kernel modules.

Good luck!

Meher
I have tried to build example hello.c for kernel following the "The Linux
Module Programming Guide" and in Chapter 2, but "make" gives following
error. can you please tell me what is wrong?

mou@mou-ubuntu:~/Downloads/Ex-Driver$ make -C
/home/mou/Downloads/linux-2.6.32.2/ M=$(PWD) helloPWD: command not found
make: Entering directory `/home/mou/Downloads/linux-2.6.32.2'
make: *** No rule to make target `hello'.  Stop.
make: Leaving directory `/home/mou/Downloads/linux-2.6.32.2'
mou@mou-ubuntu:~/Downloads/Ex-Driver$ 

My make file is 

obj−m := hello.o

all:
make −C /home/mou/Downloads/linux-2.6.32.2/ M=$(PWD) modules
clean:
make −C /home/mou/Downloads/linux-2.6.32.2/ M=$(PWD) clean

and the C file is 


/*
* hello−1.c − The simplest kernel module.
*/
#include <linux/module.h>
/* Needed by all modules */
#include <linux/kernel.h>
/* Needed for KERN_INFO */
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");

davef
From the 2nd link ... did you try:

In terminal cd to the directory that has your hello.c file.

   (gcc program.c -o program-output)

   gcc hello.c -o hello

Maybe it is a permissions problem with your procedure, ie:
   sudo make -C

Meher
It does not work since the hello is written for module, it is not finding
module.h

mou@mou-ubuntu:~/Downloads/Ex-Driver$ ls
hello.c  Makefile  Makefile~
mou@mou-ubuntu:~/Downloads/Ex-Driver$ sudo su
[sudo] password for mou: 
bash: [: /etc/debian_chexport: binary operator expected
root@mou-ubuntu:/home/mou/Downloads/Ex-Driver# gcc hello.c -o hello
hello.c:5:26: fatal error: linux/module.h: No such file or directory
compilation terminated.


The simple hello.c as follows worked for me. I have tested it 

#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}

davef
First check that you have a module.h in your ../linux directory.

Maybe, your project has to be in the directory above ../linux so that it
can find module.h

What is the full path to linux/module.h ?

davef
Since I did this, years ago, I have had to re-install Ubuntu several times.
 So, I have forgotten the process.

My thought is that where you issue your command:
   gcc hello.c -o hello

has to have a path to your cross-compile toolchain and to where you have
the kernel source. Or your project has to be in a place where it can find
module.h

But, first what do you get with:
   gcc -v

davef
Actually module.h is in /linux/include/ in your kernel source directory

davef
https://www.kernel.org/doc/Documentation/kbuild/modules.txt

See 2.1 and 2.2


    $ make -C <path_to_kernel_src> M=$PWD

OK,further up I see you have a path to your kernel source but you got an
error on that line.

What do you get with the command:
   printenv

Meher
gcc -v gives followos

mou@mou-ubuntu:~/Downloads/Ex-Driver$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-gnu-unique-object --enable-plugin --enable-objc-gc
--enable-targets=all --disable-werror --with-arch-32=i686
--with-tune=generic --enable-checking=release --build=i686-linux-gnu
--host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 
mou@mou-ubuntu:~/Downloads/Ex-Driver$ 


and printenv gives 


mou@mou-ubuntu:~/Downloads/Ex-Driver$ printenv
SSH_AGENT_PID=1302
GPG_AGENT_INFO=/tmp/keyring-SHD25S/gpg:0:1
TERM=xterm
SHELL=/bin/bash
XDG_SESSION_COOKIE=acb75566863010789e35b6ae0000000a-1486963937.343988-2092943809

WINDOWID=60825802
OLDPWD=/home/mou/Downloads
GNOME_KEYRING_CONTROL=/tmp/keyring-SHD25S
USER=mou
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd
=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=0
1;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.
tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz
=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.d
eb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31
:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=0
1;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.x
bm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;
35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mk
v=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;3
5:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=0
1;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd
=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*
.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00
;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga
=00;36:*.spx=00;36:*.xspf=00;36:
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
SSH_AUTH_SOCK=/tmp/keyring-SHD25S/ssh
SESSION_MANAGER=local/mou-ubuntu:@/tmp/.ICE-unix/1266,unix/mou-ubuntu:/tmp/.ICE-
unix/1266
DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:
/sbin:/bin:/usr/games:/home/mou/opt/FriendlyARM/toolschain/4.4.3/bin:/home/mou/l
ocal/ptxdist-2015.01.0/bin
DESKTOP_SESSION=ubuntu
PWD=/home/mou/Downloads/Ex-Driver
LANG=en_IN
MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
UBUNTU_MENUPROXY=libappmenu.so
COMPIZ_CONFIG_PROFILE=ubuntu
GDMSESSION=ubuntu
SHLVL=1
HOME=/home/mou
LANGUAGE=en_IN:en
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
LOGNAME=mou
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-MxzgGn8oYJ,guid=305cd84cc1bfa94
16887b16e0000000e
LESSOPEN=| /usr/bin/lesspipe %s
DISPLAY=:0
XDG_CURRENT_DESKTOP=Unity
LESSCLOSE=/usr/bin/lesspipe %s %s
COLORTERM=gnome-terminal
XAUTHORITY=/home/mou/.Xauthority
_=/usr/bin/printenv
mou@mou-ubuntu:~/Downloads/Ex-Driver$

davef
Further up you appear to be cross-compiling with linux-2.6.32.2

gcc -v seems to be finding a toolchain for host computer

and in printenv I don't see a path to linux-2.6.32.2

For the mini2440 you need to add a PATH to linux-2.6.32.2

Meher
Hi davef 
is this correct??


root@mou-ubuntu:/home/mou# arm-linux-gcc -v
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with:
/opt/FriendlyARM/mini2440/build-toolschain/working/src/gcc-4.4.3/configure
--build=i386-build_redhat-linux-gnu --host=i386-build_redhat-linux-gnu
--target=arm-none-linux-gnueabi --prefix=/opt/FriendlyARM/toolschain/4.4.3
--with-sysroot=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-roo
t
--enable-languages=c,c++ --disable-multilib --with-arch=armv4t
--with-cpu=arm920t --with-tune=arm920t --with-float=soft
--with-pkgversion=ctng-1.6.1 --disable-sjlj-exceptions
--enable-__cxa_atexit --with-gmp=/opt/FriendlyARM/toolschain/4.4.3
--with-mpfr=/opt/FriendlyARM/toolschain/4.4.3
--with-ppl=/opt/FriendlyARM/toolschain/4.4.3
--with-cloog=/opt/FriendlyARM/toolschain/4.4.3
--with-mpc=/opt/FriendlyARM/toolschain/4.4.3
--with-local-prefix=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sy
s-root
--disable-nls --enable-threads=posix --enable-symvers=gnu --enable-c99
--enable-long-long --enable-target-optspace
Thread model: posix
gcc version 4.4.3 (ctng-1.6.1) 
root@mou-ubuntu:/home/mou# 


root@mou-ubuntu:/home/mou/Downloads/linux-2.6.32.2# printenv
SHELL=/bin/bash
TERM=xterm
XDG_SESSION_COOKIE=acb75566863010789e35b6ae0000000a-1487332014.785431-1128254038

USER=root
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd
=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=0
1;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.
tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz
=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.d
eb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31
:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=0
1;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.x
bm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;
35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mk
v=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;3
5:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=0
1;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd
=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*
.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00
;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga
=00;36:*.spx=00;36:*.xspf=00;36:
SUDO_USER=mou
SUDO_UID=1000
USERNAME=root
MAIL=/var/mail/root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/ho
me/mou/opt/FriendlyARM/toolschain/4.4.3/bin:/home/mou/local/gawk-4.1.0:/home/mou
/local/flex-2.5.39:/home/mou/Downloads/ncurses-5.7/lib:/home/mou/local/ptxdist-2
015.01.0/bin:/epics/base-3.14.12.4/bin/linux-x86:/home/mou/Downloads/qt-everywhe
re-opensource-src-4.8.5/bin:/home/mou/Downloads/qt-everywhere-opensource-src-4.8
.5/lib
EPICS_HOST_ARCH=linux-x86
PWD=/home/mou/Downloads/linux-2.6.32.2
LANG=en_IN
SHLVL=1
SUDO_COMMAND=/bin/su
HOME=/root
LANGUAGE=en_IN:en
LOGNAME=root
LESSOPEN=| /usr/bin/lesspipe %s
SUDO_GID=1000
DISPLAY=:0
LESSCLOSE=/usr/bin/lesspipe %s %s
XAUTHORITY=/home/mou/.Xauthority
COLORTERM=gnome-terminal
_=/usr/bin/printenv
OLDPWD=/home/mou/Downloads
root@mou-ubuntu:/home/mou/Downloads/linux-2.6.32.2# 


and I found module.h in 
root@mou-ubuntu:/home/mou/Downloads/linux-2.6.32.2/include/linux#
Now what to do?

davef
No.

Configured with:
/opt/FriendlyARM/mini2440/build-toolschain/working/src/gcc-4.4.3/configure

Wrong toolchain

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/ho

me/mou/opt/FriendlyARM/toolschain/4.4.3/bin:/home/mou/local/gawk-4.1.0:/home/mou

/local/flex-2.5.39:/home/mou/Downloads/ncurses-5.7/lib:/home/mou/local/ptxdist-2

015.01.0/bin:/epics/base-3.14.12.4/bin/linux-x86:/home/mou/Downloads/qt-everywhe

re-opensource-src-4.8.5/bin:/home/mou/Downloads/qt-everywhere-opensource-src-4.8

.5/lib
****
Still don't see a path to your 2.6.32.2 toolchain.

You have paths to several toolchains, how did you set those up?

Reply

Name
eMail (not visible)
Subject (no text only in upper case; no HELP, URGENT...)
Text
HTML tags are not supported and links are generated automatically if they start with http or ftp.
Please submit long source code or log files as attachment (only registered users).
Please enter the number: 8 1 6 6