JZ2440学习总结3
生活随笔
收集整理的這篇文章主要介紹了
JZ2440学习总结3
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用FTP可直接登錄 linux虛擬機上,進行遠程操作
要是使用的是一期的視頻教程和老版本的UBUNTU進入需要使用
使用
tar xjf u-boot-1.1.6.tar.bz2 //解壓uboot文件使用
patch文件中的內容
diff -urN u-boot-1.1.6/board/100ask24x0/100ask24x0.c u-boot-1.1.6_jz2440/board/100ask24x0/100ask24x0.c --- u-boot-1.1.6/board/100ask24x0/100ask24x0.c 1970-01-01 07:00:00.000000000 +0700 +++ u-boot-1.1.6_jz2440/board/100ask24x0/100ask24x0.c 2010-11-26 12:54:37.034090906 +0800 @@ -0,0 +1,96 @@ +/* + * (C) Copyright 2002 + * Sysgo Real-Time Solutions, GmbH <www.elinos.com> + * Marius Groeger <mgroeger@sysgo.de> + * + * (C) Copyright 2002 + * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <s3c2410.h> + +DECLARE_GLOBAL_DATA_PTR; + +/* + * Miscellaneous platform dependent initialisations + */ + +int board_init (void) +{ + S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER(); + S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO(); + + /* set up the I/O ports */ + gpio->GPACON = 0x007FFFFF; + gpio->GPBCON = 0x00044555; + gpio->GPBUP = 0x000007FF; + gpio->GPCCON = 0xAAAAAAAA; + gpio->GPCUP = 0x0000FFFF; + gpio->GPDCON = 0xAAAAAAAA; + gpio->GPDUP = 0x0000FFFF; + gpio->GPECON = 0xAAAAAAAA; + gpio->GPEUP = 0x0000FFFF; + gpio->GPFCON = 0x000055AA; + gpio->GPFUP = 0x000000FF; + gpio->GPGCON = 0xFF95FFBA; + gpio->GPGUP = 0x0000FFFF; + gpio->GPHCON = 0x002AFAAA; + gpio->GPHUP = 0x000007FF; + + /* support both of S3C2410 and S3C2440, by www.100ask.net */ + if (isS3C2410) + { + /* arch number of SMDK2410-Board */ + gd->bd->bi_arch_number = MACH_TYPE_SMDK2410; + } + else + { + /* arch number of SMDK2440-Board */ + gd->bd->bi_arch_number = MACH_TYPE_S3C2440; + } + + /* adress of boot parameters */ + gd->bd->bi_boot_params = 0x30000100; +#if 0 + icache_enable(); + dcache_enable(); +#endif + 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; +} + +ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info) +{ + info->portwidth = CFG_FLASH_CFI_WIDTH; + info->chipwidth = CFG_FLASH_CFI_WIDTH; + info->interface = FLASH_CFI_X16; + return 1; +} + + diff -urN u-boot-1.1.6/board/100ask24x0/boot_init.c u-boot-1.1.6_jz2440/board/100ask24x0/boot_init.c --- u-boot-1.1.6/board/100ask24x0/boot_init.c 1970-01-01 07:00:00.000000000 +0700 +++ u-boot-1.1.6_jz2440/board/100ask24x0/boot_init.c 2010-11-26 12:54:37.042080086 +0800 @@ -0,0 +1,566 @@ +#include <common.h>+#include <s3c2410.h>++#define BUSY 1++#define NAND_SECTOR_SIZE 512+#define NAND_BLOCK_MASK (NAND_SECTOR_SIZE - 1)++#define NAND_SECTOR_SIZE_LP 2048+#define NAND_BLOCK_MASK_LP (NAND_SECTOR_SIZE_LP - 1)++/* 1?ía2?μ÷ó?μ?oˉêy */+void nand_init_ll(void);+void nand_read_ll(unsigned char *buf, unsigned long start_addr, int size);++/* NAND Flash2ù×÷μ?×üè??ú, ?ü????μ÷ó?S3C2410?òS3C2440μ??àó?oˉêy */+static void nand_reset(void);+static void wait_idle(void);+static void nand_select_chip(void);+static void nand_deselect_chip(void);+static void write_cmd(int cmd);+static void write_addr(unsigned int addr);+static unsigned char read_data(void);++/* S3C2410μ?NAND Flash??àíoˉêy */+static void s3c2410_nand_reset(void);+static void s3c2410_wait_idle(void);+static void s3c2410_nand_select_chip(void);+static void s3c2410_nand_deselect_chip(void);+static void s3c2410_write_cmd(int cmd);+static void s3c2410_write_addr(unsigned int addr);+static unsigned char s3c2410_read_data(void);++/* S3C2440μ?NAND Flash??àíoˉêy */+static void s3c2440_nand_reset(void);+static void s3c2440_wait_idle(void);+static void s3c2440_nand_select_chip(void);+static void s3c2440_nand_deselect_chip(void);+static void s3c2440_write_cmd(int cmd);+static void s3c2440_write_addr(unsigned int addr);+static unsigned char s3c2440_read_data(void);++/* S3C2410μ?NAND Flash2ù×÷oˉêy */++/* ???? */+static void s3c2410_nand_reset(void)+{+ s3c2410_nand_select_chip();+ s3c2410_write_cmd(0xff); // ?????üá?+ s3c2410_wait_idle();+ s3c2410_nand_deselect_chip();+}++/* μè?yNAND Flash?íD÷ */+static void s3c2410_wait_idle(void)+{+ int i;+ S3C2410_NAND * s3c2410nand = (S3C2410_NAND *)0x4e000000;+ + volatile unsigned char *p = (volatile unsigned char *)&s3c2410nand->NFSTAT;+ while(!(*p & BUSY))+ for(i=0; i<10; i++);+}++/* ·¢3?????D?o? */+static void s3c2410_nand_select_chip(void)+{+ int i;+ S3C2410_NAND * s3c2410nand = (S3C2410_NAND *)0x4e000000;++ s3c2410nand->NFCONF &= ~(1<<11);+ for(i=0; i<10; i++); +}++/* è???????D?o? */+static void s3c2410_nand_deselect_chip(void)+{+ S3C2410_NAND * s3c2410nand = (S3C2410_NAND *)0x4e000000;++ s3c2410nand->NFCONF |= (1<<11);+}++/* ·¢3??üá? */+static void s3c2410_write_cmd(int cmd)+{+ S3C2410_NAND * s3c2410nand = (S3C2410_NAND *)0x4e000000;++ volatile unsigned char *p = (volatile unsigned char *)&s3c2410nand->NFCMD;+ *p = cmd;+}++/* ·¢3?μ??· */+static void s3c2410_write_addr(unsigned int addr)+{+ int i;+ S3C2410_NAND * s3c2410nand = (S3C2410_NAND *)0x4e000000;+ volatile unsigned char *p = (volatile unsigned char *)&s3c2410nand->NFADDR;+ + *p = addr & 0xff;+ for(i=0; i<10; i++);+ *p = (addr >> 9) & 0xff;+ for(i=0; i<10; i++);+ *p = (addr >> 17) & 0xff;+ for(i=0; i<10; i++);+ *p = (addr >> 25) & 0xff;+ for(i=0; i<10; i++);+}++/* ?áè?êy?Y */+static unsigned char s3c2410_read_data(void)+{+ S3C2410_NAND * s3c2410nand = (S3C2410_NAND *)0x4e000000;++ volatile unsigned char *p = (volatile unsigned char *)&s3c2410nand->NFDATA;+ return *p;+}++/* S3C2440μ?NAND Flash2ù×÷oˉêy */++/* ???? */+static void s3c2440_nand_reset(void)+{+ s3c2440_nand_select_chip();+ s3c2440_write_cmd(0xff); // ?????üá?+ s3c2440_wait_idle();+ s3c2440_nand_deselect_chip();+}++/* μè?yNAND Flash?íD÷ */+static void s3c2440_wait_idle(void)+{+ int i;+ S3C2440_NAND * s3c2440nand = (S3C2440_NAND *)0x4e000000;+ volatile unsigned char *p = (volatile unsigned char *)&s3c2440nand->NFSTAT;++ while(!(*p & BUSY))+ for(i=0; i<10; i++);+}++/* ·¢3?????D?o? */+static void s3c2440_nand_select_chip(void)+{+ int i;+ S3C2440_NAND * s3c2440nand = (S3C2440_NAND *)0x4e000000;++ s3c2440nand->NFCONT &= ~(1<<1);+ for(i=0; i<10; i++); +}++/* è???????D?o? */+static void s3c2440_nand_deselect_chip(void)+{+ S3C2440_NAND * s3c2440nand = (S3C2440_NAND *)0x4e000000;++ s3c2440nand->NFCONT |= (1<<1);+}++/* ·¢3??üá? */+static void s3c2440_write_cmd(int cmd)+{+ S3C2440_NAND * s3c2440nand = (S3C2440_NAND *)0x4e000000;++ volatile unsigned char *p = (volatile unsigned char *)&s3c2440nand->NFCMD;+ *p = cmd;+}++/* ·¢3?μ??· */+static void s3c2440_write_addr(unsigned int addr)+{+ int i;+ S3C2440_NAND * s3c2440nand = (S3C2440_NAND *)0x4e000000;+ volatile unsigned char *p = (volatile unsigned char *)&s3c2440nand->NFADDR;+ + *p = addr & 0xff;+ for(i=0; i<10; i++);+ *p = (addr >> 9) & 0xff;+ for(i=0; i<10; i++);+ *p = (addr >> 17) & 0xff;+ for(i=0; i<10; i++);+ *p = (addr >> 25) & 0xff;+ for(i=0; i<10; i++);+}+++/* ·¢3?μ??· */+static void s3c2440_write_addr_lp(unsigned int addr)+{+ int i;+ S3C2440_NAND * s3c2440nand = (S3C2440_NAND *)0x4e000000;+ volatile unsigned char *p = (volatile unsigned char *)&s3c2440nand->NFADDR;+ int col, page;++ col = addr & NAND_BLOCK_MASK_LP;+ page = addr / NAND_SECTOR_SIZE_LP;+ + *p = col & 0xff; /* Column Address A0~A7 */+ for(i=0; i<10; i++); + *p = (col >> 8) & 0x0f; /* Column Address A8~A11 */+ for(i=0; i<10; i++);+ *p = page & 0xff; /* Row Address A12~A19 */+ for(i=0; i<10; i++);+ *p = (page >> 8) & 0xff; /* Row Address A20~A27 */+ for(i=0; i<10; i++);+ *p = (page >> 16) & 0x03; /* Row Address A28~A29 */+ for(i=0; i<10; i++);+}++/* ?áè?êy?Y */+static unsigned char s3c2440_read_data(void)+{+ S3C2440_NAND * s3c2440nand = (S3C2440_NAND *)0x4e000000;+ volatile unsigned char *p = (volatile unsigned char *)&s3c2440nand->NFDATA;+ return *p;+}+++/* ?úμúò???ê1ó?NAND Flash?°£?????ò???NAND Flash */+static void nand_reset(void)+{+ /* ?D??ê?S3C2410?1ê?S3C2440 */+ if (isS3C2410)+ {+ s3c2410_nand_reset();+ }+ else+ {+ s3c2440_nand_reset();+ }+}++static void wait_idle(void)+{+ /* ?D??ê?S3C2410?1ê?S3C2440 */+ if (isS3C2410)+ {+ s3c2410_wait_idle();+ }+ else+ {+ s3c2440_wait_idle();+ }+}++static void nand_select_chip(void)+{+ int i;+ + /* ?D??ê?S3C2410?1ê?S3C2440 */+ if (isS3C2410)+ {+ s3c2410_nand_select_chip();+ }+ else+ {+ s3c2440_nand_select_chip();+ }+ + for(i=0; i<10; i++);+}++static void nand_deselect_chip(void)+{+ /* ?D??ê?S3C2410?1ê?S3C2440 */+ if (isS3C2410)+ {+ s3c2410_nand_deselect_chip();+ }+ else+ {+ s3c2440_nand_deselect_chip();+ } +}++static void write_cmd(int cmd)+{+ /* ?D??ê?S3C2410?1ê?S3C2440 */+ if (isS3C2410)+ {+ s3c2410_write_cmd(cmd);+ }+ else+ {+ s3c2440_write_cmd(cmd);+ } +}+static void write_addr(unsigned int addr)+{+ /* ?D??ê?S3C2410?1ê?S3C2440 */+ if (isS3C2410)+ {+ s3c2410_write_addr(addr);+ }+ else+ {+ s3c2440_write_addr(addr);+ } +}++static void write_addr_lp(unsigned int addr)+{+ /* ?D??ê?S3C2410?1ê?S3C2440 */+ if (isS3C2410)+ {+ s3c2410_write_addr(addr);+ }+ else+ {+ s3c2440_write_addr_lp(addr);+ } +}++static unsigned char read_data(void)+{+ /* ?D??ê?S3C2410?1ê?S3C2440 */+ if (isS3C2410)+ {+ return s3c2410_read_data();+ }+ else+ {+ return s3c2440_read_data();+ } +}++/* 3?ê??ˉNAND Flash */+void nand_init_ll(void)+{+ S3C2410_NAND * s3c2410nand = (S3C2410_NAND *)0x4e000000;+ S3C2440_NAND * s3c2440nand = (S3C2440_NAND *)0x4e000000;++#define TACLS 0+#define TWRPH0 3+#define TWRPH1 0++ /* ?D??ê?S3C2410?1ê?S3C2440 */+ if (isS3C2410)+ {+ /* ê1?üNAND Flash?????÷, 3?ê??ˉECC, ???1????, éè??ê±Dò */+ s3c2410nand->NFCONF = (1<<15)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0);+ }+ else+ {+ /* éè??ê±Dò */+ s3c2440nand->NFCONF = (TACLS<<12)|(TWRPH0<<8)|(TWRPH1<<4);+ /* ê1?üNAND Flash?????÷, 3?ê??ˉECC, ???1???? */+ s3c2440nand->NFCONT = (1<<4)|(1<<1)|(1<<0);+ }++ /* ????NAND Flash */+ nand_reset();+}+++/* ?áoˉêy */+void nand_read_ll(unsigned char *buf, unsigned long start_addr, int size)+{+ int i, j;+ + if ((start_addr & NAND_BLOCK_MASK) || (size & NAND_BLOCK_MASK)) {+ return ; /* μ??·?ò3€?è2????? */+ }++ /* ???DD??? */+ nand_select_chip();++ for(i=start_addr; i < (start_addr + size);) {+ /* ·¢3?READ0?üá? */+ write_cmd(0);++ /* Write Address */+ write_addr(i);+ wait_idle();++ for(j=0; j < NAND_SECTOR_SIZE; j++, i++) {+ *buf = read_data();+ buf++;+ }+ }++ /* è???????D?o? */+ nand_deselect_chip();+ + return ;+}+ cd u-boot-1.1.6 //進入上一步解壓出來的文件夾 patch -p1 < ../u-boot-1.1.6_jz2440.patch //使用patch命令進行打補丁, 其中 使用 -p1的意思是忽略文件夾的第一的 '/'因為使用打補丁命令的時候已經進入了u-boot-1.1.6文件夾如下:
diff -urN u-boot-1.1.6/board/100ask24x0/100ask24x0.c u-boot-1.1.6_jz2440/board/100ask24x0/100ask24x0.c --- u-boot-1.1.6/board/100ask24x0/100ask24x0.c 1970-01-01 07:00:00.000000000 +0700 +++ u-boot-1.1.6_jz2440/board/100ask24x0/100ask24x0.c 2010-11-26 12:54:37.034090906 +0800文件系統(tǒng)
tar xjf linux-2.6.22.6.tar.bz2 //解壓文件 cd linux-2.6.22.6 //介入解壓之后的文件 //使用 patch -p1 < ../linux-2.6.22.6_jz2440.patch //打補丁 //然后使用,ls 查看文件 將文件中出現的 config_ok 文件 cp成 .config文件 cp config_ok .config //然后使用 make uImage生成uImage文件 make uImage//注 因為老版本的 makefile與新版本的make 有部分不兼容會出現如下的錯誤
Makefile:416:*** mixed implicit and normal rules: deprecated syntax Makefile:1449:*** mixed implicit and normal rules: deprecated syntax這是因為使用 make 比 文件中的make 較新導致的,因此需要進行如下更改即可
對416行進行修改
將
更改為
%config: scripts_basic outputmakefile FORCE將1449行
/ %/: prepare scripts FORCE更改為
%/: prepare scripts FORCE若是在進行 make uImage指令之后出現
"mkimage" command not found - U-Boot images will not be built需要進行手動的 uboot工具安裝,安裝的命令如下:;
sudo apt-get install u-boot-tools然后在進行
make uImage總結
以上是生活随笔為你收集整理的JZ2440学习总结3的全部內容,希望文章能夠幫你解決所遇到的問題。