FROG項(xiàng)目培訓(xùn)文檔系列之01? ??
開發(fā)環(huán)境和編譯燒錄
本章內(nèi)容包括:
1.Genbox安裝準(zhǔn)備
2.安裝Genbox環(huán)境
3.運(yùn)行Genbox
4.安裝配置平臺release
5.使用prebuilt安裝rootfs
6.如何編譯你修改的軟件包
6.燒錄到板
7.生成可寫rootfs文件系統(tǒng)
開始本章之前,請確保Ubuntu14.04系統(tǒng)已經(jīng)安裝
Genbox即是Frog系統(tǒng)的交叉編譯環(huán)境也是集成環(huán)境攘轩。
https://devmanual.gentoo.org/ 官方開發(fā)手冊
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安裝準(zhǔn)備
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環(huán)境
? ? ? ? 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
? ? ? ? ? 下次重啟后直接運(yùn)行run-genbox即可啟動genbox
3.運(yùn)行Genbox
? ? ?sudo /genbox/bin/genbox-ng
? ?(最近Frog網(wǎng)站申請的賬號驱证,令牌包含非十六進(jìn)制字符,此時(shí)會提示無效令牌读恃,先忽略此問題,等安裝完成后用其他命令重新設(shè)置
? ? ? ? ? ?ssh -T git@github.com
? ? ? ? 申請的Frog令牌有包含非16進(jìn)制的字符代态,在第一次配置genbox的時(shí)候回提示無效的令牌
? ? ? ? ? ?通過以下的方法fix:
? ? ? ? ? emerge --sync
? ? ? ? ?emerge frog-config
? ? ? ? ?emerge --config sys-config/frog-config
? ? ? ? ?此處重新輸入令牌配置成功
4.安裝配置平臺release
先注意一下幾點(diǎn):
1)../clone_gitsrv.sh此步從網(wǎng)絡(luò)下載軟件包太慢寺惫,可以將文件夾里已經(jīng)下載打包好的frogbywyplay.tgz放在release文件夾下,不用重復(fù)下載蹦疑,直接執(zhí)行/tmp/release/init_genbox.sh即可
2).執(zhí)行/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).執(zhí)行以下兩步,做一次完整編譯歉摧,用prebuild不能把新flash driver編譯進(jìn)去
? ? xtarget -c -v -d prebuilt_dvbc -a hi3716m42dmb =product-targets/me-4.4.3.11
? ? xmerge world
4)./script/mk_ubi_img.sh 生成image升級系統(tǒng)(直接跳過以下第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.獲取軟件包的源代碼
? 因?yàn)橹叭烤幾g后源代碼會自動刪除腔呜,這里需要重新從git庫獲取
? 在git庫中的branch和版本號,在ebuild文件中設(shè)置
? ? 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文件夾下所有內(nèi)容再悼。所以在你的改動push到git origin之前不要執(zhí)行核畴,不然改動丟失。
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.修改代碼冲九,執(zhí)行編譯安裝命令:
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.將生產(chǎn)的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升級系統(tǒng)谤草,測試
6.測試OK后,推送到remote git庫保存.
6.燒錄到板,硬件連接
平臺和電視用HDMI線連接.
平臺和電腦連接在同一個(gè)路由器莺奸,組成局域網(wǎng)內(nèi)
用USB串口將板子串口和電腦連接丑孩,安裝好驅(qū)動
機(jī)頂盒平臺接上DVB信號線
連接機(jī)頂盒平臺電源
執(zhí)行./script/mk_ubi_img.sh 后會在當(dāng)前的target root下生成:
/usr/target/current/root/boot/uImage
/usr/target/current/root/img/ubi.img
1.將上面兩個(gè)文件copy到tmp文件夾下,exit genbox環(huán)境灭贷,復(fù)制到U盤温学。
2.將uImage,ubi.img和partitions_nand.xml分區(qū)表xml文件放在同一個(gè)文件夾下甚疟。
3.打開燒錄工具h(yuǎn)itools
燒錄需要配置好串口和網(wǎng)絡(luò)仗岖,串口選擇你正在用的端口,如果是多網(wǎng)卡览妖,選擇局域網(wǎng)卡IP
板端配置默認(rèn)即可
傳輸方式選默認(rèn)網(wǎng)口
選擇文件夾下的分區(qū)表文件轧拄,即partitions_nand.xml,下面會自動流出升級對應(yīng)分區(qū)文件
勾選需要升級的分區(qū)即可黄痪,比如frog-ui只需要升級rootfs即可
4紧帕,配置OK后點(diǎn)擊燒錄,板子斷電重啟桅打,即可自動升級后重啟完成是嗜。
7.生成可寫rootfs文件系統(tǒng)
以下方法可以生產(chǎn)可寫的roorfs文件系統(tǒng),方法修改板子上的文件設(shè)置和替換更新模塊
1)修改/script/mk_ubi_img.sh中關(guān)于roofs_ubifs配置
vol_type修改為dynamic
vol_size設(shè)置為100M
[roofs_ubifs]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=100MiB
vol_type=dynamic
vol_name=rootfs
2)執(zhí)行/script/mk_ubi_img.sh挺尾,生成image升級系統(tǒng)
3)開機(jī)啟動后按住ctrl+c,進(jìn)入fastboot模式鹅搪,將啟動參數(shù)設(shè)置為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
敲如下命令重洗設(shè)置可寫啟動參數(shù):
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'
然后執(zhí)行save命令保存。
4)啟動系統(tǒng)后遭铺,文件系統(tǒng)即是可寫的丽柿。