喜欢4次
本文用于从零搭建Linux开发平台,针对不想使用Nuclei Studio IDE的用户
起因:本人用IDE感觉好不方便,所以配置了相关的Linux环境,Linx配置环境文档看得有点乱,索性整理了一下。
环境是zsh,用bash的可以稍微改一下。主要下载了nuclei-sdk、openocd、gcc,脚本(文章尾)运行后,可以通过以下三种命令进行验证环境是否正确,编译正确即可。
cd ~/Nuclei/application/baremetal/helloworld
make SOC=gd32vf103 BOARD=gd32vf103v_rvstar clean
make SOC=gd32vf103 BOARD=gd32vf103v_rvstar
依赖有:
sudo apt-get install git
sudo apt-get install wget#!/usr/bin/env zsh
#please check your environment
#https://www.nucleisys.com/download.php
OPEN_OCD=https://www.nucleisys.com/upload/files/toochain/openocd/nuclei-openocd-0.10.0-15-linux-x64.tgz
GCC=https://www.nucleisys.com/upload/files/toochain/gcc/nuclei_riscv_newlibc_prebuilt_linux64_2020.08.tar.bz2
NUCLEI_SDK=https://gitee.com/Nuclei-Software/nuclei-sdk.git
cd ~
#rm -rf Nuclei
echo 'nuclei_sdk downloading...'
git clone $NUCLEI_SDK Nuclei
echo 'nuclei_sdk has been downloaded'
cd Nuclei
mkdir toolschain
cd toolschain
echo 'openocd downloading...'
wget -O "openocd.tgz" $OPEN_OCD
echo 'openocd has been downloaded'
echo 'gcc downloading...'
wget -O "gcc.tar.bz2" $GCC
echo 'gcc has been downloaded'
tar zxvf openocd.tgz
tar jxvf gcc.tar.bz2
rm -rf openocd.tgz
rm -rf gcc.tar.bz2
PATH_TO_OPENOCD=./Nuclei/openocd/
OPENOCDDIR=`ls $PATH_TO_OPENOCD`
PATH_TO_OPENOCD=$PATH_TO_OPENOCD$OPENOCDDIR/
mv -f $PATH_TO_OPENOCD ./openocd
rm -rf ./Nuclei/
cd ..
touch setup_config.sh
echo 'set NUCLEI_TOOL_ROOT=~/Nuclei/toolschain' > setup_config.sh
echo 'source ~/Nuclei/setup.sh' >> ~/.zshrc
source ~/.zshrc
echo 'Done!'
最后注意一点,如执行上述脚本在每次source .zshrc时,均会重新导入,所以可以
1.将相关环境变量直接添加其中,并删除setup.sh
2.或者删除.zshrc中的source ~/Nuclei/setup.sh
并在每次执行make操作前执行source setup.sh
若上板时显示“monitor" command not supported by this target.则按下图操作,操作结束后,请务必拔掉板子的usb线,重新插入。