1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > [linux kernel]内核移植过程记录

[linux kernel]内核移植过程记录

时间:2022-06-22 03:21:20

相关推荐

[linux kernel]内核移植过程记录

系统版本:Ubuntu18.04-64

编译器版本:gcc version 7.4.0 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1)

uboot版本:.07 -linux4sam_6.0

板子型号:at91sama5d3x-xplained

MCU型号:sama5d36

内核移植主要是裁剪一些不需要的功能,使用对应的交叉工具链把内核重新编译,设备树文件按照硬件去配置。

一、配置文件路径

arch/arm/configs/sama5_defconfig

//配置文件路径

arch/arm/configs/sama5_defconfig

//声明环境变量,指定交叉编译器

$ export CROSS_COMPILE=arm-linux-gnueabi-

//先按照默认配置编译内核文件,看是否会报错,编译出来的文件先进行烧录,是否能正确引导文件系统;

$ make ARCH=arm sama5_defconfig

$ make ARCH=arm

//图形化配置窗口调出

$ make ARCH=arm menuconfig

//单独编译设备树文件,生成dtb文件

$ make ARCH=arm dt

二、把编译的zImage和dtb文件烧录板子,根据打印信息,分析出硬件驱动的情况。

1、内核接收uboot传递过来的分区信息,要和设备树中的分区一致,后面再细讲;

Kernel command line: console=ttyS0,115200 earlyprintk mtdparts=atmel_nand:256k(bootstrap)ro,768k(uboot)ro,256K(env_redundant),256k(env),512k(dtb),6M(kernel)ro,-(rootfs) rootfstype=ubifs ubi.mtd=6 root=ubi0:rootfs

2、GPIO控制器驱动OK

AT91: PM: standby: standby, suspend: ulp0

gpio-at91 fffff200.gpio: at address (ptrval)

gpio-at91 fffff400.gpio: at address (ptrval)

gpio-at91 fffff600.gpio: at address (ptrval)

gpio-at91 fffff800.gpio: at address (ptrval)

gpio-at91 fffffa00.gpio: at address (ptrval)

pinctrl-at91 ahb:apb:pinctrl@fffff200: initialized AT91 pinctrl driver

3、DMA通道生效

at_hdmac ffffe600.dma-controller: Atmel AHB DMA Controller ( cpy set slave ), 8 channels

at_hdmac ffffe800.dma-controller: Atmel AHB DMA Controller ( cpy set slave ), 8 channels

4、USB控制器驱动注册成功

usbcore: registered new interface driver usbfs

usbcore: registered new interface driver hub

usbcore: registered new device driver usb

5、i2C总线驱动模型注册成功

at91_i2c f0014000.i2c: using dma0chan0 (tx) and dma0chan1 (rx) for DMA transfers

at91_i2c f0014000.i2c: AT91 i2c bus driver (hw version: 0x402).

at91_i2c f0018000.i2c: using dma0chan2 (tx) and dma0chan3 (rx) for DMA transfers

at91_i2c f0018000.i2c: AT91 i2c bus driver (hw version: 0x402).

6、蓝牙驱动注册成功

Bluetooth: Core ver 2.22

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

7、串口、SPI、CAN驱动注册

ssc f0008000.ssc: Atmel SSC device at 0x(ptrval) (irq 20)

atmel_usart_serial.0.auto: ttyS2 at MMIO 0xf0020000 (irq = 24, base_baud = 4125000) is a ATMEL_SERIAL

atmel_usart_serial.1.auto: ttyS0 at MMIO 0xffffee00 (irq = 34, base_baud = 8250000) is a ATMEL_SERIAL

console [ttyS0] enabled

atmel_spi f0004000.spi: DMA TX channel not available, SPI unable to use DMA

atmel_spi f0004000.spi: Atmel SPI Controller using PIO only

m25p80 spi0.0: unrecognized JEDEC id bytes: 00, 00, 00

atmel_spi f0004000.spi: Atmel SPI Controller version 0x213 at 0xf0004000 (irq 19)

libphy: Fixed MDIO Bus: probed

CAN device driver interface

at91_can f000c000.can: device registered (reg_base=(ptrval), irq=42)

8、GMAC控制器上面的网络芯片没有驱动成功,因为id读取为全0xFF;

libphy: MACB_mii_bus: probed

Generic PHY f0028000.ethernet-ffffffff:01: attached PHY driver [Generic PHY] (mii_bus:phy_addr=f0028000.ethernet-ffffffff:01, irq=POLL)

