MEGA65 / mega65-tools

Tools and Utilities for the MEGA65 Retro Computers
GNU General Public License v3.0
30 stars 33 forks source link

bit2core: guard against sync word patterns in core data (at least for factory cores) #189

Closed lydon42 closed 6 months ago

lydon42 commented 9 months ago

It is possible that bitstream data and or attached files could contain the magic sync word (aa995566) which gets the FPGA to load the following data as a bitstream. This breaks the slot 0 recover mechanism.

We must guard against this:

lydon42 commented 9 months ago

Checking the bitstreams test builds in my local working copy, only 3 of 82 bitstreams have the sync word in the bitstream data. So the probability of getting a "contaminated" bitstream is quite small.

lydon42 commented 9 months ago

New idea needed: cores can have multiple sync words. There is no way to predict them or remove them. So we need a method for MEGAFLASH to get rid of those first.

For this bit2core saves a list of max 15 sector positions (64k granularity, so 0x00-0x7f) to 0xf0-0xff in the core header, and sets bit 6 in the install flags to inform about this list.

MEGAFLASH then can first erase those sectors, before starting the full erase.