• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
一蓑烟雨
C/C++,Linux,语音技术
博客园    首页    新随笔    联系   管理    订阅  订阅
U-Boot移植(14)解决saveenv不能保存环境变量

1、没修改之前,u-boot.bin烧入板中,在dnw终端显示操作如下:

U-Boot 1.1.6 (Nov 25 2009 - 22:15:51)
DRAM:  64 MB Flash:  1 MB NAND:  64 MiB *** Warning - bad CRC, using default environment
In:    serial Out:   serial Err:   serial UPLLVal [M:28h,P:1h,S:2h] MPLLVal [M:5ch,P:4h,S:0h] CLKDIVN:3h
+---------------------------------------------+ | S3C2440A USB Downloader ver R0.03 2004 Jan  | +---------------------------------------------+ USB: IN_ENDPOINT:1 OUT_ENDPOINT:3 FORMAT: <ADDR(DATA):4>+<SIZE(n+10):4>+<DATA:n>+<CS:2> NOTE: Power off/on or press the reset button for 1 sec       in order to get a valid USB device address.
Hit any key to stop autoboot:  0 Booting Linux ...
NAND read: device 0 offset 0x0, size 0x200000
reading NAND page at offset 0x0 failed Could not read entire image due to bad blocks 2097152 bytes read: ERROR ## Booting image at 32000000 ... Bad Magic Number
##### 100ask Bootloader for OpenJTAG ##### Download u-boot [k] Download Linux kernel [j] Download JFFS2 image [y] Download YAFFS image [d] Download to SDRAM & Run Boot the system [f] Format the Nand Flash [s] Set the boot parameters

­­­ Reboot u-boot [q] Quit from menu Enter your selection:

在上面输入q后,再输入saveenv、reset保存不了变量。。。。

可能是没把新的环境变量保存到nandflash,由于我的ylp2410没有norflash。所以不修改100ask24x0.h,就是默认把它保存到norflash中,这个也是在事后修改程序后才发觉的。修改100ask24x0.h如下:

#ifndef __CONFIG_H #define __CONFIG_H
/* * High Level Configuration Options * (easy to change) */

 #define CONFIG_ARM920T          1       /* This is an ARM920T Core      */

#define CONFIG_S3C2410          1       /* in a SAMSUNG S3C2410 SoC     */

#define CONFIG_SMDK2410         1       /* on a SAMSUNG SMDK2410 Board  */

/* input clock of PLL */

#define CONFIG_SYS_CLK_FREQ     12000000/* the SMDK2410 has 12MHz input clock */
#define USE_920T_MMU            1
#define CONFIG_USB_DEVICE   1
#ifdef CONFIG_USB_DEVICE

#define CONFIG_USE_IRQ          1

#endif
#define CONFIG_JFFS2_CMDLINE 1

#define CONFIG_JFFS2_NAND    1
#define MTDIDS_DEFAULT "nand0=nandflash0"

#define MTDPARTS_DEFAULT "mtdparts=nandflash0:2m@0(kernel)," \                            

 "8m(jffs2)," \                            

"-(yaffs)"

/*

* Size of malloc() pool

 */

 #define CFG_MALLOC_LEN          (CFG_ENV_SIZE + 128*1024)

#define CFG_GBL_DATA_SIZE       128     /* size in bytes reserved for initial data */
/* * Hardware drivers */

#if 0

#define CONFIG_DRIVER_CS8900    1     

  /* we have a CS8900 on-board */

 #define CS8900_BASE             0x19000300

#define CS8900_BUS16            1

/* the Linux driver does accesses as shorts */

#endif
#if !defined(CONFIG_DRIVER_CS8900)

#define CONFIG_DRIVER_DM9000            1

#define CONFIG_DM9000_USE_16BIT         1

#define CONFIG_DM9000_BASE                      0x20000000

#define DM9000_IO                                       0x20000000 

#define DM9000_DATA                                     0x20000004

#endif
/* * select serial console configuration */

#define CONFIG_SERIAL1          1       /* we use SERIAL 1 on SMDK2410 */
/************************************************************ * RTC ************************************************************/

#define CONFIG_RTC_S3C24X0      1
/* allow to overwrite serial and ethaddr */

