Presentation is loading. Please wait.

Presentation is loading. Please wait.

内核移植实例.

Similar presentations


Presentation on theme: "内核移植实例."— Presentation transcript:

1 内核移植实例

2 内容提要 Linux内核移植 网卡驱动移植 SD/eMMC驱动移植 USB主机控制器驱动移植

3 Linux内核移植 嵌入式linux系统移植步骤 准备开发板和相关资料 要了解开发板的相关配置(有那些外围设备等)
下载内核源码、取得相关工具软件 kernel,toolchain etc. 选定参考板 选择一个内核中已经支持,且和自己的开发板相似的参考板为模板,进行修改

4 Linux内核移植 修改开发板相关代码 完成BSP的修改移植 如:arch/arm/mach-exynos/ 如果使用设备树则修改设备树文件
如:arch/arm/boot/dts/exynos4412-origen.dts 添加驱动 编译、调试、下载内核

5 Linux内核移植 移植相关目录和代码 添加基本驱动 arch/arm/mach-exynos 闪存驱动(MTD NAND)
arch/arm/plat-samsung arch/arm/tools/mach-types arch/arm/Kconfig arch/arm/Makefile arch/arm/boot/compressed arch/arm/boot/dts/ Makefile 添加基本驱动 闪存驱动(MTD NAND) 串口用来打印信息 可以在内核启动之前打印信息 内核启动后可以通过console打印 信息 网络支持可以使得开发调试更为方便 如挂载网络文件系统 nfs

6 Linux内核移植 顶层Makefile Makefile ARCH=arm
CROSS_COMPILER=arm-cortex_a8-linux-gnueabi- …… vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o \ $(kallsyms.o)

7 arch/arm/Makefile Linux内核移植 arch/arm/mach-exynos/Makefile.boot
machine-$(CONFIG_ARCH_EXYNOS) := exynos ifneq ($(machine-y),)‏ MACHINE := arch/arm/mach-$(machine-y)/ else MACHINE := endif textofs-y := 0x TEXT_OFFSET := $(textofs-y) arch/arm/mach-exynos/Makefile.boot zreladdr-y := 0x params_phys-y := 0x

8 arch/arm/boot/Makefile
Linux内核移植 arch/arm/boot/Makefile ZRELADDR := $(zreladdr-y)‏ PARAMS_PHYS := $(params_phys-y)‏ INITRD_PHYS := $(initrd_phys-y) export ZRELADDR INITRD_PHYS PARAMS_PHYS

9 Linux内核移植 基本移植 拷贝设备树文件
cp arch/arm/boot/dts/exynos4412-origen.dts arch/arm/boot/dts/exynos fs4412.dts 在Makefile中添加新的设备树文件的编译项 $ vim arch/arm/boot/dts/Makefile exynos4412-origen.dtb \ exynos4412-fs4412.dtb \ 修改设备树文件 删除firmware节点。这是TrustZone相关的程序,并未提供。 {……};

10 Linux内核移植 生成默认配置 make ARCH=arm exynos_defconfig 修改配置
$ make ARCH=arm menuconfig General setup ---> (arm-none-linux-gnueabi-) Cross-compiler tool prefix 编译 $ make ARCH=arm uImage -j2 $ make ARCH=arm dtbs 测试 将uImage和设备树下载到开发板的内存中,使用bootm命令启动内核

11 网卡驱动移植 网卡移植 添加设备节点,参考: 原理图
Documentation/devicetree/bindings/net/davicom-dm9000.txt Documentation/devicetree/bindings/interrupt-controller/interrupts.txt Documentation/devicetree/bindings/arm/gic.txt reg = <0x x2 0x x2>; interrupt-parent = <&gpx0>; interrupts = <6 4>;

12 网卡驱动移植 添加驱动配置 添加网络配置 Device Drivers --->
[*] Network device support ---> [*] Ethernet driver support ---> <*> DM9000 support [ ] Force simple NSR based PHY polling (NEW) 添加网络配置 [*] Networking support ---> Networking options ---> <*> Packet socket <*> Unix domain sockets <*> PF_KEY sockets [*] TCP/IP networking [*] IP: kernel level autoconfiguration

13 网卡驱动移植 添加网络文件系统配置 时钟相关代码修改
File systems ---> [*] Network File Systems ---> <*> NFS client support <*> NFS client support for NFS version 2 (NEW) <*> NFS client support for NFS version 3 (NEW) [*] Root file system on NFS 时钟相关代码修改 参考Documentation/clk.txt:Part 6 - Disabling clock gating of unused clocks,可以通过bootargs进行参数传递,也可以直接修改代码。 drivers/clk/clk.c:529:static bool clk_ignore_unused = true; 重新编译并测试

14 SD/eMMC驱动移植

15 SD/eMMC驱动移植 SD卡主机控制器节点 sdhci@12530000 { bus-width = <4>;
pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_bus4>; pinctrl-names = "default"; cd-gpios = <&gpx0 7 0>; cd-inverted = <0>; status = "okay"; };

16 SD/eMMC驱动移植 驱动配置选项 Device Drivers --->
<*> MMC/SD/SDIO card support ---> <*> Secure Digital Host Controller Interface support <*> SDHCI support on Samsung S3C SoC

17 SD/eMMC驱动移植 文件系统选项 File systems ---> DOS/FAT/NT Filesystems --->
<*> MSDOS fs support <*> VFAT (Windows-95) fs support (iso8859-1) Default iocharset for FAT -*- Native language support ---> <*> Codepage 437 (United States, Canada) <*> Simplified Chinese charset (CP936, GB2312) <*> ASCII (United States) <*> NLS ISO (Latin 1; Western European Languages) <*> NLS UTF-8

18 USB主机控制器驱动移植

19 USB主机控制器驱动移植

20 USB主机控制器驱动移植 usbphy: usbphy@125B0000 { #address-cells = <1>;
#size-cells = <1>; compatible = "samsung,exynos4x12-usb2phy"; reg = <0x125B0000 0x100>; ranges; clocks = <&clock 2>, <&clock 305>; clock-names = "xusbxti", "otg"; status = "okay"; usbphy-sys { reg = <0x x8>; };

21 USB主机控制器驱动移植 ehci@12580000 { usbphy = <&usbphy>;
status = "okay"; }; { compatible = "smsc,usb3503"; reg = <0x08 0x4>; connect-gpios = <&gpm3 3 1>; intn-gpios = <&gpx2 3 1>; reset-gpios = <&gpm2 4 1>; initial-mode = <1>;

22 USB主机控制器驱动移植 Device Drivers ---> [*] USB support --->
<*> EHCI HCD (USB 2.0) support <*> EHCI support for Samsung S5P/EXYNOS SoC Series <*> USB Mass Storage support <*> USB3503 HSIC to USB20 Driver USB Physical Layer drivers ---> <*> Samsung USB 2.0 PHY controller Driver SCSI device support ---> <*> SCSI device support <*> SCSI disk support


Download ppt "内核移植实例."

Similar presentations


Ads by Google