How to remove kernel rights at axp209 chip

Started by mminar7, November 14, 2023, 01:35:25 PM

Previous topic - Next topic

How to remove kernel rights at axp209 chip

axp209
1 (100%)
kernel model
0 (0%)

Total Members Voted: 1

Voting closed: December 14, 2023, 01:35:25 PM

mminar7

I build my own I2C manager for chip axp209. The address of chip is 0x34H.
I have no problem with read rights for the chip.
I would like to have also write rights for chip.

root@a10-olinuxino:/sys/bus/platform/drivers# i2cdetect -y 0
    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                        -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

I would like to use writing rights for the chip.

olimex@a10-olinuxino:~/ecomet_i2c_raspberry_tools$ ./axp209_i2c_test.py
3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110]
ecomet.axp209: INFO     Start logging ...
internal_temperature: 48.20C
battery_exists: True
battery_charging: done
battery_current_direction: discharging
battery_voltage: 4185.5mV
battery_discharge_current: 0.5mA
battery_charge_current: -4999.5mA
battery_gauge: 100%
Traceback (most recent call last):
  File "/home/olimex/ecomet_i2c_raspberry_tools/./axp209_i2c_test.py", line 31, in <module>
    axp.vbus_write_current_limit('no limit')
  File "/home/olimex/ecomet_i2c_raspberry_tools/ecomet_i2c_sensors/axp209/axp209.py", line 94, in vbus_write_current_limit
    self.write_register('VBUS_IPSOUT_CHANNEL_MANAGEMENT_REG', flags.asbyte)
  File "/home/olimex/ecomet_i2c_raspberry_tools/ecomet_i2c_sensors/axp209/axp209.py", line 190, in write_register
    self._device.write8(reg_list[register],data)
  File "/home/olimex/ecomet_i2c_raspberry_tools/ecomet_i2c_sensors/i2c.py", line 148, in write8
    self._bus.write_byte_data(self._address, register, value)
  File "/home/olimex/.local/lib/python3.9/site-packages/Adafruit_PureIO/smbus.py", line 326, in write_byte_data
    self._select_device(addr)
  File "/home/olimex/.local/lib/python3.9/site-packages/Adafruit_PureIO/smbus.py", line 165, in _select_device
    ioctl(self._device.fileno(), I2C_SLAVE, addr & 0x7F)
OSError: [Errno 16] Device or resource busy

Thank you for your advice.

LubOlimex

Quotebattery_voltage: 4185.5mV
battery_discharge_current: 0.5mA
battery_charge_current: -4999.5mA

 :o

Seems like the error is "OSError: [Errno 16] Device or resource busy". Means that the device is already accessed by something else. Try writing something easy without pyton just with i2cset and i2cget.

Maybe also publish the ./axp209_i2c_test.py maybe moore people would be able to help.
Technical support and documentation manager at Olimex

mminar7

Hello,

Here is source code (it's source code of library ecomet_i2c_sensors fresh version).
https://github.com/mamin27/ecomet_i2c_raspberry_tools

Test script is:

axp209_i2c_test.py

The script use several reads of data from 0x34H (axp209), that works.
Write of data was the problem with mentioned error data.

I tried to add modprobe blacklist data to stop axp modules:
olimex@a10-olinuxino:~/ecomet_i2c_raspberry_tools$ cat /etc/modprobe.d/blacklist-olinuxino.conf
blacklist sun4i_gpadc_iio
blacklist sun4i_gpadc
blacklist axp20x_adc
blacklist industrialio

But still without success with same error messages.

LubOlimex

> The script use several reads of data from 0x34H (axp209), that works.

The address is 0x34 (52d) why are you using 0x34H, it is like double stating the number is hex. Either use 0x34 or 34h.

Also publish the axp209_i2c_test.py we don't know what exactly that does.
Technical support and documentation manager at Olimex

mminar7

#4
Script is inside of ecomet_i2c_raspberry_tools github repo:

https://github.com/mamin27/ecomet_i2c_raspberry_tools/blob/master/axp209_i2c_test.py

Just clone all repo and run the script from the location of:

olimex@a10-olinuxino:~/ecomet_i2c_raspberry_tools$ ls -l
total 116
-rwxr-xr-x  1 olimex olimex  1392 Nov 14 11:27 axp209_i2c_test.py
-rw-r--r--  1 olimex olimex    53 Nov 15 10:04 axp209.log
drwxr-xr-x  3 olimex olimex  4096 Nov  2 07:22 bin
drwxr-xr-x 17 olimex olimex  4096 Nov 14 08:45 ecomet_i2c_sensors
lrwxrwxrwx  1 olimex olimex    33 Nov  1 13:56 fonts -> python_test_scripts/display/fonts
drwxr-xr-x  6 olimex olimex  4096 Nov  6  2022 fpc
lrwxrwxrwx  1 olimex olimex    41 Nov 13 13:01 hdc1080_i2c_test.py -> ./python_test_scripts/hdc1080_i2c_test.py
-rw-r--r--  1 olimex olimex  1088 Nov 13 17:30 hdc1080.log
-rw-r--r--  1 olimex olimex   637 Nov  1 20:48 i2c_ecomet_detect.log
lrwxrwxrwx  1 olimex olimex    34 Nov  1 13:56 images -> python_test_scripts/display/images
-rw-r--r--  1 olimex olimex 35149 Nov  6  2022 LICENSE
lrwxrwxrwx  1 olimex olimex    40 Nov 13 13:02 ms5637_i2c_test.py -> ./python_test_scripts/ms5637_i2c_test.py
-rw-r--r--  1 olimex olimex   318 Nov 13 17:29 ms5637.log
lrwxrwxrwx  1 olimex olimex    39 Nov  1 20:08 pca_9632_i2c_rgb.py -> python_test_scripts/pca_9632_i2c_rgb.py
-rw-r--r--  1 olimex olimex    54 Nov  1 20:49 pca9632.log
drwxr-xr-x  3 olimex olimex  4096 Nov  6  2022 projects
drwxr-xr-x  2 olimex olimex  4096 Nov 13 21:08 __pycache__
drwxr-xr-x  2 olimex olimex  4096 Nov  6  2022 python
drwxr-xr-x  8 olimex olimex  4096 Nov  1 20:13 python_test_scripts
-rw-r--r--  1 olimex olimex  9380 Nov  1 13:56 README.md
-rw-r--r--  1 olimex olimex   101 Nov  6  2022 requirements.txt
lrwxrwxrwx  1 olimex olimex    51 Nov 13 13:02 sn_gcja5_i2c_test.py -> ./python_test_scripts/sn_gcja5/sn_gcja5_i2c_test.py
-rw-r--r--  1 olimex olimex    55 Nov 13 17:30 sn-gcja5.log
-rw-r--r--  1 olimex olimex   276 Nov  6  2022 test.py
drwxr-xr-x  4 olimex olimex  4096 Nov  6  2022 wiki
olimex@a10-olinuxino:~/ecomet_i2c_raspberry_tools$ ./axp209_i2c_test.py

mminar7

#5
Now also I2C write to axp209 is working. In my last github update.
;D

Github package

https://twitter.com/mminar7/status/1727401346645844289