Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Simple Flash Bootloader
PostPosted: Mon Jun 13, 2005 5:56 pm 
Offline

Joined: Sat Jun 04, 2005 3:37 pm
Posts: 17
Location: Goteborg, Sweden, Europe
I have made a simple bootloader from AT91SAM7S128

You can try it if you like...

Users manual:
Download [loader_sram/main.elf] into ARM using OCD Commander
Connect ARM (USART0) to PC (COM1)
Start PC software:
sam7bl.exe -port 1 -baud 115200 -chip 128 -write c:\.....\example.hex

Please tell me how i can improve it...

/Johan

Edit: attachment updated...


Last edited by strombom on Fri Jun 17, 2005 2:47 am, edited 7 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 5:42 am 
Offline

Joined: Tue Jun 14, 2005 5:28 am
Posts: 6
Location: Corona, CA, USA
In my opinion, it would be a big improvement if you did not use visual basic. Or at least include all the files needed to run it.

A command line interface app written in C would be nice.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 8:05 am 
Offline

Joined: Tue Apr 12, 2005 8:01 am
Posts: 22
Location: Denmark
Hi

I think it is a wery good application you have made.

Can you please tell me the name of the compiler you have used to make the code to the ARM.

One improvement would be to flash it over USB.

Regard
René

Keep working on the loader. :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 11:31 am 
Offline

Joined: Sat Jun 04, 2005 3:37 pm
Posts: 17
Location: Goteborg, Sweden, Europe
TommyBurger:
Here is an updated version that also includes visual basic runtime files:

Edit: url removed

I like visual basic because its so fast to make GUI-programs...

A question, how do I use the serial port under windows with c ?

reneske:
I will think about USB...

I used WinARM (GCC) to compile.

Right now I am thinking about how the interrupt vectors should work when I have a bootloader at the first part of the FLASH. Any ideas?

/Johan


Last edited by strombom on Thu Jun 16, 2005 11:21 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 5:15 pm 
Offline

Joined: Tue Jun 14, 2005 5:28 am
Posts: 6
Location: Corona, CA, USA
Here is a windows console app as an example of serial comm. It opens comm one at 19200, sends "Hello, World" then waits for keys and echos them back until the '~' char is received. Then the port is closed and the program terminates.

I hope this helps. Let me know if you want more example code. I have been looking for a simple flash loader for a while and appreciate your generosity sharing with us.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 5:27 pm 
Offline

Joined: Sat Jun 04, 2005 3:37 pm
Posts: 17
Location: Goteborg, Sweden, Europe
Thanks!

I will try to write a console based application...

What commands would be appropriate?

sam7bl.exe -write file.hex
sam7bl.exe -read fileout.hex

/Johan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 7:58 pm 
Offline

Joined: Tue Feb 15, 2005 10:29 pm
Posts: 10
Hi Strombom,

I am writing a bootloader too. I can't try you loader out because I do not have the same tools, by reading your source code, I have a few questions see if you can help.

1. Seems to me :wink: you load the Application at the entry flash address, after reset you application is running but how do you access the Bootloader again after you boot Application in?

2. how do you allocate memory for Bootloader and Application so the bootloader won't kill itself while flashing the application in?

3. Is it possible to compile both Bootloader and Application in one project and program them into flash at once?

4. If the Bootloader and Application have same CStartup routine but different initialization for const variable... possible to share the CStartup?

Regards,
Michael


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 8:05 pm 
Offline

Joined: Sat Jun 04, 2005 3:37 pm
Posts: 17
Location: Goteborg, Sweden, Europe
Currently I only have a bootloader in RAM, and exactly as you pointed out, it will die once you boot the FLASH software you just downloaded to the target...

I want to make a permanent bootloader in FLASH but i have the same problems as you... Using the same startup.S could be one solution, or one could simply specify the interrupt vectors and reserve a certain amount of space in the beginning of the flash region for the bootloader... I have never used an ARM before so this is new to me, GCC is also new to me :)

/Johan


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 15, 2005 1:46 am 
Offline

Joined: Sat Jun 04, 2005 3:37 pm
Posts: 17
Location: Goteborg, Sweden, Europe
TommyBurger: I have tried to use timeouts when dealing with the serial port, otherwise it hangs if you have not connected the target, but it does not work... any ideas about how to do this?

Here is my code so far...

Edit: removed


Last edited by strombom on Thu Jun 16, 2005 11:21 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 15, 2005 2:27 am 
Offline

Joined: Tue Jun 14, 2005 5:28 am
Posts: 6
Location: Corona, CA, USA
I see one problem. Line 126 has a memset to zero of commtimeouts, just after you set them up so nicely.

We might want to take this discussion offline. email me direct to tspiegel at sbcglobal.net. I also use AIM and Yahoo messenger.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 15, 2005 6:24 am 
Offline

Joined: Wed Jan 19, 2005 10:39 am
Posts: 28
Location: Russia
strombom wrote:
TommyBurger: I have tried to use timeouts when dealing with the serial port, otherwise it hangs if you have not connected the target, but it does not work... any ideas about how to do this?


Did you try to use some line for serial port. Such as DTR and so on ?

Probably it can help for you:

http://www.bds.dogma.net/pnp_part1.htm


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 15, 2005 12:19 pm 
Offline

Joined: Sat Jun 04, 2005 3:37 pm
Posts: 17
Location: Goteborg, Sweden, Europe
V. Shatunov: Actually I have already solved it, but thanks!

/Johan


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 15, 2005 6:44 pm 
Offline

Joined: Sat Jun 04, 2005 3:37 pm
Posts: 17
Location: Goteborg, Sweden, Europe
I have finished the command-line program

/Johan

Edit: removed


Last edited by strombom on Thu Jun 16, 2005 11:21 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 6:13 am 
Offline

Joined: Tue Jun 14, 2005 5:28 am
Posts: 6
Location: Corona, CA, USA
Success.

I had to recomplile because I am using AT91SAM7S64. It only has 128 bytes per page. I found a few problems.

The call to openPort still has a constant for the bit rate. Should be your variable baud.
In parseHex, tmpbuffer array should have length of 4 not two. Buffer overflow here.
In the "send data to flash" loop (around line 143, I may have altered line number a little) loop goes for 256, should go to SIZE_FLASH_PAGE. For your chip it is 256, for mine it is 128.

I am very happy. I am now able to put my programs copiled with winarm in the chip and run them.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 1:47 pm 
Offline

Joined: Sat Jun 04, 2005 3:37 pm
Posts: 17
Location: Goteborg, Sweden, Europe
Thanks for finding those bugs :) I will use an extra argument for chip-type

/Johan


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron