After configuring the information in (1), do you have a mood to write a program under Windows. Unlike windows, there is no need to install a VC-like application in Linux. There are already ready-made in the system.
First, write helloworld applicationRainysky is used to convenience. In opt, several folders are created, opt/zedboard/code, and cd /opt/zedboard/code puts its own code inside for easy management.
Use vim helloworld.c to write the file, I believe everyone is familiar with it, the contents are as follows:
Use gcc **.c –o *** when compiling .c files under linux, use ./ to execute the program. In order to distinguish from the later programs, the generated executable file is helloworld_pc, the code and the running result are as follows
The establishment of the cross-compilation environment After running helloworld on the PC, I definitely want to run the program on the zedboard board. Rainysky also has such an expectation, but the executable program of pc can't run directly on the arm board. The reason can be explained roughly. As follows: PC uses the X86 architecture, and the arm uses the arn structure, the two executable binary code is not the same, so the executable file can not be mixed, if there is still a way to use, that is Cross-compilation, the purpose of cross-compilation is to generate files that the target machine (zedboard) can execute on the host. I feel so annoying when I have so much, and I feel that the cross-compilation function is very powerful and it is not easy to get. In fact, zedboard has already given us the cross-compiled files, just a few simple instructions.
In the CD-ROM accompanying the book "Implementation of Software and Hardware Co-Design in Embedded Systems--Based on Xilinx Zynq", the cross-compiled installation files are also included in the directory Chapter 9\Src\9.3 Single Board Computer. I don't know if you remember to set up a shared directory of PCs and virtual machines in the first post. At this time, you can display its convenient functions. Copy it directly to the directory (rainysky is in /opt/zedboard/).
As with the helloworld of the previous section, using the ./xilinx-2011.09-50-arm-xilinx-linux-gnueabi.bin installation file, there is a pitfall in the error, as follows:
Baidu googled a bit, enter the following command dpkg-reconfigure dash in the terminal, and select <No> in the pop-up dialog box, it can be (the reason is probably: Ubuntu shell is installed by default dash, not bash, dash Bash is lighter and faster than bash. But bash is more common. If some commands, scripts, etc. can't be executed normally, it may be the reason for dash. For example, when compiling Android source code, if you use dash, it may compile error. Or the compiled system can not be started. <Online paste>), can be installed, it will go all the way by default, but this time it is best to pay attention to where the file is installed.
At this time you can find a cross-compilation tool similar to gcc.
Cross-tools are not a lot, but if you enter arm-xilinx-linux-gnueabi-gcc directly in the terminal, you will not be prompted. This is similar to windows, you need to set the environment variable, in ubuntu, the environment variable file is /etc/bash.bashrc, modify this file on the line (command vim /etc/bash.bashrc), the added content is
Export ARCH=arm
Export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
Export PATH=/root/CodeSourcery/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux/bin/:$PATH
At this point save the file, and close the terminal, re-open a terminal input arm-xilinx Press a few tabs to show the cute cross-compilation chain. This concludes that the cross-compilation chain is installed.
Cross compilation helloworld
After the cross-compilation chain is successfully installed, you can cross-compile the c file, go to the /opt/zedboard/code/ folder, use arm-xilinx-linux-gnueabi-gcc helloworld.c -o helloworld_zed to generate the zed board. The file that can be executed on the card, and verify it with the file command
As you can see above, helloworld_zed is a program that runs in the arm architecture. helloworld_pc is executable under the X86 architecture. After that, it will be OK to run on the board. . . . . . . . . .
Surface Mount,Adjustable Surface Mounted Socket,Surface Mount Socket,Surface Mount Dc Socket
Dongguan Swan Electronic Technology Co., Ltd , https://www.swanconnector.com