fix: align bootloader image validation limits
This commit is contained in:
@ -48,7 +48,7 @@ const int universalShifterAttWriteOverheadBytes = 3;
|
||||
const int universalShifterDfuPreferredMtu = 128;
|
||||
|
||||
const int universalShifterDfuAppStart = 0x00030000;
|
||||
const int universalShifterDfuAppSlotSizeBytes = 0x00042000;
|
||||
const int universalShifterDfuAppSlotSizeBytes = 0x0003F000;
|
||||
const int universalShifterDfuMinimumImageLengthBytes = 8;
|
||||
const int universalShifterDfuRamStart = 0x20000000;
|
||||
const int universalShifterDfuRamEnd = 0x20010000;
|
||||
|
||||
@ -138,12 +138,14 @@ class FirmwareFileSelectionService {
|
||||
final vectorStackPointer = _readLeU32(selection.fileBytes, 0);
|
||||
final vectorReset = _readLeU32(selection.fileBytes, 4);
|
||||
|
||||
final sessionId = _normalizeSessionId(_sessionIdGenerator());
|
||||
|
||||
final metadata = BootloaderDfuFirmwareMetadata(
|
||||
totalLength: selection.fileBytes.length,
|
||||
crc32: BootloaderDfuProtocol.crc32(selection.fileBytes),
|
||||
appStart: universalShifterDfuAppStart,
|
||||
imageVersion: 0,
|
||||
sessionId: _sessionIdGenerator() & 0xFF,
|
||||
sessionId: sessionId,
|
||||
flags: universalShifterDfuFlagNone,
|
||||
vectorStackPointer: vectorStackPointer,
|
||||
vectorReset: vectorReset,
|
||||
@ -215,7 +217,12 @@ class FirmwareFileSelectionService {
|
||||
return ByteData.sublistView(bytes).getUint32(offset, Endian.little);
|
||||
}
|
||||
|
||||
static int _normalizeSessionId(int sessionId) {
|
||||
final normalized = sessionId & 0xFF;
|
||||
return normalized == 0 ? 1 : normalized;
|
||||
}
|
||||
|
||||
static int _randomSessionId() {
|
||||
return Random.secure().nextInt(256);
|
||||
return Random.secure().nextInt(255) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user