User:AndreasJellinghaus/GetStarted

From Openmoko

< User:AndreasJellinghaus(Difference between revisions)
Jump to: navigation, search
 
m (linkfix)
 
(8 intermediate revisions by one user not shown)
Line 1: Line 1:
= Start developing applications for OpenMoko! =
+
== Start developing applications for OpenMoko! ==
 +
 
 +
Warning: this is my writeup from yesterday. I couldn't verify it today, because buildhost.openmoko.org is down.
  
 
Here is what you need to do.
 
Here is what you need to do.
Line 15: Line 17:
 
stable, but I don't know where to find such a thing.
 
stable, but I don't know where to find such a thing.
  
 +
Note: before running dfu-util you need your moko in uboot mode. To do that turn off your moko
 +
(if nothing else helps, remove usb and battery), and turn it on again - while pressing AUX,
 +
i.e. the upper left buttom. you will see a boot menu with "factory reset" and similar options.
 +
OpenMoko needs to be in this menu for below procedure to work.
 
<pre>
 
<pre>
 
BASE=http://buildhost.openmoko.org/OM2007.2/tmp/deploy/glibc/images/neo1973/
 
BASE=http://buildhost.openmoko.org/OM2007.2/tmp/deploy/glibc/images/neo1973/
Line 29: Line 35:
 
./dfu-util -a rootfs -R -D openmoko-devel-image-fic-gta01.jffs2
 
./dfu-util -a rootfs -R -D openmoko-devel-image-fic-gta01.jffs2
 
</pre>
 
</pre>
 +
(see [[Flashing the Neo 1973]] for details)
  
 
Next you need to get network access over USB to work for you. On my Ubuntu 7.10 I don't need to
 
Next you need to get network access over USB to work for you. On my Ubuntu 7.10 I don't need to
Line 36: Line 43:
 
route add -host 192.168.0.202/32 dev usb0
 
route add -host 192.168.0.202/32 dev usb0
 
</pre>
 
</pre>
 +
(see [[USB_Networking]] for details)
  
 
Now I can SSH to my Moko with
 
Now I can SSH to my Moko with
Line 46: Line 54:
 
<pre>
 
<pre>
 
cat > hello_world <<EOF
 
cat > hello_world <<EOF
#!/usr/bin/python
+
#!/usr/bin/env python
  
# Load in pygtk and gtk
 
 
import pygtk
 
pygtk.require('2.0')
 
 
import gtk
 
import gtk
+
 
# Define the main window
+
def on_button_clicked(*args):
+
    print "Hello World"
class Whc:
+
 
    def __init__(self):
+
window = gtk.Window()
        # Window and framework
+
window.connect("delete_event", gtk.main_quit)
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+
window.set_border_width(10)
        self.window.connect("destroy", self.destroy)
+
button = gtk.Button("Hello World")
+
button.connect("clicked", on_button_clicked)
        # A Button, with an action
+
window.add(button)
        # Add it to the geometry
+
window.show_all()
        # show the button
+
gtk.main()
        self.button = gtk.Button("First Button")
+
        self.button.connect("clicked", self.hello, None)
+
        self.window.add(self.button)
+
        self.button.show()
+
+
        # Show the window
+
        self.window.show()
+
+
# Callback function for use when the button is pressed
+
+
    def hello(self, widget, data=None):
+
        print "Hello World"
+
+
# Destroy method causes appliaction to exit
+
# when main window closed
+
+
    def destroy(self, widget, data=None):
+
        gtk.main_quit()
+
+
# All PyGTK applicatons need a main method - event loop
+
+
    def main(self):
+
        gtk.main()
+
+
if __name__ == "__main__":
+
    base = Whc()
+
    base.main()
+
 
EOF
 
EOF
 
chmod 0755 ./hello_world
 
chmod 0755 ./hello_world
Line 100: Line 77:
 
DISPLAY=:0 ./hello_world
 
DISPLAY=:0 ./hello_world
 
</pre>
 
</pre>
 +
(if you press the button you will see "Hello World" on the console. Use ctrl-c on the console to abort.)
  
 
Issues not handled yet:
 
Issues not handled yet:
Line 105: Line 83:
 
* packaging of a new application
 
* packaging of a new application
 
* submitting of a new application to the openmoko team for inclusion
 
* submitting of a new application to the openmoko team for inclusion
 +
 +
=== Notes ===
 +
* see [[Application_Development_Crash_Course]] if you want to create C/C++ applications, and also for packaging etc.
 +
* above pygtk example is from http://live.gnome.org/PyGtkQuickIntro
 +
* pygtk home page is http://www.pygtk.org/ and it has an [http://www.pygtk.org/pygtk2tutorial/index.html official tutorial] and [http://www.pygtk.org/reference.html reference documentation] and a [http://faq.pygtk.org/index.py?req=index faq]

Latest revision as of 16:52, 22 October 2008

[edit] Start developing applications for OpenMoko!

Warning: this is my writeup from yesterday. I couldn't verify it today, because buildhost.openmoko.org is down.

Here is what you need to do.

First, you need to have a recent image on your moko. Beware: this can brick your hardware, don't do any of this unless, you know what you are doing, and willing to take the risk.

