Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
c4_esp
PostPosted: Jun 14, 2011 - 09:25 AM
Hangaround


Joined: May 03, 2011
Posts: 122
Location: Spain

Hi,

Yes...I want to delete all firmware in execution time...similar to format c: in windows or sudo rm -R / in linux OS, if this isn't possible, ¿Can we reserve RAM/ROM memory to write private data and then remove it?.

Thanks for all.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
danicampora
PostPosted: Jun 14, 2011 - 10:23 AM
Hangaround


Joined: Oct 10, 2007
Posts: 395
Location: Valls, Spain

Move the piece of code that performs the erasing to RAM space, resume execution from there (RAM), then erase the entire flash.

_________________
Daniel Campora
http://www.lear.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
c4_esp
PostPosted: Jun 14, 2011 - 10:43 AM
Hangaround


Joined: May 03, 2011
Posts: 122
Location: Spain

Hi danicampora,

Quote:
Move the piece of code that performs the erasing to RAM space, resume execution from there (RAM), then erase the entire flash.


It seems to be very dificult... Shocked

Do you have some little examples that show us how we can do this...?

Thanks for all.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
danicampora
PostPosted: Jun 14, 2011 - 11:22 AM
Hangaround


Joined: Oct 10, 2007
Posts: 395
Location: Valls, Spain

It is not that hard really, you need to link the erasing code to the RAM address you will be moving it, there is an App note on how to exute code from a external SDRAM, some of it applies for the internal RAM:

http://www.atmel.com/dyn/resources/prod ... c32160.pdf


I haven´t done it yet (RAM execution) with the AVR32 so I can't give you any example code, but there is plenty of people here in the forum that could help you more. Take a look at the ASF examples on the flash controller, there you will learn how to erase the flash, is all in the Framework API anyway.

_________________
Daniel Campora
http://www.lear.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
sma
PostPosted: Jun 15, 2011 - 12:14 PM
Posting Freak


Joined: Jan 14, 2007
Posts: 1836
Location: Nantes, France

Are you talking about RAM or flash erase?

-sma
 
 View user's profile Send private message  
Reply with quote Back to top
c4_esp
PostPosted: Jun 15, 2011 - 12:47 PM
Hangaround


Joined: May 03, 2011
Posts: 122
Location: Spain

Sorry, i thinks that i was talking flash memory, or in others words...maybe, internal memory of avr32...
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
sma
PostPosted: Jun 16, 2011 - 10:03 AM
Posting Freak


Joined: Jan 14, 2007
Posts: 1836
Location: Nantes, France

You can reserve a flash area in the linker script with a specific address/size. Then you can easily erase it with the flash controller page erase commands (applied to all pages in your area) (or simpler use the ASF flash_memcpy function to erase/write the flash).
Of course you need the functions you'll copy in this area to be correctly linked in the right section.

-sma
 
 View user's profile Send private message  
Reply with quote Back to top
c4_esp
PostPosted: Oct 31, 2011 - 02:04 PM
Hangaround


Joined: May 03, 2011
Posts: 122
Location: Spain

Hi again guys,

I return this topic, becouse now I have time to try to implement AVR32 formating.

Quote:
You can reserve a flash area in the linker script with a specific address/size. Then you can easily erase it with the flash controller page erase commands (applied to all pages in your area) (or simpler use the ASF flash_memcpy function to erase/write the flash).
Of course you need the functions you'll copy in this area to be correctly linked in the right section.


I try to erase all flash with this function,

Code:
if (flashc_erase_all_pages(TRUE)==TRUE)
      {      
      }


But it seems to be that program brake down, and later I view flash memory with JTAG and dont put FF data in all flash...

By the way, i don't understand this...

Quote:
Of course you need the functions you'll copy in this area to be correctly linked in the right section.


Any idea?

Thanks for all.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
krishnabalan
PostPosted: Nov 02, 2011 - 01:12 PM
Hangaround


Joined: Sep 08, 2010
Posts: 257
Location: India

Why don't you use a bootloader to erase your application ?
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
c4_esp
PostPosted: Nov 03, 2011 - 07:04 AM
Hangaround


Joined: May 03, 2011
Posts: 122
Location: Spain

Quote:
Why don't you use a bootloader to erase your application ?


And...how I can do this?, Any example or paper?.

Thanks
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jkuusama
PostPosted: Nov 03, 2011 - 11:18 AM
Hangaround


Joined: Sep 21, 2004
Posts: 212


Simple bootloader example: http://www.avrfreaks.net/index.php?name ... p;t=111102
 
 View user's profile Send private message  
Reply with quote Back to top
c4_esp
PostPosted: Nov 03, 2011 - 11:37 AM
Hangaround


Joined: May 03, 2011
Posts: 122
Location: Spain

