pcDuino的linux移植四简单驱动开发

继pcDuino linux移植一、二、三,成功搭建linux最小系统,抽点时间开始linux内核驱动开发之旅。由于时间关系,基本上都是边玩边写,一些还没写完甚至有问题,就被转载了,以致大家看到的五花八门,希望转载的人也及时更新。遗留的很多问题随着时间都慢慢解决了,都是亲身体验能跑起来的,才敢写在这。我自己收获了很多,希望读到的人也能有收获,希望能一直坚持下去。

开发环境
系统:ubuntu 10.04.4
单板:pcDuino(全志A10)
编译器:arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

搭建开发环境详见ubuntu 10.04.4开发环境配置。

目标
1.配置 编译linux-3.0.62内核,串口正常输出
2.配置内核,支持nfs挂载,启动文件系统
3.最简单内核驱动开发

这个是在pcDuino linux移植一、二、三的基础上写的,重点介绍内核驱动开发,其它具体移植过程不再详述。最基础的裸板开发、u-boot移植以及linux移植,参考前面的文章,这里不再重复。

一、搭建驱动开发平台

这里用官方提供的源码kernel for pcduino,我试了哈,这里面有些常用的驱动,比如网卡驱动之类,在官方提供的kernel平台再添加自己的驱动。

1.准备工作

获取交叉编译器http://code.google.com/p/smp-on-qemu/downloads/list选择arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2并下载。然后在ubuntu下直接解压即可,配置过程还不清楚的看Ubuntu 10.04.4开发环境配。

获取linux源码 https://github.com/pcduino/kernel 点击linux-sunxi,跳转到https://github.com/linux-sunxi/linux-sunxi下载linux-sunxi源码

2.配置、编译内核

打开linux-sunxi-sunxi-3.0目录下的Makefile,修改195:

ARCH ?= ARM

CROSS_COMPILE ?=  your-path/arm-2009q3/bin/arm-none-linux-gnueabi-

其中your-path是gcc-linaro-arm-linux-gnueabihf-4.8-2013.04-20130417_linux.tar.bz2的解压路径

change@change:~$ cd /home/change/Si/A10/pcduino/linux-sunxi-sunxi-3.0/
change@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ make menuconfig

记住选中wemac support(A1x),其它不变。开始也不知道选这个,后来分析官方提供的kernel才知道的。

编译过程超长,如果编译过程中遇到些问题,见pcduino linux 移植一、二、三

change@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ ls arch/arm/boot
bootp  compressed  Image  install.sh  Makefile  uImage  zImage

3.测试

经过pcDuino linux移植一、二、三,我们已制作一张可启动的tf卡,现在用我们新的内核uImage,替换掉以前的进行测试。将上次制作的启动卡插到PC机,弹出窗口,直接拷贝上面编译生成的uimage到sdb1,替换掉以前的,取下tf卡插到pcduino启动如下:

U-Boot SPL 2012.10 (Apr 19 2013 - 18:46:44)
DRAM: 1024MB
SUNXI SD/MMC: 0


U-Boot 2012.10 (Apr 19 2013 - 18:46:44) Allwinner Technology

CPU:   SUNXI Family
Board: pcDuino
I2C:   ready
DRAM:  1 GiB
MMC:   SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0
reading uEnv.txt

144 bytes read
Loaded environment from uEnv.txt
reading boot.scr

270 bytes read
Jumping to boot.scr
## Executing script at 44000000
reading script.bin

" from mmc 0:1 ** "script.bin
reading uImage

" from mmc 0:1 ** "uImage
bootm - boot application image from memory

Usage:
bootm [addr [arg ...]]
    - boot application image stored in memory
        passing arguments 'arg ...'; when booting a Linux kernel,
        'arg' can be the address of an initrd image

Sub-commands to do part of the bootm sequence.  The sub-commands must be
issued in the order below (it's ok to not issue all sub-commands):
        start [addr [arg ...]]
        loados  - load OS image
        cmdline - OS specific command line processing/setup
        bdt     - OS specific bd_t processing
        prep    - OS specific prep before relocation or go
        go      - start OS
reading script.bin

44900 bytes read
reading uImage

4693140 bytes read
## Booting kernel from Legacy Image at 48000000 ...
   Image Name:   Linux-3.0.62
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4693076 Bytes = 4.5 MiB
   Load Address: 40008000
   Entry Point:  40008000
   Verifying Checksum ... OK
 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值