From bf17066523b9b940f1a072fb3f5d1b10909f2cae Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sun, 22 Dec 2024 18:55:01 -0600 Subject: [PATCH 1/3] Add NXP_SE050 detection --- arch/portduino/portduino.ini | 2 +- src/detect/ScanI2C.h | 3 ++- src/detect/ScanI2CTwoWire.cpp | 32 +++++++++++++++++++++++++++---- variants/portduino/platformio.ini | 1 + 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index e4e32693c1..96599f3415 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -1,6 +1,6 @@ ; The Portduino based 'native' environment. Currently supported on Linux targets with real LoRa hardware (or simulated). [portduino_base] -platform = https://github.com/meshtastic/platform-native.git#73bd1a21183ca8b00c4ea58bb21315df31a50dff +platform = https://github.com/meshtastic/platform-native.git#562d189828f09fbf4c4093b3c0104bae9d8e9ff9 framework = arduino build_src_filter = diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index 2473a65731..2561a8e17a 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -64,7 +64,8 @@ class ScanI2C TPS65233, MPR121KB, CGRADSENS, - INA226 + INA226, + NXP_SE050, } DeviceType; // typedef uint8_t DeviceAddress; diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index 79c0deccfe..6e695c22f8 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -154,9 +154,14 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize) } i2cBus->beginTransmission(addr.address); #ifdef ARCH_PORTDUINO - if (i2cBus->read() != -1) - err = 0; - else + err = 2; + if ((addr.address >= 0x30 && addr.address <= 0x37) || (addr.address >= 0x50 && addr.address <= 0x5F)) { + if (i2cBus->read() != -1) + err = 0; + } else { + err = i2cBus->writeQuick((uint8_t)0); + } + if (err != 0) err = 2; #else err = i2cBus->endTransmission(); @@ -396,7 +401,6 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize) SCAN_SIMPLE_CASE(OPT3001_ADDR, OPT3001, "OPT3001", (uint8_t)addr.address); SCAN_SIMPLE_CASE(MLX90632_ADDR, MLX90632, "MLX90632", (uint8_t)addr.address); SCAN_SIMPLE_CASE(NAU7802_ADDR, NAU7802, "NAU7802", (uint8_t)addr.address); - SCAN_SIMPLE_CASE(FT6336U_ADDR, FT6336U, "FT6336U", (uint8_t)addr.address); SCAN_SIMPLE_CASE(MAX1704X_ADDR, MAX17048, "MAX17048", (uint8_t)addr.address); #ifdef HAS_TPS65233 SCAN_SIMPLE_CASE(TPS65233_ADDR, TPS65233, "TPS65233", (uint8_t)addr.address); @@ -444,6 +448,26 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize) } break; + case 0x48: { + i2cBus->beginTransmission(addr.address); + uint8_t getInfo[] = {0x5A, 0xC0, 0x00, 0xFF, 0xFC}; + uint8_t expectedInfo[] = {0xa5, 0xE0, 0x00, 0x3F, 0x19}; + uint8_t info[5]; + size_t len = 0; + i2cBus->write(getInfo, 5); + i2cBus->endTransmission(); + len = i2cBus->readBytes(info, 5); + if (len == 5 && memcmp(expectedInfo, info, len) == 0) { + LOG_INFO("NXP SE050 crypto chip found\n"); + type = NXP_SE050; + + } else { + LOG_INFO("FT6336U touchscreen found\n"); + type = FT6336U; + } + break; + } + default: LOG_INFO("Device found at address 0x%x was not able to be enumerated", (uint8_t)addr.address); } diff --git a/variants/portduino/platformio.ini b/variants/portduino/platformio.ini index aa11142f71..34ae129e14 100644 --- a/variants/portduino/platformio.ini +++ b/variants/portduino/platformio.ini @@ -6,6 +6,7 @@ build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino -I /usr/include !pkg-config --libs libulfius --silence-errors || : !pkg-config --libs openssl --silence-errors || : + -li2c board = cross_platform lib_deps = ${portduino_base.lib_deps} build_src_filter = ${portduino_base.build_src_filter} From 3ec30a171e98ba1f36e85f8a8fcb68600d8306b0 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sun, 22 Dec 2024 21:20:36 -0600 Subject: [PATCH 2/3] Put the flag in the right place --- arch/portduino/portduino.ini | 1 + variants/portduino/platformio.ini | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index 96599f3415..777ce1e020 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -39,4 +39,5 @@ build_flags = -lbluetooth -lgpiod -lyaml-cpp + -li2c -std=c++17 \ No newline at end of file diff --git a/variants/portduino/platformio.ini b/variants/portduino/platformio.ini index 34ae129e14..aa11142f71 100644 --- a/variants/portduino/platformio.ini +++ b/variants/portduino/platformio.ini @@ -6,7 +6,6 @@ build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino -I /usr/include !pkg-config --libs libulfius --silence-errors || : !pkg-config --libs openssl --silence-errors || : - -li2c board = cross_platform lib_deps = ${portduino_base.lib_deps} build_src_filter = ${portduino_base.build_src_filter} From ef9540569fae0dce26a901b679115c5b1a8d9cc2 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sun, 22 Dec 2024 22:28:35 -0600 Subject: [PATCH 3/3] Include libi2c0 dependency in .deb packages --- .github/workflows/package_amd64.yml | 4 ++-- .github/workflows/package_raspbian.yml | 4 ++-- .github/workflows/package_raspbian_armv7l.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/package_amd64.yml b/.github/workflows/package_amd64.yml index 782ef479bc..c6e82e1be2 100644 --- a/.github/workflows/package_amd64.yml +++ b/.github/workflows/package_amd64.yml @@ -79,7 +79,7 @@ jobs: maintainer: Jonathan Bennett version: ${{ steps.version.outputs.version }} # refs/tags/v*.*.* arch: amd64 - depends: libyaml-cpp0.7, openssl, libulfius2.7 + depends: libyaml-cpp0.7, openssl, libulfius2.7, libi2c0 desc: Native Linux Meshtastic binary. - uses: actions/upload-artifact@v4 @@ -87,4 +87,4 @@ jobs: name: meshtasticd_${{ steps.version.outputs.version }}_amd64.deb overwrite: true path: | - ./*.deb \ No newline at end of file + ./*.deb diff --git a/.github/workflows/package_raspbian.yml b/.github/workflows/package_raspbian.yml index aef8905f82..a4cd49573d 100644 --- a/.github/workflows/package_raspbian.yml +++ b/.github/workflows/package_raspbian.yml @@ -79,7 +79,7 @@ jobs: maintainer: Jonathan Bennett version: ${{ steps.version.outputs.version }} # refs/tags/v*.*.* arch: arm64 - depends: libyaml-cpp0.7, openssl, libulfius2.7 + depends: libyaml-cpp0.7, openssl, libulfius2.7, libi2c0 desc: Native Linux Meshtastic binary. - uses: actions/upload-artifact@v4 @@ -87,4 +87,4 @@ jobs: name: meshtasticd_${{ steps.version.outputs.version }}_arm64.deb overwrite: true path: | - ./*.deb \ No newline at end of file + ./*.deb diff --git a/.github/workflows/package_raspbian_armv7l.yml b/.github/workflows/package_raspbian_armv7l.yml index ddb84d4a7e..c4cc5c6736 100644 --- a/.github/workflows/package_raspbian_armv7l.yml +++ b/.github/workflows/package_raspbian_armv7l.yml @@ -79,7 +79,7 @@ jobs: maintainer: Jonathan Bennett version: ${{ steps.version.outputs.version }} # refs/tags/v*.*.* arch: armhf - depends: libyaml-cpp0.7, openssl, libulfius2.7 + depends: libyaml-cpp0.7, openssl, libulfius2.7, libi2c0 desc: Native Linux Meshtastic binary. - uses: actions/upload-artifact@v4 @@ -87,4 +87,4 @@ jobs: name: meshtasticd_${{ steps.version.outputs.version }}_armhf.deb overwrite: true path: | - ./*.deb \ No newline at end of file + ./*.deb