Skip to content

[T DEV0] Environment installation for cross compilation

A.L edited this page Apr 3, 2019 · 1 revision

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

Problematic

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).

After installing Linux:

  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 "/home/remy/gcc-arm-none-eabi-7-2018-q2-update-linux/gcc-arm-none-eabi-7-2018-q2-update/bin"
  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. If the microcontroller is detected then it's fine !

Flash.sh

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