aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/tools/tlv_eeprom/eeprom-dump.c
blob: 9afcef4313c6ef11f54460cb404d19b9829a69da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright 2019 Ettus Research, a National Instruments Brand
 */

#include <stdio.h>
#include <stdlib.h>

#include "tlv_eeprom.h"
#include "tlv_eeprom_io.h"
#include "usrp_eeprom.h"

int main(int argc, char **argv)
{
	struct tlv_eeprom *eeprom;

	if (argc != 2) {
		fprintf(stderr, "usage: %s <eeprom>\n", argv[0]);
		return 1;
	}

	eeprom = tlv_eeprom_read_from_file(argv[1]);
	if (!eeprom)
		return 1;

	if (!tlv_eeprom_validate(eeprom, USRP_EEPROM_MAGIC))
		tlv_for_each(eeprom->tlv, eeprom->size, usrp_eeprom_trace);
	else
		fprintf(stderr, "eeprom contents invalid!\n");

	free(eeprom);

	return 0;
}