Skip to content

What is the purpose of erasing in banzai() #197

Open
@keestux

Description

@keestux

Hi,

In commit dd50d5c the 1200bps touch feature was added. But not only that, the code also erases the Reset vector (and thus it "self destructs") before doing a soft reset.
After the reset it enters the bootloader. The bootloaders sees no program and it will hang in there until a new program is uploaded.

Take a look at Reset.cpp, there is the function banzai. It is called (indirectly) from the the ticks handler. And this is initiated from CDC.cpp function CDC_Setup.

My question: What is the reasoning to "Erase application" before doing a reset?

Let me already give my opinion about it :-)
I find this code unnecessary, because it should be the task of the bootloader to erase (and load a new program)
Even if you want to be able to force the bootloader to stay in "bootloader mode", it should be possible to use the "double tap" trick that the bootloader itself uses, namely set the magic word (0x07738135) at address 0x20007FFC. I did some experimenting and it works perfectly well.

I find the current behaviour unwanted and maybe even a bit dangerous. Suppose there is a run-away pointer that changes the variable static int ticks in Reset.cpp, as soon as ticks is back to zero your program will be erased.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions