题目:为什么下面的函数被指定到来0xff00,函数如下:
void BOOTLOADER_SECTION boot_program_page(uint32_t address, uint8_t *buf)
{
uint16_t i;
uint8_t sreg;
// Disable interrupts.
sreg = SREG;
cli();
// eeprom_busy_wait ();
boot_page_erase( address );
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( address + i, w );
}
boot_page_write( address ); // 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;
}
答:留意到BOOTLOADER_SECTION描述在函数前面,这个不是C的东西,这个是哪里来的?后来对WINAVR GCC 安装目录搜索发现这个是编译环境定义了,如下:
WINAVR通过makefile给一个函数指定地址
那么只要给.bootloader指定地址这个函数就有地址了。
另看makefile如下:

Linker flags

LDFLAGS = $(COMMON)
LDFLAGS += -Wl,-Map=C106_BOOTLOADER.map
LDFLAGS += -Wl,-section-start=.bootloader=0xD000#0XFF00
LDFLAGS += -Ttext=0x7E00
所以给.bootloader指定了0XD000的地址。
所有可以给题中函数指定到0xff00的地址。

相关文章:

  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2022-12-23
  • 2022-12-23
  • 2021-04-15
  • 2021-11-30
猜你喜欢
  • 2021-11-22
  • 2021-07-19
  • 2022-12-23
  • 2021-10-04
  • 2022-12-23
  • 2021-09-18
  • 2021-04-09
相关资源
相似解决方案