update s3c2440camera device driver for kernel mini2440(2.6.29.4)

majid
hi

how it is possible to upgrade s3c2440camera device driver for kernel
mini2440(2.6.29.4) ?

regards

open-nandra
Well you need to adapt camera code for kernel which you need. Lot of
changes should be there.

majid
It has compiled and built.
What files should be replaced or modified in mini2440?

open-nandra
If you have builded module just include to kernel and use.

majid
I did but

[root@FriendlyARM /]# cd sdcard
[root@FriendlyARM /sdcard]# ls
mjpg-streamer     s3c2440camera.ko  test_capture
[root@FriendlyARM /sdcard]# chmod u+x s3c2440camera.ko 
[root@FriendlyARM /sdcard]# chmod u+x test_capture 
[root@FriendlyARM /sdcard]# insmod s3c2440camera.ko 
[root@FriendlyARM /sdcard]# ./test_capture 
./test_capture: line 1: syntax error: "(" unexpected
[root@FriendlyARM /sdcard]# 


I build with 2.6.32 and mini2440 is 2.6.29.4 version.

open-nandra
Test capture has some config file? If yes please check it.

majid
no, It has only a makefile

open-nandra
Well I try on my board works fine:
./test_capture 
Usage:./test_capture <device> <width> <height> <output_base> [number of
frames]

Check if you compile correctly.

majid
kindly, what is your host kernel version and mini2440 kernel version ?
could you please send me test_capture and s3c2440camera.ko files.

open-nandra
Attachment: driver.tar.gz (85.98 KB)
Sure! In attachment. I use 2.6.32-rc8.

majid
tanx
your file does not work on my mini2440(2.6.29.4)

[root@FriendlyARM /sdcard]# chmod u+x s3c2440camera.ko 
[root@FriendlyARM /sdcard]# insmod s3c2440camera.ko 
insmod: cannot insert 's3c2440camera.ko': invalid module format
[root@FriendlyARM /sdcard]# chmod u+x test_capture
[root@FriendlyARM /sdcard]# ./test_capture
-sh: ./test_capture: not found
[root@FriendlyARM /sdcard]#

open-nandra
For sure you can't load module compiled for 2.6.32 to 2.6.29.

majid
I just updated mini2440-128 with vivi,zImage_t35 & root_gtopia.img (just
downloaded from friendlyarm)


but still the problem exist

[root@FriendlyARM /]# chmod u+x s3c2440camera.ko 
[root@FriendlyARM /]# insmod s3c2440camera.ko 
insmod: cannot insert 's3c2440camera.ko': invalid module format

do you use original image or have had modification on you mini2440 files?

majid
[the uploaded images & binaries are latest version]

majid
{and I use FileZilla3 in binary transfer format; size of transferred files
from pc to mini2440 are the same}

Marcio Lima
Hi

Are you sure you compiled the module with the rigth Linux kernel version ? 
Run objdump and verify if the generated code is ARM. You may be compiling
the module with the gcc for Intel instead of the ARM cross compile.

majid
root@dab-desktop:/home/dab/project/mini2440/s3c2440camera-r5# objdump -i
test_capture
BFD header file version (GNU Binutils for Ubuntu) 2.20.1-system.20100303
elf32-i386
 (header little endian, data little endian)
  i386
a.out-i386-linux
 (header little endian, data little endian)
  i386
pei-i386
 (header little endian, data little endian)
  i386
elf32-little
 (header little endian, data little endian)
  i386
  l1om
  plugin
elf32-big
 (header big endian, data big endian)
  i386
  l1om
  plugin
elf64-x86-64
 (header little endian, data little endian)
  i386
pei-x86-64
 (header little endian, data little endian)
  i386
elf64-l1om
 (header little endian, data little endian)
  l1om
elf64-little
 (header little endian, data little endian)
  i386
  l1om
  plugin
elf64-big
 (header big endian, data big endian)
  i386
  l1om
  plugin
plugin
 (header little endian, data little endian)
BFD: BFD (GNU Binutils for Ubuntu) 2.20.1-system.20100303 assertion fail
../../bfd/plugin.c:436
objdump: plugin: Bad value
srec
 (header endianness unknown, data endianness unknown)
  i386
  l1om
  plugin
symbolsrec
 (header endianness unknown, data endianness unknown)
  i386
  l1om
  plugin
verilog
 (header endianness unknown, data endianness unknown)
  i386
  l1om
  plugin
tekhex
 (header endianness unknown, data endianness unknown)
  i386
  l1om
  plugin
