How to program without delete the bootloader section?

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

Hi,

I have developed a firmware. This firmware is uploaded by ISP the fisth time.

The microcontroller (AT90usb162) have a original usb bootloader.

When the firmware is uploade, the bootloader is cleared.

My firmware is composed by Application Zone, EEPROM, fuses and LockBits.

How to program without delete the bootloader section?

Can i resolve this through the makefile configuration?

Thanks

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

Get the .hex file for the bootloader from the Atmel site and merge it with your own .hex then program the composite

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

The practical solution is to download and program the .hex file for the bootloader via ISP.

Put your ISP programmer away in a drawer, and do all subsequent programming via FLIP.

The same applies to any bootloader system. Do NOT use ISP for programming subsequent applications.

Now it is very likely that you want to do some debugging via JTAG. In which case forget about bootloaders and FLIP. Just accept that your debug sessions will probably erase any bootloader.

Or best of all put a line in your Makefile that appends the bootloader.hex with every build. --- just like Cliff has suggested.

David.

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

Thanks to all.

david.prentice wrote:
Or best of all put a line in your Makefile that appends the bootloader.hex with every build. --- just like Cliff has suggested.

How to do this?

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

Load the Atmel Bootloader into your editor. Remove the last line that looks like this:

:00000001FF

and save it as "partboot.hex"

then in your Makefile:

combined.hex: $(TARGET).hex
     cat partboot.hex $TARGET).hex >$@

and in your "all:" line

all: $(TARGET).hex combined.hex

and you burn "combined.hex" when you ISP

David.

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

