version magic '2.6.22.6 mod_unload ARMv5 ' should be '2.6.22.6 mod_unload ARMv4 字符设备驱动遇到的内核版本不匹问题

我一开始的内核编译是有错误的

1.

 我使用的不是 linux-2.6.22.6_jz2440.patch 补丁  而是  linux-2.6.22.6_jz2440_v2v3.patch

2.

忘记了一个步骤  那就是

生成  .config配置文件

可以有两种方法生成 .config文件

1.make xxxx_deconfig 

2.cp config_ok .config  (复制厂家的配置文件)

 

一开始执行 make uImage 错误的编译信息:

drivers/char/s3c24xx_leds.c:7:32: asm/arch/regs-gpio.h: No such file or directory
drivers/char/s3c24xx_leds.c:19: error: `S3C2410_GPB5' undeclared here (not in a function)
drivers/char/s3c24xx_leds.c:19: error: initializer element is not constant
drivers/char/s3c24xx_leds.c:19: error: (near initialization for `led_table[0]')
drivers/char/s3c24xx_leds.c:20: error: `S3C2410_GPB6' undeclared here (not in a function)
drivers/char/s3c24xx_leds.c:20: error: initializer element is not constant
drivers/char/s3c24xx_leds.c:20: error: (near initialization for `led_table[1]')
drivers/char/s3c24xx_leds.c:21: error: `S3C2410_GPB7' undeclared here (not in a function)
drivers/char/s3c24xx_leds.c:21: error: initializer element is not constant
drivers/char/s3c24xx_leds.c:21: error: (near initialization for `led_table[2]')
drivers/char/s3c24xx_leds.c:22: error: `S3C2410_GPB8' undeclared here (not in a function)
drivers/char/s3c24xx_leds.c:22: error: initializer element is not constant
drivers/char/s3c24xx_leds.c:22: error: (near initialization for `led_table[3]')
drivers/char/s3c24xx_leds.c:27: error: `S3C2410_GPB5_OUTP' undeclared here (not in a function)
drivers/char/s3c24xx_leds.c:27: error: initializer element is not constant
drivers/char/s3c24xx_leds.c:27: error: (near initialization for `led_cfg_table[0]')
drivers/char/s3c24xx_leds.c:28: error: `S3C2410_GPB6_OUTP' undeclared here (not in a function)
drivers/char/s3c24xx_leds.c:28: error: initializer element is not constant
drivers/char/s3c24xx_leds.c:28: error: (near initialization for `led_cfg_table[1]')
drivers/char/s3c24xx_leds.c:29: error: `S3C2410_GPB7_OUTP' undeclared here (not in a function)
drivers/char/s3c24xx_leds.c:29: error: initializer element is not constant
drivers/char/s3c24xx_leds.c:29: error: (near initialization for `led_cfg_table[2]')
drivers/char/s3c24xx_leds.c:30: error: `S3C2410_GPB8_OUTP' undeclared here (not in a function)
drivers/char/s3c24xx_leds.c:30: error: initializer element is not constant
drivers/char/s3c24xx_leds.c:30: error: (near initialization for `led_cfg_table[3]')
drivers/char/s3c24xx_leds.c: In function `s3c24xx_leds_open':
drivers/char/s3c24xx_leds.c:42: warning: implicit declaration of function `s3c2410_gpio_cfgpin'
drivers/char/s3c24xx_leds.c: In function `s3c24xx_leds_ioctl':
drivers/char/s3c24xx_leds.c:63: warning: implicit declaration of function `s3c2410_gpio_setpin'
scripts/Makefile.build:208: recipe for target 'drivers/char/s3c24xx_leds.o' failed
make[2]: *** [drivers/char/s3c24xx_leds.o] Error 1
scripts/Makefile.build:323: recipe for target 'drivers/char' failed
make[1]: *** [drivers/char] Error 2
Makefile:765: recipe for target 'drivers' failed
make: *** [drivers] Error 2

 

正确的make uImage 编译信息:

  SYSMAP  .tmp_System.map
  MODPOST vmlinux
