Porting(移植) B2G OS【1】——Porting basics

1.前提

原文地址:https://developer.mozilla.org/en-US/docs/Archive/B2G_OS/Porting_B2G_OS/basics

B2G OS使用的是一个来自Android的内核,上层有一个基于gecko的用户界面。本文且作为一个粗略的移植指南

Note!

本指南假设您正在移植到一个已经运行Android的新设备;如果您正在移植到另一个设备,那么这项工作将会更加复杂。

You can find help on porting on the #fxos IRC channel and on Mozilla Discourse.

2.配置编译环境

可参照B2G OS build prerequisites进行。

3.Clone the B2G repositories

第一步克隆 B2G repository和the repository with the manifests

1
2
git clone https: //github .com /mozilla-b2g/B2G .git
git clone https: //github .com /mozilla-b2g/b2g-manifest .git

4.Add a new device to config.sh

下一步是向config.sh中添加一个新设备在B2G存储库中;可以用现存的config.sh为模板。

5.Create a manifest for the new device

现在要为新设备添加一个manifest file(清单文件)。可参考一个模板的现有清单,比如 hamachi 。一旦完成,应该将新的清单添加到本地b2g-manifest存储库中。

1
2
git add my-new-device.xml
git commit

接下来,要让config.sh使用本地的b2g-manifest取代官方版。只要修改config.sh中的GITREPO和BRANCH变量的值即可,比如:

1
2
GITREPO=${GITREPO:- "file:///home/yourname/b2g-manifest" }
BRANCH=${BRANCH:-master}

6.Create a configuration tree for the new device

为新设备创建一个新的配置树。其所在位置为device/<manufacturer>/<device_id>。配置树应该至少包含:

这些内容会因设备的不同而不同。特别是BoardConfig.mk和extract-files.sh会有显著区别。这些配置是最麻烦的,需要反复调整、测试、debug才能调试出最优状态。可参考configuration for the hamachi device进行修改这些文件。

7.Rebuild boot.img

一旦您完成了所有的工作,您就需要重新构建引导映像。并不是修改内核,而是要将更改提取到init.rc。

7.1修改init.rc

将移植前手机原来的Android系统init.c提取出来进行修改,主要修改的内容包括以下几点:

1.导入init.b2g.rc:

1
2
3
on early-init
     start ueventd
     import  /init .b2g.rc

2.修改权限:

修改/system/b2g/b2g、/system/b2g/updater/system/b2g/plugin-container的权限;

1
2
3
chmod  0755  /system/b2g/b2g
chmod  0755  /system/b2g/updater
chmod  0755  /system/b2g/plugin-container

You might want to start by modifying the init.rc from the new device instead of using the init.rc provided by the build system; if so, you need to remember to set TARGET_PROVIDES_INIT_RC in BoardConfig.mk.

7.2 Prebuild kernel 和 building the kernel from source

您可以使用预先构建的内核,或者您可以从源代码构建内核。要从源代码构建内核,请添加AndroidKernel。mk和内核配置到设备配置树。

The maguro on the old build system is an example that builds the kernel from source.


1
2
3
chmod  0755  /system/b2g/b2g
chmod  0755  /system/b2g/updater
chmod  0755  /system/b2g/plugin-container

7.3提取并修改现有boot.img

It is possible to recover the boot image of a phone by dumping the contents of the /dev/mtd/mtd1 or /dev/mtd/mtd2 devices, the resulting image file can then be easily recovered:


1
2
adb shell  'cat /dev/mtd/mtd1 > /sdcard/boot.img'
adb pull  /sdcard/boot .img

待续。。

8.Add the new device to flash.sh

Add the new device to flash.sh; the specifics of how to do this will depend on what tools need to be used to flash the new device.

9.Configure,build,and flash the new device

Now you can try building for and flashing to your new device:

1
2
3
ANDROIDFS_DIR=my_device_backup . /config .sh <device_id>  '../b2g-manifest/default.xml'
. /build .sh
. /flash .sh

猜你喜欢

转载自blog.csdn.net/xiaoma_pedro/article/details/81030670