打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
PX4固件v1.9.2在ubuntu linux下的开发环境搭建​

1系统环境搭建

1.1系统环境需求

操作系统: ubuntu server 16.04

虚拟机工具:VirtualBox

文件共享服务:在UbuntuSAMBA文件服务,将Linux目录共享给windows

远程终端连接:在Windows端使用工具SSH Secure Shell连接Ubuntu进行终端命令操作(主要是为了方便复制粘贴文本内容)

1.2安装和配置过程

1.2.1 初始安装选项

1.2.1.1硬件配置

安装选项:4G Bytes 内存、40G Bytes硬盘、硬盘空间自动分配和使用VBX格式硬盘,其他默认。

安装位置:选择安装在有较大空闲存储空间的分区上。

1.2.1.2配置系统安装启动盘

virtualbox

设置--->存储--->控制器:IDE---->点击“没有盘片--->点击“分配光驱”右侧光盘按钮并设置Linux系统ISO文件路径--->点击“OK”按钮--->最后点击“启动”按钮

1.2.2 安装配置

安装语言:English(US)

安装内容:Install Ubuntu Server

1.2.2.1 自动更新

选中无自动更新

1.2.2.2 软件选项

选中SAMBA file server

选中Standard system tools(默认选中)

选中OpenSSH server

选择安装grub

1.2.3 网络设置

配置ubuntu为双网卡,网卡1用于访问windows主机internet,网卡2用于将文件共享给windows

1.2.3.1 Virtualbox网络设置

ubuntu系统终端里敲入命令“shutdown now关闭ubuntu系统,然后按如下方法设置virtualbox网络:

设置--->网络--->网卡1--->选中“启用网络连接”且连接方式--->选择“网络地址转换(NAT

设置--->网络--->网卡2--->选中“启用网络连接”且连接方式--->选择“仅主机(Host Only)网络

设置完后,启动ubuntu系统

解释:“仅主机(Host Only)网络”网络模式使得Windows主机增加一个虚拟网卡,该网卡的IP地址和ubuntuIP地址同在一个网段,从而可实现共享,但如果只有这种模式虚拟机的系统是无法访问internet

1.2.3.2 Ubuntu网络设置

1.2.3.2.1 查看网卡状态

$ ls /sys/class/net/

enp0s3  enp0s8  lo

1.2.3.2.2 编辑网卡配置,增加网卡enp0s8(绿色字体部分为新增内容)

$ sudo vim /etc/network/interfaces 

# This file describes the network interfaces available on your system

# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

auto enp0s3

iface enp0s3 inet dhcp

auto enp0s8

iface enp0s8 inet dhcp

注:启动vim后,按“insert”按键进入插入状态,退出插入状态时按“esc”按键,然后敲如“:wq”保存文件并退出vi

1.2.3.2.3 重启网络

$ /etc/init.d/networking restart

[ok] Restarting networking (via systectl):networking.service.

1.2.3.2.4 检查网络状态

$ ifconfig

enp0s3    Link encap:Ethernet  HWaddr 08:00:27:5b:6d:a4  

          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0

          inet6 addr: fe80::a00:27ff:fe5b:6da4/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:450 errors:0 dropped:0 overruns:0 frame:0

          TX packets:230 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:525616 (525.6 KB)  TX bytes:20003 (20.0 KB)

enp0s8    Link encap:Ethernet  HWaddr 08:00:27:cb:91:9b  

          inet addr:192.168.56.102  Bcast:192.168.56.255  Mask:255.255.255.0

          inet6 addr: fe80::a00:27ff:fecb:919b/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:323 errors:0 dropped:0 overruns:0 frame:0

          TX packets:208 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:50576 (50.5 KB)  TX bytes:32637 (32.6 KB)

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:65536  Metric:1

          RX packets:164 errors:0 dropped:0 overruns:0 frame:0

          TX packets:164 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1

          RX bytes:12080 (12.0 KB)  TX bytes:12080 (12.0 KB)

1.2.4 远程终端访问设置

Windows下启动SSH Secure Shell,点击“Quick Connect”按钮,填入

Host Name:192.168.56.102

User Name:ryan_huang

Port:22

Authentication:<Profile Settings>

然后点击Connect”按钮,当远程终端连接上之后,我们就可以在Windows界面下连接和操作linux服务器了

如果连接不上,请检查ubuntu server系统是否启动了SSH服务。

1.3 FAQ

1.3.1 问题1:SSH连接报错

https://blog.csdn.net/heroybc/article/details/78562954

ssh连接报错server respondedalgorithm negotiation failed

解决方法:

修改ssh的配置文件 /etc/ssh/sshd_config

$vim /etc/ssh/sshd_config

1

2

在配置文件尾部添加如下蓝色字的内容:

Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc

MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96

KexAlgorithms diffie-hellman-group1-sha1, diffie-hellman-group14-sha1, diffie-hellman-group-exchange-sha1, diffie-hellman-group-exchange-sha256, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group1-sha1, curve25519-sha256@libssh.org

重启sshd服务后(sudo service ssh restart),即可正常连接:

$sudo /etc/init.d/ssh restart

1.3.2 问题2:没有安装openssl

执行命令git clone https://github.com/PX4/Firmware.git -b v1.9.2

出现如下失败失败提示:

fatal: unable to access ‘https://github.com/PX4/Firmware.git/’ : guntls_handshack() failed: The TLS connection was non-properly terminated.

原因:git的版本是gnutls 而不是openssl版本导致。

http://blog.chinaunix.net/uid-26824563-id-5784518.html

1.3.3 问题3 ubuntu linux在vritualbox中如何共享windows系统剪切板?

答:在ubuntu的运行页面下点击virtualbox的“控制-->设置”进入系统设置界面,然后再“常规--->高级”属性页下,点击“共享粘贴板”设置成“双向”即可。

https://blog.csdn.net/sg656720274/article/details/53100266

1.4 SAMBA服务配置

Samba服务是linux提供给其他操作系统来访问linux目录和文件的一种服务,windows可以通过samba服务访问linux文件系统。

1.4.1 创建共享目录并修改权限

ryan_huang@ubuntu:~$ mkdir ryan_share

ryan_huang@ubuntu:~$ chmod 777 ryan_share

说明:执行完上述两条命令后,共享目录的完整路径为/home/ryan_huang/ryan_share/

1.4.2 检查是否已安装Samba

ryan_huang@ubuntu:~$ sudo smbd --version

[sudo] password for ryan_huang:

Version 4.3.11-Ubuntu

ryan_huang@ubuntu:~$ systemctl status smbd

?smbd.service - LSB: start Samba SMB/CIFS daemon (smbd)

   Loaded: loaded (/etc/init.d/smbd; bad; vendor preset: enabled)

   Active: active (running) since Tue 2019-10-15 10:59:07 CST; 32min ago

     Docs: man:systemd-sysv-generator(8)

  Process: 1505 ExecReload=/etc/init.d/smbd reload (code=exited, status=0/SUCCESS)

  Process: 906 ExecStart=/etc/init.d/smbd start (code=exited, status=0/SUCCESS)

    Tasks: 3

   Memory: 37.6M

      CPU: 626ms

   CGroup: /system.slice/smbd.service

            954 /usr/sbin/smbd -D

            975 /usr/sbin/smbd -D

           1081 /usr/sbin/smbd -D

这说明已经安装了Samba服务程序

1.4.3 安装Samba

(未安装时执行安装命令)

安装命令:

$sudo apt-get install samba samba-common

卸载命令:

$sudo apt-get autoremove samba

1.4.4 检查Samba服务运行状态

以下两条命令检查Samba服务的运行状态:

ryan_huang@ubuntu:~$ systemctl status smbd

?smbd.service - LSB: start Samba SMB/CIFS daemon (smbd)

   Loaded: loaded (/etc/init.d/smbd; bad; vendor preset: enabled)

   Active: active (running) since Tue 2019-10-15 10:59:07 CST; 1h 55min ago

     Docs: man:systemd-sysv-generator(8)

  Process: 1948 ExecReload=/etc/init.d/smbd reload (code=exited, status=0/SUCCESS)

  Process: 906 ExecStart=/etc/init.d/smbd start (code=exited, status=0/SUCCESS)

    Tasks: 3

   Memory: 37.6M

      CPU: 764ms

   CGroup: /system.slice/smbd.service

            954 /usr/sbin/smbd -D

            975 /usr/sbin/smbd -D

           1081 /usr/sbin/smbd -D

Oct 15 12:35:11 ubuntu smbd[1863]:    ...done.

Oct 15 12:35:11 ubuntu systemd[1]: Reloaded LSB: start Samba SMB/CIFS daemon (smbd).

Oct 15 12:45:02 ubuntu systemd[1]: Reloading LSB: start Samba SMB/CIFS daemon (smbd).

Oct 15 12:45:02 ubuntu smbd[1907]:  * Reloading /etc/samba/smb.conf smbd

Oct 15 12:45:02 ubuntu smbd[1907]:    ...done.

Oct 15 12:45:02 ubuntu systemd[1]: Reloaded LSB: start Samba SMB/CIFS daemon (smbd).

Oct 15 12:52:59 ubuntu systemd[1]: Reloading LSB: start Samba SMB/CIFS daemon (smbd).

Oct 15 12:52:59 ubuntu smbd[1948]:  * Reloading /etc/samba/smb.conf smbd

Oct 15 12:52:59 ubuntu smbd[1948]:    ...done.

Oct 15 12:52:59 ubuntu systemd[1]: Reloaded LSB: start Samba SMB/CIFS daemon (smbd).

ryan_huang@ubuntu:~$ systemctl status nmbd

?nmbd.service - LSB: start Samba NetBIOS nameserver (nmbd)

   Loaded: loaded (/etc/init.d/nmbd; bad; vendor preset: enabled)

   Active: active (running) since Tue 2019-10-15 10:59:08 CST; 1h 55min ago

     Docs: man:systemd-sysv-generator(8)

  Process: 1107 ExecStart=/etc/init.d/nmbd start (code=exited, status=0/SUCCESS)

    Tasks: 1

   Memory: 2.0M

      CPU: 286ms

   CGroup: /system.slice/nmbd.service

           1181 /usr/sbin/nmbd -D

Oct 15 10:59:08 ubuntu systemd[1]: Starting LSB: start Samba NetBIOS nameserver (nmbd)...

Oct 15 10:59:08 ubuntu nmbd[1107]:  * Starting NetBIOS name server nmbd

Oct 15 10:59:08 ubuntu nmbd[1107]:    ...done.

Oct 15 10:59:08 ubuntu systemd[1]: Started LSB: start Samba NetBIOS nameserver (nmbd).

ryan_huang@ubuntu:~$

1.4.5 为Samba服务添加用户

ryan_huang@ubuntu:~$ sudo smbpasswd -a ryan_huang

[sudo] password for ryan_huang: (输入访问Samba的密码)

New SMB password:(输入访问Samba的密码)

Retype new SMB password:(输入访问Samba的密码)

Added user ryan_huang.

ryan_huang@ubuntu:~$

1.4.6 修改Samba服务配置

注意:vim命令只能在ubuntu服务器上直接执行,不能通过SSH Secure Shell执行,只能猜测可能是哪个配置权限没放开没法修改文件权限。

ryan_huang@ubuntu:~$ sudo vim /etc/samba/smb.conf

启动vim后,按“insert”按键进入插入状态,退出插入状态时按“esc”按键,然后敲如“:wq”保存文件并退出vi

[myshare ]

comment=This is samba dir   #说明

path=/home/ryan_huang/ryan_share  #共享目录在Linux中的位置

create mask=0755    #创建新文件权限为可读写执行

directory mask=0755   #目录权限为可读写执行

writeable=yes

valid users=ryan_huang   #登陆的用户名

browseable=yes

1.4.7 启动、停止、重启Samba服务

启动Samba服务器只需执行如下命令:

$sudo /etc/init.d/samba start

注意:ubuntu server如果执行了“shutdown”命令或者“reboot”命令重启系统后,需要重新执行samba启动服务命令。

关闭Samba服务器:

$sudo /etc/init.d/samba stop

重启Samba服务

$sudo /etc/init.d/smbd restart  

或者  

$sudo service smbd restart 

1.4.8 访问共享服务

windows的文件目录下,输入“\\192.168.56.101\myshare”,然后按“Enter”按键,接着输入用户名“ryan_huang”和输入密码即可访问共享目录。

1.5 Samba服务设置参考网文

https://blog.csdn.net/u012478275/article/details/78876181

https://www.linuxidc.com/Linux/2017-11/148194.htm

2 PX4开发编译环境的搭建

2.1 Git安装

$ sudo apt install git

2.2 cmake安装

$ sudo apt install cmake

2.2.1 cmake安装失败的现象

ryan_huang@ubuntu:~$ sudo apt install cmake

[sudo] password for ryan_huang:

Reading package lists... Done

Building dependency tree       

Reading state information... Done

Package cmake 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 'cmake' has no installation candidate

ryan_huang@ubuntu:~$

2.2.2 问题解决办法

这个问题的原因是ubuntu/etc/apt/source.list中的源比较旧了,需要更新一下,更新方法:

$ sudo apt-get -y update

更新完毕之后,再使用apt-get就没有问题了。

2.3 交叉编译工具安装

2.3.1 安装新版本的编译工具(推荐)

$sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa

$sudo apt-get update

$sudo apt-get install gcc-arm-embedded

参考文章:

https://www.cnblogs.com/kinging/p/5877885.html

说明:这里系统为ubuntu server 16.04 64bits也可以成功升级,并非只有“Ubuntu 10.04/12.04/14.04/14.10 32 and 64 bit”才能成功。

升级成功后通过如下命令可以看到编译器版本信息:

$ arm-none-eabi-gcc --version

arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2018-q3-update) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907]

Copyright (C) 2017 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

2.3.2 安装旧版本的编译工具(不推荐)

$ sudo apt-get install gcc-arm-none-eabi

编译工具有600多兆,下载时间较长。

2.4 升级到新版本的编译工具(可选)

如果不慎安装了旧版本的编译工具,则执行如下删除旧编译工具,然后执行2.3.1的三条命令即可:

$sudo apt-get remove gcc-arm-none-eabi gdb-arm-none-eabi binutils-arm-none-eabi gcc-arm-embedded

参考文章:

https://blog.csdn.net/x_kh_2001/article/details/81127695

2.5 安装patch

$ sudo apt-get install patch

2.6 安装genromfs

$ sudo apt-get install genromfs

2.7 安装python-jinja2 

$ sudo apt-get install python-jinja2

2.8 安装Python-empy 

$ sudo apt-get install python-empy

2.9 安装Python-pip

$ sudo apt-get -y install python-pip

2.10 安装numpy

$ sudo pip install numpy

2.11 安装toml

$ sudo pip install toml

2.12 安装pyyaml

$ sudo pip install pyyaml

V1.9.2新增工具。

2.13 固件下载:

$ mkdir px4_src_v1.9.2

$ cd px4_src_v1.9.2/

$ git clone https://github.com/PX4/Firmware.git -b v1.9.2

2.14 子模块更新

$cd Firmware

$git submodule update --init --recursive

2.15 编译

$ make px4fmu-v4_default

主机

系统(64 bits

固件版本

虚拟机设置的CPU核心数

执行make clean

编译用时

系统启动后首次运行

1

Ubuntu destop 16.04

1.9.2

1

242

1

Ubuntu server 16.04

1.9.2

4

130

1

Ubuntu server 16.04

1.9.2

4

109

2

Ubuntu server 16.04

1.7.2

4

347

2

Windows 7

1.7.2

4

超过13分钟

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
SAMBA 在ubuntu和centos下的启动命令
VirtualBox安装部署Ubuntu 16.04 图文详解
windows访问linux共享文件夹
如何解决ubuntu16.04安装samba的依赖问题
在Ubuntu 12.04安装和设置Samba实现网上邻居共享
ubuntu 12.04 LTS安装samba实现与windows共享文件
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服