View detail for Atmel AVR947: Single-Wire Bootloader for any MCU with Self Programming Capability

Add to my manuals
19 Pages

advertisement

View detail for Atmel AVR947: Single-Wire Bootloader for any MCU with Self Programming Capability | Manualzz

7.1.2 Linker file changes

The provided bootloader is based on the Atmel ATMEGA16HVA, so it is based on this device’s default linker file

modified as explained in Section 1.2.1

. To port this bootloader to another device, similar changes would be required in the selected device’s default linker file.

7.1.3 System clock

The provided bootloader must be run at the 4MHz system clock. As the target application may run at any system clock, the bootloader should set its clock by modifying the clock register settings as part of its init code. For example, for the

ATMEGA16HVA, the system clock is set to 4MHz by adding the following lines of code in the provided bootloader firmware:

CLKPR = (1<<CLKPCE);

CLKPR = 0x01;

For any other device, make sure that this code is replaced by an appropriate code to set the system clock to 4MHz.

7.2

Note:

Note:

Target application software

To be able to be used with the bootloader, there are some configuration changes that are needed in the application firmware. Normally these files are automatically included from their default locations by the compiler, but as we are using modified versions, these three files must be included manually. The files are already provided in the software package accompanying this application note. The files are:

1.

2.

3.

Linker file.

Cstartup.s90 file. macros.m90.

The changes made in these files are explained next.

To use a custom linker file, right click the project, go to options, under the linker tab, set the checkbox for “Override default” and set the linker file location.

To add Cstartup.s90, right click the project, go to Add->Add files and select the Cstartup.s90 file. The macros.m90 file is a dependency on the Cstartup.s90 file and does not need to be included in the project. It just needs to be in the same folder as the Cstartup.s90 file.

7.2.1 Linker file setting for reserving flash used for bootloader

In the application, the higher side of the program memory needs to be reserved for the bootloader firmware (see

Figure

1-1 ). The bootloader start address is fixed and hardcoded in the bootloader firmware. The available application memory

cannot overlap the bootloader segment; hence it needs to be carefully defined in the application linker file. For example, in the given bootloader source code, the bootloader starts at 0x3A00, hence the application accessible flash memory must end at 0x39FF even though it is a 16K device. This can be done by modifying the flash end addresses in the linker file.

For example, for the ATmega16HVA device (16K flash), the following changes can be made in the linker file to reserve the bootloader segment from 0x3A00-0x3FFF.

-D_..X_FLASH_NEND=39FF /* End of near flash memory */

-D_..X_FLASH_END=39FF /* End of flash memory */

These changes make the last 1.5KB (0x3A00 – 0x3FFF) of flash inaccessible to the linker. If the application compiled binary is bigger than 14.5K, the linker will generate an error.

7.2.2 Linker file setting for preserving one byte in EEPROM used for bootloader flag

One byte of EEPROM byte (preferably last byte) needs to be reserved for storing the EEPROM bootloader flag.

Atmel AVR947: Single-Wire Bootloader for any MCU with Self Programming Capability

[APPLICATION NOTE]

42034A −AVR−10/2012

16

advertisement

Was this manual useful for you? Yes No
Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Related manuals