hi3531 cross-compilation environment Arm-hisiv100nptl-linux building process on Ubuntu

Source: Internet
Author: User

Install SDK
1.Hi3531 SDK package location
In the "Hi3531_V100R001 *** / 01.software/board" directory, you can see a Hi3531_SDK_Vx.x.x.x.tgz file,
This file is the Hi3531 software development kit.


2.Unzip SDK package
On a Linux server (or a major Linux distribution on a PC with Linux installed), use the command: tar -zxf Hi3531_SDK_Vx.x.x.x.tgz,
Unzip the file to get a Hi3531_SDK_Vx.x.x.x directory.


3.Expand SDK package contents
Return to the Hi3531_SDK_Vx.x.x.x directory and run ./sdk.unpack (please execute with root or sudo permissions). The SDK package will be packed and compressed. Please follow the prompts to complete


Make.
If you need to transfer and copy the SDK package through the Windows operating system, please run ./sdk.cleanup first, collapse the contents of the SDK package, copy to the new directory, and then expand.


4. Install cross compiler on linux server
1) Install the uclibc cross compiler (note that you need to have sudo permissions or root permissions):
Enter Hi3531_SDK_Vx.x.x.x / osdrv / toolchain / arm-hisiv100-linux directory, run chmod + x cross.install, and then run ./cross.install


Just fine.
2) Install glibc cross compiler (note that you need to have sudo or root permissions):
Enter Hi3531_SDK_Vx.x.x.x / osdrv / toolchain / arm-hisiv200-linux directory, run chmod + x cross.install, and then run ./cross.install


Just fine.
3) Run source / etc / profile, and the environment variables configured by the script for installing the cross-compiler will take effect, or please log in again.

Enter the command arm-linux on the terminal and press the Tab key, you can see the following figure, indicating that the environment variable is successfully set

ls @ ubuntu: / slq / nfs / mpp $ arm-hisiv100nptl-linux-
arm-hisiv100nptl-linux-addr2line arm-hisiv100nptl-linux-gprof
arm-hisiv100nptl-linux-ar arm-hisiv100nptl-linux-ld
arm-hisiv100nptl-linux-as arm-hisiv100nptl-linux-nm
arm-hisiv100nptl-linux-c ++ arm-hisiv100nptl-linux-objcopy
arm-hisiv100nptl-linux-c ++ filt arm-hisiv100nptl-linux-objdump
arm-hisiv100nptl-linux-cpp arm-hisiv100nptl-linux-ranlib
arm-hisiv100nptl-linux-g ++ arm-hisiv100nptl-linux-readelf
arm-hisiv100nptl-linux-gcc arm-hisiv100nptl-linux-size
arm-hisiv100nptl-linux-gcc-4.4.1 arm-hisiv100nptl-linux-strings
arm-hisiv100nptl-linux-gccbug arm-hisiv100nptl-linux-strip
arm-hisiv100nptl-linux-gcov



Verify, compile a hello.c file

#include <stdio.h>
int main ()
{
Printf ("hello world! \ N");
}


Use the command: arm-hisiv100nptl-linux-gcc hello.c -o hello to see if the compilation is successful

Root @ ubuntu: / slq / test # ls
hello hello.c

It can be seen that the binary file was successfully generated. Zh




5.Compile osdrv
1.osdrv instructions
The design idea of this directory is that a set of source code supports two toolchain compilations, so different toolchains need to be specified through compilation parameters. Among them, arm-hisiv100nptl-linux is the uclibc toolchain, and arm-hisiv200-linux is the glibc toolchain. The specific commands are as follows
(1) Compile the entire osdrv directory:
make OSDRV_CROSS = arm-hisiv100nptl-linux all
or
make OSDRV_CROSS = arm-hisiv200-linux all
(2) Clear the compiled files of the entire osdrv directory:
make OSDRV_CROSS = arm-hisiv100nptl-linux clean
or
make OSDRV_CROSS = arm-hisiv200-linux clean
(3) Completely clear the compiled files of the entire osdrv directory. In addition to clearing the compiled files, delete the compiled image:
make OSDRV_CROSS = arm-hisiv100nptl-linux distclean
or
make OSDRV_CROSS = arm-hisiv200-linux distclean
(4) Compile the kernel separately:
After entering the kernel source code directory, perform the following operations
cp arch / arm / configs / godnet_defconfig .config
make ARCH = arm CROSS_COMPILE = arm-hisiv100nptl-linux- menuconfig
make ARCH = arm CROSS_COMPILE = arm-hisiv100nptl-linux- uImage
or
cp arch / arm / configs / godnet_defconfig .config
make ARCH = arm CROSS_COMPILE = arm-hisiv200-linux- menuconfig
make ARCH = arm CROSS_COMPILE = arm-hisiv200-linux- uImage
(5) Compile uboot separately:
After entering the boot source code directory, perform the following operations
make ARCH = arm CROSS_COMPILE = arm-hisiv100nptl-linux- godnet_config
make ARCH = arm CROSS_COMPILE = arm-hisiv100nptl-linux-
or
make ARCH = arm CROSS_COMPILE = arm-hisiv200-linux- godnet_config
make ARCH = arm CROSS_COMPILE = arm-hisiv200-linux-
(6) Make a file system image:
There is a compiled file system in osdrv / pub /, so there is no need to repeatedly compile the file system. You only need to make a file system image according to the specifications and models of flash on the board.


The spi flash uses a jffs2 format image. When making a jffs2 image, the block size of the spi flash is required. This information is printed when uboot starts. It is recommended to run the mkfs.jffs2 tool directly before use, and fill in the relevant parameters based on the print information. The following example uses a block size of 64KB:
osdrv / pub / bin / pc / mkfs.jffs2 -d osdrv / pub / rootfs_uclibc -l -e 0x40000 -o osdrv / pub / rootfs_uclibc_256k.jffs2


osdrv / pub / bin / pc / mkfs.jffs2 -d osdrv / pub / rootfs_uclibc -l -e 0x10000 -o osdrv / pub / rootfs_uclibc_64k.jffs2
sudo osdrv / pub / bin / pc / mkfs.jffs2 -d osdrv / pub / rootfs_uclibc -l -e 0x10000 --pad = 0x9A0000 -o osdrv / pub / rootfs_uclibc_64k.jffs2
sudo osdrv / pub / bin / pc / mkfs.jffs2 -d osdrv / pub / rootfs_uclibc_slq -l -e 0x10000 --pad = 0x9A0000 -o osdrv / pub / rootfs_uclibc_64k_slq.jffs2


sudo osdrv / pub / bin / pc / mkfs.jffs2 -d osdrv / pub / rootfs_custom_slq -l -e 0x10000 --pad = 0x100000 -o osdrv / pub / rootfs_custom_64k_slq.jffs2
or
osdrv / pub / bin / pc / mkfs.jffs2 -d osdrv / pub / rootfs_glibc -l -e 0x40000 -o osdrv / pub / rootfs_glibc_256k.jffs2


The nand flash uses a yaffs2 format image. To make a yaffs2 image, you need to use the pagesize and ecc of the nand flash. This information is printed when uboot starts. It is recommended to run the mkyaffs2image tool directly before use and fill in the relevant parameters based on the print information. The following uses 2KB pagesize and 1bit ecc as examples:
osdrv / pub / bin / pc / mkyaffs2image osdrv / pub / rootfs_uclibc osdrv / pub / rootfs_uclibc_2k_1bit.yaffs2 1 1
or
osdrv / pub / bin / pc / mkyaffs2image osdrv / pub / rootfs_glibc osdrv / pub / rootfs_glibc_2k_1bit.yaffs2 1 1
(7) Compile the PCIE MCC driver module separately:
First, prepare the kernel source code directory you need to link to when compiling the module:
cd ./kernel/
tar -xvf linux-3.0.y.tgz
After decompressing the kernel source code, you need to compile the kernel (taking Hi3531 as an example) according to the specific chip type to generate the corresponding header file.
cd ./linux-3.0.y
cp arch / arm / configs / godnet_defconfig .config
make ARCH = arm CROSS_COMPILE = arm-hisiv100nptl-linux- menuconfig
make ARCH = arm CROSS_COMPILE = arm-hisiv100nptl-linux- uImage
After the kernel source code is prepared, you can enter the source code directory of the PCIE MCC driver module and compile the driver:
cd ../../drv/pcie_mcc
If it is ko to compile the main film, use the make command directly
make
If you are compiling the ko file from the slice, please bring the parameter target = slave
make target = slave
(Note: By default, the compiler-driven toolchain is arm-hisiv100nptl-linux-, if you need to change, please bring the parameter CROSS_COMPILE = arm-hisiv200-linux-)


