How to connect your Firefox OS phone to a Linux computer for app pushing

IMG-20130420-WA0001

I was truly exited when Mozilla handed the first Geeksphone’s Firefox OS developer preview phones on the Madrid App Workshop last Saturday. They had showed us how, with the push a button, you could push apps from the 3.0 version of the Firefox OS simulator to the phone, so imagine my surprise when I plug it into my Linux running laptop, see the Device connected message, click the “push” button and… nothing happens. The Device connected message would keep showing then on, even when I unplugged the device.

After a short conversation with the Mozilla Engineers about what the simulator’s connection ran behind the curtain and some effort I managed to make it work, and I want to document how so future developers could go smoothly from taking the phone out of the box to trying your HTML5 app.

Short version for experienced android devs:

The simulator’s dashboard runs some sort of adb version to push manifests and files into the phone. If you can get adb to correctly recognize the dev phone (it shows up correctly in adb devices) the simulator’s dashboard should work correctly with it as well.

If you do not know that adb is or how to do what I stated above, keep reading.

What is adb? Where do I get that?

If you are not into making android apps you are probably scratching your head at the acronym. It stands for Android Debug Bridge and it is one, if not, the most important tool for pushing and debugging apps at an Android Device. If you know all this and have a version of adb running, move on to the next section. If not I will give a short explanation of what you need just to get the Firefox OS dev phone connection running.

  1. Go to http://developer.android.com/sdk/index.html and download the Android SDK for linux.
  2. Extract the downloaded tar.bz2 file somewhere you can remember.
  3. Open up your terminal and navigate to the extracted folder. Look for the platform-tools folder inside the sdk folder and navigate there.
  4. Execute ./adb devices, and something like this should show up:

not recognized

This means your phone is not being recognized.

So how do I make it recognize the phone?

By adding a line to the /etc/udev/rules/51-android.rules file. The line goes as follow:

SUBSYSTEM==”usb”, ATTR{idVendor}==”HERE_GOES_VENDOR_ID”, ATTR{idProduct}==”HERE_GOES_DEVICE_ID”, MODE=”0666″

In order to find the device and vendor ir for our Firefox OS dev phone we can us the lsusb command on Linux and get something like this:

Screenshot from 2013-04-22 20:13:55

My Keon is recognized as a Qualcomm device with an vendor id of 05c6 and a device id of 8013. If you do not know which of all the devices is the phone I recommend unpluging the phone, running lsusb command again, and looking for which line is missing. For me all I needed was to add line:

SUBSYSTEM==”usb”, ATTR{idVendor}==”05c6″, ATTR{idProduct}==”8013″, MODE=”0666″

Remember, if your phone is not a Keon it may be different.

Use vim, nano, geddit or your favorite text editor for this. Remember to use it a super user.

With that done, reboot your computer. When you log back, navigate to the android sdk and run ./adb devices again you should see the line:

Screenshot from 2013-04-22 19:17:54

This means you are done. Go back to your simulator’s dashboard and push your app. Remember to enable remote debugging on your Firefox OS phone and keep an eye for the notifications on screen when pushing anything. Reboot your phone after a successful push and you are ready to run it.

Happy coding!

Edit 9-may-2013:  I recently decided to build and flash the latest Firefox OS (using these instructions) in order to try several things that the bugs in the included version did not allow. I was surprised when the app push on the simulator dashboard stopped working again, even tough adb was still making its work correctly and the device connected message showed, nothing happened when push was pressed. Some tinkering later I realized there is a bug that affects the remote debugger and, by extension, the app pushing ability. The Keon build must have had the workaround pre-set. Fixing this is easy:

With your phone plugged in. Go to wherever you have adb downloaded and execute:

./adb shell

Congratulations, you are now in a shell inside your phone. Now execute:

ls /data/b2g/mozilla/

Look for a folder with an extension of .default. The name is diferent. Once you take note of the name exit the shell:

exit

And run the following to copy your preferences file into your computer:

./adb pull /data/b2g/mozilla/INSERTNAME.default/prefs.js prefs.js

Please remember to replace INSERTNAME with the actual name of your default folder. Now opne the copied file with your favorite text editor (gedit in my case):

gedit prefs.js

And add the following line at the bottom of the file:

user_pref("marionette.defaultPrefs.enabled", false);

Save and the push back the file into your phone:

adb push prefs.js /data/b2g/mozilla/INSERTNAME.default/prefs.js

Done! Reboot your phone and pushing apps should work right now.

About these ads

An upcoming web developer and android app-maker with an interest on using reliable tech in creative ways, open source projects and start-ups.

Tagged with: , , , , ,
Posted in developer tips
One comment on “How to connect your Firefox OS phone to a Linux computer for app pushing
  1. very usefull information to keon users

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: