AliOS Things Docker version development environment (suitable for beginners)

 

1. Introduction to the Docker development environment

The Docker version of AliOS Things development environment consists of 2 parts:

  • The script that runs on the host machine (that is, the computer you are using) can be downloaded from gitee. For details, see the "Download One-Click Installation Tool" section below. The directory structure is as follows:
dev_tool

├── dev_tool_linux.sh         # 一键安装脚本,Ubuntu版本

├── dev_tool_osx.sh           # 一键安装脚本,MacOS版本

├── dev_tool_win.bat          # 一键安装脚本,Win10版本

├── README.md                 # 说明文档

├── pic                       # 说明文档中使用的图片

├── aos_burn_tool             # aos烧录工具

└── utilities                 # 其它脚本和工具

 

  • The docker container is installed by the one-click installation script mentioned above. After the container is installed and started, the user can use the browser on the host to connect to the container in HTTP mode, view the code in the docker container, or edit, compile the code, and burn the firmware. The installed docker container contains the following:
├──ubuntu 20.04               #容器系统    

├──sshd                       #远程连接服务工具

├──aos-cube                   #AliOS Things的集成开发工具

├──dev_3.1.0_haas             #AliOS Things的dev_3.1.0_haas分支源代码

└──code-server               #网页版的Visual Studio Code
  • The logical block diagram of the development environment is shown in the figure below.

 

2. Installation

2.1. Download the one-click installation tool

2.2, one-click installation

Enter the dev_tool directory cd dev_tool and execute the corresponding script according to the computer system:

MacOS: bash ./dev_tool_osx.sh -i

Ubuntu: bash ./dev_tool_linux.sh -i

Win10: .\dev_tool_win.bat -i

The installation script will complete the following tasks. The entire installation process takes about 5-30 minutes, depending on the system configuration and network speed. During the installation process, the user is required to enter a password :

  • Install docker software and its dependent tools
  • Download the docker image rtos:v0.1 containing AliOS Things development tools
  • Use rtos:v0.1 to create a docker container, and download the source code of the dev_3.1.0_haas branch of AliOS Things to the /workspace/AliOS-Things directory in the container
  • Install code-server and AliOS Studio in the docker container as a Web IDE developed by AliOS Things

If the installation fails, you can execute the command again to reinstall.

Note for Win system :

  • If downloading the Docker installation file from the Docker official website is slow, you can use the command .\dev_tool_win.bat -m instead of .\dev_tool_win.bat -i. This command will download the installation file from the Alibaba Cloud mirror site and install it. Using this command may download a mirror that is not the latest version.
  • Some additional manual operations, please choose according to the following picture

A prompt of Installing Docker Desktop appears , please make sure to select Enable Hyper-V Windows Feature and Install required Windows components for WSL2 , and then click the "OK" button to start installing docker.

After the installation is complete, click the "Close and Restart" button to restart the computer. After restarting the computer, you need to enter the "one-click installation" command again to continue the installation .

A python installation page similar to Python 3.9.1 (64-bit) Setup appears , please make sure to select Add Python 3.9 to PATH , and then click the "Install Now" button to start installing python.

MacOS system notes :

  • During the Installing Cask docker stage, there will be a long pause, please be patient
  • If downloading the Docker installation file from the Docker official website is slow, you can use the command bash ./dev_tool_osx.sh -m instead of bash ./dev_tool_osx.sh -i. This command downloads the installation file from the Alibaba Cloud mirror site and installs it. Using this command may download a mirror that is not the latest version.
  • Some additional manual operations, please choose according to the following picture

A prompt appears that "Docker" is an App downloaded from the Internet . Are you sure you want to open it? , Please click the "Open" button

A prompt "Docker Desktop needs privileged access" appears , please click the "OK" button

A prompt "Docker" is trying to install a new helper tool , please enter the password and click the "Install Helper" button

A similar pop-up window that prompts "Docker" to access files in the " Desktop " folder appears , please click the "OK" button

If the pop-up page docker software directly, indicating that the user first installed docker, users simply minimized to

  • One-click installation demo video

 

3.  Development and use

3.1, log in to code-server

After the one-click installation is successful, the browser will automatically open and enter the login code-server page

Password acquisition method

  • After successfully logging in to the web page, the system has automatically copied the password to the clipboard, just click the right mouse button in the password box, then select "Paste" in the menu, and click "SUBMIT" to log in to the server
  • In the terminal window where the "one-click installation" script is executed, search for the keyword password, as shown in the figure below, password:<password>, copy the password

 

It is recommended that users change their passwords as soon as possible. The way to change the password is as follows:

MacOS: bash ./dev_tool_osx.sh -p

Ubuntu: bash ./dev_tool_linux.sh -p

Win10: .\dev_tool_win.bat -p

 

3.2, configuration and compilation

Use the AliOS Studio plug-in pre-installed on the code-server, select the app and board, and click the "√" sign in the lower left corner to compile.

  • Click the box helloworld@developerkit in the lower left corner, and select app helloworld_demo in the subsequent pop-up window

  • Select the development board model haaseduk1

  • Click the "√" sign below to compile

   

  • After the compilation is successful, you can see the generated elf file and bin file in the out/helloworld_demo@haaseduk1/binary directory

3.3. Burn firmware

  • Click on the ⚡️ logo in the status bar below

   

  • Follow the prompts to select the corresponding serial port to start programming. The serial port configuration information will be saved in the .aos_config_burn file in the code root directory. If there is a change in the subsequent serial port, you can delete the file before burning.
  • Switch back to the original terminal (the terminal that started the command line of the IDE) to view the detailed burn log. If Please reboot the board manually. appears in the log or you hear a beep every second, please press the reset button to manually reset the development board
  • The prompt message after successful burning is shown in the figure below

​​​​​​​

  • If Communicated with host pc is failed. Please start flash programmer in host pc. is prompted during the burning process, you need to use the "open docker again" described below, this command will start a burning monitoring program in the background; then restart Burn.

 

4.  Open docker again

After the installation is successful, the docker container will run in the background. If you restart the machine next time, you can use the -s parameter to run the installation script and reopen docker.

MacOS: bash ./dev_tool_osx.sh -s

Ubuntu: bash ./dev_tool_linux.sh -s

Win10: .\dev_tool_win.bat -s

 

5. SSH connection

For developers who are not accustomed to using Web IDE, you can also connect to docker through ssh, enter the container to view the code, compile the version, and burn the firmware.

  • Use the command docker ps -a to check whether the docker is running, as shown in the following figure:
    STATUS: running status, UP normal startup status, other status indicates that the container is not operating normally, please refer to the method described in the "open docker again" chapter to reopen
    PORTS: Port mapping status, port 22 in the container corresponds to port 64028 of the host

  • Use SSH to connect:

        Method 1 : Command line ssh -p <port> [email protected], where port is the host port number, as shown in the figure below

  • Method 2 : vscode+ssh remote plug-in, if you have installed the vscode and ssh remote plug-ins on the host machine (that is, the computer that the user is using), please modify the ~/.ssh/config file and add the following 4 lines. After the configuration is complete , Log in to the container through ssh code-server.

Host code-server

 User root

 HostName 127.0.0.1

 Port 64028 #Please fill in the port number corresponding to 22 according to the docker ps command

 

6. Delete the docker image

To delete the docker image rtos:v0.1 of AliOS Things and its corresponding container, please execute the following command

MacOS: bash ./dev_tool_osx.sh -r

Ubuntu: bash ./dev_tool_linux.sh -r

Win10: .\dev_tool_win.bat -r

 

7. Uninstall the docker tool

MacOS: bash ./dev_tool_osx.sh -u

Ubuntu: bash ./dev_tool_linux.sh -u

Win10: .\dev_tool_win.bat -u

Note: This command will delete all docker images on the host , please use it with caution.

 

8. Developer technical support

If you need more technical support, you can join the DingTalk developer group, or follow the WeChat public account

For more technology and solution introduction, please visit the Aliyun AIoT homepage https://iot.aliyun.com/

Guess you like

Origin blog.csdn.net/HaaSTech/article/details/114283824