Chinaunix首页 | 论坛 | 博客
  • 博客访问: 98158
  • 博文数量: 38
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 384
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-06 16:52
文章分类

全部博文(38)

文章存档

2014年(38)

我的朋友

分类: 嵌入式

2014-04-06 17:38:39

1.修改include/configs/smdk6410.h,更改nandflash大小,改为

点击(此处)折叠或打开

  1. /* NAND chip page size */
  2. #define CONFIG_SYS_NAND_PAGE_SIZE 4096
  3. /* NAND chip block size */
  4. #define CONFIG_SYS_NAND_BLOCK_SIZE (512 * 1024)
  5. /* NAND chip page per block count */
  6. #define CONFIG_SYS_NAND_PAGE_COUNT 128


2.
支持8位ECC

    替换drivers/mtd/nand/s3c64xx.c,替换文件下载地址:,内容如下

点击(此处)折叠或打开

  1. /*
  2.  * (C) Copyright 2006 DENX Software Engineering
  3.  *
  4.  * Implementation for U-Boot 1.1.6 by Samsung
  5.  *
  6.  * (C) Copyright 2008
  7.  * Guennadi Liakhovetki, DENX Software Engineering, <lg@denx.de>
  8.  *
  9.  * See file CREDITS for list of people who contributed to this
  10.  * project.
  11.  *
  12.  * This program is free software; you can redistribute it and/or
  13.  * modify it under the terms of the GNU General Public License as
  14.  * published by the Free Software Foundation; either version 2 of
  15.  * the License, or (at your option) any later version.
  16.  *
  17.  * This program is distributed in the hope that it will be useful,
  18.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20.  * GNU General Public License for more details.
  21.  *
  22.  * You should have received a copy of the GNU General Public License
  23.  * along with this program; if not, write to the Free Software
  24.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25.  * MA 02111-1307 USA
  26.  */

  27. #include <common.h>

  28. #include <nand.h>
  29. #include <linux/mtd/nand.h>

  30. #ifdef CONFIG_S3C6400
  31. #include <asm/arch/s3c6400.h>
  32. #else
  33. #include <asm/arch/s3c6410.h>
  34. #endif

  35. #include <asm/io.h>
  36. #include <asm/errno.h>

  37. #define MAX_CHIPS    2
  38. static int nand_cs[MAX_CHIPS] = {0, 1};

  39. #ifdef CONFIG_NAND_SPL
  40. #define printf(arg...) do {} while (0)
  41. #endif

  42. /* Nand flash definition values by jsgood */
  43. #ifdef S3C_NAND_DEBUG
  44. /*
  45.  * Function to print out oob buffer for debugging
  46.  * Written by jsgood
  47.  */
  48. static void print_oob(const char *header, struct mtd_info *mtd)
  49. {
  50.     int i;
  51.     struct nand_chip *chip = mtd->priv;

  52.     printf("%s:\t", header);

  53.     for (i = 0; i < 64; i++)
  54.         printf("%02x ", chip->oob_poi[i]);

  55.     printf("\n");
  56. }
  57. #endif /* S3C_NAND_DEBUG */

  58. static void s3c_nand_select_chip(struct mtd_info *mtd, int chip)
  59. {
  60.     int ctrl = readl(NFCONT);

  61.     switch (chip) {
  62.     case -1:
  63.         ctrl |= 6;
  64.         break;
  65.     case 0:
  66.         ctrl &= ~2;
  67.         break;
  68.     case 1:
  69.         ctrl &= ~4;
  70.         break;
  71.     default:
  72.         return;
  73.     }

  74.     writel(ctrl, NFCONT);
  75. }

  76. /*
  77.  * Hardware specific access to control-lines function
  78.  * Written by jsgood
  79.  */
  80. static void s3c_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  81. {
  82.     struct nand_chip *this = mtd->priv;

  83.     if (ctrl & NAND_CTRL_CHANGE) {
  84.         if (ctrl & NAND_CLE)
  85.             this->IO_ADDR_W = (void __iomem *)NFCMMD;
  86.         else if (ctrl & NAND_ALE)
  87.             this->IO_ADDR_W = (void __iomem *)NFADDR;
  88.         else
  89.             this->IO_ADDR_W = (void __iomem *)NFDATA;
  90.         if (ctrl & NAND_NCE)
  91.             s3c_nand_select_chip(mtd, *(int *)this->priv);
  92.         else
  93.             s3c_nand_select_chip(mtd, -1);
  94.     }

  95.     if (cmd != NAND_CMD_NONE)
  96.         writeb(cmd, this->IO_ADDR_W);
  97. }

  98. /*
  99.  * Function for checking device ready pin
  100.  * Written by jsgood
  101.  */
  102. static int s3c_nand_device_ready(struct mtd_info *mtdinfo)
  103. {
  104.     return !!(readl(NFSTAT) & NFSTAT_RnB);
  105. }

  106. #ifdef CONFIG_SYS_S3C_NAND_HWECC
  107. /*
  108.  * This function is called before encoding ecc codes to ready ecc engine.
  109.  * Written by jsgood
  110.  */
  111.  
  112. #if defined(CONFIG_NAND_BL1_8BIT_ECC) && (defined(CONFIG_S3C6410) || defined(CONFIG_S3C6430))
  113.  /***************************************************************
  114.   * jsgood: Temporary 8 Bit H/W ECC supports for BL1 (6410/6430 only)
  115.   ***************************************************************/
  116.  int cur_ecc_mode=0;
  117.     /*
  118.      * Function for checking ECCEncDone in NFSTAT
  119.      * Written by jsgood
  120.      */
  121.     static void s3c_nand_wait_enc(void)
  122.     {
  123.         while (!(readl(NFSTAT) & NFSTAT_ECCENCDONE)) {}
  124.     }
  125.     
  126.     /*
  127.      * Function for checking ECCDecDone in NFSTAT
  128.      * Written by jsgood
  129.      */
  130.     static void s3c_nand_wait_dec(void)
  131.     {
  132.         while (!(readl(NFSTAT) & NFSTAT_ECCDECDONE)) {}
  133.     }
  134.   
  135.  static void s3c_nand_wait_ecc_busy_8bit(void)
  136.  {
  137.      while (readl(NF8ECCERR0) & NFESTAT0_ECCBUSY) {}
  138.  }
  139.  void s3c_nand_enable_hwecc_8bit(struct mtd_info *mtd, int mode)
  140. {
  141.     u_long nfcont, nfconf;

  142.     cur_ecc_mode = mode;

  143.     /* 8 bit selection */
  144.     nfconf = readl(NFCONF);

  145.     nfconf &= ~(0x3 << 23);
  146.     nfconf |= (0x1 << 23);

  147.     writel(nfconf, NFCONF);

  148.     /* Initialize & unlock */
  149.     nfcont = readl(NFCONT);
  150.     nfcont |= NFCONT_INITECC;
  151.     nfcont &= ~NFCONT_MECCLOCK;

  152.     if (mode == NAND_ECC_WRITE)
  153.         nfcont |= NFCONT_ECC_ENC;
  154.     else if (mode == NAND_ECC_READ)
  155.         nfcont &= ~NFCONT_ECC_ENC;

  156.     writel(nfcont, NFCONT);
  157. }
  158. int s3c_nand_calculate_ecc_8bit(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
  159. {
  160.     u_long nfcont, nfm8ecc0, nfm8ecc1, nfm8ecc2, nfm8ecc3;

  161.     /* Lock */
  162.     nfcont = readl(NFCONT);
  163.     nfcont |= NFCONT_MECCLOCK;
  164.     writel(nfcont, NFCONT);

  165.     if (cur_ecc_mode == NAND_ECC_READ)
  166.         s3c_nand_wait_dec();
  167.     else {
  168.         s3c_nand_wait_enc();

  169.         nfm8ecc0 = readl(NFM8ECC0);
  170.         nfm8ecc1 = readl(NFM8ECC1);
  171.         nfm8ecc2 = readl(NFM8ECC2);
  172.         nfm8ecc3 = readl(NFM8ECC3);

  173.         ecc_code[0] = nfm8ecc0 & 0xff;
  174.         ecc_code[1] = (nfm8ecc0 >> 8) & 0xff;
  175.         ecc_code[2] = (nfm8ecc0 >> 16) & 0xff;
  176.         ecc_code[3] = (nfm8ecc0 >> 24) & 0xff;
  177.         ecc_code[4] = nfm8ecc1 & 0xff;
  178.         ecc_code[5] = (nfm8ecc1 >> 8) & 0xff;
  179.         ecc_code[6] = (nfm8ecc1 >> 16) & 0xff;
  180.         ecc_code[7] = (nfm8ecc1 >> 24) & 0xff;
  181.         ecc_code[8] = nfm8ecc2 & 0xff;
  182.         ecc_code[9] = (nfm8ecc2 >> 8) & 0xff;
  183.         ecc_code[10] = (nfm8ecc2 >> 16) & 0xff;
  184.         ecc_code[11] = (nfm8ecc2 >> 24) & 0xff;
  185.         ecc_code[12] = nfm8ecc3 & 0xff;
  186.     }

  187.     return 0;
  188. }

  189. int s3c_nand_correct_data_8bit(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc)
  190. {
  191.     int ret = -1;
  192.     u_long nf8eccerr0, nf8eccerr1, nf8eccerr2, nfmlc8bitpt0, nfmlc8bitpt1;
  193.     u_char err_type;

  194.     s3c_nand_wait_ecc_busy_8bit();

  195.     nf8eccerr0 = readl(NF8ECCERR0);
  196.     nf8eccerr1 = readl(NF8ECCERR1);
  197.     nf8eccerr2 = readl(NF8ECCERR2);
  198.     nfmlc8bitpt0 = readl(NFMLC8BITPT0);
  199.     nfmlc8bitpt1 = readl(NFMLC8BITPT1);

  200.     err_type = (nf8eccerr0 >> 25) & 0xf;

  201.     /* No error, If free page (all 0xff) */
  202.     if ((nf8eccerr0 >> 29) & 0x1)
  203.         err_type = 0;

  204.     switch (err_type)
  205.     {
  206.     case 8: /* 8 bit error (Correctable) */
  207.         dat[(nf8eccerr2 >> 22) & 0x3ff] ^= ((nfmlc8bitpt1 >> 24) & 0xff);
  208.         printk("s3c-nand: %d bit(s) error detected, corrected successfully\n", err_type);

  209.     case 7: /* 7 bit error (Correctable) */
  210.         dat[(nf8eccerr2 >> 11) & 0x3ff] ^= ((nfmlc8bitpt1 >> 16) & 0xff);
  211.         printk("s3c-nand: %d bit(s) error detected, corrected successfully\n", err_type);

  212.     case 6: /* 6 bit error (Correctable) */
  213.         dat[nf8eccerr2 & 0x3ff] ^= ((nfmlc8bitpt1 >> 8) & 0xff);
  214.         printk("s3c-nand: %d bit(s) error detected, corrected successfully\n", err_type);

  215.     case 5: /* 5 bit error (Correctable) */
  216.         dat[(nf8eccerr1 >> 22) & 0x3ff] ^= (nfmlc8bitpt1 & 0xff);
  217.         printk("s3c-nand: %d bit(s) error detected, corrected successfully\n", err_type);

  218.     case 4: /* 4 bit error (Correctable) */
  219.         dat[(nf8eccerr1 >> 11) & 0x3ff] ^= ((nfmlc8bitpt0 >> 24) & 0xff);
  220.         printk("s3c-nand: %d bit(s) error detected, corrected successfully\n", err_type);

  221.     case 3: /* 3 bit error (Correctable) */
  222.         dat[nf8eccerr1 & 0x3ff] ^= ((nfmlc8bitpt0 >> 16) & 0xff);
  223.         printk("s3c-nand: %d bit(s) error detected, corrected successfully\n", err_type);

  224.     case 2: /* 2 bit error (Correctable) */
  225.         dat[(nf8eccerr0 >> 15) & 0x3ff] ^= ((nfmlc8bitpt0 >> 8) & 0xff);
  226.         printk("s3c-nand: %d bit(s) error detected, corrected successfully\n", err_type);


  227.     case 1: /* 1 bit error (Correctable) */
  228.         printk("s3c-nand: %d bit(s) error detected, corrected successfully\n", err_type);
  229.         dat[nf8eccerr0 & 0x3ff] ^= (nfmlc8bitpt0 & 0xff);
  230.         ret = err_type;
  231.         break;

  232.     case 0: /* No error */
  233.         ret = 0;
  234.         break;

  235.     }

  236.     return ret;
  237. }

  238. void s3c_nand_write_page_8bit(struct mtd_info *mtd, struct nand_chip *chip,
  239.                               const uint8_t *buf)
  240. {
  241.     int i, eccsize = 512;
  242.     int eccbytes = 13;
  243.     int eccsteps = mtd->writesize / eccsize;
  244.     uint8_t *ecc_calc = chip->buffers->ecccalc;
  245.     uint8_t *p = buf;

  246.     for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
  247.         s3c_nand_enable_hwecc_8bit(mtd, NAND_ECC_WRITE);
  248.         chip->write_buf(mtd, p, eccsize);
  249.         s3c_nand_calculate_ecc_8bit(mtd, p, &ecc_calc[i]);
  250.     }

  251.     for (i = 0; i < eccbytes * (mtd->writesize / eccsize); i++)
  252.         chip->oob_poi[i+24] = ecc_calc[i];
  253.     chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
  254. }

  255. int s3c_nand_read_page_8bit(struct mtd_info *mtd, struct nand_chip *chip,
  256.                             uint8_t *buf)
  257. {
  258.     int i, stat, eccsize = 512;
  259.     int eccbytes = 13;
  260.     int eccsteps = mtd->writesize / eccsize;
  261.     int col = 0;
  262.     uint8_t *p = buf;

  263.     /* Step1: read whole oob */
  264.     col = mtd->writesize;
  265.     chip->cmdfunc(mtd, NAND_CMD_RNDOUT, col, -1);
  266.     chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);

  267.     col = 0;
  268.     for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
  269.         chip->cmdfunc(mtd, NAND_CMD_RNDOUT, col, -1);
  270.         s3c_nand_enable_hwecc_8bit(mtd, NAND_ECC_READ);
  271.         chip->read_buf(mtd, p, eccsize);
  272.         chip->write_buf(mtd, chip->oob_poi + 24 + (((mtd->writesize / eccsize) - eccsteps) * eccbytes), eccbytes);
  273.         s3c_nand_calculate_ecc_8bit(mtd, 0, 0);
  274.         stat = s3c_nand_correct_data_8bit(mtd, p, 0, 0);

  275.         if (stat == -1)
  276.             mtd->ecc_stats.failed++;

  277.         col = eccsize * ((mtd->writesize / eccsize) + 1 - eccsteps);
  278.     }

  279.     return 0;
  280. }

  281. /********************************************************/
  282. #endif

  283. static void s3c_nand_enable_hwecc(struct mtd_info *mtd, int mode)
  284. {
  285.     u_long nfcont, nfconf;

  286.     /*
  287.      * The original driver used 4-bit ECC for "new" MLC chips, i.e., for
  288.      * those with non-zero ID[3][3:2], which anyway only holds for ST
  289.      * (Numonyx) chips
  290.      */

  291.     nfconf = readl(NFCONF) & ~NFCONF_ECC_4BIT;
  292.     
  293.     writel(nfconf, NFCONF);

  294.     /* Initialize & unlock */
  295.     nfcont = readl(NFCONT);
  296.     nfcont |= NFCONT_INITECC;
  297.     nfcont &= ~NFCONT_MECCLOCK;

  298.     if (mode == NAND_ECC_WRITE)
  299.         nfcont |= NFCONT_ECC_ENC;
  300.     else if (mode == NAND_ECC_READ)
  301.         nfcont &= ~NFCONT_ECC_ENC;

  302.     writel(nfcont, NFCONT);
  303. }

  304. /*
  305.  * This function is called immediately after encoding ecc codes.
  306.  * This function returns encoded ecc codes.
  307.  * Written by jsgood
  308.  */
  309. static int s3c_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
  310.                  u_char *ecc_code)
  311. {
  312.     u_long nfcont, nfmecc0;
  313.     /* Lock */
  314.     nfcont = readl(NFCONT);
  315.     nfcont |= NFCONT_MECCLOCK;
  316.     writel(nfcont, NFCONT);

  317.     nfmecc0 = readl(NFMECC0);

  318.     ecc_code[0] = nfmecc0 & 0xff;
  319.     ecc_code[1] = (nfmecc0 >> 8) & 0xff;
  320.     ecc_code[2] = (nfmecc0 >> 16) & 0xff;
  321.     ecc_code[3] = (nfmecc0 >> 24) & 0xff;
  322.     
  323.     return 0;
  324. }

  325. /*
  326.  * This function determines whether read data is good or not.
  327.  * If SLC, must write ecc codes to controller before reading status bit.
  328.  * If MLC, status bit is already set, so only reading is needed.
  329.  * If status bit is good, return 0.
  330.  * If correctable errors occured, do that.
  331.  * If uncorrectable errors occured, return -1.
  332.  * Written by jsgood
  333.  */
  334. static int s3c_nand_correct_data(struct mtd_info *mtd, u_char *dat,
  335.                  u_char *read_ecc, u_char *calc_ecc)
  336. {
  337.     int ret = -1;
  338.     u_long nfestat0, nfmeccdata0, nfmeccdata1, err_byte_addr;
  339.     u_char err_type, repaired;

  340.     /* SLC: Write ecc to compare */
  341.     nfmeccdata0 = (calc_ecc[1] << 16) | calc_ecc[0];
  342.     nfmeccdata1 = (calc_ecc[3] << 16) | calc_ecc[2];
  343.     writel(nfmeccdata0, NFMECCDATA0);
  344.     writel(nfmeccdata1, NFMECCDATA1);

  345.     /* Read ecc status */
  346.     nfestat0 = readl(NFESTAT0);
  347.     err_type = nfestat0 & 0x3;

  348.     switch (err_type) {
  349.     case 0: /* No error */
  350.         ret = 0;
  351.         break;

  352.     case 1:
  353.         /*
  354.          * 1 bit error (Correctable)
  355.          * (nfestat0 >> 7) & 0x7ff    :error byte number
  356.          * (nfestat0 >> 4) & 0x7    :error bit number
  357.          */
  358.         err_byte_addr = (nfestat0 >> 7) & 0x7ff;
  359.         repaired = dat[err_byte_addr] ^ (1 << ((nfestat0 >> 4) & 0x7));

  360.         printf("S3C NAND: 1 bit error detected at byte %ld. "
  361.          "Correcting from 0x%02x to 0x%02x...OK\n",
  362.          err_byte_addr, dat[err_byte_addr], repaired);

  363.         dat[err_byte_addr] = repaired;

  364.         ret = 1;
  365.         break;

  366.     case 2: /* Multiple error */
  367.     case 3: /* ECC area error */
  368.         printf("S3C NAND: ECC uncorrectable error detected. "
  369.          "Not correctable.\n");
  370.         ret = -1;
  371.         break;
  372.     }

  373.     return ret;
  374. }
  375. #endif /* CONFIG_SYS_S3C_NAND_HWECC */

  376. /*
  377.  * Board-specific NAND initialization. The following members of the
  378.  * argument are board-specific (per include/linux/mtd/nand.h):
  379.  * - IO_ADDR_R?: address to read the 8 I/O lines of the flash device
  380.  * - IO_ADDR_W?: address to write the 8 I/O lines of the flash device
  381.  * - hwcontrol: hardwarespecific function for accesing control-lines
  382.  * - dev_ready: hardwarespecific function for accesing device ready/busy line
  383.  * - enable_hwecc?: function to enable (reset) hardware ecc generator. Must
  384.  * only be provided if a hardware ECC is available
  385.  * - eccmode: mode of ecc, see defines
  386.  * - chip_delay: chip dependent delay for transfering data from array to
  387.  * read regs (tR)
  388.  * - options: various chip options. They can partly be set to inform
  389.  * nand_scan about special functionality. See the defines for further
  390.  * explanation
  391.  * Members with a "?" were not set in the merged testing-NAND branch,
  392.  * so they are not set here either.
  393.  */
  394. int board_nand_init(struct nand_chip *nand)
  395. {
  396.     static int chip_n;

  397.     if (chip_n >= MAX_CHIPS)
  398.         return -ENODEV;

  399.     NFCONT_REG = (NFCONT_REG & ~NFCONT_WP) | NFCONT_ENABLE | 0x6;

  400.     nand->IO_ADDR_R        = (void __iomem *)NFDATA;
  401.     nand->IO_ADDR_W        = (void __iomem *)NFDATA;
  402.     nand->cmd_ctrl        = s3c_nand_hwcontrol;
  403.     nand->dev_ready        = s3c_nand_device_ready;
  404.     nand->select_chip    = s3c_nand_select_chip;
  405.     nand->options        = 0;
  406. #ifdef CONFIG_NAND_SPL
  407.     nand->read_byte        = nand_read_byte;
  408.     nand->write_buf        = nand_write_buf;
  409.     nand->read_buf        = nand_read_buf;
  410. #endif

  411. #ifdef CONFIG_SYS_S3C_NAND_HWECC
  412.     #ifdef CONFIG_NAND_BL1_8BIT_ECC
  413.     printf("USE HWECC 8BIT\n");//zxd
  414.     nand->ecc.hwctl        = s3c_nand_enable_hwecc_8bit;
  415.     nand->ecc.calculate    = s3c_nand_calculate_ecc_8bit;
  416.     nand->ecc.correct    = s3c_nand_correct_data_8bit;
  417.     nand->ecc.read_page = s3c_nand_read_page_8bit;
  418.     nand->ecc.write_page = s3c_nand_write_page_8bit;
  419.     #else
  420.     printf("USE HWECC Default\n");//zxd
  421.     nand->ecc.hwctl        = s3c_nand_enable_hwecc;
  422.     nand->ecc.calculate    = s3c_nand_calculate_ecc;
  423.     nand->ecc.correct    = s3c_nand_correct_data;
  424.     #endif
  425.     /*
  426.      * If you get more than 1 NAND-chip with different page-sizes on the
  427.      * board one day, it will get more complicated...
  428.      */
  429.     nand->ecc.mode        = NAND_ECC_HW;
  430.     nand->ecc.size        = CONFIG_SYS_NAND_ECCSIZE;
  431.     nand->ecc.bytes        = CONFIG_SYS_NAND_ECCBYTES;
  432.     printf("ECC Size:%d ECC Bytes:%d\n",nand->ecc.size,nand->ecc.bytes);//zxd    
  433. #else
  434.     nand->ecc.mode        = NAND_ECC_SOFT;
  435. #endif /* ! CONFIG_SYS_S3C_NAND_HWECC */

  436.     nand->priv        = nand_cs + chip_n++;

  437.     return 0;
  438. }

    修改common/cmd_nand.c文件,在662行的#endif之后、#ifdef CONFIG_CMD_NAND_YAFFS之前添加

