EmbDev.net

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


von Sevc D. (sevc)


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

regards.

Dzairo

von Martin Thomas (Guest)


Rate this post
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_projects/index_at91.html#at91uart_and_aic
or convert with an external software like hex2bin.exe (from atmel.com,
keil.com etc.) or the srecord-tools.

von Sevc D. (sevc)


Rate this post
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

von Martin Thomas (Guest)


Rate this post
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.

von Sevc D. (sevc)


Rate this post
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

von Johann K. (johannkok)


Rate this post
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

von Sevc D. (sevc)


Rate this post
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

von Martin Thomas (Guest)


Rate this post
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_projects/index_at91.html#at91_gamma

Martin Thomas

von Sevc D. (sevc)


Rate this post
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_projects/index_at91.html#at91_gamma
>
> 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

von Martin Thomas (Guest)


Rate this post
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

von Sevc D. (sevc)


Rate this post
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.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.