龙芯技术社区
直播中

gjianw217

10年用户 688经验值
擅长:嵌入式技术 控制/MCU RF/无线
私信 关注
[2K系列]

【龙芯2K0300蜂鸟板试用】4 ubuntu20搭建开发环境(uboot kernel rootfs)

环境

PC:WIN11+X86
VMware Workstation Pro :15
Ubuntu:22.04

虽然官方提供了配置好的Ubuntu开发环境,但版本ubuntu版本是18的,本次是基于新安装的ubuntu22上,搭建龙芯2K0300蜂鸟板开发环境,中间遇到了些问题,结果是成功的。

toolchain

1 [ 龙芯 GNU 编译工具链](http://www.loongnix.cn/zh/toolchain/GNU/)官方下载

2 右侧,历史版本,选择最新版本下载
image.png

3 解压

tar xvf ../Downloads/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1.tar.xz -C toolchain

4 参考官方setenv.sh,制作脚本

source setenv.sh

1)source会在当前终端,执行或sh会创建子进程,
2)一定要source,否则环境变量不生效

uboot

1 下载代码

git clone https://gitee.com/open-loongarch/u-boot

2 编译,最后生成u-boot-with-spl.bin

make loongson_2k300_mini_dp_defconfig
make

3 报错解决

**$ make loongson_2k300_mini_dp_defconfig**
**make[1]: Entering directory '/home/xproject/2k0300/uboot/u-boot/build'**
**  HOSTCC  scripts/basic/fixdep**
**/bin/sh: 1: cc: not found**
**make[2]: ***** [scripts/Makefile.host:95: scripts/basic/fixdep] Error 127**
**make[1]: *** [/home/xproject/2k0300/uboot/u-boot/Makefile:492: scripts_basic] Error 2**
**make[1]: Leaving directory '/home/xproject/2k0300/uboot/u-boot/build'**
**make: *** [Makefile:177: sub-make] Error 2

**make loongson_2k300_mini_dp_defconfig**
**make[1]: Entering directory '/home/xproject/2k0300/toolchain/build'**
**  HOSTCC  scripts/basic/fixdep**
**  GEN     Makefile**
**  HOSTCC  scripts/kconfig/conf.o**
**  YACC    scripts/kconfig/zconf.tab.c**
**/bin/sh: 1: bison: not found**
**make[2]: ***** [scripts/Makefile.lib:224: scripts/kconfig/zconf.tab.c] Error 127**
**make[1]: *** [/home/xproject/2k0300/test/u-boot-2022.04-devboard-src/Makefile:574: loongson_2k300_mini_dp_defconfig] Error 2**
**make[1]: Leaving directory '/home/xproject/2k0300/toolchain/build'**
**make: *** [Makefile:177: sub-make] Error 2

**make[1]: Entering directory '/home/xproject/2k0300/toolchain/build'**
**  GEN     Makefile**
**  YACC    scripts/kconfig/zconf.tab.c**
**  LEX     scripts/kconfig/zconf.lex.c**
**/bin/sh: 1: flex: not found**
**make[2]: ***** [scripts/Makefile.lib:216: scripts/kconfig/zconf.lex.c] Error 127**
**make[1]: *** [/home/xproject/2k0300/test/u-boot-2022.04-devboard-src/Makefile:574: loongson_2k300_mini_dp_defconfig] Error 2**
**make[1]: Leaving directory '/home/xproject/2k0300/toolchain/build'**
**make: *** [Makefile:177: sub-make] Error 2

**sudo apt-get install make**
**sudo apt-get install gcc**
**sudo apt-get install bison**
**sudo apt-get install flex      ^**~~~~~~~~~~

**$ make**
**../include/image.h:1167:12: fatal error: openssl/evp.h: No such file or directory**
** 1167 | #  include <openssl/evp.h>**
**      |            ^**~~~~~~~~~~**
** sudo apt-get install libssl-dev

kernel

1 下载代码

git clone https://gitee.com/open-loongarch/linux-5.10.git

2 编译,最后生成uImage.gz

make loongson_2k300_defconfig
make uImage

3 报错解决

**error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel**

**sudo apt-get install libelf-dev**

**"mkimage" command not found - U-Boot images will not be built**

