代码运行到了第二阶段代码lib_arm/board.c 中的start_armboot 函数,开始了系统的全面初始化。
3.1 修改 lib_arm/board.c 文件
这个文件的修改主要是关闭为AT9200 写的代码,增加LED的点亮(如果需要,此文未加)
#include <onenand_uboot.h>
#include <mmc.h>
//#include <s3c2410.h> //for led
…………
#if 0
/************************************************************************
* Coloured LEDfunctionality
************************************************************************
* May besupplied by boards if desired
*/
void inline __coloured_LED_init (void) {}
void coloured_LED_init (void) __attribute__((weak,alias("__coloured_LED_init")));
void inline __red_LED_on (void) {}
void red_LED_on (void) __attribute__((weak,alias("__red_LED_on")));
…………….
void inline __blue_LED_off(void) {}
void blue_LED_off(void) __attribute__((weak,alias("__blue_LED_off")));
#endif
/************************************************************************
* InitUtilities *
************************************************************************
static int display_banner (void)
{
printf("\n\n%s\n\n", version_string);
printf (" sunzl\n"); //根据个人兴趣打印想输出到终端的信息
printf(" Love Linux forever!!\n\n");
debug("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n",
_armboot_start, _bss_start, _bss_end);
大家可以看到lib_arm/board.c 中的start_armboot 函数中调用了很多初始化函数,这些函数分布在不同的文件中,后面会分别来修改。
3.2 修改 board/sunzl/sunzl2440/sunzl2440.c文件
这个文件负责板级初始化的任务, 修改其对GPIO和PLL的配置(请参阅开发板的硬件说明和芯片手册),还有添加网卡芯片(DM9000)的初始化函数。
#if FCLK_SPEED==0 /*Fout = 203MHz, Fin = 12MHz for Audio */
#define M_MDIV 0xC3
#define M_PDIV 0x4
#define M_SDIV 0x1
#elif FCLK_SPEED==1 /*Fout = 202.8MHz */
//#define M_MDIV 0x5c
//#define M_PDIV 0x4
//#define M_SDIV 0x0
#if defined(CONFIG_S3C2410)
/* Fout = 202.8MHz */
#define M_MDIV 0xA1
#define M_PDIV 0x3
#define M_SDIV 0x1
#endif
#if defined(CONFIG_S3C2440)
/* Fout = 405MHz */
#define M_MDIV 0x7f
#define M_PDIV 0x2
#define M_SDIV 0x1
#endif
#endif
#define USB_CLOCK 1
#if USB_CLOCK==0
#define U_M_MDIV 0xA1
#define U_M_PDIV 0x3
#define U_M_SDIV 0x1
#elif USB_CLOCK==1
#if defined(CONFIG_S3C2410)
#define U_M_MDIV 0x48
#define U_M_PDIV 0x3
#endif
#if defined(CONFIG_S3C2440)
#define U_M_MDIV 0x38
#define U_M_PDIV 0x2
#endif
#define U_M_SDIV 0x2
#endif
…………..
/*
* Miscellaneousplatform dependent initialisations
*/
int board_init (void)
{
………
/* set up the I/O ports */
gpio->GPACON= 0x007FFFFF;
//gpio->GPBCON = 0x00044556;
gpio->GPBCON = 0x00044555;//启动后禁止蜂鸣器响
………………
gpio->EXTINT0=0x22222222;
gpio->EXTINT1=0x22222222;
gpio->EXTINT2=0x22222222;
#if defined(CONFIG_S3C2410)
/* archnumber of SMDK2410-Board */
gd->bd->bi_arch_number= MACH_TYPE_SMDK2410;
#endif
#if defined(CONFIG_S3C2440)
/* arch number of S3C2440-Board */
gd->bd->bi_arch_number= MACH_TYPE_S3C2440 ;
#endif
/* adress ofboot parameters */
gd->bd->bi_boot_params= 0x30000100;
icache_enable();
dcache_enable();
return 0;
}
int dram_init (void)
{
gd->bd->bi_dram[0].start= PHYS_SDRAM_1;
gd->bd->bi_dram[0].size= PHYS_SDRAM_1_SIZE;
return 0;
}
#if 0
#if defined(CONFIG_CMD_NAND)
extern ulong nand_probe(ulong physadr);
……..
void nand_init(void)
{
structs3c2410_nand * const nand = s3c2410_get_base_nand();
NF_Init();
#ifdef DEBUG
printf("NANDflash probing at 0x%.8lX\n", (ulong)nand);
#endif
printf("%4lu MB\n", nand_probe((ulong)nand) >> 20);
}
#endif
#endif
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_CS8900
rc =cs8900_initialize(0, CONFIG_CS8900_BASE);
#endif
#ifdef CONFIG_DRIVER_DM9000
rc= dm9000_initialize(bis);
#endif
return rc;
}
#endif
到这里第二阶段的初始化的主线代码就修改完了,下面是各子系统的初始化和功能代码的修改