Anycloud平台基于Ubuntu 22.04搭建编译环境

Anycloud平台基于Ubuntu 22.04搭建编译环境

0. 下载安装 Ubuntu 22.04

  • 官网下载ubuntu22.04镜像(ubuntu-22.04-desktop-amd64.iso)

  • 基于Virtualbox安装系统

  • 进入系统后,打开命令行终端(ALT+CTRL+T), 配置系统更新源:

    选择一个国内的更新源,运行: sudo update-manager
    在这里插入图片描述
    选择更新源后,然后手动进行更新:

    sudo apt-get update
    sudo apt-get upgrade
    

    Note:

    • 由于新版本系统默认不带ifconfig命令,建议先运行安装ifconfig命令工具:
      sudo apt-get install net-tools
    • 为了后续步骤能够安装好相关库,必须要完成上面的步骤,否则可能存在依赖的缺漏.
    • 环境适用于Anycloud37d、Anycloud37e、Anycloud39ev330等.

1. 下载安装常规使用的工具

sudo apt-get install net-tools
sudo apt-get install samba ssh

安装sambe server,用于将SDK传输到Ubuntu中.

samba配置如下(/etc/samba/smb.conf):

[anyka]
    comment = samba home directory
    path = /home/anyka/samba
    public = yes
    browseable = yes
    public = yes
    writeable = yes
    read only = no
#    valid users = anyka
    create mask = 0777
    directory mask = 0777
    #force user = nobody
    #force group = nogroup
    available = yes

/home/anyka/samba目录需要配置为所有用户可读写(chmod 777 /home/anyka/samba).

2. 下载安装相关依赖库、工具

下载SDK需要依赖的库:

sudo apt-get install make 
sudo apt-get install liblzo2-dev liblzo2-2 liblzo2-dev:i386
sudo apt-get install libmpfr-dev libmpfr6 libmpfr6:i386
sudo apt-get install zlib1g-dev lib32z1-dev
sudo apt-get install device-tree-compiler
sudo apt-get install u-boot-tools
sudo apt-get install lib32ncurses5 libncurses5-dev

下载开发过程需要的工具:

sudo apt-get install python
sudo apt-get install autoconf
sudo apt-get install vim exuberant-ctags cscope 
sudo apt-get install git gitk
sudo apt-get install unrar
sudo apt-get install p7zip-full
sudo apt-get install ffmpeg
sudo apt-get install tree
sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install dos2unix
sudo apt-get install cmake

3. 测试环境

本次使用Anyclod37e平台搭建:

  • SDK版本:AK37E_SDK_V1.05
  • 工具链版本:gcc version 4.9.4 (Buildroot 2018.02.7_V1.0.05-gec2d034)

4. 配置工具链

  • 将SDK 中tool目录下面的工具解压到**/opt**目录下:

    sudo tar xjf arm-anykav500-linux-uclibcgnueabi_V1.0.05.tar.bz2 -C /opt/

  • 配置系统环境变量PATH, 打开~/.bashrc ,添加配置:

    export PATH="${PATH}:/opt/arm-anykav500-linux-uclibcgnueabi/bin"

    打开新的终端界面,确认PATH已经添加工具链路径,运行命令:

    anyka@anyka-VirtualBox:~/samba/AK37E_SDK_V1.05$ arm-anykav500-linux-uclibcgnueabi-gcc -v
    Using built-in specs.
    COLLECT_GCC=/opt/arm-anykav500-linux-uclibcgnueabi/bin/arm-anykav500-linux-uclibcgnueabi-gcc.br_real
    COLLECT_LTO_WRAPPER=/opt/arm-anykav500-linux-uclibcgnueabi/bin/../libexec/gcc/arm-anykav500-linux-uclibcgnueabi/4.9.4/lto-wrapper
    Target: arm-anykav500-linux-uclibcgnueabi
    Configured with: ./configure --prefix=/home/leihaitao/nfs/project/buildroot/buildroot.stable/arm-anykav500-linux-uclibcgnueabi --sysconfdir=/home/leihaitao/nfs/project/buildroot/buildroot.stable/arm-anykav500-linux-uclibcgnueabi/etc --enable-static --target=arm-anykav500-linux-uclibcgnueabi --with-sysroot=/home/leihaitao/nfs/project/buildroot/buildroot.stable/arm-anykav500-linux-uclibcgnueabi/arm-anykav500-linux-uclibcgnueabi/sysroot --disable-__cxa_atexit --with-gnu-ld --disable-multilib --with-gmp=/home/leihaitao/nfs/project/buildroot/buildroot.stable/arm-anykav500-linux-uclibcgnueabi --with-mpc=/home/leihaitao/nfs/project/buildroot/buildroot.stable/arm-anykav500-linux-uclibcgnueabi --with-mpfr=/home/leihaitao/nfs/project/buildroot/buildroot.stable/arm-anykav500-linux-uclibcgnueabi --with-pkgversion='Buildroot 2018.02.7_V1.0.05-gec2d034' --with-bugurl=http://bugs.buildroot.net/ --disable-libquadmath --disable-libsanitizer --enable-tls --disable-libmudflap --enable-threads --without-isl --without-cloog --with-float=soft --disable-decimal-float --with-abi=aapcs-linux --with-cpu=arm926ej-s --with-float=soft --with-mode=arm --enable-languages=c,c++ --with-build-time-tools=/home/leihaitao/nfs/project/buildroot/buildroot.stable/arm-anykav500-linux-uclibcgnueabi/arm-anykav500-linux-uclibcgnueabi/bin --enable-shared --disable-libgomp --enable-libssp
    Thread model: posix
    gcc version 4.9.4 (Buildroot 2018.02.7_V1.0.05-gec2d034)
    

