同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
You must complete the settings in Basic OS Environment Setup.
NOTICE: This section describes how to use an installation package to set up the compilation and building environment. If you are going to use Docker to set up the environment, the Linux server-related tools in Table 1 are not required, and you only need to install the Windows workstation.
The following table describes the environment configuration requirements specific to the Hi3861 development board.
Table 1 Hi3861 development environment-specific requirements
NOTICE:
- If you acquire the source code using an HPM component or HPM CLI tool, gcc_riscv32 is not required.
- (Recommended) If you obtain the source code via the mirror site or code repository, install gcc_riscv32. When installing gcc_riscv32, ensure that the environment variable paths of the compilation tools are unique.
Install the software.
sudo apt-get install build-essential && sudo apt-get install gcc && sudo apt-get install g++ && sudo apt-get install make && sudo apt-get install zlib* && sudo apt-get install libffi-dev
Start a Linux server.
Install the SCons installation package.
python3 -m pip install scons
Check whether the installation is successful.
scons -v
Figure 1 Successful installation (SCons version requirement: 3.0.4 or later)
Install setuptools.
pip3 install setuptools
Install the GUI menuconfig tool (Kconfiglib). You are advised to install Kconfiglib 13.2.0 or later.
Command line:
sudo pip3 install kconfiglib
Installation package:
Download the .whl file (for example, kconfiglib-13.2.0-py2.py3-none-any.whl).
Download path: https://pypi.org/project/kconfiglib#files
Install the .whl file.
sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl
Install PyCryptodome using either of the following methods:
Install the Python component packages on which the file signature depends, including PyCryptodome, six, and ecdsa. As the installation of ecdsa depends on that of six, install six first.
Command line:
sudo pip3 install pycryptodome
Installation package:
Download the .whl file (for example, pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl).
Download path: https://pypi.org/project/pycryptodome/#files
Install the .whl file.
sudo pip3 install pycryptodome-3.9.9-cp38-cp38-manylinux1_x86_64.whl
Install six using either of the following methods:
Command line:
sudo pip3 install six --upgrade --ignore-installed six
Installation package:
Download the .whl file, for example, six-1.12.0-py2.py3-none-any.whl.
Download path: https://pypi.org/project/six/#files
Install the .whl file.
sudo pip3 install six-1.12.0-py2.py3-none-any.whl
Install ecdsa using either of the following methods:
Command line:
sudo pip3 install ecdsa
Installation package:
Download the .whl file, for example, ecdsa-0.14.1-py2.py3-none-any.whl.
Download path: https://pypi.org/project/ecdsa/#files
Install the .whl file.
sudo pip3 install ecdsa-0.14.1-py2.py3-none-any.whl
NOTICE: The Hi3861 platform supports only the static link of the libgcc library. The dynamic link is not recommended because version 3 of the GNU General Public License (GPLv3) will be polluted during commercial distribution.
Start a Linux server.
Install the GCC, G++, Bison, Flex, Makeinfo tools to ensure that the toolchain can be correctly compiled.
sudo apt-get install gcc && sudo apt-get install g++ && sudo apt-get install flex bison && sudo apt-get install texinfo
Download the RISC-V GNU toolchain.
git clone --recursive https://github.com/riscv/riscv-gnu-toolchain
Open the riscv-gnu-toolchain folder and delete empty folders to prevent conflicts during the download of Newlib, Binutils, and GCC.
cd riscv-gnu-toolchain && rm -rf riscv-newlib && rm -rf riscv-binutils && rm -rf riscv-gcc
Download RISC-V Newlib 3.0.0.
git clone -b riscv-newlib-3.0.0 https://github.com/riscv/riscv-newlib.git
Download RISC-V Binutils 2.31.1.
git clone -b riscv-binutils-2.31.1 https://github.com/riscv/riscv-binutils-gdb.git
Download RISC-V GCC 7.3.0.
git clone -b riscv-gcc-7.3.0 https://github.com/riscv/riscv-gcc
Add the RISC-V GCC 7.3.0 patch.
Visit the GCC official patch links 89411 and 86724, and manually add the changes to the .c and .h files based on the requirements in the patch links. Note that the number of rows may not match because of different versions of the patch and GCC. You need to search for the keyword in the patch to locate the corresponding row.
Download, decompress, and install GMP 6.1.2.
tar -xvf gmp-6.1.2.tar.bz2 && mkdir build_gmp && cd build_gmp && ../gmp-6.1.2/configure --prefix=/usr/local/gmp-6.1.2 --disable-shared --enable-cxx && make && make install
Download, decompress, and install mpfr-4.0.2.
tar -xvf mpfr-4.0.2.tar.gz && mkdir build_mpfr && cd build_mpfr && ../mpfr-4.0.2/configure --prefix=/usr/local/mpfr-4.0.2 --with-gmp=/usr/local/gmp-6.1.2 --disable-shared && make && make install
Download, decompress, and install mpc-1.1.0.
tar -xvf mpc-1.1.0.tar.gz && mkdir build_mpc && cd build_mpc && ../mpc-1.1.0/configure --prefix=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2 --disable-shared && make && make install
Open the riscv-gnu-toolchain folder and create a directory for toolchain output.
cd /opt && mkdir gcc_riscv32
Compile binutils.
mkdir build_binutils && cd build_binutils && ../riscv-binutils-gdb/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --bindir=/opt/gcc_riscv32/bin --libexecdir=/opt/gcc_riscv32/riscv32 --libdir=/opt/gcc_riscv32 --includedir=/opt/gcc_riscv32 && make -j16 && make install && cd ..
Build Newlib.
mkdir build_newlib && cd build_newlib && ../riscv-newlib/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" \CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --bindir=/opt/gcc_riscv32/bin --libexecdir=/opt/gcc_riscv32 --libdir=/opt/gcc_riscv32 --includedir=/opt/gcc_riscv32 && make -j16 && make install && cd ..
Build GCC.
mkdir build_gcc && cd build_gcc && ../riscv-gcc/configure --prefix=/opt/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" CXXFLAGS="-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE" LDFLAGS="-Wl,-z,relro,-z,now,-z,noexecstack" CXXFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" CFLAGS_FOR_TARGET="-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar" --with-headers="/opt/gcc-riscv32/riscv32-unknown-elf/include" --with-mpc=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2 && make -j16 && make install
Set an environment variable.
vim ~/.bashrc
Copy the following command to the last line of the .bashrc file, save the file, and exit.
export PATH=/opt/gcc_riscv32/bin:$PATH
Validate the environment variable.
source ~/.bashrc
Check whether the compiler is successfully installed. If the compiler version number is correctly displayed, the installation is successful.
riscv32-unknown-elf-gcc -v
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。