Unable to access I.MX6ULL memory map registers using devmem2 - fsl-yocto-L4.9.11_1.0.0.tar

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unable to access I.MX6ULL memory map registers using devmem2 - fsl-yocto-L4.9.11_1.0.0.tar

3,802 Views
srishan
Contributor III

Dear I.MX Community

Am trying to verify I2C2 Controller module registers in linux using devmem2, I have hereby attached my devmem2.c file 

root@imx6ull14x14evk:/# devmem2 0x21A0000 
/dev/mem opened. 
Error at line 86, file devmem2.c (1) [Operation not permitted] 
root@imx6ull14x14evk:/# 

whereas, I was able to access other register using devmem for example as shown below 

root@imx6ull14x14evk:/# devmem2 0x21EC08C w 0x00008200 
/dev/mem opened. 
Memory mapped at address 0x76f80000. 
Value at address 0x21EC08C (0x76f8008c): 0x8000 
Written 0x8200; readback 0x8000 


Could you please let me know how this i2c memory map registers can be accessed using devmem2? 

Requesting you to let me know if there any issues in the attached devmem2.c file or share me the working devmem2 file in your test setup 

Kindly do the needful as early as possible, as I stuck in this issue from past 2 weeks 
Eagerly awaiting for your replies 
Many Thanks in adavnce

Labels (3)
0 Kudos
4 Replies

2,699 Views
ankitr_patel
Senior Contributor II

srishan

Hi Sri Shan,

The clock for the I2C module is disabled from the Driver. To access I2C MemoryMap register, first of all, you need to enable Clock for the I2C Module.

That is not a legitimate way to access physical memory from userspace. To Read/Write the I2C MemoryMap Register you have to use Linux Driver. if you want to read those register from userspace then you have to create SYSFS entry in the Linux kernel, which will Communicate the Linux Driver from the userspace.

The below-attached file is the driver file in which I2C Clock is Enabled, and the SYSFS entry to read the I2C MemoryMap Register from the userspace.

you have to Replace below driver with your driver in the driver/i2c/busses/i2c-imx.c. this will Enable the I2C Clock. and By following bellow command you can read I2C MemoryMap Register.

To find a i2c_show entry from sysfs

root@imx6ull14x14evk:/#  find /sys/ -name "i2c_show"

/sys/devices/platform/soc/2100000.aips-bus/21a0000.i2c/i2c_show
/sys/devices/platform/soc/2100000.aips-bus/21a4000.i2c/i2c_show

 

To read register value from I2C driver
root@imx6ull14x14evk:/#  cat /sys/devices/platform/soc/2100000.aips-bus/21a0000.i2c/i2c_show

 

Above command will call the i2c_show function which will enable I2C clock and then print I2C Memorymap Register.

Once you run Above Command after that you are able to read those Register with devmem2.c

To read I2C register using devmem2.c
root@imx6ull14x14evk:/# devmem2 0x21A0008 h

NOTE:- all the I2C register are 16-bits if you try to read those register as 32-bit then it will crash your kernel or restart your kernel.

----------------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
----------------------------------------------------------------------------------------------------------------------------

0 Kudos

2,700 Views
srishan
Contributor III

I would very much appreciate for providing this very much detailed info Ankit,

Could you also please help me how can we read back SAI module registers

0 Kudos

2,700 Views
ankitr_patel
Senior Contributor II

Hi srishan

Thanks for your appreciation.

You can read SAI module registers in a similar way as you have read I2C MemoryMap Register.

For example : devmem2 <SAI_MODULE_REGISTER_ADDRESS> h

                         e.g. devmem2 0x2028004 h

The SAI module registers addresses will be found in i.MX6UL Reference Manual.

Regards,

Ankit

0 Kudos

2,700 Views
igorpadykov
NXP Employee
NXP Employee

Hi Sri

one can try with nxp tool : memtool

memtool\test - imx-test - i.MX Driver Test Application Software 

In general some modules may require a privilege access in order to

modify their settings. These addresses are locked for user space access. 

You can modify its registers within the kernel driver.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos