NXP

i.MX6DL学习记录---kernel移植

2019-07-12 12:05发布

软件版本:uboot-2013-04 + kernel-3.10.35 硬件版本:i.MX6DL-Sabreasd
准备工作 移植kernel和uboot差不多,由于这里下载的是freescale官网维护的kernel版本,所以工作量不是很大,找到对应的config文件,参照自己的硬件修改对应的源码即可,在arch/arm/configs中可以找到这里需要的配置文件,因为imx6dl是一款ARMv7框架的芯片,所以这里的配置文件是imx_v7_config。以前接触的kernel都是使用传统的ATAGS方式传递内核参数,这次使用的kernel-3.10.35引进了一个新的概念DeviceTree,据说是从kernel3.x之后就开始实行了,有兴趣的可以去了解下。
在实行新的DTB方式传递内核参数后驱动源码的结构就更加清晰了,省去了设备注册这部分重复的代码,代替以前的设备注册,改成了arch/arm/boot/dts目录下的.dts文件了。在这个目录下找到对应板子的.dts文件imx6dl-sabresd.dts,在这个文件中就实现了一个i2c设备注册,但包含了一系列.dtsi文件,类似于include “xxx.h”一样 /dts-v1/; #include "imx6dl.dtsi" #include "imx6qdl-sabresd.dtsi" #include "imx6dl-sabresd-common.dtsi" / { model = "Freescale i.MX6 DualLite SABRE Smart Device Board(PFUZE100)"; compatible = "fsl,imx6dl-sabresd", "fsl,imx6dl"; }; 需要修改设备注册文件imx6qdl-sabresd.dtsi  和引脚定义文件imx6qdl.dtsi,在后面各个设备驱动的移植添加会大量修改这两个文件
内核移植 既然是freescale维护的内核,而且这里使用的board也和官网demo板差不多,所以即使不做任何修改也能在机器上跑起来。这里修改下SD3引脚以支持SD卡存储,为后面挂载文件系统做准备。 1》修改CD引脚 --- a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi +++ b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi @@ -637,9 +637,9 @@ &usdhc3 { pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_usdhc3_1>; - cd-gpios = <&gpio2 0 0>; - wp-gpios = <&gpio2 1 0>; + pinctrl-0 = <&pinctrl_usdhc3_2>; /*板载SD3使用的是4PIN数据线,在imx6qdl.dtsi中已经定义好了*/ + cd-gpios = <&gpio1 6 0>; + bus-width = <4>; no-1-8-v; keep-power-in-suspend; enable-sdio-wakeup;
2》使用DTB 由于官方默认方式是使用传统的ATAGS方式传递内核参数的,但为了提高开发效率,本文还是使用了新的DTB方式传递内核参数。为此,需要配置内核,关闭老式ATAGS方式内核参数传递的支持。 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1859,7 +1859,7 @@ config USE_OF config ATAGS bool "Support for the traditional ATAGS boot data passing" if USE_OF - default y + default n help This is the traditional way of passing data to the kernel at boot time. If you are solely relying on the flattened device tree (or 将默认的ATAGS方式失能

3》编译内核 #!/bin/bash export ARCH=arm export CROSS_COMPILE=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi- #make distclean; make imx_v7_defconfig make imx6dl-sabresd.dtb make uImage LOADADDR=0x12000000
4》烧录镜像 #!/bin/sh sudo dd if=uImage of=/dev/sdx bs=512 seek=2048 conv=fsync sudo dd if=./dts/imx6dl-sabresd.dtb of=/dev/sdx bs=512 seek=20480 conv=fsync
启动内核 将SD卡插到开发板后给开发板上电,按任意键打断uboot启动,并按如下内容配置uboot环境变量。
setenv bootargs 'noinitrd console=ttymxc0,115200 root=/dev/mmcblk2p1 rw init=/linuxrc' setenv bootcmd 'mmc dev 1; mmc read 0x11ffffc0 0x800 0x3000; mmc read 0x18000000 0x5000 0x800; bootm 0x11ffffc0 - 0x18000000' saveenvrun bootcmd
启动log如下: U-Boot 2013.04-04989-g6bb0820-dirty (Jul 25 2016 - 10:31:08) CPU: Freescale i.MX6DL rev1.1 at 792 MHz CPU: Temperature 54 C, calibration data: 0x5aa50e69 Reset cause: POR Board: MX6Q/SDL-SabreSD I2C: ready DRAM: 1 GiB MMC: FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2 No panel detected: default to Hannstar-XGA Display: Hannstar-XGA (1024x768) In: serial Out: serial Err: serial mmc1 is current device Net: Phy not found PHY reset timed out FEC [PRIME] Warning: failed to set MAC address Normal Boot Hit any key to stop autoboot: 0 mmc1 is current device MMC read: dev # 1, block # 2048, count 12288 ... 12288 blocks read: OK MMC read: dev # 1, block # 20480, count 2048 ... 2048 blocks read: OK ## Booting kernel from Legacy Image at 11ffffc0 ... Image Name: Linux-3.10.53-84330-g1409f05-dir Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 5590960 Bytes = 5.3 MiB Load Address: 12000000 Entry Point: 12000000 Verifying Checksum ... OK ## Flattened Device Tree blob at 18000000 Booting using the fdt blob at 0x18000000 XIP Kernel Image ... OK OK Read SW1AB error! Using Device Tree in place at 18000000, end 1800f378 Starting kernel ... Booting Linux on physical CPU 0x0 Linux version 3.10.53-84330-g1409f05-dirty (robin@Grandtelco) #19 SMP PREEMPT Thu Jul 28 11:52:43 CST 2016 CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c53c7d CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache Machine: Freescale i.MX6 Quad/DualLite (Device Tree), model: Freescale i.MX6 DualLite SABRE Smart Device Board(PFUZE100) cma: CMA: reserved 320 MiB at 3c000000 Memory policy: ECC disabled, Data cache writealloc PERCPU: Embedded 8 pages/cpu @81593000 s8960 r8192 d15616 u32768 Built 1 zonelists in Zone order, mobility grouping on. Total pages: 260096 Kernel command line: noinitrd console=ttymxc0,115200 root=/dev/mmcblk0p1 rw init=/linuxrc PID hash table entries: 4096 (order: 2, 16384 bytes) Dentry cache hash table entries: 131072 (order: 7, 524288 bytes) Inode-cache hash table entries: 65536 (order: 6, 262144 bytes) Memory: 1024MB = 1024MB total Memory: 697228k/697228k available, 351348k reserved, 0K highmem Virtual kernel memory layout: vector : 0xffff0000 - 0xffff1000 ( 4 kB) fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB) vmalloc : 0xc0800000 - 0xff000000 (1000 MB) lowmem : 0x80000000 - 0xc0000000 (1024 MB) pkmap : 0x7fe00000 - 0x80000000 ( 2 MB) modules : 0x7f000000 - 0x7fe00000 ( 14 MB) .text : 0x80008000 - 0x80c6e6b4 (12698 kB) .init : 0x80c6f000 - 0x80cb9300 ( 297 kB) .data : 0x80cba000 - 0x80d10fc0 ( 348 kB) .bss : 0x80d10fc0 - 0x80d7a0e4 ( 421 kB) SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1 Preemptible hierarchical RCU implementation. RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2. NR_IRQS:16 nr_irqs:16 16 L310 cache controller enabled l2x0: 16 ways, CACHE_ID 0x410000c8, AUX_CTRL 0x32050000, Cache size: 524288 B sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 1431655ms CPU identified as i.MX6DL, silicon rev 1.1 Console: colour dummy device 80x30 Calibrating delay loop... 1581.05 BogoMIPS (lpj=7905280) pid_max: default: 32768 minimum: 301 Mount-cache hash table entries: 512 CPU: Testing write buffer coherency: ok CPU0: thread -1, cpu 0, socket 0, mpidr 80000000 Setting up static identity map for 0x806800e0 - 0x80680138 CPU1: Booted secondary processor CPU1: thread -1, cpu 1, socket 0, mpidr 80000001 Brought up 2 CPUs SMP: Total of 2 processors activated (3162.11 BogoMIPS). CPU: All CPU(s) started in SVC mode. devtmpfs: initialized pinctrl core: initialized pinctrl subsystem regulator-dummy: no parameters NET: Registered protocol family 16 DMA: preallocated 256 KiB pool for atomic coherent allocations Use WDOG2 as reset source syscon 20c8000.anatop: regmap [mem 0x020c8000-0x020c8fff] registered vdd1p1: 800 <--> 1375 mV at 1100 mV vdd3p0: 2625 <--> 3400 mV at 3000 mV vdd2p5: 2000 <--> 2750 mV at 2400 mV cpu: 725 <--> 1450 mV at 1150 mV vddpu: 725 <--> 1450 mV vddsoc: 725 <--> 1450 mV at 1200 mV syscon 20e0000.iomuxc-gpr: regmap [mem 0x020e0000-0x020e0037] registered syscon 21bc000.ocotp-ctrl: regmap [mem 0x021bc000-0x021bffff] registered hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers. hw-breakpoint: maximum watchpoint size is 4 bytes. imx6dl-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver bio: create slab at 0 mxs-dma 110000.dma-apbh: initialized usb_otg_vbus: 5000 mV usb_h1_vbus: 5000 mV wm8962-supply: no parameters mipi_dsi_pwr_on: no parameters sensor-supply: 3300 mV i2c-core: driver [max17135] using legacy suspend method i2c-core: driver [max17135] using legacy resume method SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb i2c i2c-0: IMX I2C adapter registered i2c i2c-1: IMX I2C adapter registered i2c i2c-2: Max17135 PMIC not found! i2c i2c-2: IMX I2C adapter registered Linux video capture interface: v2.00 pps_core: LinuxPPS API ver. 1 registered pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti PTP clock support registered imx-ipuv3 2400000.ipu: IPU DMFC NORMAL mode: 1(0~1), 5B(4,5), 5F(6,7) mxc_mipi_csi2 21dc000.mipi_csi: i.MX MIPI CSI2 driver probed mxc_mipi_csi2 21dc000.mipi_csi: i.MX MIPI CSI2 dphy version is 0x3130302a MIPI CSI2 driver module loaded Advanced Linux Sound Architecture Driver Initialized. Bluetooth: Core ver 2.16 NET: Registered protocol family 31 Bluetooth: HCI device and connection manager initialized Bluetooth: HCI socket layer initialized Bluetooth: L2CAP socket layer initialized Bluetooth: SCO socket layer initialized cfg80211: Calling CRDA to update world regulatory domain pureg-dummy: no parameters Switching to clocksource mxc_timer1 NET: Registered protocol family 2 TCP established hash table entries: 8192 (order: 4, 65536 bytes) TCP bind hash table entries: 8192 (order: 4, 65536 bytes) TCP: Hash tables configured (established 8192 bind 8192) TCP: reno registered UDP hash table entries: 512 (order: 2, 16384 bytes) UDP-Lite hash table entries: 512 (order: 2, 16384 bytes) NET: Registered protocol family 1 RPC: Registered named UNIX socket transport module. RPC: Registered udp transport module. RPC: Registered tcp transport module. RPC: Registered tcp NFSv4.1 backchannel transport module. hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 7 counters available Bus freq driver module loaded futex hash table entries: 512 (order: 3, 32768 bytes) VFS: Disk quotas dquot_6.5.2 Dquot-cache hash table entries: 1024 (order 0, 4096 bytes) NFS: Registering the id_resolver key type Key type id_resolver registered Key type id_legacy registered jffs2: version 2.2. (NAND) �© 2001-2006 Red Hat, Inc. fuse init (API version 7.22) msgmni has been set to 2001 io scheduler noop registered io scheduler deadline registered io scheduler cfq registered (default) imx-weim 21b8000.weim: WEIM driver registered. mxc_mipi_dsi 21e0000.mipi: i.MX MIPI DSI driver probed MIPI DSI driver module loaded mxc_sdc_fb fb.31: registered mxc display driver ldb imx-ipuv3 2400000.ipu: IPU DMFC DP HIGH RESOLUTION: 1(0,1), 5B(2~5), 5F(6,7) Console: switching to colour frame buffer device 128x48 mxc_hdmi 20e0000.hdmi_video: Detected HDMI controller 0x13:0x1a:0xa0:0xc1 fbcvt: 1920x1080@60: CVT Name - 2.073M9 mxc_sdc_fb fb.32: registered mxc display driver hdmi imx_epdc_fb 20f4000.epdc: Unable to get display PMIC regulator.err = 0xfffffdfb imx-sdma 20ec000.sdma: no iram assigned, using external mem imx-sdma 20ec000.sdma: loaded firmware 1.1 imx-sdma 20ec000.sdma: initialized pfuze100-regulator 1-0008: unrecognized pfuze chip ID! pfuze100-regulator: probe of 1-0008 failed with error -5 Serial: IMX driver 2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 58) is a IMX console [ttymxc0] enabled serial: Freescale lpuart driver imx sema4 driver is registered. [drm] Initialized drm 1.1.0 20060810 [drm] Initialized vivante 1.0.0 20120216 on minor 0 brd: module loaded loop: module loaded of_dma_request_slave_channel: dma-names property missing or empty spi_imx 2008000.ecspi: cannot get the TX DMA channel! spi_imx 2008000.ecspi: dma setup error,use pio instead m25p80 spi32766.0: found mr25h256, expected m25p32 m25p80 spi32766.0: mr25h256 (32 Kbytes) spi_imx 2008000.ecspi: probed CAN device driver interface fec 2188000.ethernet (unregistered net_device): Invalid MAC address: 00:00:00:00:00:00 fec 2188000.ethernet (unregistered net_device): Using random MAC address: 82:30:12:c7:0f:05 libphy: fec_enet_mii_bus: probed fec 2188000.ethernet eth0: registered PHC device 0 ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver usbcore: registered new interface driver usb-storage ci_hdrc ci_hdrc.1: doesn't support gadget ci_hdrc ci_hdrc.1: EHCI Host Controller ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 1 ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00 hub 1-0:1.0: USB hub found hub 1-0:1.0: 1 port detected mousedev: PS/2 mouse device common for all mice elan-touch 2-0010: elan - Read Hello Packet Failed elan-touch: probe of 2-0010 failed with error -22 egalax_ts 1-0004: Failed to read firmware version egalax_ts: probe of 1-0004 failed with error -5 egalax_ts 2-0004: Failed to read firmware version egalax_ts: probe of 2-0004 failed with error -5 input: max11801_ts as /devices/soc0/soc.1/2100000.aips-bus/21a4000.i2c/i2c-1/1-0048/input/input0 i2c-core: driver [isl29023] using legacy suspend method i2c-core: driver [isl29023] using legacy resume method snvs_rtc 20cc034.snvs-rtc-lp: rtc core: registered 20cc034.snvs-rtc-lp as rtc0 i2c /dev entries driver mxc_v4l2_output v4l2_out.37: V4L2 device registered as video16 mxc_v4l2_output v4l2_out.37: V4L2 device registered as video17 mxc_v4l2_output v4l2_out.37: V4L2 device registered as video18 max11801_ts 1-0048: FIFO_RD_AUX_MSB read fails max11801_ts 1-0048: FIFO_RD_AUX_MSB read fails max11801_ts 1-0048: FIFO_RD_AUX_MSB read fails max11801_ts 1-0048: FIFO_RD_AUX_MSB read fails max11801_ts 1-0048: FIFO_RD_AUX_MSB read fails max11801_ts 1-0048: FIFO_RD_AUX_MSB read fails max11801_ts 1-0048: FIFO_RD_AUX_MSB read fails max11801_ts 1-0048: FIFO_RD_AUX_MSB read fails max11801_ts 1-0048: FIFO_RD_AUX_MSB read fails max11801_ts 1-0048: FIFO_RD_AUX_MSB read fails max11801_ts 1-0048: FIFO_RD_AUX_MSB read fails max11801_ts 1-0048: FIFO_RD_AUX_MSB read fails mag3110 2-000e: check mag3110 chip ID mag3110 2-000e: read chip ID 0xfffffffb is not equal to 0xc4! mag3110: probe of 2-000e failed with error -22 i2c-core: driver [mag3110] using legacy suspend method i2c-core: driver [mag3110] using legacy resume method mma8451 0-001c: read chip ID 0x1 is not equal to 0x1a or 0x2a! mma8451: probe of 0-001c failed with error -22 imx2-wdt 20c0000.wdog: IMX2+ Watchdog Timer enabled. timeout=60s (nowayout=0) Bluetooth: HCI UART driver ver 2.2 Bluetooth: HCI H4 protocol initialized Bluetooth: HCI BCSP protocol initialized Bluetooth: HCIATH3K protocol initialized usbcore: registered new interface driver bcm203x usbcore: registered new interface driver btusb Bluetooth: Generic Bluetooth SDIO driver ver 0.1 usbcore: registered new interface driver ath3k cpuidle: using governor ladder cpuidle: using governor menu sdhci: Secure Digital Host Controller Interface driver sdhci: Copyright(c) Pierre Ossman sdhci-pltfm: SDHCI platform and OF driver helper mmc1: no vqmmc regulator found mmc1: no vmmc regulator found mmc1: SDHCI controller on 2194000.usdhc [2194000.usdhc] using ADMA mmc2: no vqmmc regulator found mmc2: no vmmc regulator found mmc2: SDHCI controller on 2198000.usdhc [2198000.usdhc] using ADMA mmc3: no vqmmc regulator found mmc3: no vmmc regulator found mmc3: SDHCI controller on 219c000.usdhc [219c000.usdhc] using ADMA galcore: clk_get vg clock failed, disable vg! mmc2: host does not support reading read-only switch. assuming write-enable. mmc2: new high speed SDHC card at address aaaa mmcblk2: mmc2:aaaa SS08G 7.40 GiB Galcore version 5.0.11.25762 mmcblk2: p1 p2
总结:第一次接触DeviceTree,需要了解的还很多,先暂时学会使用,目前只了解如果需要添加device,例如:i2c设备,SDIO设备等,就在.dts或对应的.dtsi文件中添加相应的设备信息,设备驱动对应的驱动程序需要添加对设备信息的识别部分,例如设备名,GPIO等信息