In this example I don't update the uboot bootloader - you should do so only if you need to. Mine is fine. Also always only use tested versions of the bootloader - you can fix everything else if the bootloader is still working (as far as I know). But if the bootloader is broken, you need a debug board to fix the issue.

Warning: The URL below points to the images of the day. Sometimes they work, sometimes they don't. It would be much better to point to some tested release that is at least somehow stable, but I don't know where to find such a thing.

Note: before running dfu-util you need your moko in uboot mode. To do that turn off your moko (if nothing else helps, remove usb and battery), and turn it on again - while pressing AUX, i.e. the upper left buttom. you will see a boot menu with "factory reset" and similar options. OpenMoko needs to be in this menu for below procedure to work.

BASE=http://buildhost.openmoko.org/OM2007.2/tmp/deploy/glibc/images/neo1973/

wget $BASE/dfu-util
wget $BASE/uImage-neo1973-latest.bin
wget $BASE/openmoko-devel-image-fic-gta01.jffs2

chmod +x dfu-util

sudo bash
# ./dfu-util -a u-boot -R -D uboot-gta01bv4-latest.bin  # not needed
./dfu-util -a kernel -R -D uImage-neo1973-latest.bin
./dfu-util -a rootfs -R -D openmoko-devel-image-fic-gta01.jffs2

(see Flashing the Neo 1973 for details)

Next you need to get network access over USB to work for you. On my Ubuntu 7.10 I don't need to patch the kernel, load modules or anything like that, all I need to do is:

ifconfig usb0 192.168.0.200 netmask 255.255.255.0
route add -host 192.168.0.202/32 dev usb0

(see USB_Networking for details)

Now I can SSH to my Moko with

ssh root@192.168.0.202
Password is "root"

and now I can create a simple hello world application:

cat > hello_world <<EOF
#!/usr/bin/env python

import gtk

def on_button_clicked(*args):
    print "Hello World"

window = gtk.Window()
window.connect("delete_event", gtk.main_quit)
window.set_border_width(10)
button = gtk.Button("Hello World")
button.connect("clicked", on_button_clicked)
window.add(button)
window.show_all()
gtk.main()
EOF
chmod 0755 ./hello_world

and start it

DISPLAY=:0 ./hello_world

(if you press the button you will see "Hello World" on the console. Use ctrl-c on the console to abort.)

Issues not handled yet:

  • menu files so it can be started via the launcher
  • packaging of a new application
  • submitting of a new application to the openmoko team for inclusion

[edit] Notes

Start developing applications for OpenMoko!

Here is what you need to do.

First, you need to have a recent image on your moko. Beware: this can brick your hardware, don't do any of this unless, you know what you are doing, and willing to take the risk.

In this example I don't update the uboot bootloader - you should do so only if you need to. Mine is fine. Also always only use tested versions of the bootloader - you can fix everything else if the bootloader is still working (as far as I know). But if the bootloader is broken, you need a debug board to fix the issue.

Warning: The URL below points to the images of the day. Sometimes they work, sometimes they don't. It would be much better to point to some tested release that is at least somehow stable, but I don't know where to find such a thing.

BASE=http://buildhost.openmoko.org/OM2007.2/tmp/deploy/glibc/images/neo1973/

wget $BASE/dfu-util
wget $BASE/uImage-neo1973-latest.bin
wget $BASE/openmoko-devel-image-fic-gta01.jffs2

chmod +x dfu-util

sudo bash
# ./dfu-util -a u-boot -R -D uboot-gta01bv4-latest.bin  # not needed
./dfu-util -a kernel -R -D uImage-neo1973-latest.bin
./dfu-util -a rootfs -R -D openmoko-devel-image-fic-gta01.jffs2

Next you need to get network access over USB to work for you. On my Ubuntu 7.10 I don't need to patch the kernel, load modules or anything like that, all I need to do is:

ifconfig usb0 192.168.0.200 netmask 255.255.255.0
route add -host 192.168.0.202/32 dev usb0

Now I can SSH to my Moko with

ssh root@192.168.0.202
Password is "root"

and now I can create a simple hello world application:

cat > hello_world <<EOF
#!/usr/bin/python

# Load in pygtk and gtk
 
import pygtk
pygtk.require('2.0')
import gtk
 
# Define the main window
 
class Whc:
    def __init__(self):
        # Window and framework
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("destroy", self.destroy)
 
        # A Button, with an action
        # Add it to the geometry
        # show the button
        self.button = gtk.Button("First Button")
        self.button.connect("clicked", self.hello, None)
        self.window.add(self.button)
        self.button.show()
 
        # Show the window
        self.window.show()
 
# Callback function for use when the button is pressed
 
    def hello(self, widget, data=None):
        print "Hello World"
 
# Destroy method causes appliaction to exit
# when main window closed
 
    def destroy(self, widget, data=None):
        gtk.main_quit()
 
# All PyGTK applicatons need a main method - event loop
 
    def main(self):
        gtk.main()
 
if __name__ == "__main__":
    base = Whc()
    base.main()
EOF
chmod 0755 ./hello_world

and start it

DISPLAY=:0 ./hello_world

Issues not handled yet:

  • menu files so it can be started via the launcher
  • packaging of a new application
  • submitting of a new application to the openmoko team for inclusion