Skip to content

Instantly share code, notes, and snippets.

@kholia
Last active January 4, 2022 15:10
Show Gist options
  • Save kholia/4c2d272e627c5b5d75af1dd5e99e7c91 to your computer and use it in GitHub Desktop.
Save kholia/4c2d272e627c5b5d75af1dd5e99e7c91 to your computer and use it in GitHub Desktop.
Backup stock uBitx's calibration values

TLDR: Dump Stock Raduino's EEPROM using avrdude program. Once this EEPROM is dumped (and checked), we can always restore it back safely.

EEPROM size -> ATmega328 (Arduino Uno, Nano, Mini) -> 1024 bytes

Dump the EEPROM:

$ avrdude -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -U eeprom:r:eeprom_dump_dhiru_v3.5-1.txt

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading eeprom memory:

Reading | ################################################## | 100% 1.86s

avrdude: writing output file "eeprom_dump_dhiru_v3.5-1.txt"

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

Sanity-check the size:

$ ls -la eeprom_dump_dhiru_v3.5-1.txt
-rw-rw-r-- 1 dhiru dhiru 1024 Aug  4 15:29 eeprom_dump_dhiru_v3.5-1.txt

Parse the EEPROM:

$ xxd eeprom_dump_dhiru_v3.5-1.txt
00000000: fb5c 0200 ffff ffff 1c0e b700 ffff ffff  .\..............
00000010: 6056 6c00 70e9 d700 ffff ffff 9600 ffff  `Vl.p...........
00000020: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00000030: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00000040: 13fb 5c02 00ff ffff ff1c 0eb7 00ff ffff  ..\.............
00000050: ffb0 196d 0070 e9d7 00ff ffff ff96 00ff  ...m.p..........
...
$ ipython
Python 3.8.2 (default, Apr 10 2020, 12:38:04)


In [2]: int("0x00025cfb", 16)  <- first 4 EEPROM byte in LE format => MASTER_CAL
Out[2]: 154875

In [3]: int("0x00b70e1c", 16)  <- BFO setting (USB_CAL)!
Out[3]: 11996700

These values match the ones read by uBITX_Manager_V1.11 (which works for custom non-factory firmwares only?).

[NEW] uBitx EEPROM parser:

$ python parser.py eeprom_dump_dhiru_v3.5-1.txt
Master Calibration (MASTER_CAL): 154875
USB Calibration (USB_CAL): 11996700 'BFO'
$ python parser.py eeprom_dump_dhiru_v3.5-larc-2021.txt
Master Calibration (MASTER_CAL): 121625
USB Calibration (USB_CAL): 11995800 'BFO'
python parser.py eeprom_dump_dhiru_v6-2022.txt
Master Calibration (MASTER_CAL): 180700
USB Calibration (USB_CAL): 11056300 'BFO'

[NEW] Windows Tips:

  • [NEW] Extract (to a writable folder) and use the included avrdude.zip. Just click on the included dump.bat.

[OLD] Windows Tips:

  • Install Arduino IDE

  • Find avrdude.conf and avrdude.exe on your computer. Copy avrdude.conf next to avrdude.exe.

  • You may need to add -F flag to the avrdude command. Also, you may need to copy avrdude.exe and its dependencies to a new writable folder.

  • Get latest Python from https://www.python.org/downloads/windows/.

  • Yes, Windows gets in the way, more often than not.

stuff:
fyne-cross windows "-arch=*" -ldflags="-s"
upx ./fyne-cross/bin/windows-amd64/ubitx-eeprom-dump.exe
cp ./fyne-cross/bin/windows-amd64/ubitx-eeprom-dump.exe parser.exe
deps:
go get -u github.com/fyne-io/fyne-cross
This file has been truncated, but you can view the full file.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment