regarding our discussion yesterday...
a minor related bug is that erase_and_write_flash would report success if there is no single "ok" eraser (in the patched version). it would return the initial value of ret, which is 0. we should never reach this point, because we check for this in chip_safety_check, but it would not hurt if we initialize ret = 1 imho.