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
Dbazinet
PostPosted: Mar 01, 2010 - 07:40 AM
Wannabe


Joined: Dec 23, 2008
Posts: 79
Location: Montréal, Canada

OK, I found it. I should use more often this forum so I could find more answers myself... I read this post (did not get my attention the first time) pointing on the memory settings.

Project menu
Configuration Options
Memory Settings
[Add]
Type = Flash (already selected)
Name = .text
Address = 0x1C00 (for example)
[OK]
[OK]

Thanks to Cliff.
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Mar 01, 2010 - 10:18 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England

1) No problem whatsoever

2) not that you have to but I'll just point out that JTAGICEmkII is also an ISP programmer and can be used very like an AVRISPmkII

3) that's EXACTLY what you should do - the BL should be a completely standalone program with its own reset vector, C pre-amble and main() function - so you build it just like any other program with the single change to the .text base address

4) Your --section-start *SHOULD* have worked (you may be interested to know that -Ttext=.... is shorthand for the same) however Studio can make this easier for you. Go to Config Options on the Project menu and select the fourth icon down on the left ("Memory settings"). Click [Add]. Leave type as "Flash". Enter ".text" for name and for the address the key thing is that this is "Atmel-speak" so the address must be in WORDS not BYTEs. You know your desired byte address is 0x3800 so half this to get the word address 0x1C00 and enter that.

The nett effect of (4) is that when the code links (avr-gcc invoked without -c) you should see that very same --section-start=.text=0x3800 that you were trying to use being passed. (in fact it will be interesting to hear how this differs from your attempt - maybe you had it on the compile rather than the link?)

Cliff

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
Dbazinet
PostPosted: Mar 03, 2010 - 05:30 AM
Wannabe


Joined: Dec 23, 2008
Posts: 79
Location: Montréal, Canada

Thanks you Cliif,

About 2)
I usually use the DW to program my devices when they only support DW (not JTAG mode like the Mega168). I have never been able to program or change the fuses with the ISP mode. I use a STK-600 to do that. Am I suppose to be able to program or set the fuses on a Mega168 with ISP?

3) That's what I've done, but because I had a hard time loading the program at the bootloadwr section, I though it could be an issue.

4) I do not have the set up here tonight, I will come back on it but now it works but I remenber that I saw the --section-start=.text=0x3800 after compiling. Is it in the complie or link section, I don't know.

Now I need to load some pages through spi (from RF an device, SI4432) and reprogram the Mega168. I may have more questions!

Thanks for your reply!

Dominic
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Mar 03, 2010 - 10:00 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England

