日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux arm下硬件驱动程序放哪里,Arm-Linux摄像头驱动程序的移植

發布時間:2025/3/12 linux 57 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux arm下硬件驱动程序放哪里,Arm-Linux摄像头驱动程序的移植 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Arm開發板上攝像頭的移植有兩種方法:第一,將驅動程序添加到內核,通過編譯內核,燒寫到板子上;第二種,通過動態加載攝像頭驅動模塊的方法進行硬件的驅動。作者首先在PC的linux系統進行攝像驅動程序的移植,保證驅動程序版本正確,然后將驅動程序編譯成模塊,通過文件系統掛載到板子,然后進行加載,進而創建攝像頭設備節點。下面將具體介紹攝像頭動態加載的過程。

移植過程所使用的攝像頭型號ZC301P,arm板上的內核版本為2.6.9,開發板為pxa270,所采用的驅動程序包為spca5xx-20060501.tar.gz。

第一步,使用命令解壓文件: tar zxvf spca5xx-20060501.tar.gz

進入spca5xx-20060501 : cd spca5xx-20060501

第二步,修改Makefile文件:VERSION??? = 00.60.00

Makefile的內容如下,注釋掉的為藍色,紅色表示修改過的內容:

CC????? =arm-linux-gcc

LD????? =arm-linux-ld

CVSVERSION = "$Experimental work Michel Xhaard && Reza Jelveh 03/02/2004"

DEFINES??? =

###

# The following flags enable experimental features.

# By default, these are enabled for development versions of the driver, and

# disabled for release versions.

# Optional: Enable driver debugging

DEFINES?? += -DSPCA50X_ENABLE_DEBUG

# Optional: Enable direct register read/write for PAC207 development

#DEFINES?? += -DSPCA5XX_ENABLE_REGISTERPLAY

###

# The following flags enable features that aren't yet implemented, and

# therefore are disabled by default.

# Optional: Enable compression

DEFINES?? += -DSPCA50X_ENABLE_COMPRESSION

###

# Rest of Makefile follows here. You probably won't need to touch this.

# Setup defines

DEFINES?? += -DCONFIG_USB_SPCA5XX_MODULE=1 -DMODULE -D__KERNEL__

DEFINES?? += -DVID_HARDWARE_SPCA5XX=0xFF -DSPCA5XX_VERSION=\"$(VERSION)\"

ifneq ($(shell uname -r | cut -d. -f1,2), 2.4)

ifneq ($(KERNELRELEASE),)?? # We were called by kbuild

CFLAGS += $(DEFINES)

obj-m += spca5xx.o

spca5xx-objs := drivers/usb/spca5xx.o drivers/usb/spcadecoder.o

else?? # We were called from command line

#KERNEL_VERSION = `uname -r`

KERNEL_VERSION = 2.6.9

#KERNELDIR := /lib/modules/$(KERNEL_VERSION)/build

KERNELDIR := /up-techpxa270/kernel/linux-2.6.9

PWD? := $(shell pwd)

#MODULE_INSTALLDIR = /lib/modules/$(KERNEL_VERSION)/kernel/drivers/usb/media/

MODULE_INSTALLDIR? =/root/modules/

# Targets, don't change!

default:

@echo '?? Building SPCA5XX driver for 2.5/2.6 kernel.'

@echo '?? Remember: you must have read/write access to your kernel source tree.'

$(MAKE) -C $(KERNELDIR) SUBDIRS=$(PWD) CC=$(CC) modules

install:

mkdir -p $(MODULE_INSTALLDIR)

rm -f $(MODULE_INSTALLDIR)spca50x.ko

rm -f $(MODULE_INSTALLDIR)et61x.ko

install -c -m 0644 spca5xx.ko $(MODULE_INSTALLDIR)

/sbin/depmod -ae

uninstall:

rm -f $(MODULE_INSTALLDIR)/spca5xx.ko

/sbin/depmod -aq

endif

else?? # kernel version test

#############################################################################

# For Linux 2.4 users.

# Change the following lines according to your system configuration.

# It is important to configure your particular source tree ("make dep") before

# compiling this module!

#############################################################################

###

# This makefile will build the spca50x driver module external to the kernel

# source tree. It makes it easier to swap kernels.

#KERNEL_VERSION = `uname -r`

KERNEL_VERSION = 2.4.x

###

# Location of the header files (most importantly the config files)

# for the kernel you want to build the module against.

# This should be correct for the currently installed kernel on your machine.

#KINCLUDE?? = /lib/modules/$(KERNEL_VERSION)/build/include

KINCLUDE??? =/up-techpxa270/kernel/linux2.4.x

KERNEL_ACFILE = $(KINCLUDE)/linux/autoconf.h

KERNEL_MODVERSIONSFILE = $(KINCLUDE)/linux/modversions.h

#MODULE_INSTALLDIR = /lib/modules/$(KERNEL_VERSION)/kernel/drivers/usb/

MODULE_INSTALLDIR =/root/modules/

# Detect module versioning support

ifneq ($(strip $(shell grep 'define CONFIG_MODVERSIONS 1' $(KERNEL_ACFILE))),)

DEFINES += -DMODVERSIONS -include $(KERNEL_MODVERSIONSFILE)

endif

# Detect SMP support

ifneq ($(strip $(shell grep 'define CONFIG_SMP 1' $(KERNEL_ACFILE))),)

DEFINES += -D__SMP__ -DSMP

endif

# Setup the tools

#CC???????? = gcc

#LD???????? = ld

CC????????=arm-linux-gcc

LD??????? =arm-linux-gcc

# Setup compiler warnings

WARNINGS?? = -Wall -Wpointer-arith

WARNINGS? += -Wcast-align -Wwrite-strings -Wstrict-prototypes

WARNINGS? += -Wuninitialized -Wreturn-type -Wunused -Wparentheses

# Setup compiler flags

CFLAGS???? = -O2 -fomit-frame-pointer -fno-strict-aliasing -pipe

CFLAGS??? += -mpreferred-stack-boundary=2

CFLAGS??? += -I$(KINCLUDE) -Idrivers/usb

# Setup link flags

LDFLAGS??? = --strip-debug -r

# Setup the list of files to be included in a distribution

DIST_FILES = CHANGELOG \

README \

Makefile \

drivers/usb/Config.in \

drivers/usb/spcadecoder.c \

drivers/usb/spcadecoder.h \

drivers/usb/spcagamma.h \

drivers/usb/spcaCompat.h \

drivers/usb/spcausb.h \

drivers/usb/spca500_init.h \

drivers/usb/spca501_init.h \

drivers/usb/sp5xxfw2.dat \

drivers/usb/sp5xxfw2.h \

drivers/usb/spca505_init.h \

drivers/usb/spca506.h \

drivers/usb/spca508_init.h \

drivers/usb/spca561.h \

drivers/usb/sonix.h \

drivers/usb/cs2102.h \

drivers/usb/hv7131b.h \

drivers/usb/icm105a.h \

drivers/usb/hv7131c.h \

drivers/usb/hdcs2020.h \

drivers/usb/pb0330.h \

drivers/usb/tas5130c.h \

drivers/usb/zc3xx.h\

drivers/usb/tv8532.h\

drivers/usb/cxlib.h\

drivers/usb/sn9cxxx.h\

drivers/usb/cx11646.h\

drivers/usb/pac207.h\

drivers/usb/spca5xx.c \

drivers/usb/spca5xx.h

OBJS?????? = drivers/usb/spcadecoder.o \

drivers/usb/spca5xx.o

BINARY???? = spca5xx.o

###

# Targets follow here

binary:?$(OBJS)

@echo Linking $(BINARY)

@$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS)

install: binary

@echo Installing.. Your root password may be required.

su -c "make install-root"

install-root:

@echo Installing..

@mkdir -p /lib/modules/`uname -r`/kernel/drivers/usb

@rm -f /lib/modules/`uname -r`/kernel/drivers/usb/spca50x.o

@rm -f /lib/modules/`uname -r`/kernel/drivers/usb/et61x.o

@cp spca5xx.o /lib/modules/`uname -r`/kernel/drivers/usb/spca5xx.o

@/sbin/depmod

dist:?clean binary

@echo Making distributable archives

@rm -f spca5xx-src-$(VERSION).tar.gz

@tar zcf spca5xx-src-$(VERSION).tar.gz $(DIST_FILES)

@rm -f spca5xx-module-$(VERSION).tar.gz

@cp $(BINARY) spca5xx-$(VERSION).o

@tar zcf spca5xx-module-$(VERSION).tar.gz spca5xx-$(VERSION).o README

@rm spca5xx-$(VERSION).o

.c.o:?Makefile $*.c

@echo Compiling $*.c

@$(CC) $(CFLAGS) $(WARNINGS) $(DEFINES) -c $*.c -o $*.o

###

# Dependencies follow here

drivers/usb/spca5xx.o: drivers/usb/spca5xx.h \

drivers/usb/spcaCompat.h \

drivers/usb/spcausb.h \

drivers/usb/sonix.h \

drivers/usb/spca500_init.h \

drivers/usb/spca501_init.h \

drivers/usb/sp5xxfw2.h \

drivers/usb/spca505_init.h \

drivers/usb/spca506.h \

drivers/usb/spca508_init.h \

drivers/usb/spca561.h \

drivers/usb/zc3xx.h\

drivers/usb/tv8532.h\

drivers/usb/cx11646.h\

drivers/usb/mr97311.h\

drivers/usb/sn9cxxx.h\

drivers/usb/pac207.h\

drivers/usb/spcadecoder.o: drivers/usb/spcadecoder.h \

drivers/usb/spcagamma.h \

endif? # End kernel version test

##############################################################################

# OTHER TARGETS

##############################################################################

clean:

rm -r -f drivers/usb/*.o drivers/usb/.spcadecoder.o.cmd \

drivers/usb/.spca5xx.o.cmd? *.o *.ko *.mod.* .[a-z]* core *.i

##############################################################################

關于修改Makefile文件做幾點說明:1Makefile文件針對不同內核回編譯成不同的目標文件,該Makefile前部分是針對2.6的內核,后部分針對2.4的內核,用戶根據自己的內核進行修改,我修改的是2.6.9的內核,關于2.4.x是表示2.4的某個版本,只是一個代號,用戶自己根據實際修改。2修改的東西,主要有兩個,一是gcc變成arm-linux-gcc;二是內核路徑,注意這是交叉編譯環境的內核路徑,即arm-linux的內核路徑,非pc上linux系統的內核。3 在Makefile文件修改之后,如果你的arm-linux從未編譯,需要先編譯內核,然后在make。MODULE_INSTALLDIR 這個是你編譯生成的模塊放在哪個路徑,可以不用改,當然為了方便,最好改成你想要的文件夾下,文件夾權限要改成可讀寫的。

第三步: make

編譯成功后,會在模塊MODULE_INSTALLDIR 路徑生成spca5xx.ko,spca5xx.o等目標文件。

第四步:將你的目標文件spca5xx.ko(2.6內核)或者spca5xx.o(2.4內核)掛載到arm開發板上

第五步:在開發板上進入掛載的文件夾下 insmod spca5xx.ko

第六步: 插上攝像頭,測試攝像頭

不出意外情況下,在/dev/下會有video0設備符,或者是/dev/v4l/video0

第七步: cat /dev/video0 > a.jpg 看看是否有文件a.jpg

按 ctrl+C 退出,將a.jpg拷貝到pc linux下通過gqview軟件進行查看,也可以編一個圖像采集小程序,抓取一幀保存成文件,然后到pclinux下進行查看。gqview軟件下得麻煩,我是寫了個小程序,將jpg文件保存下來,到pc linux

下直接看的,很方便。

當然,也有意外,攝像頭驅動加載之后,不能使用攝像頭,下一篇文章將會介紹一個特殊情況。我也是被這個問題卡了一兩天,問了一個技術達人才解決的。前面過程網上很多,我是將過程再細化一些,供初學者參考,共同進步。

總結

以上是生活随笔為你收集整理的linux arm下硬件驱动程序放哪里,Arm-Linux摄像头驱动程序的移植的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。