diff --git a/builder/family/realtek-ambz2.py b/builder/family/realtek-ambz2.py index b3e2fd4..512f981 100644 --- a/builder/family/realtek-ambz2.py +++ b/builder/family/realtek-ambz2.py @@ -404,6 +404,12 @@ bootloader_dst = env.subst("${BUILD_DIR}/bootloader.axf") if not isfile(bootloader_dst): copyfile(bootloader_src, bootloader_dst) +# OTA2 clearing - 4096 bytes of 0xFF +image_ota_clear = env.subst("${BUILD_DIR}/raw_ota_clear.bin") +if not isfile(image_ota_clear): + with open(image_ota_clear, "wb") as f: + f.write(b"\xFF" * 4096) + # Build all libraries queue.BuildLibraries() @@ -416,5 +422,7 @@ env.Replace( UF2OTA=[ # same OTA images for flasher and device f"{image_firmware_is},{image_firmware_is}=device:ota1,ota2;flasher:ota1,ota2", + # clearing headers of the "other" OTA image (hence the indexes are swapped) + f"{image_ota_clear},{image_ota_clear}=device:ota2,ota1;flasher:ota2,ota1", ], ) diff --git a/cores/common/arduino/libraries/api/Serial/Serial.h b/cores/common/arduino/libraries/api/Serial/Serial.h index da3bf02..232c48c 100644 --- a/cores/common/arduino/libraries/api/Serial/Serial.h +++ b/cores/common/arduino/libraries/api/Serial/Serial.h @@ -8,24 +8,30 @@ using namespace arduino; +#if HAS_SERIAL0 #ifndef PIN_SERIAL0_RX #define PIN_SERIAL0_RX PIN_INVALID #endif -#ifndef PIN_SERIAL1_RX -#define PIN_SERIAL1_RX PIN_INVALID -#endif -#ifndef PIN_SERIAL2_RX -#define PIN_SERIAL2_RX PIN_INVALID -#endif #ifndef PIN_SERIAL0_TX #define PIN_SERIAL0_TX PIN_INVALID #endif +#endif +#if HAS_SERIAL1 +#ifndef PIN_SERIAL1_RX +#define PIN_SERIAL1_RX PIN_INVALID +#endif #ifndef PIN_SERIAL1_TX #define PIN_SERIAL1_TX PIN_INVALID #endif +#endif +#if HAS_SERIAL2 +#ifndef PIN_SERIAL2_RX +#define PIN_SERIAL2_RX PIN_INVALID +#endif #ifndef PIN_SERIAL2_TX #define PIN_SERIAL2_TX PIN_INVALID #endif +#endif class SerialClass : public HardwareSerial { private: diff --git a/cores/realtek-ambz2/arduino/libraries/Serial/Serial.cpp b/cores/realtek-ambz2/arduino/libraries/Serial/Serial.cpp index eb1e462..3b69859 100644 --- a/cores/realtek-ambz2/arduino/libraries/Serial/Serial.cpp +++ b/cores/realtek-ambz2/arduino/libraries/Serial/Serial.cpp @@ -33,10 +33,6 @@ void SerialClass::begin(unsigned long baudrate, uint16_t config) { this->data = new SerialData(); this->buf = &BUF; - if (this->port == 2) { - hal_uart_deinit(&log_uart); - } - // TODO handle PIN_INVALID hal_uart_init(&UART, this->tx, this->rx, NULL);