macb f0028000.ethernet eth0: Cadence GEM rev 0x0009 at 0xf0028000 irq 43 (ee🆎c1:d2:e6:c6)

macb f802c000.ethernet: invalid hw address, using random

9、ksz8081 芯片的id号能够读取到,但是驱动没有匹配成功;

libphy: MACB_mii_bus: probed

Micrel KSZ8081 or KSZ8091 f802c000.ethernet-ffffffff:01: attached PHY driver [Micrel KSZ8081 or KSZ8091] (mii_bus:phy_addr=f802c000.ethernet-ffffffff:01, irq=49)

macb f802c000.ethernet eth1: Cadence MACB rev 0x0001010c at 0xf802c000 irq 44 (36:d7:c3:e6:2a:c7)

已经打印出"Micrel KSZ8081 or KSZ8091",可能是时序的问题;

10、系统时钟的rtc,从打印信息可以看出,是使用cpu内部的rtc寄存器,而非外部的RX8025芯片,作为rtc0供系统读取调用;原因稍后分析。

qt1070 1-001b: ID 206 not supported

at91_rtc fffffeb0.rtc: registered as rtc0

at91_rtc fffffeb0.rtc: AT91 Real Time Clock driver.

i2c /dev entries driver

11、EMMC控制器信息,mmc0上面挂载了一片32GByte的EMMC芯片;

sdhci: Secure Digital Host Controller Interface driver

sdhci: Copyright© Pierre Ossman

atmel_mci f0000000.mmc: version: 0x505

atmel_mci f0000000.mmc: using dma0chan4 for DMA transfers

atmel_mci f0000000.mmc: Atmel MCI controller at 0xf0000000 irq 18, 1 slots

atmel_mci f8000000.mmc: version: 0x505

atmel_mci f8000000.mmc: using dma1chan0 for DMA transfers

atmel_mci f8000000.mmc: Atmel MCI controller at 0xf8000000 irq 25, 1 slots

sdhci-pltfm: SDHCI platform and OF driver helper

12、NAND Flash参数,及分区信息

nand: device found, Manufacturer ID: 0x01, Chip ID: 0xda

nand: AMD/Spansion S34ML02G2

nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 128

Bad block table found at page 131008, version 0x01

Bad block table found at page 130944, version 0x01

7 cmdlinepart partitions found on MTD device atmel_nand

Creating 7 MTD partitions on “atmel_nand”:

0x000000000000-0x000000040000 : “bootstrap”

0x000000040000-0x000000100000 : “uboot”

0x000000100000-0x000000140000 : “env_redundant”

0x000000140000-0x000000180000 : “env”

0x000000180000-0x000000200000 : “dtb”

0x000000200000-0x000000800000 : “kernel”

0x000000800000-0x000010000000 : “rootfs”

分区信息,前面为地址,后面为分区大小。

NandFlash的参数信息,如果不清楚,也可以再uboot里面使用命令查看;

使用uboot查看nand info参数

=> nand info

Device 0: nand0, sector size 128 KiB

Page size 2048 b

OOB size 128 b

Erase size 131072 b

subpagesize 2048 b

options 0x40004200

bbt options 0x00008000

这个参数也同样重要,做文件系统ubi的时候会使用到具体的参数值;

二、编译出镜像文件路径为

//设备树文件

arch/arm/boot/dts/at91-sama5d3_xplaint.dts

//编译出的设备树镜像文件

arch/arm/boot/dts/at91-sama5d3_xplaint.dtb

//编译出的内核镜像文件

arch/arm/boot/zImage

最后根据配置生成的配置文件,在内核根目录下,默认为.config文件;

Tips:在做完修改之后,最好把.config文件备份一个,比如:cp .config Jackatmelconfig;以后不小心重新配置了,还可以返回以前的配置;

更多linux知识点推荐:

[linux kernel] 内核启动流程梳理

[linux 底层]u-boot EMMC驱动

[linux 底层]u-boot图形化裁剪配置

[Linux 底层]U-boot ksz9031网络驱动调试

[Linux 底层]U-boot调试命令使用技巧

[Linux 底层]U-boot编译移植

[Linux 底层]U-boot烧录脚本介绍SecureCRT

[Linux 底层]bootstrap移植裁剪及编译

[Linux 底层] 平台软件分层介绍

[Linux 驱动] RS485测试程序编写

[Linux 驱动] CAN测试程序编写

推荐阅读:

芯片手册解读 | Linux底层

关注微信公众号,回复“内核打印”,下载内核打印信息文件,有启动不了的解决方法。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。