本笔记并不是一个完整的关于 OpenWRT 移植的笔记,只作为个人备忘用。同时亦分享出来给需要的朋友作为参考。水平有限,如果有出错地方请反馈 yplam(at)yplam.com
嵌入式 Linux 三大件:uboot,kernel,rootfs;uboot 暂时不打算动,kernel 之前已编译测试过可启动,所以剩下只需要将 OpenWRT 的 rootfs 构建出来,那么 OpenWRT 运行起来应该也不是很难的事。
资料搜集
可能比较少人在 OpenWRT 上用 imx6ull,能搜集的资料并不多,不过够用
- i.mx6ul 移植Openwrt https://blog.csdn.net/wind0419/article/details/78036522
- i.mx6ul开发板移植openwrt系统 https://blog.csdn.net/qq_40614144/article/details/105538483
- 一个托管在git上面的 imx6ull openwrt 移植项目 https://github.com/iuncuim/openwrt-imx6ull
增加 target imx6ull
参考上面的 git 项目,在 OpenWRT 源码 target/linux 下添加一个 imx6ull 目录,然后将我们之前内核编译的 .config 文件拷贝到 target/linux/imx6ull/config-4.14 。
由于我们用的是官方内核,所以 patch 相关的可以忽略掉。
最小配置的 imx6ull 目录如下:
.
├── base-files
│ └── etc
│ └── inittab
├── config-4.14
├── image
│ └── Makefile
├── Makefile
└── profiles
└── 100-generic.mk
Makefile:
#
# Copyright (C) 2013-2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
ARCH:=arm
BOARD:=imx6ull
BOARDNAME:=Freescale i.MX 6 ULL
FEATURES:=audio display fpu gpio rtc usb usbgadget squashfs ext4 targz nand ubifs
CPU_TYPE:=cortex-a7
CPU_SUBTYPE:=neon-vfpv4
KERNEL_PATCHVER:=4.14
include $(INCLUDE_DIR)/target.mk
KERNELNAME:=zImage
DEFAULT_PACKAGES += uboot-envtools
$(eval $(call BuildTarget))
profiles/100-generic.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/Generic
PRIORITY:=1
NAME:=Generic (default)
endef
define Profile/Generic/Description
Package set compatible with most Freescale i.MX 6 ull based boards.
endef
$(eval $(call Profile,Generic))
image/Makefile
#
# Copyright (C) 2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk
KERNEL_LOADADDR:=0x80800000
define Device/Default
PROFILES := Generic
FILESYSTEMS := squashfs ext4
KERNEL_INSTALL := 1
KERNEL_SUFFIX := -uImage
KERNEL_NAME := zImage
KERNEL_PREFIX := $$(IMAGE_PREFIX)
endef
$(eval $(call BuildImage))
base-files/etc/inittab
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K shutdown
::askconsole:/usr/libexec/login.sh
tty1::askfirst:/usr/libexec/login.sh
以上配置基于个人猜测以及参考以下文档:
- https://openwrt.org/docs/techref/image.makefile
- https://openwrt.org/docs/techref/process.boot
- https://openwrt.org/docs/guide-user/additional-software/imagebuilder#addingmodifying_profiles
编译 ROOTFS
编译过程与常规类似,主要区别是选择我们自己的内核目录,以及工具链使用 glibc 而不是默认的 musl(推测原因是我们的内核并没有打 musl 相关的 patch)。
选好 Target System, Target Profile,编译。如无意外会生成我们想要的 rootfs:bin/targets/imx6ull/generic-glibc/openwrt-imx6ull-generic-rootfs.tar.gz
将 rootfs 解压到 SD 卡分区,启动开发板,更改 uboot 的内核启动相关配置到我们的内核与rootfs,启动