canmove, Confirmed users, Bureaucrats and Sysops emeriti
960
edits
(→Status) |
m (added Category:Raspberry Pi using HotCat) |
||
(33 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
This page is intended for folks who are interested in building and running b2g on Raspberry Pi devices. | This page is intended for folks who are interested in building and running [[Fxos_on_RaspberryPi|b2g on Raspberry Pi devices]]. | ||
<font color="red">'''NBB'''</font>: parameters like RAM allocation for video memory are currently tuned for Raspberry Pis with 512MB RAM (Model B rev2 and Model B+). A 256MB Pi should work but performance may not be optimal. | <font color="red">'''NBB'''</font>: parameters like RAM allocation for video memory are currently tuned for Raspberry Pis with 512MB RAM (Model B rev2 and Model B+). A 256MB Pi should work but performance may not be optimal. | ||
Line 7: | Line 7: | ||
b2g on the Raspberry Pi is still very much a work in progress. Eventually a nice compability matrix will be posted. Also see {{bug|1001404}} for overall tracking. For now, the worst bugs to watch out for are | b2g on the Raspberry Pi is still very much a work in progress. Eventually a nice compability matrix will be posted. Also see {{bug|1001404}} for overall tracking. For now, the worst bugs to watch out for are | ||
* graphics | * OpenGL rendering is not supported yet. This means graphics performance is worse than it will be eventually. Also, WebGL won't work correctly either. {{bug|1084624}} | ||
* the output resolution of the RPi is artificially limited to 480p for the time being. {{bug|1072148}} | * the output resolution of the RPi is artificially limited to 480p for the time being. {{bug|1072148}} | ||
* | * audio output doesn't seem to be fully working {{bug|1072499}} | ||
* system capabilities like camera and GPIO access are not yet supported by the b2g runtime. | * system capabilities like camera and GPIO access are not yet supported by the b2g runtime. | ||
* | |||
== Flash an existing build == | |||
First [https://www.dropbox.com/s/4udfp704u2hmemx/ffos-rpi-04.img.tar.bz2?dl=0 download the build]. Next extract it as follows | |||
tar jxvf ffos-rpi-*.img.tar.bz2 | |||
That will produce a file called <code>ffos-rpi-*.img</code>. Now insert your SD card into a card reader/writer. Your OS should add your SD card as a device called something like <code>/dev/mmcblk0</code>, <code>/dev/sdc</code>, or <code>/dev/disk2</code>. Let's call that device <code>$disk</code> below. | |||
<font size="5" color="red">WARNING WARNING WARNING</font>: the remaining steps with <font size="5">COMPLETELY AND PERMANENTLY ERASE YOUR SD CARD</font>. Be extra-triple-careful that you found the right device for your SD card. | |||
Finally, run | |||
sudo dd bs=4M if=ffos-rpi-*.img of=$device | |||
Note: this disk image is pre-partitioned for a 4GB disk. If you have a larger SD card and want to allocate the remaining space for your SDCARD partition, then resize that partition in a tool like <code>gparted</code>. | |||
== Enable touchscreen output == | |||
b2g on the Raspberry Pi supports a class of extension touchscreens. So far, only the [https://www.adafruit.com/products/1601 PiTFT] has been tested, so that model is strongly recommended. The default prebuilt b2g image, and images you build yourself, include support for touchscreen output by default. However, it's disabled by default. | |||
Once you've attached a touchscreen (by which we mean the PiTFT) to your Raspberry Pi (when it's powered off, of course), you can enable it by running the following command through adb (see below) | |||
adb shell setprop persist.fbtft adafruitts | |||
This restarts b2g and has it output to the PiTFT device. At any time you can revert to HDMI output by running | |||
adb shell setprop persist.fbtft none | |||
This setting persists across reboots, as you would expect. | |||
Note: if you're configured your RPi to output through the touchscreen, and you disconnect the touchscreen (when the RPi is powered off, of course), then after rebooting the RPi may still try to output through the nonexistent screen. This bug is not yet understood and seems to be a kernel issue. But you can still follow the directions above to revert to HDMI output. | |||
Touchscreen input (using the PiTFT) seems not to work by now. | |||
== Building b2g for RPi == | == Building b2g for RPi == | ||
Install the [https://developer.mozilla.org/en-US/Firefox_OS/Firefox_OS_build_prerequisites b2g build prerequisites]. For the time being, only linux is supported as a build environment. 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. | Install the [https://developer.mozilla.org/en-US/Firefox_OS/Firefox_OS_build_prerequisites 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). | 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). | ||
Line 32: | Line 61: | ||
./config.sh rpi | ./config.sh rpi | ||
The config.sh step can take quite a while, because it downloads a large amount of data. Once that finishes, build b2g | The config.sh step can take quite a while, because it downloads a large amount of data. Once that finishes, you need to apply a patch to the gecko checkout (for now; the patches are making their way through reviews etc.). [https://www.dropbox.com/s/j5bbuifod7pjusi/ffos-rpi-04.patch?dl=0 Download the patch from here] and then apply to your <code>B2G/gecko</code> subdirectory by running the command | ||
(cd gecko && git apply [the patch you downloaded]) | |||
Note: if <code>git apply</code> fails, you may need to use <code>patch -p1</code>. Also, the contents of this patch should shrink over time as changes are landed upstream. So after you <code>repo sync</code> your checkout, you may need to return to this page and apply a new version of the patch. Hopefully, soon no extra patches will be needed. | |||
Next, either copy the files <code>device/rpi/rpi/custom-settings.json</code> and <code>device/rpi/rpi/custom-prefs.js</code> in your <code>gaia/build/config/</code> directory, or --- if you already have custom settings or prefs --- append the contents of those files to your existing custom-* files. | |||
Finally, build b2g | |||
./build.sh | ./build.sh | ||
Line 42: | Line 79: | ||
== Preparing to flash b2g onto your SD card == | == Preparing to flash b2g onto your SD card == | ||
Note: you may find it more convenient to simply flash an existing image, following the instructions above. | |||
Flashing an image requires the following | Flashing an image requires the following | ||
Line 51: | Line 88: | ||
An Ubuntu 12.04 OS is recommended for ''building'', but any linux distribution is OK for ''flashing'' an image. If you're running Ubuntu 12.04 in a VM, that's perfectly fine: you can mirror your build into your host OS and then flash from your host. | An Ubuntu 12.04 OS is recommended for ''building'', but any linux distribution is OK for ''flashing'' an image. If you're running Ubuntu 12.04 in a VM, that's perfectly fine: you can mirror your build into your host OS and then flash from your host. | ||
On Ubuntu 12.04, you may need to [http://ubuntuportal.com/2012/07/quick-tips-easy-way-to-disable-auto-mount-on-ubuntu-12-04-lts.html disable automounting of USB drives]. | |||
If you built b2g in your host OS, you can skip the following instructions. | If you built b2g in your host OS, you can skip the following instructions. | ||
Line 104: | Line 143: | ||
You only need to follow these steps once. After your SD card is prepared for the first time, you can update it with new build files without removing it from your RPi. Those partial-update steps are described below. | You only need to follow these steps once. After your SD card is prepared for the first time, you can update it with new build files without removing it from your RPi. Those partial-update steps are described below. | ||
Note: you may find it more convenient to simply flash an existing image, following the instructions above. | |||
To flash an SD card with a B2G build for the first time, run the commands below. (If you built in a guest VM, be sure to follow the steps above to mirror your build into your host machine.) | To flash an SD card with a B2G build for the first time, run the commands below. (If you built in a guest VM, be sure to follow the steps above to mirror your build into your host machine.) | ||
Line 111: | Line 152: | ||
You have to run the flash.sh command as superuser because it directly writes to your SD card block device. Follow the instructions and prompts presented by <code>flash.sh</code> to complete the setup process. | You have to run the flash.sh command as superuser because it directly writes to your SD card block device. Follow the instructions and prompts presented by <code>flash.sh</code> to complete the setup process. | ||
The script attempts to auto-detect your SD card. If it fails, then simply pass your SD card device to the script manually as follows | |||
sudo DISK="/dev/your-sd-card" ./flash.sh -f | |||
When the flashing script finishes, your SD card is ready. Congratulations! Remove it from your host machine, insert it into your Raspberry Pi and start up b2g! :) | When the flashing script finishes, your SD card is ready. Congratulations! Remove it from your host machine, insert it into your Raspberry Pi and start up b2g! :) | ||
Line 116: | Line 161: | ||
== Preparing a development environment == | == Preparing a development environment == | ||
To hack b2g on the RPi, you'll | To hack b2g on the RPi, you'll need to create an adb connection. adb is the "android debug bridge" over which diagnostic output is received and development commands are sent. Usually an adb connection is made over USB, but the RPi's USB ports can't be configured for slave mode. (On Models B and newer.) | ||
You can connect adb over TCP/IP, though. You have the option of connecting over wifi or ethernet. To connect over wifi, first join the wireless LAN that your host machine is on. | |||
<font size="5" color="red">WARNING WARNING WARNING</font>: FFOS builds for the RPi are intended for DEVELOPERS. They are <font size="5" color="red">WILDLY INSECURE</font>. Don't connect your RPi to a network on which you don't mind it getting <font size="5" color="red">completely pwned</font>. | |||
Next, find your wifi card's IP address through the gaia settings app. Call this address <code>$IP</code>. Finally, on your host machine, run | |||
adb connect $IP:5555 | |||
(5555 is the port that the adb server on your RPi listens on.) | |||
Alternatively, to connect over ethernet, first connect your RPi's ethernet cable to your LAN. The <em>SAME CAVEATS ABOUT SECURITY</em> apply. Next, boot up your RPi and find out its IP address on your LAN. You can do this by either looking at your network router's client table (easy), or running the following command on your RPi's serial console (a little harder; see instructions below on how to set up a serial console) | |||
netcfg | netcfg | ||
Let's call your RPi's address <code>$IP</code>. Connect adb by running the following command on your host machine | |||
adb connect $IP:5555 | adb connect $IP:5555 | ||
To test your adb connect, run the following command on your host | |||
adb logcat | adb logcat | ||
You should a long list of diagnostic messages. Pressing Ctrl-c stops the logcat output. | You should see a long list of diagnostic messages. Pressing Ctrl-c stops the logcat output. | ||
In addition to adb, a serial console is strongly recommended. A serial console is basically required for anyone doing networking or kernel development. You can purchase a serial-to-USB or serial-port connector for your RPi, [https://www.adafruit.com/products/954 for example this one from adafruit]. Some RPi kits also include one of these. The adapter shown above requires you to connect the black lead to pin 6 (ground), the white lead to pin 8 (GPIO14, UART0_TXD), and the green lead to pin 10 (GPIO15, UART0_RXD). You don't need to connect the red lead if your RPi already has a power source. | |||
<font size="5" color="red">'''WARNING'''</font>: be very careful that you connect the leads to the correct pins! At least one developer has burned out a USB-to-serial adapter by connecting the wrong pins. | |||
The b2g kernel is pre-configured to open a serial console for the RPi, so all you need to do is plug the USB cable into your host machine and start up a terminal emulator. The <code>minicom</code> program works well. On ubuntu, install minicom with the command | |||
sudo apt-get install minicom | |||
Then connect to your RPi using the command | |||
minicom -b 115200 -o -D /dev/ttyUSB0 | |||
(Replacing <code>/dev/ttyUSB0</code> with the device assigned to your USB-to-serial adapter, if it's not assigned that name.) You should then see terminal output and get a shell prompt. | |||
Note: you must run minicom in a "smart terminal". minicom doesn't work when run inside an emacs shell, and it errors out with a somewhat cryptic message ("No cursor motion capability (cm)"). | |||
== Rebuilding b2g and updating your RPi == | == Rebuilding b2g and updating your RPi == | ||
Line 166: | Line 225: | ||
You can also flash your SD card anew at any time by following the instructions above. But this should usually not be necessary. | You can also flash your SD card anew at any time by following the instructions above. But this should usually not be necessary. | ||
[[Category:Firefox OS]] | |||
[[Category:Raspberry Pi]] |