FS4412开发板移植Linux内核4.9.9版本

基本移植

1、源码下载

官网下载最新的linux4.9.9内核:https://mirrors.edge.kernel.org/pub/linux/kernel/。

第三个数字是修订版本号。

2、解压并配置

tar xvf linux-4.9.9.tar.xz

进入内核源码目录及: cd linux-4.9.9 

修改编译工具链,打开顶层的Makefile: vi Makefile 

修改:

ARCH  ?= $(SUBARCH)
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)

为:

ARCH  ?= arm
CROSS_COMPILE ?= arm-none-linux-gnueabi-

如果不修改编译工具链,默认使用编译x86的gcc编译器,如果不想修改Makefile也可以执行make时添加 如:

make uImage ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-

3、导入的默认的配置

make exynos_defconfig

实际上是执行了:cp arch/arm/configs/exynos_defconfig .config

4、配置内核

make menuconfig

修改指定内核的调试串口:

Kernel hacking
    --> Kernel low-level debugging functions (read help!)  选择
        --> Kernel low-level debugging port (Use Samsung S3C UART 2 for low-level debug)  打开选择uart2

选择这个调试串口很重要,否则打印不出内核启动的相关信息(exynos默认没有打开此功能,没有打开此处会发现内核打印信息停止在Starting kernel …处)

5、编译内核和设备树

编译uImage镜像:

make uImage -j4 LOADADDR=0x40008000

-j4表示双线程编译,LOADADDR=0X40008000表示指定内核的加载地址(没有此选项编译生成uImage会报错)
最后提示以下错误。

Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
multiple (or no) load addresses: 
This is incompatible with uImages
Specify LOADADDR on the commandline to build an uImage
make[1]: *** [arch/arm/boot/uImage] 错误 1
make: *** [uImage] 错误 2

编译设备树:

在编译设备树之前需要对设备树进行配置,在这里使用参考板origen的设备树文件。

cp arch/arm/boot/dts/exynos4412-origen.dts  arch/arm/boot/dts/exynos4412-fs4412.dts

修改arch/arm/boot/dts/下的Makefile文件:

make dtbs

6、移植网卡

增加DM9000网卡的设备树节点信息: vi arch/arm/boot/dts/exynos4412-fs4412.dts 

srom-cs1@5000000 {
        compatible = "simple-bus";
        #address-cells = <1>;
        #size-cells = <1>;
        reg = <0x5000000 0x1000000>;
        ranges;
        ethernet@5000000 {
                compatible = "davicom,dm9000";
                reg = <0x5000000 0x2 0x5000004 0x2>;
                interrupt-parent = <&gpx0>;
                interrupts = <6 4>;
                davicom,no-eeprom;
                mac-address = [00 0a 2d a6 55 a2];
        };
};

注:一定要在跟节点中增加节点,否则设备树编译会报错。

修改时钟:

static bool clk_ignore_unused;

为:

static bool clk_ignore_unused = true;

内核配置:

// 网络协议配置
[*] Networking support --->
Networking options --->
<*> Packet socket
<*> Unix domain sockets
[*] TCP/IP networking
[*] IP: kernel level autoconfiguration

// 网卡驱动的配置
Device Drivers --->
[*] Network device support --->
[*] Ethernet driver support (NEW) --->
<*> DM9000 support

// NFS服务和根文件系统配置
File systems --->
[*] Network File Systems (NEW) --->
<*> NFS client support
[*] NFS client support for NFS version 3
[*] NFS client support for the NFSv3 ACL protocol extension
[*] Root file system on NFS

重新编译内核和设备树即可。

USB驱动移植

1、修改设备树文件

