AM335x(TQ335x)學習筆記——Nand&&網卡驅動移植,am335xtq335x
移植完成音效卡驅動之後本想再接再勵,移植網卡驅動,但沒想到的是TI維護的核心太健壯,移植網卡驅動跟之前移植按鍵驅動一樣簡單,Nand驅動也是如此,於是,本人將Nand和網卡放在同一篇文章中介紹。介紹之前先感慨一下:TI的維護的核心真的很健壯,DTS真的很強大。
1. Nand驅動移植
閱讀TQ335x的原理圖可知,TQ335x的Nand串連到了GPMC上,且都是使用的相應引腳的MODE0複用功能,AM335x上上電複位後這些引腳的預設狀態就處於MODE0模式,故無需進行pinmux設定,原始的DTS中pinmux僅有一條:
0x160 (PIN_INPUT | MUX_MODE7) /* spi0_cs1.gpio0_6 */
此處不做任何修改,直接編譯核心,並放到開發板上運行會發現核心可以識別Nand但是因為沒有開啟OMAP的BCH功能,該項配置需要在核心配置項中進行配置,配置方式如下:
Device Drivers ---><*> Memory Technology Device (MTD) support ---><*> NAND Device Support ---><*> Support hardware based BCH error correction
儲存配置並退出menuconfig,然後重新編譯核心並放到開發板上運行,此時會發現核心已經可以正常識別Nand了,完整的啟動Log會在文章末尾給出。從這裡可以看出,TI的核心維護的真的很不錯,比以前移植三星晶片時省事很多。
2. 網卡驅動移植
進行網卡驅動移植的方法與進行Nand驅動移植的方法相同,邏輯上講,先應該去確認下網卡的引腳串連並在DTS中進行相應的pinmux設定,但是,移植完Nand後查看核心的啟動Log可知,網卡已經正常識別了,因此,可以直接執行指令:
udhcpc
來動態擷取ip(需要將開發板通過網線串連到路由器並開啟路由器的DHCP功能,預設一般是開啟的),會發現開發板能夠從路由器分配到IP,但是沒有分配DNS,這是因為我們只做檔案系統時沒有進行dhcp的設定。設定方法很簡單,將busybox中的examples/udhcp/simple.script拷貝到根檔案系統的usr/share/udhcpc/目錄下,並改名為default.script即可。然後重新執行:
udhcpc
會發現開發板可以正常擷取到IP和DNS,但是仍有一處錯誤,詳細如下:
@tq335x #udhcpc udhcpc (v1.22.1) startedSetting IP address 0.0.0.0 on eth0[ 11.489311] net eth0: initializing cpsw version 1.12 (0)[ 11.576237] net eth0: phy found : id is : 0x1cc915<span style="color:#ff0000;">[ 11.581418] libphy: PHY 4a101000.mdio:01 not found[ 11.586480] net eth0: phy 4a101000.mdio:01 not found on slave 1</span>Sending discover...[ 13.576458] cpsw 4a100000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/txSending discover...Sending select for 192.168.0.103...Lease of 192.168.0.103 obtained, lease time 86400Setting IP address 192.168.0.103 on eth0Deleting routersroute: SIOCDELRT: No such processAdding router 192.168.0.1Recreating /etc/resolv.conf Adding DNS server 10.0.0.1
標記紅色的文字即錯誤所在,參考TI官網提供的evm開發板的dts,本文對tq335x.dts做如下修改:
&mac { <span style="color:#ff0000;">slaves = <1>;</span> pinctrl-names = "default", "sleep"; pinctrl-0 = <&cpsw_default>; pinctrl-1 = <&cpsw_sleep>; status = "okay";};
然後刪除以下節點:
&cpsw_emac1 { phy_id = <&davinci_mdio>, <1>; phy-mode = "rgmii-txid";};
重新編譯tq335x.dtb:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- tq335x.dtb
用新的tq335x.dtb啟動開發板:
load mmc 0:1 0x88000000 /boot/tq335x.dtbload mmc 0:1 0x82000000 /boot/zImagebootz 0x82000000 - 0x88000000
最後,再次使用指令:
udhcpc
進行測試,會發現開發板能夠正常擷取IP和DNS。如果您的路由器已經串連到了外網,還可以使用ping指令測試與外網的串連,如pingGoogle的DNS伺服器:
ping 8.8.8.8
至此,就完成了TQ335x的Nand和網卡驅動移植,並不需要深入的瞭解其內部的工作原理,有問題可以留言討論。如果想瞭解這兩個模組的工作原理,強烈推薦韋東山老師的嵌入式教學視頻,靜下心來看的話,絕對物有所值。該視頻還是需要一定的硬體和軟體功底的,如果看不懂可以補習下C語言、基本原理圖閱讀等方面的知識。
3. 啟動Log
完整的啟動Log如下:
Starting kernel ...[ 0.000000] Booting Linux on physical CPU 0x0[ 0.000000] Linux version 3.17.2 (lilianrong@smarter) (gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-12ubuntu1) ) #73 SMP Tue Dec 23 22:06:01 CST 2014[ 0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c5387d[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache[ 0.000000] Machine model: TI AM335x EVM[ 0.000000] cma: Reserved 16 MiB at 9e800000[ 0.000000] Memory policy: Data cache writeback[ 0.000000] HighMem zone: 1048574 pages exceeds freesize 0[ 0.000000] CPU: All CPU(s) started in SVC mode.[ 0.000000] AM335X ES2.1 (sgx neon )[ 0.000000] PERCPU: Embedded 9 pages/cpu @dfa99000 s14336 r8192 d14336 u36864[ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 129792[ 0.000000] Kernel command line: console=ttyO0,115200n8 root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait[ 0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)[ 0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)[ 0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)[ 0.000000] Memory: 484108K/523264K available (6082K kernel code, 667K rwdata, 2448K rodata, 410K init, 8214K bss, 39156K reserved, 0K highmem)[ 0.000000] Virtual kernel memory layout:[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)[ 0.000000] fixmap : 0xffc00000 - 0xffe00000 (2048 kB)[ 0.000000] vmalloc : 0xe0800000 - 0xff000000 ( 488 MB)[ 0.000000] lowmem : 0xc0000000 - 0xe0000000 ( 512 MB)[ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)[ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB)[ 0.000000] .text : 0xc0008000 - 0xc085cc80 (8532 kB)[ 0.000000] .init : 0xc085d000 - 0xc08c3800 ( 410 kB)[ 0.000000] .data : 0xc08c4000 - 0xc096ac10 ( 668 kB)[ 0.000000] .bss : 0xc096ac10 - 0xc11707a0 (8215 kB)[ 0.000000] Hierarchical RCU implementation.[ 0.000000] RCU restricting CPUs from NR_CPUS=2 to nr_cpu_ids=1.[ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1[ 0.000000] NR_IRQS:16 nr_irqs:16 16[ 0.000000] IRQ: Found an INTC at 0xfa200000 (revision 5.0) with 128 interrupts[ 0.000000] Total of 128 interrupts on 1 active controller[ 0.000000] OMAP clockevent source: timer2 at 24000000 Hz[ 0.000013] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 178956969942ns[ 0.000062] OMAP clocksource: timer1 at 24000000 Hz[ 0.000794] Console: colour dummy device 80x30[ 0.000846] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar[ 0.000855] ... MAX_LOCKDEP_SUBCLASSES: 8[ 0.000863] ... MAX_LOCK_DEPTH: 48[ 0.000870] ... MAX_LOCKDEP_KEYS: 8191[ 0.000877] ... CLASSHASH_SIZE: 4096[ 0.000884] ... MAX_LOCKDEP_ENTRIES: 32768[ 0.000891] ... MAX_LOCKDEP_CHAINS: 65536[ 0.000898] ... CHAINHASH_SIZE: 32768[ 0.000906] memory used by lock dependency info: 5167 kB[ 0.000914] per task-struct memory footprint: 1152 bytes[ 0.000956] Calibrating delay loop... 996.14 BogoMIPS (lpj=4980736)[ 0.079052] pid_max: default: 32768 minimum: 301[ 0.079452] Security Framework initialized[ 0.079577] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)[ 0.079589] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)[ 0.081767] CPU: Testing write buffer coherency: ok[ 0.082936] CPU0: thread -1, cpu 0, socket -1, mpidr 0[ 0.083055] Setting up static identity map for 0x805c3270 - 0x805c32e0[ 0.086292] Brought up 1 CPUs[ 0.086313] SMP: Total of 1 processors activated.[ 0.086323] CPU: All CPU(s) started in SVC mode.[ 0.088953] devtmpfs: initialized[ 0.097712] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 3[ 0.133428] omap_hwmod: tptc0 using broken dt data from edma[ 0.133784] omap_hwmod: tptc1 using broken dt data from edma[ 0.134117] omap_hwmod: tptc2 using broken dt data from edma[ 0.141998] omap_hwmod: debugss: _wait_target_disable failed[ 0.199949] pinctrl core: initialized pinctrl subsystem[ 0.202465] regulator-dummy: no parameters[ 0.232121] NET: Registered protocol family 16[ 0.240699] DMA: preallocated 256 KiB pool for atomic coherent allocations[ 0.242951] cpuidle: using governor ladder[ 0.242981] cpuidle: using governor menu[ 0.254980] OMAP GPIO hardware version 0.1[ 0.270240] omap-gpmc 50000000.gpmc: could not find pctldev for node /pinmux@44e10800/nandflash_pins_s0, deferring probe[ 0.270283] platform 50000000.gpmc: Driver omap-gpmc requests probe deferral[ 0.274806] hw-breakpoint: debug architecture 0x4 unsupported.[ 0.319718] edma-dma-engine edma-dma-engine.0: TI EDMA DMA engine driver[ 0.321050] vbat: 5000 mV [ 0.321878] lis3_reg: no parameters[ 0.325259] SCSI subsystem initialized[ 0.326052] usbcore: registered new interface driver usbfs[ 0.326223] usbcore: registered new interface driver hub[ 0.330168] usbcore: registered new device driver usb[ 0.330998] omap_i2c 44e0b000.i2c: could not find pctldev for node /pinmux@44e10800/pinmux_i2c0_pins, deferring probe[ 0.331037] platform 44e0b000.i2c: Driver omap_i2c requests probe deferral[ 0.331092] omap_i2c 4802a000.i2c: could not find pctldev for node /pinmux@44e10800/pinmux_i2c1_pins, deferring probe[ 0.331116] platform 4802a000.i2c: Driver omap_i2c requests probe deferral[ 0.332291] Advanced Linux Sound Architecture Driver Initialized.[ 0.335642] Switched to clocksource timer1[ 0.487189] NET: Registered protocol family 2[ 0.489058] TCP established hash table entries: 4096 (order: 2, 16384 bytes)[ 0.489243] TCP bind hash table entries: 4096 (order: 5, 147456 bytes)[ 0.490606] TCP: Hash tables configured (established 4096 bind 4096)[ 0.490797] TCP: reno registered[ 0.490823] UDP hash table entries: 256 (order: 2, 20480 bytes)[ 0.491013] UDP-Lite hash table entries: 256 (order: 2, 20480 bytes)[ 0.492039] NET: Registered protocol family 1[ 0.493915] RPC: Registered named UNIX socket transport module.[ 0.493936] RPC: Registered udp transport module.[ 0.493946] RPC: Registered tcp transport module.[ 0.493955] RPC: Registered tcp NFSv4.1 backchannel transport module.[ 0.495229] hw perfevents: enabled with armv7_cortex_a8 PMU driver, 5 counters available[ 0.499735] futex hash table entries: 256 (order: 2, 16384 bytes)[ 0.504791] VFS: Disk quotas dquot_6.5.2[ 0.504950] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)[ 0.507753] NFS: Registering the id_resolver key type[ 0.508115] Key type id_resolver registered[ 0.508132] Key type id_legacy registered[ 0.508279] jffs2: version 2.2. (NAND) (SUMMARY) 漏 2001-2006 Red Hat, Inc.[ 0.508729] msgmni has been set to 977[ 0.513651] io scheduler noop registered[ 0.513685] io scheduler deadline registered[ 0.513753] io scheduler cfq registered (default)[ 0.516150] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568[ 0.521255] backlight supply power not found, using dummy regulator[ 0.524492] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled[ 0.530892] omap_uart 44e09000.serial: no wakeirq for uart0[ 0.531504] 44e09000.serial: ttyO0 at MMIO 0x44e09000 (irq = 88, base_baud = 3000000) is a OMAP UART0[ 1.232153] console [ttyO0] enabled[ 1.241558] omap_rng 48310000.rng: OMAP Random Number Generator ver. 20[ 1.249198] [drm] Initialized drm 1.1.0 20060810[ 1.261409] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).[ 1.268521] [drm] No driver support for vblank timestamp query.[ 1.331152] Console: switching to colour frame buffer device 100x30[ 1.342247] tilcdc 4830e000.lcdc: fb0: frame buffer device[ 1.348135] tilcdc 4830e000.lcdc: registered panic notifier[ 1.354036] [drm] Initialized tilcdc 1.0.0 20121205 on minor 0[ 1.389964] brd: module loaded[ 1.408309] loop: module loaded[ 1.414443] mtdoops: mtd device (mtddev=name/number) must be supplied[ 1.425081] usbcore: registered new interface driver asix[ 1.430985] usbcore: registered new interface driver ax88179_178a[ 1.437512] usbcore: registered new interface driver cdc_ether[ 1.443772] usbcore: registered new interface driver smsc95xx[ 1.449928] usbcore: registered new interface driver net1080[ 1.455981] usbcore: registered new interface driver cdc_subset[ 1.462281] usbcore: registered new interface driver zaurus[ 1.468354] usbcore: registered new interface driver cdc_ncm[ 1.476438] usbcore: registered new interface driver cdc_wdm[ 1.482554] usbcore: registered new interface driver usb-storage[ 1.489102] usbcore: registered new interface driver usbtest[ 1.497261] mousedev: PS/2 mouse device common for all mice[ 1.508204] omap_rtc 44e3e000.rtc: rtc core: registered 44e3e000.rtc as rtc0[ 1.516418] i2c /dev entries driver[ 1.520156] Driver for 1-wire Dallas network protocol.[ 1.533123] omap_wdt: OMAP Watchdog Timer Rev 0x01: initial timeout 60 sec[ 1.543243] omap_hsmmc 48060000.mmc: unable to get vmmc regulator -517[ 1.550707] platform 48060000.mmc: Driver omap_hsmmc requests probe deferral[ 1.560219] ledtrig-cpu: registered to indicate activity on CPUs[ 1.567132] usbcore: registered new interface driver usbhid[ 1.572953] usbhid: USB HID core driver[ 1.584275] davinci_evm sound: ASoC: CODEC (null) not registered[ 1.591095] davinci_evm sound: snd_soc_register_card failed (-517)[ 1.597727] platform sound: Driver davinci_evm requests probe deferral[ 1.605542] oprofile: using arm/armv7[ 1.610156] TCP: cubic registered[ 1.613633] Initializing XFRM netlink socket[ 1.618345] NET: Registered protocol family 17[ 1.623080] NET: Registered protocol family 15[ 1.628155] Key type dns_resolver registered[ 1.632833] omap_voltage_late_init: Voltage driver support not added[ 1.639539] sr_dev_init: No voltage domain specified for smartreflex0. Cannot initialize[ 1.648011] sr_dev_init: No voltage domain specified for smartreflex1. Cannot initialize[ 1.657602] ThumbEE CPU extension supported.[ 1.662123] Registering SWP/SWPB emulation handler[ 1.667204] SmartReflex Class3 initialized[ 1.679204] omap-gpmc 50000000.gpmc: GPMC revision 6.0[ 1.686359] nand: device found, Manufacturer ID: 0xec, Chip ID: 0xd3[ 1.693006] nand: Samsung NAND 1GiB 3,3V 8-bit[ 1.697702] nand: 1024MiB, SLC, page size: 2048, OOB size: 64[ 1.703702] nand: using OMAP_ECC_BCH8_CODE_HW ECC scheme[ 1.709544] 10 ofpart partitions found on MTD device omap2-nand.0[ 1.715935] Creating 10 MTD partitions on "omap2-nand.0":[ 1.721581] 0x000000000000-0x000000020000 : "NAND.SPL"[ 1.738760] 0x000000020000-0x000000040000 : "NAND.SPL.backup1"[ 1.750072] 0x000000040000-0x000000060000 : "NAND.SPL.backup2"[ 1.759540] 0x000000060000-0x000000080000 : "NAND.SPL.backup3"[ 1.770709] 0x000000080000-0x0000000c0000 : "NAND.u-boot-spl"[ 1.780999] 0x0000000c0000-0x0000001c0000 : "NAND.u-boot"[ 1.794193] 0x0000001c0000-0x0000001e0000 : "NAND.u-boot-env"[ 1.803810] 0x0000001e0000-0x000000200000 : "NAND.u-boot-env.backup1"[ 1.815705] 0x000000200000-0x000000a00000 : "NAND.kernel"[ 1.831741] 0x000000a00000-0x000010000000 : "NAND.file-system"[ 2.128744] tps65910 0-002d: No interrupt support, no core IRQ[ 2.145804] vrtc: 1800 mV [ 2.149201] vrtc: supplied by vbat[ 2.156403] vio: at 1500 mV [ 2.159674] vio: supplied by vbat[ 2.166535] vdd_mpu: 912 <--> 1312 mV at 1325 mV [ 2.171674] vdd_mpu: supplied by vbat[ 2.178847] vdd_core: 912 <--> 1150 mV at 1137 mV [ 2.184071] vdd_core: supplied by vbat[ 2.190808] vdd3: 5000 mV [ 2.196352] vdig1: at 1800 mV [ 2.199763] vdig1: supplied by vbat[ 2.206242] vdig2: at 1800 mV [ 2.209646] vdig2: supplied by vbat[ 2.216312] vpll: at 1800 mV [ 2.219632] vpll: supplied by vbat[ 2.226021] vdac: at 1800 mV [ 2.229339] vdac: supplied by vbat[ 2.235593] vaux1: at 1800 mV [ 2.238998] vaux1: supplied by vbat[ 2.245289] vaux2: at 3300 mV [ 2.248809] vaux2: supplied by vbat[ 2.255223] vaux33: at 3300 mV [ 2.258804] vaux33: supplied by vbat[ 2.265220] vmmc: 1800 <--> 3300 mV at 3300 mV [ 2.270279] vmmc: supplied by vbat[ 2.276822] vbb: at 3000 mV [ 2.280309] vbb: supplied by vbat[ 2.288030] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz[ 2.301649] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 100 kHz[ 2.347377] wm8960 0-001a: No platform data supplied[ 2.424716] mmc0: host does not support reading read-only switch. assuming write-enable.[ 2.436373] mmc0: new high speed SDHC card at address aaaa[ 2.444716] mmcblk0: mmc0:aaaa SL16G 14.8 GiB [ 2.456727] mmcblk0: p1 p2[ 2.471831] davinci_evm sound: wm8960-hifi <-> 4803c000.mcasp mapping ok[ 2.555784] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6[ 2.562174] davinci_mdio 4a101000.mdio: detected phy mask ffffffde[ 2.572385] libphy: 4a101000.mdio: probed[ 2.576709] davinci_mdio 4a101000.mdio: phy[0]: device 4a101000.mdio:00, driver unknown[ 2.585071] davinci_mdio 4a101000.mdio: phy[5]: device 4a101000.mdio:05, driver unknown[ 2.594702] cpsw 4a100000.ethernet: Detected MACID = c4:ed:ba:88:b5:e4[ 2.606568] input: gpio_keyad@0 as /devices/gpio_keyad@0/input/input0[ 2.616308] omap_rtc 44e3e000.rtc: setting system clock to 2000-01-01 00:00:00 UTC (946684800)[ 2.625329] sr_init: No PMIC hook to init smartreflex[ 2.630961] sr_init: platform driver register failed for SR[ 2.653937] lis3_reg: disabling[ 2.657604] ALSA device list:[ 2.660710] #0: AM335x-EVM[ 2.779242] kjournald starting. Commit interval 5 seconds[ 2.787736] EXT3-fs (mmcblk0p2): using internal journal[ 2.795710] EXT3-fs (mmcblk0p2): recovery complete[ 2.800726] EXT3-fs (mmcblk0p2): mounted filesystem with ordered data mode[ 2.808089] VFS: Mounted root (ext3 filesystem) on device 179:2.[ 2.818461] devtmpfs: mounted[ 2.822292] Freeing unused kernel memory: 408K (c085d000 - c08c3000)----------mount all..........----------Starting mdev......Please press Enter to activate this console. @tq335x #@tq335x #udhcpc udhcpc (v1.22.1) startedSetting IP address 0.0.0.0 on eth0[ 11.489311] net eth0: initializing cpsw version 1.12 (0)[ 11.576237] net eth0: phy found : id is : 0x1cc915[ 11.581418] libphy: PHY 4a101000.mdio:01 not found[ 11.586480] net eth0: phy 4a101000.mdio:01 not found on slave 1Sending discover...[ 13.576458] cpsw 4a100000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/txSending discover...Sending select for 192.168.0.103...Lease of 192.168.0.103 obtained, lease time 86400Setting IP address 192.168.0.103 on eth0Deleting routersroute: SIOCDELRT: No such processAdding router 192.168.0.1Recreating /etc/resolv.conf Adding DNS server 10.0.0.1@tq335x #ping 8.8.8.8PING 8.8.8.8 (8.8.8.8): 56 data bytes64 bytes from 8.8.8.8: seq=0 ttl=38 time=471.858 ms64 bytes from 8.8.8.8: seq=1 ttl=38 time=479.178 ms64 bytes from 8.8.8.8: seq=3 ttl=38 time=574.362 ms64 bytes from 8.8.8.8: seq=4 ttl=38 time=476.201 ms^C--- 8.8.8.8 ping statistics ---5 packets transmitted, 4 packets received, 20% packet lossround-trip min/avg/max = 471.858/500.399/574.362 ms@tq335x #
本文作者:girlkoo
本文串連:http://blog.csdn.net/girlkoo/article/details/42110683