public void QueueRegionProgramming(List <CustomStartStep> cmds, ProgrammableRegion region) { cmds.Add(QueueInvocation(1, region.Offset.ToString(), region.Size.ToString(), null, 0, 0, false, string.Format("Failed to erase the FLASH region starting at 0x{0:x}", region.Offset))); for (int off = 0; off < region.Size;) { int todo = Math.Min(region.Size - off, DataBufferSize); int alignment = 4; int alignedTodo = ((todo + alignment - 1) / alignment) * alignment; cmds.Add(QueueInvocation(2, (region.Offset + off).ToString(), alignedTodo.ToString(), region.FileName, off, todo, false, string.Format("Failed to program the FLASH region starting at 0x{0:x}, offset 0x{1:x}, size 0x{2:x}", region.Offset, off, todo))); off += todo; } }
public void QueueRegionProgramming(List<CustomStartStep> cmds, ProgrammableRegion region, int eraseBlockSize, bool eraseStage) { if (eraseStage) { int eraseSize = ((region.Size + eraseBlockSize - 1) / eraseBlockSize) * eraseBlockSize; cmds.Add(QueueInvocation(1, region.Offset.ToString(), eraseSize.ToString(), null, 0, 0, false, string.Format("Failed to erase the FLASH region starting at 0x{0:x}", region.Offset))); } else { for (int off = 0; off < region.Size;) { int todo = Math.Min(region.Size - off, DataBufferSize); int alignment = 4; int alignedTodo = ((todo + alignment - 1) / alignment) * alignment; cmds.Add(QueueInvocation(2, (region.Offset + off).ToString(), alignedTodo.ToString(), region.FileName, off, todo, false, string.Format("Failed to program the FLASH region starting at 0x{0:x}, offset 0x{1:x}, size 0x{2:x}", region.Offset, off, todo))); off += todo; } } }