diff options
author | Moritz Fischer <moritz.fischer@ettus.com> | 2018-04-25 18:01:09 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-06-20 17:10:05 -0500 |
commit | 91a5518443f4ff938f67a2f1bd1b09b24bceecd5 (patch) | |
tree | eb4adccd6d3c687d157d4a4073e76970a5ed0a69 /mpm/tools/eeprom-init.c | |
parent | 0935bf5c2a6952fd07bc4b6c618d12b0bd79ca78 (diff) | |
download | uhd-91a5518443f4ff938f67a2f1bd1b09b24bceecd5.tar.gz uhd-91a5518443f4ff938f67a2f1bd1b09b24bceecd5.tar.bz2 uhd-91a5518443f4ff938f67a2f1bd1b09b24bceecd5.zip |
mpm: tools: Introduce dt-compat and mcu-compat fields
Introduce dt-compat and mcu-compat fields into the eeprom
structure.
For the motherboard eeprom this is straightforward, since
there's still padding bytes that could be (ab)used for this.
On the dboard side more creativity is required and the
original revision field of 2 bytes is reduced to only
one byte revision and one byte dt-compat.
Since this will only affect new units being backwards
compatible with older versions of the bootloader is not
an issue.
Reviewed-by: Brent Stapleton <brent.stapleton@ettus.com>
Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
Diffstat (limited to 'mpm/tools/eeprom-init.c')
-rw-r--r-- | mpm/tools/eeprom-init.c | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/mpm/tools/eeprom-init.c b/mpm/tools/eeprom-init.c index a2b608464..87dc26a6b 100644 --- a/mpm/tools/eeprom-init.c +++ b/mpm/tools/eeprom-init.c @@ -8,39 +8,75 @@ #include <stdio.h> #include <stdlib.h> +int derive_dt_compat(int rev) +{ + /* up to rev6 they were individual dts */ + if (rev > 5) + return 5; + + return rev; +} + +int derive_mcu_compat(int rev) +{ + /* up to rev6 they were individual firmware */ + if (rev > 5) + return 5; + + return rev; +} + void usage(char *argv[]) { printf("-- Usage -- \n"); - printf("%s serial# revision eth0 eth1 eth2 pid\n\n", argv[0]); + printf("%s serial# revision eth0 eth1 eth2 [pid] [dt-compat] [mcu-compat]\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 0x4242\n", argv[0]); - + printf("or specifying dt-compat and mcu-compat explicitly:\n"); + printf("$ %s 310A850 2 0c:22:cc:1a:25:c1 0c:22:cc:1a:25:c2 0c:22:cc:1a:25:c3 0x4242 5 5\n", + argv[0]); } int main(int argc, char *argv[]) { struct usrp_sulfur_eeprom *ep, *ep2; + u16 dt_compat = 0; + u16 mcu_compat = 0; - if (argc < 6 || argc > 7) { + if (argc < 6 || argc > 9) { usage(argv); return EXIT_FAILURE; } - printf("sizeof(*ep)=%lu\n", sizeof(*ep)); - long pid = 0x4242; - if (argc == 7) { + if (argc >= 7) { pid = strtol(argv[6], NULL, 0); } + if (argc >= 8) { + dt_compat = strtol(argv[7], NULL, 0); + printf("dt_compat=%u\n", dt_compat); + } + + if (argc == 9) { + mcu_compat = strtol(argv[8], NULL, 0); + printf("mcu_compat=%u\n", mcu_compat); + } + 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]); + /* If no MCU or DT compat specified, derive based on rule up there, + * i.e. everything newer than 5 will be 5, assuming we don't change + * anything software visible anymore + */ + ep = usrp_sulfur_eeprom_new(NULL, (u16) pid, atoi(argv[2]), argv[1], + argv[3], argv[4], argv[5], dt_compat ? dt_compat : derive_dt_compat(atoi(argv[2])), + mcu_compat ? mcu_compat : derive_mcu_compat(atoi(argv[2]))); + usrp_sulfur_eeprom_print(ep); usrp_sulfur_eeprom_to_i2c(ep, "/dev/i2c-2"); free(ep); |