FirefoxOS/RPiB2: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(removing long lines)
(Correction in a command line)
 
(21 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== State of the project ==
<font color="red">'''READ FIRST'''</font>
This project is officially on HOLD. It will be active again after transition branch is completely merged. If you want to know more details about this project and next steps, please check this [http://gioyik.com/p/raspberrypi-final-state blog post]
== About The Project ==
== About The Project ==
[[File:Fxpi.png|250px|thumbnail|right]]
We are looking to demonstrate that Firefox OS can be a viable and valuable operating system for a range of development boards and hardware related to IoT
We are looking to demonstrate that Firefox OS can be a viable and valuable operating system for a range of development boards and hardware related to IoT


Line 6: Line 12:
<font color="red">'''WARNING'''</font>: this guide is specific for the <font color="green">'''Raspberry PI B+ 2'''</font>, older models have a different chipset and newest model have not been tested.
<font color="red">'''WARNING'''</font>: this guide is specific for the <font color="green">'''Raspberry PI B+ 2'''</font>, older models have a different chipset and newest model have not been tested.


The initial goal is release a downloadable and flashable version of Firefox OS for Raspberry Pi B+ 2 board and a step by step guide to let everybody create their our roms using the B2G build system.
The initial goal is release a downloadable and flashable version of Firefox OS for Raspberry Pi B+ 2 board and a step by step guide to let everybody create their our roms using the B2G build system. The meta bug for this project is [https://bugzilla.mozilla.org/show_bug.cgi?id=1225139 bug 1225139]


== Project Management Team ==
== Project Management Team ==
Line 26: Line 32:


== What We'd Like To See Happen ==
== What We'd Like To See Happen ==
TBD
 
* Start the path of the new strategy '''Connected Devices''' with this port
* Let the community be part of the success in this project.
* Bring RPi users more options (operating systems) for their next project
* Push the Web of things forward
* Enable programmers (via DOM/CSS) to develop robotics and other IoT projects


== Limitations ==
== Limitations ==
Line 32: Line 43:
* VC4 driver is still on development
* VC4 driver is still on development
* Sometimes slow and buggy
* Sometimes slow and buggy
 
* Not all device capabilities are exposed through Web APIs
== Follow-up projects ==
* Small/integrated display not planned to support soon
Working on something with a Raspberry Pi + Firefox OS? Let us know. :)


== Development Sprints ==
== Development Sprints ==
Line 50: Line 60:
* '''Android devices files for RP2''' <font color="green">'''[DONE]'''</font>
* '''Android devices files for RP2''' <font color="green">'''[DONE]'''</font>
** B2G build system uses AOSP that requires a repo with device configuration. Folder and files like AndroidBoard.mk, AndroidProducts.mk, BoardConfig.mk, device_rpi2.mk, recovery.fstab, and more will be created or adapted to RPI 2 architecture
** B2G build system uses AOSP that requires a repo with device configuration. Folder and files like AndroidBoard.mk, AndroidProducts.mk, BoardConfig.mk, device_rpi2.mk, recovery.fstab, and more will be created or adapted to RPI 2 architecture
* '''Make RPI 2 kernel build from source''' <font color="orange">'''[WORKING]'''</font>
* '''Make RPI 2 kernel build from source''' <font color="green">'''[DONE]'''</font>
** Create a sync configuration for BoardConfig.mk file to build the kernel and any required kernel modules automatically.  
** Create a sync configuration for BoardConfig.mk file to build the kernel and any required kernel modules automatically.  
* '''Create manifest file for RPI 2''' <font color="green">'''[DONE]'''</font>
* '''Create manifest file for RPI 2''' <font color="green">'''[DONE]'''</font>
Line 56: Line 66:


==== Phase 2 ====
==== Phase 2 ====
* '''Add libraries'''
* '''Add libraries''' <font color="green">'''[DONE]'''</font>
** In the device specific files during compilation process there are necessary includes to specific libraries
** In the device specific files during compilation process there are necessary includes to specific libraries
* '''Configure modules'''
* '''Configure modules''' <font color="green">'''[DONE]'''</font>
** In the device specific files is necessary to add external modules/files to be compiled and binary generated
** In the device specific files is necessary to add external modules/files to be compiled and binary generated
* '''Kernel configuration for RPI 2''' <font color="green">'''[DONE]'''</font>
* '''Kernel configuration for RPI 2''' <font color="green">'''[DONE]'''</font>
Line 68: Line 78:
* '''Automated Android builds server''' <font color="orange">'''[WORKING]'''</font>
* '''Automated Android builds server''' <font color="orange">'''[WORKING]'''</font>
** Jenkins or TaskCluster running to make automated builds of Android for the RPI 2.
** Jenkins or TaskCluster running to make automated builds of Android for the RPI 2.
* '''Find issues''' <font color="orange">'''[WORKING]'''</font>
* '''Update documentation''' <font color="green">'''[DONE]'''</font>
** Debug the build to search for possible bugs and issues that could make a risk for stability in the next Quarter Phases.
* '''Update documentation''' <font color="orange">'''[WORKING]'''</font>
** Update building steps and requirements with new ones for Raspberry PI 2
** Update building steps and requirements with new ones for Raspberry PI 2


Line 80: Line 88:
* '''Gecko Port''' <font color="green">'''[DONE]'''</font>
* '''Gecko Port''' <font color="green">'''[DONE]'''</font>
** Having a basic Android base system the next priority is get Gecko working. This will help to identify easily more problems in the final ROM
** Having a basic Android base system the next priority is get Gecko working. This will help to identify easily more problems in the final ROM
* '''Graphics support'''
* '''Graphics support''' <font color="green">'''[DONE]'''</font>
** In this project there is a challenge, and that’s the correct graphics support. RPI 2 has a VideoCore with a Broadcom BCM2739 that changed a lot in this latest version of the RPI 2. Will be necessary take a look of Broadcom reference guides
** Use hardware default renderer.
* '''Update documentation'''
** In this project there is a challenge, and that’s the correct graphics support. RPI 2 has a VideoCore with a Broadcom BCM2739 that changed a lot in this latest version of the RPI 2. Will be necessary take a look of Broadcom reference guides  
* '''Update documentation''' <font color="green">'''[DONE]'''</font>
** Create page about Firefox OS architecture on the Raspberry PI 2
** Create page about Firefox OS architecture on the Raspberry PI 2


==== Phase 2 ====
==== Phase 2 ====
* '''Input support'''
* '''Input support''' <font color="blue">'''[PARTIAL DONE]'''</font>
** Keyboard and mouse support is one of the P1 for Raspberry PI port. The basic support for Keyboard would be on early stages of Android building. So, the work here would be add listeners for input fields. The mouse support work will consist in implement a pointer interface on Gaia and enable on-click listeners
** Keyboard and mouse support is one of the P1 for Raspberry PI port. The basic support for Keyboard would be on early stages of Android building.
* '''Storage support'''
** Mouse support: https://bugzilla.mozilla.org/show_bug.cgi?id=1082892
* '''Storage support''' <font color="green">'''[DONE]'''</font>
** Add support to SD Card recognition and USB storage devices
** Add support to SD Card recognition and USB storage devices
* '''Connection support'''
* '''Connection support''' <font color="blue">'''[PARTIAL DONE]'''</font>
** Work on WiFi and Ethernet support and add listeners for every time you plug or unplug it to the board. Usually it recognizes Ethernet connection if is connected before booting.
** Work on WiFi and Ethernet support and add listeners for every time you plug or unplug it to the board. Usually it recognizes Ethernet connection if is connected before booting.
* '''ADB Push''' <font color="green">'''[DONE]'''</font>
** Enable support to push apps by ADB connection


==== Phase 3 ====
==== Phase 3 ====
* '''Generate complete/stable/usable Firefox OS build'''
* '''Generate complete/stable/usable Firefox OS build''' <font color="green">'''[DONE]'''</font>
** After all the base system is working and running, I will create builds to distribute and  
** After all the base system is working and running, I will create builds to distribute and publish them.
* '''Flashing files'''
* '''Flashing files''' <font color="green">'''[DONE]'''</font>
** The Raspberry PI could not be flashed correctly with common Fastboot method, is necessary to create a filesystem that will be copied to the SD card
** The Raspberry PI could not be flashed correctly with common Fastboot method, is necessary to create a filesystem that will be copied to the SD card
* '''Using U-Boot''' <font color="red">'''[BLOCKED]'''</font>
* '''Update documentation''' <font color="green">'''[DONE]'''</font>
** U-Boot will help to make the booting process more easier with the filesystem and partitions we have mounted in the SD Card with Firefox OS
* '''Update documentation'''
** Update flashing guide with steps for Raspberry PI 2
** Update flashing guide with steps for Raspberry PI 2


==== Phase 4 ====
==== Phase 4 ====
* '''Gaia Port'''
* '''Gaia Port''' <font color="green">'''[DONE]'''</font>
** The Gaia port will be ready only when the graphics support is done, added to this, maybe will be some display/resolution limitations if the graphic support is not fully implemented or there are missing parts.
** The Gaia port will be ready only when the graphics support is done, added to this, maybe will be some display/resolution limitations if the graphic support is not fully implemented or there are missing parts.
* '''Remove unnecessary apps'''
* '''Remove unnecessary apps'''
** Apps like Radio, Dialer, Messages and others are not necessary due Raspberry PI 2 itself doesn’t have hardware components to be used with those apps.
** Apps like Radio, Dialer, Messages and others are not necessary due Raspberry PI 2 itself doesn’t have hardware components to be used with those apps.
* '''Update documentation'''
* '''NOOBS installer''' <font color="green">'''[DONE]'''</font>
** Create page with benchmarks of the port
** Add support to install B2G using NOOBs installer
** Create page about Known Issues with Raspberry PI 2 builds and how to fix common problems
* '''Update documentation''' <font color="orange">'''[WORKING]'''</font>
* '''Video review (?=optional)'''
** Blog post on Hacks Blog
** Produce a short video reviewing the state of Firefox OS on Raspberry PI 2
* '''Benchmark report (?=optional)'''
** With a working/stable build would be great to create Benchmark reports to show improvements on performance and speed
 
== Getting Started ==
 
0. You need a Raspberry Pi B+ 2, of course. :)
 
1. TBD


== Build From Source ==
== Build From Source ==
Line 128: Line 129:
Be sure of have those libraries installed to avoid compiling problems. On Ubuntu would be:
Be sure of have those libraries installed to avoid compiling problems. On Ubuntu would be:


  sudo apt-get install libfontconfig1 libXrender1 libXcomposite1 libXasound2 libgtk2.0 libxt6 unzip
  sudo apt-get install libfontconfig1 libXrender1 libXcomposite1 libgtk2.0-0 libxt6 unzip python-pip gettext libasound2
 
Installing pip dependencies for LibMesa:
 
pip install Mako --upgrade


To build b2g for your Raspberry Pi B+ 2, first download the b2g helper scripts
To build b2g for your Raspberry Pi B+ 2, first download the b2g helper scripts
Line 137: Line 142:


  cd B2G
  cd B2G
  ./config.sh rpib2
  ./config.sh rpi2b-l


The config.sh step can take quite a while, because it downloads a large amount of data. Finally, build b2g
The config.sh step can take quite a while, because it downloads a large amount of data. Finally, build b2g
Line 145: Line 150:
This step also takes some time, because it's building an entire operating system.  When your build finishes, it's time to flash it onto an SD card for your RPi.
This step also takes some time, because it's building an entire operating system.  When your build finishes, it's time to flash it onto an SD card for your RPi.


== Build Kernel ==
== Prepare To Flash ==


It's planned to add the kernel building process to the b2g build system, but for now, you have to do it yourself.
<font color="red">'''WARNING'''</font>: The process described here will erase all the data in your SD card. Be sure of not lose sensitive data inside the card.


=== Prepare Toolchain ===
You need a 4Gb SD card at least, if has more space better. Then create partitions and copy the files to let the Raspberry PI boot Firefox OS.
 
We need to cross compiling to kernel for the Raspberry Pi, for this we need the correct toolchain. Clone the toolchain repository in a folder you will remember:
 
git clone https://github.com/raspberrypi/tools


Then add the directory of the repo you have cloned to the '''path''' in you system.
=== Configure UDEV rules for the SD card ===


=== Compile from source ===
By configuring udev rules for the specific SD card you are going to use for B2G, you will avoid the need to pass via root access (e.g., '''sudo dd''') to be able to copy data. This also limits the risks of doing '''dd''' to the wrong device and mess with everything. This is documented for use with a sd card integrated reader, but this should be able to work elsewhere.


The kernel is copied in ''kernel/raspberrypi/rpib2''. Knowing this follow the steps.
First, plug your sdcard and identify its serial:
$ udisksctl status
MODEL                    REVISION  SERIAL              DEVICE
--------------------------------------------------------------------------
[...]
SL08G                              0xa0442a9f          mmcblk0


1. Go inside B2G directory and kernel directory
So in this case, '''/dev/mmcblk0''' has serial number '''0xa0442a9f'''. You can now unplug the card for now.


kernel/raspberrypi/rpib2
The populate a file in '''/etc/udev/rules.d/''', let be its name '''52-mmcblk.rules'''. And put the following content:
# µSD B2G
SUBSYSTEM=="block", SUBSYSTEMS=="mmc", DRIVERS=="mmcblk", ATTRS{serial}=="0xa0442a9f", MODE="0666", GROUP="plugdev"


2. Merge configurations into '''.config''' to build the kernel
Make sure you have '''ATTRS{serial}=="0xa0442a9f"'''. Rule will match any '''mmcblk''' exposed device whose attribute serial is 0xa0442a9f. If it matches, then it will set permissions 0666 and group plugdev. Save this file, and issue a udev reload:


  ARCH=arm scripts/kconfig/merge_config.sh arch/arm/configs/bcm2709_defconfig android/configs/android-base.cfg android/configs/android-recommended.cfg
  # udevadm control --reload


3. Build the zImage
Now, if you replug the sdcard, it should be set with the proper permissions in /dev.
 
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make zImage
 
4. Build the dtb file
 
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make dtbs
 
The two files that are generated and you need to boot the Raspberry PI B+ 2 are located in:
 
kernel/raspberrypi/rpib2/arch/arm/boot/zImage
kernel/raspberrypi/rpib2/arch/arm/boot/dts/bcm2709-rpi-2-b.dtb
 
== Prepare To Flash ==
 
<font color="red">'''WARNING'''</font>: The process described here will erase all the data in your SD card. Be sure of not lose sensitive data inside the card.
 
You need a 4Gb SD card at least, if has more space better. Then create partitions and copy the files to let the Raspberry PI boot Firefox OS.


=== Partitions for the SD card ===
=== Partitions for the SD card ===
Line 192: Line 183:
Create 4 partitions in next order and be careful with the sized of each one.
Create 4 partitions in next order and be careful with the sized of each one.


  boot (Partition 1) = Size [512MB] = Format as fat32, tag bootable flag
  boot (Partition 1) = Size [48MB] = Format as fat32, tag bootable flag
  system (Partition 2) = Size [537MB] = Format as new primary partition or ext4
  system (Partition 2) = Size [537MB] = Format as new primary partition or ext4
  cache (Partition 3) = Size [512MB] = format as ext4
  cache (Partition 3) = Size [512MB] = format as ext4
  data (Partition 4) = Size [Rest of free space] = format as ext4
  data (Partition 4) = Size [Rest of free space] = format as ext4


=== Copying data to SD card ===
=== Installing on the SD card ===
 
For a first time installation, you will have to flash all partitions. Images have been produced in the '''out/target/product/rpi2b''' directory and you should flash:
# boot.img to Partition 1
# system.img to Partition 2
# cache.img to Partition 3
# userdata.img to Partition 4
 
Please proceed with the '''dd''' command (and replace '''file''' with the proper file name):
 
dd if=file of=/dev/XpY bs=1m
 
Be sure of check that everything is copied successfully on the partition. For this port we create a ''userdebug'' build, so, everything is inside system image. Usually, '''X''' will be the name of your device and '''pY''' should be replaced by the partition number. For example, a SD card reader might expose this as: '''/dev/mmcblk0p1''' for boot partition (Partition 1).


Copy the following files to each partition.
Remember to NOT flash cache and/or userdata images if you are just '''updating''' your system, except if you are sure or instructed to do so. Doing this will result in your data being erased.


1. Everything inside '''device/raspberrypi/rpib2/boot/''' is copied into '''boot (Partition 1)'''
=== Faster flashing ===


device/raspberrypi/rpib2/boot/* => boot
You can also make use of '''bmaptool''' to flash faster than with '''dd'''. [http://git.infradead.org/users/dedekind/bmap-tools.git bmaptool repo].


2. '''zImage''' is copied into '''boot (Partition 1)'''
==== Produce bmap files ====


  kernel/raspberrypi/rpib2/arch/arm/boot/zImage => boot
Once you have built the system, produce bmap files:
  $ bmaptool create -o out/target/product/rpi2b/PARTITION.bmap out/target/product/rpi2b/PARTITION.img


3. '''bcm2709-rpi-2-b.dtb''' is copied into '''boot (Partition 1)'''
You can do this for each '''PARTITION''' that we have: boot, system, cache and userdata.


kernel/raspberrypi/rpib2/arch/arm/boot/dts/bcm2709-rpi-2-b.dtb => boot
==== Flashing with bmaptool ====


4. '''ramdisk.img''' is copied into '''is copied into '''boot (Partition 1)'''
Then flash using bmaptool (here only boot partition):
$ sudo bmaptool copy out/target/product/rpi2b/boot.img /dev/mmcblk0p1
bmaptool: info: discovered bmap file 'out/target/product/rpi2b/boot.bmap'
bmaptool: info: block map format version 2.0
bmaptool: info: 12288 blocks of size 4096 (48.0 MiB), mapped 2358 blocks (9.2 MiB or 19.2%)
bmaptool: info: copying image 'boot.img' to block device '/dev/mmcblk0p1' using bmap file 'boot.bmap'
bmaptool: info: 100% copied
bmaptool: info: synchronizing '/dev/mmcblk0p1'
bmaptool: info: copying time: 0.6s, copying speed 16.1 MiB/sec


out/target/product/rpib2/ramdisk.img => boot
Using '''dd''' on the same partition reports a write speed of 5.0MiB/s.


== Debugging ==
== Debugging ==
Line 290: Line 302:
The Console lead has four female connections that can be plugged directly onto the GPIO header of the Raspberry Pi. The Adafruit USB console cable has 3.3V logic, so its safe to use with your Pi.
The Console lead has four female connections that can be plugged directly onto the GPIO header of the Raspberry Pi. The Adafruit USB console cable has 3.3V logic, so its safe to use with your Pi.


[[File:RPiB2_Debug_Kit.jpg|300px]]
[[File:RPi2B_Debug_Kit.jpg|300px]]


For this experiment, the serial lead is going to power the Raspberry Pi. So, DO NOT attach the Pi's USB power adapter. If you would rather power the Pi from your USB power adapter then leave the Red lead from the Serial lead un attached.
For this experiment, the serial lead is going to power the Raspberry Pi. So, DO NOT attach the Pi's USB power adapter. If you would rather power the Pi from your USB power adapter then leave the Red lead from the Serial lead un attached.
Line 298: Line 310:
Attach the leads as shown below:
Attach the leads as shown below:


[[File:Putty-settings.png]]
[[File:Rpi2-serial-cable-connection.jpg|250px]]


The connections are to the outside pin connections of the GPIO header.  
The connections are to the outside pin connections of the GPIO header.  
Line 307: Line 319:
* The <font color="green">'''green'''</font> lead to RXD.
* The <font color="green">'''green'''</font> lead to RXD.


Now plug in the USB lead and you will see the Pi's power LED should light.  
Now plug in the USB lead and you will see the Pi's power LED should light.


===Boot messages===
===Boot messages===
Line 323: Line 335:
and so on. Eventually, you should see a login prompt:
and so on. Eventually, you should see a login prompt:


  shell@rpib2:/ $
  shell@rpi2b:/ $


You can then log in as you would with a keyboard and screen.
You can then log in as you would with a keyboard and screen.
Line 335: Line 347:


== Need Help? ==
== Need Help? ==
TBD
 
* IRC channel '''#fxos''' (Ping '''Gioyik''')
* Fill a bug on bugzilla
* Send an email to '''fxos''' mailing list


[[Category:Firefox OS]]
[[Category:Firefox OS]]
[[Category:Raspberry Pi]]
[[Category:Raspberry Pi]]

Latest revision as of 04:48, 12 June 2016

State of the project

READ FIRST

This project is officially on HOLD. It will be active again after transition branch is completely merged. If you want to know more details about this project and next steps, please check this blog post

About The Project

Fxpi.png

We are looking to demonstrate that Firefox OS can be a viable and valuable operating system for a range of development boards and hardware related to IoT

This page describes how to install Firefox OS in a Raspberry Pi B+ 2 running, without a Linux distribution installation previously. This is not Firefox OS running on top of Raspbian, this is a clean and full rom based on Android (as the ones running on phones).

WARNING: this guide is specific for the Raspberry PI B+ 2, older models have a different chipset and newest model have not been tested.

The initial goal is release a downloadable and flashable version of Firefox OS for Raspberry Pi B+ 2 board and a step by step guide to let everybody create their our roms using the B2G build system. The meta bug for this project is bug 1225139

Project Management Team

Name Role Email address
Dietrich Ayala Project Manager dietrich@mozilla.com
Giovanny Gongora Porting Developer gioyik@mozilla.com

What We'd Like To See Happen

  • Start the path of the new strategy Connected Devices with this port
  • Let the community be part of the success in this project.
  • Bring RPi users more options (operating systems) for their next project
  • Push the Web of things forward
  • Enable programmers (via DOM/CSS) to develop robotics and other IoT projects

Limitations

  • VC4 driver is still on development
  • Sometimes slow and buggy
  • Not all device capabilities are exposed through Web APIs
  • Small/integrated display not planned to support soon

Development Sprints

This is a 6 months project, starting November 2015 and finishing April 2016. The project is divided in two Sprints each one of 3 months.

Sprint A

In the first three months I will divide them in 3 phases. The main goal for this Q1 is have at the end a full build of Android Lollipop running in the Raspberry PI to continue with the port of Firefox OS components.

Phase 1

  • Prepare for Android Lollipop [DONE]
    • Identify the product name, code name, architecture, memory size, internal storage size, and platform architecture of the RPI 2. Collect any available existing source code to be used to make a build and add support for more hardware components.
  • Start AOSP tree for RPI 2 [DONE]
    • Generate the folders for RPI 2 device configuration
  • Android devices files for RP2 [DONE]
    • B2G build system uses AOSP that requires a repo with device configuration. Folder and files like AndroidBoard.mk, AndroidProducts.mk, BoardConfig.mk, device_rpi2.mk, recovery.fstab, and more will be created or adapted to RPI 2 architecture
  • Make RPI 2 kernel build from source [DONE]
    • Create a sync configuration for BoardConfig.mk file to build the kernel and any required kernel modules automatically.
  • Create manifest file for RPI 2 [DONE]
    • Create the rpi2.xml in b2g-manifest with all the sources for the first build

Phase 2

  • Add libraries [DONE]
    • In the device specific files during compilation process there are necessary includes to specific libraries
  • Configure modules [DONE]
    • In the device specific files is necessary to add external modules/files to be compiled and binary generated
  • Kernel configuration for RPI 2 [DONE]
    • Create a configuration specially for RPI 2 hardware components and ARM support

Phase 3

  • Generate working build [DONE]
    • Generate a first booting copy of Android Lollipop
  • Automated Android builds server [WORKING]
    • Jenkins or TaskCluster running to make automated builds of Android for the RPI 2.
  • Update documentation [DONE]
    • Update building steps and requirements with new ones for Raspberry PI 2

Sprint B

The next three months will divided in 4 phases. The main goal for Q2 is have a stable Firefox OS build with most of the hardware in the Raspberry supported (not fully support expected) and some tweaks for the UI to make it desktop friendly.

Phase 1

  • Gecko Port [DONE]
    • Having a basic Android base system the next priority is get Gecko working. This will help to identify easily more problems in the final ROM
  • Graphics support [DONE]
    • Use hardware default renderer.
    • In this project there is a challenge, and that’s the correct graphics support. RPI 2 has a VideoCore with a Broadcom BCM2739 that changed a lot in this latest version of the RPI 2. Will be necessary take a look of Broadcom reference guides
  • Update documentation [DONE]
    • Create page about Firefox OS architecture on the Raspberry PI 2

Phase 2

  • Input support [PARTIAL DONE]
  • Storage support [DONE]
    • Add support to SD Card recognition and USB storage devices
  • Connection support [PARTIAL DONE]
    • Work on WiFi and Ethernet support and add listeners for every time you plug or unplug it to the board. Usually it recognizes Ethernet connection if is connected before booting.
  • ADB Push [DONE]
    • Enable support to push apps by ADB connection

Phase 3

  • Generate complete/stable/usable Firefox OS build [DONE]
    • After all the base system is working and running, I will create builds to distribute and publish them.
  • Flashing files [DONE]
    • The Raspberry PI could not be flashed correctly with common Fastboot method, is necessary to create a filesystem that will be copied to the SD card
  • Update documentation [DONE]
    • Update flashing guide with steps for Raspberry PI 2

Phase 4

  • Gaia Port [DONE]
    • The Gaia port will be ready only when the graphics support is done, added to this, maybe will be some display/resolution limitations if the graphic support is not fully implemented or there are missing parts.
  • Remove unnecessary apps
    • Apps like Radio, Dialer, Messages and others are not necessary due Raspberry PI 2 itself doesn’t have hardware components to be used with those apps.
  • NOOBS installer [DONE]
    • Add support to install B2G using NOOBs installer
  • Update documentation [WORKING]
    • Blog post on Hacks Blog

Build From Source

Install the b2g build prerequisites. For the time being, only linux is officially supported as a build environment; you can use OS X but you'll have to manually partition your RPi's SD card for the first flash. Note that Ubuntu 12.04 is the best-supported development OS. If you're not running Ubuntu 12.04 on your development machine, you can install it as virtual machine and build in there. A b2g build environment consumes a fair amount of disk space, between 15-20 GB. Please make sure you have enough free space on your development machine (or VM).

Be sure of have those libraries installed to avoid compiling problems. On Ubuntu would be:

sudo apt-get install libfontconfig1 libXrender1 libXcomposite1 libgtk2.0-0 libxt6 unzip python-pip gettext libasound2

Installing pip dependencies for LibMesa:

pip install Mako --upgrade

To build b2g for your Raspberry Pi B+ 2, first download the b2g helper scripts

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

Next configure b2g for your Raspberry Pi B+ 2

cd B2G
./config.sh rpi2b-l

The config.sh step can take quite a while, because it downloads a large amount of data. Finally, build b2g

./build.sh

This step also takes some time, because it's building an entire operating system. When your build finishes, it's time to flash it onto an SD card for your RPi.

Prepare To Flash

WARNING: The process described here will erase all the data in your SD card. Be sure of not lose sensitive data inside the card.

You need a 4Gb SD card at least, if has more space better. Then create partitions and copy the files to let the Raspberry PI boot Firefox OS.

Configure UDEV rules for the SD card

By configuring udev rules for the specific SD card you are going to use for B2G, you will avoid the need to pass via root access (e.g., sudo dd) to be able to copy data. This also limits the risks of doing dd to the wrong device and mess with everything. This is documented for use with a sd card integrated reader, but this should be able to work elsewhere.

First, plug your sdcard and identify its serial:

$ udisksctl status
MODEL                     REVISION  SERIAL               DEVICE
--------------------------------------------------------------------------
[...]
SL08G                               0xa0442a9f           mmcblk0 

So in this case, /dev/mmcblk0 has serial number 0xa0442a9f. You can now unplug the card for now.

The populate a file in /etc/udev/rules.d/, let be its name 52-mmcblk.rules. And put the following content:

# µSD B2G
SUBSYSTEM=="block", SUBSYSTEMS=="mmc", DRIVERS=="mmcblk", ATTRS{serial}=="0xa0442a9f", MODE="0666", GROUP="plugdev"

Make sure you have ATTRS{serial}=="0xa0442a9f". Rule will match any mmcblk exposed device whose attribute serial is 0xa0442a9f. If it matches, then it will set permissions 0666 and group plugdev. Save this file, and issue a udev reload:

# udevadm control --reload

Now, if you replug the sdcard, it should be set with the proper permissions in /dev.

Partitions for the SD card

Create 4 partitions in next order and be careful with the sized of each one.

boot (Partition 1) = Size [48MB] = Format as fat32, tag bootable flag
system (Partition 2) = Size [537MB] = Format as new primary partition or ext4
cache (Partition 3) = Size [512MB] = format as ext4
data (Partition 4) = Size [Rest of free space] = format as ext4

Installing on the SD card

For a first time installation, you will have to flash all partitions. Images have been produced in the out/target/product/rpi2b directory and you should flash:

  1. boot.img to Partition 1
  2. system.img to Partition 2
  3. cache.img to Partition 3
  4. userdata.img to Partition 4

Please proceed with the dd command (and replace file with the proper file name):

dd if=file of=/dev/XpY bs=1m

Be sure of check that everything is copied successfully on the partition. For this port we create a userdebug build, so, everything is inside system image. Usually, X will be the name of your device and pY should be replaced by the partition number. For example, a SD card reader might expose this as: /dev/mmcblk0p1 for boot partition (Partition 1).

Remember to NOT flash cache and/or userdata images if you are just updating your system, except if you are sure or instructed to do so. Doing this will result in your data being erased.

Faster flashing

You can also make use of bmaptool to flash faster than with dd. bmaptool repo.

Produce bmap files

Once you have built the system, produce bmap files:

$ bmaptool create -o out/target/product/rpi2b/PARTITION.bmap out/target/product/rpi2b/PARTITION.img

You can do this for each PARTITION that we have: boot, system, cache and userdata.

Flashing with bmaptool

Then flash using bmaptool (here only boot partition):

$ sudo bmaptool copy out/target/product/rpi2b/boot.img /dev/mmcblk0p1
bmaptool: info: discovered bmap file 'out/target/product/rpi2b/boot.bmap'
bmaptool: info: block map format version 2.0
bmaptool: info: 12288 blocks of size 4096 (48.0 MiB), mapped 2358 blocks (9.2 MiB or 19.2%)
bmaptool: info: copying image 'boot.img' to block device '/dev/mmcblk0p1' using bmap file 'boot.bmap'
bmaptool: info: 100% copied
bmaptool: info: synchronizing '/dev/mmcblk0p1'
bmaptool: info: copying time: 0.6s, copying speed 16.1 MiB/sec

Using dd on the same partition reports a write speed of 5.0MiB/s.

Debugging

The Raspberry Pi serial port consists of two signals (a 'transmit' signal, TxD and a 'receive' signal RxD) made available on the GPIO header. To connect to another serial device, you connect the 'transmit' of one to the 'receive' of the other, and vice versa. You will also need to connect the Ground pins of the two devices together.

If you wish to connect your Pi to a PC with a USB port, the simplest option is to use a USB-to-serial cable which uses 3.3V logic levels (e.g. the Adafruit 954 cable, the FTDI TTL-232R-RPI cable, or the Debug Buddy ultimate serial port). These can be simply plugged in directly to the GPIO header (see illustration).

Linux terminal set up

If your PC is running Linux, you will need to know the port name of its serial port:

  • Built-in (standard) Serial Port: the Linux standard is /dev/ttyS0, /dev/ttyS1, and so on
  • USB Serial Port Adapter: /dev/ttyUSB0, /dev/ttyUSB1, and so on.
    • Some types of USB serial adapter may appear as /dev/ttyACM0 ...

You will need to be a member of the dialout group to access this port (for later releases the required group is tty). You can check which is needed with:

ls -l /dev/ttyUSB0

and you will see something like "crw-rw----T 1 root dialout ...", c means character device, and root can 'read,write' and the group dialout can 'read,write' to the port and everyone else cannot access it.

To find out if you, the current user, is in the group dialout, use the command:

id

If you do not see dialout listed, add yourself with the command

sudo usermod -a -G dialout username

You then have a choice of terminal emulation programs:

Using GNU Screen

Enter the command below into a terminal window

 screen port_name 115200

To exit GNU screen, type Control-A k.

Using Minicom

Run minicom with the following parameters:

minicom -b 115200 -o -D Port_Name

You can exit minicom with Control-A x

Windows terminal set-up

Users of Windows Vista or later will need to download a terminal program, for instance PuTTY, or TeraTerm. Users of XP and below can choose between using PuTTY and the built-in Hyperterminal.

PuTTY users simply need to choose 'serial', select the correct COM port and set the speed, as shown in the dialog below.

File:Putty-settings.png

If you are unsure of the COM port, run [Device Manager] and look under 'Ports'. USB-attached serial adapters should have the name of the adapter shown (the Adafruit cable comes up as 'Prolific USB-to_Serial Comm Port'.

Mac OS X terminal set-up

OSX includes terminal emulation software that you can use from the command line, so we only need to install the USB drivers for the cable.

[Check out the most recent Mac Driver from prolific]

If using Lion or Mountain Lion or later OS X, try this driver here http://changux.co/osx-installer-to-pl2303-serial-usb-on-osx-lio

Both downloads are standard Mac installers. Accept all defaults when prompted.

Using Screen

Open a Terminal window and issue the command:

screen /dev/cu.usbserial 115200

The device will have a slightly different name to mine. So, type the line above as far as "cu." then press the TAB key to auto-complete to whatever your device is called, before adding 115200 (which is the baud rate) to the end.

Connect All The Things

The Console lead has four female connections that can be plugged directly onto the GPIO header of the Raspberry Pi. The Adafruit USB console cable has 3.3V logic, so its safe to use with your Pi.

File:RPi2B Debug Kit.jpg

For this experiment, the serial lead is going to power the Raspberry Pi. So, DO NOT attach the Pi's USB power adapter. If you would rather power the Pi from your USB power adapter then leave the Red lead from the Serial lead un attached.

The important thing here is to only power it from one source, the USB power adaptor or the Console Lead BUT NOT BOTH.

Attach the leads as shown below:

Rpi2-serial-cable-connection.jpg

The connections are to the outside pin connections of the GPIO header.

  • The red lead should be connected to 5V,
  • The black lead to GND,
  • The white lead to TXD.
  • The green lead to RXD.

Now plug in the USB lead and you will see the Pi's power LED should light.

Boot messages

If your connection is set up correctly, when the Pi is booted you should see many messages as the system comes up:

Uncompressing Linux... done, booting the kernel.
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 3.2.27+ (dc4@dc4-arm-01)
[    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[    0.000000] Machine: BCM2708
[    0.000000] Memory policy: ECC disabled, Data cache writeback
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 113792

and so on. Eventually, you should see a login prompt:

shell@rpi2b:/ $

You can then log in as you would with a keyboard and screen.

Keeping Log Copy

If you are debugging, maybe you will be interested on keep a copy of the logs. If you are using screen you can do it adding -L flag. For example:

screen -L /dev/cu.usbserial 115200

Then you will have a file named screenlog.0 with a record of all the logs you got when you run screen command.

Need Help?

  • IRC channel #fxos (Ping Gioyik)
  • Fill a bug on bugzilla
  • Send an email to fxos mailing list