能够正常运行arm-anykav500-linux-uclibcgnueabi-gcc -v即可.

5. 解决编译Kernel错译问题

在编译内核时,会出现以下错误:

  • libmpfr链接异常

    anyka@anyka-VirtualBox:~/samba/AK37E_SDK_V1.05/os$ ./build_kernel.sh
    CROSS_COMPILE : arm-anykav500-linux-uclibcgnueabi-
    make[1]: Entering directory '/home/anyka/samba/AK37E_SDK_V1.05/os/bd'
      HOSTCC  scripts/basic/fixdep
      GEN     ./Makefile
      HOSTCC  scripts/kconfig/conf.o
      SHIPPED scripts/kconfig/zconf.tab.c
      SHIPPED scripts/kconfig/zconf.lex.c
      SHIPPED scripts/kconfig/zconf.hash.c
      HOSTCC  scripts/kconfig/zconf.tab.o
      HOSTLD  scripts/kconfig/conf
    #
    # configuration written to .config
    #
    make[1]: Leaving directory '/home/anyka/samba/AK37E_SDK_V1.05/os/bd'
    make[1]: Entering directory '/home/anyka/samba/AK37E_SDK_V1.05/os/bd'
      GEN     ./Makefile
    scripts/kconfig/conf  --silentoldconfig Kconfig
      CHK     include/config/kernel.release
      UPD     include/config/kernel.release
      Using /home/anyka/samba/AK37E_SDK_V1.05/os/kernel as source for kernel
      GEN     ./Makefile
      WRAP    arch/arm/include/generated/asm/bitsperlong.h
      WRAP    arch/arm/include/generated/asm/cputime.h
      WRAP    arch/arm/include/generated/asm/current.h
      WRAP    arch/arm/include/generated/asm/emergency-restart.h
      WRAP    arch/arm/include/generated/asm/errno.h
      WRAP    arch/arm/include/generated/asm/exec.h
      WRAP    arch/arm/include/generated/asm/ioctl.h
      WRAP    arch/arm/include/generated/asm/ipcbuf.h
      WRAP    arch/arm/include/generated/asm/irq_regs.h
      WRAP    arch/arm/include/generated/asm/kdebug.h
      WRAP    arch/arm/include/generated/asm/local.h
      WRAP    arch/arm/include/generated/asm/local64.h
      WRAP    arch/arm/include/generated/asm/mm-arch-hooks.h
      WRAP    arch/arm/include/generated/asm/msgbuf.h
      WRAP    arch/arm/include/generated/asm/msi.h
      WRAP    arch/arm/include/generated/asm/param.h
      WRAP    arch/arm/include/generated/asm/parport.h
      WRAP    arch/arm/include/generated/asm/poll.h
      WRAP    arch/arm/include/generated/asm/preempt.h
      WRAP    arch/arm/include/generated/asm/resource.h
      WRAP    arch/arm/include/generated/asm/rwsem.h
      WRAP    arch/arm/include/generated/asm/seccomp.h
      WRAP    arch/arm/include/generated/asm/sections.h
      WRAP    arch/arm/include/generated/asm/segment.h
      WRAP    arch/arm/include/generated/asm/sembuf.h
      WRAP    arch/arm/include/generated/asm/serial.h
      WRAP    arch/arm/include/generated/asm/shmbuf.h
      WRAP    arch/arm/include/generated/asm/siginfo.h
      WRAP    arch/arm/include/generated/asm/simd.h
      WRAP    arch/arm/include/generated/asm/sizes.h
      WRAP    arch/arm/include/generated/asm/socket.h
      WRAP    arch/arm/include/generated/asm/sockios.h
      WRAP    arch/arm/include/generated/asm/termbits.h
      WRAP    arch/arm/include/generated/asm/termios.h
      WRAP    arch/arm/include/generated/asm/timex.h
      WRAP    arch/arm/include/generated/asm/trace_clock.h
      CHK     include/generated/uapi/linux/version.h
      UPD     include/generated/uapi/linux/version.h
      CHK     include/generated/utsrelease.h
      UPD     include/generated/utsrelease.h
      Generating include/generated/mach-types.h
      CC      kernel/bounds.s
    /opt/arm-anykav500-linux-uclibcgnueabi/bin/../libexec/gcc/arm-anykav500-linux-uclibcgnueabi/4.9.4/cc1: error while loading shared libraries: libmpfr.so.4: cannot open shared object file: No such file or directory
    make[2]: *** [/home/anyka/samba/AK37E_SDK_V1.05/os/kernel/./Kbuild:20: kernel/bounds.s] Error 1
    make[1]: *** [/home/anyka/samba/AK37E_SDK_V1.05/os/kernel/Makefile:1040: prepare0] Error 2
    make[1]: Leaving directory '/home/anyka/samba/AK37E_SDK_V1.05/os/bd'
    make: *** [Makefile:152: sub-make] Error 2
    

    解决方法:

    sudo ln -s /usr/lib/x86_64-linux-gnu/libmpfr.so.6 /usr/lib/x86_64-linux-gnu/libmpfr.so.4

  • yylloc符号错误

    anyka@anyka-VirtualBox:~/samba/AK37E_SDK_V1.05/os$ ./build_kernel.sh
    CROSS_COMPILE : arm-anykav500-linux-uclibcgnueabi-
    make[1]: Entering directory '/home/anyka/samba/AK37E_SDK_V1.05/os/bd'
      GEN     ./Makefile
    #
    # configuration written to .config
    #
    make[1]: Leaving directory '/home/anyka/samba/AK37E_SDK_V1.05/os/bd'
    make[1]: Entering directory '/home/anyka/samba/AK37E_SDK_V1.05/os/bd'
      GEN     ./Makefile
    scripts/kconfig/conf  --silentoldconfig Kconfig
      CHK     include/config/kernel.release
      Using /home/anyka/samba/AK37E_SDK_V1.05/os/kernel as source for kernel
      GEN     ./Makefile
      CHK     include/generated/uapi/linux/version.h
      CHK     include/generated/utsrelease.h
    make[2]: 'include/generated/mach-types.h' is up to date.
      CC      kernel/bounds.s
      CHK     include/generated/bounds.h
      UPD     include/generated/bounds.h
      CHK     include/generated/timeconst.h
      UPD     include/generated/timeconst.h
      CC      arch/arm/kernel/asm-offsets.s
      CHK     include/generated/asm-offsets.h
      UPD     include/generated/asm-offsets.h
      CALL    /home/anyka/samba/AK37E_SDK_V1.05/os/kernel/scripts/checksyscalls.sh
      HOSTCC  scripts/dtc/dtc.o
      HOSTCC  scripts/dtc/flattree.o
      HOSTCC  scripts/dtc/fstree.o
      HOSTCC  scripts/dtc/data.o
      HOSTCC  scripts/dtc/livetree.o
      HOSTCC  scripts/dtc/treesource.o
      HOSTCC  scripts/dtc/srcpos.o
      HOSTCC  scripts/dtc/checks.o
      HOSTCC  scripts/dtc/util.o
      SHIPPED scripts/dtc/dtc-lexer.lex.c
      SHIPPED scripts/dtc/dtc-parser.tab.h
      HOSTCC  scripts/dtc/dtc-lexer.lex.o
      SHIPPED scripts/dtc/dtc-parser.tab.c
      HOSTCC  scripts/dtc/dtc-parser.tab.o
      HOSTLD  scripts/dtc/dtc
    /usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
    collect2: error: ld returned 1 exit status
    make[3]: *** [scripts/Makefile.host:100: scripts/dtc/dtc] Error 1
    make[2]: *** [/home/anyka/samba/AK37E_SDK_V1.05/os/kernel/scripts/Makefile.build:484: scripts/dtc] Error 2
    make[1]: *** [/home/anyka/samba/AK37E_SDK_V1.05/os/kernel/Makefile:558: scripts] Error 2
    make[1]: Leaving directory '/home/anyka/samba/AK37E_SDK_V1.05/os/bd'
    make: *** [Makefile:152: sub-make] Error 2
    

    解决方法(scripts/dtc/dtc-parser.tab.c_shipped):

    ......
    186
    187 extern YYSTYPE yylval;
    188 //extern YYLTYPE yylloc;
    189 int yyparse (void);
    ......
    1193 /* The lookahead symbol.  */
    1194 int yychar;
    1195
    1196 /* The semantic value of the lookahead symbol.  */
    1197 YYSTYPE yylval;
    1198 /* Location data for the lookahead symbol.  */
    1199 static YYLTYPE yylloc
    1200 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
    1201   = { 1, 1, 1, 1 }
    1202 # endif
    1203 ;
    1204 /* Number of syntax errors so far.  */
    1205 int yynerrs;
    1206
    ......
    

    调整yylloc为局部符号.

