From e82d4f2edaefb74c9dee27f6d26c4d2038af0384 Mon Sep 17 00:00:00 2001 From: Piotr Esden-Tempski Date: Tue, 15 Mar 2022 19:05:53 -0700 Subject: [PATCH] native: Fixes an hw version issue with some older BMP. The BMP with hardware version 4 and newer, use option bytes instead of physical GPIO to encode the hardware version. In some older BMP there is a chance that the user option byte is set to 255 (0x00FF pattern). This can throw off the hardware version detection routine. --- src/platforms/native/platform.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/platforms/native/platform.c b/src/platforms/native/platform.c index b472854..c732aaa 100644 --- a/src/platforms/native/platform.c +++ b/src/platforms/native/platform.c @@ -80,12 +80,13 @@ int platform_hwversion(void) /* Check if the hwversion is set in the user option byte. */ if (hwversion == -1) { - if (BMP_HWVERSION_BYTE != 0xFFFF) { + if ((BMP_HWVERSION_BYTE != 0xFFFF) && + (BMP_HWVERSION_BYTE != 0x00FF)) { /* Check if the data is valid. * When valid it should only have values 4 and higher. */ - if ((BMP_HWVERSION_BYTE >> 8) != - (~BMP_HWVERSION_BYTE & 0xFF) || + if (((BMP_HWVERSION_BYTE >> 8) != + (~BMP_HWVERSION_BYTE & 0xFF)) || ((BMP_HWVERSION_BYTE & 0xFF) < 4)) { return -2; } else {