点击(此处)折叠或打开

  1. } else if (!read && s != NULL && (!strcmp(s, ".uboot")) && nand->writesize == 4096) {
  2.                 rwsize=4096;
  3.                 nand_write(nand, off, &rwsize, (u_char *)addr);
  4.                 off+=4096;
  5.                 addr+=2048;
  6.                 nand_write(nand, off, &rwsize, (u_char *)addr);
  7.                 off+=4096;
  8.                 addr+=2048;
  9.                 nand_write(nand, off, &rwsize, (u_char *)addr);
  10.                 off+=4096;
  11.                 addr+=2048;
  12.                 nand_write(nand, off, &rwsize, (u_char *)addr);
  13.                 off+=4096;
  14.                 addr+=2048;
  15.                 rwsize= CONFIG_SYS_NAND_U_BOOT_SIZE - 8*1024;
  16.                 ret = nand_write(nand, off, &rwsize, (u_char *)addr);

    修改nand_spl/board/samsung/smdk6410/cinfig.mk,把PAD_TO := $(shell expr $$[$(CONFIG_SYS_TEXT_BASE) + 4096])
                改为PAD_TO := $(shell expr $CONFIG_SYS_TEXT_BASE) + 8192)


3.制作SD卡启动的u-boot.bin,修改include/configs/smdk6410.h,

