cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jawbone_101
Adventurer
Adventurer
420 Views
Registered: ‎05-07-2008

How to acccess ARM v8 peripheral register space

With Zynq-7000 I was able to read certain registers from the USB controller with a user space program to determine when a USB plug event happened. This program ran in the background and would load or unload a user space program based on the plug event.

I am now using Zynq UltraScale+ and the same type of direct access no longer works. I am assuming due to the new/added security features.

The above is one example where I need access to a register in one of the ARM's peripherals. Another example is adjusting the ARM's I2C dividers to change I2C bus speed.

Looking for suggestions on how I should go about getting access to these registers again, ideally from user space.

Thanks in advance.

0 Kudos
3 Replies
deville
Explorer
Explorer
379 Views
Registered: ‎09-28-2018

If you say User space, I presume you are talking about Linux. 

Basically you want an event driven alert if an USB device is plugged in. Linux does not work with interrupts as it is a preemptive OS.    ( with a scheduler )

Things you can do: 

  • Alter or add a device driver ( ioctl ) in such a way that you can poll for a change in a virtual file ( which the driver created at boot time )
  • Poll with existing tools. for example, I inserted in my PC an extra 7th USB device:

      

$ lsusb | wc
      6      62     366
$ lsusb | wc
      7      72     436

You have plenty of tools already available inside linux but you can also develop with a custom user space C or Python application. 

As for the I2C speed settings, I think you better change the device tree to your needs. There is already a parameter for altering the speed.  

 

Now the experimental answer:

Here is an example tool : devmem2 

This alows you to straigth hack your way into the device tree binaries. The devicetree itself is in fact a layout or map so the kernel finds its pheriperals.

 

 

 

 

0 Kudos
jawbone_101
Adventurer
Adventurer
371 Views
Registered: ‎05-07-2008

Thanks for the responses. Yes, this is Linux.

I need changing I2C speed to be dynamic, i.e from the command line, and not static as with devicetree.

lsusb assumes I am using the USB port in host mode, I am using it in device mode. Unfornatully I do not have an external VBUD detect circuit as I've been able to read the USB controller directly.

devmem2 has the same issues as mmap to these memory locations. the system will hang when accessing 0xFF020000 (I2C0) for example.

0 Kudos
deville
Explorer
Explorer
364 Views
Registered: ‎09-28-2018

 

I2C:  The driver itself needs to configure the I2C bus speed at boot time so If you can alter the driver in such a way it opens a virtual file / folder you can set the bus when you echo a corrected speed into it. 

 

Deville

 

 

 

0 Kudos