隨着神U s3c2440,6410的停產,NXP 針對中國市場推出低成本方案i.mx6ul,可用於商業級和工業級應用,10年超長供貨週期,市場很有潛力。
官方只支持Yocto,但個人感覺Yocto太多龐大且太複雜,而工業市場業務並不是特別負責,需要用到的軟件包有限,且在特定的一個範圍。工業市場
對穩定性要求較高,並不需很大的靈活度。
本文將介紹使用Buildroot爲i.mx6製作文件系統,相對來說Buildroot較爲簡單,容易理解,且有接近2千種包支持,穩定性也不是問題。
移植Buildroot前,需要先了解i.mx6體系結構,本文移植基於米爾科技的i.mx6ulx開發板,256MB Nand,256MB RAM,支持SD卡;
i.mx6ul 爲Cortex-A7架構,支持Neon;
前序:
在製作文件系統之前,先了解一下幾個基本概念。
Uboot:引導操作系統之用;
Linux Kernel:內核,主要關注其穩定性,其中接口驅動最爲重要,一般使用官方的Release包,因爲官方在標準的Kernel之上針對自家芯片做了一系列的優化工作,且有很多廠商的應用案例,其穩定性得到了一定的驗證;不建議使用標準的kernel,尤其是接口驅動穩定性得不到保證。
文件系統:可以看成一系列基本命令的集合,如:ps,insmod,netstat,iptables,ifconfig等等;我們所開發的應用程序也會包含在文件系統之中,並且將使用到文件系統所提供的基本命令和各種標準庫以及第三方庫等;
製作文件系統:有很多方法,Buildroot和Yocto只是一個輔助框架,其本身已經設定好編譯環境,且支持多種平臺,可以很方便的幫助用戶爲特定的平臺製作文件系統。當然也可以自行手動建立,文件系統無非就是一堆文件的集合,自行手動編譯,打包即可;只是比較耗費精力,穩定性和移植性也得不到保證;所以一般情況下,我們會選用Buildroot等框架輔助我們建立文件系統;
第一步:
- 下載Buildroot包:
從Buildroot官網下載 https://buildroot.org/download.html
第二步:
- make menuconfig 配置相關選項
- CPU架構配置,i.mx6ul爲小端格式,Cortex-a7架構,浮點運算EABIHf,VFPv4
Target Architecture (ARM (little endian)) ---> x x Target Binary Format (ELF) ---> x x Target Architecture Variant (cortex-A7) ---> x x Target ABI (EABIhf) ---> x x Floating point strategy (VFPv4-D16) ---> x x ARM instruction set (ARM) --->
- Build Options: 編譯選項主要是package下載位置,默認dl目錄,主要是配置共享庫,shared only
gcc optimization level (optimize for size) ---> x x build code with Stack Smashing Protection (None) ---> x x libraries (shared only) --->
- Toolchain: 交叉編譯工具鏈,使用NXP 官方提供的即可。根據實際情況設定gcc version和kernel header version;
- gcc version可以在主機上使用arm-linux-gnueabihf -v查看
rget/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu Thread model: posix gcc version 4.9.3 20141031 (prerelease) (Linaro GCC 2014.11)
- kernel header version在工具鏈目錄的xxx/libc/include/linux/version.h;
cat /opt/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/libc/usr/include/linux/version.h #define LINUX_VERSION_CODE 200960 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
200960 轉換爲Hex格式0x31100;即3.11.0 版本;但編譯過程中Buildroot貌似會自動判斷Linux Version,我的主機自動判斷是3.17,因此我選擇3.17版本;此處還有待考察;
注意使能MMUToolchain type (External toolchain) ---> x x x x *** Toolchain External Options *** x x x x Toolchain (Custom toolchain) ---> x x x x Toolchain origin (Pre-installed toolchain) ---> x x x x (/opt/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/) Toolchain path x x x x ($(ARCH)-linux-gnueabihf) Toolchain prefix x x x x External toolchain gcc version (4.9.x) ---> x x x x External toolchain kernel headers series (3.17.x) ---> x x x x External toolchain C library (glibc/eglibc) --->
[*] Enable MMU support
- System configuration:主要是些hostname,banner,busybox,password,console等一些配置
需要注意的地方有2點:bash 和 tty的選擇; nxp的tty默認是/dev/ttymxc0;(buildrootbywind) System hostname x x x x (Welcome to Buildroot by wind) System banner x x x x Passwords encoding (md5) ---> x x x x Init system (BusyBox) ---> x x x x /dev management (Dynamic using devtmpfs + eudev) ---> x x x x (system/device_table.txt) Path to the permission tables x x x x [ ] support extended attributes in device tables x x x x [ ] Use symlinks to /usr for /bin, /sbin and /lib x x x x [*] Enable root login with password x x x x (123456) Root password x x x x /bin/sh (bash) ---> x x x x [*] Run a getty (login prompt) after boot --->
選擇Bash前需打開Show packages that are alse provideed by busybox; 位於Target Package 下
tty配置爲:-*- BusyBox x x x x (package/busybox/busybox.config) BusyBox configuration file to use? x x x x () Additional BusyBox configuration fragment files x x x x [*] Show packages that are also provided by busybox
--- Run a getty (login prompt) after boot x x x x (/dev/ttymxc0) TTY port x x x x Baudrate (keep kernel default) ---> x x x x (vt100) TERM environment variable x x x x () other options to pass to getty
- 剩下就是Filesystem image配置:主要選擇文件系統類型,以及相關參數
Ext2/3/4支持:[*] ext2/3/4 root filesystem x x x x ext2/3/4 variant (ext4) ---> x x x x () filesystem label x x x x (60M) exact size x x x x (0) exact number of inodes (leave at 0 for auto calculation) x x x x (5) reserved blocks percentage x x x x (-O ^64bit) additional mke2fs options x x x x Compression method (no compression) --
- tar 和Ubifs支持,我的板子爲256M Nand,使用ubifs,因此必須選擇
UBI文件系統主要參數根據實際NAND參數來配置即可;[*] tar the root filesystem x x x x Compression method (no compression) ---> x x x x () other random options to pass to tar x x x x [*] ubifs root filesystem x x x x (0x1f800) logical eraseblock size x x x x (0x800) minimum I/O unit size x x x x (2048) maximum logical eraseblock count x x x x ubifs runtime compression (lzo) ---> x x x x Compression method (no compression) --->
- Target packages中是一些開源軟件,自行根據需要來配置;
至此,配置完畢;
第三步:
make all編譯;
輸出結果位於output/images 下
燒寫文件系統:具體燒寫方式請見我另一篇博文 對於ARM的啓動,系統升級,燒寫過程和文件系統等方面的總結分析