binary
 (header endianness unknown, data endianness unknown)
  i386
  l1om
  plugin
ihex
 (header endianness unknown, data endianness unknown)
  i386
  l1om
  plugin
trad-core
 (header endianness unknown, data endianness unknown)
root@dab-desktop:/home/dab/project/mini2440/s3c2440camera-r5#

majid
makefile


# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.

# or specify your own in command line
KERNELDIR =/opt/FriendlyArm/mini2440/linux-2.6.32.2
# where libtiff is compiled, only needed for tiff_capture
TIFFDIR ?= ../tiff-3.9.2

EXTRA_CFLAGS += -I/opt/FriendlyArm/mini2440/linux-2.6.32.2

ifneq ($(KERNELRELEASE),)
  obj-m := s3c2440camera.o
  s3c2440camera-objs      :=      s3c2440_ov9650.o sccb.o s3c2440camif.o

# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
  PWD  := $(shell pwd)

default:
  bash ./ARM-Linux-GCC-4.3.2.sh
  $(MAKE) -C $(KERNELDIR) M=$(PWD) ARCH=arm modules

test_capture: test_capture.c
  bash ./ARM-Linux-GCC-4.3.2.sh
  $(CC) -Wall -std=gnu99  -O3 test_capture.c -o test_capture 
#-I$(KERNELDIR)/include

set_parameters: set_parameters.c
  bash ./ARM-Linux-GCC-4.3.2.sh
  $(CC) -Wall -std=gnu99  -O3 set_parameters.c -o set_parameters 

tiff_capture: tiff_capture.c
  bash ./ARM-Linux-GCC-4.3.2.sh
  $(CC) -Wall -std=gnu99 -I$(TIFFDIR)/libtiff -L$(TIFFDIR)/libtiff/.libs
-O3 tiff_capture.c -o tiff_capture -ltiff -lz -lm  
#-I$(KERNELDIR)/include

clean:
  rm -f s3c2440camera.mod.o  s3c2440camera.o  s3c2440camif.o 
s3c2440_ov9650.o  sccb.o  s3c2440camera.ko s3c2440camera.mod.c 
test_capture tiff_capture 

tar:
  tar czf s3c2440camera.tar.gz *.c *.h Makefile 
endif

Marcio Lima
Your module is being created with Intel code. Check the instalation of your
cross compile. check also if the CC variavel is set to arm-linux-gcc.
Check the PATH variavel and see if has included your cross compile path.

majid
ARM-Linux-GCC-4.3.2.sh


#BASE=/opt/FriendlyARM

export CROSS_COMPILE=arm-linux-

export ARCH=arm # Platform architecture
export CC=${CROSS_COMPILE}gcc;        echo CC: ${CC}
export CXX=${CROSS_COMPILE}gxx;       echo CXX: ${CXX}
export CPP=${CROSS_COMPILE}cpp;       echo CPP: ${CPP}
export AR=${CROSS_COMPILE}ar;         echo AR: ${AR}
export AS=${CROSS_COMPILE}as;         echo AS: ${AS}
export LD=${CROSS_COMPILE}ld;         echo LD: ${LD}
export NM=${CROSS_COMPILE}nm;         echo NM: ${NM}
export RANLIB=${CROSS_COMPILE}ranlib; echo RANLIB: ${RANLIB}
export STRIP=${CROSS_COMPILE}strip;   echo STRIP: ${STRIP}
export SIZE=${CROSS_COMPILE}size;     echo SIZE: ${SIZE}

#export PATH=$BASE/usr/local/arm/4.3.2/bin:$PATH
export PATH=$PATH:/usr/local/arm/4.3.2/bin

majid
this objdump info of "s3c2440camera.ko" from
"code.google.com/p/s3c2440camera/" that can be successfully insmod in my
mini2440-128 :

how can we find that it is for arm9 ?

root@dab-desktop:/home/dab/project/mini2440/s3c2440camera-r5# objdump -i -m
s3c2440camera.ko
BFD header file version (GNU Binutils for Ubuntu) 2.20.1-system.20100303
elf32-i386
 (header little endian, data little endian)
  i386
a.out-i386-linux
 (header little endian, data little endian)
  i386
pei-i386
 (header little endian, data little endian)
  i386
elf32-little
 (header little endian, data little endian)
  i386
  l1om
  plugin
elf32-big
 (header big endian, data big endian)
  i386
  l1om
  plugin
elf64-x86-64
 (header little endian, data little endian)
  i386
pei-x86-64
 (header little endian, data little endian)
  i386
elf64-l1om
 (header little endian, data little endian)
  l1om
elf64-little
 (header little endian, data little endian)
  i386
  l1om
  plugin
elf64-big
 (header big endian, data big endian)
  i386
  l1om
  plugin
plugin
 (header little endian, data little endian)
BFD: BFD (GNU Binutils for Ubuntu) 2.20.1-system.20100303 assertion fail
../../bfd/plugin.c:436
objdump: plugin: Bad value
srec
 (header endianness unknown, data endianness unknown)
  i386
  l1om
  plugin
symbolsrec
 (header endianness unknown, data endianness unknown)
  i386
  l1om
  plugin
verilog
 (header endianness unknown, data endianness unknown)
  i386
  l1om
  plugin
tekhex
 (header endianness unknown, data endianness unknown)
  i386
  l1om
  plugin
binary
 (header endianness unknown, data endianness unknown)
  i386
  l1om
  plugin
ihex
 (header endianness unknown, data endianness unknown)
  i386
  l1om
  plugin
trad-core
 (header endianness unknown, data endianness unknown)
root@dab-desktop:/home/dab/project/mini2440/s3c2440camera-r5#

majid
these are warnings of make:

 
root@dab-desktop:/home/dab/project/mini2440/s3c2440camera-r5# make clean
rm -f s3c2440camera.mod.o  s3c2440camera.o  s3c2440camif.o 
s3c2440_ov9650.o  sccb.o  s3c2440camera.ko s3c2440camera.mod.c 
test_capture tiff_capture 

root@dab-desktop:/home/dab/project/mini2440/s3c2440camera-r5# make
bash ./ARM-Linux-GCC-4.3.2.sh
CC: arm-linux-gcc
CXX: arm-linux-gxx
CPP: arm-linux-cpp
AR: arm-linux-ar
AS: arm-linux-as
LD: arm-linux-ld
NM: arm-linux-nm
RANLIB: arm-linux-ranlib
STRIP: arm-linux-strip
SIZE: arm-linux-size
make -C /opt/FriendlyArm/mini2440/linux-2.6.32.2
M=/home/dab/project/mini2440/s3c2440camera-r5 ARCH=arm modules
make[1]: Entering directory `/opt/FriendlyArm/mini2440/linux-2.6.32.2'
  CC [M]  /home/dab/project/mini2440/s3c2440camera-r5/s3c2440_ov9650.o
/home/dab/project/mini2440/s3c2440camera-r5/ov9650_qcif.h:1: warning:
'ov9650_qcif' defined but not used
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440_ov9650.c:36: warning:
'ov9650_invert' defined but not used
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440_ov9650.c:39: warning:
'ov9650_restore' defined but not used
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440_ov9650.c:117: warning:
'ov9650_exp' defined but not used
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440_ov9650.c:118: warning:
'ov9650_gain' defined but not used
  CC [M]  /home/dab/project/mini2440/s3c2440camera-r5/sccb.o
  CC [M]  /home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.o
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c: In function
'update_target_fmt_regs':
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:414: warning:
unused variable 'cicoscctrl'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:413: warning:
unused variable 'cicrscctrl'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:412: warning:
unused variable 'cicrctrl'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:409: warning:
unused variable 'ciprscctrl'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:408: warning:
unused variable 'ciprctrl'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:407: warning:
unused variable 'ciprtrgfmt'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c: In function
'update_target_zoom_regs':
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:580: warning:
unused variable 'cicoscpreratio'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:578: warning:
unused variable 'ciprscctrl'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:577: warning:
unused variable 'ciprscpredst'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:571: warning:
unused variable 'preDstHeight'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:571: warning:
unused variable 'preDstWidth'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:566: warning:
unused variable 'preVratio'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:566: warning:
unused variable 'preHratio'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c: In function
'start_capture':
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:704: warning:
unused variable 'ciimgcpt'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:703: warning:
unused variable 'ciprscctrl'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c: In function
's3c2410camif_querycap':
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:1229: warning:
unused variable 'pcam'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c: In function
's3c2410camif_enum_fmt_vid_cap':
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:1269: warning:
unused variable 'dev'
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c: At top level:
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:152: warning:
's3c2440camif_free_frame_buf' defined but not used
/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camif.c:257: warning:
's3c2440camif_reg_dump' defined but not used
  LD [M]  /home/dab/project/mini2440/s3c2440camera-r5/s3c2440camera.o
  Building modules, stage 2.
  MODPOST 1 modules
WARNING: "video_device_release"
[/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camera.ko] undefined!
WARNING: "video_register_device"
[/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camera.ko] undefined!
WARNING: "video_device_alloc"
[/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camera.ko] undefined!
WARNING: "video_unregister_device"
[/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camera.ko] undefined!
WARNING: "video_devdata"
[/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camera.ko] undefined!
WARNING: "video_ioctl2"
[/home/dab/project/mini2440/s3c2440camera-r5/s3c2440camera.ko] undefined!
  CC      /home/dab/project/mini2440/s3c2440camera-r5/s3c2440camera.mod.o
  LD [M]  /home/dab/project/mini2440/s3c2440camera-r5/s3c2440camera.ko
make[1]: Leaving directory `/opt/FriendlyArm/mini2440/linux-2.6.32.2'

