i2c-scanner
ACK-probes every 7-bit address on an I²C bus and reports the ones that respond. Useful as a sanity check that buses are wired correctly and chips are populated.
Source: examples/i2c-scanner/.
board.yaml
schema_version: 2
som:
sku: E1M-AEN701
carrier:
name: E1M-EVK
cores:
m55_hp:
os: zephyr
app: ./src
peripherals: [i2c]
diagnostics:
log_level: info
Source (abbreviated)
#include <alp/peripheral.h>
#include <alp/e1m_pinout.h>
#include <zephyr/kernel.h>
int main(void) {
alp_i2c_t *bus = alp_i2c_open(&(alp_i2c_config_t){
.bus_id = E1M_I2C0,
.bitrate_hz = 100000u,
});
if (bus == NULL) {
printk("[i2c] open failed: err=%d\n", (int)alp_last_error());
return -1;
}
uint8_t addrs[128];
size_t count;
alp_i2c_scan(bus, addrs, sizeof(addrs), &count);
printk("[i2c] found %zu device(s):\n", count);
for (size_t i = 0; i < count; i++) {
printk(" 0x%02x\n", addrs[i]);
}
alp_i2c_close(bus);
return 0;
}
Expected output
On a populated E1M EVK:
[i2c] found 5 device(s):
0x30 // OPTIGA Trust M
0x40 // TMP112
0x50 // 24C128 EEPROM
0x52 // RV-3028-C7 RTC
0x68 // 5L35023B clock gen (V2N only)
Troubleshooting
| Symptom | Cause / fix |
|---|---|
open failed err=-ENOSUPPORT | Wrapper not implemented for this OS/SoM yet. Check the test plan. |
| Zero devices on a known-populated bus | Check pull-up resistors; bridge / mux PWREN line. |
| Expected device missing | ACK-probe fails → chip is DNI on this BOM variant, or the rail powering it is down. |
See also
Questions about this page? Discuss in Community Forum