4
\$\begingroup\$

I am in a need of programming a bootloader code written in C into the boot section of AVR ATmega32A using a serial programmer. I can't write the code directly into the boot section from Atmel studio. So, I am looking for a way here. Also, is there any good way of combining application code and Boot code and write them in respective sections using C program?

JYelton
35.7k34 gold badges149 silver badges281 bronze badges
asked May 29, 2014 at 11:12
\$\endgroup\$
6
  • 2
    \$\begingroup\$ Last time I wrote an AVR bootloader was before Atmel Studio but just having a quick I think you should be able to do it under project properties | Toolchain | AVR/GNU Linker | Memory Settings. Normally if I want them combined I do the bootloader, use it to load and then read back the result. \$\endgroup\$ Commented May 29, 2014 at 11:29
  • \$\begingroup\$ Yes. I can see the option there, but its really confusing \$\endgroup\$ Commented May 29, 2014 at 11:38
  • \$\begingroup\$ I am really confused with .text and .boot. Also that boot section only take last 512 words,so from where 1234 is coming. Please tell me where to look at for your old project. \$\endgroup\$ Commented May 29, 2014 at 12:01
  • \$\begingroup\$ Ok so i need to replace it with boot section address of Atmega32A. Right am I? \$\endgroup\$ Commented May 29, 2014 at 12:11
  • \$\begingroup\$ I am getting an error "File contents does not map to any valid device memory for programming Flash" when i include .text. when replace it with .boot it works, but writing from the same 0x00 address. \$\endgroup\$ Commented May 29, 2014 at 13:11

1 Answer 1

3
\$\begingroup\$

The ATmega32A Datasheet on page 245 shows the following table of where the bootloader area starts depending on how the BOOTSZ fuses are set:

ATmega32A boot size configuration

So assuming you have BOOTSZ0 and BOOTSZ1 are both cleared for the largest bootloader section it will start at 0x3800. From the memory sections documentation you can see the code goes into the .text linker segment and the address may be changed by going under Project properties | Toolchain | AVR/GNU Linker | Memory Settings and adding .text=0x3800 under the FLASH segment section:

Atmel Studio FLASH segment for bootloader

Normally if I want the bootloader combined with the application firmware for production programming I use the bootloader to load the main firmware and then read back the result from FLASH. It should be technically possible to combine them using custom linker segments but you'd have to be very careful about where things like standard library functions were placed so the former method is probably easier and safer.

answered May 30, 2014 at 9:58
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.