|
大家好,求助,急,bootloader在avr studio(gcc)的环境下配置问题,我用是mega128
[复制链接]
大家好、请教一下,bootloader在avr
studio(gcc)的环境下应该怎么配置呀?我用是mega128
这几天上网找了很多的资料(包括马潮老师,傻孩子老师,shaoziyang老师的帖子)也看了大家的讨论,ICC下的bootloader已经实现。但是avr
studio(gcc)始终不行。 我主要代码如下,其中写flash代码是来自于http://www.nongnu.org/avr-libc/user-manual/group__avr__boot.html
unsigned char data1[]={…………………………………………};//这个是我希望用bootloader 写入的数组
void boot_program_page (uint32_t page, uint8_t *buf) //来源于avr-libc的范例
{ uint16_t i; uint8_t sreg; // Disable interrupts.
sreg = SREG; cli(); eeprom_busy_wait ();
boot_page_erase (page); boot_spm_busy_wait (); // Wait until the memory
is erased.
for (i=0; i<SPM_PAGESIZE; i+=2) {
// Set up little-endian word.
uint16_t w = *buf++; w +=
(*buf++) << 8; boot_page_fill (page + i, w); }
boot_page_write (page); // Store buffer in flash page.
boot_spm_busy_wait(); // Wait until the memory is written.
//
Reenable RWW-section again. We need this if we want to jump back // to the
application after bootloading.
boot_rww_enable ();
//
Re-enable interrupts (if they were ever enabled).
SREG = sreg; }
void main()//主函数,调用上面的函数,将数组写入对应的地址 { …… address=0x0000;
boot_program_page(address,data1); …… }
我的BOOTSZ1和BOOTSZ0都是取默认的0,即4096words, 32 pages;应用区0000~EFFF;
boot:F000~FFFF直接在avr studio里面选好就行了。 同时BOOTRST也是默认,返回到0000;
另外,原来的帖子中写到需要在makefile 里面加上LDFLAGS =
-Wl,-Map=$(TARGET).map,--cref,--section-start=工程名.text=0x1F000 但是这样不能写入。
或者,在memory 中设置memory:flash name: 工程名.text
address: 0x1F000 也不成功。另外我尝试的地址有0x1e000也不行
lib中的代码应该是没问题的,我想请教大家,avr studio中具体的应该怎么设置啊?关于mega128的
|
|