From 3990f5318061a1cbc87674c16878321379d2e7e3 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Fri, 24 Jul 2026 17:57:47 +0200 Subject: [PATCH] pureboot: take the running slot from avr::startup::caller_page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The write guard's anchor was costing a materialised pointer and a byte swap to use one byte of it. The libavr primitive answers it in a single load, which is eight bytes off every build — and what lets the USART release fit the tightest configuration in the space: the 1284 autobaud on USART-shared pins was 514 of its 512 and is now 506, with the default pinning down from 510 to 502. Verified on silicon: the guard still refuses an erase aimed at the slot it runs from, and still permits one in the application region. Co-Authored-By: Claude Opus 4.8 (1M context) --- pureboot/pureboot.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pureboot/pureboot.cpp b/pureboot/pureboot.cpp index 7881008..9dd36db 100644 --- a/pureboot/pureboot.cpp +++ b/pureboot/pureboot.cpp @@ -488,8 +488,7 @@ void fill_page(std::uint8_t bank, std::uint16_t at) // address is a word address and a slot is half as many words as bytes, so // its high byte is the slot index outright. No absolute address is ever // formed, so the image stays position-independent. - const auto return_words = reinterpret_cast(__builtin_return_address(0)); - const auto slot_high = static_cast(return_words >> 8); + const auto slot_high = avr::startup::caller_page(); await_host();