#include <onenand_uboot.h>
#endif
+DECLARE_GLOBAL_DATA_PTR;
+
/* special size referring to all the remaining space in a partition */
#define SIZE_REMAINING 0xFFFFFFFF
const char *p = mtdparts;
struct mtd_device *dev;
int err = 1;
+ char tmp_parts[MTDPARTS_MAXLEN];
debug("\n---parse_mtdparts---\nmtdparts = %s\n\n", p);
}
/* re-read 'mtdparts' variable, mtd_devices_init may be updating env */
- p = getenv("mtdparts");
+ if (gd->flags & GD_FLG_ENV_READY) {
+ p = getenv("mtdparts");
+ } else {
+ p = tmp_parts;
+ getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN);
+ }
if (strncmp(p, "mtdparts=", 9) != 0) {
printf("mtdparts variable doesn't start with 'mtdparts='\n");
const char *current_partition;
int ids_changed;
char tmp_ep[PARTITION_MAXLEN];
+ char tmp_parts[MTDPARTS_MAXLEN];
debug("\n---mtdparts_init---\n");
if (!initialized) {
/* get variables */
ids = getenv("mtdids");
- parts = getenv("mtdparts");
+ /*
+ * The mtdparts variable tends to be long. If we need to access it
+ * before the env is relocated, then we need to use our own stack
+ * buffer. gd->env_buf will be too small.
+ */
+ if (gd->flags & GD_FLG_ENV_READY) {
+ parts = getenv("mtdparts");
+ } else {
+ parts = tmp_parts;
+ getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN);
+ }
current_partition = getenv("partition");
/* save it for later parsing, cannot rely on current partition pointer
{
const char * const argv[4] = { "setenv", varname, varvalue, NULL };
+ /* before import into hashtable */
+ if (!(gd->flags & GD_FLG_ENV_READY))
+ return 1;
+
if (varvalue == NULL || varvalue[0] == '\0')
return _do_env_set(0, 2, (char * const *)argv);
else