mirror of
https://github.com/OpenMANET/morse-feed.git
synced 2025-12-10 03:43:06 -06:00
persistent-vars-storage-bcm2711: adds a Raspberry Pi compatible persistent storage utility
The Morse Micro persistent-vars-storage package is used to load and store certain device parameters or configuration from non-volatile storage on a device. This is useful for a more persistent configuration than what is offered by UCI. Typically used for dpp keys. The bcm2711 version targets Raspberry Pis and pushes this configuration to the on-board eeprom.
This commit is contained in:
parent
a60dee014e
commit
7eb52b2b31
35
utils/persistent-vars-storage-bcm2711/Makefile
Normal file
35
utils/persistent-vars-storage-bcm2711/Makefile
Normal file
@ -0,0 +1,35 @@
|
||||
#
|
||||
# Copyright 2023 Morse Micro
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
|
||||
PKG_NAME:=persistent-vars-storage-bcm2711
|
||||
PKG_RELEASE=1
|
||||
|
||||
PKG_MAINTAINER:=Morse Micro
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/persistent-vars-storage-bcm2711
|
||||
SECTION:=Utilities
|
||||
CATEGORY:=Utilities
|
||||
PROVIDES:=persistent-vars-storage
|
||||
TITLE:=Reads (or maybe writes in future) key-value pairs from(/into) the RPi 4 EEPROM memory
|
||||
DEPENDS:= +bcm27xx-userland @TARGET_bcm27xx_bcm2711
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
|
||||
endef
|
||||
|
||||
define Package/persistent-vars-storage-bcm2711/install
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_BIN) ./files/sbin/persistent_vars_storage.sh $(1)/sbin/persistent_vars_storage.sh
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,persistent-vars-storage-bcm2711))
|
||||
53
utils/persistent-vars-storage-bcm2711/files/sbin/persistent_vars_storage.sh
Executable file
53
utils/persistent-vars-storage-bcm2711/files/sbin/persistent_vars_storage.sh
Executable file
@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2023 MorseMicro
|
||||
#
|
||||
|
||||
|
||||
operation="$1"
|
||||
key="$2"
|
||||
value="$3"
|
||||
|
||||
set -eu
|
||||
|
||||
get_key_from_persistent_storage()
|
||||
{
|
||||
local config_key=
|
||||
config_key=$(vcgencmd bootloader_config | grep "$key=")
|
||||
config_key=$(echo "$config_key" | sed "s/$key=//g")
|
||||
echo "$config_key"
|
||||
}
|
||||
|
||||
print_usage()
|
||||
{
|
||||
echo "persistent_vars_storage.sh OPERATION(READ|WRITE|ERASE) KEY [VALUE]" 1>&2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
case "$operation" in
|
||||
READ)
|
||||
value=$(get_key_from_persistent_storage)
|
||||
if [ -n "$value" ]; then
|
||||
echo "$value"
|
||||
exit 0
|
||||
else
|
||||
echo "The key \"$key\" doesn't exist in bootloader config." 1>&2;
|
||||
print_usage
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
WRITE|ERASE)
|
||||
echo "Writing to persistent memory isn't implemented on bcm2711, yet." 1>&2;
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*)
|
||||
print_usage
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user