Stored in the last four bytes of the eeprom in network byte order. --- src/rtl_eeprom.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/rtl_eeprom.c b/src/rtl_eeprom.c index 35191de..51024d6 100644 --- a/src/rtl_eeprom.c +++ b/src/rtl_eeprom.c @@ -23,8 +23,10 @@
#ifndef _WIN32 #include <unistd.h> +#include <arpa/inet.h> #else #include <Windows.h> +#include <WinSock2.h> #include "getopt/getopt.h" #endif
@@ -84,6 +86,7 @@ void usage(void) "\t[ terratec_plus\tTerratec T Stick+ (DVB-T/DAB)]\n" "\t[-w <filename> write dumped file to device]\n" "\t[-r <filename> dump EEPROM to file]\n" + "\t[-x <Hz> store calibrated XTAL frequency]\n" "\t[-h display this help text]\n" "\nUse on your own risk, especially -w!\n"); exit(1); @@ -262,9 +265,10 @@ int main(int argc, char **argv) int default_config = 0; int change = 0; int ir_endpoint = 0; + uint32_t xtal_freq = 0; char ch;
- while ((opt = getopt(argc, argv, "d:m:p:s:i:g:w:r:h?")) != -1) { + while ((opt = getopt(argc, argv, "d:m:p:s:i:g:w:r:x:h?")) != -1) { switch (opt) { case 'd': dev_index = atoi(optarg); @@ -306,6 +310,9 @@ int main(int argc, char **argv) case 'r': filename = optarg; break; + case 'x': + xtal_freq = htonl(atol(optarg)); + break; default: usage(); break; @@ -347,6 +354,14 @@ int main(int argc, char **argv) if (r < 0) return -1;
+ if(xtal_freq) { + r = rtlsdr_write_eeprom(dev, (void*)&xtal_freq, EEPROM_SIZE-4, 4); + if (r < 0) + fprintf(stderr, "Error while writing XTAL frequency to EEPROM: %i\n", r); + else + fprintf(stderr, "XTAL frequency successfully written.\n"); + } + fprintf(stderr, "Current configuration:\n"); parse_eeprom_to_conf(&conf, buf); dump_config(&conf);