新聞中心

minis3c2440移植之uboot移植

作者: 時(shí)間:2016-11-24 來(lái)源:網(wǎng)絡(luò) 收藏
U-boot移植
(以下步驟適用于s3c2440開(kāi)發(fā)板)
1、修改Makefile文件:
a.修改交叉編譯宏(CROSS_COMPILE?=)修改為(CROSS_COMPILE?=arm-linux-);
b.將._LIBS:后的兩個(gè)變量交換位置(line289)
c.添加tocore2440_config Make文件(line2997)
tocore2440_config: unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t tocore2440 tocore s3c24x0
包含六個(gè)參數(shù):$1. tocore2440 表示在include/configs/目錄下必須包含tocore2440.h文件;$2. arm表示在主目錄下包含lib_arm目錄,在include/目錄下包含asm_arm目錄;$3.arm920t表示CPU型號(hào),在cpu目錄下包含arm920t目錄;$4.tocore2440芯片型號(hào);$5.廠商目錄(if($5!=NULL),則在board目錄下有$5/$4目錄,else,則在board目錄下有$4目錄);$6. s3c24x0表示在include/asm_arm/包含arch_ s3c24x0目錄;
d.以上部分表示在移植U-boot前首先要添加開(kāi)發(fā)板自己的配置頭文件,并在board目錄下建立自己的開(kāi)發(fā)板目錄,修改s3c24x0(cpu/arm920t/s3c24x0,include/asm_arm/archs3c24x0)文件,改為支持2440開(kāi)發(fā)板,修改過(guò)程如下:
1) 修改inperrupts.c文件,添加宏定義:#defined(CONFIG_S3C2440)( line36)。
2) 修改speed.c文件:a.添加宏定義:#defined (CONFIG_S3C2440) ( line33);b.在get_PLLCLK()函數(shù)中添加2440支持,具體修改方式如下:在return返回值前添加#if defined(CONFIG_S3C2440)
if (pllreg == MPLL)
return((CONFIG_SYS_CLK_FREQ * m * 2) / (p << s)); //得到2440開(kāi)發(fā)板的頻率
else if (pllreg == UPLL)
#endif
c.將get_HCLK()函數(shù)修改為2440支持,將原函數(shù)返回改為:
//該函數(shù)為讀取當(dāng)前系統(tǒng)時(shí)鐘
#if defined(CONFIG_S3C2440)
if (clk_power->CLKDIVN & 0x6)
{
if ((clk_power->CLKDIVN & 0x6)==2) return(get_FCLK()/2);
if ((clk_power->CLKDIVN & 0x6)==6) return((clk_power->CAMDIVN & 0x100) ? get_FCLK()/6 : get_FCLK()/3);
if ((clk_power->CLKDIVN & 0x6)==4) return((clk_power->CAMDIVN & 0x200) ? get_FCLK()/8 : get_FCLK()/4);
return(get_FCLK());
}
else return(get_FCLK());
#else
return((clk_power->CLKDIVN & 0x2) ? get_FCLK()/2 : get_FCLK());
#endif
d.修改time.c文件,添加宏定義#defined (CONFIG_S3C2440)(line33)
2、添加配置文件
a.將smdk2410.h復(fù)制為tocore2440.h,其文件修改如下:
1)添加宏#undef CONFIG_SKIP_LOWLEVEL_INIT (line40)
2)注釋2410宏定義:
//#define CONFIG_S 3C2410 1
//#define CONFIG_SBC2410X 1
3)添加2440宏定義:
#define CONFIG_S3C2440 1
#define CONFIG_TOCORE2440 1
#define CONFIG_TOCORE2440_LED 1 //添加點(diǎn)燈宏定義
#define CONFIG_S3C2440_NAND_BOOT 1 //Nandflash啟動(dòng)
4)注釋CS8900網(wǎng)卡宏定義(在line72添加#if 0,在line76 添加#endif),添加DM9000網(wǎng)卡宏定義:
#define CONFIG_DRIVER_DM9000 1
#define CONFIG_DM9000_USE_16BIT 1
#define CONFIG_DM9000_BASE 0x20000300
#define DM9000_IO 0x20000300
#define DM9000_DATA 0x20000304
#define CONFIG_DM9000_NO_SROM 1
#undef CONFIG_DM9000_DEBUG
#define CONFIG_NET_MULTI
5)在命令行宏定義中添加如下宏定義:
#define CONFIG_CMD_ASKENV
#define CONFIG_CMD_DHCP
#define CONFIG_CMD_PING
#define CONFIG_CMD_NAND
#define CONFIG_CMD_SAVEENV

