FROG项目培训文档系列之01
开发环境和编译烧录
本章内容包括:
1.Genbox安装准备
2.安装Genbox环境
3.运行Genbox
4.安装配置平台release
5.使用prebuilt安装rootfs
6.如何编译你修改的软件包
6.烧录到板
7.生成可写rootfs文件系统
开始本章之前,请确保Ubuntu14.04系统已经安装
Genbox即是Frog系统的交叉编译环境也是集成环境。
https://devmanual.gentoo.org/ 官方开发手册
It manages its own packages, controls the execution environment and guarantees the stability and reproducibility of the embedded-system building process.The Genbox cross-compilation environment is composed of two parts:
- the compilation environment which appears as a “squashfs” image (file structure on your disk),
- the management script to download, install and run this image.
1.Genbox安装准备
To use the Genbox, you need GitHub SSH credentials and a Frog authentication token. You also need to link your Frog and GitHub accounts.
Supported platforms : Ubuntu 14.04
Required packages
1).Install the squashfstools package:
sudo apt-get install squashfs-tools
2).Check that the openssh and openssh-client packages are installed.
sudo apt-get install ssh
sudo apt-get install openssh-server
sudo apt-get install openssh-client
3).Prepare your SSH and Github credentials.
The Genbox requires you to use SSH to connect to Github.
ssh-keygen -t rsa -b 4096 -C "wang2@qq.com"
Make sure the SSH agent is active:
ps aux |grep ssh-agent
Should return something like:
user 1311 0.0 0.0 2300 288 ? Ss 11:28 0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session /usr/bin/im-launch gnome-session --session=ubuntu
If not, launch a new SSH agent:
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa
ssh -T git@github.com
Make sure SSH_AUTH_SOCK is set to a path shared between the development computer and the Genbox (for instance, /tmp):
sudo gedit /etc/sudoers
add a line:
Defaults env_keep+=SSH_AUTH_SOCK
echo $SSH_AUTH_SOCK
it Should return something like:
/tmp/ssh-U1B7SaDJibVF/agent.3188
2.安装Genbox环境
You can enter genbox using:
sudo /genbox/bin/genbox-ng
Create an alias to run the Genbox, and store it in your ~/.bashrc file:
echo 'alias run-genbox="sudo /genbox/bin/genbox-ng"' >> ~/.bashrc
echo 'alias run-genbox="sudo /home/work/genbox/bin/genbox-ng"' >> ~/.bashrc
下次重启后直接运行run-genbox即可启动genbox
3.运行Genbox
sudo /genbox/bin/genbox-ng
(最近Frog网站申请的账号,令牌包含非十六进制字符,此时会提示无效令牌,先忽略此问题,等安装完成后用其他命令重新设置
ssh -T git@github.com
申请的Frog令牌有包含非16进制的字符,在第一次配置genbox的时候回提示无效的令牌
通过以下的方法fix:
emerge --sync
emerge frog-config
emerge --config sys-config/frog-config
此处重新输入令牌配置成功
4.安装配置平台release
先注意一下几点:
1)../clone_gitsrv.sh此步从网络下载软件包太慢,可以将文件夹里已经下载打包好的frogbywyplay.tgz放在release文件夹下,不用重复下载,直接执行/tmp/release/init_genbox.sh即可
2).执行/tmp/release/release_setup.sh /tmp/release完成后,删除linux.git .用文件夹下linux.git替换,新的linux.git包含新增加我们用的平台的flash driver
rm -frv /git/his/linux.git
cp -frv ./linux.git /git/his/
3).执行以下两步,做一次完整编译,用prebuild不能把新flash driver编译进去
xtarget -c -v -d prebuilt_dvbc -a hi3716m42dmb =product-targets/me-4.4.3.11
xmerge world
4)./script/mk_ubi_img.sh 生成image升级系统(直接跳过以下第5步使用prebuilt安装rootfs)
5.使用prebuilt安装rootfs
Frog provide one or several prebuilt rootfs, or prebuilt, that you install and manage in the Genbox through xtarget command.
1).Ensure that your overlays are up-to-date, so that the list of available prebuilts is accurate as well:
xtarget --sync
The --sync command updates the /usr/local/portage/targets repository
2).Listing the prebuilts available for installation
xtarget --list-profiles --verbose
xtarget -pv
3).Installing a prebuilt rootfs
USE=prebuilt xtarget -c -v -d prebuilt_dvbc -a hi3716m42dmb =product-targets/me-4.4.3.11
xtarget installs a complete rootfs in /usr/targets/prebuilt_dvbc /root.
--dir option tells xtarget that the new target will be installed under /usr/targets/frog.
If you do not add dir option, xtarget creates the new target under /usr/targets/- directory.
xtarget just processes an ebuild from the “targets” overlay (in /usr/local/portage/targets).
This target ebuild simply installs configuration files necessary to build a complete rootfs.
5).Listing the installed prebuilt
xtarget -lv
6).Setting the prebuilt as the default target
xtarget --set prebuilt_dvbc
Setting a default target creates a symlink named /usr/targets/current pointing to /usr/targets/
Managing packages in a target rootfs
Genbox is derived from Gentoo, hence Portage is used in order to build a component. This chapter is a quick Portage overview, so I advise you to also have a look at Gentoo Portage official documentation.
ActionCommand
Search for packages with foo pattern in its name [1]xmerge --search foo
Install foo package (and its dependencies if missing) [2]xmerge foo
Install foo dependencies but not foo package itselfxmerge --onlydeps foo
Update Portage tree and its overlays [3]xmerge --sync
Update all installed packages [4]xmerge --update --deep world
Remove foo packagexmerge --unmerge foo
Remove orphaned dependencies [5]xmerge --depclean
Special use cases:
Using a regular expression for package search
You can enable a regular expression search by prefixing the search string with %.
For example:
xmerge --search "%^foo"
searches for any package whose name starts with “foo”.
package version to install. To install a specific package version:
xmerge '=sys-apps/busybox-1.4.1-r13'
To preview what would be installed without really installing packages:
xmerge --pretend --verbose
To preview what will be installed before installing packages:
xmerge --ask --verbose
6.如何编译你修改的软件包 (方法一致,以frog-ui为例)
This page explains how to retrieve an existing package, modify its code and integrate it in a target rootfs.
1.首先找到你要编辑的软件包的ebuild文件在哪里
The component is already installed in the target rootfs:
xexec equery which frog-ui
this command has the advantage to display the exact desired result
The component is not installed in the target rootfs yet:
xmerge --search frog-ui
xmerge - frog-ui
the line beginning with “Path” to get the ebuild’s path.
/usr/targets/prebuilt_dvbc/portage/frog/media-gfx/frog-ui/frog-ui-1.1.31.5.ebuild
2.获取软件包的源代码
因为之前全部编译后源代码会自动删除,这里需要重新从git库获取
在git库中的branch和版本号,在ebuild文件中设置
EGIT_BRANCH:="1.1.31-stable"
EGIT_REVISION:="asa11********"
xbuild /usr/targets/prebuilt_dvbc/portage/frog/media-gfx/frog-ui/frog-ui-1.1.31.5.ebuild clean
xbuild /usr/targets/prebuilt_dvbc/portage/frog/media-gfx/frog-ui/frog-ui-1.1.31.5.ebuild unpack
clean会清除xbuild /usr/targets/prebuilt_dvbc/portage/frog/media-gfx/下面的frog-ui文件夹下所有内容。所以在你的改动push到git origin之前不要执行,不然改动丢失。
unpack会从/git/frogbywyplay/app_frog-ui.git库clone源代码到work目录
The unpack action indicates where to find the component sources, here in :
/usr/targets/prebuilt_dvbc/work/media-gfx/frog-ui-1.1.31.5/work/frog-ui-1.1.31.5
3.修改代码,执行编译安装命令:
xbuild /usr/targets/current/portage/wms/dev-libs/wylog/wylog-1.2.4.ebuild compile
>>> Compiling source in /usr/targets/.../work/dev-libs/wylog-1.2.4/work//frog-ui-1.1.31.5 ...
* Running eautoreconf in '/usr/targets/.../work/dev-libs/wylog-1.2.4/work//frog-ui-1.1.31.5...
* QA Warning: running aclocal in compile phase
* Running aclocal …
[...]
>>> Source compiled.
xbuild /usr/targets/current/portage/wms/dev-libs/wylog/wylog-1.2.4.ebuild install
4.将生产的binary文件合并到default target rootfs:
xbuild /usr/targets/current/portage/wms/dev-libs/wylog/wylog-1.2.4.ebuild install qmerge
5 ./script/mk_ubi_img.sh 生成image升级系统,测试
6.测试OK后,推送到remote git库保存.
6.烧录到板,硬件连接
平台和电视用HDMI线连接.
平台和电脑连接在同一个路由器,组成局域网内
用USB串口将板子串口和电脑连接,安装好驱动
机顶盒平台接上DVB信号线
连接机顶盒平台电源
执行./script/mk_ubi_img.sh 后会在当前的target root下生成:
/usr/target/current/root/boot/uImage
/usr/target/current/root/img/ubi.img
1.将上面两个文件copy到tmp文件夹下,exit genbox环境,复制到U盘。
2.将uImage,ubi.img和partitions_nand.xml分区表xml文件放在同一个文件夹下。
3.打开烧录工具hitools
烧录需要配置好串口和网络,串口选择你正在用的端口,如果是多网卡,选择局域网卡IP
板端配置默认即可
传输方式选默认网口
选择文件夹下的分区表文件,即partitions_nand.xml,下面会自动流出升级对应分区文件
勾选需要升级的分区即可,比如frog-ui只需要升级rootfs即可
4,配置OK后点击烧录,板子断电重启,即可自动升级后重启完成。
7.生成可写rootfs文件系统
以下方法可以生产可写的roorfs文件系统,方法修改板子上的文件设置和替换更新模块
1)修改/script/mk_ubi_img.sh中关于roofs_ubifs配置
vol_type修改为dynamic
vol_size设置为100M
[roofs_ubifs]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=100MiB
vol_type=dynamic
vol_name=rootfs
2)执行/script/mk_ubi_img.sh,生成image升级系统
3)开机启动后按住ctrl+c,进入fastboot模式,将启动参数设置为rw
fastboot# print
bootdelay=1
baudrate=115200
ethaddr=00:00:00:00:00:00
ipaddr=192.168.1.10
serverip=192.168.1.1
netmask=255.255.255.0
bootfile="uImage"
bootargs_512M=mem=512M mmz=ddr,0,0,256M
bootargs_1G=mem=1G mmz=ddr,0,0,380M
bootargs_2G=mem=2G mmz=ddr,0,0,600M
bootargs=console=ttyAMA0,115200 ubi.mtd=6 root=ubi0:rootfs rootfstype=ubifs mem=512M mmz=ddr,0,0,256M mtdparts=hinand:1M(boot),1M(bootargs),1M(baseparam),1M(pqparam),1M(logo),8M(kernel),-(rootfs) ro rootwait // 这里ro需要改为rw
bootcmd=nand read 1000000 500000 800000;bootm 1000000
stdin=serial
stdout=serial
stderr=serial
ethact=up
ver=Fastboot 3.3.0-dirty (dwx443370@fish) (Mar 16 2017 - 20:11:30)
Environment size: 627/65532 bytes
敲如下命令重洗设置可写启动参数:
set bootargs 'console=ttyAMA0,115200 ubi.mtd=6 root=ubi0:rootfs rootfstype=ubifs mem=512M mmz=ddr,0,0,256M mtdparts=hinand:1M(boot),1M(bootargs),1M(baseparam),1M(pqparam),1M(logo),8M(kernel),-(rootfs) rw rootwait'
然后执行save命令保存。
4)启动系统后,文件系统即是可写的。
网友评论