Linux系统 ARM开发板 启动过程

Linux系统 ARM开发板 启动过程,第1张

开发板上电第一步是启动固件,固件是出厂时固化好的,固件的作用是初始化一下基本的 设备,以nand为例,固件irom初始化好sram后,将nand中的前4k的bootloader(一般为uboot)拷贝到sram中,sram再初始化另一些设备比如dram等等,然后运行剩下的bootloader,接下来就是引导linux内核的启动了。bios在开发板相当与irom部分功能和uboot的前4k,内存时钟会在uboot中初始化的。uboot先做一些准备(比如设svc模式,关看门狗、中断、mmu等),然后设置内核参数表,然后跳到内核的地址运行,内核一般是压缩的,需要先解压,入口是stext,是在arch/arm/kernel/vmlinux.lds.S中定义的

1. 内核启动地址

ZTEXTADDR

解压代码运行的开始地址。没有物理地址和虚拟地址之分,因为此时MMU处于关闭状态。这个地址不一定时RAM的地址,可以是支持读写寻址的flash等存储中介。

Start address of decompressor. here's no point in talking about virtual or physical addresses here, since the MMU will be off at the time when you call the decompressor code. You normally call the kernel at this address to start it booting. This doesn't have to be located in RAM, it can be in flash or other read-only or read-write addressable medium.

在arch/arm/boot/compressed/Makefile中说的很明确

#

# We now have a PIC decompressor implementation. Decompressors running

# from RAM should not define ZTEXTADDR. Decompressors running directly

# from ROM or Flash must define ZTEXTADDR (preferably via the config)

# FIXME: Previous assignment to ztextaddr-y is lost here. See SHARK

ifeq ($(CONFIG_ZBOOT_ROM),y)

ZTEXTADDR := $(CONFIG_ZBOOT_ROM_TEXT)

ZBSSADDR:= $(CONFIG_ZBOOT_ROM_BSS)

else

ZTEXTADDR := 0

ZBSSADDR:= ALIGN(8)

endif

ZRELADDR

内核启动在RAM中的地址。压缩的内核映像被解压到这个地址,然后执行。

This is the address where the decompressed kernel will be written, and eventually executed. The following constraint must be valid:

__virt_to_phys(TEXTADDR) == ZRELADDR

The initial part of the kernel is carefully coded to be position independent.

一般定义在项目目录下,比如:

arch/arm/mach-at91/Makefile.boot: zreladdr-y += 0x70008000

arch/arm/mach-at91/Makefile.boot: zreladdr-y += 0x20008000

arch/arm/mach-cns3xxx/Makefile.boot: zreladdr-y += 0x00008000

arch/arm/mach-davinci/Makefile.boot: zreladdr-y += 0xc0008000

arch/arm/mach-davinci/Makefile.boot: zreladdr-y += 0x80008000

arch/arm/mach-dove/Makefile.boot: zreladdr-y += 0x00008000

arch/arm/mach-ebsa110/Makefile.boot: zreladdr-y += 0x00008000

arch/arm/mach-exynos/Makefile.boot: zreladdr-y += 0x40008000

arch/arm/mach-footbridge/Makefile.boot: zreladdr-y += 0x00008000

arch/arm/mach-gemini/Makefile.boot: zreladdr-y += 0x00008000

arch/arm/mach-gemini/Makefile.boot: zreladdr-y += 0x10008000

arch/arm/mach-integrator/Makefile.boot: zreladdr-y += 0x00008000

arch/arm/mach-iop13xx/Makefile.boot: zreladdr-y += 0x00008000

在arch/arm/boot/Makefile中被赋值:

ZRELADDR := $(zreladdr-y)

PARAMS_PHYS := $(params_phys-y)

INITRD_PHYS := $(initrd_phys-y)

... ...

ifneq ($(LOADADDR),)

UIMAGE_LOADADDR=$(LOADADDR)

else

ifeq ($(CONFIG_ZBOOT_ROM),y)

UIMAGE_LOADADDR=$(CONFIG_ZBOOT_ROM_TEXT)

Arm linux 内核启动流程 还是从编译链接生成vmlinux的过程来看吧,由一大堆.o文件链接而成,第一个就是 kernel\arch\arm\kernel\head-armv.o


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/7544434.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-06
下一篇 2023-04-06

发表评论

登录后才能评论

评论列表(0条)

保存