点击(此处)折叠或打开

  1. #define CONFIG_SYS_MAPPED_RAM_BASE CONFIG_SYS_SDRAM_BASE
  2. #define CONFIG_BOOTCOMMAND "nand read 0x50018000 0x60000 0x1c0000;" \
  3.                             "bootm 0x50018000"
  4. #endif
    修改为

点击(此处)折叠或打开

  1. #define CONFIG_SYS_MAPPED_RAM_BASE CONFIG_SYS_SDRAM_BASE
  2. #ifdef CONFIG_BOOT_SD
  3. #define CONFIG_BOOTCOMMAND "fatload mmc 0 50008000 u-boot-nand.bin;" \
  4.                             "nand erase.chip;" \
  5.                             "nand write.uboot 50008000 0 0"
  6. #else
  7. #define CONFIG_BOOTCOMMAND "nand read 0x50008000 0x100000 0x500000;" \
  8.                             "bootm 50008000"
  9. #endif
  10. #endif
    把生成的u-boot.bin烧写到SD卡,这样开发板SD卡启动后会执行fatload mmc 0 50008000 u-boot-nand.bin;""nand erase.chip;" "nand write.uboot 50008000 0 0"三个命令


4.修改include/configs/smdk6410.h,注释掉#define CONFIG_BOOT_SD

    修改

