# CPU register access from userspace

**URL:** <https://community.solid-run.com/t/cpu-register-access-from-userspace/365>\
**Category:** NXP LX2160\
**Created:** [June 24, 2022, 2:48pm UTC](https://community.solid-run.com/t/cpu-register-access-from-userspace/365 "2022-06-24T14:48:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![joes](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@joes](https://community.solid-run.com/u/joes)\
**Post date:** [June 24, 2022, 2:48pm UTC](https://community.solid-run.com/t/cpu-register-access-from-userspace/365/1 "2022-06-24T14:48:15Z")

</div>

Does anyone (or NXP or SolidRun) have a tool that can inspect and write to the processor registers from user space?

We generally write a such a tool when we do BSP development but I haven’t gotten around to doing that. If someone else has written one, it’ll save me some time. In the past, with Freescale PowerPC parts, it’s been a fairly simple memory mapping exercise, you just need to know the right memory offsets. Layerscape should be the same but I haven’t done that research yet. Does SolidRun use the same map that the the NXP LX2160ARDB uses or are there different memory offsets?

---

<div class="post-metadata">

**Author:** ![womble](https://dub1.discourse-cdn.com/flex005/user_avatar/community.solid-run.com/womble/32/114_2.png) [@womble](https://community.solid-run.com/u/womble)\
**Post date:** [June 24, 2022, 3:41pm UTC](https://community.solid-run.com/t/cpu-register-access-from-userspace/365/2 "2022-06-24T15:41:11Z")

</div>

I’ve been using the devmem tool for this which can be installed via the apt package devmem2

[https://manpages.ubuntu.com/manpages/bionic/man1/devmem2.1.html](https://manpages.ubuntu.com/manpages/bionic/man1/devmem2.1.html)

If you’re looking to change the serdes configuration, there’s a process that has to be followed which includes halting the lane, changing the config and then re-starting it. It’s explained in one of the NXP manuals, probably the SRM.

You can also change registers pre-boot using the u-boot memory read (md) and memory write (mw) commands

---

<div class="post-metadata">

**Author:** ![joes](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@joes](https://community.solid-run.com/u/joes)\
**Post date:** [June 24, 2022, 4:01pm UTC](https://community.solid-run.com/t/cpu-register-access-from-userspace/365/3 "2022-06-24T16:01:31Z")

</div>

Great, devmem should work! Sounds like a shell script is in order to automate the whole process.

Do I need to add in any offset to the devmem address arg to get to the processor registers?

---

<div class="post-metadata">

**Author:** ![womble](https://dub1.discourse-cdn.com/flex005/user_avatar/community.solid-run.com/womble/32/114_2.png) [@womble](https://community.solid-run.com/u/womble)\
**Post date:** [June 24, 2022, 4:17pm UTC](https://community.solid-run.com/t/cpu-register-access-from-userspace/365/4 "2022-06-24T16:17:10Z")

</div>

You just use the physical address of the memory-mapped register you need to access. It’ll only read/write memory mapped registers such as those used to configure peripheral controllers and can’t access registers which are not presented in physical memory such as the cpu registers.

---

<div class="post-metadata">

**Author:** ![joes](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@joes](https://community.solid-run.com/u/joes)\
**Post date:** [June 24, 2022, 7:49pm UTC](https://community.solid-run.com/t/cpu-register-access-from-userspace/365/5 "2022-06-24T19:49:42Z")

</div>

Since its a highly integrated SoC they are all “processor” registers to me but, yeah, technically they’re peripheral regs. I have no need to look at the CPU registers. I was just wondering whether or not there is an offset to the registers described in Memory Map in the NXP Reference manual.

---

<div class="post-metadata">

**Author:** ![jnettlet](https://dub1.discourse-cdn.com/flex005/user_avatar/community.solid-run.com/jnettlet/32/62_2.png) [@jnettlet](https://community.solid-run.com/u/jnettlet)\
**Post date:** [June 25, 2022, 4:00am UTC](https://community.solid-run.com/t/cpu-register-access-from-userspace/365/6 "2022-06-25T04:00:38Z")

</div>

those are the physical addresses of the registers
