summaryrefslogtreecommitdiff
path: root/recipes-bsp/multitech/u-boot-linux-utils
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2017-04-12 13:00:14 -0500
committerJohn Klug <john.klug@multitech.com>2017-04-24 11:43:23 -0500
commitfd20f52b91a74efd6c5aaed8f10247c31af45dca (patch)
treed256de107ee008977fade3572677980b8b565bc6 /recipes-bsp/multitech/u-boot-linux-utils
parent12068cd37b9d722f0cecf546fe8bbacbe9abd497 (diff)
downloadmeta-multitech-atmel-fd20f52b91a74efd6c5aaed8f10247c31af45dca.tar.gz
meta-multitech-atmel-fd20f52b91a74efd6c5aaed8f10247c31af45dca.tar.bz2
meta-multitech-atmel-fd20f52b91a74efd6c5aaed8f10247c31af45dca.zip
Parameters for environment defaults now come mostly from u-boot header files
Diffstat (limited to 'recipes-bsp/multitech/u-boot-linux-utils')
-rw-r--r--recipes-bsp/multitech/u-boot-linux-utils/uboot_c.patch (renamed from recipes-bsp/multitech/u-boot-linux-utils/uboot_mac.patch)165
-rw-r--r--recipes-bsp/multitech/u-boot-linux-utils/uboot_configure.patch16
2 files changed, 134 insertions, 47 deletions
diff --git a/recipes-bsp/multitech/u-boot-linux-utils/uboot_mac.patch b/recipes-bsp/multitech/u-boot-linux-utils/uboot_c.patch
index 77f28a2..33374dd 100644
--- a/recipes-bsp/multitech/u-boot-linux-utils/uboot_mac.patch
+++ b/recipes-bsp/multitech/u-boot-linux-utils/uboot_c.patch
@@ -1,50 +1,44 @@
-commit afa8fc0d0b3d8ccde464ab207724491c7b732c3d
+commit 4099235d80474025bb86b75caddbb6c25f573d9b
Author: John Klug <john.klug@multitech.com>
-Date: Tue Apr 11 17:58:15 2017 -0500
+Date: Wed Apr 12 12:50:36 2017 -0500
- Derive MTD size from CONFIG_ENV_SIZE
+ Parameters for defaults come mostly from u-boot header files
diff --git a/src/u_boot.c b/src/u_boot.c
-index e240475..8c4fced 100644
+index e240475..9480471 100644
--- a/src/u_boot.c
+++ b/src/u_boot.c
-@@ -33,8 +33,25 @@
+@@ -33,8 +33,16 @@
#include <fcntl.h>
#include <zlib.h>
-
+#include <u-boot/config.h>
#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;
-+}
++#include "mtd_erase_all.h"
+
++#define XMK_STR(x) #x
++#define MK_STR(x) XMK_STR(x)
+
+#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);
-@@ -46,7 +63,7 @@ static int tokcmp(const char *cmd, const char *pattern) {
+@@ -46,8 +54,10 @@ 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)
++#define DO_WRITE_ENV 1
++#define SKIP_WRITE_ENV 0
struct environment {
uint32_t crc;
-@@ -64,6 +81,8 @@ static int write_uboot_env(const char *device, struct environment *env)
+ uint8_t flags;
+@@ -64,6 +74,8 @@ static int write_uboot_env(const char *device, struct environment *env)
error("mtd_erase_all %s failed", device);
return -1;
}
@@ -53,7 +47,16 @@ index e240475..8c4fced 100644
fd = open(device, O_WRONLY);
if (fd < 0) {
-@@ -166,7 +185,7 @@ static int cmd_setenv(struct environment *env, int argc, char **argv)
+@@ -144,7 +156,7 @@ static int cmd_printenv(struct environment *env, int argc, char **argv)
+ return true;
+ }
+
+-static int cmd_setenv(struct environment *env, int argc, char **argv)
++static int cmd_setenv(struct environment *env, int argc, char **argv, int do_write)
+ {
+ int tmp;
+ char *var;
+@@ -166,7 +178,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] == '=') {
@@ -62,7 +65,7 @@ index e240475..8c4fced 100644
cp = next_var(var);
while (*cp) {
-@@ -213,7 +232,7 @@ static int cmd_setenv(struct environment *env, int argc, char **argv)
+@@ -213,18 +225,19 @@ static int cmd_setenv(struct environment *env, int argc, char **argv)
}
env->crc = crc32(0, (uint8_t *) env->data, sizeof(env->data));
@@ -70,8 +73,28 @@ index e240475..8c4fced 100644
+ dbg("Calculated crc (to be stored): 0x%08X", env->crc);
env->flags = 0;
- tmp = write_uboot_env(MTD_ENV1, env);
-@@ -238,7 +257,7 @@ static void print_version(const char *name) {
+- tmp = write_uboot_env(MTD_ENV1, env);
+- if (tmp < 0) {
+- dbg("write_uboot_env %s failed with %d", MTD_ENV1, tmp);
+- }
+- tmp = write_uboot_env(MTD_ENV2, env);
+- if (tmp < 0) {
+- dbg("write_uboot_env %s failed with %d", MTD_ENV1, tmp);
++ if(do_write == DO_WRITE_ENV) {
++ tmp = write_uboot_env(MTD_ENV1, env);
++ if (tmp < 0) {
++ dbg("write_uboot_env %s failed with %d", MTD_ENV1, tmp);
++ }
++ tmp = write_uboot_env(MTD_ENV2, env);
++ if (tmp < 0) {
++ dbg("write_uboot_env %s failed with %d", MTD_ENV1, tmp);
++ }
+ }
+-
+ return true;
+ }
+
+@@ -238,7 +251,7 @@ static void print_version(const char *name) {
}
static void usage(FILE *out) {
@@ -80,7 +103,7 @@ index e240475..8c4fced 100644
fprintf(out, "\n");
}
-@@ -252,6 +271,7 @@ int main(int argc, char *argv[]) {
+@@ -252,6 +265,7 @@ int main(int argc, char *argv[]) {
struct environment *env2;
uint32_t crc1_ok;
uint32_t crc2_ok;
@@ -88,7 +111,7 @@ index e240475..8c4fced 100644
if (argc <= 1) {
usage(stderr);
-@@ -301,12 +321,18 @@ int main(int argc, char *argv[]) {
+@@ -301,12 +315,18 @@ int main(int argc, char *argv[]) {
error("read_uboot_env failed");
return 1;
}
@@ -110,7 +133,7 @@ index e240475..8c4fced 100644
crc1_ok = 0;
}
-@@ -315,20 +341,64 @@ int main(int argc, char *argv[]) {
+@@ -315,20 +335,130 @@ int main(int argc, char *argv[]) {
error("read_uboot_env failed");
return 1;
}
@@ -139,6 +162,8 @@ index e240475..8c4fced 100644
+ int mp_fd = open(MAC_PATH, O_RDONLY);
+ int len,retval;
+ char *p;
++ char *genarg[2];
++ char number[128];
+
+ fputs("WARNING: Flash is in initial state, so use defaults\n",stderr);
env = env1;
@@ -151,7 +176,7 @@ index e240475..8c4fced 100644
+ }
+
+ len = sizeof DUMMY_MAC - 1; /* remove null from count */
-+ p = malloc(len);
++ p = malloc(len+1);
+ retval = read(mp_fd,p,len);
+ dbg("Mac read of %d returned %d",len,retval);
+ if(retval != len) {
@@ -166,24 +191,90 @@ index e240475..8c4fced 100644
+ exit(1);
+ }
+ }
-+ len = sizeof(DEFAULT_ENV);
-+ memcpy(env->data + len - 1, MACNAME, sizeof MACNAME);
-+ len += sizeof MACNAME - 1;
-+ env->data[len-1] = '=';
-+ memcpy(env->data + len, p, sizeof DUMMY_MAC - 1);
-+ len += sizeof DUMMY_MAC;
-+ env->data[len-1] = 0;
-+ env->data[len] = 0;
++ p[len] = 0;
++ genarg[0] = "ethaddr";
++ genarg[1] = p;
++ if (cmd_setenv(env,2,genarg,SKIP_WRITE_ENV) == false)
++ exit(1);
++ free(p);
++ genarg[1] = number;
++
++#ifdef CONFIG_BAUDRATE
++ genarg[0] = "baudrate";
++ sprintf(number,"%lld",(long long)(CONFIG_BAUDRATE));
++ if (cmd_setenv(env,2,genarg,SKIP_WRITE_ENV) == false)
++ exit(1);
++#endif
++#ifdef CONFIG_BOOTDELAY
++ genarg[0] = "bootdelay";
++ sprintf(number,"%lld",(long long)(CONFIG_BOOTDELAY));
++ if (cmd_setenv(env,2,genarg,SKIP_WRITE_ENV) == false)
++ exit(1);
++#endif
++#ifdef CONFIG_LOADADDR
++ genarg[0] = "loadaddr";
++ sprintf(number,"0x%llx",(long long)(CONFIG_LOADADDR));
++ if (cmd_setenv(env,2,genarg,SKIP_WRITE_ENV) == false)
++ exit(1);
++#endif
++#ifdef CONFIG_HOSTNAME
++ genarg[0] = "hostname";
++ genarg[1] = MK_STR(CONFIG_HOSTNAME);
++ if (cmd_setenv(env,2,genarg,SKIP_WRITE_ENV) == false)
++ exit(1);
++#endif
++#ifdef CONFIG_IPADDR
++ genarg[0] = "ipaddr";
++ genarg[1] = MK_STR(CONFIG_IPADDR);
++ if (cmd_setenv(env,2,genarg,SKIP_WRITE_ENV) == false)
++ exit(1);
++#endif
++#ifdef CONFIG_SERVERIP
++ genarg[0] = "serverip";
++ genarg[1] = MK_STR(CONFIG_SERVERIP);
++ if (cmd_setenv(env,2,genarg,SKIP_WRITE_ENV) == false)
++ exit(1);
++#endif
++#ifdef CONFIG_NETMASK
++ genarg[0] = "netmask";
++ genarg[1] = MK_STR(CONFIG_NETMASK);
++ if (cmd_setenv(env,2,genarg,SKIP_WRITE_ENV) == false)
++ exit(1);
++#endif
++#ifdef CONFIG_EXTRA_ENV_SETTINGS
++ p = env->data;
++ while((p = next_var(p)) && *p);
++ len = (p - env->data);
++ if (len + sizeof CONFIG_EXTRA_ENV_SETTINGS < ENV_DATA_SIZE)
++ memcpy(env->data + len,CONFIG_EXTRA_ENV_SETTINGS,sizeof CONFIG_EXTRA_ENV_SETTINGS);
++ else
++ fprintf(stderr,"Default memory settings overflow. Current size %d, CONFIG_EXTRA_ENV_SETTINGS size %d, Maximum %d\n",
++ len,sizeof CONFIG_EXTRA_ENV_SETTINGS,ENV_DATA_SIZE);
++#endif
++#ifdef CONFIG_BOOTARGS
++ genarg[0] = "bootargs";
++ genarg[1] = CONFIG_BOOTARGS;
++ if (cmd_setenv(env,2,genarg,SKIP_WRITE_ENV) == false)
++ exit(1);
++#endif
++#ifdef CONFIG_BOOTCOMMAND
++ genarg[0] = "bootcmd";
++ genarg[1] = CONFIG_BOOTCOMMAND;
++ if (cmd_setenv(env,2,genarg,SKIP_WRITE_ENV) == false)
++ exit(1);
++#endif
+ } else if (!crc1_ok && !crc2_ok) {
+ error("both environments are bad: not loading DEFAULT_ENV");
+ exit(1);
} else if (crc1_ok && !crc2_ok) {
env = env1;
} else if (!crc1_ok && crc2_ok) {
-@@ -353,6 +423,9 @@ int main(int argc, char *argv[]) {
+@@ -352,7 +482,10 @@ int main(int argc, char *argv[]) {
+ if (!tokcmp(cmd, "printenv")) {
err = cmd_printenv(env, argc, argv);
} else if (!tokcmp(cmd, "setenv")) {
- err = cmd_setenv(env, argc, argv);
+- err = cmd_setenv(env, argc, argv);
++ err = cmd_setenv(env, argc, argv, DO_WRITE_ENV);
+ } else if (!tokcmp(cmd, "clearenv")) {
+ (void)write_uboot_env(MTD_ENV1, NULL);
+ (void)write_uboot_env(MTD_ENV2, NULL);
diff --git a/recipes-bsp/multitech/u-boot-linux-utils/uboot_configure.patch b/recipes-bsp/multitech/u-boot-linux-utils/uboot_configure.patch
index d8f5223..eb650a0 100644
--- a/recipes-bsp/multitech/u-boot-linux-utils/uboot_configure.patch
+++ b/recipes-bsp/multitech/u-boot-linux-utils/uboot_configure.patch
@@ -1,19 +1,15 @@
-commit 591d0dab81465e5e0df5b5ba6b70e2ec74f25bbc
+commit cc5abf5a1ed0f0cc5487e8f87b8cf69c6b8173ea
Author: John Klug <john.klug@multitech.com>
-Date: Tue Apr 11 17:35:38 2017 -0500
+Date: Wed Apr 12 12:31:28 2017 -0500
- Allow a DEFAULT ENV file, and get the MTD_SIZE from CONFIG_ENV_SIZE in uboot
+ Remove debug
diff --git a/configure.in b/configure.in
-index 8fdc9ef..8f6a1db 100644
+index 8fdc9ef..0377375 100644
--- a/configure.in
+++ b/configure.in
-@@ -15,12 +15,15 @@ required header missing]))
-
- AC_CHECK_LIB([z], [crc32], [], AC_MSG_ERROR([libz is required]))
-
--AC_DEFINE([DEBUG], 0, [set to 1 to enable debug])
-+AC_DEFINE([DEBUG], 1, [set to 1 to enable debug])
+@@ -18,9 +18,12 @@ AC_CHECK_LIB([z], [crc32], [], AC_MSG_ERROR([libz is required]))
+ AC_DEFINE([DEBUG], 0, [set to 1 to enable debug])
AC_DEFINE([MTD_ENV1], "/dev/mtd3", [set to the first u-boot env mtd])
AC_DEFINE([MTD_ENV2], "/dev/mtd4", [set to the second (redundant) u-boot env mtd])
-AC_DEFINE([MTD_SIZE], 0x20000, [size of u-boot env mtd])