2. Image storage directory description
Compiled images, rootfs, etc. are stored in the osdrv / pub directory
pub
│ rootfs_uclibc.tgz ------------------------------------------ Compiled by hisiv100nptl rootfs file system
│ rootfs_glibc.tgz ------------------------------------------- hisiv200 compiled Rootfs file system

├─image_glibc-
----------------------------------------------- Hisiv200 compiled Image file
│ ^ uImage ------------------------------------------------ -kernel image
│ ba u-boot-hi3531_930MHz.bin ------------------------------- u-boot image
│ rootfs_256k.jffs2 -------------------------------------- jffs2 rootfs image (corresponding to spi-flash blocksize = 256K)
│ ^ rootfs_2k_1bit.yaffs2 ---------------------------------- yaffs2 rootfs image (corresponding to nand-flash pagesize = 2K ecc = 1bit)

├─image_uclibc ----------------------------------------------- hisiv100nptl compiled image file
│ ^ uImage ------------------------------------------------ -kernel image
│ ba u-boot-hi3531_930MHz.bin ------------------------------- u-boot image
│ rootfs_256k.jffs2 -------------------------------------- jffs2 rootfs image (corresponding to spi-flash blocksize = 256K)
│ ^ rootfs_2k_1bit.yaffs2 ---------------------------------- yaffs2 rootfs image (corresponding to nand-flash pagesize = 2K ecc = 1bit)

└─bin
├ ├─pc
│ │ │ mkfs.jffs2
│ │ │ mkimage
│ │ mkfs.cramfs
│ │ │ mkyaffs2image
│ │
├─board_glibc -------------------------------------------- Compiled by hisiv200 Single board tools and pcie message communication layer ko
│ │ │ flash_eraseall
│ │ │ mcc_usrdev_host.ko
│ │ │ flash_erase
│ │ │ mcc_usrdev_slv.ko
│ │ │ 35hi_xx_dev_slv.ko
│ │ │ nandwrite
│ │ │ 35hi_xx_dev_host.ko
│ │ │ mcc_drv_slv.ko
│ │ mtmt_debug
│ │ │ flash_info
│ │ │ mcc_drv_host.ko
│ │ │ boot_device.ko
│ │ │ pcit_dma_slv.ko
│ │ │ sumtool
│ │ mtmtinfo
│ │ │ flashcp
│ │ │ nandtest
│ │ nanddump
│ │ │ parted_glibc
│ │ │ pcit_dma_host.ko
│ │ │ gdb-arm-hisiv200-linux
│ │
└─board_uclibc ------------------------------------------- compiled by hisiv100nptl Single board tool and pcie message communication layer ko
Flash_eraseall
Mcc_usrdev_host.ko
Flash_erase
Mcc_usrdev_slv.ko
35 _ 35 35 hi35xx_dev_slv.ko
Nandwrite
Hi35xx_dev_host.ko
Mcc_drv_slv.ko
Mtd_debug
Flash_info
Parted_uclibc
Mcc_drv_host.ko
Boot_device.ko
Pcit_dma_slv.ko
^ ^ ^ Sumtool
Mtdinfo
Flashcp
Nandtest
Gdb-arm-hisiv100nptl-linux
Nanddump
Cit cit pcit_dma_host.ko




3.osdrv directory structure description:
osdrv
├─Makefile ------------------------------ osdrv directory compilation script
├─busybox ------------------------------- The directory where the busybox source code is stored
├─tools --------------------------------- Directory for storing various tools
│ ├├─board_tools ----------------------- various boards use tools
│ │ │├─reg-tools-1.0.0 --------------- register read and write tools
│ ││ ├├─mtd-utils --------------------- flash naked reading and writing tool
│ ││ ├├─udev-100 ---------------------- udev toolset
│ ││ ├├─gdb --------------------------- gdb tool
│ ││ ├├partial ------------------------ Large-capacity hard disk partition tool
│ ││ └─e2fsprogs --------------------- mkfs toolset
│ └─pc_tools -------------------------- Tools for various pcs
│ │ ├├─mkfs.cramfs ------------------- cramfs file system creation tool
│ │ ├├─mkfs.jffs2 -------------------- jffs2 file system production tool
│ │ ├├─mkimage ----------------------- uImage production tool
│ │ ├├─mkyaffs2image301 -------------- yaffs2 file system production tool
│ │ ├├─nand_production --------------- nand flash programming file creation tool
│ └─uboot_tools ------------------- uboot image creation tool, xls file and ddr initialization script, bootrom tool
├─toolchain ----------------------------- Directory to store the toolchain
│ ├├─arm-hisiv100nptl-linux ---------------- hisiv100nptl cross tool chain
│ └─arm-hisiv200-linux ---------------- hisiv200 cross tool chain
├─pub ----------------------------------- Directory for various images
│ ├├─image_glibc ----------------------- Compiled based on hisiv100nptl toolchain, image files available for flash programming, including uboot, kernel, file system
│ ├├─image_uclibc ---------------------- An image file compiled based on hisiv200 toolchain for flash programming, including uboot, kernel, file system
│ ├├─bin ------------------------------- various tools not put in the root file system
│ ││ ├├─pc ---------------------------- tools to execute on pc
│ │ ├├board_glibc ------------------- Tools compiled on the board based on hisiv100nptl tool chain
│ │ └ board─board_uclibc ------------------ Tools compiled on the board based on hisiv200 toolchain
│ ├├─rootfs_uclibc.tgz ----------------- root file system compiled based on hisiv100nptl toolchain
│ └─rootfs_glibc.tgz ------------------ root file system compiled based on hisiv200 toolchain
├─drv ----------------------------------- Directory for storing peripheral drivers
│ └─pcie_mcc -------------------------- pcie message communication layer driver
├─rootfs_scripts ------------------------ The directory where the root file system makes scripts
├─uboot --------------------------------- Directory for uboot source code
└─kernel -------------------------------- The directory where the kernel source code is stored




4. Notes
(1) After compiling with a toolchain, if you need to replace the toolchain, please clear the original toolchain compilation file, and then replace the toolchain to compile.
(2) When copying source code packages under windows, executable files under linux may become non-executable files, resulting in failure to compile and use. After u-boot or kernel compilation, there will be many symbolic link files, which are copied under windows. These source code packages will make the source code package huge, because the symbolic link file under Linux becomes a real file under Windows, so the source code package swells. So please be careful not to copy the source code package under windows.
(3) The current network is an adaptive mode. If you want to change to a fixed rate mode, you need to modify the file kernel / linux-3.0.y / drivers / net / stmmac / stmmac_mdio.c:
Turn off the macro definition TNK_HW_PLATFORM_ADJUST and comment out 33 lines;
Select a speed that requires a fixed configuration. For example, if the fixed configuration is 100M full-duplex, open the 46-line macro definition PHY_SPEED_100.
(4) Hi3531 supports hard floating point. The libraries released in the file system are all hard floating point libraries. Therefore, please note that when compiling all Hi3531 board code, you need to add the following commands in the Makefile:
CFLAGS + = -march = armv7-a -mcpu = cortex-a9 --mfloat-abi = softfp -mfpu = vfpv3-d16
CXXFlAGS + =-march = armv7-a -mcpu = cortex-a9 --mfloat-abi = softfp -mfpu = vfpv3-d16
Among them, XX in CXXFlAGS is determined according to the specific name of the macro used in the user's Makefile, e.g: CPPFLAGS.



reference:

http://blog.csdn.net/mybelief321/article/details/9076583

