From 9d46d64dcdac88c934bb3e64c3732639572e3e8d Mon Sep 17 00:00:00 2001 From: John Klug Date: Tue, 11 Apr 2017 18:01:18 -0500 Subject: Start of deriving the environment from the u-boot package. --- .../multitech/u-boot-linux-utils/uboot_mac.patch | 55 +++++++++++++++------- 1 file changed, 39 insertions(+), 16 deletions(-) (limited to 'recipes-bsp/multitech/u-boot-linux-utils/uboot_mac.patch') diff --git a/recipes-bsp/multitech/u-boot-linux-utils/uboot_mac.patch b/recipes-bsp/multitech/u-boot-linux-utils/uboot_mac.patch index 5b92f35..77f28a2 100644 --- a/recipes-bsp/multitech/u-boot-linux-utils/uboot_mac.patch +++ b/recipes-bsp/multitech/u-boot-linux-utils/uboot_mac.patch @@ -1,27 +1,50 @@ -commit de3ea4470a6da4c01bfff9377649324747c1e3c9 +commit afa8fc0d0b3d8ccde464ab207724491c7b732c3d Author: John Klug -Date: Mon Apr 10 12:16:08 2017 -0500 +Date: Tue Apr 11 17:58:15 2017 -0500 - Add MAC address in default environment and add clearenv functionality. + Derive MTD size from CONFIG_ENV_SIZE diff --git a/src/u_boot.c b/src/u_boot.c -index e240475..7eea5e9 100644 +index e240475..8c4fced 100644 --- a/src/u_boot.c +++ b/src/u_boot.c -@@ -36,6 +36,12 @@ +@@ -33,8 +33,25 @@ + #include + #include +- ++#include #include "u_boot.h" - ++static char *env_strings(void) ++{ ++ char *p; ++ int count; ++ static const char *bd = "bootdelay="; ++ count = strlen(bd); ++ count += snprintf(NULL,0,"%d",CONFIG_BOOTDELAY); ++ p = malloc(count); ++ snprintf(p,count,"%d",CONFIG_BOOTDELAY); ++ return p; ++} ++ + +#define DUMMY_MAC "00:00:00:00:00:00" +#define MACNAME "ethaddr" + +#define EMPTY_CRC 0xf9137807 -+ + static int tokcmp(const char *cmd, const char *pattern) { int len = strlen(cmd); - if (len > strlen(pattern)) { -@@ -64,6 +70,8 @@ static int write_uboot_env(const char *device, struct environment *env) +@@ -46,7 +63,7 @@ static int tokcmp(const char *cmd, const char *pattern) { + } + + #define ENV_HEADER_SIZE (sizeof(uint32_t) + sizeof(uint8_t)) +-#define ENV_DATA_SIZE (MTD_SIZE - ENV_HEADER_SIZE) ++#define ENV_DATA_SIZE (CONFIG_ENV_SIZE - ENV_HEADER_SIZE) + + struct environment { + uint32_t crc; +@@ -64,6 +81,8 @@ static int write_uboot_env(const char *device, struct environment *env) error("mtd_erase_all %s failed", device); return -1; } @@ -30,7 +53,7 @@ index e240475..7eea5e9 100644 fd = open(device, O_WRONLY); if (fd < 0) { -@@ -166,7 +174,7 @@ static int cmd_setenv(struct environment *env, int argc, char **argv) +@@ -166,7 +185,7 @@ static int cmd_setenv(struct environment *env, int argc, char **argv) var = env->data; while (*var) { if (!strncmp(var, name, name_len) && var[name_len] == '=') { @@ -39,7 +62,7 @@ index e240475..7eea5e9 100644 cp = next_var(var); while (*cp) { -@@ -213,7 +221,7 @@ static int cmd_setenv(struct environment *env, int argc, char **argv) +@@ -213,7 +232,7 @@ static int cmd_setenv(struct environment *env, int argc, char **argv) } env->crc = crc32(0, (uint8_t *) env->data, sizeof(env->data)); @@ -48,7 +71,7 @@ index e240475..7eea5e9 100644 env->flags = 0; tmp = write_uboot_env(MTD_ENV1, env); -@@ -238,7 +246,7 @@ static void print_version(const char *name) { +@@ -238,7 +257,7 @@ static void print_version(const char *name) { } static void usage(FILE *out) { @@ -57,7 +80,7 @@ index e240475..7eea5e9 100644 fprintf(out, "\n"); } -@@ -252,6 +260,7 @@ int main(int argc, char *argv[]) { +@@ -252,6 +271,7 @@ int main(int argc, char *argv[]) { struct environment *env2; uint32_t crc1_ok; uint32_t crc2_ok; @@ -65,7 +88,7 @@ index e240475..7eea5e9 100644 if (argc <= 1) { usage(stderr); -@@ -301,12 +310,18 @@ int main(int argc, char *argv[]) { +@@ -301,12 +321,18 @@ int main(int argc, char *argv[]) { error("read_uboot_env failed"); return 1; } @@ -87,7 +110,7 @@ index e240475..7eea5e9 100644 crc1_ok = 0; } -@@ -315,20 +330,64 @@ int main(int argc, char *argv[]) { +@@ -315,20 +341,64 @@ int main(int argc, char *argv[]) { error("read_uboot_env failed"); return 1; } @@ -157,7 +180,7 @@ index e240475..7eea5e9 100644 } else if (crc1_ok && !crc2_ok) { env = env1; } else if (!crc1_ok && crc2_ok) { -@@ -353,6 +412,9 @@ int main(int argc, char *argv[]) { +@@ -353,6 +423,9 @@ int main(int argc, char *argv[]) { err = cmd_printenv(env, argc, argv); } else if (!tokcmp(cmd, "setenv")) { err = cmd_setenv(env, argc, argv); -- cgit v1.2.3