Srecord (part of WinAVR) or more specifically srec_cat can also be used to do the "gluing" without the need to edit out the intervening end of data record (well that's exactly what srec_cat does for you in fact)

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

What an appalling example of a Manual!

It took a lot of deciphering to discover:

combined.hex: $(TARGET).hex
     srec_cat bootloader.hex -intel $(TARGET).hex -intel -o $@ -intel

or just append this command to the "all" target

all: $(TARGET).hex
     srec_cat bootloader.hex -intel $(TARGET).hex -intel -o combined.hex -intel

Thanks to Cliff.

David.

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

I have a problem when Build the firmware:

"make: *** No rule to make target `srec_cat', needed by `all'. Stop."

My original all section:

Quote:

## Build
.PHONY: all
all: $(TARGET) $(PROJECT).hex size

Thanks again.

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

At a command prompt type:

c:\> srec_cat -VERsion

or maybe just:

c:\> which srec_cat.exe

to check that srec_cat.exe is available in your PATH.

(in the latest WinAVR it should be in C:\WinAVR-20090313\bin\srec_cat.exe)

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

srec_cat version 1.38.D001

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

How have you added the dependency?

srec_cat is a command, not a target or dependency.

make goes through the list of dependencies to see how to build a target:

target:   depend1 depend2 depend3
       consequence1
       consequence2

So for any consequent commands to be invoked when building "all", it must first successfully build $(TARGET) then $(PROJECT).hex then size

Obviously you do not want "combined.hex" to be built until everything else is ok.

Please post your current Makefile lines for "all"

David.

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

My current Makefile lines for "all":

Quote:

all: $(TARGET).hex srec_cat size
srec_cat bootloader_part_v105.hex -intel $(TARGET).hex -intel $(PROJECT).hex -intel

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

Well for one thing I wouldn't call the rule the same name as the utility - too much opportunity for confusion. But your rule doesn't look like a rule anyway. Try:

all: $(TARGET).hex join_hex size 
join_hex: $(TARGET).hex
srec_cat bootloader_part_v105.hex -intel $(TARGET).hex -intel $(PROJECT).hex -intel 

which is pretty much what David suggested above.

Last Edited: Tue. Oct 13, 2009 - 01:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

Don't work. The bootloader is not integrated in the firmware.

My "all" section is now:

Quote:

## Build
.PHONY: all

all: $(TARGET).hex join_hex size

join_hex: $(TARGET).hex
srec_cat bootloader_part_v105.hex -intel $(TARGET).hex -intel

And after Build is created a .elf , .elf.hex and .map files.

You can explain how to work the "all" section?

Thanks

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

What happens if you actually "make all" rather than just "make" (should be the same).

Also how do you know that the bootloader is not being concatenated onto the rest of the code? Did you examine the generated .ex file and look for the "join"?

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

It works!
Now is generated a join_hex.hex file.

But I need "merge" the boot in .elf file. I need to program the uP with All firmware in one step (Boot + App + EEPROM + Fuses + Lockbits)

Thanks for All

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

You have not created an output file. I have not got sufficient will-to-live required to trawl the srec docs.

But as a general rule you often get a default output file. e.g. ld produces a.out

I would guess that the default would be a Motorola .srec Srecord type file.

When someone tries to offer you an example command, it is worth your while making an intelligent attempt to copy it.

If you want to see what files have been created:

ls -ltr 

David.

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

david.prentice wrote:
You have not created an output file. I have not got sufficient will-to-live required to trawl the srec docs.

But as a general rule you often get a default output file. e.g. ld produces a.out

I would guess that the default would be a Motorola .srec Srecord type file.

When someone tries to offer you an example command, it is worth your while making an intelligent attempt to copy it.

If you want to see what files have been created:

ls -ltr 

David.

Thanks!!

But have Ideia about "merge" the boot in .elf file? I need to program the uP with All firmware in one step (Boot + App + EEPROM + Fuses + Lockbits)

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

You cannot merge ELF files so that will not be possible. Create one composite .hex and program that and then the EEPROM, Fuses and Lockbits separately (maybe all by the launch of a single .bat file?)

Or are you under the misapprehension that the only way to set fuses is using avr/fuse.h and then programming the resultant .elf ? (until about a year ago that option didn't even exist)

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

In fact when the application firmware is uploaded to debug it (with AVR Studio), the bootloader is cleared.

There is a method to merge my application firmware with bootloader hex WITHOUT use external makefile ?

Or I'm forced to use external makefile to avoid loss bootloader when debug my application ?

Thanks for help,
Rinaldo

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

Why do you load your program with ISP if you have a bootloader installed on the chip?

If there is a "first time" issue, load the program with ISP, load the bootloader with ISP, and then load the program with the bootloader.

That's too easy though. There must be something I don't understand.

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

I try explain my question:

- First I load bootloader
- Then I load application

But when I must debug application with AVR Studio, a maybe I must correct a bug for example, when update application firmware, the bootloader is cleared.

There is a way to update application+bootloader at same time?

Thanks,
Rinaldo

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

The bootloader and the application are two completely separate programs. Develop, debug and test each in complete isolation from the other unless the app is relying on boot functions (the opposite cannot be true). In this case you have to accept that there will be no symbolic info in the app.elf for the boot functions - but at this stage they should be fully developed/tested anyway.

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

If you debug with JTAG, there is an option to not load the program.

You need to be running JTAG to access the option. Click Debug > JTAGICE mkii options.

You have the option of never loading, loading if object file has changed, or always loading.

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

rlisario wrote:
There is a way to update application+bootloader at same time?
You need to concatenate the application and bootloader .hex files. The combined file can be used for production programming or debugging. To debug, open the combined .hex file in AVR Studio to create the project. That way, you'll get both parts loaded.

The problem is that there is no symbol information in the .hex file. This is not a major impediment if you are adept at reading assembly language code and relating it to the original C code. You can open the .lss file in an editor and use it to follow along, select addresses for setting breakpoints, etc. One issue is that the .lss file contains byte addresses while the AVR Studio debugger displays word addresses. You'll have to do the math to convert.

More information can be found in previous threads on the topic:
https://www.avrfreaks.net/index.p...
https://www.avrfreaks.net/index.p...

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net