Linux4.1.15 kernel porting -imx6ull

A, Linux kernel compilation
1, modify the top Makefile

252 Line Review:

ARCH ?= arm
CROSS_COMPLIE ?= arm-linux-gnueabihf-


2, configure and compile the Linux kernel

make clean
make imx_v7_mfg_defconfig

 

3, the Linux kernel to start the test
  1, to ensure that the variable configuration
    Console = ttymxc0,115200 the root = / dev / mmcblk1p2 rootwait RW
  2, and the copying apparatus zImage tree file directory to tftp server
  3, the device tree file download kernel to the development board , and starts the kernel

tftp 80800000 zImage
tftp 83000000 imx6ull-14x14- evk.dtb
bootz 8080000083000000

  4, in front of the specified environment variable root is the root file system

 

Second, add their own development boards
  1, add boards default profile
    CD Arch / ARM / configs
    CP imx_v7_mfg_defconfig imx_alientek_emmc_defconfig
    can then be used directly to make imx_alientek_emmc_defconfig compiled kernel
  2, add boards corresponding device tree file
    cd arch / arm / boot / DTS
    cp imx6ull-14x14-evk.dts imx6ull-alientek-emmc.dts
    then need to find dtb in arch / arm / boot / dts / Makefile in - $ (CONFIG_SOC_IMX6ULL), and add imx6ull-alientek-emmc in this configuration. DTB
  3, compile the test
    write scripts imx6ull_alientek_emmc.sh

#!/bin/sh
# Clean up
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean
# Default configuration imx_alientek_emmc_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- imx_alientek_emmc_defconfig
# Open the graphical configuration interface
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
# Compiler Linux
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- all -j16

 

Three, CPU frequency and network drivers modification
1, CPU frequency modifying
  cat / proc / cpuinfo # view CPU information
  wherein BogoMIPS value used to measure the operating speed of processors.

  Directory / sys / bus / cpu / devices / cpu0 / cpufreq part of the file recorded in the CPU frequency information:

cpuinfo_cur_freq: cpu current operating frequency, read from the register to the CPU operating frequency.
cpuinfo_max_freq: processor can run a maximum operating frequency (Unit: KHz).
cpuinfo_min_freq: processor can run the lowest operating frequency (Unit: KHz).
cpuinfo_transition_latency: processor switching frequency required time (unit: ns).
scaling_available_frequencies: processor supports the main frequency list (unit: KHz).
scaling_available_governors: The current kernel supports all of the governor (FM) type.
scaling_cur_freq: cpufreq module cache holds the current CPU frequency, CPU hardware register will not be checked.
scaling_driver: The file is saved FM drive current CPU used.
scaling_governor: governor (FM) strategy, Linux kernel, a total of 5 in the FM policy,
①、 Performance,最高性能,直接用最高频率,不考虑耗电。
②、 Interactive,一开始直接用最高频率,然后根据 CPU 负载慢慢降低。
③、 Powersave,省电模式,通常以最低频率运行,系统性能会受影响,一般不会用这个!
④、 Userspace,可以在用户空间手动调节频率。
⑤、 Ondemand,定时检查负载,然后根据负载来调节频率。负载低的时候降低 CPU 频率,这样省电,负载高的时候提高 CPU 频率,增加性能。
scaling_max_freq: governor(调频)可以调节的最高频率。
cpuinfo_min_freq: governor(调频)可以调节的最低频率。
stats 目录下给出了 CPU 各种运行频率的统计情况,比如 CPU 在各频率下的运行时间以及变频次数。    

 

  cat /sys/bus/cpu/devices/cpu0/cpufreq/stats/time_in_state #查看CPU在各频率下工作时间
  默认配置文件imx_alientek_emmc_defconfig中:

41 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y #配置默认调频策略为ONDEMAND
42 CONFIG_CPU_FREQ_GOV_POWERSAVE=y
43 CONFIG_CPU_FREQ_GOV_USERSPACE=y
44 CONFIG_CPU_FREQ_GOV_INTERACTIVE=y

  屏蔽41行,并添加 CONFIG_CPU_FREQ_GOV_ONDEMAND=y
  在目录/sys/devices/system/cpu/cpu0/cpufreq/下查看文件cpuinfo_cur_freq、scaling_governor(当前调频策略)。

  超频至700MHz:只需修改设置树文件中cpu0信息,添加 792000 1225000
  编译设备树命令:
    make dtbs

  2、使能8线EMMC驱动
  Linux内核驱动默认EMMC是4线模式,将其修改为8线。修改设备树文件。

734 &usdhc2 {
735 pinctrl-names = "default";
736 pinctrl-0 = <&pinctrl_usdhc2>;
737 non-removable;
738 status = "okay";
739 };
将其修改为一下内容
734 &usdhc2 {
735 pinctrl-names = "default", "state_100mhz", "state_200mhz";
736 pinctrl-0 = <&pinctrl_usdhc2_8bit>;
737 pinctrl-1 = <&pinctrl_usdhc2_8bit_100mhz>;
738 pinctrl-2 = <&pinctrl_usdhc2_8bit_200mhz>;
739 bus-width = <8>;
740 non-removable;
741 status = "okay";
742 };

 


  编译设备树命令:
    make dtbs

  3、修改网络驱动
  NXP官方开发板使用的是KSZ8081,正点原子使用的LAN8720,两款芯片的复位IO不同。需要修改网络驱动。
    1、修改LAN8720的复位引脚驱动
    屏蔽SPI4使用到的SNVS_TAMPER7和SNVS_TAMPER8管脚,也即GPIO5_IO07、GPIO5_IO08
    在ENET1和ENET2中添加两个管脚的配置
    2、修改LAN8720A的PHY地址
    修改&fec1、&fec2的内容,分别添加

    phy-reset-gpios = <&gpio5 7 GPIO_ACTIVE_LOW>;/*网络复位引脚为GPIO5_IO07,低电平有效*/
    phy-reset-duration = <26>;/*复位低电平信号持续时间为26ms*/

    phy-reset-gpios = <&gpio5 8 GPIO_ACTIVE_LOW>;/*网络复位引脚为GPIO5_IO08,低电平有效*/
    phy-reset-duration = <26>;/*复位低电平信号持续时间为26ms*/

    3、修改fec_main.c文件
    打 开drivers/net/ethernet/freescale/fec_main.c,找到函数 fec_probe,添加一以下代码:

/* 设置 MX6UL_PAD_ENET1_TX_CLK 和 MX6UL_PAD_ENET2_TX_CLK
* 这两个 IO 的复用寄存器的 SION 位为 1。
*/
void __iomem *IMX6U_ENET1_TX_CLK;
void __iomem *IMX6U_ENET2_TX_CLK;

IMX6U_ENET1_TX_CLK = ioremap(0X020E00DC, 4);
writel(0X14, IMX6U_ENET1_TX_CLK);

IMX6U_ENET2_TX_CLK = ioremap(0X020E00FC, 4);
writel(0X14, IMX6U_ENET2_TX_CLK);

    设置了ENET1和ENET2的TX_CLK引脚复位寄存器的SION位为1。
    4、配置Linux内核,使能LAN8720驱动
    -> Device Drivers
      -> Network device support
        -> PHY Device support and infrastructure
          -> Drivers for SMSC PHYs
    5、修改smsc.c文件
     修改drivers/net/phy/smsc.c文件中的smsc_phy_reset函数。使得只要调用该函数就执行软复位。
  6、保存.config文件
    1、直接另存配置好的.config文件
    2、通过图形接面保存配置文件,可使用相对路径(相对Linux内核源码根目录),一般保存在arch/arm/configs/


  以上内容是基于《正点原子I.MX6U嵌入式Linux驱动开发指南V1.0》的第37章进行的摘要。



Guess you like

Origin www.cnblogs.com/mofei004/p/12058593.html