> -----Original Message----- > From: Thomas Richter [mailto:[EMAIL PROTECTED] > Sent: Friday, March 09, 2007 7:00 AM > To: Eric Weddington; avr-chat > Subject: Re: [avr-chat] ATmega2561: bootloader can not write > in application section > > Hi Eric, > > > Ok, here are the obvious questions: > > > > How did you declare the prototype to writeFlashPage() > above? Did you put it in it's own named section (.bootloader)? > > > the bootloader was putted at 0x1F000 with following LDFLAG in > Makefile: > LDFLAGS += -Wl,--section-start=.text=0x1F000 > > Did you relocate the .bootloader section to the correct address? > >
Again, this is a problem with the datasheets that causes much confusion: On page 325 of the mega2561 datasheet, table 145, the "Boot Size" column gives the size in WORDS (word = 16 bits). Consequently, all of the addresses given in table 145 are WORD addresses. GCC (and the other compilers as well) does everything in BYTE addresses. So basically if you refer to those addresses in that table, you have to multiply them by 2 to convert them from a WORD address to a BYTE address. This has been a historic problem with all of the AVR datasheets, as programmers don't really care how many WORDS are in the bootloader. It's usually only IC designers that think in WORDS. Most software engineers (and consequently the compilers) think in terms of bytes. It also makes it difficult because there isn't a clear note in the datasheets that specify unequivocally that the addresses given in the tables are WORD addresses. The end-user has to infer it from doing the actual calculations and wondering why things don't match. What this means is that you relocated your .bootloader section to 0x1F000, which is incorrect for a mega2561. Multiply that address by 2 to get 0x3E000 and put your .bootloader section there. Assuming your fuse settings below are correct (I didn't verify them), then you should have better results. > The Bootloader program works fine. I could read and write to UART0 > interface and do read options to flash sections. > > > What address did you relocate it to? > > > I call the function with the address 0x0000. > > > Do you have the correct fuse settings for the size of the > bootloader area? > > > > > Here are my fuse settings: > lfuse = 0xFF > hfuse = 0x91 > efuse = 0xFE > Good luck! Eric Weddington _______________________________________________ AVR-chat mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/avr-chat
