0. Environmental Science
Linux host OS:Ubuntu14.04 64 position , Running on the wmware workstation 10 virtual machine
Raspberry pie version :raspberry pi 2 B type .
Raspberry pie OS: From the official website raspbian-jessie.
Recommended in the root User login operation , Reference resources Set up root Sign in
1. Why cross compiling is needed
stay Ubuntu Directly compile a .c The source file can use the system's own gcc Compiler compilation test.c
gcc test.c -o test
Then execute the generated binaries
Cross compiling is the process of compiling in LINUX PC( Or other hosts ) On the implementation , Then copy the binary executable to raspberry pie ( Or other platforms ) perform
I understand that cross compiling is mainly fast and convenient debug, If you compile one or two source files, maybe PC It's no different from raspberry pie , But if you compile the kernel, the speed gap is obvious .
On the compilation process reference :http://lxwei.github.io/posts/262.html
2. What kind of cross compiler tool to use
The cross compiler tool is chosen for the platform on which binary files are executed , There is a special cross compiler for raspberry pie :https://github.com/raspberrypi/tools, choice branch:master edition , On the right side clone or download, Click on download zip download .
It can also be installed directly online :
sudo apt-get install build-essential git
git clone git://github.com/raspberrypi/tools.git
3. Install cross compiler tool
The downloaded file is tools-master.zip, You can right-click extract decompression , It's fine too unzip Unzip to the new RPI Under the folder , -d Used to specify that the path is ./RPI
unzip -d ./RPI tools-master.zip
stay RPI Under the document tools/arm-bcm2708 There is... Under the folder 5 A folder ( Different versions may be slightly different ):
about 32 Bit Ubuntu, Use gcc-linaro-arm-linux-gnueabihf-raspbian, about 64 Use of bits gcc-linaro-arm-linux-gnueabihf-raspbian-x64. In the choice 64 Bit cross compiler tool .
3.2 Add environment variables
To use the cross compile tool, you need to add environment variables . The environment variable is simply to specify the path of the program , Make the program run directly on the terminal . Such as execution ls Instructions don't need to /bin/ls Because this path has been added to the environment variable PATH route . For environmental variables, please refer to Methods to modify environment variables
To view environment variables, you can use :
Add cross compiler tools to environment variables , Can be directly in /etc/profile Add... At the end of the file （ You can also catalog it at home .bashrc, Refer to the following update ）
#rpi cross compile path
Restart the environment variables to take effect immediately
Test for successful installation , Press google To the method in the terminal type
An error is as follows （ If no error is reported, skip to the next step 4 Step ）
After repeatedly confirming the environment variables PATH No problem , Found in gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin The next one is arm-linux-gnueabihf-gcc Text file for , The content is arm-linux-gnueabihf-gcc-4.8.3, And this file is executable . Maybe it's for the sake of version update compatibility that we do this kind of specified processing .
The terminal executes the following instructions
You can see that the installation is normal
4 Use cross compilation to generate executable files
For a single simple source file, you can directly call the cross compiler tool with instructions to generate binary files ; For complex multi-source files, you need to write makefile then make Instructions to compile
Compile from the command line here hellowd.c Generate an executable for raspberry pie hellowd
hellowd.c as follows
Assign to hellowd.c route , And compile , The results are as follows （ If no error is reported, direct the second 5 Step ）
According to the error information , View path /arm-linux-gnueabihf/libc/lib/arm-linux-gnueabihf/libc.so.6
It turns out that this is a text file , The content is libc-2.13.so Based on previous experience ,libc.so.6 It should be pointing to libc-2.13.so By default, the compiler uses libc.so.6 But it should be used libc-2.13.so , Only need to libc-2.13.so Rename it to libc.so.6 that will do ( Backup first libc.so.6 text file ).
Compile again as follows
Problem as above , Only need to modify ld-linux-armhf.so.3 Specified in the ld-2.13.so The name of the document is ld-linux-armhf.so.3 that will do
There is no error in recompiling
Under the source file path, you can see the generated executable file , Pay attention to the need for copy Go to raspberry pie
5. Executing executable files on raspberry pie
5.1 install filezilla
Due to conditions , Raspberry pie can't be connected to the Internet , Can't be used U disc , Only Ubuntu The host can access the Internet . I've tried it before Ubuntu Host installation vsftpd, Raspberry pie ftp host ip To transfer files , It turns out that the raspberry pie system is not installed ftp Instructions . End use filezilla Software implementation Ubuntu File transfer with raspberry pie .
I use it. .deb install , You need to manually install several dependency Libraries ,Ubuntu14.04 64 Bit filezilla Links are as follows https://pkgs.org/ubuntu-14.04/ubuntu-universe-amd64/filezilla_3.7.3-1ubuntu1_amd64.deb/download/
Conditions allow direct online installation , Please do it yourself google
see Ubuntu yes 32 A still 64 You can use the command
If appear x86_64 yes amd64 position , appear i686( Other systems may i386) yes 32 position
my 64 position ubuntu as follows
5.2 copy hellowd Executable file
Raspberry pie and Ubuntu PC Connect to the switch through network cable respectively ( Or a router ), If the raspberry pie is connected with an external LCD screen, it can be operated directly in the raspberry pie , Otherwise, you can go through putty Software in PC Remote login raspberry pie operation , However putty You need to know about raspberry pie ip Address
If you use a router, you can check the address of the router on the browser for raspberry pie ip
Those with display screen can be viewed on the command line of raspberry pie ip
No screen to see ip Reference resources http://www.shumeipaiba.com/wanpai/jiaocheng/17.html
Raspberry pie and PC Direct reference http://www.shumeipaiba.com/wanpai/jiaocheng/20.html
Got the raspberry pie ip after , For example, mine is 192.168.2.46 It can be used filezilla Transfer files to raspberry pie
Host Raspberry pie ip: 192.168.2.46
Password:raspberry ( The default password )
Click on Quickconnect Successful connection
Right click hellowd file ,add files to queue Add to transmission queue
Right click the transmission queue below process queue Processing queues , Complete the transmission . Refresh to see that the raspberry pie on the right already has hellowd file
5.3 perform hellowd
Raspberry pie external display can be directly cd To hellowd route , then ./hellowd perform
It can also be in PC through putty Log in to raspberry pie to execute
Default login pi password raspberry The password will not show , Enter directly after entering , Wrong input is OK backspace Delete
You need to change the authority to hellowd Can be executed by raspberry pie , The implementation is as follows
You can see that it's in line with the program's expectations , Cross compile successful
On the raspberry pie LCD screen, the terminal effect is as follows :
scrot It's a screenshot Software , You can take a screenshot on the raspberry pie , link :https://packages.debian.org/jessie/scrot
use uname -a Check out the raspberry pie structure for armhf, Install the appropriate version .
About scrot Use , Sure scrot --help see
------------------------------------------------------- Update the dividing line --------------------------------------------------------------------
Soon after I finished writing this article, I reloaded Ubuntu14.04 64 position , Reset cross compiler does not appear in this article cross compiler can not find the path and compile error and so on , But the previous mistakes are still worth recording and studying
Now my cross compiler tool is in the root directory ,root Log in to the home directory .bashrc Add cross compiler paths to environment variables
source After checking the version and cross compiling are normal , The path is written in /root/.bashrc /root/.profile /et/profile /etc/bash.bashrc There are no previous mistakes , Tested the addition of PATH The path is written as a variable $HOME/RPI Or the absolute path /RPI/ All normal .
It is recommended to put the tool in the root directory , Don't put it on HOME(/root) in , Modify the environment variables written in /root Of .bashrc in , Try to write absolute paths
This article allows you to reprint , Please state the original address first http://www.cnblogs.com/cursorhu/p/5760415.html
Linux Cross compiling and file transfer of raspberry pie are realized on the host , More related articles about remote login
- Linux Using cross compile migration on the host u-boot To raspberry pie
0 Environmental Science Linux host OS:Ubuntu14.04 64 position , Running on the wmware workstation 10 virtual machine Raspberry pie version :raspberry pi 2 B type . Raspberry pie OS: Debian Jes ...
- adopt SecureCRT To remote Linux Host upload and download files
Sometimes directly in Linux Pass on server wget or curl The tool will be slow to cut large network files , At this time, we usually use in Windows The platform can download good target files through more modern tools such as Xunlei ( Thunderbolt members can be faster ...
- How to be in linux Run on main engine / debugging arm/mips Architecturally binary
How to be in linux Run on main engine / debugging arm/mips Architecturally binary Link to the original text M4x@10.0.0.55 This article is used to show binary They are from Jarvis OJ On pwn Of add,typo Two questions Write this ...
- solve Linux Host computer long-range MySQL The client can't connect
Can't connect to MySQL The possible reasons are as follows : 1. PHP Unable to connect MySQL May be PHP Incorrect configuration , No connection MySQL The function of . 2. MySQL Package upgrade , But the database was not upgraded , Or installation ...
- Linux introduction (1)_VMware And system partition and system installation and remote login management
1 VMware Installation and use Pay attention to it snapshot and clone The function of . A snapshot is equivalent to creating a System restore point , You can go back to your original state at any time . Cloning can replicate the same system as the current one , And you can choose the link to install , Using only a small amount of space can ...
- mac On ssh Tools , Contains simple file transfer functions
I need to be in mac Shanglian ssh, But before mac It's easy to use SSH Shell, No file transfer function found . I miss you very much at this time win Upper winscp, There's an interface , It's very intuitive to pass something on . After several searches , Finally found a ...
- Linux Network programming ：UDP Achieve reliable file transfer
We know , use TCP It's easy to transfer files . be relative to TCP, because UDP Is for connectionless . Unreliable transmission protocol , So we need to consider packet loss and late first come ( Order of packages ) The problem of , So we want to achieve UDP Transfer files , We need to solve these two problems . Fang ...
- Linux On the host java web application
1. Link to remote host command ssh user@hostname Such as : shh email@example.com 2. Check the host operating system version uname -a 3.linux System installation mysql a) Check for installation ...
- Linux Study -Linux User messaging on the host
Query users : w, who, last, lastlog If you want to know the users who have logged into the system at present ? You can go through w or who Come to inquire ! The following example shows : [root@study ~]# w 01:49 ...
- MIFARE series 5《 Storage structure 》
Mifare S50 hold 1K The capacity of bytes is divided into 16 Sectors (Sector0-Sector15), Each sector includes 4 Data blocks (Block0-Block3), We will also 16 It's a sector 64 Blocks are numbered by absolute address as 0~63, Every ...
- framwork NHibernate
NHibernate One .NHibernate 1.HQL curd Sentence summary . Query all fields of the entire mapping object ? // direct from What you find is a mapping object , namely : Query all fields of the entire mapping object String ...
- Imitation Android Netease News client , And add horizontal picture slide , Improve the reading experience
Imitate Netease News Android End APP Main function display and code implementation It took almost a week , So far, we have achieved the goal of news coverage, including headlines . sports . A series of entertainment news shows , And click to enter the news details display . The current effect For the current effect, please visit the website ...
- take Eclipse Existing in java Class generates class diagram
demand : take Eclipse Existing in java Class generates class diagram One : What is? ModelGoon? It's a Eclipse plug-in unit , Used based on UML Model design of graph , And reverse engineering ( That is to generate class diagram from existing source code ). Two : install download Mod ...
- How to use while loop Output a multiplication table
Method 1 i = 1 while i < 10: k = 1 while k <= i: print('%d*%d=%2d '% (i,k,i*k),end='') #end='' It means not to change ...
- xadmin backstage Import excel Functional expansion
newly build excel file stay xadmin Of plugins Let's add one excel.py # _*_ coding:utf-8 _*_ __author__ = "yangtuo" ...
- 「 Luogu 3469」「POI2008」BLO-Blockade【Tarjan Please cut point 】
Topic link [ The valley gate ] Answer key Obviously , When this point is not a cut point , The answer is \(2*(n-1)\) If this point is a cut point , Then the answer is to find the combination number between two separated components . Code #include <bits ...
- Interface testing tool -Jmeter Use notes （ Nine ： Passing variables across thread groups ）
Use scenarios : request API An authorization token is required , But the authorization token only needs to be obtained once , You can call other business interfaces on the server . So I want to put authorization in a separate thread , The business flow is in other threads . This requires me to pass the token obtained from the authorization thread into the business flow ...
- Extranet IP Monitoring and reporting procedures ( Use Poco Library SMTPClientSession Send E-mail )
Catalog IPReport Project introduction Compilation instructions Installation instructions Access to Internet IP The way Email key code IPReport Code address https://gitee.com/solym/IPReport Project introduction Extranet ...
- JMeter-- Use URL Write back to handle user sessions
If the test is Web The application system uses URL Write back instead of Cookie To save session information , So testers need to do some extra work to test web Site In order to respond correctly URL Write back ,JMeter You need to parse the... Received from the server HTML, And get the only ...