From f307eb134034aaab22f1e30fda1b5b54315aef02 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sat, 11 Apr 2020 23:02:16 +0200 Subject: [PATCH] Fix bootloader size read-out --- stk500v2/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stk500v2/main.cpp b/stk500v2/main.cpp index a5fa85a..c8f0b35 100644 --- a/stk500v2/main.cpp +++ b/stk500v2/main.cpp @@ -340,15 +340,15 @@ static inline void performChipErase() }; constexpr auto getBootloaderSize = []() -> uint16_t { - const auto extendedFuse = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS); + const auto highFuse = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS); constexpr auto BOOTSZ0 = 1; constexpr auto BOOTSZ1 = 2; - if (extendedFuse & (1 << BOOTSZ1 | 1 << BOOTSZ0)) + if (highFuse & (1 << BOOTSZ1) && highFuse & (1 << BOOTSZ0)) return 256 * 2; - else if (extendedFuse & (1 << BOOTSZ1)) + else if (highFuse & (1 << BOOTSZ1)) return 512 * 2; - else if (extendedFuse & (1 << BOOTSZ0)) + else if (highFuse & (1 << BOOTSZ0)) return 1024 * 2; return 2048 * 2; };