2621 views|6 replies

155

Posts

1

Resources
The OP
 

[Luckfox RV1106 Linux Development Board Review] 4. Access the Internet and Ubun through a PC shared network... [Copy link]

 

My post [Luckfox RV1106 Linux Development Board Review] link:

1. Unboxing and testing

2. SDK acquisition and image compilation

3. GPIO Lighting

1. Access the Internet

The GPIO section of Luckfox also mentioned the method of controlling IO with Python, but the Buildroot image does not include Python. Then I saw the content of configuring Buildroot to add software packages through menuconfig in the Buildroot configuration section of the document, but when I checked the downloaded SDK directory, there was no relevant content in the corresponding location. After that, I asked a question in the Luckfox forum, and the administrator answered quickly: "The Python source code is not in the SDK."

Figure 4-1 There is no Buildroot related content in the SDK

So, I decided to plug in the TF card and switch to the Ubuntu image (the image compiled by me in the second review), and then tried to install Python in Ubuntu using apt, only to find that the development board could not access the Internet. It makes sense, the development board is a local area network built by RNDIS and PC, so of course it cannot access the Internet. The board has an RJ45 connector, and plugging the development board into the router should allow access to the Internet, but the router at home is hung on the wall, and it is troublesome to connect a long network cable. Later, I found a method on the Internet to share the network adapter of the PC connected to the Internet with the development board. The details are as follows:

First, share the network adapter in the Win10 system, and share the PC's Internet adapter (WLAN here) to the development board's RNDIS, which is Ethernet 3 in the figure below. However, after sharing, the IP address of RNDIS will become 192.168.137.1, which is an inevitable change in the shared network in Windows - there will also be a pop-up reminder when clicking Share.

Figure 4-2 Sharing the “Internet access” adapter in the PC to the RNDIS adapter

Next, we need to modify the static IP of the development board to the same network segment. Because the RNDIS of the development board does not have DHCP, it cannot automatically obtain an IP. Fortunately, the board has the ifconfig command, which can be used to modify it. Still, log in to the development board console through adb shell, and then enter the command:

# Modify the static IP of the development board

ifconfig usb0 192.168.137.2

# Set the gateway, which is the IP address of the RNDIS in the PC

route add default gw 192.168.137.1

Figure 4-3 Development board pinging Baidu IP result

At this point, the development board can access the Internet and ping Baidu IP successfully. However, the domain name cannot be used yet because the development board does not have a DNS service, so the last step is to edit the "/etc/resolv.conf" file and write: "nameserver 114.114.114.114".

Figure 4-4 Adding a domain name server IP

Figure 4-5 Result of pinging www.baidu.com

2. Python controls IO

The development board is connected to the Internet. Since it is an Ubuntu system, it can download software through apt, so I executed sudo apt update, sudo apt install python3. It turned out that the system image comes with Python3. Previously, when I used the "python" command, it prompted that it could not be found. I should use the "python3" command. However, it is still necessary for the development board to be able to access the Internet, because there is also pip to install Python packages.

According to the sample code in the document, you need to install the python-periphery library - note that the library name has the python- prefix. Looking at the code, I directly wrote periphery. As a result, I spent a long time and found out that the library name was wrong after searching on Baidu.

Figure 4-6 Python library on the development board Ubuntu system

The Python sample program in the document is as follows. It controls the output of IO55 and flips it, and then reads the value of IO54. However, there is a delay missing in the sample code. Without this delay, the LED will not turn off but remain on.

from periphery import GPIO
import time

Write_Pin = 55
Read_Pin = 54

Write_GPIO = GPIO(Write_Pin, "out")
Read_GPIO = GPIO(Read_Pin, "in")

try:
    while True:
        try:
            Write_GPIO.write(True)
            pin_state = Read_GPIO.read()
            print(f"Pin state: {pin_state}")
            # 示例没有这个延时,所以IO输出高观测不到,加上就可以闪烁灯了
            time.sleep(1)

            Write_GPIO.write(False)
            pin_state = Read_GPIO.read()
            print(f"Pin state: {pin_state}")
            time.sleep(1)

        except KeyboardInterrupt:
            Write_GPIO.write(False)
            break

except IOError:
    print("Error")

finally:
    Write_GPIO.close()
    Read_GPIO.close()

This post is from Domestic Chip Exchange

Latest reply

Blogger, when I burned buildroot, the burning failed Error: Write LBA failed, can't read flash id from device! And the download of Downloadbin file failed. What should I do? Have you encountered similar problems?   Details Published on 2024-2-6 15:33
 
 

6062

Posts

4

Resources
2
 

Thank you for your hard work!

This post is from Domestic Chip Exchange
 
 
 

270

Posts

0

Resources
3
 

Study


This post is from Domestic Chip Exchange
 
 
 

364

Posts

0

Resources
4
 

Yes, I am using rj45 now, and typeC allows me to change it to host

This post is from Domestic Chip Exchange

Comments

Indeed, I just realized that I only did the Ubuntu image compilation, so I only downloaded the Ubuntu source code. I must do the Buildroot compilation again to get the source code. Thanks for the reminder.  Details Published on 2024-1-29 22:23
 
 
 

155

Posts

1

Resources
5
 
LitchiCheng posted on 2024-1-27 20:58 Yes, I am using rj45 now, and typeC allows me to change it to host

Indeed, I just realized that I only did the Ubuntu image compilation, so I only downloaded the Ubuntu source code. I must do the Buildroot compilation again to get the source code. Thanks for the reminder.

This post is from Domestic Chip Exchange
 
 
 

3

Posts

0

Resources
6
 

Blogger, when I burned buildroot, the burning failed Error: Write LBA failed, can't read flash id from device! And the download of Downloadbin file failed. What should I do? Have you encountered similar problems?

This post is from Domestic Chip Exchange

Comments

I haven't encountered this before. My tests have been relatively smooth. Sorry.  Details Published on 2024-2-6 23:26
 
 
 

155

Posts

1

Resources
7
 
The Silence of the Lambs 1 Published on 2024-2-6 15:33 Blogger, when I burned buildroot, the burning failed Error: Write LBA failed, can't read flash id from device! And download...

I haven't encountered this before. My tests have been relatively smooth. Sorry.

This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list