Install VS Code
VSCode is already installed on the lab computers. If you are using your personal computer, install it from https://code.visualstudio.com/download
Next, Install the Remote - SSH extension from Microsoft.
SSH Config and SSH Keys
Before proceeding, make sure you set up your SSH config file (
~/.ssh/config) and SSH keys (
~/.ssh/id_rsa.pub) as described on an earlier page.
Note: If you are using Windows on your personal computer, VSCode will look for your SSH config file and SSH keys in your Windows home directory (not the WSL home directory).
Before proceeding to setup VSCode, you will need to create an SSH config file on your home computer.
- Click the green button in the bottom left of VSCode, and select Remote-SSH: Open Configuration File…. Note: if there is no green button in the bottom left, you haven’t installed the Remote - SSH extension (see above).
- You will then be asked to select an SSH configuration file to open. You should pick the one that is in your home directory (~/.ssh/config).
- This SSH configuration file is used to tell the SSH program about computers you can connect to, and to save settings for each computer. This file may be empty right now, but you should add a new entry like this:
Host pynq<number> Hostname pynq03.ee.byu.edu User byu
The SSH config serves as a shortcut for using SSH, and is required by VSCode for remote connections. Keep in mind that as you switch seats and boards in the lab, you will need to add new entries to this file.
Connecting via SSH
- Click the green button in the bottom left of VSCode, and select Remote-SSH: Connect to Host..
- If your SSH config file is set up correctly, you should now be given a list of the machines available in your SSH config file. Select your pynq<number> board.
- A new VSCode window should pop up, and the VSCode server will be installed on your PYNQ board. This can take a few minutes. If an error pops up, try clicking Retry a few times.
- Once connected, the green status bar in the lower left corner should read SSH: pynq<number>
- You can now click File->Open Folder and then select your ecen427 repository folder that you cloned earlier.
If the future, you can just press Ctrl+R to list all of the recent folders you have opened. This can be used to quickly reconnect to the PYNQ board and open your repository.
Install VSCode Extensions
When you open the folder using VSCode, you should see a message indicating that there are recommended extensions for your code. Click Install All.
Accessing the Terminal
Instead of using a separate terminal to SSH to your PYNQ, you may prefer to use the terminal integrated in VSCode. Click Terminal->New Terminal (Ctrl+~) to open a remote terminal.
Committing Code via Git
From VSCode you can now directly edit your files and commit them to your Github repository. Try it out:
- Create a new file called README. You can do this by opening the Explorer view in VSCode (top button in left-hand pane), then in the file browser, right-click and select New File.
- Add the line This is the ECEN427 repo for <your name> to your file and save it.
- Open the Source Control view of VSCode (third button down in the left-hand pane). Your new file should be listed in the Changes section.
- Click the + button next to your file to Stage it for commit.
- Add a commit message and click the check mark to commit (or Ctrl+Enter)
- Push this commit up to Github by clicking the three dots and selecting Push, or by clicking the Sync button in the bottom blue strip of VSCode (two buttons to the right of the green SSH button you used earlier).