From 5b48f21f53050a17fd15e7a8f7987f4b86120164 Mon Sep 17 00:00:00 2001 From: mumpf Date: Sat, 15 Oct 2022 22:24:58 +0200 Subject: [PATCH 1/2] get rid of some warnings during build (#214) (comparison between signed and unsigned integer expressions) Co-authored-by: Waldemar Porscha --- src/knx/memory.cpp | 2 +- src/knx/platform.cpp | 8 ++++---- src/knx/platform.h | 2 +- src/knx/table_object.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/knx/memory.cpp b/src/knx/memory.cpp index 5d33148..c7bdd00 100644 --- a/src/knx/memory.cpp +++ b/src/knx/memory.cpp @@ -127,7 +127,7 @@ void Memory::readMemory() void Memory::writeMemory() { // first get the necessary size of the writeBuffer - size_t writeBufferSize = _metadataSize; + uint16_t writeBufferSize = _metadataSize; for (int i = 0; i < _saveCount; i++) writeBufferSize = MAX(writeBufferSize, _saveRestores[i]->saveSize()); diff --git a/src/knx/platform.cpp b/src/knx/platform.cpp index a66a341..3c2a74e 100644 --- a/src/knx/platform.cpp +++ b/src/knx/platform.cpp @@ -181,8 +181,8 @@ uint32_t Platform::writeNonVolatileMemory(uint32_t relativeAddress, uint8_t* buf uint32_t start = _bufferedEraseblockNumber * (flashEraseBlockSize() * flashPageSize()); uint32_t end = start + (flashEraseBlockSize() * flashPageSize()); - ptrdiff_t offset = relativeAddress - start; - ptrdiff_t length = end - relativeAddress; + uint32_t offset = relativeAddress - start; + uint32_t length = end - relativeAddress; if(length > size) length = size; memcpy(_eraseblockBuffer + offset, buffer, length); @@ -227,7 +227,7 @@ void Platform::writeBufferedEraseBlock() if(_bufferedEraseblockNumber > -1 && _bufferedEraseblockDirty) { flashErase(_bufferedEraseblockNumber); - for(int i = 0; i < flashEraseBlockSize(); i++) + for(uint32_t i = 0; i < flashEraseBlockSize(); i++) { int32_t pageNumber = _bufferedEraseblockNumber * flashEraseBlockSize() + i; uint8_t *data = _eraseblockBuffer + flashPageSize() * i; @@ -238,7 +238,7 @@ void Platform::writeBufferedEraseBlock() } -void Platform::bufferEraseBlock(uint32_t eraseBlockNumber) +void Platform::bufferEraseBlock(int32_t eraseBlockNumber) { if(_bufferedEraseblockNumber == eraseBlockNumber) return; diff --git a/src/knx/platform.h b/src/knx/platform.h index 2aaf758..21a2867 100644 --- a/src/knx/platform.h +++ b/src/knx/platform.h @@ -104,7 +104,7 @@ class Platform // writes _eraseblockBuffer to flash virtual void writeBufferedEraseBlock(); // copies a EraseBlock into the _eraseblockBuffer - void bufferEraseBlock(uint32_t eraseBlockNumber); + void bufferEraseBlock(int32_t eraseBlockNumber); // in theory we would have to use this buffer for memory reads too, // but because ets always restarts the device after programming it diff --git a/src/knx/table_object.cpp b/src/knx/table_object.cpp index 1f670a9..90e6624 100644 --- a/src/knx/table_object.cpp +++ b/src/knx/table_object.cpp @@ -110,7 +110,7 @@ bool TableObject::allocTable(uint32_t size, bool doFill, uint8_t fillByte) if (doFill) { uint32_t addr = _memory.toRelative(_data); - for(int i = 0; i< size;i++) + for(uint32_t i = 0; i < size;i++) _memory.writeMemory(addr+i, 1, &fillByte); } From a0134e6cfb04a54943384ddb8d01f9343545d5cd Mon Sep 17 00:00:00 2001 From: Sonnengruesser <36325150+Sonnengruesser@users.noreply.github.com> Date: Sat, 15 Oct 2022 22:25:22 +0200 Subject: [PATCH 2/2] RP2040 EEPROM/Flash compiler flag fix (#216) * RP2040 EEPROM/Flash compiler flag fix only check flash size if Flash is used, not EEPROM * RP2040 EEPROM/Flash compiler flag fix use EEPROM emulation as default to allow build of the knx-demo (memory.h defines EEPROM size 1024 which doesn't work with Flashsize 4k) * Update rp2040_arduino_platform.h --- src/rp2040_arduino_platform.cpp | 2 ++ src/rp2040_arduino_platform.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/rp2040_arduino_platform.cpp b/src/rp2040_arduino_platform.cpp index 7392223..0374e85 100644 --- a/src/rp2040_arduino_platform.cpp +++ b/src/rp2040_arduino_platform.cpp @@ -35,6 +35,7 @@ A RAM-buffered Flash can be use by defining USE_RP2040_LARGE_EEPROM_EMULATION #define FLASHPTR ((uint8_t*)XIP_BASE + KNX_FLASH_OFFSET) +#ifndef USE_RP2040_EEPROM_EMULATION #if KNX_FLASH_SIZE%4096 #error "KNX_FLASH_SIZE must be multiple of 4096" #endif @@ -42,6 +43,7 @@ A RAM-buffered Flash can be use by defining USE_RP2040_LARGE_EEPROM_EMULATION #if KNX_FLASH_OFFSET%4096 #error "KNX_FLASH_OFFSET must be multiple of 4096" #endif +#endif #ifndef KNX_SERIAL #define KNX_SERIAL Serial1 diff --git a/src/rp2040_arduino_platform.h b/src/rp2040_arduino_platform.h index 8a9e7f3..77a8736 100644 --- a/src/rp2040_arduino_platform.h +++ b/src/rp2040_arduino_platform.h @@ -4,10 +4,12 @@ #ifdef ARDUINO_ARCH_RP2040 +#ifndef USE_RP2040_EEPROM_EMULATION #ifndef KNX_FLASH_OFFSET #define KNX_FLASH_OFFSET 0x180000 // 1.5MiB #pragma warning "KNX_FLASH_OFFSET not defined, using 0x180000" #endif +#endif #ifdef USE_RP2040_LARGE_EEPROM_EMULATION #define USE_RP2040_EEPROM_EMULATION