#define CONFIG_ENV_OVERWRITE
#define CONFIG_BAUDRATE         115200
/* for tag(s) to transfer message to kernel, www.100ask.net */

#define CONFIG_SETUP_MEMORY_TAGS    1

#define CONFIG_CMDLINE_TAG          1
/*********************************************************** * Command definition ***********************************************************/

#define CONFIG_COMMANDS \                        

 ((CONFIG_CMD_DFL | \                        

CFG_CMD_CACHE    | \                    

/* Start: by www.100ask.net */ \                        

/* CFG_CMD_PING     | */ \                        

 CFG_CMD_JFFS2    | \                        

CFG_CMD_NAND     | \                    

/* End: by www.100ask.net */ \                        

 /*CFG_CMD_EEPROM |*/ \                        

/*CFG_CMD_I2C    |*/ \                        

 /*CFG_CMD_USB    |*/ \                        

CFG_CMD_REGINFO  | \                        

CFG_CMD_DATE     | \                        

CFG_CMD_ELF))
/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */

#include <cmd_confdefs.h>
#define CONFIG_BOOTDELAY        3

#define CONFIG_BOOTARGS         "noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0"

#define CONFIG_ETHADDR      08:00:3e:26:0a:5b #define CONFIG_NETMASK      255.255.255.0

#define CONFIG_IPADDR           192.168.7.17

#define CONFIG_SERVERIP         192.168.7.11 /*

#define CONFIG_BOOTFILE       "elinos-lart" */

#define CONFIG_BOOTCOMMAND      "nand read.jffs2 0x32000000 kernel; bootm 0x32000000"
#if (CONFIG_COMMANDS & CFG_CMD_KGDB) #define CONFIG_KGDB_BAUDRATE    115200          /* speed to run kgdb serial port */

 /* what's this ? it's not used anywhere */  

#define CONFIG_KGDB_SER_INDEX   1               /* which serial port to use */

#endif
/*

* Miscellaneous configurable options

 */

#define CFG_LONGHELP                            /* undef to save memory         */

#define CFG_PROMPT              "OpenJTAG> "    /* Monitor Command Prompt       */

#define CFG_CBSIZE              256             /* Console I/O Buffer Size      */

#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */

#define CFG_MAXARGS             16              /* max number of command args   */

#define CFG_BARGSIZE            CFG_CBSIZE      /* Boot Argument Buffer Size    */
#define CFG_MEMTEST_START       0x30000000      /* memtest works on     */

#define CFG_MEMTEST_END         0x33F00000      /* 63 MB in DRAM        */
#undef  CFG_CLKS_IN_HZ          /* everything, incl board info, in Hz */

#define CFG_LOAD_ADDR           0x33000000      /* default load address */
/* the PWM TImer 4 uses a counter of 15625 for 10 ms, so we need */

/* it to wrap 100 times (total 1562500) to get 1 sec. */

#define CFG_HZ                  1562500
/* valid baudrates */ #define CFG_BAUDRATE_TABLE      { 9600, 19200, 38400, 57600, 115200 }
/*----------------------------------------------------------------------- * Stack sizes * * The stack sizes are set up in start.S using the settings below */

#define CONFIG_STACKSIZE        (128*1024)      /* regular stack */

#ifdef CONFIG_USE_IRQ

#define CONFIG_STACKSIZE_IRQ    (4*1024)        /* IRQ stack */

#define CONFIG_STACKSIZE_FIQ    (4*1024)        /* FIQ stack */

#endif
/*----------------------------------------------------------------------- * Physical Memory Map */ #define CONFIG_NR_DRAM_BANKS    1          /* we have 1 bank of DRAM */

#define PHYS_SDRAM_1            0x30000000 /* SDRAM Bank #1 */

#define PHYS_SDRAM_1_SIZE       0x04000000 /* 64 MB */
#define PHYS_FLASH_1            0x00000000 /* Flash Bank #1 */
#define CFG_FLASH_BASE          PHYS_FLASH_1
//#define CONFIG_SURPORT_WINCE    1
/*----------------------------------------------------------------------- * FLASH and environment organization */
#if 0

