NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: I cannot make i2c work in raspberry pi Zero W



Hello Michael,

El 7/7/24 a las 22:10, Michael van Elst escribió:
ea1abz%gmail.com@localhost (Ramiro Aceves) writes:

I have connected a BMP280 pressure sensor to my piZeroW just to learn a li=
ttle of i2c programming on NetBSD=2E Before doing real programming I issued=
a i2scan command to ensure the system works, but a lot of inexistent devic=
es are detected (even if nothing is connected to the pi)

Yes, the i2scan behaviour is unfortunate.

Thank you very much for answering.

Yes, i2cscan is something that surprise you the first time you use it and immediately start thinking something is wrong.


The BMP280 should respond on address 0x76 or 0x77.


Yes!

[     4.886672] bmx280thp0 at iic2 addr 0x76
[     4.916724] bmx280thp0: Bosch Sensortec BMP280, Chip ID: 0x58



The i2c interface for the GPIO port is /soc/i2c@7e804000

If your kernel configures more than one device, you
can use this to check if it is the right one:

% drvctl -p iic0 device-parent
bsciic0
% drvctl -p bsciic0 fdt-path
/soc/i2c@7e804000


yes:

netbsd-raspaZeroW$ drvctl -p bsciic0 fdt-path
/soc/i2c@7e805000
netbsd-raspaZeroW$ drvctl -p bsciic1 fdt-path
/soc/i2c@7e205000
netbsd-raspaZeroW$ drvctl -p bsciic2 fdt-path
/soc/i2c@7e804000

I see that i2c works even if not configured on /boot/config.txt commenting the dtparam=i2c_arm=on:


netbsd-raspaZeroW$ cat /boot/config.txt
#
upstream_kernel=1
os_prefix=dtb/
cmdline=../cmdline.txt
# UART settings, see https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-uarts
enable_uart=1
force_turbo=0
# Default kernel for BCM2836 and later
kernel=/kernel7.img
# Override kernel for BCM2835 based boards
[pi0]
kernel=/kernel.img
[pi0w]
kernel=/kernel.img
[pi1]
kernel=/kernel.img
[all]
#
#dtparam=i2c_arm=on

After reboot device continues working:

[     4.876644] bmx280thp0 at iic2 addr 0x76
[     4.916708] bmx280thp0: Bosch Sensortec BMP280, Chip ID: 0x58


netbsd-raspaZeroW$ envstat
                 Current  CritMax  WarnMax  WarnMin  CritMin  Unit
[bmx280thp0]
  temperature:    28.320                                      degC
     pressure:   930.080                                       hPa
[vcmbox0]
  temperature:    48.692   85.000                             degC

So it seems that it is not necesary.

Regards.
Ramiro.









Home | Main Index | Thread Index | Old Index