Ubuntu12.04 embedded cross-compilation environment arm-linu-gcc build process, illustrated
Category: Qt programming2013-06-12 08:44 2462 people read comments (2) favorite collection report
ubuntu12.04arm-linux-gcc
Installation Environment

Linux version: Ubuntu 12.04 Kernel version: Linux 3.5.0 Cross-compiler version: arm-linux-gcc-4.4.3 I have uploaded the cross-compiler for this version, you can download it, click here to download

Before the installation

First, let's briefly introduce the so-called cross-compilation environment, which is to install and configure the cross-compilation tool chain. Under this environment, the operating system, applications, etc. required by the embedded Linux system are compiled, and then uploaded to the target machine.

The cross-compilation toolchain is designed to compile, link, process, and debug program code for cross-platform architectures. For cross-developed toolchains, a prefix is added to the file name to distinguish the local toolchain. For example, arm-linux- means the cross-compilation toolchain for arm; arm-linux-gcc means the compiler using gcc. Except for the architecture-related compilation options, it is used in the same way as gcc on a Linux host, so Linux programming techniques are equally applicable to embedded. However, not every version can be used, and various software packages often have version matching problems. For example, when compiling the kernel, you need to use the arm-linux-gcc-4.3.3 version of the cross-compilation tool chain, while using the arm-linux-gcc-3.4.1 version of the cross-compilation tool chain, the compilation will fail.

What is the difference between gcc and arm-linux-gcc? The difference is that gcc is a C language compiler under linux, the compiled program is executed locally, and arm-linux-gcc is used to cross-platform C language compiler under linux, and the compiled program is on the target machine (such as ARM platform ), Embedded development should use the embedded cross-compilation tool chain.

installation steps

1. Store the compressed package arm-linux-gcc-4.4.3.tar.gz in a directory. This directory is the directory you will decompress. You cannot delete this directory afterwards. My storage path is / home / song / software, as shown below, remember this path, will be used later.

Zh

2.Use the tar command: tar zxvf arm-gcc-4.4.3.tar.gz to decompress and install arm-linux-gcc-4.4.3.tar.gz in the software folder to the current directory as shown below

^ ^

The following figure shows that the decompression was successful, and the decompressed files are stored in the /home/song/software/opt/FriendlyARM/toolschain/4.4.3 folder, as shown in the following figure. ,As shown below

Zh

3. Next, configure the system environment variables and add the path of the cross-compilation tool chain to the environment variable PATH so that you can use these tools in any directory. Make a note of the installation path in the previous step, use the command: vim / etc / profile to edit the profile file, and add environment variables.



Add the last line in the profile: export PATH = $ PATH: /home/song/software/opt/FriendlyARM/toolschain/4.4.3/bin This path is the path where the bin directory is located. Maybe yours is different. Just fill in the directory, as shown in Figure 32 below

Zh

After writing and saving, just fine

4. Use the command: source / etc / profile to make the environment variables take effect

5. Enter the command arm-linux on the terminal and then press the Tab key, you can see the following figure, indicating that the environment variable is successfully set

Zh

6. Use the command: arm-linux-gcc -v and the following error message will appear: /home/song/software/opt/FriendlyARM/toolschain/4.4.3/bin/arm-linux-gcc: 15: exec: / home /song/software/opt/FriendlyARM/toolschain/4.4.3/bin/.arm-none-linux-gnueabi-gcc: not found

Zh

The reason for this problem is that Ubuntu 12.04 uses 64-bit. The solution is to use the command: sudo apt-get install ia32-libs to install some 32-bit libraries

Zh

7. After installing the 32-bit library, use the command: arm-linux-gcc -v, this time it succeeds, as shown below

Zh

8, verify, compile a hello.c file

Zh

Use the command: arm-linux-gcc hello.c -o hello to see if the compilation is successful

Zh

It can be seen that the binary file was successfully generated. Zh

Reprint please indicate the source: http://blog.csdn.net/mybelief321/article/details/9076583
————————————————
Copyright statement: This article is the original article of the CSDN blogger "lianqiang_sun", which follows the CC 4.0 BY-SA copyright agreement. Please reprint the original source link and this statement for reprinting.
Original link: https://blog.csdn.net/s170262941/article/details/20707675


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.