首页 > 其他 > 详细

u-boot nor flash 初始化过程

时间:2020-12-14 21:52:15      阅读:35      评论:0      收藏:0      [点我收藏+]

board_init_r
  initr_flash

    flash_init

      cfi_flash_init_dm

        cfi_flash_probe

      flash_get_size

#if defined(CONFIG_MTD_NOR_FLASH)
static int initr_flash(void)
{
    ulong flash_size = 0;
    bd_t *bd = gd->bd;

    puts("Flash: ");

    if (board_flash_wp_on()) 
        printf("Uninitialized - Write Protect On\n");
    else
        flash_size = flash_init();

    print_size(flash_size, "");
#ifdef CONFIG_SYS_FLASH_CHECKSUM
    /*
     * Compute and print flash CRC if flashchecksum is set to ‘y‘
     *
     * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
     */
    if (env_get_yesno("flashchecksum") == 1) {
        const uchar *flash_base = (const uchar *)CONFIG_SYS_FLASH_BASE;

        printf("  CRC: %08X", crc32(0,
                        flash_base,
                        flash_size));
    }
#endif /* CONFIG_SYS_FLASH_CHECKSUM */
    putc(\n);

    /* update start of FLASH memory    */
#ifdef CONFIG_SYS_FLASH_BASE
    bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
#endif
    /* size of FLASH memory (final value) */
    bd->bi_flashsize = flash_size;

#if defined(CONFIG_SYS_UPDATE_FLASH_SIZE)
    /* Make a update of the Memctrl. */
    update_flash_size(flash_size);
#endif

#if defined(CONFIG_OXC) || defined(CONFIG_RMU)
    /* flash mapped at end of memory map */
    bd->bi_flashoffset = CONFIG_SYS_TEXT_BASE + flash_size;
#elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
    bd->bi_flashoffset = monitor_flash_len;    /* reserved area for monitor */
#endif
    return 0;
}
#endif

__weak int board_flash_wp_on(void)
{
    /*
     * Most flashes can‘t be detected when write protection is enabled,
     * so provide a way to let U-Boot gracefully ignore write protected
     * devices.
     */
    return 0;
}

 

u-boot nor flash 初始化过程

原文:https://www.cnblogs.com/idyllcheung/p/14134727.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!