root@dab-desktop:/home/dab/project/mini2440/s3c2440camera-r5# make
test_capture
bash ./ARM-Linux-GCC-4.3.2.sh
CC: arm-linux-gcc
CXX: arm-linux-gxx
CPP: arm-linux-cpp
AR: arm-linux-ar
AS: arm-linux-as
LD: arm-linux-ld
NM: arm-linux-nm
RANLIB: arm-linux-ranlib
STRIP: arm-linux-strip
SIZE: arm-linux-size
cc -Wall -std=gnu99  -O3 test_capture.c -o test_capture 
In file included from /usr/include/string.h:640,
                 from test_capture.c:10:
In function ‘memset’,
    inlined from ‘main’ at test_capture.c:43:
/usr/include/bits/string3.h:83: warning: call to ‘__warn_memset_zero_len’
declared with attribute warning: memset used with constant zero length
parameter; this could be due to transposed parameters
/tmp/cc9mG9j1.o: In function `main':
test_capture.c:(.text+0x4a): warning: memset used with constant zero length
parameter; this could be due to transposed parameters
root@dab-desktop:/home/dab/project/mini2440/s3c2440camera-r5#

Marcio Lima
objdump -d s3c2440camera.ko

And check the generated code.

majid
root@dab-desktop:/home/dab/project/mini2440/s3c2440camera-r5# objdump -d
s3c2440camera.ko

s3c2440camera.ko:     file format elf32-little

objdump: Can't disassemble for architecture UNKNOWN!

open-nandra
Shouldn't there be some arm-linux-objdump ....?

majid
tanx

I found that test_capture is in known (not ARM!) format.

but as you see I defined paths and exported them

Marcio Lima
You should use arm-linux-objdump but the result "architeture UNKNOWN" from
the objdump says that the code maybe ARM.

majid
root@dab-desktop:/home/dab/project/mini2440/s3c2440camera-r5#
objarm-linux-objdump
objarm-linux-objdump: command not found
root@dab-desktop:/home/dab/project/mini2440/s3c2440camera-r5# arm-linux-gcc
-v
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/julian/lite-respin/linux/src/gcc-4.3/configure
--build=i686-pc-linux-gnu --host=i686-pc-linux-gnu
--target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap
--disable-libssp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld
--enable-languages=c,c++ --enable-shared --enable-symvers=gnu
--enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 2008q3-72'
--with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls
--prefix=/opt/codesourcery
--with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc
--with-build-sysroot=/scratch/julian/lite-respin/linux/install/arm-none-linux-gn
ueabi/libc
--with-gmp=/scratch/julian/lite-respin/linux/obj/host-libs-2008q3-72-arm-none-li
nux-gnueabi-i686-pc-linux-gnu/usr
--with-mpfr=/scratch/julian/lite-respin/linux/obj/host-libs-2008q3-72-arm-none-l
inux-gnueabi-i686-pc-linux-gnu/usr
--disable-libgomp --enable-poison-system-directories
--with-build-time-tools=/scratch/julian/lite-respin/linux/install/arm-none-linux
-gnueabi/bin
--with-build-time-tools=/scratch/julian/lite-respin/linux/install/arm-none-linux
-gnueabi/bin
Thread model: posix
gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72) 
root@dab-desktop:/home/dab/project/mini2440/s3c2440camera-r5#

majid
also

root@dab-desktop:/home/dab/project/mini2440/s3c2440camera-r5#
arm-linux-gnueabi-objdump 
arm-linux-gnueabi-objdump: command not found
root@dab-desktop:/home/dab/project/mini2440/s3c2440camera-r5#