6. 编译SDK

6.1 编译整个SDK

在顶层目录运行:./auto_build.sh

此脚本默认只支持第一次拿到SDK编译,因为默认会重新解压Kernel、uboot代码.

所以,第一次编译完后,可以修改脚本:

  6 # 检查是否有残留的kernel目录
  7 #if test -d kernel ; then
  8 #       rm -rf kernel
  9 #fi
 10
 11 # 解压缩内核,并进行编译
 12 #tar xvfz linux.tar.gz
 13 ./build_kernel.sh
 14 ./build_kernel.sh -i
 15
 16 # 检查是否存在编译错误
 17 if test $? -ne 0 ; then
 18         echo "Kernel build failed!"
 19     exit
 20 fi
 21
 22 # 检查是否有残留的uboot目录
 23 #if test -d uboot ; then
 24 #       rm -rf uboot
 25 #fi
 26
 27 # 解压缩uboot,并进行编译
 28 #tar xvfz uboot.tar.gz
 29 ./build_uboot.sh
 30 ./build_uboot.sh -i

去掉删除旧目录,重新解压的动作.

6.2 单独编译kernel

跳转到os目录,直接运行脚本:

./build_kernel.sh
./build_kernel.sh -i

6.3 单独编译U-boot

同样在os目录下,运行脚本:

