1.先从官方上获取ubuntu core的tar包:
$ wget http://cdimage.ubuntu.com/ubuntu-base/releases/14.04/release/ubuntu-base-14.04-core-armhf.tar.gz
2.下载完后,解压到rootfs/ubuntu目录:
$ mkdir ubuntu
$ sudo tar -xpf ubuntu-base-14.04-core-armhf.tar.gz -C ubuntu
3.在PC上模拟运行根文件系统,需要安装一个工具:
$ sudo apt-get install qemu-user-staticcd
在切换到此根文件系统前,要对根文件系统做一些配置修改
$ cd ubuntu
$ sudo cp /usr/bin/qemu-arm-static usr/bin/
拷贝PC主机端的dns配置,因为待会安装程序时要用网络:
$ sudo cp -b /etc/resolv.conf etc/resolv.conf
增加软件源:
$ sudo vim etc/apt/source.list.d/trusty_source.list
加入如下内容,保存后退出:
deb http://mirrors.mit.edu/ubuntu-ports/ trusty main restricted universe multiverse
deb http://mirrors.mit.edu/ubuntu-ports/ trusty-updates main restricted universe multiverse
deb http://mirrors.mit.edu/ubuntu-ports/ trusty-security main restricted universe multiverse
deb http://mirrors.mit.edu/ubuntu-ports/ trusty-backports main restricted universe multiverse
deb http://mirror.csclub.uwaterloo.ca/ubuntu-ports/ trusty main restricted universe multiverse
deb http://mirror.csclub.uwaterloo.ca/ubuntu-ports/ trusty-updates main restricted universe multiverse
deb http://mirror.csclub.uwaterloo.ca/ubuntu-ports/ trusty-security main restricted universe multiverse
deb http://mirror.csclub.uwaterloo.ca/ubuntu-ports/ trusty-backports main restricted universe multiverse
配置串口调试服务:
$ sudo cp etc/init/tty1.conf etc/init/ttyS2.conf
$ sudo vi etc/init/ttyS2.conf
修改 sudo vi etc/rc.local 加上start ttyS2
4.上电后等待时间长的问题解决办法:
修改延时
编辑etc/init/failsafe.conf文件
将第一个sleep从20秒改成5秒
# The point here is to wait for 2 minutes before forcibly booting
# the system. Anything that is in an "or" condition with 'started
# failsafe' in rc-sysinit deserves consideration for mentioning in
# these messages. currently only static-network-up counts for that.
sleep 5
把下面的语句都注释掉
#$PLYMOUTH message --text="Waiting for network configuration..." || :
#sleep 40
#$PLYMOUTH message --text="Waiting up to 60 more seconds for network con
figuration..." || :
#sleep 59
修改文件系统主机的名字
$ vim /ect/hostname 添加主机的名字
$ vim /ect/hosts 修改成127.0.0.1 localhost \n 127.0.0.1 firefly
6.经过上述步骤,已经对ubuntu根文件系统做了简单的配置,现在可以用工具切换到此根文件系统了。
为了简化操作过程,这里使用一个切换根文件系统的脚本,拷贝到rootfs目录,并增加可执行权限。用脚本挂载切换到指定的根文件系统,命令为:
$ cd rootfs/
$ chmod +x ch-mount.sh
$ ./ch-mount.sh -m ubuntu/
ch-mount.sh的具体内容为:
#!/bin/bash
function mnt() {
echo "MOUNTING"
sudo mount -t proc /proc ${2}proc
sudo mount -t sysfs /sys ${2}sys
sudo mount -o bind /dev ${2}dev
sudo mount -o bind /dev/pts ${2}dev/pts
sudo chroot ${2}
}
function umnt() {
echo "UNMOUNTING"
sudo umount ${2}proc
sudo umount ${2}sys
sudo umount ${2}dev/pts
sudo umount ${2}dev
}
if [ "$1" == "-m" ] && [ -n "$2" ] ;
then
mnt $1 $2
elif [ "$1" == "-u" ] && [ -n "$2" ];
then
umnt $1 $2
else
echo ""
echo "Either 1'st, 2'nd or both parameters were missing"
echo ""
echo "1'st parameter can be one of these: -m(mount) OR -u(umount)"
echo "2'nd parameter is the full path of rootfs directory(with trailing '/')"
echo ""
echo "For example: ch-mount -m /media/sdcard/"
echo ""
echo 1st parameter : ${1}
echo 2nd parameter : ${2}
fi
7.可以看到执行后,终端显示的用户名发生了变化,用ls可以看到文件系统也有变化,此终端里的根文件系统已经切换到binary目录里的根文件系统。可以在终端里做安装程序等操作了,就像进入了一个新系统,所以我也叫作是模拟运行根文件系统。
$ apt-get update
$ apt-get install language-pack-zh-hans
$ apt-get install net-tools
$ apt-get install vim git openssh-server
安装界面
#apt-get install ubuntu-session xubuntu-desktop
选择启动的桌面
#update-alternatives --config x-session-manager
配置默认登录界面
#dpkg-reconfigure lightdm
配置网络:
#echo auto eth0 > etc/network/interfaces.d/eth0
#echo iface eth0 inet dhcp >> etc/network/interfaces.d/eth0
#echo auto wlan0 > etc/network/interfaces.d/wlan0
#echo allow-hotplug wlan0 > etc/network/interfaces.d/wlan0
#echo iface wlan0 inet dhcp >> etc/network/interfaces.d/wlan0
wifi必要的包:
方法一:
$ apt-get install wireless-tools wpasupplicant
方法二:
$ apt-get install network-manager systemd
添加一个用户ubuntu,并设置密码:
$useradd -s '/bin/bash' -m -G adm,sudo ubuntu
修改ubuntu用户密码,回车后按提示输入两次密码:
$passwd ubuntu
修改root帐号的密码,回车后按提示输入两次密码:
$passwd root
Ros系统配置:
安装 ROS Indigo
# 设置sources.list(软件源)
$ sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
或
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
# 设置密钥
$ wget http://packages.ros.org/ros.key -O - | apt-key add -
#安装更新
$ apt-get update
$ apt-get install ros-indigo-desktop-full 桌面完整版
$ apt-get install ros-indigo-desktop 桌面版
$ apt-get install ros-indigo-ros-base 基础版
初始化rosdep
$ rosdep init
$ rosdep update
环境设置
$ echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc
$ source ~/.bashrc
安装rosinstall
rosinstall是ROS的一个命令行工具,用于下载ROS软件包
$ apt-get install python-rosinstall
文件系统安装结束:
$ exit
$ ./ch-mount.sh -u ubuntu/
8.制作镜像
$ dd if=/dev/zero of=ubuntu.img bs=1M count=4096
格式化镜像,并加入linuxroot卷标:
$ sudo mkfs.ext4 -F -L linuxroot ubuntu.img
挂载镜像并往里面拷入修改后的文件系统:
$ mkdir ubuntu-mount
$ sudo mount ubuntu.img ubuntu-mount
$ sudo cp -rfp ubuntu/* ubuntu-mount
卸载镜像:
$ sudo umount ubuntu-mount
这样ubuntu.img里就已经有刚才制作的根目录内容了,但ubuntu.img文件大小却是定义的分区大小,不是文件系统的实际大小,所以还要经过一些处理才能发布。
检查并修复ubuntu.img镜像的文件系统,不熟悉的朋友可以通过网络了解此工具:
$ e2fsck -p -f ubuntu.img
减小ubuntu.img镜像文件的大小:mkfs.e
$ resize2fs -M ubuntu.img
执行上面两命令后,ubuntu.img瘦身不少,可以用来烧录了。
9.上电后,扩容指令:
$ df -h
$ sudo resize2fs /dev/mmcblk0p5
$ sudo reboot
10.Wifi配置
方法一:关掉有线网卡的操作:
终端下的命令:
$ sudo ifconfig wlan0 down
重启有线网卡的操作:
终端下的命令:
$ sudo ifconfig wlan0 up
配置wpa_supplicant.conf配置文件.配置文件如下:
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
ap_scan=1
network={
ssid="wifi名字"
psk="wifi密码"
priority=5
}
使用wpa_supplicant连接热点
$ sudo wpa_supplicant -B -Dnone -iwlan0 -c./wpa_supplicant.conf
输入该命令后会出现以下错误:
ioctl[SIOCSIWENCODEEXT]: Invalid argument
出现此错误不用管,继续下一步获取ip地址;
通过dhclient获取ip地址终端下的命令:
$ sudo dhclient wlan0
方法二:安装network-manager
安装network-manager和systemctl
$ sudo apt-get install network-manager
$ sudo apt-get install systemd
//Error: NetworkManager is not running. 错误提示,则需要输入下面内容
$ sudo service network-manager restart
测试是否成功,连接网络
# sudo nmcli dev wifi connect "wifi-name" password "wifi-password" name "wlan0"
11.设置自动登录
写脚本autologin
代码:
#!/bin/bash
/bin/login -f #你的用户名
移动到/usr/bin/下,并且用chmod +x autologin设置可执行权限
修改/etc/init/tty1.conf
# tty1 - getty
#
# This service maintains a getty on tty1 from the point the system is
# started until it is shut down again.
start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]
respawn
exec /sbin/getty -n -l /usr/bin/autologin -8 38400 tty1