How do I build a .hex file in C ++ for Arduino?

I have a hex file that needs to be collapsed on an Atmel chip running on an Arduino device.

There are some aspects of this file that I would like to modify before putting it on my Arduino, but I don't have the source C ++; just a hex file.

Is there an efficient way to take a .hex file and compile the C code? If so, how?

+6
source share
2 answers

It may not have been available at the time other answers were given. It closes .hex back to assembler. You may need to know the architecture of the original AVR for which it was intended. Works well for me for the code I wrote and compiled. I tested the AVR-25 for the Tiny 85. Hope this helps. It would be nice to have a standalone version of the same! http://www.onlinedisassembler.com/ An alternative commercial option is the IDA from https://www.hex-rays.com/

+10
source

I would look at the output of avr-objdump (gulp):

avr-objdump -j .sec1 -d -m avr5 foo.hex 

You will need to change the words following the "-m" to your architecture. Even when / if it works, you will get C code that may not look like you have ever written. Variable names will be different, and convenient Arduino functions will look like dirty C-garbage. Hope there is a better way, sorry.

See also AVR GCC Forum - Using avr-objdump to demonstrate hex code .

+7
source

Source: https://habr.com/ru/post/945653/


All Articles