[i.MX6q]i.MX6q处理器,linux操作系统平台搭建 从SD卡启动系统
转自:http://www.07net01.com/linux/2016/02/1232094.html
参照1:http://blog.csdn.net/girlkoo/article/details/44536447
参照2:http://blog.csdn.net/girlkoo/article/details/44626011
2017-02-04 22:52:54
目录:
本文的目的是,完成一个从sd卡启动的一个纯净版的linux系统移植,其实就是一个很裸的根文件系统,后期有空会试着把QT移植进入.
下面开始移植了,我使用的开发板是天嵌的E9,但是使用主要是imx6q开发板便宜,现在选择的余地可能大很多.
我移植过程的源码下载地址为:http://pan.baidu.com/s/1bnOr7Ef,提供内容见里面的readme
1. uboot 的移植
资料下载:
官方资源下载:uboot的下载地址,在百度上搜索git freescale 即进入freescale的管理库,里面资源很多,uboot版本为imx_v2009.08_3.0.35_4.1.0,点击download即可下载,这个版本对应的linux版本为3.0.35_4.1.0,当然linux内核版本在git freescale也可下载.
(1)首先是习惯性的make distclean
移除所有以前的记录,这样保证我是在一个干净的环境下进行编译.
(2)参考上面文档,我的参考平台是mx6q_sabresd
我就直接在原版基础上进行修改了,需修改的文件都在"./board/freescale/mx6q_sabresd"下"flash_header.S"和"mx6q_sabresd.c".
(3)修改"flash_header.S"文件
使用下面代码替换源文件中代码
1 #else /* i.MX6Q */ 2 dcd_hdr: .word 0x40a002D2 /* Tag=0xD2, Len=83*8 + 4 + 4, Ver=0x40 */ 3 write_dcd_cmd: .word 0x049c02CC /* Tag=0xCC, Len=83*8 + 4, Param=0x04 */ 4 5 /* DCD */ 6 7 8 MXC_DCD_ITEM(1, IOMUXC_BASE_ADDR + 0x798, 0x000C0000) 9 MXC_DCD_ITEM(2, IOMUXC_BASE_ADDR + 0x758, 0x00000000) 10 11 MXC_DCD_ITEM(3, IOMUXC_BASE_ADDR + 0x588, 0x00000030) 12 MXC_DCD_ITEM(4, IOMUXC_BASE_ADDR + 0x594, 0x00000030) 13 14 MXC_DCD_ITEM(5, IOMUXC_BASE_ADDR + 0x56c, 0x00000030) 15 MXC_DCD_ITEM(6, IOMUXC_BASE_ADDR + 0x578, 0x00000030) 16 MXC_DCD_ITEM(7, IOMUXC_BASE_ADDR + 0x74c, 0x00000030) 17 18 MXC_DCD_ITEM(8, IOMUXC_BASE_ADDR + 0x57c, 0x00000030) 19 20 MXC_DCD_ITEM(9, IOMUXC_BASE_ADDR + 0x58c, 0x00000000) 21 MXC_DCD_ITEM(10, IOMUXC_BASE_ADDR + 0x59c, 0x00000030) 22 MXC_DCD_ITEM(11, IOMUXC_BASE_ADDR + 0x5a0, 0x00000030) 23 MXC_DCD_ITEM(12, IOMUXC_BASE_ADDR + 0x78c, 0x00000030) 24 25 MXC_DCD_ITEM(13, IOMUXC_BASE_ADDR + 0x750, 0x00020000) 26 27 MXC_DCD_ITEM(14, IOMUXC_BASE_ADDR + 0x5a8, 0x00000018) /* 00000030 */ 28 MXC_DCD_ITEM(15, IOMUXC_BASE_ADDR + 0x5b0, 0x00000018) /* 00000030 */ 29 MXC_DCD_ITEM(16, IOMUXC_BASE_ADDR + 0x524, 0x00000018) /* 00000030 */ 30 MXC_DCD_ITEM(17, IOMUXC_BASE_ADDR + 0x51c, 0x00000018) /* 00000030 */ 31 MXC_DCD_ITEM(18, IOMUXC_BASE_ADDR + 0x518, 0x00000018) /* 00000030 */ 32 MXC_DCD_ITEM(19, IOMUXC_BASE_ADDR + 0x50c, 0x00000018) /* 00000030 */ 33 MXC_DCD_ITEM(20, IOMUXC_BASE_ADDR + 0x5b8, 0x00000018) /* 00000030 */ 34 MXC_DCD_ITEM(21, IOMUXC_BASE_ADDR + 0x5c0, 0x00000018) /* 00000030 */ 35 36 MXC_DCD_ITEM(22, IOMUXC_BASE_ADDR + 0x774, 0x00020000) 37 38 MXC_DCD_ITEM(23, IOMUXC_BASE_ADDR + 0x784, 0x00000018) /* 00000030 */ 39 MXC_DCD_ITEM(24, IOMUXC_BASE_ADDR + 0x788, 0x00000018) /* 00000030 */ 40 MXC_DCD_ITEM(25, IOMUXC_BASE_ADDR + 0x794, 0x00000018) /* 00000030 */ 41 MXC_DCD_ITEM(26, IOMUXC_BASE_ADDR + 0x79c, 0x00000018) /* 00000030 */ 42 MXC_DCD_ITEM(27, IOMUXC_BASE_ADDR + 0x7a0, 0x00000018) /* 00000030 */ 43 MXC_DCD_ITEM(28, IOMUXC_BASE_ADDR + 0x7a4, 0x00000018) /* 00000030 */ 44 MXC_DCD_ITEM(29, IOMUXC_BASE_ADDR + 0x7a8, 0x00000018) /* 00000030 */ 45 MXC_DCD_ITEM(30, IOMUXC_BASE_ADDR + 0x748, 0x00000018) /* 00000030 */ 46 47 MXC_DCD_ITEM(31, IOMUXC_BASE_ADDR + 0x5ac, 0x00000018) /* 00000030 */ 48 MXC_DCD_ITEM(32, IOMUXC_BASE_ADDR + 0x5b4, 0x00000018) /* 00000030 */ 49 MXC_DCD_ITEM(33, IOMUXC_BASE_ADDR + 0x528, 0x00000018) /* 00000030 */ 50 MXC_DCD_ITEM(34, IOMUXC_BASE_ADDR + 0x520, 0x00000018) /* 00000030 */ 51 MXC_DCD_ITEM(35, IOMUXC_BASE_ADDR + 0x514, 0x00000018) /* 00000030 */ 52 MXC_DCD_ITEM(36, IOMUXC_BASE_ADDR + 0x510, 0x00000018) /* 00000030 */ 53 MXC_DCD_ITEM(37, IOMUXC_BASE_ADDR + 0x5bc, 0x00000018) /* 00000030 */ 54 MXC_DCD_ITEM(38, IOMUXC_BASE_ADDR + 0x5c4, 0x00000018) /* 00000030 */ 55 56 MXC_DCD_ITEM(39, MMDC_P0_BASE_ADDR + 0x800, 0xA1390003) 57 58 MXC_DCD_ITEM(40, MMDC_P0_BASE_ADDR + 0x80c, 0x001F001F) 59 MXC_DCD_ITEM(41, MMDC_P0_BASE_ADDR + 0x810, 0x001F001F) 60 MXC_DCD_ITEM(42, MMDC_P1_BASE_ADDR + 0x80c, 0x001F001F) 61 MXC_DCD_ITEM(43, MMDC_P1_BASE_ADDR + 0x810, 0x001F001F) 62 63 MXC_DCD_ITEM(44, MMDC_P0_BASE_ADDR + 0x83c, 0x4333033F) 64 MXC_DCD_ITEM(45, MMDC_P0_BASE_ADDR + 0x840, 0x032C031D) 65 MXC_DCD_ITEM(46, MMDC_P1_BASE_ADDR + 0x83c, 0x43200332) 66 MXC_DCD_ITEM(47, MMDC_P1_BASE_ADDR + 0x840, 0x031A026A) 67 MXC_DCD_ITEM(48, MMDC_P0_BASE_ADDR + 0x848, 0x4D464746) 68 MXC_DCD_ITEM(49, MMDC_P1_BASE_ADDR + 0x848, 0x47453F4D) 69 MXC_DCD_ITEM(50, MMDC_P0_BASE_ADDR + 0x850, 0x3E434440) 70 MXC_DCD_ITEM(51, MMDC_P1_BASE_ADDR + 0x850, 0x47384839) 71 72 MXC_DCD_ITEM(52, MMDC_P0_BASE_ADDR + 0x81c, 0x33333333) 73 MXC_DCD_ITEM(53, MMDC_P0_BASE_ADDR + 0x820, 0x33333333) 74 MXC_DCD_ITEM(54, MMDC_P0_BASE_ADDR + 0x824, 0x33333333) 75 MXC_DCD_ITEM(55, MMDC_P0_BASE_ADDR + 0x828, 0x33333333) 76 MXC_DCD_ITEM(56, MMDC_P1_BASE_ADDR + 0x81c, 0x33333333) 77 MXC_DCD_ITEM(57, MMDC_P1_BASE_ADDR + 0x820, 0x33333333) 78 MXC_DCD_ITEM(58, MMDC_P1_BASE_ADDR + 0x824, 0x33333333) 79 MXC_DCD_ITEM(59, MMDC_P1_BASE_ADDR + 0x828, 0x33333333) 80 81 MXC_DCD_ITEM(60, MMDC_P0_BASE_ADDR + 0x8b8, 0x00000800) 82 MXC_DCD_ITEM(61, MMDC_P1_BASE_ADDR + 0x8b8, 0x00000800) 83 84 MXC_DCD_ITEM(62, MMDC_P0_BASE_ADDR + 0x004, 0x00020036) 85 MXC_DCD_ITEM(63, MMDC_P0_BASE_ADDR + 0x008, 0x09444040) 86 MXC_DCD_ITEM(64, MMDC_P0_BASE_ADDR + 0x00c, 0x8A8F7955) /* 555A7975 */ 87 MXC_DCD_ITEM(65, MMDC_P0_BASE_ADDR + 0x010, 0xFF328F64) /* FF328F64 */ 88 MXC_DCD_ITEM(66, MMDC_P0_BASE_ADDR + 0x014, 0x01FF00DB) 89 MXC_DCD_ITEM(67, MMDC_P0_BASE_ADDR + 0x018, 0x00001740) 90 91 MXC_DCD_ITEM(68, MMDC_P0_BASE_ADDR + 0x01c, 0x00008000) 92 MXC_DCD_ITEM(69, MMDC_P0_BASE_ADDR + 0x02c, 0x000026D2) 93 MXC_DCD_ITEM(70, MMDC_P0_BASE_ADDR + 0x030, 0x008F1023) /* 005A1023 */ 94 MXC_DCD_ITEM(71, MMDC_P0_BASE_ADDR + 0x040, 0x00000047) /* 00000027 */ 95 96 MXC_DCD_ITEM(72, MMDC_P0_BASE_ADDR + 0x000, 0x841A0000) /* 831A0000 */ 97 98 MXC_DCD_ITEM(73, MMDC_P0_BASE_ADDR + 0x01c, 0x04088032) 99 MXC_DCD_ITEM(74, MMDC_P0_BASE_ADDR + 0x01c, 0x00008033) 100 MXC_DCD_ITEM(75, MMDC_P0_BASE_ADDR + 0x01c, 0x00048031) 101 MXC_DCD_ITEM(76, MMDC_P0_BASE_ADDR + 0x01c, 0x09408030) 102 MXC_DCD_ITEM(77, MMDC_P0_BASE_ADDR + 0x01c, 0x04008040) 103 104 MXC_DCD_ITEM(78, MMDC_P0_BASE_ADDR + 0x020, 0x00005800) 105 106 MXC_DCD_ITEM(79, MMDC_P0_BASE_ADDR + 0x818, 0x00011117) 107 MXC_DCD_ITEM(80, MMDC_P1_BASE_ADDR + 0x818, 0x00011117) 108 109 MXC_DCD_ITEM(81, MMDC_P0_BASE_ADDR + 0x004, 0x00025576) 110 MXC_DCD_ITEM(82, MMDC_P0_BASE_ADDR + 0x404, 0x00011006) 111 MXC_DCD_ITEM(83, MMDC_P0_BASE_ADDR + 0x01c, 0x00000000) 112 113 #endif
(4)修改"mx6q_sabresd.c"文件
完成对应硬件的uart的修改和mmc的修改
uart1移植,修改UART1对应的TXD和RXD引脚.
1 static void setup_uart(void) 2 { 3 #if defined CONFIG_MX6Q 4 /* UART1 TXD */ 5 //mxc_iomux_v3_setup_pad(MX6Q_PAD_CSI0_DAT10__UART1_TXD); 6 /* UART1 RXD */ 7 //mxc_iomux_v3_setup_pad(MX6Q_PAD_CSI0_DAT11__UART1_RXD); 8 9 /* UART1 TXD */ 10 mxc_iomux_v3_setup_pad(MX6Q_PAD_SD3_DAT7__UART1_TXD); 11 12 // /* UART1 RXD */ 13 mxc_iomux_v3_setup_pad(MX6Q_PAD_SD3_DAT6__UART1_RXD); 14 15 #elif defined CONFIG_MX6DL 16 /* UART1 TXD */ 17 mxc_iomux_v3_setup_pad(MX6DL_PAD_CSI0_DAT10__UART1_TXD); 18 19 /* UART1 RXD */ 20 mxc_iomux_v3_setup_pad(MX6DL_PAD_CSI0_DAT11__UART1_RXD); 21 #endif 22 }
mmc移植,解决mmc的引脚冲突文件,
1 iomux_v3_cfg_t usdhc3_pads[] = { 2 MX6Q_PAD_SD3_CLK__USDHC3_CLK, 3 MX6Q_PAD_SD3_CMD__USDHC3_CMD, 4 MX6Q_PAD_SD3_DAT0__USDHC3_DAT0, 5 MX6Q_PAD_SD3_DAT1__USDHC3_DAT1, 6 MX6Q_PAD_SD3_DAT2__USDHC3_DAT2, 7 MX6Q_PAD_SD3_DAT3__USDHC3_DAT3, 8 // MX6Q_PAD_SD3_DAT4__USDHC3_DAT4, 9 // MX6Q_PAD_SD3_DAT5__USDHC3_DAT5, 10 // MX6Q_PAD_SD3_DAT6__USDHC3_DAT6, 11 // MX6Q_PAD_SD3_DAT7__USDHC3_DAT7, 12 };
( 5 )修改uboot启动默认环境变量.
初始烧写时,存放uboot环境变量的存储空间无环境变量,此时uboot会使用默认的环境变量,imx6q_sabresd默认环境变量位置为 ./include/configs 下的mx6q_sabresd.h.
vi mx6q_sabresd.h
默认环境变量为
1 #define CONFIG_EXTRA_ENV_SETTINGS 2 "netdev=eth0\0" 3 "ethprime=FEC0\0" 4 "uboot=u-boot.bin\0" 5 "kernel=uImage\0" 6 "nfsroot=/opt/eldk/arm\0" 7 "bootargs_base=setenv bootargs console=ttymxc0,115200\0" 8 "bootargs_nfs=setenv bootargs ${bootargs} root=/dev/nfs " 9 "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0"10 "bootcmd_net=run bootargs_base bootargs_nfs; " 11 "tftpboot ${loadaddr} ${kernel}; bootm\0" 12 "bootargs_mmc=setenv bootargs ${bootargs} ip=dhcp " 13 "root=/dev/mmcblk0p1 rootwait\0" 14 "bootcmd_mmc=run bootargs_base bootargs_mmc; " 15 "mmc dev 3; " 16 "mmc read ${loadaddr} 0x800 0x2000; bootm\0" 17 "bootcmd=run bootcmd_net\0"
需要修改处:
①根文件系统存储地址
"root=/dev/mmcblk0p1 rootwait\0" 更改为 "root=/dev/mmcblk1p1 rootwait\0"
②uboot 运行的参数
"bootcmd=run bootcmd_net\0" 这为启动网络方式挂载内核和根文件系统 更改为 "bootcmd=run bootcmd_mmc\0" 这为从flash中获取内核和根文件系统
③获取可执行程序位置
"mmc dev 3; " 更改为 "mmc dev 1; "
④去掉IP地址通过DHCP获取
"bootargs_mmc=setenv bootargs ${bootargs} ip=dhcp " \ 更改为 "bootargs_mmc=setenv bootargs ${bootargs} " \
⑤增加了uboot期间,网络的mac地址
"ethaddr=11:22:33:44:55:66\0"\
⑥更改了网络挂载根文件系统的位置
"nfsroot=/home/shirf/my_explore/nfs_file/rootfs\0"
⑦更改了通过网络获取内核和根文件系统时的配置
"bootargs_nfs=setenv bootargs ${bootargs} root=/dev/nfs "\
"ip=${ipaddr} nfsroot=${serverip}:${nfsroot},v3,tcp\0"\
不用原版的通过dhcp获取ip,而用uboot环境变量中的静态ip
更改后我的默认环境变量为
1 #define CONFIG_EXTRA_ENV_SETTINGS 2 "ethaddr=11:22:33:44:55:66\0" 3 "netdev=eth0\0" 4 "ethprime=FEC0\0" 5 "uboot=u-boot.bin\0" 6 "kernel=uImage\0" 7 "nfsroot=/home/shirf/my_explore/nfs_file/rootfs\0" 8 "bootargs_base=setenv bootargs console=ttymxc0,115200\0" 9 "bootargs_nfs=setenv bootargs ${bootargs} root=/dev/nfs "10 "ip=${ipaddr} nfsroot=${serverip}:${nfsroot},v3,tcp\0"11 "bootcmd_net=run bootargs_base bootargs_nfs; " 12 "tftpboot ${loadaddr} ${kernel}; bootm\0" 13 "bootargs_mmc=setenv bootargs ${bootargs} " 14 "root=/dev/mmcblk1p1 rootwait\0" 15 "bootcmd_mmc=run bootargs_base bootargs_mmc; " 16 "mmc dev 1; " 17 "mmc read ${loadaddr} 0x800 0x2000; bootm\0" 18 "bootcmd=run bootcmd_mmc\0"
按照如上修改,就可以从SD卡获取剩余的内核和根文件系统,并进行后面的程序启动.
uboot启动时,默认的ip地址也在./include/configs 下的mx6q_sabresd.h.
1 175 #define CONFIG_IPADDR 192.168.1.103 2 176 #define CONFIG_SERVERIP 192.168.1.101 3 177 #define CONFIG_NETMASK 255.255.255.0
(6)编辑编译脚本
1 vi build.sh 2 3 export ARCH=arm 4 export CROSS_COMPILE=arm-none-linux-gnueabi- 5 make distclean 6 make mx6q_sabresd_config 7 make
chmod +x build.sh
./build.sh
烧写文件:在uboot的根目录下生成,u-boot.bin即使需要的烧写文件
2,linux内核移植
资源下载:
官方下载地址:http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/commit/?h=imx_3.0.35_4.1.0,下载内核版本为linux_imx_3,0.35_4.1.0版本
( 1 )首先习惯性使用make distclean 对源码进行清零.
( 2 )修改串口配置,
进入arch/arm/mach-mx6/目录,修改
vi board-mx6q_sabresd.h /* UART1 for debug */ //MX6Q_PAD_CSI0_DAT10__UART1_TXD, //MX6Q_PAD_CSI0_DAT11__UART1_RXD, MX6Q_PAD_SD3_DAT7__UART1_TXD, MX6Q_PAD_SD3_DAT6__UART1_RXD,
(3)修改SD配置部分
/* USDHC2 */ MX6Q_PAD_SD2_CLK__USDHC2_CLK, MX6Q_PAD_SD2_CMD__USDHC2_CMD, MX6Q_PAD_SD2_DAT0__USDHC2_DAT0, MX6Q_PAD_SD2_DAT1__USDHC2_DAT1, MX6Q_PAD_SD2_DAT2__USDHC2_DAT2, MX6Q_PAD_SD2_DAT3__USDHC2_DAT3, //MX6Q_PAD_NANDF_D4__USDHC2_DAT4, //MX6Q_PAD_NANDF_D5__USDHC2_DAT5, //MX6Q_PAD_NANDF_D6__USDHC2_DAT6, //MX6Q_PAD_NANDF_D7__USDHC2_DAT7, //MX6Q_PAD_NANDF_D2__GPIO_2_2, /* SD2_CD */ //MX6Q_PAD_NANDF_D3__GPIO_2_3, /* SD2_WP */ MX6Q_PAD_GPIO_2__USDHC2_WP, MX6Q_PAD_GPIO_4__USDHC2_CD,
(4)修改SD3于串口冲突地方,修改为
/* USDHC3 */ MX6Q_PAD_SD3_CLK__USDHC3_CLK_50MHZ, MX6Q_PAD_SD3_CMD__USDHC3_CMD_50MHZ, MX6Q_PAD_SD3_DAT0__USDHC3_DAT0_50MHZ, MX6Q_PAD_SD3_DAT1__USDHC3_DAT1_50MHZ, MX6Q_PAD_SD3_DAT2__USDHC3_DAT2_50MHZ, MX6Q_PAD_SD3_DAT3__USDHC3_DAT3_50MHZ, //MX6Q_PAD_SD3_DAT4__USDHC3_DAT4_50MHZ, //MX6Q_PAD_SD3_DAT5__USDHC3_DAT5_50MHZ, //MX6Q_PAD_SD3_DAT6__USDHC3_DAT6_50MHZ, //MX6Q_PAD_SD3_DAT7__USDHC3_DAT7_50MHZ, MX6Q_PAD_NANDF_D0__GPIO_2_0, /* SD3_CD */ MX6Q_PAD_NANDF_D1__GPIO_2_1, /* SD3_WP */
(5)修改board-mx6q_sabresd.c
vi board-mx6q_sabresd.c
//#define SABRESD_SD2_CD IMX_GPIO_NR(2, 2) //#define SABRESD_SD2_WP IMX_GPIO_NR(2, 3) #define SABRESD_SD2_CD IMX_GPIO_NR(1, 4) #define SABRESD_SD2_WP IMX_GPIO_NR(1, 2)
(6)编译内核需求工具
编译内核需要mkimage工具,此工具在uboot 下tools目录中,有两种方式,
第一种,讲mkimage复制到/usr/bin下
第二种讲./tools加到环境变量中.
此时,在编译内核时,就会找到mkimage工具
(7)写编译脚本
回到内核源码的根目录中
vi build.sh
export ARCH=arm export CROSS_COMPILE=arm-none-linux-gnueabi- make distclean make imx6_defconfig make uImage
chmod +x build.sh
./build.sh
此时就开始编译内核,但是时间大概要5分钟左右,可以洗洗刷刷.
烧写文件:./arch/arm/boot/ 目录下uImage文件
3.根文件系统制作
rootfs所需资料:一个目录结构,busybox,linux内核模块,编译器的库.
其中busybox提供精简而常用的指令.busybox下载地址:百度下就知道了 https://busybox.net/
下面开始建立rootfs了,
( 1 )建立目录结构
vi rootfs.sh
#!/bin/sh echo "------Create rootfs directons start...--------" mkdir rootfs cd rootfs echo "--------Create root,dev....----------" mkdir bin sbin root dev etc boot tmp var sys proc lib mnt home usr mkdir usr/sbin usr/bin usr/lib usr/modules echo "make node in dev/console dev/null" sudo mknod -m 600 dev/console c 5 1 sudo mknod -m 600 dev/null c 1 3 mkdir mnt/etc mnt/jffs2 mnt/yaffs mnt/data mnt/temp mkdir var/lib var/lock var/run var/tmp chmod 1777 tmp chmod 1777 var/tmp echo "-------make direction done---------"
chmod +x rootfs.sh
./rootfs.sh
(2)安装busybox
我使用busybox-1_24_stable.tar.bz2版本
tar -xvjf busybox-1_24_stable.tar.bz2 cd busybox-1_24_stable/ make distclean make defconfig make menuconfig
配置菜单跟配置内核时的差不多,依次进入 Busybox Settings => Build Options => Cross Compiler prefix (NEW) ,设置为编译器的前缀,我的是 arm-none-linux-gnueabi-
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
make CONFIG_PREFIX=../rootfs install
至此,busybox安装完毕
(3)配置etc启动项
busybox自带的etc默认在 busybox-1_24_stable/examples/bootfloppy/etc/ 文件夹下,就以此为模板来修改
cp -rf busybox-1_24_stable/examples/bootfloppy/etc/* rootfs/etc/
①inittab文件更改为
::sysinit:/etc/init.d/rcS #power on not login ::respawn:-/bin/sh #power on need login #::respawn:-/bin/login ::ctrlaltdel:/bin/umount -a -r
②profie文件更改为
# /etc/profile: system-wide .profile file for the Bourne shells PATH=/bin:/sbin:/usr/bin:/usr/sbin export LD_LIBRARY_PATH=/lib:/usr/lib echo echo -n "Processing /etc/profile... " echo "Done" echo
③init/rcS文件更改为
#! /bin/sh /bin/mkdir -p /dev/pts /bin/mkdir -p /dev/shm /bin/mount -a /bin/mount -t tmpfs mdev /dev /bin/echo /sbin/mdev > /proc/sys/kernel/hotplug mdev -s #######config Network################################ /sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0 /sbin/ifconfig eth0 192.168.1.103 /sbin/ifconfig eth0 netmask 255.255.255.0 /sbin/route add default gw 192.168.1.1 eth0
④fstab文件更改为
proc /proc proc defaults 0 0 sysfs /sys sysfs defaults 0 0 none /dev/pts devpts mode=0622 0 0 tmpfs /dev/shm tmpfs defaults 0
⑤登陆用户
cp /etc/passwd etc/ cp /etc/shadow etc/ cp /etc/group etc/
保留你需要的登陆用户名
当然此步可以忽略,无此步就是需要要任何认证即可登陆
(4)安装内核模块
进入linux-3.0.35内核源码根目录
make modules ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
make modules_install ARCH=arm INSTALL_MOD_PATH=../mkrootfs/rootfs
至此完成内核模块的安装
(5)复制编译器的库
cp -pR ../../arm-none-linux-gnueabi-4.8.3/arm-none-linux-gnueabi/libc/lib/*so* ./lib/ -d cp -pR ../../arm-none-linux-gnueabi-4.8.3/arm-none-linux-gnueabi/libc/usr/lib/*so* ./usr/lib/ -d
此次库安装完毕.
打包跟文件系统,进入根文件系统的根目录,
tar cvzf rootfs.tgz *
此时,rootfs.tgz就是打包好的根文件系统.
到此为止,根文件系统建立完毕.下面开始烧写可执行文件喽.
4.烧写
烧写所需食材就是前面生成的可执行文件,u-boot.bin/uImage/rootfs.tgz.
我的SD卡为sdb设备文件,根据挂载的设备文件不同进行修改.
( 1 )擦除环境变量存储位置
sudo dd if=/dev/zero of=/dev/sdb bs=512 seek=1536 count=16 sync
( 2 )烧写u-boot.bin
sudo dd if=u-boot.bin of=/dev/sdb bs=512 seek=2 skip=2 sync
( 3)烧写uImage
sudo dd if=uImage of=/dev/sdb bs=512 seek=2048 sync
(4)烧写根文件系统
对SD进行ext3分区,并拷贝文件分区
sudo fdisk /dev/sdb
Step1: 通过指令u切换到sectors模式。输入u后回车,fdisk会在sectors模式和cylinders模式间切换,这里切换到sectors模式。
Step2:通过d指令删除原来的分区。重复的输入d并回车,可以删除SD卡原有的分区,知道没有任何分区为止。
Step3:通过n指令新建分区。输入n并回车。
Step4:通过p指令设置为主分区。输入p并回车。
Step5:输入分区编号。这里输入数字1。
Step6:输入分区的起始位置。该位置是sectors为单位的,每个sector的大小为512B,这里偏移8M,给内核留下足够的存储空间,输入16384(8192*2)并回车。
Step7:输入分区的结束为止。直接使用默认值,即到达SD卡的末尾,故直接回车即可。
Step8:保存分区信息。输入指令w并回车。
使用ext3格式化SD卡
sudo mkfs.ext3 /dev/sdb1
挂载SD卡到/mnt目录下,这样就可用对SD卡进行操作
sudo mount /dev/sdb1 /mnt sudo tar xvzf rootfs.tgz -C /mnt/ sync
此时,已完成平台移植,查到开发板开电,是不是很激动而紧张啊
5.上电打印信息
U-Boot 2009.08-dirty ( 1??月 24 2016 - 20:47:28) CPU: Freescale i.MX6 family TO1.2 at 792 MHz Thermal sensor with ratio = 170 Temperature: 20 C, calibration data 0x5384a769 mx6q pll1: 792MHz mx6q pll2: 528MHz mx6q pll3: 480MHz mx6q pll8: 50MHz ipg clock : 66000000Hz ipg per clock : 66000000Hz uart clock : 80000000Hz cspi clock : 60000000Hz ahb clock : 132000000Hz axi clock : 264000000Hz emi_slow clock: 132000000Hz ddr clock : 528000000Hz usdhc1 clock : 198000000Hz usdhc2 clock : 198000000Hz usdhc3 clock : 198000000Hz usdhc4 clock : 198000000Hz nfc clock : 24000000Hz Board: i.MX6Q-SABRESD: unknown-board Board: 0x63012 [WDOG ] Boot Device: SD I2C: ready DRAM: 1 GB MMC: FSL_USDHC: 0,FSL_USDHC: 1,FSL_USDHC: 2,FSL_USDHC: 3 *** Warning - bad CRC or MMC, using default environment In: serial Out: serial Err: serial Net: got MAC address from IIM: 00:00:00:00:00:00 FEC0 [PRIME] Hit any key to stop autoboot: 0 mmc1 is current device MMC read: dev # 1, block # 2048, count 8192 ... 8192 blocks read: OK ## Booting kernel from Legacy Image at 10800000 ... Image Name: Linux-3.0.35 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 3847528 Bytes = 3.7 MB Load Address: 10008000 Entry Point: 10008000 Verifying Checksum ... OK Loading Kernel Image ... OK OK Starting kernel ... Uncompressing Linux... done, booting the kernel. Linux version 3.0.35 (shirf@shirf-pc) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29) ) #1 SMP PREEMPT Sun Jan 246 CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c53c7d CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache Machine: Freescale i.MX 6Quad/DualLite/Solo Sabre-SD Board Ignoring unrecognised tag 0x54410008 Memory policy: ECC disabled, Data cache writealloc CPU identified as i.MX6Q, silicon rev 1.2 PERCPU: Embedded 7 pages/cpu @8c008000 s5440 r8192 d15040 u32768 Built 1 zonelists in Zone order, mobility grouping on. Total pages: 194560 Kernel command line: console=ttymxc0,115200 root=/dev/mmcblk1p1 rootwait PID hash table entries: 4096 (order: 2, 16384 bytes) Dentry cache hash table entries: 131072 (order: 7, 524288 bytes) Inode-cache hash table entries: 65536 (order: 6, 262144 bytes) Memory: 512MB 256MB = 768MB total Memory: 765844k/765844k available, 282732k reserved, 0K highmem Virtual kernel memory layout: vector : 0xffff0000 - 0xffff1000 ( 4 kB) fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB) DMA : 0xf4600000 - 0xffe00000 ( 184 MB) vmalloc : 0xc0800000 - 0xf2000000 ( 792 MB) lowmem : 0x80000000 - 0xc0000000 (1024 MB) pkmap : 0x7fe00000 - 0x80000000 ( 2 MB) modules : 0x7f000000 - 0x7fe00000 ( 14 MB) .init : 0x80008000 - 0x8003c000 ( 208 kB) .text : 0x8003c000 - 0x80a9a220 (10617 kB) .data : 0x80a9c000 - 0x80affce0 ( 400 kB) .bss : 0x80affd04 - 0x80b2db4c ( 184 kB) SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=4, Nodes=1 Preemptible hierarchical RCU implementation. NR_IRQS:624 MXC GPIO hardware sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 1431655ms arm_max_freq=1GHz MXC_Early serial console at MMIO 0x2020000 (options ‘115200‘) bootconsole [ttymxc0] enabled Console: colour dummy device 80x30 Calibrating delay loop... 1581.05 BogoMIPS (lpj=7905280) pid_max: default: 32768 minimum: 301 Mount-cache hash table entries: 512 CPU: Testing write buffer coherency: ok hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 7 counters available CPU1: Booted secondary processor CPU2: Booted secondary processor CPU3: Booted secondary processor Brought up 4 CPUs SMP: Total of 4 processors activated (6324.22 BogoMIPS). print_constraints: dummy: NET: Registered protocol family 16 print_constraints: vddpu: 725 <--> 1300 mV at 700 mV fast normal print_constraints: vddcore: 725 <--> 1300 mV at 1150 mV fast normal print_constraints: vddsoc: 725 <--> 1300 mV at 1200 mV fast normal print_constraints: vdd2p5: 2000 <--> 2775 mV at 2400 mV fast normal print_constraints: vdd1p1: 800 <--> 1400 mV at 1100 mV fast normal print_constraints: vdd3p0: 2625 <--> 3400 mV at 3000 mV fast normal hw-breakpoint: found 6 breakpoint and 1 watchpoint registers. hw-breakpoint: 1 breakpoint(s) reserved for watchpoint single-step. hw-breakpoint: maximum watchpoint size is 4 bytes. L310 cache controller enabled l2x0: 16 ways, CACHE_ID 0x410000c7, AUX_CTRL 0x32070000, Cache size: 1048576 B bio: create slab <bio-0> at 0 mxs-dma mxs-dma-apbh: initialized print_constraints: SPKVDD: 4200 mV print_constraints: vmmc: 3300 mV SCSI subsystem initialized spi_imx imx6q-ecspi.0: probed usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb Freescale USB OTG Driver loaded, $Revision: 1.55 $ mc_pfuze 1-0008: recv failed!:-5,c8 mc_pfuze: probe of 1-0008 failed with error -1 imx-ipuv3 imx-ipuv3.0: IPU DMFC NORMAL mode: 1(0~1), 5B(4,5), 5F(6,7) imx-ipuv3 imx-ipuv3.1: IPU DMFC NORMAL mode: 1(0~1), 5B(4,5), 5F(6,7) mxc_mipi_csi2 mxc_mipi_csi2: i.MX MIPI CSI2 driver probed mxc_mipi_csi2 mxc_mipi_csi2: i.MX MIPI CSI2 dphy version is 0x3130302a MIPI CSI2 driver module loaded Advanced Linux Sound Architecture Driver Version 1.0.24. Bluetooth: Core ver 2.16 NET: Registered protocol family 31 Bluetooth: HCI device and connection manager initialized Bluetooth: HCI socket layer initialized Bluetooth: L2CAP socket layer initialized Bluetooth: SCO socket layer initialized cfg80211: Calling CRDA to update world regulatory domain max17135 2-0048: PMIC MAX17135 for eInk display i2c-core: driver [max17135] using legacy suspend method i2c-core: driver [max17135] using legacy resume method Switching to clocksource mxc_timer1 NET: Registered protocol family 2 IP route cache hash table entries: 32768 (order: 5, 131072 bytes) TCP established hash table entries: 131072 (order: 8, 1048576 bytes) TCP bind hash table entries: 65536 (order: 7, 786432 bytes) TCP: Hash tables configured (established 131072 bind 65536) TCP reno registered UDP hash table entries: 512 (order: 2, 16384 bytes) UDP-Lite hash table entries: 512 (order: 2, 16384 bytes) NET: Registered protocol family 1 RPC: Registered named UNIX socket transport module. RPC: Registered udp transport module. RPC: Registered tcp transport module. RPC: Registered tcp NFSv4.1 backchannel transport module. PMU: registered new PMU device of type 0 Static Power Management for Freescale i.MX6 wait mode is enabled for i.MX6 cpaddr = 0 suspend_iram_base=f2900000 PM driver module loaded IMX usb wakeup probe add wake up source irq 75 IMX usb wakeup probe cpu regulator mode:ldo_enable i.MXC CPU frequency driver JFFS2 version 2.2. (NAND) ?? 2001-2006 Red Hat, Inc. msgmni has been set to 1495 alg: No test for stdrng (krng) io scheduler noop registered io scheduler deadline registered io scheduler cfq registered (default) mxc_mipi_dsi mxc_mipi_dsi: i.MX MIPI DSI driver probed MIPI DSI driver module loaded mxc_sdc_fb mxc_sdc_fb.0: register mxc display driver ldb _regulator_get: get() with no identifier imx-ipuv3 imx-ipuv3.1: IPU DMFC DP HIGH RESOLUTION: 1(0,1), 5B(2~5), 5F(6,7) Console: switching to colour frame buffer device 128x48 mxc_sdc_fb mxc_sdc_fb.1: register mxc display driver ldb mxc_sdc_fb mxc_sdc_fb.2: register mxc display driver lcd mxc_sdc_fb mxc_sdc_fb.3: register mxc display driver ldb mxc_sdc_fb mxc_sdc_fb.3: ipu1-di0 already in use mxc_sdc_fb: probe of mxc_sdc_fb.3 failed with error -16 imx-sdma imx-sdma: loaded firmware 1.1 imx-sdma imx-sdma: initialized Serial: IMX driver imx-uart.2: ttymxc2 at MMIO 0x21ec000 (irq = 60) is a IMX imx-uart.0: ttymxc0 at MMIO 0x2020000 (irq = 58) is a IMX console [ttymxc0] enabled, bootconsole disabled console [ttymxc0] enabled, bootconsole disabled loop: module loaded Wait for CR ACK error! sata phy rx_pll is stable! No sata disk. m25p80 spi0.0: unrecognized JEDEC id ffffff GPMI NAND driver registered. (IMX) vcan: Virtual CAN interface driver CAN device driver interface flexcan netdevice driver FEC Ethernet Driver fec_enet_mii_bus: probed ehci_hcd: USB 2.0 ‘Enhanced‘ Host Controller (EHCI) Driver fsl-ehci fsl-ehci.0: Freescale On-Chip EHCI Host Controller fsl-ehci fsl-ehci.0: new USB bus registered, assigned bus number 1 fsl-ehci fsl-ehci.0: irq 75, io base 0x02184000 fsl-ehci fsl-ehci.0: USB 2.0 started, EHCI 1.00 hub 1-0:1.0: USB hub found hub 1-0:1.0: 1 port detected add wake up source irq 72 fsl-ehci fsl-ehci.1: Freescale On-Chip EHCI Host Controller fsl-ehci fsl-ehci.1: new USB bus registered, assigned bus number 2 fsl-ehci fsl-ehci.1: irq 72, io base 0x02184200 fsl-ehci fsl-ehci.1: USB 2.0 started, EHCI 1.00 hub 2-0:1.0: USB hub found hub 2-0:1.0: 1 port detected Initializing USB Mass Storage driver... usbcore: registered new interface driver usb-storage USB Mass Storage support registered. ARC USBOTG Device Controller driver (1 August 2005) mousedev: PS/2 mouse device common for all mice input: gpio-keys as /devices/platform/gpio-keys/input/input0 input: max11801_ts as /devices/platform/imx-i2c.1/i2c-1/1-0048/input/input1 egalax_ts 1-0004: egalax_ts: failed to read firmware version egalax_ts: probe of 1-0004 failed with error -5 egalax_ts 2-0004: egalax_ts: failed to read firmware version egalax_ts: probe of 2-0004 failed with error -5 usb 2-1: new high speed USB device number 2 using fsl-ehci elan - Read Hello Packet Failed elan-touch: probe of 2-0010 failed with error -22 i2c-core: driver [isl29023] using legacy suspend method i2c-core: driver [isl29023] using legacy resume method snvs_rtc snvs_rtc.0: rtc core: registered snvs_rtc as rtc0 i2c /dev entries driver Linux video capture interface: v2.00 mxc_v4l2_output mxc_v4l2_output.0: V4L2 device registered as video16 mxc_v4l2_output mxc_v4l2_output.0: V4L2 device registered as video17 mxc_v4l2_output mxc_v4l2_output.0: V4L2 device registered as video18 mxc_v4l2_output mxc_v4l2_output.0: V4L2 device registered as video19 mxc_v4l2_output mxc_v4l2_output.0: V4L2 device registered as video20 hub 2-1:1.0: USB hub found hub 2-1:1.0: 4 ports detected mag3110 2-000e: check mag3110 chip ID mag3110 2-000e: read chip ID 0xfffffffb is not equal to 0xc4! mag3110: probe of 2-000e failed with error -22 i2c-core: driver [mag3110] using legacy suspend method i2c-core: driver [mag3110] using legacy resume method mma8451 0-001c: read chip ID 0x1 is not equal to 0x1a or 0x2a! mma8451: probe of 0-001c failed with error -22 imx2-wdt imx2-wdt.0: IMX2+ Watchdog Timer enabled. timeout=60s (nowayout=1) Bluetooth: Virtual HCI driver ver 1.3 Bluetooth: HCI UART driver ver 2.2 Bluetooth: HCIATH3K protocol initialized Bluetooth: Generic Bluetooth USB driver ver 0.6 usbcore: registered new interface driver btusb sdhci: Secure Digital Host Controller Interface driver sdhci: Copyright(c) Pierre Ossman mmc0: SDHCI controller on platform [sdhci-esdhc-imx.3] using DMA sdhci sdhci-esdhc-imx.1: no card-detect pin available! mmc1: SDHCI controller on platform [sdhci-esdhc-imx.1] using DMA mmc2: SDHCI controller on platform [sdhci-esdhc-imx.2] using DMA mxc_vdoa mxc_vdoa: i.MX Video Data Order Adapter(VDOA) driver probed VPU initialized mxc_asrc registered Galcore version 4.6.9.9754 Thermal calibration data is 0x5384a769 Thermal sensor with ratio = 170 Anatop Thermal registered as thermal_zone0 anatop_thermal_probe: default cooling device is cpufreq! leds-gpio: probe of leds-gpio failed with error -16 usbcore: registered new interface driver usbhid usbhid: USB HID core driver usbcore: registered new interface driver snd-usb-audio mxc_hdmi_soc mxc_hdmi_soc.0: MXC HDMI Audio Cirrus Logic CS42888 ALSA SoC Codec Driver i2c-core: driver [cs42888] using legacy suspend method i2c-core: driver [cs42888] using legacy resume method imx-hdmi-soc-dai imx-hdmi-soc-dai.0: Failed: Load HDMI-video first. wm8962 0-001a: Failed to get supply ‘DCVDD‘: -19 wm8962 0-001a: Failed to request supplies: -19 wm8962 0-001a: asoc: failed to probe CODEC wm8962.0-001a: -19 asoc: failed to instantiate card wm8962-audio: -19 mmc0: new high speed DDR MMC card at address 0001 imx_3stack asoc driver mmcblk0: mmc0:0001 008G92 7.28 GiB mmcblk0boot0: mmc0:0001 008G92 partition 1 4.00 MiB mmcblk0boot1: mmc0:0001 008G92 partition 2 4.00 MiB mmcblk0: p1 Initialize HDMI-audio failed. Load HDMI-video first! ALSA device list: No soundcards found. NET: Registered protocol family 26 mmcblk0boot1: unknown partition table TCP cubic registered NET: Registered protocol family 17 can: controller area network core (rev 20090105 abi 8) NET: Registered protocol family 29 can: raw protocol (rev 20090105) can: broadcast manager protocol (rev 20090105 t) Bluetooth: RFCOMM TTY layer initialized Bluetooth: RFCOMM socket layer initialized Bluetooth: RFCOMM ver 1.11 Bluetooth: BNEP (Ethernet Emulation) ver 1.3 Bluetooth: BNEP filters: protocol multicast mmcblk0boot0: unknown partition table Bluetooth: HIDP (Human Interface Emulation) ver 1.2 lib80211: common routines for IEEE802.11 drivers VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4 DDR type is DDR3 Bus freq driver module loaded Bus freq driver Enabled mxc_dvfs_core_probe DVFS driver module loaded regulator_init_complete: SPKVDD: incomplete constraints, leaving on snvs_rtc snvs_rtc.0: setting system clock to 1970-01-01 00:01:00 UTC (60) Waiting for root device /dev/mmcblk1p1... mmc1: new high speed SD card at address 1234 mmcblk1: mmc1:1234 SA02G 1.81 GiB mmcblk1: p1 EXT3-fs: barriers not enabled kjournald starting. Commit interval 5 seconds EXT3-fs (mmcblk1p1): using internal journal EXT3-fs (mmcblk1p1): recovery complete EXT3-fs (mmcblk1p1): mounted filesystem with writeback data mode VFS: Mounted root (ext3 filesystem) on device 179:25. Freeing init memory: 208K eth0: Freescale FEC PHY driver [Generic PHY] (mii_bus:phy_addr=1:00, irq=-1) Processing /etc/profile... Done / # PHY: 1:00 - Link is Up - 100/Full