cannot jump into arduino boot loader

怎甘沉沦 提交于 2019-12-13 07:08:14

问题


I want to jump from my application to the bootloader ( I load via bluetooth and have an application command to jump to the boot loader).

the following work :

void* bl = (void *) 0x3c00;
goto *bl;

or

asm volatile { jmp BOOTL ::}

asm volatile { .org 0x3c00
               BOOTL: }

(but code size grows to 0x3c00)

BUT, the most obvious option

asm volatile { jmp 0x3c00 ::}

does not (seems it does not even produce code }

Any idea why ?


回答1:


The question as stated is not clear, as to what is working and what is failing. And about your environment, which is important. That said I guess your stating the void and/or "jmp BOOTL" work as desired, but makes the code appear to be huge.

I tried it on Arduino IDE 1.0.5 and only saw less than a 1/2K of code. Note 16K or Huge.

void* bl = (void *) 0x3c00;

void setup()
{
  // put your setup code here, to run once:
}

void loop()
{
  goto *bl;  
  // put your main code here, to run repeatedly:

}

with a compile output of...

Binary sketch size: 474 bytes (of a 32,256 byte maximum)
Estimated used SRAM memory: 11 bytes (of a 2048 byte maximum)

I suspect your observation is that the linker is seeing the pointer out at 0x3C00 the location of the BOOTSECTOR (noting it is at end of code) So it only looks like it is huge. I suspect there is a lot of white space between you may want to use the "avr-objdump.exe -d output.elf" to see what it is actually doing, versus what you expect.




回答2:


0x3C00 is a 16-bit word address.

Use 0x7800 in GCC if you are using goto. GCC uses byte address (0x3C00 * 2 = 0x7800).

Example:

void *bl = (void *) 0x7800;
goto *bl;

will create the following assembly language (see *.lss output file):

c4: 0c 94 00 3c jmp 0x7800 ; 0x7800 <__stack+0x6d01>



来源:https://stackoverflow.com/questions/17694996/cannot-jump-into-arduino-boot-loader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!