**arch/loongarch/boot/ 生成 uImage 文件。**

**sudo apt-get install u-boot-tools**

**Invalid architecture, supported are:**
**	**alpha            Alpha**
**	**arc              ARC**
**	**arm              ARM**
**	**arm64            AArch64**
**	**avr32            AVR32**
**	**blackfin         Blackfin**
**	**ia64             IA64**
**	**invalid          Invalid ARCH**
**	**m68k             M68K**
**	**microblaze       MicroBlaze**
**	**mips             MIPS**
**	**mips64           MIPS 64 Bit**
**	**nds32            NDS32**
**	**nios2            NIOS II**
**	**or1k             OpenRISC 1000**
**	**powerpc          PowerPC**
**	**riscv            RISC-V**
**	**s390             IBM S390**
**	**sandbox          Sandbox**
**	**sh               SuperH**
**	**sparc            SPARC**
**	**sparc64          SPARC 64 Bit**
**	**x86              Intel x86**
**	**x86_64           AMD x86_64**
**	**xtensa           Xtensa

**Error: Invalid architecture**

**sudo mv /usr/bin/mkimage /usr/bin/mkimage.bk**
**sudo cp ../../uboot/u-boot/build/tools/mkimage /usr/bin/mkimage**

rootfs

1 下载代码

git clone https://gitee.com/open-loongarch/buildroot.git

2 编译,最后生成rootfs.img

make loongson2k300_mini_dp_defconfig
make

3 报错解决

usr/bin/make -j1 O=/home/xproject/2k0300/rootfs/buildroot/output HOSTCC="/usr/bin/gcc" HOSTCXX="g++" syncconfig

You seem to have the current working directory in your
LD_LIBRARY_PATH environment variable. This doesn't work.
make[1]: *** [support/dependencies/dependencies.mk:27: dependencies] Error 1
make: *** [Makefile:84: _all] Error 2

>>https://blog.csdn.net/huliu0521/article/details/115403437
>
>make
>/usr/bin/make -j1 O=/home/xproject/2k0300/rootfs/buildroot/output HOSTCC="/usr/bin/gcc" HOSTCXX="g++" syncconfig

You seem to have the current working directory in your
LD_LIBRARY_PATH environment variable. This doesn't work.
make[1]: *** [support/dependencies/dependencies.mk:27: dependencies] Error 1
make: *** [Makefile:84: _all] Error 2
xproject@xproject:~/2k0300/rootfs/buildroot$ echo $LD_LIBRARY_PATH
/home/xproject/2k0300/toolchain/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1/loongarch64-linux-gnu/lib64:/home/xproject/2k0300/toolchain/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1/lib:/home/xproject/2k0300/toolchain/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1/loongarch64-linux-gnu/lib64:/home/xproject/2k0300/toolchain/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1/lib:
xproject@xproject:~/2k0300/rootfs/buildroot$ export LD_LIBRARY_PATH=/home/xproject/2k0300/toolchain/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1/loongarch64-linux-gnu/lib64:/home/xproject/2k0300/toolchain/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1/lib:/home/xproject/2k0300/toolchain/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1/loongarch64-linux-gnu/lib64:/home/xproject/2k0300/toolchain/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.3-1/lib
xproject@xproject:~/2k0300/rootfs/buildroot$ make


make

You may have to install 'g++' on your build machine
You must install 'hg' on your build machine
  hg is usually part of the mercurial package in your distribution
make[1]: *** [support/dependencies/dependencies.mk:27: dependencies] Error 1
make: *** [Makefile:84: _all] Error 2
xproject@xproject:~/2k0300/rootfs/buildroot$ sudo apt-get install g++

sudo apt update && sudo apt upgrade
sudo apt-get install hgsubversion
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package hgsubversion is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'hgsubversion' has no installation candidate

sudo apt install mercurial



annot execute cross-compiler '/opt/loongson-gnu-toolchain-x86_64-loongarch64-linux-gnu/bin/loongarch64-linux-gnu-gcc'


make menuconfig 《配置交叉编译器》
 *** 'make menuconfig' requires the ncurses libraries.

