The Aegis key generation happens the first time a device boots after a clean flash, before user is presented with the UI of the device. Hence, it is important to make sure that the device boots up in Open Mode the first time after flashing. The way to accomplish this is what I call back-to-back flashing.