python serial on firefly

1.prepare on PC
Flash Ubuntu 14.04 system on Firefly-RK3288 (hereinafter referred to as FR) , uart1 connected to PC by USB to TTL serial port module,set serial rate to 9600 when use C-Kermit(or other serial communication software)

2.enable uart1 on FR
— a/kernel/arch/arm/boot/dts/firefly-rk3288.dts
+++ b/kernel/arch/arm/boot/dts/firefly-rk3288.dts
@@ -404,6 +404,13 @@
pinctrl-0 = <&uart0_xfer &uart0_cts>;
};

+&uart_bb {

  •    status = "okay";
    
  •    dma-names = "!tx", "!rx";
    
  •    pinctrl-0 = <&uart1_xfer &uart1_cts>;
    

+};
+
+
&i2c0 {
status = “okay”;
rk808: rk808@1b {

compile kernel and flash resource.img, reboot then you will find /dev/ttyS1 on FR

  1. install python-serial on FR
    sudo apt-get install python-serial

4.test it on FR:
firefly@firefly:~/test$ sudo python
Python 2.7.6 (default, Mar 22 2014, 23:30:12)
[GCC 4.8.2] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import serial
ser = serial.Serial(“/dev/ttyS1”, 9600)
count = ser.inWaiting()
count
32
ser.read(count) #read date from PC
‘firefly python serial read test\n’
ser.write(“firefly python serial write test”) #send date to PC
32
everything is going well.

5.the whole code uart_fr.py:
# -- coding: utf-8 -
import serial
import time
# open uart1
ser = serial.Serial(“/dev/ttyS1”, 9600)
ser.write(“firefly python serial*\r\n”)
def main():
while True:
# receive
count = ser.inWaiting()
if count != 0:
# read buff and echo
recv = ser.read(count)
ser.write(recv)
ser.flushInput()
# just delay
time.sleep(0.1)

if name == ‘main’:
try:
main()
except KeyboardInterrupt:
if ser != None:
ser.close()

6.run it on FR:sudo python uart_fr.py

Your article has truly stunned me, I appreciate you sharing it! The MS-700 minimum pass score resources are outstanding, and they come with no cost.