MEGA65 / mega65-core

MEGA65 FPGA core
Other
240 stars 85 forks source link

MEGAFLASH: add JTAG-less slot 0 flashing option #625

Closed lydon42 closed 6 months ago

lydon42 commented 1 year ago

If slot 0 is erased, a slot 1 core will still be booted after 30 seconds of searching. This also happens if only the start of slot 0 is erased, or some piece inside slot 0. My tests always ended up booting slot 1 after a short while.

So we could make a slot 0 flasher by requiring a good core in slot 1 and asking the user if he is able to start the system from slot 1.

This would enable us to add the Slot 0 flash function as a official function to the integrated flasher.

Checks:

Questions to be answered: I am aware that I VOID my warranty if I flash slot 0 without a JTAG interface I hereby CONFIRM that I am able to boot the system by selecting slot 1 from the flash menu The user needs to type yes to both of them and confirm each entry with return. Alternative he could also be required to type VOID and CONFIRM for some more variation... We (deft, martin, I) are positive that this will be enough to not be accidentally triggered. In addition the Slot 0 Flash functions stays on the (currently secret) MEGA-something combination, so that it is not triggered by accident.

So in total three prerequisites need to be fulfilled and the user needs to confirm two question by typing YES

Recovery: if slot 0 is broken because of some mishap, the system will boot slot 1 in a short while and you can use NO-SCROLL to enter the Slot 1 flasher. Edit: this is not entierly true, Paul corrected that the first sector needs to be erased so that happens. If an later sector would be erased, the system will still be unrecoverable without a JTAG.

dansanderson commented 1 year ago

We should avoid implying the existence of a warranty if there isn't one. I think we just want to emphasize that this is a technically complicated procedure that may fail, and failure will require a recovery process.

You are about to replace the core in slot 0. Do not turn off your machine or interrupt this process.

If the process is interrupted or the replacement fails in some way, your MEGA65 will not boot normally: it will blink blue lights for 30 seconds, then boot to core 1. You can restart the core 0 flashing process by holding the NO SCROLL key during these 30 seconds.

It appears you have a MEGA65 core installed in slot 1. You should test that the core in slot 1 boots correctly before proceeding.

Type "I UNDERSTAND" to confirm that you understand this message, or press Return to abort: [I UNDERSTAND] Type "CONFIRM" to confirm that you are able to boot the core in slot 1, or press Return to abort: [CONFIRM]

lydon42 commented 1 year ago

Three words: to many characters! Please condense you proposal so it fits 40x25, but less would be better, as there is not much space left!

Edit: we could do the long version if we don't do it in the core flasher but with a PRG... that also means that I remove all slot 0 flashing from the core flasher. Also fine with me.

dansanderson commented 1 year ago

CleanShot 2022-10-04 at 15 27 52

You are about to replace core 0.

If this process fails or is interrupted,
core 0 will fail to boot and MEGA65 will
blink blue lights.

If this happens, hold the NO SCROLL key
for 30 seconds to restart this process.
This requires a working MEGA65 core in
slot 1.

Be sure to confirm that core 1 works
before proceeding!

  * I have read and understand this
    message.

  * I have tried booting with core 1
    and it works.

  Type CONFIRM to proceed, or press
  Return to abort: CONFIRM_
dansanderson commented 1 year ago

If you need fewer bytes, let me know how many bytes you're willing to spare. :)

lydon42 commented 1 year ago

Looks nice on the screen! And if we go with JTAGFLASH.PRG instead of integrating it into the CORE, the space situation is much better!

lydon42 commented 1 year ago

Info from Paul about recovery (from discord):

depends exactly what is left in slot 0. If the fpga init block is gone it will work. If it's there it will run off into lala land. Should be in first 8kb, I believe. You can only erase whole pages = 256kb with the r3a flash

lydon42 commented 1 year ago

Extra ideas:

lydon42 commented 11 months ago

This is in 683-cartflash but still needs finishing touches.