Difference between revisions of "Rock3/CM3/raspcm4io"
Line 9: | Line 9: | ||
== Resource == | == Resource == | ||
+ | |||
+ | ====<span id="gpio">General purpose input-output (GPIO) connector</span> ==== | ||
+ | |||
+ | CM4 IO has a 40-pin expansion header. Each pin is distinguished by color. | ||
+ | |||
+ | {| class="wikitable" style="vertical-align:middle;" | ||
+ | |- style="font-weight:bold; text-align:center;" | ||
+ | ! GPIO number | ||
+ | ! Function4 | ||
+ | ! Function3 | ||
+ | ! Function2 | ||
+ | ! Function1 | ||
+ | ! Pin# | ||
+ | ! | ||
+ | ! Pin# | ||
+ | ! Function1 | ||
+ | ! Function2 | ||
+ | ! Function3 | ||
+ | ! Function4 | ||
+ | ! GPIO number | ||
+ | |- | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | +3.3V | ||
+ | | style="background-color:#FF0;" | 1 | ||
+ | | | ||
+ | | style="background-color:#F00;" | 2 | ||
+ | | +5.0V | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |- | ||
+ | | 14 | ||
+ | | SPI0_MOSI_M0 | ||
+ | | I2C2_SDA_M0 | ||
+ | | PWM2_M1 | ||
+ | | GPIO0_B6 | ||
+ | | style="background-color:#008000; color:#FFF;" | 3 | ||
+ | | | ||
+ | | style="background-color:#F00;" | 4 | ||
+ | | +5.0V | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |- | ||
+ | | 13 | ||
+ | | SPI0_CLK_M0 | ||
+ | | I2C2_SCL_M0 | ||
+ | | PWM1_M1 | ||
+ | | GPIO0_B5 | ||
+ | | style="background-color:#008000; color:#FFF;" | 5 | ||
+ | | | ||
+ | | style="background-color:#000; color:#FFF" | 6 | ||
+ | | GND | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |- | ||
+ | | 125 | ||
+ | | | ||
+ | | I2S1_SDI3_M1 | ||
+ | | SDMMC2_PWREN_M0 | ||
+ | | GPIO3_D5 | ||
+ | | style="background-color:#008000; color:#FFF;" | 7 | ||
+ | | | ||
+ | | style="background-color:#008000; color:#FFF;" | 8 | ||
+ | | GPIO0_D1 | ||
+ | | style="background-color:#FFA500;" | UART2_TX_M0 | ||
+ | | | ||
+ | | | ||
+ | | 25 | ||
+ | |- | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | GND | ||
+ | | style="background-color:#000; color:#FFF" | 9 | ||
+ | | | ||
+ | | style="background-color:#008000; color:#FFF;" | 10 | ||
+ | | GPIO0_D0 | ||
+ | | style="background-color:#FFA500;" | UART2_RX_M0 | ||
+ | | | ||
+ | | | ||
+ | | 24 | ||
+ | |- | ||
+ | | 23 | ||
+ | | | ||
+ | | UART0_CTSn | ||
+ | | PWM0_M1 | ||
+ | | GPIO0_C7 | ||
+ | | style="background-color:#008000; color:#FFF;" | 11 | ||
+ | | | ||
+ | | style="background-color:#008000; color:#FFF;" | 12 | ||
+ | | GPIO3_C7 | ||
+ | | I2S1_SCLK_TX_M1 | ||
+ | | | ||
+ | | | ||
+ | | 119 | ||
+ | |- | ||
+ | | 15 | ||
+ | | | ||
+ | | | ||
+ | | PWM0_M0 | ||
+ | | GPIO0_B7 | ||
+ | | style="background-color:#008000; color:#FFF;" | 13 | ||
+ | | | ||
+ | | style="background-color:#000; color:#FFF" | 14 | ||
+ | | GND | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |- | ||
+ | | 19 | ||
+ | | | ||
+ | | PWM4 | ||
+ | | VOP_PWM_M0 | ||
+ | | GPIO0_C3 | ||
+ | | style="background-color:#008000; color:#FFF;" | 15 | ||
+ | | | ||
+ | | style="background-color:#008000; color:#FFF;" | 16 | ||
+ | | GPIO3_D4 | ||
+ | | I2S1_SDI2_M1 | ||
+ | | | ||
+ | | | ||
+ | | 124 | ||
+ | |- | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | +3.3V | ||
+ | | style="background-color:#FF0;" | 17 | ||
+ | | | ||
+ | | style="background-color:#008000; color:#FFF;" | 18 | ||
+ | | GPIO3_D3 | ||
+ | | I2S1_SDI1_M1 | ||
+ | | | ||
+ | | | ||
+ | | 123 | ||
+ | |- | ||
+ | | 138 | ||
+ | | I2S2_SDI_M1 | ||
+ | | SPI3_MOSI_M0 | ||
+ | | I2C4_SDA_M0 | ||
+ | | GPIO4_B2 | ||
+ | | style="background-color:#008000; color:#FFF;" | 19 | ||
+ | | | ||
+ | | style="background-color:#000; color:#FFF" | 20 | ||
+ | | GND | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |- | ||
+ | | 136 | ||
+ | | | ||
+ | | SPI3_MISO_M0 | ||
+ | | I2S1_SDO1_M1 | ||
+ | | GPIO4_B0 | ||
+ | | style="background-color:#008000; color:#FFF;" | 21 | ||
+ | | | ||
+ | | style="background-color:#008000; color:#FFF;" | 22 | ||
+ | | GPIO3_C6 | ||
+ | | I2S1_MCLK_M1 | ||
+ | | | ||
+ | | | ||
+ | | 118 | ||
+ | |- | ||
+ | | 139 | ||
+ | | I2S2_SDO_M1 | ||
+ | | SPI3_CLK_M0 | ||
+ | | I2C4_SCL_M0 | ||
+ | | GPIO4_B3 | ||
+ | | style="background-color:#008000; color:#FFF;" | 23 | ||
+ | | | ||
+ | | style="background-color:#008000; color:#FFF;" | 24 | ||
+ | | GPIO4_A6 | ||
+ | | I2S1_SCLK_RX_M1 | ||
+ | | SPI3_CS0_M0 | ||
+ | | | ||
+ | | 134 | ||
+ | |- | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | GND | ||
+ | | style="background-color:#000; color:#FFF" | 25 | ||
+ | | | ||
+ | | style="background-color:#008000; color:#FFF;" | 26 | ||
+ | | SARADC_IN3 | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |- | ||
+ | | 140 | ||
+ | | | ||
+ | | | ||
+ | | I2C2_SDA_M1 | ||
+ | | GPIO4_B4 | ||
+ | | style="background-color:#00F; color:#FFF;" | 27 | ||
+ | | | ||
+ | | style="background-color:#00F; color:#FFF;" | 28 | ||
+ | | GPIO4_B5 | ||
+ | | I2S1_SDO3_M1 | ||
+ | | I2C2_SCL_M1 | ||
+ | | | ||
+ | | 141 | ||
+ | |- | ||
+ | | 137 | ||
+ | | | ||
+ | | I2S1_SDO2_M1 | ||
+ | | ISP_PRELIGHT_TRIG | ||
+ | | GPIO4_B1 | ||
+ | | style="background-color:#008000; color:#FFF;" | 29 | ||
+ | | | ||
+ | | style="background-color:#000; color:#FFF" | 30 | ||
+ | | GND | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |- | ||
+ | | 21 | ||
+ | | | ||
+ | | SPI0_MISO_M0 | ||
+ | | PWM6 | ||
+ | | GPIO0_C5 | ||
+ | | style="background-color:#008000; color:#FFF;" | 31 | ||
+ | | | ||
+ | | style="background-color:#008000; color:#FFF;" | 32 | ||
+ | | GPIO4_C0 | ||
+ | | PWM11_IR_M1 | ||
+ | | | ||
+ | | | ||
+ | | 144 | ||
+ | |- | ||
+ | | 22 | ||
+ | | | ||
+ | | SPI0_CS0_M0 | ||
+ | | PWM7_IR | ||
+ | | GPIO0_C6 | ||
+ | | style="background-color:#008000; color:#FFF;" | 33 | ||
+ | | | ||
+ | | style="background-color:#000; color:#FFF" | 34 | ||
+ | | GND | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |- | ||
+ | | 120 | ||
+ | | | ||
+ | | | ||
+ | | I2S1_LRCK_TX_M1 | ||
+ | | GPIO3_D0 | ||
+ | | style="background-color:#008000; color:#FFF;" | 35 | ||
+ | | | ||
+ | | style="background-color:#008000; color:#FFF;" | 36 | ||
+ | | GPIO4_A7 | ||
+ | | I2S1_LRCK_RX_M1 | ||
+ | | SPI3_CS1_M0 | ||
+ | | | ||
+ | | 135 | ||
+ | |- | ||
+ | | 18 | ||
+ | | | ||
+ | | | ||
+ | | PWM3_IR | ||
+ | | GPIO0_C2 | ||
+ | | style="background-color:#008000; color:#FFF;" | 37 | ||
+ | | | ||
+ | | style="background-color:#008000; color:#FFF;" | 38 | ||
+ | | GPIO3_D2 | ||
+ | | I2S1_SDI0_M1 | ||
+ | | | ||
+ | | | ||
+ | | 122 | ||
+ | |- | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | GND | ||
+ | | style="background-color:#000; color:#FFF" | 39 | ||
+ | | | ||
+ | | style="background-color:#008000; color:#FFF;" | 40 | ||
+ | | GPIO3_D1 | ||
+ | | I2S1_SDO0_M1 | ||
+ | | | ||
+ | | | ||
+ | | 121 | ||
+ | |} | ||
+ | |||
+ | ==== More details about 40-pin Header ==== | ||
+ | |||
+ | * Pins marked with color orange are designed for debug console. | ||
+ | * PWM:x7,PWM0/PWM1/PWM2/PWM3/PWM6/PWM7/PWM11 | ||
+ | * SPI:X2,SPI0/SPI3 | ||
+ | * I2C:X2,I2C2/I2C4 | ||
+ | * UART:X2,UART0/UART2 | ||
+ | * ADC:X1, SARADC_IN3 | ||
+ | * I2S:X2, I2S1/I2S2 | ||
+ | |||
+ | === IO Voltage === | ||
+ | |||
+ | RK3566 have three IO voltages, 1.8V/3.3V. For CM4 IO, the high level voltage of GPIO pin on 40-PIN HEADER is 3.3V. | ||
+ | |||
+ | <pre> | ||
+ | | GPIO | Voltage Level | Tolerance | | ||
+ | | ---------- | ------------- | --------- | | ||
+ | | SARADC_IN3 | 1.8V | 1.98V | | ||
+ | </pre> | ||
+ | |||
+ | === GPIO number === | ||
+ | |||
+ | Rockchip RK3566 GPIO has 5 banks, GPIO0 to GPIO4, each bank has 32pins, naming as below: | ||
+ | |||
+ | GPIO0_A0 ~ A7 | ||
+ | GPIO0_B0 ~ B7 | ||
+ | GPIO0_C0 ~ C7 | ||
+ | GPIO0_D0 ~ D7 | ||
+ | |||
+ | GPIO1_A0 ~ A7 | ||
+ | .... | ||
+ | GPIO1_D0 ~ D7 | ||
+ | |||
+ | The GPIO number can be calculated as below, take GPIO4_D1 (PIN26 on 4-0PIN HEADER) as an example: | ||
+ | |||
+ | GPIO4_D1 = 4*32 + 3*8 + 1 = 153 | ||
+ | (A=0, B=1, C=2, D=3) | ||
+ | |||
+ | To set GPIO4_D1 output | ||
+ | |||
+ | cd /sys/class/gpio | ||
+ | echo 153 > export | ||
+ | cd gpio153 | ||
+ | echo out > direction | ||
+ | echo 1 > value # output high | ||
+ | echo 0 > value # output low |
Revision as of 03:09, 12 October 2021
ROCK 3 > Compute Module 3 > Raspberry Pi CM4 IO Board
Contents
Getting Started
Status
Resource
General purpose input-output (GPIO) connector
CM4 IO has a 40-pin expansion header. Each pin is distinguished by color.
GPIO number | Function4 | Function3 | Function2 | Function1 | Pin# | Pin# | Function1 | Function2 | Function3 | Function4 | GPIO number | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
+3.3V | 1 | 2 | +5.0V | |||||||||
14 | SPI0_MOSI_M0 | I2C2_SDA_M0 | PWM2_M1 | GPIO0_B6 | 3 | 4 | +5.0V | |||||
13 | SPI0_CLK_M0 | I2C2_SCL_M0 | PWM1_M1 | GPIO0_B5 | 5 | 6 | GND | |||||
125 | I2S1_SDI3_M1 | SDMMC2_PWREN_M0 | GPIO3_D5 | 7 | 8 | GPIO0_D1 | UART2_TX_M0 | 25 | ||||
GND | 9 | 10 | GPIO0_D0 | UART2_RX_M0 | 24 | |||||||
23 | UART0_CTSn | PWM0_M1 | GPIO0_C7 | 11 | 12 | GPIO3_C7 | I2S1_SCLK_TX_M1 | 119 | ||||
15 | PWM0_M0 | GPIO0_B7 | 13 | 14 | GND | |||||||
19 | PWM4 | VOP_PWM_M0 | GPIO0_C3 | 15 | 16 | GPIO3_D4 | I2S1_SDI2_M1 | 124 | ||||
+3.3V | 17 | 18 | GPIO3_D3 | I2S1_SDI1_M1 | 123 | |||||||
138 | I2S2_SDI_M1 | SPI3_MOSI_M0 | I2C4_SDA_M0 | GPIO4_B2 | 19 | 20 | GND | |||||
136 | SPI3_MISO_M0 | I2S1_SDO1_M1 | GPIO4_B0 | 21 | 22 | GPIO3_C6 | I2S1_MCLK_M1 | 118 | ||||
139 | I2S2_SDO_M1 | SPI3_CLK_M0 | I2C4_SCL_M0 | GPIO4_B3 | 23 | 24 | GPIO4_A6 | I2S1_SCLK_RX_M1 | SPI3_CS0_M0 | 134 | ||
GND | 25 | 26 | SARADC_IN3 | |||||||||
140 | I2C2_SDA_M1 | GPIO4_B4 | 27 | 28 | GPIO4_B5 | I2S1_SDO3_M1 | I2C2_SCL_M1 | 141 | ||||
137 | I2S1_SDO2_M1 | ISP_PRELIGHT_TRIG | GPIO4_B1 | 29 | 30 | GND | ||||||
21 | SPI0_MISO_M0 | PWM6 | GPIO0_C5 | 31 | 32 | GPIO4_C0 | PWM11_IR_M1 | 144 | ||||
22 | SPI0_CS0_M0 | PWM7_IR | GPIO0_C6 | 33 | 34 | GND | ||||||
120 | I2S1_LRCK_TX_M1 | GPIO3_D0 | 35 | 36 | GPIO4_A7 | I2S1_LRCK_RX_M1 | SPI3_CS1_M0 | 135 | ||||
18 | PWM3_IR | GPIO0_C2 | 37 | 38 | GPIO3_D2 | I2S1_SDI0_M1 | 122 | |||||
GND | 39 | 40 | GPIO3_D1 | I2S1_SDO0_M1 | 121 |
More details about 40-pin Header
- Pins marked with color orange are designed for debug console.
- PWM:x7,PWM0/PWM1/PWM2/PWM3/PWM6/PWM7/PWM11
- SPI:X2,SPI0/SPI3
- I2C:X2,I2C2/I2C4
- UART:X2,UART0/UART2
- ADC:X1, SARADC_IN3
- I2S:X2, I2S1/I2S2
IO Voltage
RK3566 have three IO voltages, 1.8V/3.3V. For CM4 IO, the high level voltage of GPIO pin on 40-PIN HEADER is 3.3V.
| GPIO | Voltage Level | Tolerance | | ---------- | ------------- | --------- | | SARADC_IN3 | 1.8V | 1.98V |
GPIO number
Rockchip RK3566 GPIO has 5 banks, GPIO0 to GPIO4, each bank has 32pins, naming as below:
GPIO0_A0 ~ A7 GPIO0_B0 ~ B7 GPIO0_C0 ~ C7 GPIO0_D0 ~ D7 GPIO1_A0 ~ A7 .... GPIO1_D0 ~ D7
The GPIO number can be calculated as below, take GPIO4_D1 (PIN26 on 4-0PIN HEADER) as an example:
GPIO4_D1 = 4*32 + 3*8 + 1 = 153 (A=0, B=1, C=2, D=3)
To set GPIO4_D1 output
cd /sys/class/gpio echo 153 > export cd gpio153 echo out > direction echo 1 > value # output high echo 0 > value # output low