u-boot-fw-utils: add patch with minimal U-Boot environment API
Implements functions to get and set variables from U-Boot's environment. https://jira.digi.com/browse/DEL-3358 Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
parent
3e8887da53
commit
f787a22ef1
|
|
@ -0,0 +1,146 @@
|
|||
From: Javier Viguera <javier.viguera@digi.com>
|
||||
Date: Tue, 10 Jan 2017 19:34:26 +0100
|
||||
Subject: [PATCH] Implement U-Boot environment access functions
|
||||
|
||||
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
|
||||
---
|
||||
tools/env/Makefile | 2 +-
|
||||
tools/env/ubootenv.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
tools/env/ubootenv.h | 46 ++++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 109 insertions(+), 1 deletion(-)
|
||||
create mode 100644 tools/env/ubootenv.c
|
||||
create mode 100644 tools/env/ubootenv.h
|
||||
|
||||
diff --git a/tools/env/Makefile b/tools/env/Makefile
|
||||
index fa2a564bb357..b29dcea16fe8 100644
|
||||
--- a/tools/env/Makefile
|
||||
+++ b/tools/env/Makefile
|
||||
@@ -25,7 +25,7 @@ hostprogs-y := fw_printenv
|
||||
|
||||
lib-y += fw_env.o \
|
||||
crc32.o ctype.o linux_string.o \
|
||||
- env_attr.o env_flags.o aes.o ../../lib/md5.o
|
||||
+ env_attr.o env_flags.o aes.o ../../lib/md5.o ubootenv.o
|
||||
|
||||
fw_printenv-objs := fw_env_main.o $(lib-y)
|
||||
|
||||
diff --git a/tools/env/ubootenv.c b/tools/env/ubootenv.c
|
||||
new file mode 100644
|
||||
index 000000000000..db789a55adaa
|
||||
--- /dev/null
|
||||
+++ b/tools/env/ubootenv.c
|
||||
@@ -0,0 +1,62 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2017, Digi International Inc.
|
||||
+ *
|
||||
+ * This Source Code Form is subject to the terms of the Mozilla Public
|
||||
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
+ * file, you can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
+ *
|
||||
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
+ *
|
||||
+ * Description: U-Boot environment get/set wrappers
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+
|
||||
+#include "fw_env.h"
|
||||
+
|
||||
+/*
|
||||
+ * Function: uboot_getenv
|
||||
+ * Description: get U-Boot's environment variable
|
||||
+ */
|
||||
+int uboot_getenv(char *name, const char **value)
|
||||
+{
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ ret = fw_env_open();
|
||||
+ if (ret)
|
||||
+ goto err;
|
||||
+
|
||||
+ *value = fw_getenv(name);
|
||||
+
|
||||
+err:
|
||||
+ return ret ? -1 : 0;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Function: uboot_setenv
|
||||
+ * Description: set U-Boot's environment variable
|
||||
+ */
|
||||
+int uboot_setenv(char *name, char *value)
|
||||
+{
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ ret = fw_env_open();
|
||||
+ if (ret)
|
||||
+ goto err;
|
||||
+
|
||||
+ ret = fw_env_write(name, value);
|
||||
+ if (ret)
|
||||
+ goto err;
|
||||
+
|
||||
+ ret = fw_env_close();
|
||||
+
|
||||
+err:
|
||||
+ return ret ? -1 : 0;
|
||||
+}
|
||||
diff --git a/tools/env/ubootenv.h b/tools/env/ubootenv.h
|
||||
new file mode 100644
|
||||
index 000000000000..d4043db75372
|
||||
--- /dev/null
|
||||
+++ b/tools/env/ubootenv.h
|
||||
@@ -0,0 +1,46 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2017, Digi International Inc.
|
||||
+ *
|
||||
+ * This Source Code Form is subject to the terms of the Mozilla Public
|
||||
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
+ * file, you can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
+ *
|
||||
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
+ *
|
||||
+ * Description: U-Boot environment get/set wrappers
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#ifndef UBOOTENV_H
|
||||
+#define UBOOTENV_H
|
||||
+
|
||||
+/*
|
||||
+ * Get U-Boot's environment variable.
|
||||
+ *
|
||||
+ * Params:
|
||||
+ * 'name' (input) Name of the environment variable
|
||||
+ * 'value' (output) Pointer to the variable's value
|
||||
+ * (NULL if not found)
|
||||
+ *
|
||||
+ * Return: 0 on sucess, -1 on failure
|
||||
+ */
|
||||
+int uboot_getenv(char *name, const char **value);
|
||||
+
|
||||
+/*
|
||||
+ * Set U-Boot's environment variable.
|
||||
+ *
|
||||
+ * Params:
|
||||
+ * 'name' (input) Name of the environment variable
|
||||
+ * 'value' (input) Value of the environment variable
|
||||
+ *
|
||||
+ * Return: 0 on sucess, -1 on failure
|
||||
+ */
|
||||
+int uboot_setenv(char *name, char *value);
|
||||
+
|
||||
+#endif /* UBOOTENV_H */
|
||||
|
|
@ -6,6 +6,7 @@ SRC_URI += " \
|
|||
file://fw_env.config \
|
||||
file://0001-tools-env-implement-support-for-environment-encrypti.patch \
|
||||
"
|
||||
SRC_URI_append = " file://0004-Implement-U-Boot-environment-access-functions.patch"
|
||||
SRC_URI_append_ccimx6 = " file://0002-fw_env-add-support-to-unlock-emmc-boot-partition.patch"
|
||||
|
||||
# We do not have a platform defconfig in this version of u-boot, so just use the generic
|
||||
|
|
@ -14,6 +15,8 @@ UBOOT_CONFIG = "sandbox"
|
|||
UBOOT_CONFIG[sandbox] = "sandbox_defconfig"
|
||||
|
||||
do_install_append() {
|
||||
install -d ${D}${includedir}/libubootenv
|
||||
install -m 0644 ${S}/tools/env/ubootenv.h ${D}${includedir}/libubootenv/
|
||||
install -m 0644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue