a problem in the makefile templet of WINAVR 20070122

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

hi,

I just tried to use makefile templet of WINAVR 20070122 to generate .bin file of the code, but after I changed:

# Output format. (can be srec, ihex, binary)
FORMAT = ihex

to

# Output format. (can be srec, ihex, binary)
FORMAT = binary

,
it still generate the old hex file. I think the code for generate bin file was wrong in this templet.

Regards,

Cheng

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

Have a look at what is INSIDE the .hex file - I think you may find that it HAS changed.

Cliff

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

If you want .bin with the correct file extension I think the easiest way may be to locate:

# Create final output files (.hex, .eep) from ELF output file.
%.hex: %.elf
	@echo
	@echo $(MSG_FLASH) $@
	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@

and add after it:

# Create final output file (.bin) from ELF output file.
%.bin: %.elf
	@echo
	@echo $(MSG_FLASH) $@
	$(OBJCOPY) -O binary -R .eeprom $< $@

then locate:

build: elf hex eep lss sym

and change it to be:

build: elf hex bin eep lss sym

and add a line between:

hex: $(TARGET).hex
eep: $(TARGET).eep

so that it then reads:

hex: $(TARGET).hex
bin: $(TARGET).bin
eep: $(TARGET).eep

Now, when you "make" you get a file.bin as well as file.hex output.

(oh and you might want to add it under clean: too!)

Cliff

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

thanks, Cliff, I had the added code to generate the bin together with hex before. I just wondered about the this binary output format in the makefile.

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

Well that's becasue the original rule remained:

# Create final output files (.hex, .eep) from ELF output file. 
%.hex: %.elf 
   @echo 
   @echo $(MSG_FLASH) $@ 
   $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@

and all that changed in this was the $(FORMAT) that switched from "ihex" to "binary" but the rule still was taking the .elf as input and outputting to a .hex of the same name. (though it no longer contained hex)

Cliff

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

Hmm. Yeah, that's not necessarily the best design, was it. :(

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

no, that's a little bit confusing.

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

Patches welcome. :)