Quote:
Simple bootloader example: http://www.avrfreaks.net/index.php?name ... p;t=111102


Quote:
Why don't you use a bootloader to erase your application ?


I was thinking about bootloader...bootloader is an application that it runs before any other application. Normaly in microcontroller is useful to autoprogram microcontroller from external memory (RAM, ROM, SD, etc...). In this case i dont have external memory and is imposible to me autoprogram my microcontroller.

In any case, i dont know if bootloader can switch between to diferents programs in flash memory and how i can put 2 diferent programs in flash.

Can we create a delete function, and then put this function in reserve flash memory (in last block in flash memory) and then delete flash memory sector by sector?.

I view somethig like that in this paper.

http://atmel.com/dyn/resources/prod_doc ... c32158.pdf

Thanks for all guys.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jkuusama
PostPosted: Nov 04, 2011 - 08:18 AM
Hangaround


Joined: Sep 21, 2004
Posts: 212


You can do that, by learning how the linker actually works. You can also have the erase function in the bootloader section of FLASH and jump into that from your main program, the approach would not be much different.

The easiest way might be to use an existing bootloader example and the way these work: The bootloader runs first and checks a certain FLASH location. If it doesn't contain a certain value, the bootloader jumps to the main routine. If the magic number is there, the bootloader writes the main FLASH. When the application program wants the update/erasure, it writes the magic number and resets itself by setting up the watchdog and not serving it.

If you don't care that this is not a complete erase (the cleaning routine remains) these are the easiest way forward. Once you figure out how to place a routine in a certain section in FLASH, you can also copy the routine from FLASH to RAM and run the suicide routine from RAM (jumping to a RAM routine just like jumping to a FLASH routine). Now, the erasure routine is still there but does not survive a power down. (A real geek would then erase the RAM in a way that the last location to go is the clear instruction itself, leaving behind a completely erased part.)
 
 View user's profile Send private message  
Reply with quote Back to top
c4_esp
PostPosted: Nov 04, 2011 - 10:07 AM
Hangaround


Joined: May 03, 2011
Posts: 122
Location: Spain

Hi jkuusama,

Bootloader appears a great method, but i don't know anything about how to compile bootloader in my UC3A and never do it in other microcontroller, all this is new for me and I have to learn step by step.

Do you know any paper, source code, tutorial, links or similar to implement bootloader in my UC3A?.

Thanks for all.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jkuusama
PostPosted: Nov 04, 2011 - 11:22 AM
Hangaround


Joined: Sep 21, 2004
Posts: 212


Atmel documentation and this forum. The link above has a simple source code example and some instructions, too.
 
 View user's profile Send private message  
Reply with quote Back to top
c4_esp
PostPosted: Nov 04, 2011 - 02:13 PM
Hangaround


Joined: May 03, 2011
Posts: 122
Location: Spain

Hi again,

I know, I'm such a pest, please be patient with me, I want to learn about bootloader's world.

I'm taking a look to bootloader.c (spi flash). One question about that...

Have I to programme my microcontroller with "bootloader program" in 0x80000000 flash position (by default), and then modify linker script to put "main program" in 0x80002000 flash position?.

Is it right?.

Thanks for all.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jkuusama
PostPosted: Nov 05, 2011 - 08:41 AM
Hangaround


Joined: Sep 21, 2004
Posts: 212


Yes.
 
 View user's profile Send private message  
Reply with quote Back to top
krishnabalan
PostPosted: Nov 05, 2011 - 08:15 PM
Hangaround


Joined: Sep 08, 2010
Posts: 257
Location: India

I dont know your exact need to erase the entire firmware but anyhow it can be done easily. UC3 devices have flash controller(Hardware module controlling flash) you just need to give erase commands to erase the flash contents. If you dont need any code to present in the flash (Even the bootloader) what you can do is write a simple function like kill_my_flash(). This function can just select all flash pages and give erase commands. For this function to execute while erasing flash it has to run from RAM. I dont know about AVR GCC compiler but in IAR compiler you can use __ramfunc keyword before your function definition such that the function will be copied to RAM for execution once you call that function which is residing in RAM you will be able to erase all flash contents (if flash is locked you need to unlock and erase it)

Cheers !!!
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
c4_esp
PostPosted: Nov 07, 2011 - 07:46 AM
Hangaround


Joined: May 03, 2011
Posts: 122
Location: Spain

Hi krishnabalan,

Thanks for your answare.

Now I try to implement this 2 ways (bootloader and put functions in internal RAM).

In last one, i was following AVR32795 application note, in this case 6.2 section.

http://atmel.com/dyn/resources/prod_doc ... c32158.pdf

But it doesn,t work, any idea?

Thanks for all.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits