Welcome! Log In Create A New Profile

Advanced

How to read Hex dump file

Posted by warankarp 
How to read Hex dump file
February 17, 2016 12:29AM
Hello,

I have a hex dump file of my firmware, which I would like to open and read. My goal here is to copy values from the config.h and pins.h file. This is for Marlin

Please let me know if there is any converter or a reader that can do this

Thanks in Advance
Re: How to read Hex dump file
February 17, 2016 03:13AM
No such application exists
Re: How to read Hex dump file
February 17, 2016 03:32AM
Here is one for a windows platform called HxD [mh-nexus.de]
Also you will need to know and understand hexadecimal. 16 digits 0-9 A-F which which correspond to decimal values 10 to 15
and the binary system, most of this was/should be covered in Computer Science.


Supporting 3D Printers with Parts and Build services.
Printer: Ormerod 2 (528.4) Duel extruder set-up with Aluminium X-Rib, RRPro Firmware v1.11-ch (2016-04-08)
Re: How to read Hex dump file
February 17, 2016 04:41AM
You have chosen quite hard task. It is doable, but quite boring, time consuming and results aren't sure. I've don't recommend this way unless you really want learn how computers work. This isn't stuff they teach in universities. This is stuff they write doctoral thesis in reverse engineering.

First you need to get AVR-gcc and compile same firmware. Now you have two binaries. Disassemble them. Differences are from differences in code or code generation from compiler.
When you have guessed right compiler and compiler options, you can start predicting what values you have.

Third compilation might be handy if you compile it with debugging symbols and generate assembly listing. It can give information where in binary each constant is used. But depends a lot of code generation process.

And then you just tweak the one source code until you get exact disassembly. So yes it is doable, scriptable but not worth of the effort. You should just write your your own proper config.

Being newbie in this forum I've seen quite many times question for getting configuration constants. IMHO those should be data which should be available to be queried from binary.
Re: How to read Hex dump file
February 17, 2016 05:38AM
If you compile the exact version of firmware you have with the exact version of the compiler that was used, with the exact same options you may be able to get something from a binary difference. But strings of variable length can offset all bytes after it.

IMHO all configuration options should be in eeprom, not even in the firmware..
Re: How to read Hex dump file
February 17, 2016 06:36AM
I have found visual diff to be good in such cases. I generate picture of the blob and side by side change the dimensions and then I encode a video. And with the disassembly listing and coordinates I can find a lot of information. I also do much work with IDA and simulators. But that's mainly when finding differences between firmware versions of some devices.

Configuring through EEPROM would be nice. It would however make big performance penalty.

PORTA |= (1 << SOME_PIN); would turn into load PORTA address from eeprom to register, read SOME_PIN from eeprom to register , read value from PORTA write 1 to register shift it with SOME_PIN amount or it with PORTA value and write PORTA.

However AVR has command which sets one pin in one or two cycles and compiler can optimize that to it.

And yes. Every example has counter example. I have chosen very specific example to fit my purposes.

And if the values in EEPROM are just for read back purposes, someone would tweak them and hope them to make changes. So that's why my opinion is to put them inside flash. With some C-macro trickery they can be declared and added even names for them so that it easy to read them from binary blob. Most of the time flash is bigger than EEPROM too.
Re: How to read Hex dump file
February 18, 2016 02:18AM
This seems like such a daunting task. Is there any work around ? How do I copy EEPROM settings without connecting to the printer ?

I need the calibration steps and few other numbers. This is for Prusa i3 Hictop version.
Re: How to read Hex dump file
February 18, 2016 02:48AM
Hi,

Wouldn't think you could read settings from the EEPROM without at least a serial connection to it.
It might be quicker to start from scratch. There are calculators for working out the numbers you need;
You will need to know what hardware settings you used I.E. thread pitch, belt type and pitch and technical details for your stepper motor

[www.openbuilds.com]
[nathan7.eu]
[prusaprinters.org]

There is also this guide I found useful [reprap.org]


Supporting 3D Printers with Parts and Build services.
Printer: Ormerod 2 (528.4) Duel extruder set-up with Aluminium X-Rib, RRPro Firmware v1.11-ch (2016-04-08)
Re: How to read Hex dump file
February 18, 2016 05:27PM
As I said reading back from binary is tough task which is about equivalent to impossible.

Which firmware the dump came? Is it Marlin?
Marlin is licensed with GPL so there is your right to get the source code.

If you bought the printer and you know its firmware and the firmware is licensed as GPL, getting source code is your right. Or has the printer just dropped out of the sky in to your hands and you have no way to get the source?

Or if that is too hard, then just sit down, take your favourite editor and open config.h and study. Write 20+ words additional comment to every constant about what it does. After you have done it, comment out default values and write your own values below. If you do good quality and want, then you could send it to Marlin developers so that it could be added to the documentation.

Maybe easier is to use tools linked by orictosh but you lose the learning part. Same target can be achieved many ways. I like to get my goals so that my understanding about topic grows.
Re: How to read Hex dump file
February 22, 2016 12:29AM
Thanks for the input guys

Here are some information I was able to get about the printer over the weekend. Its a HICTOP Prusa i3 from bought on Amazon. Runs Marlin

I have the hex file for this firmware. The only problem is the board has some issues. So, I want to use a RAMPS 1.4 board for now and implement this before I get that fixed or probably the same board ->MKS so that i dont have to mess with pins.h file.

Also, I want to upgrade this printer with an inductive probe for auto bed leveling. I read about the procedure for installing the Z-probe.

One more question, I am just curious on how to get a hexdump from an existing printer. I believe I can use Cura to upload the hexdump back into the printer for reinstalling the firmware But How do I get a hex file of any printer ?

Edited 1 time(s). Last edit at 02/23/2016 04:56PM by warankarp.
Re: How to read Hex dump file
February 22, 2016 02:12AM
As others say the best you can do is to take notes of the settings from the printer right now and recreate the configuration.h file. To extract the hex you can use a cheap USB programmer like usbasp (check eBay) and plug it into the icsp of your printer board.


My printers:
-Makerbot TOM (#5215, circa 2011), MK6 extruder, ABS 3 mm
-HICTOP Prusa i3 (modded for auto-level, thread screws), ABS/PLA 1.75 mm

About me:
[www.thingiverse.com]
Re: How to read Hex dump file
February 23, 2016 04:54PM
Eried,

For the probe, Did you split the power input using 2 resistors or did you directly plug it into the Zmin endstop ? I am wondering whether I should use the 7805 Voltage regulator or just a couple of resistors

Also, can you share your config file ?

**edited

Edited 2 time(s). Last edit at 02/23/2016 04:57PM by warankarp.
Sorry, only registered users may post in this forum.

Click here to login