I have a firmware upgrade app in C# that updates the firmware on a stm32f417IGT over USART.
It works on small upgrades — original test files were about 13K — but when I started testing the full firmware (200K), the host program would hang while executing the write command in the bootloader.
I added a delay in case the FIFO in Windows was getting full (64 bytes), but the host app still can't make it to the end of the 400K .HEX file. There is extra room in the .HEX file for firmware growth, with a CRC at the end of that "partition".
The write command will fail at different points, from 15K to 200K+ of the file completed.
Does anyone know why the write command would just stop like that?
I tried adding delay after the write, but that did not help.
Here is the section of C# code where it hangs:
for ( int i = 0; i < length; i++ )
// Send individual characters to device
HANGS HERE--> _serialPort.Write(bytes, 4 + i, 1);
// increment counter
if( byteCounter % 32 == 0 )
// Add byte to checksum
hexChecksum ^= bytes[4 + i];
// If counter == 256, reset counter, send checksum
if (byteCounter == 256)
sendAddress = true;
byteCounter = 0;
// Convert checksum to a byte value and send
hexChecksum = hexChecksum ^ 0xFF;
byte csByte = Convert.ToByte(hexChecksum);
Byte csByte_arr = BitConverter.GetBytes(csByte);
_serialPort.Write(csByte_arr, 0, 1);
// Receive ACK byte
byte_read = _serialPort.ReadByte();
if (byte_read == NACK)
} // end IF byteCounter == 256
} // end FOR loop