The environment is created using Yocoto for the i.MX8MP evk kit.
How can I access registers connected by memory mapped IO?
For example, I want to read 3088_0080 UART Control Register 1 (UART3_UCR1).
Similarly for other registers.
Should I change the .dts file?
I'm trying, but for some reason I can't access anything after 0x3000_0000.
★Can you see why?
One problem was cleared.
This is an issue where memtool could not write to the UART3 register.
This was caused by no clock being supplied to UART3.
When I executed the following command, I was able to write the UART3 register with memtool.
./memtool 0x3038B000=0x10000000
./memtool 0x303844B0=0x00000003
However, it is not yet possible to change the register in the code.
What else am I missing?
you can refer to the link as below, try to check if your UART3 clock is enable or not, find it from imx8mp reference manual
Solved: Memtool write not working on UART2, UART3... - NXP Community
Thank you for your answer.
memtool can be avoided by setting the Clock.
./memtool 0x3038B000=0x10000000
./memtool 0x303844B0=0x00000003
By setting the Clock, I was able to manipulate the registers of UART3 with memtool.
The current problem is that registers cannot be accessed in C code.
Also, I found an example of writing registers using code from another Community, so I tried implementing it.
uint32_t *UART3_UCR1 = ((uint32_t *)0x30880080);
uint32_t *UART3_UCR2 = ((uint32_t *)0x30880084);
uint32_t *UART3_UCR3 = ((uint32_t *)0x30880088);
uint32_t *UART3_UCR4 = ((uint32_t *)0x3088008C);
uint32_t *UART3_UFCR = ((uint32_t *)0x30880090);
uint32_t *UART3_USR1 = ((uint32_t *)0x30880094);
uint32_t *UART3_USR2 = ((uint32_t *)0x30880098);
uint32_t *UART3_UESC = ((uint32_t *)0x3088009C);
uint32_t *UART3_UTIM = ((uint32_t *)0x308800A0);
uint32_t *UART3_UBIR = ((uint32_t *)0x308800A4);
uint32_t *UART3_UBMR = ((uint32_t *)0x308800A8);
uint32_t *UART3_UBRC = ((uint32_t *)0x308800AC);
*UART3_UCR1 = 0x00000201;
*UART3_UCR2 = 0x0000502F;
*UART3_UCR3 = 0x0000038C;
*UART3_UCR4 = 0x00004002;
*UART3_UFCR = 0x00000B08;
*UART3_USR1 = 0x00002040;
*UART3_USR2 = 0x00005008;
*UART3_UESC = 0x0000002B;
*UART3_UTIM = 0x00000000;
*UART3_UBIR = 0x0000014F;
*UART3_UBMR = 0x00000270;
*UART3_UBRC = 0x00000008;
However, it becomes as follows.
Segmentation fault (core dumped)
★Is there any solution to this?
why don't you just write a script which uses memtool to control the registers? if you insist on using c code, pls submit a new ticket, add your c code and what kind of Segmentation fault you get
After that, UART2_UCR1 was able to be changed using memtool as shown below.
root@imx8mpevk:/usr/bin# ./memtool -32 0x30890080 1
E
Reading 0x1 count starting at address 0x30890080
0x30890080: 00000201
root@imx8mpevk:/usr/bin# ./memtool -32 0x30890080=0x00000000
Writing 32-bit value 0x0 to address 0x30890080
root@imx8mpevk:/usr/bin# ./memtool -32 0x30890080 1
E
Reading 0x1 count starting at address 0x30890080
0x30890080: 00000000
root@imx8mpevk:/usr/bin# ./memtool -32 0x30890080=0x00000201
Writing 32-bit value 0x201 to address 0x30890080
root@imx8mpevk:/usr/bin# ./memtool -32 0x30890080 1
E
Reading 0x1 count starting at address 0x30890080
0x30890080: 00000201
root@imx8mpevk:/usr/bin#
★What is the reason why UART3_UCR1 is not changed by memtool?
Is someone else posting at certain times?
try to use memtool under /unit_test to read the register
I was able to read it with memtool.
However, I cannot write to it.
root@imx8mpevk:/usr/bin# ./memtool -32 0x30880080 1
E
Reading 0x1 count starting at address 0x30880080
0x30880080: 00000000
root@imx8mpevk:/usr/bin# ./memtool -32 0x30880080=0x00000201
Writing 32-bit value 0x201 to address 0x30880080
root@imx8mpevk:/usr/bin# ./memtool -32 0x30880080 1
E
Reading 0x1 count starting at address 0x30880080
0x30880080: 00000000
root@imx8mpevk:/usr/bin#
★Can you see why?
Also, I found an example of writing registers using code from another Community, so I tried implementing it.
uint32_t *UART3_UCR1 = ((uint32_t *)0x30880080);
uint32_t *UART3_UCR2 = ((uint32_t *)0x30880084);
uint32_t *UART3_UCR3 = ((uint32_t *)0x30880088);
uint32_t *UART3_UCR4 = ((uint32_t *)0x3088008C);
uint32_t *UART3_UFCR = ((uint32_t *)0x30880090);
uint32_t *UART3_USR1 = ((uint32_t *)0x30880094);
uint32_t *UART3_USR2 = ((uint32_t *)0x30880098);
uint32_t *UART3_UESC = ((uint32_t *)0x3088009C);
uint32_t *UART3_UTIM = ((uint32_t *)0x308800A0);
uint32_t *UART3_UBIR = ((uint32_t *)0x308800A4);
uint32_t *UART3_UBMR = ((uint32_t *)0x308800A8);
uint32_t *UART3_UBRC = ((uint32_t *)0x308800AC);
*UART3_UCR1 = 0x00000201;
*UART3_UCR2 = 0x0000502F;
*UART3_UCR3 = 0x0000038C;
*UART3_UCR4 = 0x00004002;
*UART3_UFCR = 0x00000B08;
*UART3_USR1 = 0x00002040;
*UART3_USR2 = 0x00005008;
*UART3_UESC = 0x0000002B;
*UART3_UTIM = 0x00000000;
*UART3_UBIR = 0x0000014F;
*UART3_UBMR = 0x00000270;
*UART3_UBRC = 0x00000008;
However, it becomes as follows.
Segmentation fault (core dumped)
★Is there any solution to this?