• DM3730 uboot 分析


    记录下启动log

    1. Texas Instruments X-Loader 1.42 BSP-dm37x-2.4-2 for dm3730logic (2013-06-18 15:59:36)
    2. DRAM: 256MB (MT29C4G48MAZAPAKQ5)
    3. Starting U-boot on MMC
    4. Reading boot sector
    5. 454540 bytes read from MMC to 80400000
    6. U-Boot 2011.06 BSP-dm37x-2.4-2 (Jun 18 2013 - 15:35:26)
    7. OMAP3630/3730-GP ES2.1, CPU-OPP2, L3-200MHz, Max CPU Clock 1 Ghz
    8. Logic DM37x/OMAP35x reference board + LPDDR/NAND
    9. I2C: ready
    10. DRAM: 256 MiB
    11. Board: DM37xx SOM LV
    12. NOR: no flash device detected
    13. NAND: 512 MiB
    14. NAND: Internal to NAND ECC selected
    15. *** Warning - bad CRC or ECC error, using default environment
    16. Found '28' display panel
    17. In: serial
    18. Out: serial
    19. Err: serial
    20. Product ID data cached to: 40200000
    21. at88_send_packet:82 NACK idx 3
    22. at88_send_packet:82 NACK idx 3
    23. at88_send_packet:82 NACK idx 3
    24. at88_send_packet:82 NACK idx 3
    25. at88_send_packet:82 NACK idx 3
    26. at88_send_packet:82 NACK idx 3
    27. Die ID #74ae00229ff84000013c124c1700c017
    28. OTG_SYSCONFIG: 00001008 - needs to be 00002001
    29. ID data ROM : Gen 1
    30. Part Number : L3-5000518
    31. Model Name : SOMDM3730-PHI02-0301R-A
    32. Serial Number: 2520M01457
    33. LAN ethaddr : 00:08:ee:10:92:ad
    34. Data (writethrough) Cache is ON
    35. Net: smc911x-0
    36. =================================== NOTICE ===================================
    37. The U-Boot environment was not found. If the display is not set properly
    38. linux will not have video support.
    39. Valid display options are:
    40. 2 == LQ121S1DG31 TFT SVGA (12.1) Sharp
    41. 3 == LQ036Q1DA01 TFT QVGA (3.6) Sharp w/ASIC
    42. 5 == LQ064D343 TFT VGA (6.4) Sharp
    43. 7 == LQ10D368 TFT VGA (10.4) Sharp
    44. 15 == LQ043T1DG01 TFT WQVGA (4.3) Sharp
    45. 28 == LQ043T1DG28 TFT WQVGA (4.3) Sharp (DEFAULT)
    46. vga[-16 OR -24] LCD VGA 640x480
    47. svga[-16 OR -24] LCD SVGA 800x600
    48. xga[-16 OR -24] LCD XGA 1024x768
    49. 720p[-16 OR -24] LCD 720P 1280x720
    50. sxga[-16 OR -24] LCD SXGA 1280x1024
    51. uxga[-16 OR -24] LCD UXGA 1600x1200
    52. Default `display` environment variable is now being set to: 28
    53. At the U-Boot prompt type commands: `setenv display `, then type
    54. `saveenv` to save the environment to NAND flash. This will avoid seeing
    55. this notice on future boots
    56. =================================== NOTICE ===================================
    57. Hit any key to stop autoboot: 3 2 1 0
    58. == Checking mmc1 for alternate boot script boot.scr ==
    59. mmc1 is available
    60. reading boot.scr
    61. 129 bytes read
    62. == Found script on mmc 1, starting ==
    63. ## Executing script at 80ff0000
    64. ## Resetting to default environment
    65. kernel_location: mmc , rootfs_location: mmc , rootfs_type: ramdisk
    66. == Loading kernel file uImage to 0x81000000 ==
    67. mmc1 is available
    68. reading uImage
    69. 3977032 bytes read
    70. == Loading rootfs file rootfs.ext2.gz.uboot to 0x82000000 ==
    71. reading rootfs.ext2.gz.uboot
    72. 28842095 bytes read
    73. == Kernel bootargs ==
    74. nand-ecc=chip console=ttyO0,115200n8 display=28 ignore_loglevel early_printk no_console_suspend mtdparts=omap2-nand.0:512k(x-loader),1664k(u-boot),384k(u-boot-env),5m(kernel),20m(ramdisk),-(fs) root=/dev/ram rw ramdisk_size=128000
    75. bootm 0x81000000 0x82000000
    76. ## Booting kernel from Legacy Image at 81000000 ...
    77. Image Name: Linux-3.0.0-BSP-dm37x-2.4-2
    78. Image Type: ARM Linux Kernel Image (uncompressed)
    79. Data Size: 3976968 Bytes = 3.8 MiB
    80. Load Address: 80008000
    81. Entry Point: 80008000
    82. Verifying Checksum ... OK
    83. ## Loading init Ramdisk from Legacy Image at 82000000 ...
    84. Image Name: uboot ext2 ramdisk rootfs
    85. Image Type: ARM Linux RAMDisk Image (gzip compressed)
    86. Data Size: 28842031 Bytes = 27.5 MiB
    87. Load Address: 00000000
    88. Entry Point: 00000000
    89. Verifying Checksum ... OK
    90. Loading Kernel Image ... OK
    91. OK
    92. Starting kernel ...

    代码过程

    连接脚本 arch/arm/cpu/armv7/u-boot.lds

    再看arch/arm/cpu/armv7/start.S  最后调用 arch/arm/lib/board.c的board_init_f().

    该函数中,首先调用arch/arm/lib/board.c: init_sequence序列初始化,初始化gpmc/arch_cpu/timer/clk/env/serial/bandrate/console/display/print/board_info/i2c/dram等

    1. init_fnc_t *init_sequence[] = {
    2. #if defined(CONFIG_ARCH_CPU_INIT)
    3. arch_cpu_init, /* basic arch cpu dependent setup */
    4. #endif
    5. #if defined(CONFIG_BOARD_EARLY_INIT_F)
    6. board_early_init_f,
    7. #endif
    8. timer_init, /* initialize timer */
    9. #ifdef CONFIG_FSL_ESDHC
    10. get_clocks,
    11. #endif
    12. env_init, /* initialize environment */
    13. init_baudrate, /* initialze baudrate settings */
    14. serial_init, /* serial communications setup */
    15. console_init_f, /* stage 1 init of console */
    16. display_banner, /* say that we are here */
    17. #if defined(CONFIG_DISPLAY_CPUINFO)
    18. print_cpuinfo, /* display cpu info (and speed) */
    19. #endif
    20. #if defined(CONFIG_DISPLAY_BOARDINFO)
    21. checkboard, /* display board info */
    22. #endif
    23. #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
    24. init_func_i2c,
    25. #endif
    26. dram_init, /* configure available RAM banks */
    27. NULL,
    28. };

    然后保存ram_size 到gd,初始化gb->fb_base 等gb信息

    最后调用relocate_code----》start.S里实现

    为什么要relocate_code? 

    1.由x-loade可知,其将uboot前的部分代码(比如16k)拷贝到内部RAM的基地址,然后直接跳转到这个地址执行,但是一般的,uboot总是大于16K的,也就是说内部RAM不能完整执行uboot,需要把剩下的uboot搬移到外部RAM的高端地址执行。kernel是在DDR低地址执行的,为避免kernel与uboot地址重叠,需要把uboot搬移到DDR的高端地址执行。

    2.某些uboot是从Nor等启动的,需要拷贝到DDR中才能完整执行。

    参考[uboot] uboot relocation介绍_Andy_0755的博客-CSDN博客

    uboot 跳转入ram执行代码分析(重映射分析)-erlei_2013-ChinaUnix博客

    start.S中relocate_code段的如下代码,实现uboot的重定位,跳转到RAM中继续执行uboot

    jump_2_ram:
        ldr    r0, _board_init_r_ofs
        adr    r1, _start
        add    lr, r0, r1
        add    lr, lr, r9
        /* setup parameters for board_init_r */
        mov    r0, r5        /* gd_t */
        mov    r1, r6        /* dest_addr */
        /* jump to it ... */
        mov    pc, lr

    _start表示uboot.bin的绝对开始地址,_board_init_r_ofs是uboot.bin编译过程中生成的全部符号表board_init_r的地址,由此可以得出board_init_r与——start的偏移地址。

    R9存储拷贝uboot到RAM中的地址,在根据函数的偏移地址,可以得出board_init_r函数在RAM中的地址,直接跳转到这个地址,即直接执行了board_init_r()函数。

    该函数在arch/arm/lib/board.c中,

    该函数继续初始化一些总线与外设,然后进入main_loop() ; 这里面执行bootm启动命令,从Nand等加载uImage执行内核启动。

  • 相关阅读:
    uniapp踩坑之项目:隐藏显示密码功能
    【译】You probably should stop using a custom TaskScheduler
    每日学到 42 - JavaScript内置对象
    Rank-embedded Hashing for Large-scale Image Retrieval
    目标检测算法——安全帽识别数据集(附下载链接)
    使用MySQL Workbench进行数据库创建
    「PAT甲级真题解析」Advanced Level 1007 Maximum Subsequence Sum
    IS-IS——图解9种报文
    基于R做宏基因组进化树+丰度柱状图TreeBar带聚类树的堆叠柱形图
    二十四、W5100S/W5500+RP2040树莓派Pico<PHY的状态模式控制>
  • 原文地址:https://blog.csdn.net/layuetian2011/article/details/126161837