Written by Shu Xu
Email: [email protected]
System | Windows 10 Home |
---|---|
System Version | 21H2 |
System Type | 64-bit operating system, x64-based processor |
Processor | Intel(R) Core(TM) i5-9300H CPU @ 2.40GHz 2.40 GHz |
This is a guideline to help readers set up their laptops to be ready for flashing c code to QT PY 2040 board, from zero to the first "hello world" c file. Be aware that the whole set up will take a rather long time to run through. Please be patient not to miss the small notices during the installation process. We will be using the following softweres to complete set ups:
In this prelab part, you will install and set up a terminal, serial console, and text editor for the rest of ESE 5190 course. The goal is to turn your own laptop into a powerful portable development environment that you can use anywhere.
In this part, we choose Ubuntu as a reference to show you the process to install a terminal to your PC.
If you don't yet have Ubuntu in your PC, simply open Microsoft Store and search for the latest version. It only takes minutes to finish downloading.
Notice that if you have a older version of Ubuntu existed in your PC, you might run into an error: "The attempted operation is not supported for the type of object referenced". In this case, open up the cmd as admin and copy paste the following command:
netsh winsock reset
For the first timers, follow the first time Ubuntu instructions, set up new user name.
Create a new '.txt' file named 'test.txt' under lab2 file. Using the following command:
$ cd /mnt/c
$ cd Users/your user name/Lab2/prelab_setup
$ touch test.txt
$ ls
You should now be able to see your 'test.txt' file listed below.
Edit 'test.txt' use cat command:
$ cat test.txt
Print "Hello World!" in your terminal screen. You should be able to see the changes in your 'test.txt' file.
Even though you can acess and edit files directly in terminal, Vim is one better option for this purpose. As Vim is a built-in part of Ubuntu, it is already available from your terminal!
Run vimtutor by input command:
$ vimtutor
Start lesson 1, and follow the instructions to go through at least a few slides. Now you should be able to edit files in a more feasible way(after you get experienced)
Now we need a tool to be able to display the output. For windows users, open this site and follow instructions on how to install a serial console.
Open the device manger. Then plug in board to a USB jack, you should be able to see a new list named Port. Under Port, confirm which COM# are you using. In the following steps, we will use COM3 as an example.
Download PuTTY of latest 64 bit version. Open it. Under Connection type on the left, choose Serial.Enter COM3(replace with your own COM#) under Serial line box. Set the speed to 115200. You may also use other serila console you preferred.
Notice that this board does not require speed change. However, boards with a separate chip(No built in USB) such as ESP8266 requires the speed to be 115200 bits/sec.
You may also use save/load function to save the setting for future usage. Hit open. A PuTTY window should pop up with a blank screen or with welcome messages.
In this part, you will set up your PC for RP2040 development using the official C/C++ SDK, and compile & run example code on your board. This part takes most of the time you will spend in this guideline, but it will be worth it. This part will be based on section 9.2 of A Raspberry Pi Pico guideline. It is recommended to read through this document.
Install the following tool chains:
It is recommended to install them one by one as you go through the following sections:
Step 1.1 Arm GNU Toolchain
- For Arm GNU Toolchain, making sure you choose the right file to download(the file ended with -arm-none-eabi.exe).
- Then click the box "Add pathto environment variable" at the end of installation.
Step 1.2 CMake
- For CMake, choose the right 64bit version for windows
- Making sure that you select the add path for all users as shown below:
Step 1.3 Build Tools for Visual Studio 2022
- For vs studio, download the build tool for Visual Studio 2022.
- Then install the Desktop development with C++ only. Make sure to include a full "windows 10 sdk" package as well.
Step 1.4 Python 3.10
- For python 3, you may want to choose the lastest version of 64 bits(3.10.7 by the time this guidline is published).
- Also don't forget to select add python 3.10 to path before installing.
- Click disable the MAX_PATH length limit at the end of installation.
Step 1.5 Git
- For Git, choose the 64-bit Git for Windows Setup. Unselect the bottom box "Only show new options" to make sure you don't miss the options.
- Use anything but vim as default editor
- Allow to git from 3rd-party software
- Select "Checkout as -is, commit as-is"
- Select "Use Windows default console window"'
- Select "Enable experimental support for pseudo consoles"
You may leave any other unmentioned checkbox as it is.
Open up the "Developer Command Prompt for VS 2022". You may search it from your windows menu. In this command prompt, create a directory named pico under your User directory, then create another directory named Downloads inside pico, using the following command:
$ cd Users
$ md pico
$ cd pico
$ md Downloads
Noticing that if you failed to make changes under user directory, try to reopen the "developer command prompt of vs 2020" with right click and select open as a admin.
Within the Downloads directory, run the following commands to install SDK:
$ C:\Users\pico\Downloads> git clone -b master https://github.com/raspberrypi/pico-sdk.git
$ C:\Users\pico\Downloads> cd pico-sdk
$ C:\Users\pico\Downloads\pico-sdk> git submodule update --init
$ C:\Users\pico\Downloads\pico-sdk> cd ..
$ C:\Users\pico\Downloads> git clone -b master https://github.com/raspberrypi/pico-examples.git
Now you are ready to make us of SDK
Before you build your c file, set the path to the SDK using the following command:
$ setx PICO_SDK_PATH "..\..\pico-sdk"
To make sure that this set up works properly. Close and reopen the command prompt for vs 2022. Use "cd" to Naviage into the "pico-examples" folder, then build the "Hello World" example as follows:
$ cd pico-examples
$ mkdir build
$ cd build
$ cmake -G "NMake Makefiles" ..
$ nmake
This process may take some time.
Finally, it's time to flash the code and run on your board. For RP 2040 board, including QT PY we are using, simply hold down the BOOTSEL button to force it into USB Mass Storage Mode. You should be able to see a new drive appeared. Find 'hello_usb.uf2' under pico-examples\build\hello_world\usb directory, and drag it to the newly appeared drive. Then open the serial console using PuTTY, you should be able to see the output now.