#define CONFIG_AMD_LV400        1       /* uncomment this if you have a LV400 flash */

#endif

#define CONFIG_AMD_LV800        1       /* uncomment this if you have a LV800 flash */
#define CFG_MAX_FLASH_BANKS     1       /* max number of memory banks */   

#ifdef CONFIG_AMD_LV800

#define PHYS_FLASH_SIZE         0x00100000 /* 1MB */

#define CFG_MAX_FLASH_SECT      (19)    /* max number of sectors on one chip */

#define CFG_ENV_ADDR            (CFG_FLASH_BASE + 0x0F0000) /* addr of environment */

#endif

#ifdef CONFIG_AMD_LV400

 #define PHYS_FLASH_SIZE         0x00080000 /* 512KB */

#define CFG_MAX_FLASH_SECT      (11)    /* max number of sectors on one chip */

#define CFG_ENV_ADDR            (CFG_FLASH_BASE + 0x070000) /* addr of environment */

#endif
/* timeout values are in ticks */

#define CFG_FLASH_ERASE_TOUT    (5*CFG_HZ) /* Timeout for Flash Erase */

#define CFG_FLASH_WRITE_TOUT    (5*CFG_HZ) /* Timeout for Flash Write */
#define CFG_ENV_IS_IN_FLASH     1          /*enviroment is in the norflash*/

//#define CFG_ENV_IS_IN_NAND  1           /*enviroment is in the nandflash*/这里为修改的。。

改为:

//#define CFG_ENV_IS_IN_FLASH     1          /*enviroment is in the norflash*/

#define CFG_ENV_IS_IN_NAND  1

#define CFG_ENV_OFFSET      0x40000

#define CFG_ENV_SIZE            0x10000              /* Total Size of Environment Sector */
/*----------------------------------------------------------------------- * NAND flash settings */

#define CFG_NAND_BASE           0

#define CFG_MAX_NAND_DEVICE     1

#define NAND_MAX_CHIPS          1
#endif  /* __CONFIG_H */ ~

修改完再生成u-boot.bin再烧入板中,在dnw下观察信息,竟然第一次的warning都没有,有点不可思议。

直接是下面的信息。

U-Boot 1.1.6 (Nov 29 2009 - 15:05:35)

 

DRAM: 64 MB

Flash: 1 MB

NAND: 64 MiB

In:   serial

Out:   serial

Err:   serial

UPLLVal [M:28h,P:1h,S:2h]

MPLLVal [M:5ch,P:4h,S:0h]

CLKDIVN:3h


 

+---------------------------------------------+

| S3C2440A USB Downloader ver R0.03 2004 Jan  |

+---------------------------------------------+

USB: IN_ENDPOINT:1 OUT_ENDPOINT:3

FORMAT: <ADDR(DATA):4>+<SIZE(n+10):4>+<DATA:n>+<CS:2>

 

NOTE: Power off/on or press the reset button for 1 sec

 

      in order to get a valid USB device address.

 

Hit any key to stop autoboot:  0

Booting Linux ...


 

NAND read: device 0 offset 0x60000, size 0x200000


 

Reading data from 0x60000 --   0ete.

Reading data from 0x65000 --   1ete.

Reading data from 0x6a200 --   2ete.

Reading data from 0x6f400 --   3ete.

Reading data from 0x74600 --   4ete.

Reading data from 0x79800 --   5ete.

Reading data from 0x7ea00 --   6ete.

Reading data from 0x83c00 --   7ete.

Reading data from 0x88e00 --   8ete.

Reading data from 0x8e000 --   9ete.

Reading data from 0x93200 --  10ete.

Reading data from 0x98400 --  11ete.

Reading data from 0x9d600 --  12ete.

Reading data from 0xa2800 --  13ete.

Reading data from 0xa7a00 --  14ete.

Reading data from 0xacc00 --  15ete.

Reading data from 0xb1e00 --  16ete.

Reading data from 0xb7000 --  17ete.

Reading data from 0xbc200 --  18ete.

Reading data from 0xc1400 --  19ete.

Reading data from 0xc6600 --  20ete.

Reading data from 0xcb800 --  21ete.

Reading data from 0xd0a00 --  22ete.

Reading data from 0xd5c00 --  23ete.

