Skip to content

Commit 34218ab

Browse files
BootloaderTest: Test GET_SERIAL_NUMBER
1 parent 8822f85 commit 34218ab

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

BootloaderTest/BootloaderTest.ino

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,29 @@ test(070_get_hardware_info) {
324324
assertEqual(flash_size, AVAILABLE_FLASH_SIZE);
325325
}
326326

327+
test(075_get_serial_number) {
328+
uint8_t data[9];
329+
assertTrue(run_transaction_ok(Commands::GET_SERIAL_NUMBER, nullptr, 0, data, sizeof(data)));
330+
331+
auto on_failure = [&data]() {
332+
for (uint8_t i = 0; i < sizeof(data); ++i) {
333+
Serial.print(" 0x"); Serial.print(data[i], HEX);
334+
}
335+
};
336+
337+
// This is not required by the protocol, but the current
338+
// implementation returns the unique data from the attiny chip, which
339+
// is a lot number, wafer number and x/y position. The lot number
340+
// seems to be an ASCII uppercase letter followed by 5 ASCII numbers,
341+
// so check that.
342+
assertMoreOrEqual(data[0], 'A');
343+
assertLessOrEqual(data[0], 'Z');
344+
for (uint8_t i = 1; i < 6; ++i) {
345+
assertMoreOrEqual(data[i], '0');
346+
assertLessOrEqual(data[i], '9');
347+
}
348+
}
349+
327350
test(080_crc_error) {
328351
uint8_t status;
329352
uint8_t crc_xor = random(1, 256);

BootloaderTest/Constants.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ struct Commands {
4848
SET_I2C_ADDRESS = 0x01,
4949
POWER_UP_DISPLAY = 0x02,
5050
GET_HARDWARE_INFO = 0x03,
51-
START_APPLICATION = 0x04,
52-
WRITE_FLASH = 0x05,
53-
FINALIZE_FLASH = 0x06,
54-
READ_FLASH = 0x07,
51+
GET_SERIAL_NUMBER = 0x04,
52+
START_APPLICATION = 0x05,
53+
WRITE_FLASH = 0x06,
54+
FINALIZE_FLASH = 0x07,
55+
READ_FLASH = 0x08,
5556
END_OF_COMMANDS
5657
};
5758
};

0 commit comments

Comments
 (0)