Lab11

Computer Architecture I (CS110 / CS110P) Document
Reference: CS110 Course Page

CS110/CS110P Lab 11

Computer Architecture I@ShanghaiTech

IMPORTANT: Read the FAQ from @103 before posting on Piazza!

Your Tasks

  • Bring the following material to the Lab.
    1. Your Laptop;
    2. A type-c cable that is capable of transferring data. Recharge-only type-c cables do not work.
  • Refer to the table to lookup your tasks for this lab.
Registered in CS110P Not Registered in CS110P
Registered in CS110 Complete this lab Complete this lab
Not Registered in CS110 Complete this lab to get Longan Nano board, but this lab is UNSCORED for you. At your convenience

Objective of this lab

  1. Install software and driver (Windows Only) to download provided firmware into the Longan Nano.
  2. Get a Longan Nano board from TA.
  3. Check if the Longan Nano board and its peripheral is working.

Task 1: Install Necessary Software

Overview

Our Longan Nano board uses DFU protocol to receive firmware from PC. Therefore, you need to configure the DFU tool or driver according to your operating system.

⚠️ OS Recommendation & Compatibility Warning

Due to driver stability issues, we strongly recommend using macOS or Linux for this lab.

For Windows Users: Recent system updates have caused significant driver regressions. If you must use Windows, please refer to the specific warning in Section 1.1 regarding the April 2026 security update.

1.1 Windows Version

  1. Download and install the Longan development kit for CA1 from here. The downloaded compressed archive contains an installation guide (readme.md).
  2. Inflate longan-dev-kit-ca1-windows-version-20250403.7z, follow steps 5 and 6 in readme.md to install the DFU driver AND DFU tool.

Note 1: There is a chance that your computer crashes into a bluescreen when the Longan Nano enters DFU mode. See Piazza post @103 for more details.

Note 2: The default filter for the DFU tool selects .hex files instead of .bin. If you cannot see .bin files, this is the most likely cause.

Note 3: Compatibility Alert (April 2026): After the 2026-04 Security Update (KB5083769, OS Build 26200.8246), the Windows DFU tool may fail to recognize the device even though the driver is still visible in the system. If the DFU tool cannot see your Longan Nano, please check your update history. You may need to uninstall KB5083769 to restore functionality, or switch to a Linux/macOS environment.

1.2 Linux Version

You only need to use the dfu-util executable we provided.

  1. For users with Intel/AMD CPU, download dfu-util from here.
  2. Please use tar and the command tar xvf <path to Longan Nano dev pack> to decompress the file; otherwise, you may encounter permission issues in the following lab11.
  3. Place this file anywhere. You may need to give the dfu-util execution permission using chmod +x dfu-util.

1.3 macOS Version

On macOS, the simplest way to install dfu-util is via Homebrew. It automatically handles execution permissions and path configurations.

Open your terminal and run:

brew install dfu-util

Note: If you don't have Homebrew installed, please visit brew.sh first.

Task 2: Download Sample Firmware to Longan Nano

2.1 Preparation

  • Longan Nano Basics: Refer to Sipeed Official Website for Longan Nano Basics.
  • Sample Firmware: Download the sample firmware from here.

2.2 Enter DFU mode (on Longan Nano)

This procedure is identical regardless of your PC's operating system.

  1. Hold BOOT0 button (and do not release)
  2. Hold RESET button (and do not release)
  3. Release RESET button
  4. Release BOOT0 button

Note: The temporal ordering of pressing and releasing buttons is of vital importance on entering DFU mode. Therefore, if the attempt of entering DFU fails, please first try repeating the above procedure before posting on Piazza.

2.3 Download (Write) to Device (on PC)

Windows

Use the GD32 MCU Dfu Tool_v3.8.1.5784 we provided.

  • Select Download to Device, and open the .bin file we provided.
  • Keep @0x80000000 as default. Generally, you do not need to Verify After Download or Erase All.
  • Make sure the tool can see your device.
  • Let the tool download your firmware to the device.
  • Press RESET key on Longan Nano or click Leave DFU on PC to exit DFU mode.

Linux

USB Device Connectivity

Option A: For WSL2 Users

If you are using WSL2, please follow the official guide here to enable USB device access.

Troubleshooting Tip: If you encounter the error WSL usbip: error: Attach Request failed - Device in error state, try:

  1. Physically reconnect the USB device.
  2. Run usbipd unbind --busid <busid>.
  3. Use the --force flag when binding: usbipd bind --force --busid <busid>.
  4. Run the attach command again.

Option B: For VMware Users

When you plug in a USB device, select "Connect to a virtual machine".

Crucial Compatibility Setting: It is highly recommended to use USB 2.0.

  1. Shut down your VM.
  2. Go to VM Settings > USB Controller.
  3. Set USB compatibility to USB 2.0.

Use the dfu-util we provided:

cd <lab root>
./dfu-util -a 0 --dfuse-address 0x08000000:leave -D <path to sample firmware>
  • If it complains that the device cannot be opened, but your device is in DFU mode, use sudo to run dfu-util.
  • The command will complain Invalid DFU suffix signature and dfu-util: Error during download get_status. Ignore those two errors.
  • Press RESET key to exit DFU mode.
  • Note: If dfu-util cannot find your board, consider Piazza post @100.

macOS

Use dfu-util installed from Homebrew:

cd <lab root>
dfu-util -a 0 --dfuse-address 0x08000000:leave -D <path to sample firmware>
  • The command will complain Invalid DFU suffix signature and dfu-util: Error during download get_status. Ignore those two errors.
  • Press RESET key to exit DFU mode.

2.4 Workflow Completion Self-Check

The following steps will guide you perform a self-check on the above steps.

  1. Press RESET. You should see TEST (25s) and a circle on the screen. The color of TEST (25s) should be white.
  2. Push joystick up, down, left, right, and towards the middle. You should see blue character U, D, L, R, and C respectively. When D appears, the color of TEST should be green.
  3. Press the two buttons on the left side. You should see SW1 and SW2 respectively.

If all of the above steps succeed, then your Longan Nano is functional for all Longan Nano parts of CS110/CS110P.

Task Check Procedure

(1 Point) Show TA that your Longan Nano is functional and sign your name on TA's table as acknowledge receipt for the Longan Nano.

When to Return Your Longan Nano

Refer to the table to lookup your schedule to return your Longan Nano.

Registered in CS110P Not Registered in CS110P
Registered in CS110 After completing Project 4 After completing Lab 12
Not Registered in CS110 After completing Project 4 No later than week 15