ESE5190-Lab2-Setup

Name: Yuan Chi

Setup environment: 2019 MacBook Air 13-inch, MacOS Monterey 12.6
Processor: 1.6 GHz Intel Core i5
Memory: 8 GB 2133 MHz LPDDR3

1. Install Homebrew

 $ /bin/bash -c "$(curl -fsSL
 https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

2. Install toolchain

 $ brew install cmake
 $ brew tap ArmMbed/homebrew-formulae
 $ brew install arm-none-eabi-gcc

3. Create Pico directory

 Cd Document
 Mdkir pico
 Cd pico

4. Clone Pico-sdk and Pico-examples

      $ git clone -b master https://github.com/raspberrypi/pico-sdk.git
      $ cd pico-sdk
      $ git submodule update --init
      $ cd ..
      $ git clone -b master https://github.com/raspberrypi/pico-examples.git

5. Download Visual Studio Code

https://code.visualstudio.com/download

6. Install CMake Tools in VSCode

Type Cmd+shift+X and search for "CMake Tools";
Click on the entry in the list;
Click on the install button;
image

7. Set the Pico_SDK_PATH environment virable

Navigate to the pico-examples directory;
Create a .vscode directory and add a file called settings.json;
Copy these lines to settings.json;

 {
 "cmake.environment": {
     "PICO_SDK_PATH": "../../pico-sdk"
 },
 "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
 }

Click on the Cog Wheel at the bottom of the navigation bar on the left-hand side of the interface and select "Settings";
Click on the "Extensions" and "CMake Tools configuration";
Scroll down to " Cmake: Generator: and enter " Unix Makefiles" into the box;
image

8. Add folder to workspace and choose a compiler

Go to the File menu and click on "Add Folder to Workspace..." and navigate to pico-examples repo and click "Okay";
Select "GCC for arm-none-eabi" for compiler";
image

9. Problem Solving

Problem:
image

Solution:
Setting an environment variable through CMake tools in VSCode;
image
image

10.Build "Hello World"

Cd into pico-examples and create a build directory:

 $ cd pico-examples
 $ mkdir build
 $ cd build

Set the Pico_SDK_PATH (If clone pico-sdk and pico-examples repositories into the same directory side-by-side):

  $ export PICO_SDK_PATH=../../pico-sdk

Prepare cmake build directory by running cmake..:

 $ cmake ..

image

Change directory into the "hello_world" directory inside the "pico-examples/build" tree, and run make:

 $ cd hello_world
 $ make -j4

image

This will build two separate examples programs in the "hello_world/serial/" and "hello_world/usb/" directories;
Amongst other targets, we have now built:
• serial/hello_serial.elf, which is used by the debugger
• serial/hello_serial.uf2, which can be dragged onto the RP2040 USB Mass Storage Device (UART serial binary)
• usb/hello_usb.elf, which is used by the debugger
• usb/hello_usb.uf2, which can be dragged onto the RP2040 USB Mass Storage Device (USB serial binary)
Where hello_serial directs stdio to UART0 on pins GP0 and GP1, and hello_usb directs stdio to USB CDC serial.

11. Flash and run "Hello World"

Connect the laptop to Raspberry Pi using a micro-USB cable;
Hold down the "root" button and press "reset" button at the same time;
Push "hello_usb.uf2" in Raspberry Pi;
Enter the console:

 $ ls /dev/tty.*
 $ screen /dev/tty.board_name 115200

"Hello World!" appears in the console:
image