1 / 32

第 5 章 U-Boot 的编译和使用

第 5 章 U-Boot 的编译和使用. 本章目标. 理解什么是 Bootloader, 它的作用是什么; U-Boot 的结构; 掌握如何编译 U-Boot ; 掌握使用 U-Boot 的命令、工具。. 本章结构. 嵌入式系统引导. U-Boot 简介. U-Boot 配置与编译. U-Boot 烧录. U-Boot 的编译和使用. U-Boot 主要目录结构. U-Boot 主要功能. U-Boot 的命令使用. TFTP 工具使用. 5.1 、 初识 Boot Loader. 5.1.1 、初识 BootLoader

daria
Download Presentation

第 5 章 U-Boot 的编译和使用

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第5章 U-Boot的编译和使用

  2. 本章目标 • 理解什么是Bootloader,它的作用是什么; • U-Boot的结构; • 掌握如何编译U-Boot; • 掌握使用U-Boot的命令、工具。

  3. 本章结构 嵌入式系统引导 U-Boot简介 U-Boot配置与编译 U-Boot烧录 U-Boot的编译和使用 U-Boot主要目录结构 U-Boot主要功能 U-Boot的命令使用 TFTP工具使用

  4. 5.1、初识BootLoader • 5.1.1、初识BootLoader • 5.1.2、Bootloader的种类 • 5.1.3、 Bootloader的启动

  5. 5.1.1、初识BootLoader • 嵌入式linux系统从软件的角度看通常可以分为4个层次: 1、引导加载程序。 2、Linux 内核。 3、文件系统。 4、用户应用程序。

  6. 5.1.2 、Bootloader的种类(1)

  7. 5.1.2、Bootloader的种类(2) (1)X86 X86 的工作站和服务器上一般使用LILO 和GRUB。 (2)ARM ARM 处理器的芯片商很多,所以每种芯片的开发板都有自己的Bootloader。 常用VIVI、U-BOOT。 (3)PowerPC PowerPC 平台的处理器有标准的Bootloader,就是ppcboot。PPCBOOT 在合并armboot等之后,创建了U-Boot,成为各种体系结构开发板的通用引导程序。 (4)MIPS MIPS公司开发的YAMON 是标准的Bootloader,也有许多MIPS芯片商为自己的开发板写了Bootloader。现在,U-Boot 也已经支持MIPS平台。 (5)SH SH 平台的标准Bootloader 是sh-boot。Redboot在这种平台上也很好用。 (6)M68K M68K 平台没有标准的Bootloader。Redboot能够支持m68k系列的系统。

  8. 5.1.3、Bootloader的启动(1) • 大多数 Boot Loader 都包含两种不同的操作模式: 1、“启动加载”模式 2、“下载”模式 这种区别仅对于开发人员才有意义。但从最终用户的角度看,Boot Loader 的作用就是用来加载操作系统,而并不存在所谓的启动加载模式与 下载工作模式的区别。下面介绍各种启动模式。

  9. 5.1.3、Bootloader的启动(2) 1.网络启动方式 这种方式的开发板不需要配置较大的存储介质,跟无盘工作站有点类似。但是使用这种启动方式之前,需要把Bootloader 安装到板上的EPROM 或者Flash中。Bootloader 通过以太网接口远程下载Linux 内核映像或者文件系统。这种方式对于嵌入式系统开发来说非常重要。

  10. 5.1.3、Bootloader的启动(3) 2.磁盘启动方式 传统的Linux 系统运行在台式机或者服务器上,这些计算机一般都使用BIOS 引导,并且使用磁盘作为存储介质。如果进入BIOS设置菜单,可以探测处理器、内存、硬盘等设备,可以设置BIOS从软盘、光盘或者某块硬盘启动。也就是说,BIOS并不直接引导操作系统。

  11. 5.1.3、Bootloader的启动(4) 3.Flash启动方式 大多数嵌入式系统上都使用Flash存储介质。Flash有很多类型,包括NOR Flash、NANDFlash和其他半导体盘。Bootloader 一般是存储在Flash芯片上的。另外,Linux内核映像和RAMDISK 也可以存储在Flash上。通常需要把Flash分区使用,每个区的大小应该是Flash擦除块大小的整数倍。

  12. 5.1.3、Bootloader的启动(5) Boot Loader的启动流程: Boot Loader 的 stage1 通常包括以下步骤(以执行的先后顺序): • 硬件设备初始化。 • 为加载 Boot Loader 的 stage2 准备 RAM 空间。 • 拷贝 Boot Loader 的 stage2 到 RAM 空间中。 • 设置好堆栈。 • 跳转到 stage2 的 C 入口点。

  13. 5.1.3、Bootloader的启动(6) Boot Loader 的 stage2 通常包括以下步骤(以执行的先后 顺序): • 初始化本阶段要使用到的硬件设备。 • 检测系统内存映射(memory map)。 • 将 kernel 映像和根文件系统映像从 flash 上读到 RAM 空间中。 • 为内核设置启动参数。 • 调用内核。

  14. 5.1.3、Bootloader的启动(7)

  15. 5.2、U-Boot简介 U-Boot,全称Universal Boot Loader,是遵循GPL条款的开放源码项 目,从FADSROM、8xxROM、PPCBOOT逐步发展演化而来,其源码目录、编译 形式与Linux内核很相似。事实上,不少U-Boot源码就是相应Linux内核源 程序的简化,尤其是一些设备的驱动程序,从UBoot源码的注释中能体现这 一点。但是U-Boot不仅仅支持嵌入式Linux系统的引导,当前,它还支持 NetBSD、VxWorks、QNX、RTEMS、ARTOS、LynxOS嵌入式操作系统。

  16. 5.3、U-Boot配置与编译 • make distclean 清除与平台相关的文件 • make smdk2440_config 配置使用SMDK2440 • make CROSS_COMPILE=arm-linux- 交叉编译 如果编译过程中没有出现错误。那么将创建u-boot文件, 并通过objcopy将其转换为二进制格式和16进制文件格式。最 后将u-boot.bin下载到开发板的Flash中引导操作系统。

  17. 5.4、U-Boot烧录(1) • U-Boot不仅可以在NorFlash上运行,也可以在Nand Flash中运行,一切取决于代码的编写。 • 通过仿真器烧入uboot 通过仿真器uboot烧写到flash中就可以从NAND flash启动了。 • 通过JTAG接口,由工具烧入flash

  18. 5.4、U-Boot烧录(2) • JTAG简介 JTAG(Joint Test Action Group)是IEEE制定的用于检测PCB和IC的标准。通过这个标 准,可对JTAG接口芯片的硬件电路进行边界扫描和故障检测。详细内容可查阅IEEE1149.1 协议。目前,很多高档微处理器都带有JTAG接口,像ARM7,ARM9,DSP等。

  19. 5.5、U-Boot主要目录 目录树 |--board |--common |--cpu |--disk |--doc |--drivers |--dtt |--examples |--fs |--include |--lib_arm |--lib_generic |--lib_i386 |--lib_m68k |--lib_microblaze |--lib_mips |--lib_nios |--lib_nios2 |--lib_ppc |--net |--post |--rtc `--tools

  20. 5.6、U-Boot主要功能

  21. 5.7、U-Boot命令使用 5.7.1、U-Boot主要命令 5.7.2、常用命令使用说明 5.7.3、 TFTP工具使用

  22. 5.7.1、U-Boot主要命令(1) 使用命令help---[uboot1.1.4]# help • ? - alias for 'help' • autoscr - run script from memory • base - print or set address offset • bdinfo - print Board Info structure • boot - boot default, i.e., run 'bootcmd' • bootd - boot default, i.e., run 'bootcmd' • bootelf - Boot from an ELF image in memory • bootm - boot application image from memory • bootp - boot image via network using BootP/TFTP protocol • bootvx - Boot vxWorks from an ELF image • cmp - memory compare • coninfo - print console devices and information • cp - memory copy

  23. 7.7.1、U-Boot主要命令(2) • crc32 - checksum calculation • date - get/set/reset date & time • dcache - enable or disable data cache • echo - echo args to console • erase - erase FLASH memory • flinfo - print FLASH memory information • go - start application at address 'addr' • help - print online help • icache - enable or disable instruction cache • iminfo - print header information for application image • imls - list all images found in flash • itest - return true/false on integer compare • mw - memory write (fill)

  24. 5.7.1、U-Boot主要命令(3) • mw - memory write (fill) • nand - NAND sub-system • nboot - boot from NAND device • nfs - boot image via network using NFS protocol • nm - memory modify (constant address) • ping - send ICMP ECHO_REQUEST to network host • printenv- print environment variables • protect - enable or disable FLASH write protection • rarpboot- boot image via network using RARP/TFTP protocol • reset - Perform RESET of the CPU • run - run commands in an environment variable • saveenv - save environment variables to persistent storage

  25. 5.7.1、U-Boot主要命令(4) • setenv - set environment variables • sleep - delay execution for some time • tftpboot- boot image via network using TFTP protocol • version - print monitor version

  26. 5.8、U-Boot常用命令(1) 1、tftp(tftpboot) 即将内核镜像文件从PC中下载到SDRAM的指定地址,然后通过bootm来引导内核,前提是所用PC要安装设置tftp服务。 下载信息: [uboot1.1.4]# tftp 0x30008000 zImage 2、bootm 内核的入口地址开始引导内核。 [uboot1.1.4]# bootm 0x30008000

  27. 5.8、U-Boot常用命令(2) 3、go 直接跳转到可执行文件的入口地址,执行可执行文件。 [uboot1.1.4]# go 0x30008000 4、cp 内存拷贝,cp 源地址 目的地址 拷贝大小(字节) [uboot1.1.4]# cp 0x30008000 0x3000f000 64

  28. 5.8、U-Boot常用命令(3) 5、erase(F) 擦除FLASH MEMORY。 erase start end erase bank N -erase FLASH bank # N erase all -erase all FLASH banks

  29. 7.8、U-Boot常用命令(4) 6、printenv 打印环境变量 7、saveenv(F) 保存设定的环境变量 8、setenv 设置环境变量

  30. 9、nand read nand read InAddr FlAddr size InAddr: 从nand flash中读到内存的起始地址。 FlAddr: nand flash 的起始地址。 size: 从nand flash中读取的数据的大小。 10、nand erease nand erase FlAddr size FlAddr: nand flash 的起始地址 size: 从nand flash中擦除数据块的大小 11、nand write nand write InAddr FlAddr size InAddr: 写到Nand Flash中的数据在内存的起始地址 FlAddr: Nand Flash的起始地址 size: 数据的大小 5.8、U-Boot常用命令(5)

  31. 5.8、U-Boot常用命令(6) 12、TFTP工具使用 TFTP协议是简单的文件传输协议,适合目标板Bootloader的使用。 TFTP文件传输基于UDP。我们通过TFTP来传输目标板启动需要的 内核映象文件zImage和ramdisk。 U-Boot> tftp 21000000 zImage TFTP from server 192.168.1.2; our IP address is 192.168.1.100 Filename 'zImage'. Load address: 0x21000000 Loading: ################################################################# done Bytes transferred = 1324260 (1434e4 hex)

  32. 本章总结 • 本章讲述了Bootloader的概念,重点分析U-Boot主要功能和命令使用。最后介绍了在开发过程中常用的手段:TFTP。

More Related