Software setup
Skip navigation ENGN2219/COMP6719: Computer Architecture and Simulation Research School of Computer Science Search query Search ANU web, staff & maps Search current site content Search Menu Search query Search ENGN2219/COMP6719 Lectures Labs Deliverables Resources Search ANU web, staff & maps Search current site content Lectures Labs Deliverables Resources menu Search query Search ENGN2219/COMP6719 Search query Resources FAQ Glossary Software setup Writing a design document Books, links and other good things Project ideas Related sites Gitlab Piazza Streams Wattle RSCS Homepage You are here » Resources » Software setup Table of Contents Installation On a computer running Windows 64bit (Normal Win 7/8/10) On a computer running Linux On a Mac Using VSCode Troubleshooting Un-plug & re-plug — “Have you tried turning it off & on again?” VSCode developer tools console Breakpoint problems can’t set a breakpoint by clicking in the left-hand “gutter” OpenOCD Upload Problems connection problems flash failure libusb_open() ST-Util & GDB Problems device not found failed to read core id time out this socket is closed remote communication error remote connection closed connection refused get more debug information OS Specific Problems [Linux] Device permission issues [Windows] ST-Link Driver [Windows] integrated terminal freezes [Windows] Git HTTP Basic authentication Failed How does the software environment work? The Integrated Development Environment (IDE) we use in ENGN2219/COMP6719 is VSCode. VSCode is a generic text editor, which means that it’s really good at editing text, but doesn’t care too much what that text is/represents. However, VSCode also allows people to write “extensions” to help VSCode write & run code for different programming languages. Installation Make sure however that the “COMP2300 2021” extension is always up to date. Its version will go up as we fix problems and add features, so you should keep it up-to-date. You can click on “Extensions” in the side-bar of VSCode to manage the extensions. On a computer running Windows 64bit (Normal Win 7/8/10) Read the ENGN2219/COMP6719 own machine policy Download & install Python. Make sure you select Add Python to PATH when installing. If you have not done this, you almost certainly need to re-install Python, as extensions require Python to be in your PATH. Download & install Git. Git Bash will behave like a terminal on the lab machines and should let you do all the usual Git commands. Download & install make. copy and paste the files in the zip to C:\Program Files\Git\mingw64\. Download & install the ST-Link Windows Driver. Extract the archive and run dpinst_amd64.exe and follow the displayed instructions. Download VSCode here. If you need a version other than the 64 bit windows installer, you can find it on the website. Open VSCode, open the Extensions view Search for and install only the COMP2300 2021 extension (comp2300-anu.comp2300-2021-extension). Do not install any other extensions. Once the toolchain install is complete, reload the VSCode window (using the reload window command in the command palette). Click the dropdown in your terminal window in VSCode, select “Select Default Shell”, and choose “git bash”. You’re ready to go! If things go wrong, check the Troubleshooting section further down this page. On a computer running Linux These instructions are aimed at Ubuntu, but should work for any sensible Linux distro that’s up to date. If you’re using something other than Ubuntu, I trust that you know what you’re doing. If you need help, email Jon. For Arch users: VSCode has an AUR package, so you don’t need to download a tarball. Read the ENGN2219/COMP6719 own machine policy Download & install VSCode. You’ll want to download the .deb file - Install the package once downloaded. Ensure python and git dependencies are installed with by running this command in the terminal: sudo apt install python3-distutils python3-venv git
Open VSCode, open the Extensions view Search for and install only the COMP2300 2021 extension (comp2300-anu.comp2300-2021-extension). Do not install any other extensions. Once the toolchain install is complete, reload the VSCode window (using the reload window command in the command palette). You may encounter errors, including Couldn't find any ST-Link/V2 devices. If this occurs, or other things go wrong, check the Troubleshooting section further down this page. If things ever go seriously wrong with trying to install this stuff on your own machine, you can always “start again” by deleting the ~/.vscode and ~/.comp2300 folders in your home directory, e.g. with this terminal command: $ rm -rf ~/.vscode ~/.comp2300
On a Mac Read the ENGN2219/COMP6719 own machine policy Install XCode from the App store. Download & install VSCode. You may need to hold the control key and click to install in order to bypass a software security check. Open VSCode, open the Extensions view Search for and install only the COMP2300 2021 extension (comp2300-anu.comp2300-2021-extension). Do not install any other extensions. Once the toolchain install is complete, reload the VSCode window (using the reload window command in the command palette). You may encounter errors. If things go wrong, check the Troubleshooting section further down this page. Using VSCode VSCode has pretty good documentation. The lab material will link to specific parts of it where appropriate. However, understanding your tools is really important, so take the time to read through the documentation and get to know the features of VSCode. It’ll make your life easier in the end, even if there’s a learning curve at the start. Once you’ve got VSCode & the necessary plugins installed (and you’ve got your discoboard) you’re able to write and run your first program. That’s what lab 1 is all about—so head to that page and give it a try. The rest of this page is information to help you if you get stuck, or if you want to know the details of how all the parts of this software environment work together. You don’t have to read it in detail now, in fact it’s probably more important that you head to the lab 1 content and make sure that you can actually get this stuff working for yourself. However, it’s good to know that this information is here, so that if you have problems you know where to look (and it’s helpful for asking good questions on the forum as well). Troubleshooting Here’s a list of issues you might come across, depending on the specific details of your machine. As always, be careful with copy-pasting random code you found on the internet (even in a university course!), and try to understand the problem first before you try the solutions listed. If there are new problems which come up often enough on Piazza I’ll add them here. Un-plug & re-plug — “Have you tried turning it off & on again?” Sometimes the board can get into a bad state causing the uploading to fail (especially when the debug LED becomes yellow). Stop any active debug session, and try unplug & re-plug to reset the board. VSCode developer tools console Before you look at the specific problems, here’s a tip for getting the most useful error messages out of VSCode when things are going wrong. In command pallete, run the Developer: Toggle Developer Tools command and you’ll see a new pane pop up in VSCode. Switch to the Console tab (top-right of the screenshot) and you’ll see something like this: Now, the messages in this Console view aren’t really meant for VSCode users, so there will be a lot of stuff here, and a lot of it probably isn’t relevant. However, if you keep this view open while you do the command which isn’t working for you, then it might output some error messages here (watch for red lines of text) which give you more detailed information about what’s going wrong. Breakpoint problems can’t set a breakpoint by clicking in the left-hand “gutter” If you suddenly lose the ability to set a breakpoint by clicking in the “gutter” to the left of the line numbers next to your code, then check that VSCode is still treating your file as an ARM file rather than just an Assembly file. To see if this is the case, check the bottom-right hand corner of the VSCode window (just to the right of the smiley face ☻). If it says “Assembly”, then click there and switch it to ARM (you should probably use the “Configure file association for .S” drop-down option to set this to ARM for all .S files while you’re there). OpenOCD Upload Problems connection problems Error: open failed OR Error: failed to read version
This means that OpenOCD fails to connect the board. First check whether you have connect your board to the computer. Then try unplug and re-plug the board. If you are on Windows, make sure you have installed the driver. If you are on Linux, it could also be a permission issue. flash failure Error: init mode failed (unable to connect to target)
Sometimes a fresh new board need to be flashed first before upload using OpenOCD can work (don’t ask me why, it just seem to work this way…). This manual flash only need to be done once: Build a program image by running the COMP2300: Build command in VSCode (or press ctrl + shift + b). Run the COMP2300: Run first time flash command. Follow the instructions and if you see a success message then the subsequent COMP2300: Upload should work fine. libusb_open() Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
This doesn’t seem to be a problem as long as there are no other errors that causes the upload program to fail. The cause of this problem is still unknown, but the uploading still seems to succeed in the cases seen so far. ST-Util & GDB Problems device not found Couldn't find any ST-Link/V2 device
Check board connection; replug if necessary. If you are on Windows, check if you have installed the driver. If you are on Linux, it could also be a permission issue. failed to read core id src/common.c: Failed to read core id
Connection issue. Replug the board. time out Failed to launch ST-Util GDB Server: Timeout.
This is likely due to st-util failed to start properly. Get more info from the Adapter Output. this socket is closed Failed to launch GDB: Error: this socket is closed
This is probably because GDB failed to launch, check error output in DEBUG CONSOLE. One case we found is due to a path error made by an attempt to manually install packages. Check the paths in the settings.json, and also actual paths on your system. remote communication error Failed to launch GDB: Remote communication error. Target disconnected.: No error. (from target-select extended-remote localhost:50000)
This has been found on Windows, however the same thing MAY happen also on other OS as well. The real problem is that the default debug port 50000 is being used by some other software. So when the debugger tries to connect to it, the other software, rather than the expected server (st-util), responds, and refuses the connection request from GDB since it doesn’t know who GDB is. So the proper solution is to close the software that’s using port 50000, then everything should work just fine. To find out the clue on what it is, do the following: Open Command Prompt in Administrator mode (search “command prompt” in start menu -> right click and select “run with Administrator mode”) Run the command netstat -a -b, and look for the application with Local Address 127.0.0.1:50000. Close the application that’s using the port (system monitor MAY be needed, Ctrl+Shift+Esc). If you can’t find the application, it may also mean that port 50000 wasn’t closed properly. Maybe try restart the computer in this case. remote connection closed Failed to launch GDB: Remote connection closed (from target-select extended-remote localhost:50000)
This seems to be a problem with GDB failing to connect with st-util. Get more info from the Adapter Output. connection refused Failed to launch GDB: localhost:50000: No connection could be made because the target machine actively refused it.
This could be caused by your anti-virus software. Please check and turn it off if necessary. It could be interfering and refusing connection to certain ports. get more debug information You can also view the output from st-util in the Adapter Output tab (check OUTPUT panel during debug -> select Adapter Output from the drop down list). OS Specific Problems [Linux] Device permission issues On some Linux machines you might have read/write permission issues in connecting to your discoboard. As a result, the toolchain fails to upload (COMP2300: Upload) with the error: Error: libusb_open() failed with LIBUSB_ERROR_ACCESS
Error: open failed
This problem can be solved by with the following commands: #!/bin/sh
sudo sh -c 'cat > /etc/udev/rules.d/49-stm32.rules' <