i.mx6ul 移植Openwrt

一直在使用Openwrt很多年,从路由到IOT终端,网关等,相对于其他开发环境或者厂家SDK来说,openwrt确实很便捷,其内部的Lua,ubox,ubus,rpc等一些机制,能在开发中带来很大的便捷,而且功能也非常稳定;

鉴于Yocto的庞大,复杂 和 buildroot的相对那么不便捷,最近在考虑把Openwrt移植到i.mx6ul中,为后续开发带来更多的便捷性;


移植前的思考:

  1. 主要的稳定性来自于Kernel,因此Kernel需要使用NXP 官方的,最新的是4.1,Openwrt下载标准kernel然后打patch,不一定完全适用;
  2. Openwrt可以看成是制作文件系统的工具,帮助更方便的制作而已
  3. Openwrt支持OPKG包安装和卸载,方便调试和增量升级
  4. Uboot可以先不管,也没太大作用,仅仅引导系统和设定启动参数而已

使用LEDE的v17.01.2  release分支,其已支持imx6,因此我们在imx6基础上修改即可;主要是配置;

首先是cpu架构,原来的imx6是A9架构,i.mx6ul是A7架构,因此修改如下(git diff方式给出)

diff --git a/target/linux/imx6/Makefile b/target/linux/imx6/Makefile
index 5f7e17b..a7ac682 100644
--- a/target/linux/imx6/Makefile
+++ b/target/linux/imx6/Makefile
@@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk
 ARCH:=arm
 BOARD:=imx6
 BOARDNAME:=Freescale i.MX 6
-FEATURES:=audio display fpu gpio pcie rtc usb usbgadget squashfs targz nand ubifs
-CPU_TYPE:=cortex-a9
-CPU_SUBTYPE:=neon
+FEATURES:=fpu gpio usb usbgadget targz nand ubifs
+CPU_TYPE:=cortex-a7
+CPU_SUBTYPE:=neon-vfpv4
 MAINTAINER:=Luka Perkov <luka@openwrt.org>
-
-KERNEL_PATCHVER:=4.4
+LINUX_VERSION:=4.1
+#KERNEL_PATCHVER:=4.4

 include $(INCLUDE_DIR)/target.mk

CPU_TYPE为A7,支持NEON指令集,裁剪部分不需要FEATURES,同时更改内核版本KERNEL_VERSION=4.1,因为使用的NXP官方的kernel,所以此处PATCH就不需要了

最基本参数的参数修改完毕后,因为使用4.1版本,因此还需.config文件,用来配置kernel编译选项。

Openwrt中的.config文件,是由两部分组成的,其一target/linux/generic/config-4.1,其二target/linux/imx6/config-4.1,编译过程中合二为一;此处我们为了方便,用target/linux/imx6/config-4.1 这一个文件即可; generic的4.1为空

target/linux/imx6/config-4.1 的内容填写NXP官方kernel中的arch/arm/configs/xxx_config即可,具体xxx对应你自己的板子;


Image编译配置:

因为我的板子是NAND Flash,使用UBIFS文件系统,Openwrt的Image编译位于target/linux/imx6/image/Makefile

在其中增加我们对应的板子配置即可;

 define Device/Default
-  PROFILES := Generic
-  FILESYSTEMS := squashfs ext4
+  PROFILES := imx6ull
+  FILESYSTEMS := ext4
   KERNEL_INSTALL := 1
   KERNEL_SUFFIX := -uImage
   KERNEL_NAME := zImage
@@ -69,56 +69,12 @@ define Device/Default
   IMAGES :=
 endef
+define Device/myr-imx6ull
+  DEVICE_TITLE := Myr myr-imx6ull
+  DEVICE_DTS := mys-imx6ull-14x14-evk-gpmi-weim
 endef

 TARGET_DEVICES += \
-       ventana ventana-large \
-       wandboard
+       myr-imx6ull

 $(eval $(call BuildImage))
在此前,需要增加自己的板子配置,如我用的 target/linux/imx6/profiles/101-imx6ull.mk
#
# Copyright (C) 2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

define Profile/imx6ull
  PRIORITY:=1
  NAME:=imx6ull (default)
endef

define Profile/imx6ull/Description
 Package set compatible with most Myr i.MX6ull  boards.
endef

$(eval $(call Profile,imx6ull))

即menuconfig配置时,target会出现 imx6ull选项;

到此,针对Openwrt的改动基本可以说完毕了;后续就是改善NXP官方的Kernel配置,以适用Openwrt;

主要是开启modules动态加载;使用make kernel_menuconfig 配置即可;

因为是使用外置kernel,openwrt中的外部kernel tree配置如下:

 --- Advanced configuration options (for developers)                
  x x                   [ ]   Show broken platforms / packages               
  x x                   ()    Binary folder                   
  x x                   ()    Download folder                                          
  x x                   ()    Local mirror for source packages       
  x x                   [*]   Automatic rebuild of packages                                     
  x x                   ()    Build suffix to append to the target BUILD_DIR variable   
  x x                   ()    Override the default TARGET_ROOTFS_DIR variable        
  x x                   [ ]   Use ccache                                         
  x x                   (/home/wind/Openwrt_Proj/lede-for-imx6ul/myir-6ulx-kernel) Use external kernel tree  
Use external kernel tree,设定为你自己的路径即可;编译工具链就是用openwrt自编译生成的;


接着可以进行make V=s 开始编译了;

以下是编译过程中可能遇到的问题:

1. 编译netifd时遇到的 冲定义问题:redefinition of 'struct in6_addr'
    解决办法:修改openwrt编译工具链,staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-5.4.0_musl-1.1.16_eabi/include/linux/if_bridge.h,替换#include <linux/in6.h>
                      为#include <netinet/in.h> 即可;
2. 无法生成文件系统:
   注意openwrt板子配置,如上述的 target/linux/imx6/profiles/101-imx6ull.mk,与其配套的还有base-files/etc/board.d/02_network,base-files/lib/imx6.sh等板子led,eth配置相关,主要的还是image配置

3. Target Images配置;
 [*] ramdisk  --->                                                         
  x x                       *** Root filesystem archives ***     
  x x                   [ ] cpio.gz                                
  x x                   [*] tar.gz                              
  x x                       *** Root filesystem images *** 
  x x                   [ ] ext4  ----                            
  x x                   [*] squashfs  --->                
  x x                   [*] ubifs  --->                  
  x x                       *** Image Options *** 
tar,ubifs,必须选上,因为要用,squashfs可不选,nand用不到;

4. 编译完后,bin下找不到升级文件
   针对A7架构,openwrt编译完后,分为3个文件,其一zImage,其二dtb文件,其三文件系统
   zImage位于外部内核路径的arch/arm/boot中,dtb文件即target/linux/imx6/image/Makefile中配置的DEVICE_DTS;
   文件系统为lede-imx6-imx6ull-rootfs.tar.gz,如果格式不满足要求,可以解压后,再次压缩成想要的格式,针对ubifs升级,可以直接解压到nand中即可;
  具体可以参考我另一篇博文





  • 2
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值