Commit 1849bb73 authored by Sergei Poselenov's avatar Sergei Poselenov

RT #100047. Bugfixes of the fw_env tool:

 - Favor board configuration values for default environment
 - fixed compilation warnings
parent d4e1b2c6
......@@ -43,9 +43,9 @@
# include <mtd/mtd-user.h>
#endif
#include "fw_env.h"
#include <config.h>
#include "fw_env.h"
#define WHITESPACE(c) ((c == '\t') || (c == ' '))
......@@ -81,7 +81,9 @@ static int dev_current;
#define ENVSECTORS(i) envdevices[(i)].env_sectors
#define DEVTYPE(i) envdevices[(i)].mtd_type
#ifndef CONFIG_ENV_SIZE
#define CONFIG_ENV_SIZE ENVSIZE(dev_current)
#endif
#define ENV_SIZE getenvsize()
......@@ -212,6 +214,7 @@ static char default_environment[] = {
static int flash_io (int mode);
static char *envmatch (char * s1, char * s2);
static int parse_config (void);
static int fw_env_open(void);
#if defined(CONFIG_FILE)
static int get_config (char *);
......@@ -1073,7 +1076,7 @@ static char *envmatch (char * s1, char * s2)
/*
* Prevent confusion if running from erased flash memory
*/
int fw_env_open(void)
static int fw_env_open(void)
{
int crc0, crc0_ok;
unsigned char flag0;
......@@ -1092,7 +1095,7 @@ int fw_env_open(void)
addr0 = calloc (1, CONFIG_ENV_SIZE);
if (addr0 == NULL) {
fprintf (stderr,
"Not enough memory for environment (%ld bytes)\n",
"Not enough memory for environment (%d bytes)\n",
CONFIG_ENV_SIZE);
return -1;
}
......@@ -1131,7 +1134,7 @@ int fw_env_open(void)
addr1 = calloc (1, CONFIG_ENV_SIZE);
if (addr1 == NULL) {
fprintf (stderr,
"Not enough memory for environment (%ld bytes)\n",
"Not enough memory for environment (%d bytes)\n",
CONFIG_ENV_SIZE);
return -1;
}
......
......@@ -4,8 +4,8 @@
# Notice, that the "Number of sectors" is ignored on NOR.
# MTD device name Device offset Env. size Flash sector size Number of sectors
/dev/mtd1 0x0000 0x4000 0x4000
/dev/mtd2 0x0000 0x4000 0x4000
/dev/mtd0 0x0000 0x1000 0x10000
# NAND example
#/dev/mtd0 0x4000 0x4000 0x20000 2
......@@ -39,16 +39,23 @@
#define ENV2_SIZE 0x4000
#define DEVICE2_ESIZE 0x4000
#ifndef CONFIG_BAUDRATE
#define CONFIG_BAUDRATE 115200
#endif
#ifndef CONFIG_BOOTDELAY
#define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */
#endif
#ifndef CONFIG_BOOTCOMMAND
#define CONFIG_BOOTCOMMAND \
"bootp; " \
"setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} " \
"ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; " \
"bootm"
#endif
extern int fw_printenv(int argc, char *argv[]);
extern char *fw_getenv (char *name);
extern int fw_setenv (int argc, char *argv[]);
extern int fw_parse_script(char *fname);
extern unsigned long crc32 (unsigned long, const unsigned char *, unsigned);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment