RK3588 method of operating registers through IO commands

RK3588 method of operating registers through IO commands

IO command usage

The kernel stage uses IO commands to read and write registers

io -v -1|2|4 -r|w [-l <len>] [-f <file>] <addr> [<value>]

    -v         Verbose, asks for confirmation
    -1|2|4     Sets memory access size in bytes (default byte)
    -l <len>   Length in bytes of area to access (defaults to
               one access, or whole file length)
    -r|w       Read from or Write to memory (default read)
    -f <file>  File to write on memory read, or
               to read on memory write
    <addr>     The memory address to access
    <val>      The value to write (implies -w)

Examples:
    io 0x1000                  Reads one byte from 0x1000
    io 0x1000 0x12             Writes 0x12 to location 0x1000
    io -2 -l 8 0x1000          Reads 8 words from 0x1000
    io -r -f dmp -l 100 200    Reads 100 bytes from addr 200 to file
    io -w -f img 0x10000       Writes the whole of file to memory

Note access size (-1|2|4) does not apply to file based accesses.

uboot stage register read and write command MD

Function: read and write memory.

// 读操作
md - memory display
Usage: md [.b, .w, .l, .q] address [# of objects]

// 写操作
mw - memory write (fill)
Usage: mw [.b, .w, .l, .q] address value [count]

read operation. Example: Display 0x10 consecutive data starting from address 0x76000000.

=> md.l 0x76000000 0x10
76000000: fffffffe ffffffff ffffffff ffffffff    ................
76000010: ffffffdf ffffffff feffffff ffffffff    ................
76000020: ffffffff ffffffff ffffffff ffffffff    ................
76000030: ffffffff ffffffff ffffffff ffffffff    ................

write operation. Example: Assign the address 0x76000000 to 0x1234;

=> mw.l 0x76000000 0xffff1234 // 高16位有mask
=> md.l 0x76000000 0x10       // 回读
76000000: ffff1234 ffffffff ffffffff ffffffff    ................
76000010: ffffffdf ffffffff feffffff ffffffff    ................
76000020: ffffffff ffffffff ffffffff ffffffff    ................
76000030: ffffffff ffffffff ffffffff ffffffff    ................

IO command usage environment

IO commands need to rely on DEVMEM, and DEVMEM is closed by default, so IO cannot be used by default. If you need to use IO commands for debugging, you can modify them as follows:

@ubuntu:~/rk3588_android12.0/$ vim mkcombinedroot/configs/android-11.config

If it is a GO product, it needs to be modified:

@ubuntu:~/rk3588_android12.0$ vim mkcombinedroot/configs/android-11-go.config

Delete the following line:

# CONFIG_DEVMEM is not set

If you want to compile Android, you also need to modify the following code

cd rk3588_android12.0/kernel/configs

diff --git a/android-5.10/android-base.config b/android-5.10/android-base.config
index 5de76f0..6dcdf86 100644
--- a/android-5.10/android-base.config
+++ b/android-5.10/android-base.config
@@ -2,7 +2,6 @@
 # CONFIG_ANDROID_LOW_MEMORY_KILLER is not set
 # CONFIG_ANDROID_PARANOID_NETWORK is not set
 # CONFIG_BPFILTER is not set
-# CONFIG_DEVMEM is not set
 # CONFIG_FHANDLE is not set
 # CONFIG_FW_CACHE is not set
 # CONFIG_IP6_NF_NAT is not set
diff --git a/s/android-4.19/android-base-conditional.xml b/s/android-4.19/android-base-conditional.xml
index c7de80c..fba1afa 100644
--- a/s/android-4.19/android-base-conditional.xml
+++ b/s/android-4.19/android-base-conditional.xml
@@ -17,10 +17,6 @@
 		<key>CONFIG_CPU_SW_DOMAIN_PAN</key>
 		<value type="bool">y</value>
 	</config>
-	<config>
-		<key>CONFIG_DEVKMEM</key>
-		<value type="bool">n</value>
-	</config>
 	<config>
 		<key>CONFIG_OABI_COMPAT</key>
 		<value type="bool">n</value>
@@ -77,10 +73,6 @@
 			<value type="bool">y</value>
 		</config>
 	</conditions>
-	<config>
-		<key>CONFIG_DEVKMEM</key>
-		<value type="bool">n</value>
-	</config>
 	<config>
 		<key>CONFIG_PAGE_TABLE_ISOLATION</key>
 		<value type="bool">y</value>
diff --git a/s/android-4.19/android-base.config b/s/android-4.19/android-base.config
index d2bb2ad..8f23882 100644
--- a/s/android-4.19/android-base.config
+++ b/s/android-4.19/android-base.config
@@ -2,7 +2,6 @@
 # CONFIG_ANDROID_LOW_MEMORY_KILLER is not set
 # CONFIG_ANDROID_PARANOID_NETWORK is not set
 # CONFIG_BPFILTER is not set
-# CONFIG_DEVMEM is not set
 # CONFIG_FHANDLE is not set
 # CONFIG_FW_CACHE is not set
 # CONFIG_IP6_NF_NAT is not set
diff --git a/s/android-5.10/android-base-conditional.xml b/s/android-5.10/android-base-conditional.xml
index aae1847..2dc3e25 100644
--- a/s/android-5.10/android-base-conditional.xml
+++ b/s/android-5.10/android-base-conditional.xml
@@ -17,10 +17,6 @@
 		<key>CONFIG_CPU_SW_DOMAIN_PAN</key>
 		<value type="bool">y</value>
 	</config>
-	<config>
-		<key>CONFIG_DEVKMEM</key>
-		<value type="bool">n</value>
-	</config>
 	<config>
 		<key>CONFIG_OABI_COMPAT</key>
 		<value type="bool">n</value>
@@ -101,10 +97,6 @@
 			<value type="bool">y</value>
 		</config>
 	</conditions>
-	<config>
-		<key>CONFIG_DEVKMEM</key>
-		<value type="bool">n</value>
-	</config>
 	<config>
 		<key>CONFIG_KFENCE</key>
 		<value type="bool">y</value>
diff --git a/s/android-5.10/android-base.config b/s/android-5.10/android-base.config
index d6e1f5a..d7078da 100644
--- a/s/android-5.10/android-base.config
+++ b/s/android-5.10/android-base.config
@@ -2,7 +2,6 @@
 # CONFIG_ANDROID_LOW_MEMORY_KILLER is not set
 # CONFIG_ANDROID_PARANOID_NETWORK is not set
 # CONFIG_BPFILTER is not set
-# CONFIG_DEVMEM is not set
 # CONFIG_FHANDLE is not set
 # CONFIG_FW_CACHE is not set
 # CONFIG_IP6_NF_NAT is not set

RK3588 register address viewing method

The registers of RK3588 can be queried through the TRM manual of the chip. The address of the register is composed of Operational Base + offset. For example, the address of the iomux register of the GPIO2C group of GPIO is: 0XFD5F8000+0X0050=0XFD5F8050. The
base address of the register is described in the Address Mapping chapter of TRM

Example: Check the iomux status of GPIO through the IO command

To view the GPIO functions of GPIO2C4, you can search for gpio2c4 in TRM, and wait for the following information.
The register description of GPIO2C4 IOMUX is as follows:
insert image description here
From the above search results, it can be seen that the IOMUX of GPIO2C4 belongs to BUS_IOC, so you can continue to search for BUS_IOC, and you can get the BUS_IOC Base address:
insert image description here
From the above information, you can wait until the IOMUX register address of GPIO2C4 is: 0XFD5F8000+0X0054=0XFD5F8054
Read the value of the register through the IO command

rk3588_s:/ # io -4 -r 0XFD5F8054
fd5f8054:  00000000

Example: Set the iomux status of GPIO through the IO command

Write the register through the IO command
to set the function of GPIO2C4 to UART9_RX_M0

rk3588_s:/ # io -4 -w 0XFD5F8054 0x000a000a   //设置0XFD5F8054寄存器的值为0x000a000a   
rk3588_s:/ # io -4 -r 0XFD5F8054  //回读确认是否正确写入
fd5f8054:  0000000a

Guess you like

Origin blog.csdn.net/weixin_43245753/article/details/126879997