'debug.md'

This commit is contained in:
gcw_4spBpAfv
2026-03-25 18:25:45 +08:00
parent 704b20cde1
commit 3bc48598cd
3 changed files with 227 additions and 0 deletions

36
design_doc/debug.md Normal file
View File

@@ -0,0 +1,36 @@
1. 问题描述开机失败一直遇到Traceback (most recent call last):
File "/tmp/maixpy_run/main.py", line 525, in <module>
cmd_str()
File "/tmp/maixpy_run/main.py", line 102, in cmd_str
camera_manager.init_camera(640, 480)
File "/tmp/maixpy_run/camera_manager.py", line 59, in init_camera
self._camera = camera.Camera(width, height)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: : Runtime error: mmf vi init failed
解决方案:
根据过往经验极有可能是摄像头的接线有问题。因为在测试环境摄像头是通过一个24针转22针的线出来的然后再通过一个接线中继连接到一个22针
的fpc线到Maixcam。接线中继如果是24针的多了两针需要选好一边然后对连。但这里很容易出错或者松动。可以先用摄像头本身的金色接线直接接到
Maixcam然后跑test目录下的test_cammera.py看看能不能正常启动如果正常就确定是中继接线的问题。
2. 问题描述202609 批次的拓展版,在连接 202601 批次的电源板,或者不链接电源板的时候,开机后不久,出错,程序退出,日志是:
[v1.2.10] [INFO] network.py:1078 - [NET] TCP主线程启动
[v1.2.10] [INFO] network.py:406 - [NET] WiFi不可用或无法连接服务器使用4G网络
[v1.2.10] [INFO] network.py:475 - 连接到服务器,使用4G...
[v1.2.10] [INFO] network.py:527 - [4G-TCP] AT+MIPCLOSE=2 response:
OK
+MIPCLOSE: 2
-- [E] read failed
Trigger signal, code:SIGSEGV(11)!
maix multi-media driver released.
ISP Vipipe(0) Free pa(0x8a52c000) va(0x0x3fbeb5e000)
program exit failed. exit code: 1.
解决方案:
从日志看就是开始发送登录信息之后就崩溃了。出发了底层的read failed。经过排查是一定要插上电源板的数据连线以及电源板要插上电池。这个应该是
登录时需要读电源电压数据,
3. 问题描述202609 批次的拓展版有一块maixcam的蓝灯常亮询问maixcam的人他们觉得应该是卡没有插好。但是拓展版上的激光口挡住了数据卡的出口
没法拔出检查,
解决方案:需要做拓展版的公司(深链鑫创)在做好板子之后,确定系统能正常启动
4.

61
test/test_i2c.py Normal file
View File

@@ -0,0 +1,61 @@
#!/usr/bin/env python3
# test_i2c_devices.py
import os
from maix import i2c
def list_i2c_devices():
"""List available I2C device nodes"""
print("Available I2C devices:")
# Check /dev directory
try:
dev_files = os.listdir("/dev")
i2c_devices = [f for f in dev_files if "i2c" in f]
if i2c_devices:
for dev in sorted(i2c_devices):
print(f" /dev/{dev}")
else:
print(" No /dev/i2c-* devices found!")
except Exception as e:
print(f" Error listing /dev: {e}")
def try_i2c_bus(bus_num):
"""Try to initialize an I2C bus"""
try:
bus = i2c.I2C(bus_num, i2c.Mode.MASTER)
print(f" I2C bus {bus_num}: OK")
return True
except RuntimeError as e:
print(f" I2C bus {bus_num}: {e}")
return False
except Exception as e:
print(f" I2C bus {bus_num}: Unexpected error: {e}")
return False
def main():
print("=" * 60)
print("I2C Device Diagnostic")
print("=" * 60)
# List kernel devices
list_i2c_devices()
# Try common bus numbers
print("\nTesting I2C buses:")
working_buses = []
for bus_num in range(10):
if try_i2c_bus(bus_num):
working_buses.append(bus_num)
print(f"\nWorking buses: {working_buses}")
if not working_buses:
print("\nERROR: No I2C buses available!")
print("Possible causes:")
print(" 1. I2C kernel driver not loaded")
print(" 2. Device tree doesn't enable I2C")
print(" 3. Different kernel version with different device naming")
if __name__ == "__main__":
main()