#define CONFIG_BOOTDELAY 3 //設(shè)置系統(tǒng)啟動(dòng)等待時(shí)間
#define CONFIG_BOOTARGS "console=ttySAC0 root=/dev/nfs "
"nfsroot=192.168.2.199:/fs "
"ip=192.168.2.69:" //NFS支持
#define CONFIG_ETHADDR 08:00:3e:26:0a:5b //打開(kāi)MAC
#define CONFIG_IPADDR 192.168.2.69 //定義自身IP
#define CONFIG_SERVERIP 192.168.2.105 //定義服務(wù)器IP
#define CONFIG_BOOTCOMMAND "dhcp; bootm" //打開(kāi)DHCP
//line154之后添加如下宏定義
#define CONFIG_SYS_PROMPT "[tocore2440 ]# " //修改啟動(dòng)標(biāo)識(shí)
#define CONFIG_SYS_LOAD_ADDR 0x31000000 //下載地址
#define CONFIG_ENV_ADDR 0x060000 //斷電保存地址
#define CONFIG_ENV_IS_IN_NAND 1 //Nandflash
#define CONFIG_ENV_OFFSET 0X60000 //整個(gè)寄存器偏移地址
#define CONFIG_ENV_SIZE 0x20000 //ENV分區(qū)大小
#define MTDPARTS_DEFAULT "mtdparts=nandflash0:384k(bootloader),"
"128k(params),"
"5m(kernel),"
"-(root)" //Nandflash默認(rèn)設(shè)置

#define NAND_MAX_CHIPS 1 //Nandflash最大個(gè)數(shù)
#define CONFIG_MTD_NAND_VERIFY_WRITE //校驗(yàn)
#if defined(CONFIG_TOCORE2440_LED) //點(diǎn)燈宏定義


#define GPIO_CTL_BASE 0x56000000
#define oGPIO_B 0x10
#define oGPIO_CON 0x0
#define oGPIO_DAT 0x4
#define oGPIO_UP 0x8
#endif
#define STACK_BASE 0x33f00000
#define STACK_SIZE 0x10000

6)對(duì)Nandflash的相關(guān)設(shè)置修改如下:
添加LV800支持宏定義,注釋掉如下宏定義
//#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x0F0000)
//#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x070000)
//#define CONFIG_ENV_IS_IN_FLASH 1
//#define CONFIG_ENV_SIZE 0x10000
添加Nandflash設(shè)置:
#if defined(CONFIG_CMD_NAND)
#define CONFIG_NAND_S3C2410
#define CONFIG_SYS_MAX_NAND_DEVICE 1
#endif
#define CONFIG_SETUP_MEMORY_TAGS
#define CONFIG_INITRD_TAG
#define CONFIG_CMDLINE_TAG
#define CONFIG_SYS_HUSH_PARSER
#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
#define CONFIG_CMDLINE_EDITING
#ifdef CONFIG_CMDLINE_EDITING
#undef CONFIG_AUTO_COMPLETE
#else
#define CONFIG_AUTO_COMPLETE
#endif

#define CONFIG_SYS_NAND_BASE 0x4E000000
#define NAND_CTL_BASE 0x4E000000
#define bINT_CTL(Nb) __REG(INT_CTL_BASE + (Nb))


#define oNFCONF 0x00
#if defined(CONFIG_S3C2440)
#define CONFIG_S3C2440_NAND_BOOT 1

