欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

JZ2440学习总结3

程序员文章站 2024-03-19 09:12:58
...

使用FTP可直接登录 linux虚拟机上,进行远程操作
要是使用的是一期的****和老版本的UBUNTU进入需要使用

sudo chown book:book /work -R
//对work工作目录的使用权限进行更改
没有更改前只对root用户的开放

//更改之后会对  book用户开放

使用

 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 <[email protected]>
+ *
+ * (C) Copyright 2002
+ * David Mueller, ELSOFT AG, <[email protected]>
+ *
+ * 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)

+

+/* ¹©Íⲿµ÷Óõĺ¯Êý */

+void nand_init_ll(void);

+void nand_read_ll(unsigned char *buf, unsigned long start_addr, int size);

+

+/* NAND Flash²Ù×÷µÄ×ÜÈë¿Ú, ËüÃÇœ«µ÷ÓÃS3C2410»òS3C2440µÄÏàÓŠº¯Êý */

+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ŽŠÀíº¯Êý */

+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ŽŠÀíº¯Êý */

+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 Flash²Ù×÷º¯Êý */

+

+/* žŽÎ» */

+static void s3c2410_nand_reset(void)

+{

+    s3c2410_nand_select_chip();

+    s3c2410_write_cmd(0xff);  // žŽÎ»ÃüÁî

+    s3c2410_wait_idle();

+    s3c2410_nand_deselect_chip();

+}

+

+/* µÈŽýNAND FlashŸÍÐ÷ */

+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++);

+}

+

+/* ·¢³öƬѡÐźŠ*/

+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++);    

+}

+

+/* È¡ÏûƬѡÐźŠ*/

+static void s3c2410_nand_deselect_chip(void)

+{

+   S3C2410_NAND * s3c2410nand = (S3C2410_NAND *)0x4e000000;

+

+    s3c2410nand->NFCONF |= (1<<11);

+}

+

+/* ·¢³öÃüÁî */

+static void s3c2410_write_cmd(int cmd)

+{

+   S3C2410_NAND * s3c2410nand = (S3C2410_NAND *)0x4e000000;

+

+    volatile unsigned char *p = (volatile unsigned char *)&s3c2410nand->NFCMD;

+    *p = cmd;

+}

+

+/* ·¢³öµØÖ· */

+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++);

+}

+

+/* ¶ÁÈ¡ÊýŸÝ */

+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 Flash²Ù×÷º¯Êý */

+

+/* žŽÎ» */

+static void s3c2440_nand_reset(void)

+{

+    s3c2440_nand_select_chip();

+    s3c2440_write_cmd(0xff);  // žŽÎ»ÃüÁî

+    s3c2440_wait_idle();

+    s3c2440_nand_deselect_chip();

+}

+

+/* µÈŽýNAND FlashŸÍÐ÷ */

+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++);

+}

+

+/* ·¢³öƬѡÐźŠ*/

+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++);    

+}

+

+/* È¡ÏûƬѡÐźŠ*/

+static void s3c2440_nand_deselect_chip(void)

+{

+   S3C2440_NAND * s3c2440nand = (S3C2440_NAND *)0x4e000000;

+

+    s3c2440nand->NFCONT |= (1<<1);

+}

+

+/* ·¢³öÃüÁî */

+static void s3c2440_write_cmd(int cmd)

+{

+   S3C2440_NAND * s3c2440nand = (S3C2440_NAND *)0x4e000000;

+

+    volatile unsigned char *p = (volatile unsigned char *)&s3c2440nand->NFCMD;

+    *p = cmd;

+}

+

+/* ·¢³öµØÖ· */

+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++);

+}

+

+

+/* ·¢³öµØÖ· */

+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++);

+}

+

+/* ¶ÁÈ¡ÊýŸÝ */

+static unsigned char s3c2440_read_data(void)

+{

+   S3C2440_NAND * s3c2440nand = (S3C2440_NAND *)0x4e000000;

+    volatile unsigned char *p = (volatile unsigned char *)&s3c2440nand->NFDATA;

+    return *p;

+}

+

+

+/* ÔÚµÚÒ»ŽÎʹÓÃNAND FlashÇ°£¬žŽÎ»Ò»ÏÂNAND Flash */

+static void nand_reset(void)

