Hello everyone, my first post here. I have been studying the bootloader code and am trying to better understand how the bootloaders work. I notice in all the Arduino bootloaders, the following line starts executing the user's sketch after the bootloader code is complete:
'app_start' is simply a function pointer, defined as
void (*app_start)(void) = 0x0000;
My question is this: Does this method of calling the user sketch waste a few bytes of stack space (i.e. RAM)? I am assuming the function call pushes the address of the bootloader main() function onto the stack, as well as the values of any local variables declared within main(). And since the flow never returns to the bootloader code, these values would never get popped back off the stack, thus permanently wasting several bytes of RAM.
Would it be more economical to add some in-line assembly to simply jump to address 0x0000 to avoid pushing local variables, etc.? Or is the compiler smart enough to see that there will never be a return to main() and it doesn't bother with these values?
I realize a few bytes are not that critical, but for some applications where the user is pushing the little MCU to its limit, every byte can count.
Expert enlightenment is greatly appreciated.