Converting Intel hex to bin file

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

Hi,

 

Anybody knows where I can find a simple intel hex to bin file converter running on 32 bit platform (Win10)?

My old died moving to win10. :-)

 

Perhaps AtmelStudio should have the possibility to generate bin files??

 

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

objcopy -I ihex Demo.hex -O binary Demo.bin

 

Any (avr-, arm-none-eabi-) objcopy will work the same.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

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

Thanks a lot, it works!

 

Build Events: Post-build event command line: "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -I ihex ml6.hex -O binary ml6.bin

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

Is it possible to get the bin file filled with 0xFF up to some size with the tool?
For example, I get bin file size 32433, but I need to get it 32768. The rest should be just 0xFF.

Could the tool do it?

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

Appending?

 

That's only a few hundred bytes.  Use hexedit and add the 0xFF bytes yourself.

 

Alternately:

$ while [ $(stat -c %s foo.bin) -ne 32768 ] ; do echo -en "\0377" >> foo.bin ; done

Ugly and slow, but works.

 

Why do you need this?

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Tim0xA wrote:

Is it possible to get the bin file filled with 0xFF up to some size with the tool?
For example, I get bin file size 32433, but I need to get it 32768. The rest should be just 0xFF.

Could the tool do it?

Srecord can do that (and about a 1,000 other things). It is the "go to" tool for working with any kind of micro load image. It supports all forms of Intel Hex and Motorola Srecord and about 40 other formats too.

 

http://srecord.sourceforge.net/

 

See this page in the manual:

 

http://srecord.sourceforge.net/m...

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

Regards,
Deena

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

+1  why?

 

if it's a normal setup everything not programmed will be 0xFF

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

clawson wrote:
Srecord can do that (and about a 1,000 other things). It is the "go to" tool for working with any kind of micro load image. It supports all forms of Intel Hex and Motorola Srecord and about 40 other formats too. http://srecord.sourceforge.net/

Thanks

 

joeymorin wrote:
$ while [ $(stat -c %s foo.bin) -ne 32768 ] ; do echo -en "\0377" >> foo.bin ; done

hmmm, I don't know how to run it.

 

sparrow2 wrote:

+1  why?

 

I have to append some specific data to a firmware file pefore programming. The data should be at the very end of the MCU flash memory. The rest bytes should stay 0xFF.

hex2bin converter has the option /Ln, but it doesn't work in Win10

I've written a small tool to do it already. I append 0xFFs and add the needed data at the end.

 

I'm just interested if other CLI tools could do the same (to append and change bytes in binary file) from command line (from *.bat file).

 

Last Edited: Sun. Jan 31, 2016 - 09:01 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Tim0xA wrote:

joeymorin wrote:
$ while [ $(stat -c %s foo.bin) -ne 32768 ] ; do echo -en "\0377" >> foo.bin ; done

hmmm, I don't know how to run it.

Joey runs that on a Linux/Unix  system, on a shell prompt. If you're on windows then you cant run that command.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

JohanEkdahl wrote:

Tim0xA wrote:

joeymorin wrote:
$ while [ $(stat -c %s foo.bin) -ne 32768 ] ; do echo -en "\0377" >> foo.bin ; done

hmmm, I don't know how to run it.

Joey runs that on a Linux/Unix  system, on a shell prompt. If you're on windows then you cant run that command.

Cygwin:
http://www.google.ca/search?q=cygwin

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Sun. Jan 31, 2016 - 04:27 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

joeymorin wrote:
Cygwin

Wouldn't touch that with a 10 foot pole, based on old experiences. (They introduced their own DLL hell by having different incompatible versions of Cygwin1.dll.)

 

I prefer MinGW (with MSYS) for getting Unix/Linux functionality on a Windows system. I would have supplied the link to the MinGW build with threading support in G++, but I can't locate the link ATM.

 

Well, actually I prefer Linux in a VM.

 

Well, actually-actually I hope I can soon prefer it running as the native OS.

 

EDIT: Link to MinGW build with GCC G++ with std::Thread support: http://sourceforge.net/projects/...

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Sun. Jan 31, 2016 - 07:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wouldn't touch that with a 10 foot pole

I tend to agree, but mind you I have even stronger feelings about Windows ;-)

 

In all honestly, I haven't touched Cygwin in almost twenty years.  I posted hastily from my my mobile.

 

When I need to generate a win32 executable, I use MinGW on Linux.

 

There are also a number of "Unix utilities for Windows" packages out there:

https://www.google.ca/search?q=unix+utilities+for+windows

 

In any event, Cliff has the better solution:  Srecord.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

I have written a Windows tool that works in Windows 10 (x86/64).

Batch files are not necessary, the tool has a small automation.

 

See http://blog.copcea.ro/2016/12/28... for info and download.

 

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

What's the point when objcopy exists in binutils anyway?

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

Thanks for sharing your opinion. Some may agree, others may not.

Just out of curiosity, your post comes 2 minutes after mine.

Did you even download the tool and see what it does?

 

Fyi, I do not use Gnutils on Windows. So do others too.

 

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

You'll find few around here who will risk downloading an arbitrary executable from an unknown website.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

especially when well-known, widely used & trusted tools already exist

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...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you guys for the support.

It is not important who takes as long as I feel good giving and sharing.

 

"Some people choose to see the ugliness in this world, the disarray. I choose to see the beauty. To believe there is an order to our days. A purpose"

- Dolores

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

Sanos99 wrote:

Fyi, I do not use Gnutils on Windows.

 

What you may not understand is that objcopy is part of Atmel Studio.

So if you have installed Atmel Studio on your Windows computer, objcopy is there and ready to use.

 

I believe this is why clawson asked what motivated you to write your own.

 

 

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

Chuck,

 

thanks for the comment.

My motivation is exactly the one I have stated before:

- I do not use gnutils, I personally hate having to write a batch file for every single project.

- I find easier to have a Windows application and use it visually to make simple conversions.

- The application has also a silent button to redo countless times whatever conversion was done the first time. After each rebuild, pressing a button makes the conversion and also shows me - visually - whatever flash space is occupied, This way I can easily decide if, for example, I'll start writing a new menu taking up lots of space or if I'll just use an EEMEM variable to implement a new feature.

- the application is not intended to void the use of objcopy, it is intended to come as an alternative feature.

 

and finally

 

- I still use Studio 4.19, which does not come with objcopy or other similar tool. When using an MKII programming device, every time I shift from Studio 4.19 to Studio 7, I have to flash the MKII again, which is an additional pain.

 

If there are others struggling with the same issues than I did, this tool would be useful.

 

You gave me an idea here: I wish to provide my work free of charge for the community. I will post also the source code so everybody will be able to compile it with lazarus.