linux环境下nuttx docker开发环境搭建(不限具体linux发行版本)
作者:互联网
1准备一个linux环境
物理机器或虚拟机中安装linux系统都行
2安装docker
这个可以搜索教程自己装
3构建Dockerfile
1 准备dockerfile文件
新建文件命名为nuttx_Dockerfile,将如下内容拷贝到nuttx_Dockerfile中
镜像中下载了编译开发nuttx的环境
# Ubuntu Dockerfile
#
FROM ubuntu:20.04
LABEL maintainer="pleasecallmekaige<2964073182@qq.com>"
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
ADD sources.list /etc/apt/sources.list
RUN apt update | echo 'ignore' \
&& apt -y install apt-transport-https ca-certificates \
&& apt update \
&& apt -y install \
bison flex gettext texinfo libncurses5-dev libncursesw5-dev \
gperf automake libtool pkg-config build-essential gperf genromfs \
libgmp-dev libmpc-dev libmpfr-dev libisl-dev binutils-dev libelf-dev \
libexpat-dev gcc-multilib g++-multilib picocom u-boot-tools util-linux \
&& apt -y install kconfig-frontends \
&& apt -y install gcc-arm-none-eabi binutils-arm-none-eabi \
&& apt -y install vim \
&& apt -y install python3 python3-pip \
&& pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com compiledb
2 准备一个source.list文件
为了将默认的源改为国内源
准备一个source.list文件内容如下,和nuttx_Dockerfile放在同一个目录下
# deb cdrom:[Ubuntu 20.04.2.0 LTS _Focal Fossa_ - Release amd64 (20210209.1)]/ focal main restricted
deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ focal-updates main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://cn.archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal universe
deb http://cn.archive.ubuntu.com/ubuntu/ focal-updates universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://cn.archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ focal-updates multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://cn.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner
deb http://security.ubuntu.com/ubuntu focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://security.ubuntu.com/ubuntu focal-security universe
# deb-src http://security.ubuntu.com/ubuntu focal-security universe
deb http://security.ubuntu.com/ubuntu focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu focal-security multiverse
4 构建镜像
在当前目录下运行如下命令:
构建一个名为nuttx_dev:base的镜像,这个可能耗时会很久
docker build -f nuttx_Dockerfile -t nuttx_dev:base .
5 运行开发环境
1第一次运行时
第一次运行时需要创建容器,运行如下内容:
docker run -it --privileged \
-v /home/xmk/work/nuttx:/home/xmk/work/nuttx:rw \
-v /tmp/.X11-unix:/tmp/.X11-unix:ro \
-e DISPLAY=${DISPLAY} \
--name=nuttx_dev nuttx_dev:base /bin/bash
划重点:
-v /home/xmk/work/nuttx:/home/xmk/work/nuttx:rw \ #这一句是为了将本地的路径挂载到docker中,这里挂的是nuttx代码存放的位置
2后续每次运行
创建完成后,后面每次就只要打开工作容器
docker start nuttx_dev && docker attach nuttx_dev
6 说明
现在可以用容器中安装的环境编译nuttx啦,和本地环境无关。
由于本地的路径被挂载到容器中,可以用容器里的环境编译本地代码
标签:http,cn,linux,nuttx,ubuntu,docker,com,deb,focal 来源: https://www.cnblogs.com/xumingkai/p/16052872.html