# Set the environment of STM32F407 ###### tags: `SCA` > To form up the habit of writing some note, I will keep a record of the lessons. Unfortunately, I am a little short in English, so forgive me if I use English and Chinese at the same time. :::success There is a microcontroller (Cortex-M4) , a 32-bit RISC ARM processor cores, on the discovery kit. In first lesson, our goal is connecting the STM32F407 to our pc, writing a binary file into STM32F407 and running the example code. ::: > From teacher 楊's powerpoint :::info All command following is for ubuntu 19.10. If you want to do with windows, can make up a virtual box or [install a ubuntu environment on windows 10 ][GitHub-Sync]. If there is Mac user, welcome to share your steps. [GitHub-Sync]:https://medium.com/@misscoming/%E5%9C%A8-windows-10-%E4%B8%8A%E8%B7%91-ubuntu-18-04-92f80b2d725b ::: ## The first part: Install the needed packages ### Clone the file on github ``` git clone --recurse-submodules https://github.com/mkannwischer/STM32-getting-started ``` ``` ls #There is a dict STM32-getting-started ``` ### Install two packages ``` sudo apt-get update # It is not necessary sudo apt-get install arm-none-eabi-gcc sudo apt-get install stlink-tools ``` If your os is not ubuntu, you can take a look at these reference. reference : https://github.com/mkannwischer/STM32-getting-started https://command-not-found.com/st-flash ## The second part : Connecting STM32F407 board - [ ] Connect USB cable of STM32F407 to your PC - [ ] Connect USB cable of UART-USB to your PC - [ ] Connect **PA2** pin with **RX** pin of UART-USB connector After connect cable, you will find that /dev/ttyUSB0 show up. ``` ls /dev/ > before.txt # connect the cable ls /dev/ > after.txt diff before.txt after.txt ``` ## The third part : Compile the file and Flashing some examples If your installation of arm-none-eabi-gcc is well done, you can execute makefile easily. ``` cd STM32-getting-started/STM32F407 make ``` now, there are some binary executing file in STM32-getting-started/STM32F407. Let's write it into the flash of STM32F407 ``` st-flash write usart.bin 0x8000000 ``` Last, Receive output on your terminal ``` sudo screen /dev/ttyUSB0 115200 ```