Start of u-boot_ Armboot analysis

  • This paper mainly analyzes init_ Initialization function in sequence


int board_init(void)


	gd->bd->bi_arch_number = MACH_TYPE;
	gd->bd->bi_boot_params = (PHYS_SDRAM_1+0x100);

	return 0;
  • Only config is defined_ DRIVER_ Dm9000, so the main work focuses on dm9000 network card equipment
  • dm9000_ pre_ The init function is mainly used to configure the GPIO and port of the network card
  • gd->bd->bi_ arch_ Number is the machine code, which is the unique identification for configuring the development board. The main function of machine code is to compare and adapt between uboot and Linux kernel. When uboot starts the kernel, it will pass this machine code to the kernel as part of the parameter. Only when they are the same can they start normally
  • gd->bd->bi_ boot_ Params refers to the memory address of parameters transmitted by uboot to the Linux kernel during startup. The address defined here is 0x30000100


int interrupt_init(void)

	S5PC11X_TIMERS *const timers = S5PC11X_GetBase_TIMERS();

	/* use PWM Timer 4 because it has no output */
	/* prescaler for Timer 4 is 16 */
	timers->TCFG0 = 0x0f00;
	if (timer_load_val == 0) {
		 * for 10 ms clock period @ PCLK with 4 bit divider = 1/2
		 * (default) and prescaler = 16. Should be 10390
		 * @33.25MHz and  @ 66 MHz
		timer_load_val = get_PCLK() / (16 * 100);
	/* load value for 10 ms timeout */
	lastdec = timers->TCNTB4 = timer_load_val;
	/* auto load, manual update of Timer 4 */
	timers->TCON = (timers->TCON & ~0x00700000) | TCON_4_AUTO | TCON_4_UPDATE;
	/* auto load, start Timer 4 */
	timers->TCON = (timers->TCON & ~0x00700000) | TCON_4_AUTO | COUNT_4_ON;
	timestamp = 0;

	return (0);
  • Function to initialize timer


  • Initialize environment variables
  • This function can be found in many places, respectively in env_xxx.c in the document. After checking, this development board uses env_ The init function is located in env_movi.c medium
  • This function only initializes and determines the env in memory (GD - > env_valid). Currently, there is no relocation of environment variables from SD card to DDR, so the current environment variables cannot be used
  • start_ The armboot function is executing env_relocate the environment variables from SD card to DDR only after relocate. Environment variables can only be retrieved from DDR when they are needed after relocation. Environment variables can only be read from SD card before relocation


static int init_baudrate (void)
	char tmp[64];	/* long enough for environment variables */
	int i = getenv_r ("baudrate", tmp, sizeof (tmp));
	gd->bd->bi_baudrate = gd->baudrate = (i > 0)
			? (int) simple_strtoul (tmp, NULL, 10)

	return (0);
  • This function sets the baud rate of the serial port
  • First, get the baudrate value in the environment variable. If successful, use this value as the environment variable and record it in GD - > BD - > Bi_ Baudrate and Gd - > baudrate, otherwise use CONFIG_BAUDRATE defined value


  • Perform the first stage initialization of the console
  • Just GD - > have_ Console is assigned a value of 1


int dram_init(void)

	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
	gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;

#if defined(PHYS_SDRAM_2)
	gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
	gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;

#if defined(PHYS_SDRAM_3)
	gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
	gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE;

	return 0;
  • Initialize DDR software
  • Tell the software the starting address and length of DDR


  • Print ram configuration information
  • Under the command line of uboot, use bdinfo to print out all hardware related global variable values recorded in GD - > BD, and get the configuration information of DDR

Keywords: AI U-boot

Added by rayfinkel2 on Sat, 26 Feb 2022 18:28:05 +0200