转自 http://blog.csdn.net/kris_fei/article/details/50883969
platform: IMX6Q
os: Android 5.1
kernel: 3.14.52
1. 增加dts文件
- #cd arch/arm/boot/dts
- #cp imx6q-sabresd.dts ecovacsimx6q-sabresd.dts
- #cp imx6qdl-sabresd.dtsi ecovacsimx6qdl-sabresd.dtsi
因为这两个文件会被其他dts文件include到,这样删除原始外设信息时,编译就不会报错了。
2. mach type匹配
保证device tree中的值和mach desc结构中的值有相同的一个,
本质上就是匹配里面的compatible属性值是否一致,
否则kernel因为匹配不成功而开机失败。
本例使用imx6平台,对应的dts文件是:
kernel_imx/arch/arm/boot/dts/ecovacsimx6q-sabresd.dts
- / {
- model = "Freescale i.MX6 Quad SABRE Smart Device Board";
- compatible = "fsl,imx6q-sabresd", "fsl,imx6q";
- };
对应的mach desc结构在:
kernel_imx/arch/arm/mach-imx/mach-imx6q.c
- DT_MACHINE_START(IMX6Q, "Freescale i.MX6 Quad/DualLite (Device Tree)")
- ......
- .init_machine = imx6q_init_machine,
- .init_late = imx6q_init_late,
- .dt_compat = imx6q_dt_compat,
- .reserve = imx6q_reserve,
- .restart = mxc_restart,
- MACHINE_END
-
-
- static const char *imx6q_dt_compat[] __initdata = {
- "fsl,imx6dl",
- "fsl,imx6q",
- NULL,
- };
3. 修改uart
板子和参考方案的uart不一样,需要修改,参考uart1增加uart2的配置。
kernel_imx/arch/arm/boot/dts/ecovacsimx6qdl-sabresd.dtsi
- diff --git a/arch/arm/boot/dts/ecovacsimx6qdl-sabresd.dtsi b/arch/arm/boot/dts/ecovacsimx6qdl-sabresd.dtsi
- index d39576b..5e643d3 100644
- --- a/arch/arm/boot/dts/ecovacsimx6qdl-sabresd.dtsi
- +++ b/arch/arm/boot/dts/ecovacsimx6qdl-sabresd.dtsi
- @@ -822,6 +822,13 @@
- >;
- };
-
- + pinctrl_uart2: uart2grp {
- + fsl,pins = <
- + MX6QDL_PAD_GPIO_7__UART2_TX_DATA 0x1b0b1
- + MX6QDL_PAD_GPIO_8__UART2_RX_DATA 0x1b0b1
- + >;
- + };
- +
- pinctrl_uart5_1: uart5grp-1 {
- fsl,pins = <
- MX6QDL_PAD_KEY_COL1__UART5_TX_DATA 0x1b0b1
- @@ -1018,6 +1025,12 @@
- status = "okay";
- };
-
- +&uart2 {
- + pinctrl-names = "default";
- + pinctrl-0 = <&pinctrl_uart2>;
- + status = "okay";
- +};
fsl,pins的解释位于
kernel_imx/Documentation/devicetree/bindings/pinctrl/fsl,imx6q-pinctrl.txt
GPIO的宏定义位于:
kernel_imx/arch/arm/boot/dts/imx6q-pinfunc.h
4. 检查和调试
编译时lunch选项要选择imx6系列的,确保ecovacsimx6q-sabresd.dts
和mach-imx6q.c 有被编译进去。
如果开机kernel没有log,那么可以通过jtag或者reset之后在
u-boot阶段dump kernel log的方法分析原因出在哪里了。