diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-02-27 12:05:07 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-03-05 15:56:41 -0800 |
commit | 9c8edf8fd4b4bb42f5911f7a8240686a69077f80 (patch) | |
tree | 14ee1e4c06dd497f3fd6d63e02cb3ecad74d7b27 /mpm/tools | |
parent | 7fa1f6ed0726ff0f908245e43a01f50620293e8d (diff) | |
download | uhd-9c8edf8fd4b4bb42f5911f7a8240686a69077f80.tar.gz uhd-9c8edf8fd4b4bb42f5911f7a8240686a69077f80.tar.bz2 uhd-9c8edf8fd4b4bb42f5911f7a8240686a69077f80.zip |
mpm: Update EEPROM tools to allow setting PID
Default behaviour is to fall back to writing the N310 PID (0x4242).
Reviewed-by: Moritz Fischer <moritz.fischer@ettus.com>
Diffstat (limited to 'mpm/tools')
-rw-r--r-- | mpm/tools/eeprom-id.c | 10 | ||||
-rw-r--r-- | mpm/tools/eeprom-init.c | 20 |
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); |