Changes

Jump to: navigation, search

Orange Pi Zero 2W

774 bytes added, 14:06, 26 September 2023
40pin UART test
# As can be seen from the table below, the available uarts are uart2, uart3, uart4 and uart5. Please note that uart0 is set as a debugging serial port by default. Please do not use uart0 as a normal serial port.
<div style="display: flex;">::{| class="wikitable" style="width:390px;margin-right: 20px;text-align: center;"
|-
| '''GPIO NO.'''
| '''Function'''
| '''Pin'''
|-| style="text-align: left;"|| style="text-align: left;"|| '''3.3V'''| '''1'''|-| '''264'''| '''PI8'''| '''TWI1-SDA'''| '''3'''|-| '''263'''| '''PI7'''| '''TWI1-SCL'''| '''5'''|-| '''269'''| '''PI13'''| '''PWM3/UART4_TX'''| '''7'''|-| style="text-align: left;"|| style="text-align: left;"|| '''GND'''| '''9'''|-| '''226'''| '''PH2'''| '''UART5_TX'''| '''11'''|-| '''227'''| '''PH3'''| '''UART5_RX'''| '''13'''|-| '''261'''| '''PI5'''| '''TWI0_SCL/UART2_TX'''| '''15'''|-| style="text-align: left;"|| style="text-align: left;"|| '''3.3V'''| '''17'''|-| '''231'''| '''PH7'''| '''SPI1_MOSI'''| '''19'''|-| '''232'''| '''PH8'''| '''SPI1_MISO'''| '''21'''|-| '''230'''| '''PH6'''| '''SPI1_CLK'''| '''23'''|-| style="text-align: left;"|| style="text-align: left;"|| '''GND'''| '''25'''|-| '''266'''| '''PI10'''| '''TWI2-SDA/UART3_RX'''| '''27'''|-| '''256'''| '''PI0'''| style="text-align: left;"|| '''29'''|-| '''271'''| '''PI15'''| style="text-align: left;"|| '''31'''|-| '''268'''| '''PI12'''| '''PWM2'''| '''33'''|-| '''258'''| '''PI2'''| style="text-align: left;"|| '''35'''|-| '''272'''| '''PI16'''| style="text-align: left;"|| '''37'''|-| style="text-align: left;"|| style="text-align: left;"|| '''GND'''| '''39'''|}{| class="wikitable" style="width:390px;margin-right: 20px;text-align: center;"|-
| '''Pin'''
| '''Function'''
| '''GPIO NO.'''
|-
| style="text-align: left;"|
| style="text-align: left;"|
| '''3.3V'''
| '''1'''
|
| '''2'''
| '''5V'''
| style="text-align: left;"|
|-
| '''264'''
| '''PI8'''
| '''TWI1-SDA'''
| '''3'''
|
| '''4'''
| '''5V'''
| style="text-align: left;"|
|-
| '''263'''
| '''PI7'''
| '''TWI1-SCL'''
| '''5'''
|
| '''6'''
| '''GND'''
| style="text-align: left;"|
|-
| '''269'''
| '''PI13'''
| '''PWM3/UART4_TX'''
| '''7'''
|
| '''8'''
| '''UART0_TX'''
| '''224'''
|-
| style="text-align: left;"|
| style="text-align: left;"|
| '''GND'''
| '''9'''
|
| '''10'''
| '''UART0_RX'''
| '''225'''
|-
| '''226'''
| '''PH2'''
| '''UART5_TX'''
| '''11'''
|
| '''12'''
| style="text-align: left;"|
| '''257'''
|-
| '''227'''
| '''PH3'''
| '''UART5_RX'''
| '''13'''
|
| '''14'''
| '''GND'''
| style="text-align: left;"|
|-
| '''261'''
| '''PI5'''
| '''TWI0_SCL/UART2_TX'''
| '''15'''
|
| '''16'''
| '''PWM4/UART4_RX'''
| '''270'''
|-
| style="text-align: left;"|
| style="text-align: left;"|
| '''3.3V'''
| '''17'''
|
| '''18'''
| style="text-align: left;"|
| '''228'''
|-
| '''231'''
| '''PH7'''
| '''SPI1_MOSI'''
| '''19'''
|
| '''20'''
| '''GND'''
| style="text-align: left;"|
|-
| '''232'''
| '''PH8'''
| '''SPI1_MISO'''
| '''21'''
|
| '''22'''
| '''TWI0_SDA/UART2_RX'''
| '''262'''
|-
| '''230'''
| '''PH6'''
| '''SPI1_CLK'''
| '''23'''
|
| '''24'''
| '''SPI1_CS0'''
| '''229'''
|-
| style="text-align: left;"|
| style="text-align: left;"|
| '''GND'''
| '''25'''
|
| '''26'''
| '''SPI1_CS1'''
| '''233'''
|-
| '''266'''
| '''PI10'''
| '''TWI2-SDA/UART3_RX'''
| '''27'''
|
| '''28'''
| '''TWI2-SCL/UART3_TX'''
| '''265'''
|-
| '''256'''
| '''PI0'''
| style="text-align: left;"|
| '''29'''
|
| '''30'''
| '''GND'''
| style="text-align: left;"|
|-
| '''271'''
| '''PI15'''
| style="text-align: left;"|
| '''31'''
|
| '''32'''
| '''PWM1'''
| '''267'''
|-
| '''268'''
| '''PI12'''
| '''PWM2'''
| '''33'''
|
| '''34'''
| '''GND'''
| style="text-align: left;"|
|-
| '''258'''
| '''PI2'''
| style="text-align: left;"|
| '''35'''
|
| '''36'''
| style="text-align: left;"|
| '''76'''
|-
| '''272'''
| '''PI16'''
| style="text-align: left;"|
| '''37'''
|
| '''38'''
| style="text-align: left;"|
| '''260'''
|-
| style="text-align: left;"|
| style="text-align: left;"|
| '''GND'''
| '''39'''
|
| '''40'''
| style="text-align: left;"|
| '''259'''
|}
</div>
<ol start="2" style="list-style-type: decimal;">
<li><p>In Linux systems, uart is turned off by default and needs to be turned on manually before it can be used. The opening steps are as follows:: </p>
<ol style="list-style-type: lower-alpha;">
<li><p>First run '''orangepi-config'''. Ordinary users remember to add &gt; '''sudo''' permissions.</p>{| class="wikitable" style="width:800px;" |-| <p>orangepi@orangepi:~$ '''sudo orangepi-config'''</p>|}</li>
<li><p>Then select '''System'''</p>
<p>[[File:zero2w-img80.png]]</p></li>
<li><p>Then select '''Hardware'''</p>
<p>[[File:zero2w-img81.png]]</p></li>
<li><p>Then use the keyboard's arrow keys to locate the position shown &gt; in the picture below, and then use the '''space''' to select the &gt; serial port you want to open.</p></li></ol></li></ol>
{| class="wikitable" style="width:800px;text-align: center;"
|-
| '''Multiplexing function in 40pin'''
[[File:zero2w-img175.png]]
</ol>
<ol start="5" style="list-style-type: lower-alpha;">
<li><p>Then select '''&lt;Save&gt;''' to save</p>
<li><p>Then select '''&lt;Back&gt;'''</p>
<p>[[File:zero2w-img84.png]]</p></li>
<li><p>Then select '''&lt;Reboot&gt;''' to restart the system to make the &gt; configuration take effect.</p>
<p>[[File:zero2w-img85.png]]</p></li></ol>
</li></ol>
<!-- -->
<ol start="3" style="list-style-type: decimal;">
<li><p>After entering the Linux system, first confirm whether there is a uart5 device node under '''<span class="mark">/dev</span>'''</p>
{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| <big><p>'''注意, linux5.4系统为/dev/ttyASx.'''</p></big>|}{| class="wikitable" style="width:800px;" |-|
<p>orangepi@orangepi:~$ '''ls /dev/ttyS*'''</p>
<p>/dev/ttySx</p>|}</li>
<li><p>Then start testing the uart interface. First use Dupont wire to short-circuit the rx and tx pins of the uart interface to be tested.</p></li>
<li><p>Use the '''gpio''' command in wiringOP to test the loopback function of the serial port as shown below. If you can see the following print, it means the serial port communication is normal.</p>
{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| <big><p>'''Note that the last x in the gpio serial /dev/ttySx command needs to be replaced with the serial number of the corresponding uart device node.'''</p></big>|}{| class="wikitable" style="width:800px;" |-| <p>orangepi@orangepi:~$ '''gpio serial /dev/ttySx &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # linux-6.1 test command'''</p><p>orangepi@orangepi:~$ '''gpio serial /dev/ttyASx &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # linux-5.4 test command'''</p>  
<p>Out: 0: -&gt; 0</p>
<p>Out: 1: -&gt; 1</p>
<p>Out: 2: -&gt; 2</p>
<p>Out: 3: -&gt; 3^C</p>|}</li>
<li><p>Finally, you can run the '''serialTest.py''' program in examples to test the loopback function of the serial port. If you can see the following print, it means that the serial port loopback test is normal.</p>
{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| <big><p>'''Note that the x in /dev/ttySx or /dev/ttyASx in the command needs to be replaced with the serial number of the corresponding uart device node.'''</p></big>|}{| class="wikitable" style="width:800px;" |-|
<p>root@orangepi:~/wiringOP-Python# '''cd examples'''</p>
<p>root@orangepi:~/wiringOP-Python/examples# '''python3 serialTest.py --device &quot;/dev/ttySx&quot; # linux6.1 use'''</p>
<p>root@orangepi:~/wiringOP-Python/examples# '''python3 serialTest.py --device &quot;/dev/ttyASx&quot; # linux5.4 use'''</p>
 
 
<p>Out: 0: -&gt; 0</p>
<p>Out: 1: -&gt; 1</p>
<p>Out: 3: -&gt; 3</p>
<p>Out: 4:^C</p>
<p>exit</p>|}</li></ol>
<span id="hardware-watchdog-test"></span>

Navigation menu