EmbDev.net

Forum: ARM programming with GCC/GNU tools from HEX to BIN


Author: Sevc Dominik (sevc)
Posted on:

Rate this post
0 useful
not useful
Hi all.
How can I convert HEX compiled file to BIN .
I want program mcu with SAM-BA (AT91SAM7S64).

regards.

Dzairo

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
Sevc Dominik wrote:

> How can I convert HEX compiled file to BIN .
> I want program mcu with SAM-BA (AT91SAM7S64).

Use the appropriate parameters for arm-elf-objcopy, see the makefile of
the application
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm...
or convert with an external software like hex2bin.exe (from atmel.com,
keil.com etc.) or the srecord-tools.

Author: Sevc Dominik (sevc)
Posted on:

Rate this post
0 useful
not useful
Hi.

I download hex2bin.exe from Atmel.
I run hex2bin blinky.hex blinky.bin

create bin file bat size is too big (more then 1MByt) real data are
start from adress 100000H and end at 1002A0 (672byt).
I don't use any parameter .
I compile blinky demo from IAR.

Where is problem.

regards .

Dzairo

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
There are different hex-formats and different hex2bin utils out there.
Take the "good" way: Modify the makefile, objcopy will create a bin-file
for you. In some older examples there is a mistake, the binary has the
ending .hex even if FORMAT=bin is set in the makefile. You can just
rename the file in this case. In newer examples this has been fixed.

Author: Sevc Dominik (sevc)
Posted on:

Rate this post
0 useful
not useful
I look to make file and there is write:
## Output format. (can be ihex or binary)
FORMAT = ihex
#FORMAT = binary

If I work on WinARM OK.
But if compile any project from IAR or KEIL generate HEX file.
I wil be try to program mcu with SAM-BA. Just SAM-BA use bin file.
I knou it's possible direct from IDE (macroigor - wingler).

regards.

Dzairo

Author: Johann Kok (johannkok)
Posted on:

Rate this post
0 useful
not useful
Sevc Dominik wrote:
> I look to make file and there is write:
> ## Output format. (can be ihex or binary)
> FORMAT = ihex
> #FORMAT = binary
>
> If I work on WinARM OK.
> But if compile any project from IAR or KEIL generate HEX file.
> I wil be try to program mcu with SAM-BA. Just SAM-BA use bin file.
> I knou it's possible direct from IDE (macroigor - wingler).
>
> regards.
>
Hi Dzairo,
could you download the generated bin file with sam-ba?  Can someone
please tell me how to modify my makefile so that it creates a .bin file
and not a .hex file with binary data in it.
Also: I can download my binary file with sam-ba or sam-prog but no LED
comes on on my -EK board.  Could someone please post me a working bin
file for the GPIO example that comes with WinAVR.

regards

Author: Sevc Dominik (sevc)
Posted on:

Rate this post
0 useful
not useful
Johann Kok wrote:
> could you download the generated bin file with sam-ba?
I thiks that can't download data from mcu with SAM-BA , because if you
want use sam-ba, must connect TST pin to VCC , then mcu load from rom
data to flash (default program for upload firmware ower USB,UART..) and
after upload data to mcu on flash is your program and if you don't make
support this function on your program can't do that , but it's my
opinion.

> please tell me how to modify my makefile so that it creates a .bin file
> and not a .hex file with binary data in it.
on file makefile find  FORMAT = ihex, then change FORMAT = binary ,
after make generate file with hex extension byt file is binary, manualy
change file extension and can use with sam-ba. (I use this)
section FORMAT define file format but no file extension.(this is EASY
way)
if you want generate bin file with bin extension you must FORMAT  set
back to ihex -> FORMAT = ihex and append FORMATB = binary (define other
format definition) then you must find section -> build: and append bin,
append line-> bin: $(TARGET).bin
then find -> # Create final output files     and append this :
# Create final output files (.bin) from ELF output file.
%.bin: %.elf
  @echo
  @echo $(MSG_FLASH) $@
  $(OBJCOPY) -O $(FORMATB) $< $@

and after make generate two file ihex file and binary file.

> Also: I can download my binary file with sam-ba or sam-prog but no LED
> comes on on my -EK board.  Could someone please post me a working bin
> file for the GPIO example that comes with WinAVR.
what devboard you use? what example you need?

regards dzairo

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
Sevc Dominik wrote:
>> please tell me how to modify my makefile so that it creates a .bin file
>> and not a .hex file with binary data in it.
> on file makefile find  FORMAT = ihex, then change FORMAT = binary ,
> after make generate file with hex extension byt file is binary, manualy
> change file extension and can use with sam-ba. (I use this)
> section FORMAT define file format but no file extension.(this is EASY
> way)
> if you want generate bin file with bin extension you must FORMAT  set
> back to ihex -> FORMAT = ihex and append FORMATB = binary (define other
> format definition) then you must find section -> build: and append bin,
> append line-> bin: $(TARGET).bin
> then find -> # Create final output files     and append this :
> # Create final output files (.bin) from ELF output file.
> %.bin: %.elf
>   @echo
>   @echo $(MSG_FLASH) $@
>   $(OBJCOPY) -O $(FORMATB) $< $@
>
> and after make generate two file ihex file and binary file.

Please get one of the newer AT91SAM7 examples. They include a fixed
makefile. For example in this project:
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm...

Martin Thomas

Author: Sevc Dominik (sevc)
Posted on:

Rate this post
0 useful
not useful
Martin Thomas wrote:
> Please get one of the newer AT91SAM7 examples. They include a fixed
> makefile. For example in this project:
> 
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm...
>
> Martin Thomas

OK.
I append line to makefile and new source upload from
sevc.szm.sk\at91sam7s64_example_gamma.zip
I try it and work OK.
after make genrate two file hex and bin.
then I manualy convert hex file to bin and compare. all is OK.


regards Dzairo

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
Sevc Dominik wrote:

> OK.
> I append line to makefile and new source upload from
> sevc.szm.sk\at91sam7s64_example_gamma.zip
> I try it and work OK.
> after make genrate two file hex and bin.
> then I manualy convert hex file to bin and compare. all is OK.

Could you please explain the reason for the "new source". The fixed
makefiles in the newer examples I provide on
www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects for SAM7 and LPC2k
process the FORMAT-option correctly. IRC I have corrected this the first
time for the "AT91SAM7-Hello"-example and used the template for all
later examples. You can use FORMAT=ihex or FORMAT=binary which will
result in files in the correct format and the correct file-extension. Is
there any need for having both formats as output from one "make all"?

Martin Thomas

Author: Sevc Dominik (sevc)
Posted on:

Rate this post
0 useful
not useful
I don't create new source just append some line to makefile.

Martin Thomas wrote:
> Is there any need for having both formats as output from one "make all"?
No, there's not needed make both file (hex,bin).But .... :-) .


regards.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.