Skip to content

[T TOOL 0] Environment installation for cross compilation

yudada31 edited this page Apr 12, 2019 · 4 revisions

Software installation for setting the cross compilation and the Linux environment.

Objective:

A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. The main reason we need a cross compiler is that it is necessary to compile the code on our PC first because direct compilation on the target platform might be infeasible, for example on a microcontroller of an embedded system(the STM32 in our case).

Steps:

  1. sudo apt-get update
  2. sudo apt install git
  3. You need to install mbed-cli try pip install mbed-cli(you may need to add sudo -H before) Check if it worked by typing mbed -h if not then you need to install it manually by cloning git clone https://github.com/ARMmbed/mbed-cli and then you need to go inside the mbed-cli folder that you just cloned and run the script by typingpython setup.py install you may will need to first install python
  4. Create an new program for mbed OS5 mbed new folder_name this will create your working folder(it may take a few minutes)more info here
  5. Download the GCC_ARM embedded toolchain download here unzip it
  6. Go into the working folder that you created and the link the GCC_ARM embedded toolchain mbed config -G GCC_ARM_PATH "<your path to the bin folder of GCC_ARM>"
  7. To compile your cpp code you use mbed compile -m auto -t GCC_ARM more info here the board has to be connected to your computer

Check if it is correctly installed

Now, to check if it is correctly installed : plug in your STM32 and type mbed detect on a terminal and try to compile a simple code.

Tips:

You can find a file named flash.sh and it is simply a bash script file that is compiling the source code with this line of code:mbed compile -m auto -t GCC_ARM. Here, the target is in auto and the toolchain is GCC_ARM. You can find more informations about the commands and options with mbed --help. Then the .bin file is flashed in the STM32.

Clone this wiki locally