aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mpm/tools/eeprom-id.c10
-rw-r--r--mpm/tools/eeprom-init.c20
2 files changed, 23 insertions, 7 deletions
diff --git a/mpm/tools/eeprom-id.c b/mpm/tools/eeprom-id.c
index 0b2c78f26..151b38aff 100644
--- a/mpm/tools/eeprom-id.c
+++ b/mpm/tools/eeprom-id.c
@@ -1,17 +1,23 @@
//
-// Copyright 2017 Ettus Research, a National Instruments Company
+// Copyright 2017-2018 Ettus Research, a National Instruments Company
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#include <stdio.h>
#include <stdlib.h>
+#include <arpa/inet.h>
#include "eeprom.h"
+#define N310_PID 0x4242
+#define N300_PID 0x4240
+
static void usrp_sulfur_eeprom_print_id(struct usrp_sulfur_eeprom *ep)
{
- if (ep->pid == 0x4242)
+ if (ntohs(ep->pid) == N310_PID)
printf("product=ni,n310-rev%x\n", ntohs(ep->rev)+1);
+ else if (ntohs(ep->pid) == N300_PID)
+ printf("product=ni,n300-rev%x\n", ntohs(ep->rev)+1);
else
printf("product=unknown-(%04x)\n", ntohs(ep->pid));
diff --git a/mpm/tools/eeprom-init.c b/mpm/tools/eeprom-init.c
index a19d8a771..a2b608464 100644
--- a/mpm/tools/eeprom-init.c
+++ b/mpm/tools/eeprom-init.c
@@ -11,9 +11,9 @@
void usage(char *argv[])
{
printf("-- Usage -- \n");
- printf("%s serial# revision eth0 eth1 eth2\n\n", argv[0]);
+ printf("%s serial# revision eth0 eth1 eth2 pid\n\n", argv[0]);
printf("Example:\n");
- printf("$ %s 310A850 2 0c:22:cc:1a:25:c1 0c:22:cc:1a:25:c2 0c:22:cc:1a:25:c3\n",
+ printf("$ %s 310A850 2 0c:22:cc:1a:25:c1 0c:22:cc:1a:25:c2 0c:22:cc:1a:25:c3 0x4242\n",
argv[0]);
}
@@ -22,15 +22,25 @@ int main(int argc, char *argv[])
{
struct usrp_sulfur_eeprom *ep, *ep2;
- if (argc != 6) {
+ if (argc < 6 || argc > 7) {
usage(argv);
return EXIT_FAILURE;
}
printf("sizeof(*ep)=%lu\n", sizeof(*ep));
- ep = usrp_sulfur_eeprom_new(NULL, 0x4242, atoi(argv[2]), argv[1], argv[3],
- argv[4], argv[5]);
+ long pid = 0x4242;
+ if (argc == 7) {
+ pid = strtol(argv[6], NULL, 0);
+ }
+
+ if (pid < 0 || pid > 0xFFFF) {
+ printf("Invalid PID: %lX\n", pid);
+ return EXIT_FAILURE;
+ }
+
+ ep = usrp_sulfur_eeprom_new(NULL, (u16) pid, atoi(argv[2]), (const u8*) argv[1],
+ argv[3], argv[4], argv[5]);
usrp_sulfur_eeprom_print(ep);
usrp_sulfur_eeprom_to_i2c(ep, "/dev/i2c-2");
free(ep);