os: improve fileenv u-boot (#148)

This commit is contained in:
Pascal Vizeli 2018-08-06 23:45:12 +02:00 committed by GitHub
parent 1dc2392f15
commit bbe4c47574
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
From f76279f1d01d107972e7d1dce2ebcdfa00544da9 Mon Sep 17 00:00:00 2001
From 57051bdfadcd27f405d05716c8d568b69fec575a Mon Sep 17 00:00:00 2001
From: Pascal Vizeli <pvizeli@syshack.ch>
Date: Sun, 5 Aug 2018 20:43:03 +0000
Subject: [PATCH 1/1] CMD: read string from fileinto env
@ -7,8 +7,8 @@ Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>
---
cmd/Kconfig | 5 +++++
cmd/Makefile | 1 +
cmd/fileenv.c | 30 ++++++++++++++++++++++++++++++
3 files changed, 36 insertions(+)
cmd/fileenv.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+)
create mode 100644 cmd/fileenv.c
diff --git a/cmd/Kconfig b/cmd/Kconfig
@ -41,10 +41,10 @@ index 323f1fd2c77..0d721dc5a72 100644
obj-$(CONFIG_CMD_SMC) += smccc.o
diff --git a/cmd/fileenv.c b/cmd/fileenv.c
new file mode 100644
index 00000000000..77699192f93
index 00000000000..ea7428723a5
--- /dev/null
+++ b/cmd/fileenv.c
@@ -0,0 +1,30 @@
@@ -0,0 +1,44 @@
+#include <config.h>
+#include <common.h>
+#include <command.h>
@ -66,6 +66,20 @@ index 00000000000..77699192f93
+ return 1;
+
+ char *addr = (char *)simple_strtoul(argv[3], NULL, 16);
+ size_t size = env_get_hex("filesize", 0);
+
+ // Prepare string
+ addr[size +1] = 0x00;
+ char *s = addr;
+ while(*s != 0x00) {
+ if (*s == 0x0a || *s == 0x0d) {
+ *s = 0x00;
+ }
+ else {
+ s++;
+ }
+ }
+
+ return env_set(argv[5], addr);
+}
+