RT-Thread qemu mps2-an385 bsp transplant production: environment construction

foreword

  • Recently, I plan to study RT-Thread systematically, including the transplantation of RT-Thread BSP. Since I have been using QEMU to verify some software functions, qemu supports many CPUs and development boards, so I want to transplant a new qemu board to RT-Thread and master the method of BSP transplantation.

  • The current mainline RT-Thread BSP Qemu has three series: qemu-vexpress-a9 qemu-virt64-aarch64 qemu-virt64-riscv, so I plan to build a simple ARM Cortex-M3qemu board: mps2-an385, after verification, it is similar to the MCU of the STM32F103 series

  • The development environment is temporarily: Linux environment, ubuntu 20.04, and try to adapt to Windows later

insert image description here

  • The qemu version installed by default in ubuntu 20.04 qemu-system-arm --versionshould be 4.2.1the MCU that supports this ARM Cortex-M3:mps2-an385
$ qemu-system-arm --version
QEMU emulator version 4.2.1 (Debian 1:4.2-3ubuntu6.27)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers

development environment

  • Win10 64-bit + VS Code, ssh remote connection to ubuntu

  • VMware Workstation Pro 16 + Ubuntu 20.04

  • RT-Thread v5.0.1 (Note: The current RT-Thread BSP occupies a large space)

  • qemu qemu-system-arm mps2-an385development board, qemu version QEMU emulator version 4.2.1or higher

  • arm gcc cross-compilation toolchain: currently using the gcc compilation environment, gcc-arm-11.2-2022.02-x86_64-arm-none-eabi,gcc version 11.2.1 20220111

construction project

  • Because the current code size of RT-Thread is a bit bloated, RT-Thread v5.0.1 is close to 1.8GB after decompression, and the BSP package occupies about 1.7GB, so I plan to build an independent project, excluding other BSPs, to reduce the complexity of project management and facilitate code reading

insert image description here

insert image description here

  • Re-create the project, then remove the bsp, change to the rt-thread directory, and create a new qemu-mps2-arm directory as the bsp for transplanting qemu mps2

insert image description here

Configure arm gcc cross compilation environment

  • Download the arm gcc cross-compilation toolchain: ARM officially provides download addresses for each version https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads

  • Currently verifying that newer versions, eg gcc-arm-11.2-2022.02-x86_64-arm-none-eabi, compile and run fine

  • Set the ubuntu environment variable, qemu-mps2-armcreate a new one under the directory setup.sh, the content is as follows

#!/bin/bash

export RTT_CC=gcc
export RTT_EXEC_PATH=/home/zhangsz/linux/tools/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin
export RTT_CC_PREFIX=arm-none-eabi-

export PATH=$PATH:$RTT_EXEC_PATH


echo "CC        => ${RTT_CC}"
echo "PREFIX    => ${RTT_CC_PREFIX}"
echo "EXEC_PATH => ${RTT_EXEC_PATH}"
  • Increase execution permissionschmod +x setup.sh

  • Run before compiling: source setup.shyou can

  • Since then, the preliminary development environment should be ready, but qemu-mps2-armin the bsp directory, there is only one setup.shscript to set up the cross-compilation toolchain, and the bsp has not officially started porting

mps2-an385 Introduction

  • The qemu development board mps2-an385 has very little information. The reason for using mps2 may be due to the previous debugging of qemu in FreeRTOS. This is the one usedmps2-an385

  • The information currently available is basically ARM’s official mps2-related sdk. After downloading, there is a Keil version, and you can get some startup files and the use of some registers: such as timers, uart serial ports

  • Since mps2 is based on ARM Cortex-M3, it is planned to connect scripts, startup files, etc., to modify and adapt based on the STM32F103 series. This part will be explained in the next article.

summary

  • This article pays attention to sorting out the environment before RT-Thread BSP transplantation, choose windows development or Linux environment (such as ubuntu) development, here use Linux environment development, use arm gcc cross-compilation tool chain, code reading, editing, gdb debugging, use VS Code ssh under Win10 to remotely connect to ubuntu

  • Since the overall BSP code of RT-Thread occupies a large volume, which is not conducive to function management, a new minimal RT-Thread project is created for code management. Currently, the RT-Thread release version is used: , which can be RT-Thread v5.0.1downloaded at https://github.com/RT-Thread/rt-thread/releases/tag/v5.0.1

Guess you like

Origin blog.csdn.net/tcjy1000/article/details/131871586