3.3. Linux OR WSL environment development guide

This document introduces how to install and configure the software development tools needed for BL702 series MCUs in Linux. The installation and configuration method under WSL system is the same as under linux, please install WSL system by yourself. The difference is that one runs on a pure linux system and the other runs on windows. If you don’t want to install a virtual machine or a linux system, you can choose WSL.

Windows Subsystem for Linux (WSL) is a compatibility layer that can run native Linux binary executable files (ELF format) on Windows 10. It was developed by Microsoft and Canonical in cooperation. Its goal is to enable the pure Ubuntu image to be downloaded and decompressed to the user’s local computer, and the tools in the image can run on this subsystem. Therefore, the operation mode under WSL is exactly the same as the operation mode under linux.

3.3.1. Software and hardware environment

  • A mini USB data cable

  • A USB-TTL serial port module

  • Several Dupont lines

3.3.2. Configure RISC-V toolchain

1$ cd ~
2$ wget -c https://dev.bouffalolab.com/media/upload/download/riscv64-elf-x86_64-20210120.tar.gz
3$ mkdir -p riscv64-elf-20210120
4$ tar -zxvf riscv64-elf-x86_64-20210120.tar.gz -C riscv64-elf-20210120
5$ sudo cp -rf ~/riscv64-elf-20210120  /usr/bin
6$ echo "export PATH=\"$PATH:/usr/bin/riscv64-elf-20210120/bin\""  >> ~/.bashrc
7$ source ~/.bashrc

3.3.3. Configure cmake & make tools

1$ sudo apt update
2$ sudo apt install make
3$ cd ~
4$ wget -c https://cmake.org/files/v3.19/cmake-3.19.3-Linux-x86_64.tar.gz
5$ tar -zxvf cmake-3.19.3-Linux-x86_64.tar.gz
6$ sudo cp -rf ~/cmake-3.19.3-Linux-x86_64  /usr/bin
7$ echo "export PATH=\"$PATH:/usr/bin/cmake-3.19.3-Linux-x86_64/bin\""  >> ~/.bashrc
8$ source ~/.bashrc

3.3.4. Hardware connection

  • For the connection of the board, please refer to Hardware connection

  • Please make sure that the board is set correctly before proceeding to the following steps (Serial connection is recommended under Linux)

3.3.5. Get bl_mcu_sdk

  • Open the terminal and enter the following command to get bl_mcu_sdk

1 $ cd ~
2 $ git clone https://gitee.com/bouffalolab/bl_mcu_sdk.git  --recursive

3.3.6. Test Hello World project

Open Hello World

  • After obtaining the SDK, enter examples/hellowd/helloworld in the SDK, open main.c, and then edit the related code of helloworld.

1 $ cd ~/bl_mcu_sdk/examples/hellowd/helloworld
2 $ vi main.c
  • After editing, save the changes and close the file, and then compile

Compile Hello World

1 $ cd ~/bl_mcu_sdk
2 $ make build BOARD=bl706_iot APP=helloworld

Program Hello World

  • Please confirm the programming method first. If you use serial programming, please press and hold the boot key on the board and don’t release it. At this time, press the rst key, and then release the two keys. The board enters the boot_rom state.

  • At this time, enter the following command in the terminal to program

1 $ cd ~/bl_mcu_sdk
2 $ make download INTERFACE=uart COMx=/dev/ttyUSB1
  • If the download fails, please check:

      1. Whether the serial port is used for programming, whether the development board is powered, and whether the hardware connection is correct.

      1. Is the programming command executed in the bl_mcu_sdk directory

      1. Whether to enter boot_rom mode

      1. Whether the serial port is occupied, and whether your available serial port is selected correctly, if your serial port is not ttyUSB1, then please specify the correct serial port

Run Hello World

  • Open a new terminal, install and run the serial port tool

1 $ sudo apt install picocom   # Ignore if it is already installed
2 $ picocom -b 2000000 /dev/ttyUSB1 # Pay attention to your available serial port number (if you use the serial port of Sipeed RV-debugger Plus, it will be ``ttyUSB1``)
  • Press the rst key on the board, you can see hello world! in the serial terminal.

helloworld!

Debug Hello World