orempel / twiboot

AVR bootloader over TWI/I2C
GNU General Public License v2.0
38 stars 20 forks source link

twiboot timeout issue #6

Open MS71 opened 3 years ago

MS71 commented 3 years ago

Hi, i ported twiboot to my Tiny84 target. So far, it is working. I am able to download the code and start a small demo application via the I2C command.

Unfortunately, it is not starting without any I2C communication (timeout). Any hint?

For debugging, i added some fast LED toggling just before jump_to_app(); The problem, is, that my app code is just not working, when it is started by timeout.

Additional, i think there is a concept error with the appvect_save variable. I think, the appvect_save & rstvect_save are initialized with the wrong value in main. When I check/compare without writing it, then i get a mismatch with the original code.

I think, it should be: rstvect_save[0] = buf[APPVECT_PAGE_OFFSET]; rstvect_save[1] = buf[APPVECT_PAGE_OFFSET + 1]; appvect_save[0] = ?; appvect_save[1] = ?;

I added a simple CRC16 checksum query. This is very useful doing a quick code compare without read the entire flash to the master.

Later, i like to add support for the AT Tiny841 too. This device has a different I2C slave implementation.

Shall i provide a pull request for this?

Maik

orempel commented 3 years ago

Moin, without seeing your code changes I would guess that the HW timer is not running correctly and thus never setting "cmd = CMD_BOOT_APPLICATION" in TIMER0_OVF_vect. Might be an overflow in the TIMER_MSEC2TICKS / TIMER_MSEC2IRQCNT calculation if you have changed the default values for those.

There is no concept error in the virtual boot handling: Verify is only possible after flashing, since the RESET vector and the "app" vector (EE_RDY by default) are patched while writing:

This is required to start twiboot before the user application without having a bootloader section. It implies that the "app" vector must never be used by the application since it is used by twiboot.