WARNING: arch/arm/mach-s3c2410/built-in.o(.text+0x80): Section mismatch: reference to .init.data: (between 's3c2410_dma_add' and 's3c2410_pm_prepare')
WARNING: arch/arm/mach-s3c2410/built-in.o(.text+0x84): Section mismatch: reference to .init.data: (between 's3c2410_dma_add' and 's3c2410_pm_prepare')
WARNING: arch/arm/mach-s3c2412/built-in.o(.text+0x784): Section mismatch: reference to .init.data: (between 's3c2412_dma_add' and 's3c2412_cpu_suspend')
WARNING: arch/arm/mach-s3c2440/built-in.o(.text+0x4dc): Section mismatch: reference to .init.data: (after 's3c2440_dma_add')
WARNING: arch/arm/mach-s3c2440/built-in.o(.text+0x4e0): Section mismatch: reference to .init.data: (after 's3c2440_dma_add')
WARNING: arch/arm/mach-s3c2443/built-in.o(.text+0x74c): Section mismatch: reference to .init.text: (between 's3c2443_irq_add' and 's3c2443_irq_init')
WARNING: arch/arm/mach-s3c2443/built-in.o(.text+0x768): Section mismatch: reference to .init.text: (between 's3c2443_irq_add' and 's3c2443_irq_init')
WARNING: arch/arm/mach-s3c2443/built-in.o(.text+0x784): Section mismatch: reference to .init.text: (between 's3c2443_irq_add' and 's3c2443_irq_init')
WARNING: arch/arm/mach-s3c2443/built-in.o(.text+0x7a0): Section mismatch: reference to .init.text: (between 's3c2443_irq_add' and 's3c2443_irq_init')
WARNING: arch/arm/mach-s3c2443/built-in.o(.text+0x7bc): Section mismatch: reference to .init.text: (between 's3c2443_irq_add' and 's3c2443_irq_init')
WARNING: arch/arm/mach-s3c2443/built-in.o(.text+0x1020): Section mismatch: reference to .init.data: (after 's3c2443_dma_add')
WARNING: arch/arm/plat-s3c24xx/built-in.o(.text+0x2a8c): Section mismatch: reference to .init.text:s3c24xx_dma_init (between 's3c2410_dma_init' and 's3c2410_dma_request')
WARNING: arch/arm/plat-s3c24xx/built-in.o(.data+0x23cc): Section mismatch: reference to .init.text: (between 's3c24xx_timer' and 's3c2410_timer_irq')
WARNING: sound/built-in.o(.text+0x18c3c): Section mismatch: reference to .init.text: (between 's3c2410iis_probe' and 's3c2410iis_remove')
WARNING: sound/built-in.o(.text+0x18c64): Section mismatch: reference to .init.text: (between 's3c2410iis_probe' and 's3c2410iis_remove')
  OBJCOPY arch/arm/boot/Image
  Kernel: arch/arm/boot/Image is ready
  AS      arch/arm/boot/compressed/head.o
  GZIP    arch/arm/boot/compressed/piggy.gz
  AS      arch/arm/boot/compressed/piggy.o
  CC      arch/arm/boot/compressed/misc.o
  LD      arch/arm/boot/compressed/vmlinux
  OBJCOPY arch/arm/boot/zImage
  Kernel: arch/arm/boot/zImage is ready
  UIMAGE  arch/arm/boot/uImage
"mkimage" command not found - U-Boot images will not be built
  Image arch/arm/boot/uImage is ready

然后 重新 make 编译 字符设备驱动 

具体过程参考这篇日志:

S3C2400 第一个字符设备驱动开发日志

再次make 

book@www.100ask.org:/work/drivers_and_test$ make
make -C /work/system/linux-2.6.22.6 M=`pwd` modules
make[1]: Entering directory '/work/system/linux-2.6.22.6'
  CC [M]  /work/drivers_and_test/first_drv.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /work/drivers_and_test/first_drv.mod.o
  LD [M]  /work/drivers_and_test/first_drv.ko
make[1]: Leaving directory '/work/system/linux-2.6.22.6'
book@www.100ask.org:/work/drivers_and_test$ ll

生成了  .ko文件

拷贝它到制作的根文件系统下:

book@www.100ask.org:/work/drivers_and_test$ cp first_drv.ko /work/nfs_root/first_fs
book@www.100ask.org:/work/drivers_and_test$ ls /work/nfs_root/first_fs
bin  dev  etc  first_drv.ko  hello.txt  lib  linuxrc  proc  sbin  sys  usr

再次制作 yaff2  文件系统镜像:

book@www.100ask.org:/work/nfs_root$ mkyaffs2image first_fs first_fs11.yaffs2

book@www.100ask.org:/work/nfs_root$ ls
first_fs  first_fs10.yaffs2  first_fs11.yaffs2  first_fs6.yaff2  first_fs7.yaffs2  first_fs8.yaffs2

 

拷贝到板子里

板子里

执行 cat /proc/devices 查看当前的字符设备:

# cat /proc/devices
Character devices:
  1 mem
  2 pty
  3 ttyp
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  6 lp
  7 vcs
 10 misc
 13 input
 14 sound
 29 fb
 90 mtd
 99 ppdev
116 alsa
128 ptm
136 pts
180 usb
189 usb_device
204 s3c2410_serial
253 usb_endpoint
254 rtc

Block devices:
  1 ramdisk
  7 loop
  8 sd
 31 mtdblock
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
179 mmc

然后执行 下面命令 加载驱动模块

# insmod first_drv.ko
first_drv: module license 'unspecified' taints kernel.

 

再次查看  字符设备驱动列表:

# cat /proc/devices
Character devices:
  1 mem
  2 pty
  3 ttyp
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  6 lp
  7 vcs
 10 misc
 13 input
 14 sound
 29 fb
 90 mtd
 99 ppdev
111 first_drv
116 alsa
128 ptm
136 pts
180 usb
189 usb_device
204 s3c2410_serial
253 usb_endpoint
254 rtc

可以看到我们的主设备号为 111的驱动已经加载

 

问题解决了

就是因为  linux 之前编译出问题了

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Z文的博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值