【小熊派nano鸿蒙OS开发板】开发环境配置的踩坑

本来想采用树莓派进行,发现不行

配置Linux编译开发环境

修改bash

pi@raspberrypi:/bin $ mv sh sh.bak
mv: cannot move 'sh' to 'sh.bak': Permission denied
pi@raspberrypi:/bin $ sudo mv sh sh.bak
pi@raspberrypi:/bin $ sudo ln -s /bin/bash /bin/sh
pi@raspberrypi:/bin $ ls
bash          chgrp          dumpkeys    hciconfig   login        mv              ntfsfix       ps         ss                              tar              zcmp
bunzip2       chmod          echo        hostname    loginctl     nano            ntfsinfo      pwd        stty                            tempfile         zdiff
busybox       chown          ed          ip          lowntfs-3g   nc              ntfsls        rbash      su                              touch            zegrep
bzcat         chvt           egrep       journalctl  ls           nc.openbsd      ntfsmove      readlink   sync                            true             zfgrep
bzcmp         con2fbmap      false       kbd_mode    lsblk        nc.traditional  ntfsrecover   red        systemctl                       udevadm          zforce
bzdiff        cp             fbset       keyctl      lsmod        netcat          ntfssecaudit  rm         systemd                         ulockmgr_server  zgrep
bzegrep       cpio           fgconsole   kill        mkdir        netstat         ntfstruncate  rmdir      systemd-ask-password            umount           zless
bzexe         dash           fgrep       kmod        mknod        networkctl      ntfsusermap   rnano      systemd-escape                  uname            zmore
bzfgrep       date           findmnt     less        mktemp       nisdomainname   ntfswipe      run-parts  systemd-hwdb                    uncompress       znew
bzgrep        dd             fuser       lessecho    modeline2fb  ntfs-3g         openvt        sed        systemd-inhibit                 unicode_start
bzip2         df             fusermount  lessfile    more         ntfs-3g.probe   pidof         setfont    systemd-machine-id-setup        vdir
bzip2recover  dir            grep        lesskey     mount        ntfscat         ping          setupcon   systemd-notify                  wdctl
bzless        dmesg          gunzip      lesspipe    mountpoint   ntfscluster     ping4         sh         systemd-sysusers                which
bzmore        dnsdomainname  gzexe       ln          mt           ntfscmp         ping6         sh.bak     systemd-tmpfiles                ypdomainname
cat           domainname     gzip        loadkeys    mt-gnu       ntfsfallocate   plymouth      sleep      systemd-tty-ask-password-agent  zcat
pi@raspberrypi:/bin $ ls -l sh
lrwxrwxrwx 1 root root 9 Dec 22 08:51 sh -> /bin/bash

安装Python环境

pi@raspberrypi:/ $ sudo pip3 install pycryptodome
pi@raspberrypi:/ $ sudo pip3 install kconfiglib
pi@raspberrypi:/ $ sudo pip3 install six --upgrade --ignore-installed six
pi@raspberrypi:/ $ sudo pip3 install ecdsa

将Python3作为默认版本

pi@raspberrypi:/usr/bin $ sudo mv python python.bak
pi@raspberrypi:/usr/bin $ sudo ln -s python3.7
python3.7          python3.7-config   python3.7m         python3.7m-config  
pi@raspberrypi:/usr/bin $ sudo ln -s python3.7 /usr/bin/python
pi@raspberrypi:/usr/bin $ ls -l python
lrwxrwxrwx 1 root root 9 Dec 23 08:31 python -> python3.7
pi@raspberrypi:/usr/bin $ python -V
Python 3.7.3

安装SCons环境

pi@raspberrypi:/usr/bin $ sudo apt-get install scons -y
pi@raspberrypi:/usr/bin $ scons -v

更改为3.0.4版本
https://scons.org/pages/download.html

pi@raspberrypi:/opt/scons/SCons-4.0.1 $ sudo tar -xvf scons-4.0.1.tar.gz
pi@raspberrypi:/opt/scons/SCons-4.0.1 $ cd SCons-4.0.1/
pi@raspberrypi:/opt/scons/SCons-4.0.1 $ sudo python3 setup.py install
pi@raspberrypi:/opt/scons/SCons-4.0.1 $ scons -v
SCons by Steven Knight et al.:
    SCons: v4.0.1.

安装编译工具

gn工具——产生ninja编译脚本

pi@raspberrypi:~ $ sudo tar xvf ./gn.1523.tar -C ~/

ninja工具——执行ninja编译脚本

pi@raspberrypi:~ $ sudo tar xvf ./ninja.1.9.0.tar -C ~/

交叉编译器gcc_riscv32

pi@raspberrypi:~ $ sudo tar xvf gcc_riscv32-linux-7.3.0.tar.gz -C ~/

配置环境变量

pi@raspberrypi:~ $ vim ~/.bashrc
export PATH=~/gn:$PATH
export PATH=~/ninja:$PATH
export PATH=~/gcc_riscv32/bin:$PATH

生效配置:

pi@raspberrypi:~ $ source ~/.bashrc 
pi@raspberrypi:~ $ riscv32-unknown-elf-gcc -v
-bash: /home/pi/gcc_riscv32/bin/riscv32-unknown-elf-gcc: cannot execute binary file: Exec format error

由于树莓派不是X86架构,而是ARM架构,目前gcc_riscv32不支持。。。。
改为X86服务器即可:

(bearpi) 15:53 luohb@Studynode:~/tools 
$ riscv32-unknown-elf-gcc -v
Using built-in specs.
COLLECT_GCC=riscv32-unknown-elf-gcc
COLLECT_LTO_WRAPPER=/home/luohb/gcc_riscv32/bin/../libexec/gcc/riscv32-unknown-elf/7.3.0/lto-wrapper
Target: riscv32-unknown-elf
Configured with: ../riscv-gcc/configure --prefix=/data/d00434757/tools/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=/data/d00434757/tools/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
Thread model: single
gcc version 7.3.0 (GCC) 

获取鸿蒙系统源码并烧录到小熊派nano

参考

  1. https://gitee.com/bearpi/bearpi-hm_nano/blob/master/applications/BearPi/BearPi-HM_Nano/docs/quick-start/%E6%BA%90%E7%A0%81%E8%8E%B7%E5%8F%96.md
  2. https://gitee.com/bearpi/bearpi-hm_nano/blob/master/applications/BearPi/BearPi-HM_Nano/docs/quick-start/BearPi-HM_Nano%E5%BC%80%E5%8F%91%E6%9D%BF%E5%A6%82%E4%BD%95%E7%83%A7%E5%BD%95%E7%A8%8B%E5%BA%8F.md

你可能感兴趣的:(【小熊派nano鸿蒙OS开发板】开发环境配置的踩坑)