In my "embedded native remote development environment" approach plays Microsoft Visual Studio Code Insider the primary roll as development IDE with a SSH-connection to the SoC-FPGA development board. VS Code can not only be used for Python development but for C++ application development and debugging and for Webinterface design, as well. For every use case please follow this guide to see how you can establish a remote connection between VS Code and rsyocto.
My pre-configured and preferred Linux application development approach for C++,Python and Web
This guide describes how to install and configure Visual Studio Code Insiders to access the Linux system remotely over a ssh-connection
. Later on is shown how to use Visual Studio Code to remote debug Phyton applications.
Visual Studio Code is a code editor built by Microsoft. It is an universal binary application and runs on Windows, Linux and macOS. Visual Studio Code Insider is a special version and extended Visual Studio Code with advanced plugin support. For instance, only Visual Studio Code Insider enables a remote access via SSH to ARMv7-A and ARMv8-A Linux devices.
Visual Studio Code Insider does allow only SSH access with a SSH-Keygen. The key must be regenerated after every Board-, SD-card or IP-Address switch. A static IPv4-Address or an indexed MAC address of the board inside the DHCP-Server can prevent the OpenSSH
server to request a new keygen after a reboot.
The following step by step guide shows how to setup Visual Studio Code Insider for Python application remote development and debugging on a Windows 10 PC. For other systems please follow Microsoft's instructions: Visual Studio Code Remote Development Troubleshooting Tips and Tricks (Chapter: Improving your security with a dedicated key)
With the following guide Microsoft describes the remote debugging function of Visual Studio Code Insider: Developing on Remote Machines using SSH and Visual Studio Code
- Open the Windows "Command Prompt" or the Linux Terminal Window (admin rights not required)
- Execute the following commands
- Generate a new SSH Key
- Windows stores the key inside the following directory:
C:\Users\<USER Name>\.ssh
- Linux here:
~/.ssh
ssh-keygen -t rsa -b 4096
- Always press
ENTER
(do not enter an extra password or another name):
- Windows stores the key inside the following directory:
- Set the IPv4 Address of the board
- Here for example with the IP address 192.168.2.105
- Copy the generated SSH-Key via SSH to the board
- After this command the rsyocto splash screen appears and the Linux Distribution asks for the password:
eit
scp %USERPROFILE%\.ssh\id_rsa.pub %REMOTEHOST%:~/tmp.pub
- After this command the rsyocto splash screen appears and the Linux Distribution asks for the password:
- Authenticate and activate the SSH key
- Again, after this following command should the rsyocto splash screen appear and the Linux Distribution should ask for the password:
eit
ssh %REMOTEHOST% "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat ~/tmp.pub >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && rm -f ~/tmp.pub"
- Again, after this following command should the rsyocto splash screen appear and the Linux Distribution should ask for the password:
-
Download and install the latest version of Visual Studio Code Insider: Download Visual Studio Code Insiders
-
Follow the installation instructions
-
After a successful installation open Visual Studio Code Insider
-
On the sidebar (toolbar on the left hand side) click the
Extension
-icon -
Search for the extension:"
Remote Development
" (by Microsoft) (Remote Development - Visual Studio Marketplace) and press theinstall
-button to install this extension -
Restart Visual Studio Code Insider to accept the changes
-
Click on the side bar "
Remote Explorer
" -
Choose in the Drop Down Menu "
REMOTE EXPLORER
" and theSSH Target
-
Move the mouse of the title "
SSH TARGETS
" and click on the gear-icon -
Select in the appeared Dropdown menu: "C:\Users<USER Name>.ssh\config"
-
Configure the name and IPv4-Address by adding the following
jason
-configuration file (change the "HostName
" with the IPv4-Address of your board):
Host rsyocto
ForwardAgent yes
HostName 192.168.2.105
User root
IdentityFile ~/.ssh/id_rsa
- Save and close this configuration file
- If an error occurred close and restart Visual Studio Code Insider and try it again
-
Open Visual Studio Code Insider
-
Select on the side bar "
Remote SSH
" -
Under the tap "
Connections
" an entry with the name "rsyocto
" appears -
Right click on this entry and choose "
Connect Host in current Window
"- The first attach attempt takes a little bit longer, because the Visual Studio Code downloads and installs the Visual Studio Code Server
- Note: Be sure that the board is connected to the internet and the system time is correct (use
date
to check it) - In case that the connection to the board is established successfully a green icon with a connected symbol should appear
- Visual Studio Code Insider can access the rootfs (root file system) of the embedded Linux Distribution
- Some Python sample applications are pre-installed on rsyocto
- Navigate on the sidebar to "
Explorer
" click the blue "Open Folder
" icon - Visual Studio Code Insider should now ask for a remote directory to open
- Default:
"/home/root/"
--> User root folder with the Python examples - Web sever:
"/usr/share/apache2/default-site/htdocs"
--> Every file inside this folder will be accessible with a web browser
- Default:
- Click "
okay
"
- Now the rootfs of the embedded Linux is accessible with the Visual Studio Code Insider File explorer
- Select inside the sidebar "
Extension
" - Choose the previously installed extension "
Python
" (by Microsoft) - Press the green button:"
Install on SSH:rsyocto
"
- With this input Visual Studio Code Server starts with the installation of the required remote Python debugging components
- Press "
reload required
" to activate this changes
- Open any pre-installed Python sample located on the home directory (~) of rsyocto (also available inside
examples/python
of this repo) - Navigate to the sidebar icon "
Debug and Run
" and click on the "Debug with Python
" Button - Choose in the Drop Down Menu "
Python File
"
-
Or use the following
json
-file to configure the debugger:{ "version": "0.2.0", "configurations": [ { "type": "python", "request": "launch", "name": "Python curent file remotly", "program": "${file}", "console":"integratedTerminal" } ] }
-
The remote Debugging should start
-
If not: press the "
Start Debugging
" button orF5
-
Now Microsoft Visual Studio Code is configured to write and debug any Python Code directly on the embedded Linux via a network interface over SSH and SFTP
-
The pre-installed example "serialEchoDemo.py" requires the pySerial-module
-
"rsyocto" has a full support for all Python pip package index versions
-
Use the PiP Homepage to find a module to download and install
-
Run the following command to download and install this module with rsyocto:
pip3 install "module_name"
-
Now it is possible to use Python packages, which are designed by a large community (e.g. Raspberry Pi-community), on a powerful Intel SoC-FPGA
-
To show all pre-installed Python PiP packages
pip list
Example: Debugging the Python script "gsensorDemo.py" on a DE10 Standard Board