This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to use generic timer/counter

The technical reference manual states that the Cortex-A57 generic timer events are not affected by CPU clock frequency change. My challenge is that I can't use any built in linux libraries to create a delay because whenever I try it clears performance register that i'm trying to observe. Does anyone know a simple way to get the timer ticks value or even perhaps configure the timer. My attempts so far have all yielded in illegal instruction errors, MRS commands.  The ARMv8-A_Architecture_Reference_Manual says that they can also be accessed through memory mapped control but I'm not sure on how to go about that and would appreciate any help if that's the route i should go.

Thanks for any help.

Parents
  • Is your code running in EL0/User mode?

    If so, some of the Generic Timer system registers can be accessed at EL0 if CNTKCTL_EL1.EL0PCTEN==1.  This register requires at least EL1 privilege.  In other words, the OS has to choose to give an app access to the registers.  I suspect that Linux isn't (I'm not a Linux expert, so I don't know), as it will probably be using the timer for its own purposes.  You could modify the kernel to give you access, but you'll need to be careful what you then do with the registers afterwards.

    On the memory mapped interface, in theory you just need to know their address.  In practice, the chip's documentation will tell you the physical address.  In order to access them from your app, you'd have to request that the OS maps them in the translation tables - and does so into the app's VA space with user permissions.

Reply
  • Is your code running in EL0/User mode?

    If so, some of the Generic Timer system registers can be accessed at EL0 if CNTKCTL_EL1.EL0PCTEN==1.  This register requires at least EL1 privilege.  In other words, the OS has to choose to give an app access to the registers.  I suspect that Linux isn't (I'm not a Linux expert, so I don't know), as it will probably be using the timer for its own purposes.  You could modify the kernel to give you access, but you'll need to be careful what you then do with the registers afterwards.

    On the memory mapped interface, in theory you just need to know their address.  In practice, the chip's documentation will tell you the physical address.  In order to access them from your app, you'd have to request that the OS maps them in the translation tables - and does so into the app's VA space with user permissions.

Children