Hex to ASM utility badly needed

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

Thanks for looking. I've written an assembler project to control an XMEGA-A3BU Xplained board. I got the program working, but then had to put it away for a few years.  Then, the hard disk crashed and I lost the source code. Shame on me. I was able to download the hex file from an XPlained board using the latest version of Atmel studio, but cannot duplicate one user's experience in AVR studio wherein the program recreated an assembler file based on the hex file contents.  I was able to find other .asm versions that do not work, but if I could get this hex file into AVR assembler format, I could get the program back into original form and working. Can anyone here assist me with this?  I understand someone wrote such a program (converts .hex to .asm file format), but I have not had luck trying to download from the link supplied (went to a Chinese site). It is used as a controller for a multiband amateur radio, with OLED display and 3 DDS boards. I would really appreciate help here, as I spent over 6 months getting this working, and have now lost the source.

 

Thanks, Fred

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Assuming you have the avr-gcc tools installed:

avr-objcopy -I ihex -O elf32-avr wo.hex wo.o
avr-objdump -D wo.o  >wo.txt

and then spend some time post-processing the asm dump.

Mike

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

atlantaswl wrote:
I understand someone wrote such a program (converts .hex to .asm file format)

It's called a disassembler.

 

There have been many previous such requests; eg, only last week:

 

https://www.avrfreaks.net/forum/current-avr-codedata-seeking-disassemblers

 

 

As  mha11 showed, objcopy/objdump can do it.

 

Other disassemblers are available; in fact, if you load the hex file in the Atmel Studio simulator or debugger, it will show you a disassembly view.

 

But note that a disassembler cannot reconstruct any of your symbolic information - variable names, etc - it will be just raw instruction mnemonics and hex values.

 

And disassemblers have a hard job telling data in flash from executable code, so it's likely to take a lot of work on your part to get it right - " post-processin", as   mha11 said.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Sat. Mar 14, 2020 - 10:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Start figuring out the names of each register & inserting into you code (ex:  r21==>motor_rpm, r23==>batt_volts), that will help immensely to see what is going on.  Same thing with any flag bit registers you made & anything stored in ram, if you used that.  Since you wrote the code, it will all come back.  The hardest part might be the lack of comments.   But you say you already have a slightly older version?  That will help a LOT.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for the help.  Now I've got some work to do.

 

Regards, Fred

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In #2 you also want the correct -m to specify the right architecture for A3BU