Reading data from 0xdae00 --  24ete.

Reading data from 0xdfe00 --  25ete.

Reading data from 0xe5000 --  26

Reading data from 0xea200 --  27ete.

Reading data from 0xef400 --  28ete.

Reading data from 0xf4600 --  29ete.

Reading data from 0xf9800 --  30ete.

Reading data from 0xfea00 --  31

Reading data from 0x103c00 --  32lete.

Reading data from 0x108e00 --  33lete.

Reading data from 0x10e000 --  34lete.

Reading data from 0x113200 --  35lete.

Reading data from 0x118400 --  36lete.

Reading data from 0x11d600 --  37lete.

Reading data from 0x122800 --  38lete.

Reading data from 0x127a00 --  39lete.

Reading data from 0x12cc00 --  40lete.

Reading data from 0x131e00 --  41lete.

Reading data from 0x137000 --  42lete.

Reading data from 0x13c200 --  43lete.

Reading data from 0x141400 --  44

Reading data from 0x146600 --  45lete.

Reading data from 0x14b800 --  46lete.

Reading data from 0x150a00 --  47lete.

Reading data from 0x155c00 --  48lete.

Reading data from 0x15ae00 --  49

Reading data from 0x15fe00 --  50lete.

Reading data from 0x165000 --  51

Reading data from 0x16a200 --  52lete.

Reading data from 0x16f400 --  53lete.

Reading data from 0x174600 --  54lete.

Reading data from 0x179800 --  55lete.

Reading data from 0x17ea00 --  56lete.

Reading data from 0x183c00 --  57

Reading data from 0x188e00 --  58lete.

Reading data from 0x18e000 --  59lete.

Reading data from 0x193200 --  60lete.

Reading data from 0x198400 --  61

Reading data from 0x19d600 --  62lete.

Reading data from 0x1a2800 --  63lete.

Reading data from 0x1a7a00 --  64lete.

Reading data from 0x1acc00 --  65lete.

Reading data from 0x1b1e00 --  66lete.

Reading data from 0x1b7000 --  67lete.

Reading data from 0x1bc200 --  68

Reading data from 0x1c1400 --  69lete.

Reading data from 0x1c6600 --  70lete.

Reading data from 0x1cb800 --  71lete.

Reading data from 0x1d0a00 --  72lete.

Reading data from 0x1d5c00 --  73lete.

Reading data from 0x1dae00 --  74lete.

Reading data from 0x1dfe00 --  75

Reading data from 0x1e5000 --  76lete.

Reading data from 0x1ea200 --  77lete.

Reading data from 0x1ef400 --  78lete.

Reading data from 0x1f4600 --  79lete.

Reading data from 0x1f9800 --  80lete.

Reading data from 0x1fea00 --  81lete.

Reading data from 0x203c00 --  82lete.

Reading data from 0x208e00 --  83

Reading data from 0x20e000 --  84lete.

Reading data from 0x213200 --  85lete.

Reading data from 0x218400 --  86lete.

Reading data from 0x21d600 --  87

Reading data from 0x222800 --  88lete.

Reading data from 0x227a00 --  89lete.

Reading data from 0x22cc00 --  90lete.

Reading data from 0x231e00 --  91lete.

Reading data from 0x237000 --  92lete.

Reading data from 0x23c200 --  93lete.

Reading data from 0x241400 --  94lete.

Reading data from 0x246600 --  95lete.

Reading data from 0x24b800 --  96

Reading data from 0x250a00 --  97lete.

Reading data from 0x255c00 --  98lete.

Reading data from 0x25ae00 --  99lete.

Reading data from 0x25fe00 -- 1002097152 bytes read: OK

## Booting image at 30007fc0 ...

Bad Magic Number


 

##### 100ask Bootloader for OpenJTAG #####

[u] Download u-boot

[k] Download Linux kernel

[j] Download JFFS2 image

[y] Download YAFFS image

[d] Download to SDRAM & Run

[b] Boot the system

[f] Format the Nand Flash

[s] Set the boot parameters

Reboot u-boot

[q] Quit from menu

Enter your selection:

posted on 2011-07-14 15:41  lovemu  阅读(4412)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3