U-Boot移植(14)解决saveenv不能保存环境变量

2023-08-28  

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: +++<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
#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     */

文章来源于:电子工程世界    原文链接
本站所有转载文章系出于传递更多信息之目的,且明确注明来源,不希望被转载的媒体或个人可与我们联系,我们将立即进行删除处理。