Hacking b2g on Raspberry Pi: Difference between revisions

Line 161: Line 161:
== Preparing a development environment ==
== Preparing a development environment ==


To hack b2g on the RPi, you'll want to set up a few thingsFirst, a serial console is strongly recommended.  (A serial console is basically required for 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.
To hack b2g on the RPi, you'll need to create an adb connectionadb is the "android debug bridge" over which diagnostic output is received and development commands are sentUsually 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.)


<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.
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)


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
  netcfg


  sudo apt-get install minicom
Let's call your RPi's address <code>$IP</code>. Connect adb by running the following command on your host machine


Then connect to your RPi using the command
adb connect $IP:5555


minicom -b 115200 -o -D /dev/ttyUSB0
To test your adb connect, run the following command on your host


(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.
  adb logcat


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)").
You should see a long list of diagnostic messagesPressing Ctrl-c stops the logcat output.


You must create an adb connection for your RPiadb is the "android debug bridge" over which diagnostic output is received and development commands are sentUsually 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.)
In addition to adb, a serial console is strongly recommendedA 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 theseThe 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.


You can connect adb through the RPi's ethernet port, however. To connect adb over ethernet, you need to find out your RPi's IP address on your LAN.  You can do this by either looking at your network router's client table, or running the following command on your RPi's serial console
<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.


  netcfg
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


Once you know your RPi's IP address, connect adb by running the following command on your host machine
sudo apt-get install minicom


adb connect $IP:5555
Then connect to your RPi using the command


replacing <code>$IP</code> with your RPi's IP address, of course.  (5555 is the port that the adb server on your RPi listens on.)  To test your adb connect, run the following command on your host
minicom -b 115200 -o -D /dev/ttyUSB0


  adb logcat
(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.


You should a long list of diagnostic messagesPressing Ctrl-c stops the logcat output.
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 ==
Confirmed users
699

edits