pureboot: take the device signature from the chip database

libavr now exposes avr::hw::db.signature (compile-time, from the ATDF), so the
info block drops its per-chip hardcoded signature() for the db constant. The
loaders are byte-identical across modes with the correct signature, sizes
unchanged (488/502/504).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-20 23:30:17 +02:00
parent f9b86393e1
commit a1ff032c87

View File

@@ -37,10 +37,11 @@ constexpr auto off = avr::irq::guard_policy::unused;
constexpr std::uint8_t ack = '+'; constexpr std::uint8_t ack = '+';
// Per-chip personality, from the chip database: the clocks the dogfood // Per-chip personality: the clocks the dogfood boards run (16 MHz crystal on
// boards run (16 MHz crystal on the mega, calibrated RC on the tinies) and // the mega, calibrated RC on the tinies). The device signature comes straight
// the device signature (compile-time data — the tiny13A cannot even read its // from the chip database (avr::hw::db.signature) — compile-time data is the
// signature row from code). // only universal source, since the tiny13A cannot even read its signature row
// from code.
consteval avr::hertz_t clock() consteval avr::hertz_t clock()
{ {
if (avr::hw::db.name == "ATtiny13A") if (avr::hw::db.name == "ATtiny13A")
@@ -50,15 +51,6 @@ consteval avr::hertz_t clock()
return 16_MHz; return 16_MHz;
} }
consteval std::array<std::uint8_t, 3> signature()
{
if (avr::hw::db.name == "ATtiny13A")
return {0x1e, 0x90, 0x07};
if (avr::hw::db.name == "ATtiny85")
return {0x1e, 0x93, 0x0b};
return {0x1e, 0x95, 0x0f};
}
using dev = avr::device<{.clock = clock()}>; using dev = avr::device<{.clock = clock()}>;
// Geometry: the resident loader owns the top 512 bytes of flash; the word // Geometry: the resident loader owns the top 512 bytes of flash; the word
@@ -84,9 +76,9 @@ inline constexpr std::array<std::uint8_t, 12> info_data = {
'P', 'P',
'B', 'B',
1, // magic, protocol version 1, // magic, protocol version
signature()[0], avr::hw::db.signature[0],
signature()[1], avr::hw::db.signature[1],
signature()[2], avr::hw::db.signature[2],
static_cast<std::uint8_t>(page), static_cast<std::uint8_t>(page),
base & 0xff, base & 0xff,
base >> 8, // app flash ends here; resident loader base base >> 8, // app flash ends here; resident loader base