aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/tools/eeprom-set-flags.c
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2018-01-12 17:11:05 -0800
committerMartin Braun <martin.braun@ettus.com>2018-01-12 17:30:53 -0800
commitdeccab5a1b90df299b7b194bfef9da046f8f319b (patch)
treedac633f8e1fdabc370ff6bbacbf53d22332f260c /mpm/tools/eeprom-set-flags.c
parentefc0b22f7ea9b808512cb59a5a52202adf84b6e1 (diff)
downloaduhd-deccab5a1b90df299b7b194bfef9da046f8f319b.tar.gz
uhd-deccab5a1b90df299b7b194bfef9da046f8f319b.tar.bz2
uhd-deccab5a1b90df299b7b194bfef9da046f8f319b.zip
mpm: Add EEPROM utilities for N310
Actually-written-by: Moritz Fischer <moritz.fischer@ettus.com>
Diffstat (limited to 'mpm/tools/eeprom-set-flags.c')
-rw-r--r--mpm/tools/eeprom-set-flags.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/mpm/tools/eeprom-set-flags.c b/mpm/tools/eeprom-set-flags.c
new file mode 100644
index 000000000..00a96677e
--- /dev/null
+++ b/mpm/tools/eeprom-set-flags.c
@@ -0,0 +1,58 @@
+//
+// Copyright 2017 Ettus Research, a National Instruments Company
+//
+// SPDX-License-Identifier: GPL-3.0
+//
+
+#include "eeprom.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+void usage(char *argv[])
+{
+ printf("-- Usage -- \n");
+ printf("%s flags\n", argv[0]);
+ printf("Example:\n");
+ printf("$ %s 0x1\n", argv[0]);
+
+}
+
+int main(int argc, char *argv[])
+{
+ struct usrp_sulfur_eeprom *ep;
+ u32 flags;
+
+ if (argc != 2) {
+ usage(argv);
+ return EXIT_FAILURE;
+ }
+
+ errno = 0;
+ flags = strtol(argv[1], NULL, 16);
+ if (errno) {
+ printf("Failed to convert flags, make sure you enter as hex\n");
+ return EXIT_FAILURE;
+ }
+
+ ep = usrp_sulfur_eeprom_from_file(NVMEM_PATH_MB);
+ if (!ep) {
+ printf("eeprom not found\n");
+ return EXIT_FAILURE;
+ }
+
+ usrp_sulfur_eeprom_print(ep);
+
+ /* Set flag */
+ ep->mcu_flags[0] = htonl(flags);
+ usrp_sulfur_eeprom_recrc(ep);
+
+ /* Write out to eeprom */
+ usrp_sulfur_eeprom_to_i2c(ep, "/dev/i2c-2");
+ free(ep);
+
+ printf("-- Reading back \n");
+ ep = usrp_sulfur_eeprom_from_file(NVMEM_PATH_MB);
+ usrp_sulfur_eeprom_print(ep);
+ free(ep);
+}