Merge branch 'master' of github:OpenIPC/openipc-2.1

pull/33/head
Igor Zalatov (via Araneus server) 2021-07-08 18:41:38 +03:00
commit 1c7e30963b
1 changed files with 14 additions and 7 deletions
general/package/fwprintenv-ng

View File

@ -1,5 +1,5 @@
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 2a61a5d6f0..6398e29c38 100644 index 2a61a5d6f0..f2ed8e436d 100644
--- a/tools/env/fw_env.c --- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c +++ b/tools/env/fw_env.c
@@ -484,7 +484,8 @@ int fw_printenv(int argc, char *argv[], int value_only, struct env_opts *opts) @@ -484,7 +484,8 @@ int fw_printenv(int argc, char *argv[], int value_only, struct env_opts *opts)
@ -12,7 +12,7 @@ index 2a61a5d6f0..6398e29c38 100644
rc = -1; rc = -1;
continue; continue;
} }
@@ -1725,6 +1726,88 @@ static int check_device_config(int dev) @@ -1725,6 +1726,91 @@ static int check_device_config(int dev)
return rc; return rc;
} }
@ -21,7 +21,7 @@ index 2a61a5d6f0..6398e29c38 100644
+#define ENV_LEN 0x10000 +#define ENV_LEN 0x10000
+ +
+// Detect U-Boot environment area offset +// Detect U-Boot environment area offset
+int uboot_detect_env(void *buf, size_t len) { +static int uboot_detect_env(void *buf, size_t len) {
+ // Jump over memory by step + // Jump over memory by step
+ int scan_step = ENV_LEN; + int scan_step = ENV_LEN;
+ int res = -1; + int res = -1;
@ -38,7 +38,7 @@ index 2a61a5d6f0..6398e29c38 100644
+ return res; + return res;
+} +}
+ +
+char *open_mtdblock(int i, int *fd, uint32_t size, int flags) { +static char *open_mtdblock(int i, int *fd, uint32_t size, int flags) {
+ char filename[PATH_MAX]; + char filename[PATH_MAX];
+ +
+ snprintf(filename, sizeof filename, "/dev/mtdblock%d", i); + snprintf(filename, sizeof filename, "/dev/mtdblock%d", i);
@ -58,11 +58,12 @@ index 2a61a5d6f0..6398e29c38 100644
+} +}
+ +
+static char dev[80]; +static char dev[80];
+static void detect_env() { +static int detect_env() {
+ FILE *fp; + FILE *fp;
+ char name[80]; + char name[80];
+ int i, es, ee; + int i, es, ee;
+ struct mtd_info_user mtd; + struct mtd_info_user mtd;
+ int res = 0;
+ +
+ if ((fp = fopen("/proc/mtd", "r"))) { + if ((fp = fopen("/proc/mtd", "r"))) {
+ bool running = true; + bool running = true;
@ -88,6 +89,7 @@ index 2a61a5d6f0..6398e29c38 100644
+ ENVSIZE(0) = ENV_LEN; + ENVSIZE(0) = ENV_LEN;
+ DEVESIZE(0) = mtd.erasesize; + DEVESIZE(0) = mtd.erasesize;
+ ENVSECTORS(0) = 1; + ENVSECTORS(0) = 1;
+ res = 1;
+ break; + break;
+ } + }
+ } + }
@ -96,19 +98,24 @@ index 2a61a5d6f0..6398e29c38 100644
+ } + }
+ fclose(fp); + fclose(fp);
+ } + }
+ return res;
+} +}
+ +
static int parse_config(struct env_opts *opts) static int parse_config(struct env_opts *opts)
{ {
int rc; int rc;
@@ -1735,9 +1818,7 @@ static int parse_config(struct env_opts *opts) @@ -1735,9 +1821,11 @@ static int parse_config(struct env_opts *opts)
#if defined(CONFIG_FILE) #if defined(CONFIG_FILE)
/* Fills in DEVNAME(), ENVSIZE(), DEVESIZE(). Or don't. */ /* Fills in DEVNAME(), ENVSIZE(), DEVESIZE(). Or don't. */
if (get_config(opts->config_file)) { if (get_config(opts->config_file)) {
- fprintf(stderr, "Cannot parse config file '%s': %m\n", - fprintf(stderr, "Cannot parse config file '%s': %m\n",
- opts->config_file); - opts->config_file);
- return -1; - return -1;
+ detect_env(); + if (!detect_env()) {
+ fprintf(stderr, "Cannot parse config file '%s': %m\n",
+ opts->config_file);
+ return -1;
+ }
} }
#else #else
DEVNAME(0) = DEVICE1_NAME; DEVNAME(0) = DEVICE1_NAME;