点击(此处)折叠或打开

  1. #define CONFIG_SYS_NAND_U_BOOT_OFFS (16 * 1024) /* Offset to RAM U-Boot image */
  2. #define CONFIG_SYS_NAND_U_BOOT_SIZE (496 * 1024) /* Size of RAM U-Boot image */


    修改board/samsung/smdk6410/smdk6410_nand_spl.c,把relocate_code(CONFIG_SYS_TEXT_BASE -TOTAL_MALLOC_LEN, NULL,CONFIG_SYS_TEXT_BASE);修改为relocate_code(8*1024, NULL,CONFIG_SYS_TEXT_BASE);

    修改arch/arm/lib/crt0.S,在

点击(此处)折叠或打开

  1. #if defined(CONFIG_NAND_SPL)
  2. /* deprecated, use instead CONFIG_SPL_BUILD */
  3. ldr sp, =(CONFIG_SYS_INIT_SP_ADDR)
  4. 后面添加
  5. bss_clean:
  6. cmp r0,r1
  7. strlo r2,[r0]
  8. addlo r0,r0,#4
  9. blo bss_clean
  10. ldr pc,=nand_boot


5.制作NAND启动的u-boot-nand.bin,重新make all,把u-boot-nand.bin拷贝到刚刚烧写了u-boot.bin的SD卡中,SD卡启动开发板,自动将u-boot-nand.bin写入到nandflash中,结果如下

    
    再把开发板拨到nandflash启动,结果如下,开发板正常启动
     
阅读(2250) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~