Arduino Nesso N1 support - #10664
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new ESP32-C6 hardware variant to support the Arduino Nesso N1 board within the Meshtastic firmware variant system (pins, peripherals, and PlatformIO environment).
Changes:
- Introduces a new
arduino_nesso_n1ESP32-C6 variant with LoRa (SX1262) + TFT (ST7789) pin mappings. - Adds board-specific early init code for the PI4IO expanders (and charger configuration) used on the Nesso N1.
- Adds a new PlatformIO environment and Arduino pin mapping header for the board.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| variants/esp32c6/arduino_nesso_n1/variant.h | Board pin/peripheral feature macros (LoRa + TFT + I2C, etc.). |
| variants/esp32c6/arduino_nesso_n1/variant.cpp | Board init for I2C expanders and helper GPIO-ext routines. |
| variants/esp32c6/arduino_nesso_n1/platformio.ini | New arduino-nesso-n1 build environment, deps, and build flags. |
| variants/esp32c6/arduino_nesso_n1/pins_arduino.h | Arduino core pin constants for this environment. |
| ${esp32c6_base.build_flags} | ||
| -D PRIVATE_HW | ||
| -D ARDUINO_NESSO_N1 | ||
| -D M5STACK_UNITC6L | ||
| -I variants/esp32c6/arduino_nesso_n1 |
Firmware Size Report21 targets | no baseline available yet
Show 16 more target(s)
Updated for 31ca268 |
ed861a4 to
ea2cc62
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
ea2cc62 to
3046f06
Compare
📝 WalkthroughWalkthroughAdds a new board variant, "arduino_nesso_n1," for the ESP32-C6 platform, including default pin definitions, a PlatformIO build environment configuration, hardware initialization code for I2C-based GPIO expanders and battery charger, and a variant header configuring GPS, I2C, SPI, LoRa (SX1262), TFT display (ST7789), and BQ27220 battery monitor settings. ChangesNesso N1 board variant
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Firmware as Nesso N1 Firmware
participant c6l_init as c6l_init()
participant Wire as Wire (I2C)
participant PI4IO as PI4IO Expanders
participant AW32001E as AW32001E Charger
Firmware->>c6l_init: call c6l_init() at boot
c6l_init->>Wire: i2c_write_byte(PI4IO addr, reg, value)
Wire->>PI4IO: reset/configure GPIO direction, pull, interrupt mask
c6l_init->>Wire: i2c_write_byte(AW32001E addr, reg, value)
Wire->>AW32001E: configure charger registers
c6l_init->>Wire: i2c_read_byte(reg)
Wire-->>c6l_init: register value
Firmware->>Wire: gpio_ext_set(address, pin, value)
Wire->>PI4IO: read-modify-write output register
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
variants/esp32c6/arduino_nesso_n1/variant.cpp (2)
58-58: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
LOG_DEBUGinstead ofprintf.As per coding guidelines, "Prefer
LOG_DEBUG,LOG_INFO,LOG_WARN, andLOG_ERRORfor logging in C++ code."♻️ Suggested fix
- printf("pi4io_init\n"); + LOG_DEBUG("pi4io_init");🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@variants/esp32c6/arduino_nesso_n1/variant.cpp` at line 58, Replace the direct printf logging in variant.cpp with the project’s logging macro. Update the pi4io_init message to use LOG_DEBUG instead of printf so it follows the C++ logging conventions used elsewhere in the codebase, and keep the change localized to the initialization path in variant.cpp.Source: Coding guidelines
104-113: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider named constants for the AW32001E charger address/registers.
0x49and the raw register offsets (0x2,0x5,0x1,0x0) are used inline, unlike thePI4IO_*macros used above. Named constants would improve readability and reduce risk of typos across the four writes.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@variants/esp32c6/arduino_nesso_n1/variant.cpp` around lines 104 - 113, The AW32001E charger configuration in variant.cpp uses inline magic numbers for the I2C address and register offsets, unlike the nearby PI4IO constants. Replace the repeated 0x49 and raw register values in the AW32001E setup with named constants defined near the other board-specific symbols, and update the charger initialization calls to use those identifiers so the intent is clearer and typos are less likely.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@variants/esp32c6/arduino_nesso_n1/variant.cpp`:
- Around line 26-43: The I2C helper routines `i2c_read_byte` and
`i2c_write_byte` currently ignore the return values from
`Wire.endTransmission()` and `Wire.requestFrom()`, so bus errors can silently
propagate stale or invalid data. Update these helpers to check and surface
transmission/read failures, and make callers such as `gpio_ext_set`,
`gpio_ext_get`, and `c6l_init` handle the error path instead of using the read
value when the transaction fails.
---
Nitpick comments:
In `@variants/esp32c6/arduino_nesso_n1/variant.cpp`:
- Line 58: Replace the direct printf logging in variant.cpp with the project’s
logging macro. Update the pi4io_init message to use LOG_DEBUG instead of printf
so it follows the C++ logging conventions used elsewhere in the codebase, and
keep the change localized to the initialization path in variant.cpp.
- Around line 104-113: The AW32001E charger configuration in variant.cpp uses
inline magic numbers for the I2C address and register offsets, unlike the nearby
PI4IO constants. Replace the repeated 0x49 and raw register values in the
AW32001E setup with named constants defined near the other board-specific
symbols, and update the charger initialization calls to use those identifiers so
the intent is clearer and typos are less likely.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b1e89e18-3dc2-4aff-8d39-8e25a66cdeb5
📒 Files selected for processing (4)
variants/esp32c6/arduino_nesso_n1/pins_arduino.hvariants/esp32c6/arduino_nesso_n1/platformio.inivariants/esp32c6/arduino_nesso_n1/variant.cppvariants/esp32c6/arduino_nesso_n1/variant.h
| void i2c_read_byte(uint8_t addr, uint8_t reg, uint8_t *value) | ||
| { | ||
| Wire.beginTransmission(addr); | ||
| Wire.write(reg); | ||
| Wire.endTransmission(); | ||
| Wire.requestFrom(addr, 1); | ||
| *value = Wire.read(); | ||
| } | ||
|
|
||
| /*******************************************************************/ | ||
| void i2c_write_byte(uint8_t addr, uint8_t reg, uint8_t value) | ||
| { | ||
| Wire.beginTransmission(addr); | ||
| Wire.write(reg); | ||
| Wire.write(value); | ||
| Wire.endTransmission(); | ||
| } | ||
| /*******************************************************************/ |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the target file and nearby usage.
echo "== variant.cpp =="
wc -l variants/esp32c6/arduino_nesso_n1/variant.cpp
sed -n '1,220p' variants/esp32c6/arduino_nesso_n1/variant.cpp
echo
echo "== Search for helper usages =="
rg -n "i2c_read_byte|i2c_write_byte|gpio_ext_set|gpio_ext_get|c6l_init|Wire\.requestFrom|Wire\.endTransmission|Wire\.read" variants/esp32c6/arduino_nesso_n1 -S
echo
echo "== Surrounding call sites if found =="
for f in $(rg -l "i2c_read_byte|i2c_write_byte|gpio_ext_set|gpio_ext_get|c6l_init" variants/esp32c6/arduino_nesso_n1 -S); do
echo "--- $f ---"
rg -n -C 3 "i2c_read_byte|i2c_write_byte|gpio_ext_set|gpio_ext_get|c6l_init" "$f"
doneRepository: meshtastic/firmware
Length of output: 14879
Handle I2C errors in these helpers. i2c_read_byte/i2c_write_byte ignore Wire.endTransmission() and Wire.requestFrom(), so a NACK or short read falls through into gpio_ext_set/gpio_ext_get and c6l_init with stale or invalid data. That can misconfigure the expander/charger during bring-up.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@variants/esp32c6/arduino_nesso_n1/variant.cpp` around lines 26 - 43, The I2C
helper routines `i2c_read_byte` and `i2c_write_byte` currently ignore the return
values from `Wire.endTransmission()` and `Wire.requestFrom()`, so bus errors can
silently propagate stale or invalid data. Update these helpers to check and
surface transmission/read failures, and make callers such as `gpio_ext_set`,
`gpio_ext_get`, and `c6l_init` handle the error path instead of using the read
value when the transaction fails.
|
Follow-up / correction after more testing. Updating my earlier "fully usable" comment with what I've now actually verified on the hardware:
So the device is usable on-device via touch and via the phone app; the one gap is the physical button not being wired up. (Display offset band from my earlier note still stands.) Happy to test button fixes against the hardware. |

This is resubmit of Arduino Nesso N1 support #8784
Issue: [Board]: Arduino Nesso N1 #8744
🤝 Attestations
Summary by CodeRabbit