static async Task AlterLockAsync(this Samba nxt, int regionNum, Commands cmd) { var w = 0x5A000000 | (uint)((64 * regionNum) << 8); w += (uint)cmd; await nxt.WaitReadyAsync(); /* Flash mode register: FCMN 0x5, FWS 0x1 * Flash command register: KEY 0x5A, FCMD = clear-lock-bit (0x4) * Flash mode register: FCMN 0x34, FWS 0x1 */ await nxt.WriteWordAsync(0xFFFFFF60, 0x00050100); await nxt.WriteWordAsync(0xFFFFFF64, w); await nxt.WriteWordAsync(0xFFFFFF60, 0x00340100); }
public static async Task FlashPrepareAsync(this Samba nxt) { // Put the clock in PLL/2 mode await nxt.WriteWordAsync(0xFFFFFC30, 0x7); // Unlock the flash chip await nxt.UnlockAllRegionsAsync(); // Send the flash writing routine await nxt.SendFileAsync(0x202000, Nxt.Flash.Bin); }
static async Task FlashBlockAsync(this Samba nxt, uint blockNum, byte[] buf) { // Set the target block number await nxt.WriteWordAsync(0x202300, blockNum); // Send the block to flash await nxt.SendFileAsync(0x202100, buf); // Jump into the flash writing routine await nxt.GoAsync(0x202000); }