1 Introduction
Everything is difficult at the beginning~~ And installing the development environment is the beginning of learning a new technology. When installing the development environment, do you often encounter a lack of dependency here and a lack of configuration there? I haven't done it for a long time. And the boss is already standing behind and staring at him: Can't handle such a simple thing? !
In order to solve various problems encountered in the installation and development environment, the Docker version of the AliOS Things development environment was born. Only one "install" command is needed to help developers of AliOS Things install the development environment.
2. Introduction to development environment
The AliOS Things development environment described in this article consists of 2 parts:
- The script that runs on the host computer (that is, the computer you are using) can be downloaded from gitee. For details, see the section "Download One-Click Installation Tool" 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烧录工具,目前仅支持haas100
└── 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 logic block diagram is shown in the figure below.
3. Installation
3.1. Download the one-click installation tool
- git code download
git clone https://gitee.com/alios-things/dev_tool.git
- Download via http
https://gitee.com/alios-things/dev_tool/repository/archive/master.zip
3.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 may take about 5 to 30 minutes, depending on the system configuration and network speed, the installation process requires user input) :
- Install Docker software and its dependent tools
- Download the Docker image rtos:v0.1 that contains 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.
4. Development and use
4.1, login 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, and 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
4.2, configuration and compilation
After logging in successfully, you can see the familiar Visual Studio Code page and the already downloaded AliOS Things code.
You can configure APP and Board on this page, and then compile the code.
4.3. Burn firmware
- Click on the ⚡️ symbol in the status bar below, and then select the serial port for burning to burn the firmware.
Check the log in the host's serial port tool, and press the reset button on the board when you see "Please reboot the board manually".
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 code, and burn the firmware.
- Use the command to
docker ps -a
check whether docker is in running status, as shown in the following figure:
STATUS: running status, UP normal startup status, other status indicates that the container is not running 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 63914 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, use ssh code-server Log in to the container.
Host code-server
User root
HostName 127.0.0.1
Port 63914 #请根据docker ps命令查找22对应的端口号填写
6. 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
parameters, 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
7, 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
8. 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.
9. Detailed installation video
Windows version: Installation video link
Linux version: Installation video link
MacOS version: Installation video link
If you need more technical support, you can join the Dingding Developer Group
For more technology and solution introduction, please visit the Aliyun AIoT homepage https://iot.aliyun.com/