添加USB设备信息: vi arch/arm/boot/dts/exynos4412-fs4412.dts  

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";
        usbphy-sys {
                reg = <0x10020704 0x8 0x1001021c 0x4>;
        };
};
ehci@12580000 {
        status = "okay";
        usbphy = <&usbphy>;
};
usb3503@08 {
        compatible = "smsc,usb3503";
        reg = <0x08 0x4>;
        connect-gpios = <&gpm3 3 1>;
        intn-gpios = <&gpx2 3 1>;
        reset-gpios = <&gpm2 4 1>;
        initial-mode = <1>;
};

2、配置内核

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
        <*> SCSI generic support

3、编译内核和设备树并测试

make uImage -j4 LOADADDR=0x40008000
make dtbs

启动开发板,插入U盘显示如下:

[   31.541687] usb 1-3.3: new high-speed USB device number 3 using exynos-ehci
[   31.657886] usb 1-3.3: New USB device found, idVendor=1f75, idProduct=0917
[   31.663307] usb 1-3.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   31.670597] usb 1-3.3: Product: Teclast CoolFlash
[   31.675285] usb 1-3.3: Manufacturer: Generic
[   31.679537] usb 1-3.3: SerialNumber: 201207222874
[   31.685043] usb-storage 1-3.3:1.0: USB Mass Storage device detected
[   31.691154] scsi host0: usb-storage 1-3.3:1.0
[   32.722436] scsi 0:0:0:0: Direct-Access     Teclast  CoolFlash USB3.0 1.00 PQ: 0 ANSI: 6
[   32.730975] sd 0:0:0:0: [sda] 30679040 512-byte logical blocks: (15.7 GB/14.6 GiB)
[   32.737423] sd 0:0:0:0: Attached scsi generic sg0 type 0
[   32.742672] sd 0:0:0:0: [sda] Write Protect is off
[   32.747667] sd 0:0:0:0: [sda] Write cache: disabled, read cache: disabled, doesn't support DPO or FUA
[   32.760661]  sda:
[   32.763408] sd 0:0:0:0: [sda] Attached SCSI removable disk

在终端上执行挂载:

mount -t vfat /dev/sda  /mnt

SD卡驱动移植

1、修改设备树

添加SD卡设备信息: vi arch/arm/boot/dts/exynos4412-fs4412.dts 

// 修改
&sdhci_2 {
        bus-width = <4>;                                                                                                                                              
        pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_bus4 &sd2_cd>;
        pinctrl-names = "default";
        vmmc-supply = <&mmc_reg>;
        status = "okay";
};
// 为:
&sdhci_2 {
        bus-width = <4>;                                                                                                                                              
        pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_bus4>;
        cd-gpios = <&gpx0 7 0>;
        cd-inverted = <0>;
        pinctrl-names = "default";
        // vmmc-supply = <&mmc_reg>;
        status = "okay";
};

2、配置内核

// 配置SD卡驱动
Device Drivers --->
<*> MMC/SD/SDIO card support --->
<*> Secure Digital Host Controller Interface support
<*> SDHCI support on Samsung S3C SoC

// 文件系统支持
File systems --->
DOS/FAT/NT Filesystems --->
<*> MSDOS fs support
<*> VFAT (Windows-95) fs support
(437) Default codepage for FAT
(iso8859-1) Default iocharset for FAT

// 本地语言编码支持
-*- Native language support --->
<*> Codepage 437 (United States, Canada)
<*> Simplified Chinese charset (CP936, GB2312)
<*> ASCII (United States)
<*> NLS ISO 8859-1 (Latin 1; Western European Languages)
<*> NLS UTF-8

3、编译内核和设备树并测试

make uImage -j2 LOADADDR=0x40008000
make dtbs

启动开发板,将SD卡插入开发板,打印如下信息:

[  499.301302] mmc0: new high speed SDHC card at address 1234
[  499.305842] mmcblk0: mmc0:1234 SA04G 3.71 GiB
[  499.312642]  mmcblk0: p1

挂在SD卡:

mount -t vfat /dev/mmcblk0p1 /mnt
posted @ 2018-06-08 22:47  老姚大大  阅读(1206)  评论(0编辑  收藏  举报