Linux-4.9.2内核在mini2440上的移植(八)——RTC驱动移植

来源:互联网 发布:知乎笔记本推荐 编辑:程序博客网 时间:2024/06/04 23:27

本篇目标:移植RTC驱动,使时钟正常运行。

8.1 添加RTC支持

上篇说到,RTC的驱动有问题,这个问题在启动日志中的体现是hctosys: unable to open rtc device (rtc0)可见RTC驱动没有加载上。

我们先将RTC驱动添加到mach-mini2440.c文件中。

root@ubuntu:~/linux-4.9.2#vim arch/arm/mach-s3c24xx/mach-mini2440.c

到251行附近:

static structplatform_device *mini2440_devices[] __initdata = {

        &s3c_device_ohci,

        &s3c_device_lcd,

        &s3c_device_wdt,

        &s3c_device_i2c0,

        &s3c_device_iis,

        &s3c_device_nand,

        &s3c_device_rtc,

        &mini2440_device_eth,

};

 

添加即可

8.2在内核中配置RTC

接下来重新配置内核,以加入RTC的驱动支持,依次选择如下菜单项:

DeviceDrivers --->
< *> Real Time Clock --->

<*> Samsung S3C series SoC RTC //这里才是内核中真正的2440RTC驱动配置项。

确认完毕后,退出。

8.3 编译测试

root@ubuntu:~/linux-4.9.2#make -j8

root@ubuntu:~/linux-4.9.2#./mkuImage.sh

 

重启开发板

问题依旧

 

8.4 原因分析

经过网上大量查阅资料,网上给出的答案都无法完美解决此问题,笔者怀疑是驱动不匹配。

经过笔者大量linux内核版本测试,发现RTC有效的最后的版本是linux-3.17.8版本,升级到linux3.18.2版本的时候RTC驱动就无效了。这可能是版本升级的时候的bug,也许是新的驱动不会用?

 

8.5具体操作如下

(1)下载linux-3.17.8源码

root@ubuntu:~/linux-4.9.2#cd /root/

root@ubuntu:~#wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.17.8.tar.gz

 

(2)解压

root@ubuntu:~#tar -zxvf linux-3.17.8.tar.gz

 

(3)备份

root@ubuntu:~#cp linux-4.9.2/drivers/rtc/rtc-s3c.c linux-4.9.2/drivers/rtc/rtc-s3c_backup.c

 

(4)替换驱动

cplinux-3.17.8/drivers/rtc/rtc-s3c.c linux-4.9.2/drivers/rtc/

 

(5)编译

root@ubuntu:~#cd linux-4.9.2/

root@ubuntu:~/linux-4.9.2#make -j8

root@ubuntu:~/linux-4.9.2#./mkuImage.sh

 

(6)重启开发板

Starting kernel...

 

Booting Linux onphysical CPU 0x0

Linux version4.9.2 (root@ubuntu) (gcc version 6.3.0 20170406 (Ubuntu/Linaro 6.3.0-12ubuntu2)) #12 Wed Sep 27 22:39:58 PDT 2017

CPU: ARM920T[41129200] revision 0 (ARMv4T), cr=c000717f

CPU: VIVT datacache, VIVT instruction cache

Machine:Mini2440 development board

Memory policy:Data cache writeback

CPU S3C2440A (id0x32440001)

Built 1zonelists in Zone order, mobility grouping on. Total pages: 16256

Kernel commandline: console=ttySAC0,115200 root=/dev/nfsnfsroot=192.168.2.104:/root/NFS/rootfsip=192.168.2.188:192.168.2.104:192.168.2.1:255.255.255.0:SMDK2440A.arm9.net:eth0:offinit=/linuxrc

PID hash tableentries: 256 (order: -2, 1024 bytes)

Dentry cachehash table entries: 8192 (order: 3, 32768 bytes)

Inode-cache hashtable entries: 4096 (order: 2, 16384 bytes)