+{

+    /* ÅжÏÊÇS3C2410»¹ÊÇS3C2440 */

+    if (isS3C2410)

+   {

+       s3c2410_nand_reset();

+   }

+   else

+   {

+       s3c2440_nand_reset();

+   }

+}

+

+static void wait_idle(void)

+{

+    /* ÅжÏÊÇS3C2410»¹ÊÇS3C2440 */

+    if (isS3C2410)

+   {

+       s3c2410_wait_idle();

+   }

+   else

+   {

+       s3c2440_wait_idle();

+   }

+}

+

+static void nand_select_chip(void)

+{

+    int i;

+   

+    /* ÅжÏÊÇS3C2410»¹ÊÇS3C2440 */

+    if (isS3C2410)

+   {

+       s3c2410_nand_select_chip();

+   }

+   else

+   {

+       s3c2440_nand_select_chip();

+   }

+   

+    for(i=0; i<10; i++);

+}

+

+static void nand_deselect_chip(void)

+{

+    /* ÅжÏÊÇS3C2410»¹ÊÇS3C2440 */

+    if (isS3C2410)

+   {

+       s3c2410_nand_deselect_chip();

+   }

+   else

+   {

+       s3c2440_nand_deselect_chip();

+   }   

+}

+

+static void write_cmd(int cmd)

+{

+    /* ÅжÏÊÇS3C2410»¹ÊÇS3C2440 */

+    if (isS3C2410)

+   {

+       s3c2410_write_cmd(cmd);

+   }

+   else

+   {

+       s3c2440_write_cmd(cmd);

+   }   

+}

+static void write_addr(unsigned int addr)

+{

+    /* ÅжÏÊÇS3C2410»¹ÊÇS3C2440 */

+    if (isS3C2410)

+   {

+       s3c2410_write_addr(addr);

+   }

+   else

+   {

+       s3c2440_write_addr(addr);

+   }   

+}

+

+static void write_addr_lp(unsigned int addr)

+{

+    /* ÅжÏÊÇS3C2410»¹ÊÇS3C2440 */

+    if (isS3C2410)

+   {

+       s3c2410_write_addr(addr);

+   }

+   else

+   {

+       s3c2440_write_addr_lp(addr);

+   }   

+}

+

+static unsigned char read_data(void)

+{

+    /* ÅжÏÊÇS3C2410»¹ÊÇS3C2440 */

+    if (isS3C2410)

+   {

+       return s3c2410_read_data();

+   }

+   else

+   {

+       return s3c2440_read_data();

+   }   

+}

+

+/* ³õÊŒ»¯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

+

+    /* ÅжÏÊÇS3C2410»¹ÊÇS3C2440 */

+    if (isS3C2410)

+    {

+       /* ʹÄÜNAND Flash¿ØÖÆÆ÷, ³õÊŒ»¯ECC, œûֹƬѡ, ÉèÖÃʱÐò */

+        s3c2410nand->NFCONF = (1<<15)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0);

+    }

+    else

+    {

+       /* ÉèÖÃʱÐò */

+        s3c2440nand->NFCONF = (TACLS<<12)|(TWRPH0<<8)|(TWRPH1<<4);

+        /* ʹÄÜNAND Flash¿ØÖÆÆ÷, ³õÊŒ»¯ECC, œûֹƬѡ */

+        s3c2440nand->NFCONT = (1<<4)|(1<<1)|(1<<0);

+    }

+

+   /* žŽÎ»NAND Flash */

+   nand_reset();

+}

+

+

+/* ¶Áº¯Êý */

+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 ;    /* µØÖ·»ò³€¶È²»¶ÔÆë */

+    }

+

+    /* Ñ¡ÖÐПƬ */

+    nand_select_chip();

+

+    for(i=start_addr; i < (start_addr + size);) {

+      /* ·¢³öREAD0ÃüÁî */

+      write_cmd(0);

+

+      /* Write Address */

+      write_addr(i);

+      wait_idle();

+

+      for(j=0; j < NAND_SECTOR_SIZE; j++, i++) {

+          *buf = read_data();

+          buf++;

+      }

+    }

+

+    /* È¡ÏûƬѡÐźŠ*/

+    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

文件系统

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 %config: scripts_basic outputmakefile FORCE

更改为

%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 
相关标签: 嵌入式