Linux Step 19_Install "Ubutun Cross-Compilation Toolchain"

Since the Ubuntu system uses the GCC compiler, the compilation result is an X86 file, which can only be run on X86 and cannot be run directly on ARM. Therefore, a "Ubutun cross-compilation tool chain" must be installed before it can run on ARM.

arm-none-linux-gnueabi-gcc is an ARM cross-compilation tool based on GCC launched by Codesourcery (currently acquired by Mentor) . lsb-core lib32stdc++6 is a related library that needs to be installed.

1. Before installation, check that the virtual machine can access the Internet, otherwise the installation may fail.

2. In the virtual machine interface, right-click the mouse and the following dialog box will pop up:

3. Click "Open Terminal (E)" to get the following interface:

4. Enter " ls and press Enter " to list files and folders

Enter " cd linux and press Enter " to enter the linux directory;

Enter " rm main*Enter " to delete all files starting with main.

Type " ls and hit enter " to list files and folders

 5. Enter " mkdir tool and press Enter " to create a " tool " folder in the linux directory .

Then enter " ls and press Enter " to list files and folders;

6. Double-click "FileZilla Client.exe" on the Window system desktop to open the FTP client . At this time, we know  the usefulness of installing the " FTP client " .

7. Click "File", then click "Site Manager", as shown below:

Open E:\Development Board Information\STM32MP157 Development Board A disk basic information\05, Development Tools\05, Development Tools\01, Cross Compiler, and find the following file:

gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar

8. Click "MP1_Ubinti" in the picture below, and then click "Link". See the picture below for the operation: 

Get the following picture:

 9. Find the E drive, and then find the basic information on the STM32MP157 development board A drive. See the following figure for the operation: 

10. Drag gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar to the tool directory, as shown in the figure below:

 11. Wait for the file transfer to end

12. The file is uploaded successfully, as shown in the picture below:

 13. In the terminal, enter "pwd and press Enter". pwd is the abbreviation of the phrase print working directory , which means printing the working directory;

Enter "cd tool and press Enter" to enter the tool directory;

Enter "ls and press Enter" to list files and folders;

14. Right-click the mouse on the virtual machine interface, the following dialog box will pop up, and then open a terminal. 

15. Click "Open Terminal (E)" to get the following interface:

16. Enter "ls and press Enter"  to list files and folders;

17. Enter " sudo mkdir /usr/local/arm and press  Enter " to create an " arm " folder under the " /usr/local " path:

 18. Enter the password “123456 Enter”

19. Enter "cd /usr/local/arm  and press Enter" to enter the " arm " folder under the " /usr/local " path:

20. Enter " sudo cp gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz   /usr/local/arm and press Enter" to copy the current file to "/usr/local/arm" Under contents

21. Enter the password “123456 Enter”

 22. In another open terminal, enter " ls and press Enter " to list the files and folders;

23. Enter " sudo tar -vxf gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz and press Enter" to decompress the file.

 24. Enter the password “123456 Enter”

25. After decompression is completed, enter " ls and press Enter " to find the following directory

gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf

26. Enter " cd gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/Enter " and enter the directory gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf;

Enter " ls and press Enter " to list files and folders;

27. Enter “cd bin and press Enter” to enter the “bin” directory.

Enter " ls and press Enter " to list files and folders;

28. arm-none-linux-gnueabi-gcc is an ARM cross-compilation tool launched by Codesourcery based on GCC, as shown in the figure below:

29. Enter " pwd and press Enter " to find the full path as follows:

/usr/local/arm/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin

Enter " sudo vi /etc/profile and press Enter" to directly open the profile file in the "etc" directory and prepare to modify it.

30. Enter the password “123456 Enter”

31. Add the following statement at the end of the file

export PATH=$PATH:/usr/local/arm/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin

Note: There cannot be spaces after PATH .

32. Press the " ESC key " and then enter " :wqEnter " to save and exit.

33. Upgrade software packages in the system

Enter " cd /usr/local/arm/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin and press Enter" to enter the "bin" directory

Enter " ls and press Enter " to list files and folders;

Enter " sudo apt-get update and press Enter " to upgrade the software packages in the system.

Enter the password " 123456 Enter "

See the picture below when the update is complete:

34. Enter " sudo apt-get install lsb-core lib32stdc++6 and press Enter" to install the relevant library "lsb-core lib32stdc++6"

The problems found are as follows:

E: Unable to obtain lock /var/cache/apt/archives/lock - open (11: The resource is temporarily unavailable)

E: Unable to lock directory /var/cache/apt/archives/

Enter " ps -aux and press Enter " to list all processes and find the lock

Enter " sudo kill 850 and press Enter " to delete the lockd process ;

 Enter " sudo apt-get install lsb-core lib32stdc++6 and press Enter" to install "lsb-core lib32stdc++6";

See below:

 Enter " cd /usr/local/arm/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin and press Enter "

35. Shut down and restart the Ubuntu system

36. Right-click the mouse on the virtual machine interface, and the following dialog box will pop up:

37. Click "Open Terminal (E)" to get the following interface 

 38. Open the terminal, enter " arm-none-linux-gnueabihf-gcc -v and press Enter ". If the cross-compiler is installed correctly, the version number will be displayed .

39. Enter " cd /home/zgq/linux/Enter " to enter the linux directory under the /home/zgq path;

Enter " ls and press Enter " to list files and folders;

You can see: gcc version: 9.2-2019.12 ;

40. Enter " vi main.c and press Enter " to create a main.c file and open it .

41. Press "Capital Letter A" to insert the cursor.

#include <stdio.h>

int main(int argc,char *argv[])

{      

        printf("Hello world\r\n");

}

 42. Press " ESC Build ", enter " :wq Enter ", save and exit.

43. Enter " ls and press Enter " to list files and folders;

 44. Enter " arm -none-linux-gnueabihf-gcc  main.c -o main and press Enter " to compile and generate the executable file main.exe

Enter " ls and press Enter " to list files and folders;

See below:

45. Enter " file main and press Enter " and find that main is a 32-bit file .

46. ​​Enter "./main and press Enter" and find that main cannot be executed.

Guess you like

Origin blog.csdn.net/weixin_42550185/article/details/135410200