Memory:58756K/65536K available (4379K kernel code, 177K rwdata, 996K rodata, 176Kinit, 259K bss, 6780K reserved, 0K cma-reserved)

Virtual kernelmemory layout:

    vector : 0xffff0000 - 0xffff1000   (   4 kB)

    fixmap : 0xffc00000 - 0xfff00000   (3072kB)

    vmalloc : 0xc4800000 - 0xff800000   ( 944 MB)

    lowmem : 0xc0000000 - 0xc4000000   (  64 MB)

    modules : 0xbf000000 - 0xc0000000   (  16MB)

      .text : 0xc0008000 - 0xc044efd0   (4380 kB)

      .init : 0xc0568000 - 0xc0594000   ( 176 kB)

      .data : 0xc0594000 - 0xc05c07c0   ( 178 kB)

       .bss : 0xc05c07c0 - 0xc0601400   ( 260 kB)

SLUB:HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1

NR_IRQS:103

S3C2440: IRQSupport

irq: clearingpending status 00000002

sched_clock: 16bits at 1012kHz, resolution 987ns, wraps every 32362962ns

clocksource:samsung_clocksource_timer: mask: 0xffff max_cycles: 0xffff, max_idle_ns:28803037 ns

Console: colourdummy device 80x30

Calibratingdelay loop... 201.52 BogoMIPS (lpj=503808)

pid_max:default: 32768 minimum: 301

Mount-cache hashtable entries: 1024 (order: 0, 4096 bytes)

Mountpoint-cachehash table entries: 1024 (order: 0, 4096 bytes)

CPU: Testingwrite buffer coherency: ok

Setting upstatic identity map for 0x300081e0 - 0x30008238

clocksource:jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 9556302231375000ns

NET: Registeredprotocol family 16

DMA:preallocated 256 KiB pool for atomic coherent allocations

cpuidle: usinggovernor ladder

S3C2440:Initialising architecture

usbcore:registered new interface driver usbfs

usbcore:registered new interface driver hub

usbcore:registered new device driver usb

s3c-i2cs3c2440-i2c.0: slave address 0x10

s3c-i2cs3c2440-i2c.0: bus frequency set to 98 KHz

s3c-i2cs3c2440-i2c.0: i2c-0: S3C I2C adapter

Advanced LinuxSound Architecture Driver Initialized.

clocksource:Switched to clocksource samsung_clocksource_timer

NET: Registeredprotocol family 2

TCP establishedhash table entries: 1024 (order: 0, 4096 bytes)

TCP bind hashtable entries: 1024 (order: 0, 4096 bytes)

TCP: Hash tablesconfigured (established 1024 bind 1024)

UDP hash tableentries: 256 (order: 0, 4096 bytes)

UDP-Lite hashtable entries: 256 (order: 0, 4096 bytes)

NET: Registeredprotocol family 1

RPC: Registerednamed UNIX socket transport module.

RPC: Registeredudp transport module.

RPC: Registeredtcp transport module.

RPC: Registeredtcp NFSv4.1 backchannel transport module.

futex hash tableentries: 256 (order: -1, 3072 bytes)

workingset:timestamp_bits=30 max_order=14 bucket_order=0

NFS: Registeringthe id_resolver key type

Key typeid_resolver registered

Key typeid_legacy registered

jffs2: version2.2. (NAND) © 2001-2006 Red Hat, Inc.

romfs: ROMFS MTD(C) 2007 Red Hat, Inc.

io schedulernoop registered

io schedulerdeadline registered

io scheduler cfqregistered (default)

Console:switching to colour frame buffer device 60x53

s3c2410-lcds3c2410-lcd: fb0: s3c2410fb frame buffer device

s3c2440-uart.0:ttySAC0 at MMIO 0x50000000 (irq = 74, base_baud = 0) is a S3C2440

console[ttySAC0] enabled

s3c2440-uart.1:ttySAC1 at MMIO 0x50004000 (irq = 77, base_baud = 0) is a S3C2440