#define oNFCONT 0x04
#define oNFCMD 0x08
#define oNFADDR 0x0c
#define oNFDATA 0x10
#define oNFSTAT 0x20
#define oNFECC 0x2c
#define rNFCONF (*(volatile unsigned int *)0x4e000000)
#define rNFCONT (*(volatile unsigned int *)0x4e000004)
#define rNFCMD (*(volatile unsigned char *)0x4e000008)
#define rNFADDR (*(volatile unsigned char *)0x4e00000c)
#define rNFDATA (*(volatile unsigned char *)0x4e000010)
#define rNFSTAT (*(volatile unsigned int *)0x4e000020)
#define rNFECC (*(volatile unsigned int *)0x4e00002c)
#endif
#if defined(CONFIG_S3C2410)
#define CONFIG_S3C2410_NAND_BOOT 1

#define oNFCONF 0x00
#define oNFCMD 0x04
#define oNFADDR 0x08
#define oNFDATA 0x0c
#define oNFSTAT 0x10
#define oNFECC 0x14
#define rNFCONF (*(volatile unsigned int *)0x4e000000)
#define rNFCMD (*(volatile unsigned char *)0x4e000004)
#define rNFADDR (*(volatile unsigned char *)0x4e000008)
#define rNFDATA (*(volatile unsigned char *)0x4e00000c)
#define rNFSTAT (*(volatile unsigned int *)0x4e000010)
#define rNFECC (*(volatile unsigned int *)0x4e000014)
#define rNFECC0 (*(volatile unsigned char *)0x4e000014)
#define rNFECC1 (*(volatile unsigned char *)0x4e000015)
#define rNFECC2 (*(volatile unsigned char *)0x4e000016)
#endif
至此tocore2440.h文件修改完畢
b.建立目錄/board/tocore/tocore2440,將/board/samsung/smdk2440下的文件拷貝至/board/tocore/tocore2440下,拷貝nand_read.c(開(kāi)發(fā)板自帶)文件至該目錄下。修改Makefile文件(line28)
COBJS :=tocore2440.o nand_read.o flash.o
c.修改lowlevel_init.S文件,添加如下支持2440代碼:
#if defined(CONFIG_S3C2440)
#define Trp 0x2
#define REFCNT 1012
#else
#define Trp 0x0
#define REFCNT 0x0459
#endif
d.修改tocore2440.c文件:
在#elif FCLK_SPEED==1之后添加:
#if defined(CONFIG_S3C2440)
#define M_MDIV 0x7f
#define M_PDIV 0x2
#define M_SDIV 0x1
#endif
#endif
在#elif USB_CLOCK==1之后修改為:
//#define U_M_MDIV 0x48
//#define U_M_PDIV 0x3

#if defined(CONFIG_S3C2440)
#define U_M_MDIV 0x38
#define U_M_PDIV 0x2
#endif
修改board_init()函數(shù):
將gpio->GPGCON的值改為 0xFF95FF3A;
將gpio->GPHCON 的值改為 0x0016FAAA
在gpio->GPHUP = 0x000007FF之后添加一下宏定義:
gpio->EXTINT0=0x22222222;
gpio->EXTINT1=0x22222222;
gpio->EXTINT2=0x22222222;

在dcache_enable()函數(shù)之后添加以下低昂等操作代碼:
#if defined(CONFIG_TOCORE2440_LED)
gpio->GPBDAT = 0x181;
#endif

在board_init()函數(shù)之后添加以下函數(shù):
#ifdef CONFIG_DRIVER_DM9000
int board_eth_init(bd_t *bis)
{
return dm9000_initialize(bis);
}
#endif
至此tocore2440.c文件修改完畢
e.修改start.S文件:
1)注釋掉以下代碼:
//bl coloured_LED_init
//bl red_LED_on
在#if defined (CONFIG_S3C2400) || defined (CONFIG_S3C2410)之后添加2440的支持:|| defined(CONFIG_S3C2440)
2)在line146之后添加對(duì)時(shí)鐘設(shè)置代碼:
#define CLK_CTL_BASE 0x4C000000
#define MDIV_405 0x7f<<12
#define PSDIV_405 0x21
#define MDIV_200 0xa1<<12
#define PSDIV_200 0x31
#endif
在line163之后添加工作頻率設(shè)置匯編代碼
#if defined(CONFIG_S3C2440)

上一頁(yè) 1 2 下一頁(yè)

關(guān)鍵詞: minis3c2440移植uboot移

評(píng)論


技術(shù)專區(qū)

關(guān)閉