poipoi09876 发表于 2011-12-1 09:06:00

紧集有偿求助,大家好,请教一下,bootloader在avr studio(gcc)的环境下配置问题,我用是meg

请教一下,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的

有大牛会吗?可付报酬,qq私聊:374933900

poipoi09876 发表于 2011-12-1 09:16:15

有大牛会么?薪酬比很高!qq:374933900

poipoi09876 发表于 2011-12-3 13:08:01

问题已经解决,上面的程序可以执行,问题出在project->configuration options->memory settings
点击 memory segments中add
第一个填“flash”
第二个填“.text”,这个表示是text
第三个填“0xfc00”,其实填其他的0xf800,0xf000都可以,但是注意要和熔丝位设置的一致才行

其实是老问题了,只是我是新手而已,呵呵,不好意思啊
页: [1]
查看完整版本: 紧集有偿求助,大家好,请教一下,bootloader在avr studio(gcc)的环境下配置问题,我用是meg