130
test/test_power.py Normal file
View File

@@ -0,0 +1,130 @@
#!/usr/bin/env python3
# test_power_with_init.py
from maix import i2c, time
import sys
# INA226 register addresses
INA226_ADDR = 0x40
REG_CONFIGURATION = 0x00
REG_BUS_VOLTAGE = 0x02
REG_CURRENT = 0x04
REG_CALIBRATION = 0x05
# Configuration values
CONFIG_VALUE = 0x4527 # Configuration: 16 averages, 1.1ms conversion time, continuous mode
CALIBRATION_VALUE = 0x1400 # Calibration value
def write_register(bus, reg, value):
"""Write to INA226 register"""
data = [(value >> 8) & 0xFF, value & 0xFF]
bus.writeto_mem(INA226_ADDR, reg, bytes(data))
def read_register(bus, reg):
"""Read from INA226 register"""
data = bus.readfrom_mem(INA226_ADDR, reg, 2)
return (data[0] << 8) | data[1]
def init_ina226(bus):
"""Initialize INA226 chip"""
try:
# Write configuration register
write_register(bus, REG_CONFIGURATION, CONFIG_VALUE)
time.sleep_ms(10)
# Write calibration register
write_register(bus, REG_CALIBRATION, CALIBRATION_VALUE)
time.sleep_ms(10)
# Verify configuration by reading it back
config_read = read_register(bus, REG_CONFIGURATION)
if config_read != CONFIG_VALUE:
print(f" Warning: Config readback mismatch: 0x{config_read:04X} != 0x{CONFIG_VALUE:04X}")
return True
except Exception as e:
print(f" Init failed: {e}")
return False
def read_voltage(bus):
"""Read bus voltage"""
raw = read_register(bus, REG_BUS_VOLTAGE)
voltage = raw * 1.25 / 1000
return voltage
def read_current(bus):
"""Read current"""
raw = read_register(bus, REG_CURRENT)
# Handle signed value
if raw & 0x8000:
raw = raw - 0x10000
current_lsb = 0.001 * CALIBRATION_VALUE / 4096
current = raw * current_lsb * 1000 # mA
return current
def test_i2c_bus(bus_num):
"""Test a single I2C bus with full initialization"""
print(f"\n{'='*60}")
print(f"Testing I2C Bus {bus_num}")
print(f"{'='*60}")
try:
# Step 1: Initialize I2C bus
print(f" 1. Initializing I2C bus...")
bus = i2c.I2C(bus_num, i2c.Mode.MASTER)
print(f" OK")
# Step 2: Initialize INA226
print(f" 2. Initializing INA226...")
if not init_ina226(bus):
print(f" FAILED")
return False
print(f" OK")
# Step 3: Read voltage multiple times
print(f" 3. Reading voltage...")
for i in range(5):
try:
voltage = read_voltage(bus)
current = read_current(bus)
print(f" Read {i+1}: {voltage:.3f}V, {current:.1f}mA")
time.sleep_ms(100)
except Exception as e:
print(f" Read {i+1} failed: {e}")
print(f" SUCCESS")
return True
except Exception as e:
print(f" FAILED: {e}")
import traceback
traceback.print_exc()
return False
def main():
"""Test all I2C buses"""
print("INA226 Test with Proper Initialization")
print("=" * 60)
# Test buses in order of likelihood
test_order = [5, 1, 3, 4, 0, 2]
success_buses = []
for bus_num in test_order:
if test_i2c_bus(bus_num):
success_buses.append(bus_num)
# If we found a working bus, stop testing others
break
print(f"\n{'='*60}")
print(f"Summary:")
print(f" Working buses: {success_buses}")
if not success_buses:
print(f" ERROR: No working I2C bus found!")
return 1
return 0
if __name__ == "__main__":
sys.exit(main())