• 01-基于imx6ul从0自制Bootloader专栏实现总结


            本文主要说明一下此专栏后续文章的主要内容,基于imx6ul arm32平台,文章主要涉及:

    • 实现一个自制的Bootloader启动linux
    • 对比自制Bootloader分析uboot实现及技术细节

     Bootloader引导内核需要做什么

            根据上图,自制最小的Bootloader引导内核过程,可以总结Bootloader引导内核需要:

    • 外设必要的初始化:如时钟、mmc控制器、调试串口
    • 实现flash驱动,将flash上的内核、设备树,拷贝至ddr中指定地址
    • 准备内核参数,如对设备树进行设置(若提前设置好设备树,此步可省略)
    • 跳转执行内核

    自己实现Bootloader启动内核效果

    引导linux内核如下:

    1. ****************************************************
    2. ************* IMX6UL Bootloader RUN ****************
    3. ****************************************************
    4. 1.Init io/clock/uart/irq
    5. 2.Start Copy kerner and dtb to ddr
    6.         2.1 Mount fatfs [ success ]!
    7.         2.2 List the file in directory
    8.                 General file : DTB.
    9.                 General file : ZIMAGE.
    10.         2.3 Open zImage file [success]
    11.         2.4 Open dtb file [success]
    12.         2.5 Read kernel file to 0x80800000[success]
    13.         2.6 Read dtb file to 0x83000000[success]
    14. 3.Starting kernel ...
    15. Booting Linux on physical CPU 0x0
    16. Linux version 4.1.15-g696dd24-dirty (root@xxzh) (gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11) ) #68 SMP PREEMPT Thu Aug 11 09:45:05 CST 2022
    17. CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c53c7d
    18. CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
    19. Machine model: Freescale i.MX6 ULL 14x14 EVK Board
    20. Reserved memory: created CMA memory pool at 0x8c000000, size 320 MiB
    21. Reserved memory: initialized node linux,cma, compatible id shared-dma-pool
    22. Memory policy: Data cache writealloc
    23. PERCPU: Embedded 12 pages/cpu @8bb33000 s16908 r8192 d24052 u49152
    24. Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
    25. Kernel command line: console=ttymxc3,115200 imx2-wdt.timeout=120 root=/dev/mmcblk1p2 rootwait rw
    26. PID hash table entries: 2048 (order: 1, 8192 bytes)
    27. Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
    28. Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
    29. Memory: 180876K/524288K available (6847K kernel code, 377K rwdata, 2316K rodata, 400K init, 422K bss, 15732K reserved, 327680K cma-reserved, 0K highmem)

    uboot引导内核

    uboot启动内核如下:

    1. U-Boot 2016.03-g6f19009 (Aug 11 2022 - 17:29:34 +0800)
    2. CPU: Freescale i.MX6ULL rev1.1 528 MHz (running at 396 MHz)
    3. CPU: Industrial temperature grade (-40C to 115C) at 45C
    4. Reset cause: POR
    5. Board: MYD-Y6ULL 14x14
    6. DRAM: 512 MiB
    7. MMC: FSL_SDHC: 0, FSL_SDHC: 1
    8. *** Warning - bad CRC, using default environment
    9. In: serial
    10. Out: serial
    11. Err: serial
    12. switch to partitions #0, OK
    13. mmc1(part 0) is current device
    14. Net: GroundCtrl 20211015 oil_gpio_init
    15. FEC0
    16. Error: FEC0 address not set.
    17. Normal Boot
    18. Hit any key to stop autoboot: 0
    19. switch to partitions #0, OK
    20. mmc1(part 0) is current device
    21. switch to partitions #0, OK
    22. mmc1(part 0) is current device
    23. reading boot.scr
    24. 272 bytes read in 9 ms (29.3 KiB/s)
    25. Running bootscript from mmc ...
    26. ## Executing script at 80800000
    27. reading zImage
    28. 5511008 bytes read in 138 ms (38.1 MiB/s)
    29. reading myd-y6ull-emmc.dtb
    30. 34414 bytes read in 17 ms (1.9 MiB/s)
    31. Kernel image @ 0x83000000 [ 0x000000 - 0x541760 ]
    32. ## Flattened Device Tree blob at 84000000
    33. Booting using the fdt blob at 0x84000000
    34. Using Device Tree in place at 84000000, end 8400b66d
    35. Starting kernel ...
    36. Booting Linux on physical CPU 0x0
    37. Linux version 4.1.15-gd778688 (root@xxzh) (gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11) ) #69 SMP PREEMPT Thu Aug 11 17:28:49 CST 2022
    38. CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c53c7d
    39. CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
    40. Machine model: Freescale i.MX6 ULL 14x14 EVK Board
    41. Reserved memory: created CMA memory pool at 0x8c000000, size 320 MiB
    42. Reserved memory: initialized node linux,cma, compatible id shared-dma-pool
    43. Memory policy: Data cache writealloc
    44. PERCPU: Embedded 12 pages/cpu @8bb33000 s16908 r8192 d24052 u49152
    45. Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048
    46. Kernel command line: console=ttymxc3,115200 imx2-wdt.timeout=120 root=/dev/mmcblk1p2 rootwait rw rootfstype=ext4 rootdelay=5 mem=512M

    专栏后续涉及内容

    • 分析uboot跳转内核前做了哪些必须的工作,为自制bootloader做准备
    • 自制Bootloader实现技术细节总结
    • uboot中命令行解析实现的分析
    • uboot命令bootz实现的分析
    • imx6ul裸机程序的编译、链接、启动加载分析

  • 相关阅读:
    nodejs毕业设计源码基于nodejs的拼车网站
    iOS pod repo push 报错 ld: file not found: libarclite_iphoneos.a 问题解决方案
    Java虚拟机(JVM)-- Dump内存快照
    Vue动态绑定style
    [论文阅读] 颜色迁移-颜色空间的选择
    【Java面试】ConcurrentHashMap再JDK7和8中的区别以及ConcurrentHashMap底层实现
    LeetCode 2312. 卖木头块
    刷代码随想录有感(85):贪心算法——跳跃游戏
    Java 将HTML转为XML
    Linux自动化构建项目工具——Makefile/makefile
  • 原文地址:https://blog.csdn.net/fengyuwuzu0519/article/details/126346518