s3c2440-uart.2:ttySAC2 at MMIO 0x50008000 (irq = 80, base_baud = 0) is a S3C2440

brd: moduleloaded

s3c24xx-nands3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns

s3c24xx-nands3c2440-nand: NAND soft ECC

nand: devicefound, Manufacturer ID: 0xec, Chip ID: 0xda

nand: SamsungNAND 256MiB 3,3V 8-bit

nand: 256 MiB,SLC, erase size: 128 KiB, page size: 2048, OOB size: 64

Scanning devicefor bad blocks

Bad eraseblock1620 at 0x00000ca80000

Bad eraseblock1935 at 0x00000f1e0000

Creating 5 MTDpartitions on "NAND":

0x000000000000-0x000000040000: "boot"

0x000000040000-0x000000060000: "param"

0x000000060000-0x000000560000: "kernel"

0x000000560000-0x000006960000: "rootfs"

0x000000000000-0x000010000000: "nand"

eth0: dm9000e atc4a5b300,c4a5d304 IRQ 55 MAC: 08:00:3e:26:0a:5b (chip)

ohci_hcd: USB1.1 'Open' Host Controller (OHCI) Driver

ohci-s3c2410:OHCI S3C2410 driver

s3c2410-ohcis3c2410-ohci: OHCI Host Controller

s3c2410-ohcis3c2410-ohci: new USB bus registered, assigned bus number 1

s3c2410-ohcis3c2410-ohci: irq 42, io mem 0x49000000

random: fastinit done

hub 1-0:1.0: USBhub found

hub 1-0:1.0: 2ports detected

mousedev: PS/2mouse device common for all mice

s3c-rtcs3c2410-rtc: rtc disabled, re-enabling

s3c-rtcs3c2410-rtc: rtc core: registered s3c as rtc0

i2c /dev entriesdriver

s3c2410-wdts3c2410-wdt: watchdog inactive, reset disabled, irq disabled

sdhci: SecureDigital Host Controller Interface driver

sdhci:Copyright(c) Pierre Ossman

hidraw: raw HIDevents driver (C) Jiri Kosina

usbcore:registered new interface driver usbhid

usbhid: USB HIDcore driver

NET: Registeredprotocol family 17

Key typedns_resolver registered

s3c-rtc s3c2410-rtc: setting system clock to 2017-09-2813:55:16 UTC (1506606916)

dm9000 dm9000eth0: link down

dm9000 dm9000eth0: link up, 100Mbps, full-duplex, lpa 0x45E1

IP-Config:Complete:

     device=eth0, hwaddr=08:00:3e:26:0a:5b,ipaddr=192.168.2.188, mask=255.255.255.0, gw=192.168.2.1

     host=SMDK2440A, domain=, nis-domain=arm9.net

     bootserver=192.168.2.104,rootserver=192.168.2.104, rootpath=

ALSA devicelist:

  No soundcards found.

VFS: Mountedroot (nfs filesystem) on device 0:12.

Freeing unusedkernel memory: 176K (c0568000 - c0594000)

Thisarchitecture does not have kernel memory protection.

mount: mountingnone on /proc/bus/usb failed: No such file or directory

/etc/init.d/rcS:line 39: /etc/rc.d/init.d/netd: Input/output error

/etc/init.d/rcS:line 43: /etc/rc.d/init.d/httpd: Input/output error

/etc/init.d/rcS:line 47: /etc/rc.d/init.d/leds: Input/output error

                       

 

Please pressEnter to activate this console. /bin/qtopia: line 22: can't create/etc/pointercal: Permission denied

random: crnginit done

 

可以看到RTC已经正常运行了

 

在secureCRT按回车,输入hwclock

[root@FriendlyARM/]# hwclock

Thu Sep 2813:58:13 2017  0.000000 seconds

没问题。

新版的RTC驱动应该是需要修改才能用,可以对比一下drivers/rtc/rtc-s3c.c在linux4.9.2与linux3.17.8这两个版本有什么不同,应该就是需要修改的关键了。

阅读全文
0 0