./build_uboot.sh
./build_uboot.sh -i

6.4 编译sample、rootfs

在顶层目录下,运行默认脚本:./make_image.sh

以上步骤完成后,需要手动拷贝相关镜像到烧录目录:cp -rf image/* tools/burntool

7. 烧录固件

7.1 拷贝对应dtb配置到burntool目录

默认需要手动拷贝对应dtb到烧录工具目录下,如使用norflash的rgb核心板(例如Anycloud37E):

cp image/EVB_CBDR_AK3760E_V1.0.1.dtb tools/burntool/cloudOS.dtb

7.2 使用burntool烧录

打开tool/burntool下面的烧录工具,选择对应的nor、芯片类型,然后进行烧录.

  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
搭建 LNMP 环境需要安装 Nginx、MySQL、PHP,以下是在甲骨云 Ubuntu 22.04搭建 LNMP 环境的步骤: 1. 更新系统软件包 ```shell sudo apt update sudo apt upgrade ``` 2. 安装 Nginx ```shell sudo apt install nginx ``` 安装完成后,可以通过以下命令检查 Nginx 是否安装成功: ```shell sudo systemctl status nginx ``` 3. 安装 MySQL ```shell sudo apt install mysql-server ``` 安装完成后,可以通过以下命令检查 MySQL 是否安装成功: ```shell sudo systemctl status mysql ``` 4. 安装 PHP ```shell sudo apt install php-fpm php-mysql ``` 安装完成后,可以通过以下命令检查 PHP 是否安装成功: ```shell sudo systemctl status php-fpm ``` 5. 配置 Nginx 首先备份默认的 Nginx 配置文件: ```shell sudo mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak sudo mv /etc/nginx/sites-enabled/default /etc/nginx/sites-enabled/default.bak ``` 然后创建新的配置文件: ```shell sudo nano /etc/nginx/sites-available/default ``` 复制以下内容到文件中: ``` server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; index index.php index.html index.htm; server_name _; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; } location ~ /\.ht { deny all; } } ``` 保存并关闭文件。 然后创建符号链接: ```shell sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/ ``` 最后重新加载 Nginx: ```shell sudo systemctl reload nginx ``` 6. 测试 创建一个 PHP 文件用于测试: ```shell sudo nano /var/www/html/info.php ``` 复制以下内容到文件中: ```php <?php phpinfo(); ?> ``` 保存并关闭文件。 然后在浏览器中访问 `http://your-server-ip/info.php`,如果能够看到 PHP 信息页面,说明 LNMP 环境已经搭建成功了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值