diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4bac67e..a0f9cbb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,21 +2,19 @@ cmake_minimum_required(VERSION 3.28)
project(tsb_libavr LANGUAGES CXX)
-# libavr from a local checkout (LIBAVR_ROOT) or the forge; the toolchain file
-# comes from the same checkout via CMakePresets.json.
-include(FetchContent)
+# libavr rides as the pinned submodule; LIBAVR_ROOT (cache or environment)
+# overrides it for tandem development against a working tree. The toolchain
+# file comes from the submodule via CMakePresets.json either way.
if(NOT LIBAVR_ROOT AND DEFINED ENV{LIBAVR_ROOT})
set(LIBAVR_ROOT $ENV{LIBAVR_ROOT})
endif()
if(NOT LIBAVR_ROOT)
set(LIBAVR_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/libavr)
endif()
-if(LIBAVR_ROOT)
- FetchContent_Declare(libavr SOURCE_DIR ${LIBAVR_ROOT})
-else()
- FetchContent_Declare(libavr GIT_REPOSITORY git@git.blackmark.me:avr/libavr.git GIT_TAG main)
+if(NOT EXISTS ${LIBAVR_ROOT}/CMakeLists.txt)
+ message(FATAL_ERROR "libavr not found at ${LIBAVR_ROOT} — run: git submodule update --init libavr")
endif()
-FetchContent_MakeAvailable(libavr)
+add_subdirectory(${LIBAVR_ROOT} libavr-build)
if(PROJECT_IS_TOP_LEVEL)
add_compile_options(-Werror) # warnings are errors for the port's own code
diff --git a/ide/README.md b/ide/README.md
index 6594c07..acf6263 100644
--- a/ide/README.md
+++ b/ide/README.md
@@ -40,14 +40,13 @@ flash, so the optimisation level stays where correctness needs it.
## What Studio needs from the machine
-libavr checked out **beside this repo**, found at
-`$(MSBuildProjectDirectory)\..\..\..\libavr\include` — anchored to the project,
-because a plain relative path resolves against the generated makefile's
-directory (the configuration's output directory), not the project's. There is no
-`LIBAVR_ROOT` escape hatch: a variable exported in a shell is invisible to Studio
-launched from the Start menu, and the failure reads as a missing
-`libavr/libavr.hpp`. Pinning libavr as a submodule is the better answer and is on
-libavr's task list.
+libavr from the **submodule**, found at
+`$(MSBuildProjectDirectory)\..\..\libavr\include` — correct by construction, and
+anchored to the project because a plain relative path resolves against the
+generated makefile's directory (the configuration's output directory), not the
+project's. There is no `LIBAVR_ROOT` escape hatch: a variable exported in a
+shell is invisible to Studio launched from the Start menu, and the failure reads
+as a missing `libavr/libavr.hpp` — which is what the submodule answers.
A GCC 16.1 toolchain registered as flavour `avr-g++-16.1.0`, nothing older
reaching `-std=c++26`.
@@ -60,9 +59,9 @@ per project checks the flags have not drifted (both from libavr's
```sh
for name in pureboot tsb_asm; do
- python ../libavr/tools/atmelstudio/componentinfo.py \
+ python libavr/tools/atmelstudio/componentinfo.py \
"ide/$name/$name.componentinfo.xml" --device ATmega328P
- python ../libavr/tools/atmelstudio/check-flags.py \
+ python libavr/tools/atmelstudio/check-flags.py \
--solution ide/bootloader.atsln --project "$name" --target "$name" \
--compile-commands build/atmega328p-generated/compile_commands.json \
--log "build/as-$name.log"
diff --git a/ide/pureboot/pureboot.cppproj b/ide/pureboot/pureboot.cppproj
index 312273b..b4554e8 100644
--- a/ide/pureboot/pureboot.cppproj
+++ b/ide/pureboot/pureboot.cppproj
@@ -60,7 +60,7 @@
- $(MSBuildProjectDirectory)\..\..\..\libavr\include
+ $(MSBuildProjectDirectory)\..\..\libavr\include
Optimize for size (-Os)
@@ -92,7 +92,7 @@
- $(MSBuildProjectDirectory)\..\..\..\libavr\include
+ $(MSBuildProjectDirectory)\..\..\libavr\include
Optimize for size (-Os)
diff --git a/ide/tsb_asm/tsb_asm.cppproj b/ide/tsb_asm/tsb_asm.cppproj
index a84f839..5c63f02 100644
--- a/ide/tsb_asm/tsb_asm.cppproj
+++ b/ide/tsb_asm/tsb_asm.cppproj
@@ -57,7 +57,7 @@
- $(MSBuildProjectDirectory)\..\..\..\libavr\include
+ $(MSBuildProjectDirectory)\..\..\libavr\include
Optimize for size (-Os)
@@ -86,7 +86,7 @@
- $(MSBuildProjectDirectory)\..\..\..\libavr\include
+ $(MSBuildProjectDirectory)\..\..\libavr\include
Optimize for size (-Os)
diff --git a/libavr b/libavr
index 10d33d7..43b1f34 160000
--- a/libavr
+++ b/libavr
@@ -1 +1 @@
-Subproject commit 10d33d78948e3870b7283ca72e60e90b9ad8e7a2
+Subproject commit 43b1f34ed102f11da82491370ea688b1c912e09e
diff --git a/pureboot/README.md b/pureboot/README.md
index 4f71304..d86f28a 100644
--- a/pureboot/README.md
+++ b/pureboot/README.md
@@ -287,6 +287,14 @@ from `b`, and a command per memory (`R`/`W` flash, `r`/`w` EEPROM, `F` fuses).
above; the shipped tool speaks both, choosing on the version it reads, so a
deployed pureboot 4 stays drivable and self-updatable to 5.
+Every closed generation is tagged in this repo at its era's last commit — the
+commit just before the next version bump, so a tag holds everything its
+version ever gained — and each tag carries the `libavr/` submodule pinned to
+the libavr that loader was built against, as the whole libavr era does commit
+by commit. `git checkout v3 && git submodule update --init libavr` followed by
+the usual preset build therefore reproduces the v3 loader exactly; the open
+generation is `main`.
+
Collapsing four command bodies into one transfer loop is what paid for the
version: the data space, the host-issued SPM operations and the fuses now share
the loop, the cursor and the argument decode that `R`/`r`/`w` each carried a
@@ -452,8 +460,11 @@ counts, the programming plan, update state handling and per-phase page counts.
## Tests
-`tools/check.sh` runs every chip's workflow (`--full` adds the reflect-mode
-builds of libavr's spot set; `tools/make_presets.py` regenerates the presets).
+libavr rides as the `libavr/` submodule (`git submodule update --init libavr`);
+`LIBAVR_ROOT` (cache or environment) overrides it for tandem development
+against a working tree. `tools/check.sh` runs every chip's workflow (`--full`
+adds the reflect-mode builds of libavr's spot set; `tools/make_presets.py`
+regenerates the presets).
Per chip preset, `ctest` runs:
- `pureboot.size` — the 510-byte (patched-vector) / 512-byte budget;
diff --git a/tools/check.sh b/tools/check.sh
index 5cb8444..e797297 100755
--- a/tools/check.sh
+++ b/tools/check.sh
@@ -3,8 +3,8 @@
# the simulator-driven protocol suites. --full adds the reflect-spot builds
# (libavr's rule: reflect compiles are bounded to its spot set, never the
# full matrix) and swaps the compact size matrix for the exhaustive
-# clock × baud × backend cross product. LIBAVR_ROOT must point at the libavr
-# checkout.
+# clock × baud × backend cross product. libavr resolves from the `libavr/`
+# submodule; LIBAVR_ROOT overrides it for a working tree.
set -e
cd "$(dirname "$0")/.."