Linux主线内核移植,为AM335x移植Linux内核主线代码(32)从U-Boot到内核

虽然这个系列主要是Linux内核移植的笔记,但是从第(7)到第(31)全部写的是U-Boot的内容。

这些有关U-Boot的内容本来应该放在之前的《U-Boot for AM335x》系列里面,但是因为《U-Boot for AM335x》系列已经结束了,而移植Linux内核时调试硬件,U-Boot起的作用又非常大,因此还是放在了本系列中。

Anyway,since现在硬件调试已经告一段落,接下来就是正式的Linux Kernel移植了。

Note: 其实硬件还差LCD的触摸板和RS485没有用U-Boot调通,但是由于U-Boot的代码里面没有包含ADC驱动程序,而RS485功能并不复杂,所以这两个留到Linux Kernel移植的时候调试。

Note: 由于在调试阶段Linux Kernel需要经常修改,因此还是采用从SD卡启动U-Boot,再通过U-Boot的tftp功能将Kernel放置在SDRAM中;另外,文件系统暂时先采用Forlinx光盘中编译好的镜像,它某些文件的版本号可能和这里的kernel mainline有区别,但是影响不大,后期再制作新的文件系统。

《U-Boot for AM335x》的第13篇,记录的就是编译Linux Kernel的基本步骤,由于kernel会有更新,所以按照之前的步骤再疏理一遍:

Step 1: 使用create-sdcard.sh制作SD卡:

./create-sdcard.sh

Step 2: 将文件系统解压到SD卡的rootf:

tar xvf rootfs.tar.bz2 -C /media/rootfs

Step 3: 下载Kernel的源代码并解压:

(https://www.kernel.org)

tar xvf linux-3.18.4.tar.xz

Step 4: 下载交叉编译器并解压:

(https://software-dl.ti.com/sitara_linux/esd/AM335xSDK/latest/index_FDS.html)

tar xvf gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux.tar.bz2 -C /opt

Step 5:

make ARCH=arm CROSS_COMPILE=/opt/gcc-linaro-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -j8 mrproper

make ARCH=arm CROSS_COMPILE=/opt/gcc-linaro-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -j8 omap2plus_defconfig

General Setup -> Default hostname (MARIA)

Boot options ->  Kernel command line type (root=/dev/mmcblk0p2 rootwait console=ttyO0,115200)

make ARCH=arm CROSS_COMPILE=/opt/gcc-linaro-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -j8 am335x-bone.dtb

make ARCH=arm CROSS_COMPILE=/opt/gcc-linaro-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -j8 LOADADDR=0x80008000 uImage

Step 6:

cp arch/arm/boot/dts/am335x-bone.dtb arch/arm/boot/uImage /tftp_root/

Step 7:

U-Boot# set ipaddr 192.168.1.117; set serverip 192.168.1.116

U-Boot# tftp 0x83000000 am335x-bone.dtb

U-Boot# tftp 0x82000000 uImage

U-Boot# bootm 0x82000000 - 0x83000000

注意上面的make命令中LOADADDR和下面的uImage存放位置的区别,前者是内核解压之后的地址,后者是内核镜像的地址,它们不是一个概念。

之后就会发现内核解压之后的串口信息啦:

U-Boot# bootm 0x82000000 - 0x83000000

## Booting kernel from Legacy Image at 82000000 ...

Image Name:   Linux-3.18.4

Image Type:   ARM Linux Kernel Image (uncompressed)

Data Size:    4584480 Bytes = 4.4 MiB

Load Address: 80008000

Entry Point:  80008000

Verifying Checksum ... OK

## Flattened Device Tree blob at 83000000

Booting using the fdt blob at 0x83000000

Loading Kernel Image ... OK

Using Device Tree in place at 83000000, end 8300a0e1

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0

[    0.000000] Initializing cgroup subsys cpuset

[    0.000000] Initializing cgroup subsys cpu

[    0.000000] Initializing cgroup subsys cpuacct

[    0.000000] Linux version 3.18.4 (maria@localhost.localdomain) (gcc version 4.7.3 2013025

[    0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c5387d

[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache

[    0.000000] Machine model: TI AM335x BeagleBone

默认的mainline可以驱动大部分的设备,但并不是所有的,为了porting到自己的板子,需要修改dts文件,以及制作相应的驱动程序。

下一节是如何编译自己的dts文件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值