***

 *** Install ncurses (ncurses-devel or libncurses-dev 

sudo apt-get install libncurses-dev




/home/xproject/2k0300/rootfs/buildroot/output/build/qt5base-5.15.2/src/corelib/text/qbytearraymatcher.h: In static member function ‘static QStaticByteArrayMatcherBase::Skiptable QStaticByteArrayMatcherBase::generate(const char*, uint)’:
/home/xproject/2k0300/rootfs/buildroot/output/build/qt5base-5.15.2/src/corelib/text/qbytearraymatcher.h:103:38: error: ‘numeric_limits’ is not a member of ‘std’
  103 |         const auto uchar_max = (std::numeric_limits<uchar>::max)();
      |                                      ^~~~~~~~~~~~~~
/home/xproject/2k0300/rootfs/buildroot/output/build/qt5base-5.15.2/src/corelib/text/qbytearraymatcher.h:103:58: error: expected primary-expression before ‘>’ token
  103 |         const auto uchar_max = (std::numeric_limits<uchar>::max)();
      |                                                          ^
/home/xproject/2k0300/rootfs/buildroot/output/build/qt5base-5.15.2/src/corelib/text/qbytearraymatcher.h:103:61: error:::max’ has not been declared; did you mean ‘std::max’?
  103 |         const auto uchar_max = (std::numeric_limits<uchar>::max)();
      |                                                             ^~~
      |                                                             std::max


https://blog.csdn.net/shanpenghui/article/details/79487015
#include <stdexcept>
#include <limits>


In file included from ../../../include/QtCore/5.15.2/QtCore/private/qoffsetstringarray_p.h:1,
                 from ../../dbus/qdbuserror.cpp:44:
../../../include/QtCore/5.15.2/QtCore/private/../../../../../src/corelib/tools/qoffsetstringarray_p.h:70:22: error: ‘numeric_limits’ is not a member of ‘std’
   70 |         Last <= std::numeric_limits<quint8>::max(),
      |                      ^~~~~~~~~~~~~~
../../../include/QtCore/5.15.2/QtCore/private/../../../../../src/corelib/tools/qoffsetstringarray_p.h:70:43: error: wrong number of template arguments (1, should be 3)
   70 |         Last <= std::numeric_limits<quint8>::max(),


----------------

ster && mkdir -p build && cd ./build && cmake -D CMAKE_C_COMPILER=/home/xproject/2k0300/rootfs/buildroot/output/host/bin/loongarch64-linux-gnu-gcc ../
/bin/bash: line 1: cmake: command not found
make[1]: *** [package/pkg-generic.mk:250: /home/xproject/2k0300/rootfs/buildroot/output/build/driver_testcase-origin_master/.stamp_built] Error 127
make: *** [Makefile:84: _all] Error 2


sudo apt  install cmake

host-systemd 247.3 Building
In file included from ../src/basic/arphrd-list.c:12:
src/basic/arphrd-from-name.gperf: In function ‘lookup_arphrd’:
src/basic/arphrd-from-name.gperf:64:16: error: ‘ARPHRD_MCTP’ undeclared (first use in this function); did you mean ‘ARPHRD_FCPP’?
   64 | MCTP, ARPHRD_MCTP
      |                ^~         
      |                ARPHRD_FCPP
src/basic/arphrd-from-name.gperf:64:16: note: each undeclared identifier is reported only once for each function it appears in
In file included from ../src/basic/arphrd-list.c:13:
src/basic/arphrd-to-name.h: In function ‘arphrd_to_name’:
src/basic/arphrd-to-name.h:57:14: error: ‘ARPHRD_MCTP’ undeclared (first use in this function); did you mean ‘ARPHRD_FCPP’?
   57 |         case ARPHRD_MCTP: return "MCTP";
      |              ^~~~~~~~~~~
      |              ARPHRD_FCPP
[39/692] Compiling C object src/basic/libbasic.a.p/audit-util.c.o


https://bugs.gentoo.org/823810

#define ARPHRD_CAN	280		/* Controller Area Network      */
+#define ARPHRD_MCTP	290
#define ARPHRD_PPP	512




/bin/bash: line 1: pigz: command not found
make[1]: *** [fs/ext2/ext2.mk:103: /home/xproject/2k0300/rootfs/buildroot/output/images/rootfs.ext2] Error 127



sudo apt install pigz

参考

更多回帖

发帖
×
20
完善资料,
赚取积分