2) yes, if in the connection box of AVR Studio for JTAGICEmkII you set the mode to "ISP" rather than "JTAG" then it should operate pretty much as any standard ISP programmer using the ISP pinout given in the user manual which rather confusingly refers to it as SPI rather than ISP (yes it's a form of SPI but it's usually called ISP because it may use different pins to an AVR's normal SPI). Table 3-3 shows which 6 wires from the "squid" cable to connect to the ISP header of the board being programmed:
Code:
JTAGICE mkII probe Target pins Squid cable colors SPI pinout
Pin 1 (TCK)        SCK         Black              3
Pin 2 (GND)        GND         White              6
Pin 3 (TDO)        MISO        Grey               1
Pin 4 (VTref)      VTref       Purple             2
Pin 5 (TMS)                    Blue   
Pin 6 (nSRST)      RESET       Green              5
Pin 7 (Vsupply)                Yellow   
Pin 8 (nTRST)                  Orange   
Pin 9 (TDI)        MOSI        Red                4
Pin 10 (GND)                   Brown


Cliff

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
sjackson
PostPosted: Jul 16, 2010 - 04:10 PM
Rookie


Joined: Apr 11, 2007
Posts: 38


So does the "non-commercial" part of the FAQ Creative Commons license mean I can't reference this FAQ for building my commercial application or I can't take the FAQ and resell it or any of its information for profit?
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jul 16, 2010 - 04:19 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England

If you are an author of a bootloader Brad and I hope that after reading this you'll have a better idea of how to go about it. Why would you need to either quote passages from the document or even attempt to sell bits of it simply to ship a device that contains a bootloader that has been authored as a result of the guidance here?

As it happens, for the parts I wrote you are welcome to use them freely and openly (I'm against restrictive licences like GPL and such myself and much prefer BeerWare/Free BSD etc). For other parts you'd need to contact Brad Schick to ask his permission. He no longer visits Freaks (AFAIK) but I can email him on your behalf and ask him to contact you if you want to PM me your email address.

(a PM to his ID here may trigger an email to him anyway)

Of course none of this precludes the copyright requirements of Atmel's Tutorial Forum which are given in the sticky at the top of this forum:

Tutorial Copyright

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
sjackson
PostPosted: Jul 16, 2010 - 04:24 PM
Rookie


Joined: Apr 11, 2007
Posts: 38


clawson wrote:
Why would you need to either quote passages from the document or even attempt to sell bits of it simply to ship a device that contains a bootloader that has been authored as a result of the guidance here?
Thanks for the reply.

I'm no licensing expert and was just curious if the licensing was meant to prohibit development of commercial software based on the FAQ or just copying all or part of the text as part of commercial documentaion (the latter of which I have no intention of doing).
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jul 16, 2010 - 04:35 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England

Oh no, I don't know about Brad but personally I see a LOT of similar questions cropping up here about bootloaders - often about code positioning and often about function sharing between the two halves and when Brad took the time out to try and nail some of these questions once and for all and then asked myself and others to contribute further questions and comment on/correct what he'd wrote I welcomed it in the hope that many times we could now just say "read the bootloader FAQ" rather than writing out the same --section-start=0xNNNN thing for the 1000'th time.

EDIT 1363 downloads of the .PDF suggest a bit more than 1,000 in fact!

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
Difool
PostPosted: Sep 09, 2010 - 10:12 AM
Newbie


Joined: Nov 24, 2009
Posts: 18


Quote:
That flag specifies the starting byte address of the bootloader. You can find this value in the datasheet for your AVR. Make sure you use the byte address and not the word address (most Atmel datasheets list word addresses for flash regions, but some list byte addresses).


How to recognize byte address and word address?
And how to transform a word address to a byte address ?

Thanks
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Sep 09, 2010 - 10:20 AM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18545
Location: Lund, Sweden

Quote:

How to recognize byte address and word address?

Generally, you cant discern a byte address from a word address. You just need to know the context when reading: Eg, by knowing that Atmel likes to use word addresses in most cases. Or by recognizing something you know the address of (and the actual address used is double or half of that). Etc...

Quote:
And how to transform a word address to a byte address ?

Multiply by 2 (or shift left one position, if you prefer).
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
clawson
PostPosted: Sep 09, 2010 - 10:31 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England

You know that the four BOOTSZ1:0 are going to select a region within 4K of the end of the chip. So take a mega328 as an example. You and I know that this has 32K BYTES of code flash. Atmel would tell you that it can hold 16K opcodes because they are 16bit WORDS. An Atmel Word is 16bits so if you talk about addressing in Words rather than 8bit bytes you halve the address. Thus the word address 0x1F27 is byte address 0x1F27*2 = 0x3E4E

Now if you dig out the 328 datasheet and look at the table that sets out the four BOOTSZ combinations. It shows:
Code:
BOOTSZ1 BOOTSZ0  Boot Reset Address (start BLS)
   1       1             0x3F00
   1       0             0x3E00
   0       1             0x3C00
   0       0             0x3800 (default)

But wait a minute, you, I and GCC think it terms of bytes, not words when talking about memory sizes and addresses. We know the 328 has 32K bytes and 32K in hex is 0x8000 with addresses 0x0000 to 0x7FFF. Yet those Atmel listed addresses are down around the 0x3??? range. So they cannot be anywhere near the last 4K of the chip as we expect BOOTSZ to be. So they must be words. So to convert to bytes double them:
Code:
BOOTSZ1 BOOTSZ0      Address (words)      Address (bytes)
   1       1             0x3F00            0x7E00 = 31.5K
   1       0             0x3E00            0x7C00 = 31K
   0       1             0x3C00            0x7800 = 30K
   0       0             0x3800            0x7000 = 28K

Obviously this example applies to a 32K AVR but I guess you can see the way to interpret things for any size of AVR. Consider it's size in bytes as a hex value. If the BOOTSZ positions you are looking at appear to be half these values they are words and need to be doubled. Use the resulting byte addresses with GCC.

NOTE: If you use AVR Studio and under "Configuration Options" need to specify a memory section address (such as positioning .text to the BLS address) then being Atmel it uses WORD addresses so for the 328 and BOOTSZ=10 you would specify 0x3E00 though when the code is built by WinAVR(gcc) you will note that it's actually 0x7C00 that is passed because Atmel know to double the value before passing it to GCC.

Cliff

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
Difool
PostPosted: Sep 09, 2010 - 01:59 PM
Newbie


Joined: Nov 24, 2009
Posts: 18


Ok, I see.
Thank you for these very clear explanations.
 
 View user's profile Send private message  
Reply with quote Back to top
superAssembler
PostPosted: Oct 14, 2010 - 02:54 PM
Newbie


Joined: Oct 14, 2010
Posts: 17


Dear schickb
Sorry, I feel like blind. Where is the pdf? How can I download it? I see everybody sees it why can't i? Embarassed

_________________
Smile...
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Oct 14, 2010 - 03:56 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England

This board only lets you see/download attachments when you are logged in. Given that you had to login as superAssembler to make that post did you not then see the file while logged in?

Cliff (moderator)

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Oct 14, 2010 - 04:03 PM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18545
Location: Lund, Sweden

Quote:

Sorry, I feel like blind. Where is the pdf?

In the first post, on the first page of this thread. The post has the TOC of the FAQ as it's text, and below that text there is a box with the heading "bootloader_faq.pdf", and in that box, to the right, is a link "Download".

Or did you look for it before you signed up and logged in, but not afterward? If so, then go back now and it will be there.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
superAssembler
PostPosted: Oct 14, 2010 - 04:32 PM
Newbie


Joined: Oct 14, 2010
Posts: 17


Yes, it's ok now. The text gets out of the screen, and when I scrolled right I saw it. Thank you

_________________
Smile...
 
 View user's profile Send private message  
Reply with quote Back to top
js
PostPosted: Oct 14, 2010 - 10:52 PM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20353
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

Darn..I wish I had thought of that name. Confused

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
JohanEkdahl
PostPosted: Oct 15, 2010 - 06:46 AM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18545
Location: Lund, Sweden

We still have "superC" free, John. Go grab it! Wink
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
js
PostPosted: Oct 15, 2010 - 06:53 AM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20353
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

I had another great name but can no longer access it as it was part of the Beta site test. Wink

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
superAssembler
PostPosted: Oct 15, 2010 - 06:22 PM
Newbie


Joined: Oct 14, 2010
Posts: 17


Well, it's just a name, no much connection to the reality. Like the cape of good hope! Smile
Try UltraAssembler

_________________
Smile...
 
 View user's profile Send private message  
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