[U-Boot] ICACHE in core initialization to improve u-boot boot time: Breaks booting with i2c code while executing in flash.

Richard Retanubun RichardRetanubun at RuggedCom.com
Tue Oct 19 18:03:31 CEST 2010


Hi Kim,

I recently rebased our platform from uboot 2009.11 to 2010.09 and tried out the ICACHE improvements you made
in commit 1a2e203b31d33fb720f2cf1033b241ad36ab405a

It does not work on our platform (similar to MPC8360EMDS). I think this is specific to our platform because
we need to initialize i2c and use i2c while still executing from flash in checkboard()) to read and parse a board-id i2c-eeprom
to support a unified uboot binary for multiple board flavors.

I pasted checkboard code below; none of the underlying code uses malloc, just static buffer allocations.

Just an FYI mostly, I am okay with not having ICACHE for our board while in uboot.
Just curious if you know of a reason from the limited explanation I've provided.

Also, as a general rule, does uboot accept hosting custom non-eval-platform boards?
I'm tempted to mainline our code (mostly contained under /board/$company_name/...)

Thanks for your time

- Richard


/* ------------------- gd->board_type is identified here -------------------- */
int checkboard(void)
{
	int rc = -EINVAL;
	int i  = -1;
	int nbytes = 0;
	char pnbuf[512] = {0};


	rc = -EINVAL; /* Initialize return code */

	/*
	 * Based on code from cm5200, called while u-boot is executing in flash,
	 * thus things like malloc are not allowed.
	*/

	/*
	 * We need I2C to access HW ID data from EEPROM, so we call i2c_init()
	 * here despite the fact that it will be called again later on. We
	 * also use a little trick to silence I2C-related output.
	 */
	gd->flags |= GD_FLG_SILENT;
	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
	gd->flags &= ~GD_FLG_SILENT;

	/* Reset i2c controller(s) to clear any stuck-bus conditions */
	i2c_bus_reset(CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET);
#if defined(CONFIG_SYS_I2C2_OFFSET)
	i2c_bus_reset(CONFIG_SYS_IMMR + CONFIG_SYS_I2C2_OFFSET);
#endif /* CONFIG_SYS_I2C2_OFFSET */
	/* Print a message to stay off the i2c bus for devices to settle */
	puts("I2C:   Reset\n");

	rc = rc_id_board_from_esig(); /* fills in gd->board_type */
	if (rc == 0) {
		printf("BOARD: %s [%08lX]\n",
			rc_get_string_from_board_type(gd->board_type),
			gd->board_type);
	} else {

		/* BAD PARTNUMBER OR BAD I2C ACCESS, REBOOT */
		printf("BOARD: FAILED IDENTIFICATION, error %d\n", rc);
	}

	/* Always return 0, otherwise u-boot will halt and ask for reset */
	return 0;
}


More information about the U-Boot mailing list