Custom Bootloader AT32UC3A3

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

Hello everyone

I am trying to write my own custom bootloader. Here is what I have managed so far:

- Downloaded the Software Framework

- Imported the "AVR-UC3-SoftwareFramework-1.7.0\1.7.0-AT32UC3\SERVICES\USB\CLASS\DFU\EXAMPLES\ISP" example code

- Edited the isp.c and isp.h files.

 

I am working with an AVR AT32UC3A3.

What I want to do is change the bootloader to set a few GPIO pins to high during boot up. I want to JTAG the micro once, and from there on, it should always pull these pins high and then execute the application code. As stated earlier I have successfully modified the isp.c and isp.h files, now when I build this, I end up with a 22MB file instead of an 8kB file. How do I go about compiling this code and not ending up with such a massive file?

Any advice would be much appreciated. If you require more information from me, please let me know.

Thank you

PS

I have looked at this forum thread: https://www.avrfreaks.net/forum/a... but couldn't find what I was looking for.

This topic has a solution.

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

Just a quick update.

So I learnt that one should not use AVR32 Studio to compile the .elf file, but rather GCC or IAR. Now my question is, how does one go about this? Is there a tutorial somewhere on how to do this?

Thanks in advance

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

So I learnt that one should not use AVR32 Studio to compile the .elf file, but rather GCC or IAR.

That sentence does not make sense. AVR32 Studio used a copy of GCC?!?

 

The situation is this. avr32-gcc is an ongoing development, like all versions of GCC, over time it gets better and better (and rarely a little worse). So if you choose to use GCC the question becomes - "what's the "best" version?". A recent one would presumably be the obvious answer. Now AVR32 Studio dates from a a few years back. When Atmel first made an IDE for AVR32 they made it cross platform in the form of AVR32 Studio with a copy of avr32-gcc. Later they did a deal with the devil and decided to go Windows only with AVR Studio 5 that was based on Microsoft's Visual Studio 2010. Again the compiler was avr32-gcc. Later this became Atmel Studio 6 and that has avr32-gcc too.

 

So if you want to work with GCC for AVR32 the kind of obvious choice would be the recent versions of Atmel Studio 6. HOWEVER it is Windows only. So if you run another OS like Linux or OSX then you can still pick up a copy of avr32-gcc built for those machines but you will need to find a different IDE to wrap around it. Eclipse or Code::Blocks would be possibilities but I guess an old copy of AVR32 Studio - because it was cross platform is another way to go too. If you do you probably want to ensure that the underlying avr32-gcc is up to date.

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

Hello clawson

Haha, love the profile pic, anyway thank you for your response. Sorry what I meant to say is, using AVR32Studio to compile the .elf file I end up with the 22MB file instead of the 8KB file, but I have made some progress with this.

 

I managed to get AVR32Studio to compile the .elf file (although its 22MB). I then took this file and ran the following command "avr32-objcopy -O ihex inputFile.elf outputFile.hex" this created a hex file that was 22kB, I then ran "avr32-objcopy -I ihex -O binary inputFile.hex outputFile.bin" and now have a 9KB bin file. Now the Bootloader area is only 8KB, how does one go about changing the size of this?

Last Edited: Tue. May 19, 2015 - 09:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To reduce the size of the .elf file ;
1) enable compiler compiler optimisations to reduce the code-size, (usually by compiling in 'release' mode),
2) remove the symbolic debug information. (project properties-> toolchain -> linker -> omit all symbol information)

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

Also if you are preparing a .bin file surely that is the APPLICATION payload to be delivered to the bootloader to be programmed? Not the bootloader itself? I doubt there's any 9K limit on application code size.

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

That 8 kbyte bootloader size is the default BOOTPROT fuse setting.

The UC3A3xx can have a bootloader of size 0,1,2,4,8,16,32 or 64 kbytes.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello mikech

I have increased the bootloader size by programming the general purpose fuses, its currently set to 0xFFF5FFFF (increased the bootloader size to 16kbytes). Now the interesting thing is, my code starts up nicely and everything works, but when I want to go back into DFU mode, I get really odd behaviour (its like its restarting the application code constantly). I try to go into DFU mode by sending it a serial command and in this function I followed these instructions:

 

https://www.avrfreaks.net/forum/u...

Any thoughts to why this might be happening would be greatly appreciated.

Thank you for all the feedback so far

 

UPDATE #1:
So I have learned that the default DFU bootloader that is on the AT32UC3A3256 is v1.0.3. Now I have been using the Software Framework v1.7.0, and the DFU example that is given in there is v1.1.0. Now I assume the source code the v1.0.3 is based on, is in the Software Framework v1.6.1 but I am unable to find this anywhere. Is it possible that anyone has a copy of this? This will enable me to modify the default v1.0.3 DFU bootloader, and see whether I get different results when trying to re-enter DFU mode.

UPDATE #2:

I managed to find a copy of AVRStudio32 v2.5 and installed that (it uses Software Framework V1.6.0) which has the v1.0.3 DFU Bootloader sourcecode (grabbed it from "SERVICES\USB\CLASS\DFU\EXAMPLES\ISP", I modified it to turn on a few GPIO pins and have modified BOOTPROT fuses so the bootloader size can be 16 kilobytes. I flashed by application code onto the micro and it all runs well. I am just still having issues when trying to enter DFU mode again. When I flash the default bootloader and application code I am able to enter DFU mode. I have changed in the isp_conf.h file the PROGRAM_START_OFFSET to 0x80004000 (default value is 0x80002000). Is there something else I have to do when changing the bootloader space? 

UPDATE #3:
I have learnt that the BOOTPROT fuses weren't actually being set (I verified the fuses making use of JTAGICE-MKII), they are now being set. I successfully increase the bootloader size, however the application code now doesn't seem to execute. I have changed the PROGRAM_START_OFFSET in conf_isp.h to 0x00004000, but this didn't seem to change the behaviour.

UPDATE #4:
The default "link_at32uc3a3-isp.lds" has the line "FLASH (rxai!w) : ORIGIN = 0x80000000, LENGTH = 0x00040000", and I changed it to "FLASH (rxai!w) : ORIGIN = 0x80000000, LENGTH = 0x00004000" and it solved my issue smiley

Last Edited: Mon. May 25, 2015 - 09:32 PM