1、安装Ubantu18.04 LTS 系统虚拟机,和vmware tools过程不赘述
2、替换源
su获取管理员权限
cd /etc/apt
mv sources.list sources.list.bak
vi sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
apt-get update
exit
3、构建交叉编译环境
cd /home/wyd/package
tar -xjvf arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 -C ../omapl138/toolschain/
sudo gedit /etc/profile
在末尾加上
export PATH=$PATH:/home/wyd/omapl138/toolschain/arm-2009q1/bin
source /etc/profile
arm-none-linux-gnueabi-gcc -v
sudo apt-get install lib32z1 更新32为支持包
sudo apt-get install lsb-core 除了32位支持包还要这个核文件,否则编译存在BUG,而且没有明显报错
4、和解压工具链一样,解压内核、u-boot和文件系统
解压rootfs的时候要sudo,其他的普通权限就OK
5、编译u-boot
sudo apt install make
wyd@wyd-virtual-machine:~/omapl138/u-boot$ ls
api config.mk drivers lib nand_spl rules.mk
arch COPYING dts MAINTAINERS net snapshot.commit
board CREDITS examples MAKEALL onenand_ipl spl
boards.cfg disk fs Makefile post tools
common doc include mkconfig README
wyd@wyd-virtual-machine:~/omapl138/u-boot$ make CROSS_COMPILE=arm-none-linux-gnueabi- distclean
make CROSS_COMPILE=arm-none-linux-gnueabi- da850sdi_tl_config
make CROSS_COMPILE=arm-none-linux-gnueabi- u-boot.ais
da850sdi_tl_config 的前面是makefile的信息,会查找board.cfg,具体看boot讲解,这里只写应用
6、编译内核
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- distclean
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- da850_omapl138_tl_defconfig
sudo apt-get install u-boot-tools
sudo apt-get install libncurses5-dev
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage
虚拟机窗口注意最大化
编译完成后可以在内核源码的"arch/arm/boot"目录下找到uImage。
7、编译系统模块
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- modules
8、制作SD
umount /dev/sdb*
格式化SD卡
sudo fdisk /dev/sdb
命令(输入 m 获取帮助): d
分区号 (1,2, 默认 2): 1
分区 1 已删除。
命令(输入 m 获取帮助): d
已选择分区 2
分区 2 已删除。
命令(输入 m 获取帮助): n
分区类型
p 主分区 (0个主分区,0个扩展分区,4空闲)
e 扩展分区 (逻辑分区容器)
选择 (默认 p): p
分区号 (1-4, 默认 1): 1
第一个扇区 (2048-15523839, 默认 2048):
上个扇区,+sectors 或 +size{K,M,G,T,P} (2048-15523839, 默认 15523839): 4194304
创建了一个新分区 1,类型为“Linux”,大小为 2 GiB。
命令(输入 m 获取帮助): t
已选择分区 1
Hex 代码(输入 L 列出所有代码): b
已将分区“Linux”的类型更改为“W95 FAT32”。
命令(输入 m 获取帮助): a
已选择分区 1
分区 1 的 可启动 标志已启用。
命令(输入 m 获取帮助): n
分区类型
p 主分区 (1个主分区,0个扩展分区,3空闲)
e 扩展分区 (逻辑分区容器)
选择 (默认 p): p
分区号 (2-4, 默认 2): 2
第一个扇区 (4194305-15523839, 默认 4196352): 4194305
上个扇区,+sectors 或 +size{K,M,G,T,P} (4194305-15523839, 默认 15523839):
创建了一个新分区 2,类型为“Linux”,大小为 5.4 GiB。
命令(输入 m 获取帮助): w
分区表已调整。
将调用 ioctl() 来重新读分区表。
正在同步磁盘。
插拔SD卡,格式化分区
sudo mkfs.vfat -F 32 -n "138boot" /dev/sdb1
sudo mke2fs -j -L "myrootfs" /dev/sdb2
插拔SD卡
9、SD卡安装u-boot
制作u-boot启动执行脚本boot.scr
编写boot.cmd 用u-boot/tools下的mkimage制作生成boot启动脚本boot.scr
boot.cmd内容
mmc rescan 0
setenv bootargs ${mem_args} console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw ip=off eth=${ethaddr} rootwait
mkimage信息
Usage: ../u-boot/tools/mkimage -l image
-l ==> list image header information
../u-boot/tools/mkimage [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image
-A ==> set architecture to 'arch'
-O ==> set operating system to 'os'
-T ==> set image type to 'type'
-C ==> set compression type 'comp'
-a ==> set load address to 'addr' (hex)
-e ==> set entry point to 'ep' (hex)
-n ==> set image name to 'name'
-d ==> use image data from 'datafile'
-x ==> set XIP (execute in place)
../u-boot/tools/mkimage [-D dtc_options] -f fit-image.its fit-image
../u-boot/tools/mkimage -V ==> print version information and exit
../u-boot/tools/mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n 'Execute uImage' -d ./boot.cmd ./boot.scr
烧写u-boot.ais
这句命令的意思是把u-boot.ais 去掉前10个block,拷贝到sdb上
这时候运行结果是这样的
NAND: 512 MiB
MMC: davinci: 0
Bad block table not found for chip 0
Bad block table not found for chip 0
Bad block table written to 0x00001ffe0000, version 0x01
Bad block table written to 0x00001ffc0000, version 0x01
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: DaVinci-EMAC
Hit any key to stop autoboot: 1 0
mmc0 is current device
reading boot.scr
** Unable to read "boot.scr" from mmc 0:1 **
reading uImage
** Unable to read "uImage" from mmc 0:1 **
Loading from nand0, offset 0x100000
** Unknown image type
U-Boot >
把boot.scr放进去
reading boot.scr
64 bytes read
Loaded bootscript from boot.scr
## Executing script at c0600000
Wrong image format for "source" command
reading uImage
10、放入内核uImage
把uImage放进去,还缺少挂在的文件系统
[ 2.892584] VFS: Mounted root (ext3 filesystem) on device 179:2.
[ 2.899805] Freeing init memory: 188K
[ 2.908071] Kernel panic - not syncing: No init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
11、解压文件系统
sudo tar -xjvf rootfs-amsdk-06.00.00.00-full-v2.6.tar.bz2 -C /media/wyd/myrootfs
还是有上面的问题
问题找到了,记得解压缩完毕,sync就OK了
12、安装驱动模块modules
在编译系统模块的路径安装modules
udo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules_install INSTALL_MOD_PATH=/media/wyd/myrootfs
CROSS_COMPILE应该存在一些问题,不过这些暂时不管,先把模块装上,因为手册上目前还没有,以后找到了补充说明