Memtool write not working on UART2, UART3...

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

Memtool write not working on UART2, UART3...

Jump to solution
1,483 Views
rust_caleb
Contributor II

Added memtool by adding the following line into my local.conf file

IMAGE_INSTALL_append = "imx-test"

rebuilt using bitbake, and loaded image onto my i.mx6ul board

Memtool write to UART3 registers followed by a read shows that the write did not take effect.  Any ideas why?

Memtool write success

root@imx6ul-var-dart:/# /unit_tests/memtool UART1.UCR1=0x201

SOC: i.MX6ULL
write 0x00000201 to 0x02020080

root@imx6ul-var-dart:/# /unit_tests/memtool UART1.UCR1
SOC: i.MX6ULL
UART1 Addr:0x2020000
UART1.UCR1 Addr:0x02020080 Value:0x00000201

Memtool write no effect

root@imx6ul-var-dart:/# /unit_tests/memtool UART3.UCR1=0x201

SOC: i.MX6ULL
write 0x00000201 to 0x021EC080

root@imx6ul-var-dart:/# /unit_tests/memtool UART3.UCR1
SOC: i.MX6ULL
UART3 Addr:0x21ec000
UART3.UCR1 Addr:0x021EC080 Value:0x00000C00

Monitored UART3 output with logic analyzer

root@imx6ul-var-dart:/dev# echo "hello" > /dev/ttymxc2

When I run the above command, I see "hello" at the logic analyzer.  This leads me to believe that the driver, pin configuration and clock for UART3 are all working fine.

 

...somehow UART3 is enabled and working normally, but memtool can not write to the register values.

********* begin related info*******

I also tried writes to any/all of UART2, UART3, UART4, and all writes have no effect.  Write followed by read shows that the write was ignored.

UART1 is used for console.  UART1 is ttymxc0

root@imx6ul-var-dart:/# stty -F /dev/ttymxc0
speed 115200 baud; line = 0;
eol = ^J;
-brkint ixoff -imaxbel
-iexten

UART2, UART3, UART4 are used for other things.  UART3 is assigned to ttymxc2, the settings for which are shown below.

root@imx6ul-var-dart:/# stty -F /dev/ttymxc2
speed 115200 baud; line = 0;
eol = ^J;
-brkint ixoff -imaxbel
-iexten

All active UARTs use the same driver as far as I can tell.  The console (UART1) is in the tty group.

/dev

crw------- 1 root tty   207,  16 Nov 26 02:22 ttymxc0
crw------- 1 root root  207,  17 Nov 26 00:41 ttymxc1
crw------- 1 root root  207,  18 Nov 26 01:40 ttymxc2

Read all registers for UART3

0x021EC080: 00000C00 00004021 0000078C 00004000
0x021EC090: 00000B10 00002050 00004008 0000002B
0x021EC0A0: 00000000 00000029 00000C34 00000008
0x021EC0B0: 00002CA4 00000060 00000000

Read all registers for UART1

0x02020080: 00000241 0000402F 0000038C 00004002
0x02020090: 00000B01 00000040 00001080 0000002B

0x020200A0: 00000000 000001F7 00000C34 00000008
0x020200B0: 00002CA4 00000020 00000000

Device tree source include file

filename: ../kernel-source/arch/arm/boot/dts/imx6ul-imx6ull-var-dart-common.dtsi

/* Console UART */
&uart1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_uart1>;
status = "okay";
};

/* Bluetooth UART */
&uart2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_uart2>;
fsl,uart-has-rtscts;
status = "okay";
};

/* ttymxc2 UART */
&uart3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_uart3>;
fsl,uart-has-rtscts;
fsl,irda-mode;
status = "okay";
};

********** end related info **********

Any suggestions?  Should I use something else besides memtool for register writes?  I looked at devmem and devmem2, perhaps I'll try those next if I can't figure this out.

Any help is greatly appreciated.

Labels (2)
1 Solution
1,066 Views
rust_caleb
Contributor II

I figured it out.

Simply enable the clock to the UART3 peripheral.  
/unit_tests/memtool CCM.CCGR1.CG5=1

Then perform the write to UART3 registers as before.

/unit_tests/memtool/ UART3.UCR1=0x201

I read on the forums that if the module clock was disabled then memtool writes would hang the console, or somehow freeze the system.  On my system it didn't hang the console, so I didn't think to verify that the clock was enabled.  Evidently memtool writes can also fail silently if the clock is not enabled.

Also, writes to the ttymxc2 device would temporarily enable the UART3 clock, set the registers, and then when finished it would disable the clock and clear the registers.  So I assumed that UART3 was enabled and being clocked because ttymxc2 was working, but that was an incorrect conclusion to draw.

View solution in original post

3 Replies
1,066 Views
igorpadykov
NXP Employee
NXP Employee

Hi rust.caleb

as commented on below link and from memtool sources it uses dev/mem,

so one can try to enable devmem item in kernel config

https://community.nxp.com/message/536371?commentID=536371#comment-536371 

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

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

0 Kudos
1,066 Views
rust_caleb
Contributor II

/dev/mem is already installed and enabled.

root@imx6ul-var-dart:/dev# ls
autofs loop7 ram12 tty21 tty53
block mem ram13 tty22 tty54
bus memory_bandwidth ram14 tty23 tty55
char mtab ram15 tty24 tty56
console mtd0 ram2 tty25 tty57
cpu_dma_latency mtd0ro ram3 tty26 tty58
dri mtd1 ram4 tty27 tty59

As shown in the original post, memtool is successful with writes to registers in UART1.

0 Kudos
1,067 Views
rust_caleb
Contributor II

I figured it out.

Simply enable the clock to the UART3 peripheral.  
/unit_tests/memtool CCM.CCGR1.CG5=1

Then perform the write to UART3 registers as before.

/unit_tests/memtool/ UART3.UCR1=0x201

I read on the forums that if the module clock was disabled then memtool writes would hang the console, or somehow freeze the system.  On my system it didn't hang the console, so I didn't think to verify that the clock was enabled.  Evidently memtool writes can also fail silently if the clock is not enabled.

Also, writes to the ttymxc2 device would temporarily enable the UART3 clock, set the registers, and then when finished it would disable the clock and clear the registers.  So I assumed that UART3 was enabled and being clocked because ttymxc2 was working, but that was an incorrect conclusion to draw.