Quick installation of the Fremantle SDK (Maemo 5). Install Qt 4.6. Run and debug in the emulator and on the device
Good day habrasociety. Continuing a series of programming articles for Maemo. Earlier, I wrote how to install and configure the SDK in the “hybrid” mode - we write on the native OS, and we collect and run it on the virtual machine.
Some thought it was hard to start programming for Maemo. That’s why I decided to start by demonstrating the easy way “Easy way” © to show how easy it is to get started. Further, given the release of the official release of t 4.6.2 for maemo 5 , I will show how to put this release on the Fremantle SDK. I will demonstrate debugging in the emulator. And most importantly, how to debug the application on the device using a regular network connection and USB connection.
The result of our work will be such a window on the device:
Note: Scratchbox is used as an IDE, since this is a Fremantle SDK. QtQreator can be used, but as such Fremantle support is not and will not be. Why? Yes, because they make it support the new, cross-platform SDK - MADDE, which I already mentioned (and I will mention in the conclusion).
Well, since you are under the cut, it means you decided to read my article.
All videos here are not of very good quality, on YouTube you can watch them in HD format, just double-click on the video to do this.
Let's start from the beginning, at this point, suppose that you either didn’t read the previous article or decided not to go through thethorny, slightly long way to install the SDK. But if you went the first way, then as a prize of the result you would get a convenient environment for development in your native OS (personally, my opinion of course).
But ifyou are lazy for some reason the option described by me does not suit you, I suggest another, easier and simpler.
If you already have the Fremantle SDK, you can skip this step and go directly to the second step.
To install the SDK you need to download:
and then proceed according to the video, everything seems to be clear there:
Notes: Install add-ons for the guest OS directly from VirtualBox itself, and not those included in the SDK itself (link to them on the desktop). They do not need to be downloaded anywhere, they already come with VirtualBox itself and the distribution is connected as a virtual disk image.
As you can see, installing, configuring, and launching the application takes less than 10 minutes, unlike the method I described earlier. Everything is very simple
From this point on, it doesn’t matter if you use the installation method proposed from the previous article or from point 1. Everything is relevant for both installation cases.
here the sequence is as follows:
First, we remove the Qt 4.5 installed in the SDK.
and then install the official Qt 4.6.2 for Maemo5:
And you need to do this for both purposes ARMEL and x86. The x86 target is needed to run and debug in the emulator, and the ARMEL target is to run and debug on the device (cross-compilation). You can switch between goals in scratchbox using the menu:
Now attention !!!! The network in scratchbox may not work (there may be errors with the network when running the command to install packages). This is due to minor problems in scratchbox. They are easy to eliminate. To do this, outside the scratchbox, you need to copy the resolv.conf file that you received via DHCP or generated in the process of setting up a static network (explicitly or indirectly through utilities) for each purpose and for the scratchbox itself:
Also keep in mind that in case of using a proxy, you need to export environment variables:
You can put this into a separate script or add these lines to the ~ / .bashrc file or specify a proxy for apt-get:
In this case, apt-get will work through this proxy.
Also, before installing packages, Qt will not be out of place to update packages for each target in scratchbox (in general, all commands starting with “fakeroot” are executed only inside scratchbox, and sudo outside it):
After that, we create the Qt project - “Qt Hello World” and select all targets for ARMEL and X86 as build configurations (after all, we plan to debug both in the emulator and on the device).
This is not enough to build a Qt project, the fact is that ESBox does not know about the existence of official Qt, which is installed in / opt / qt4-maemo5, unlike the unofficial Qt, which integrates into the system (it is scattered in different directories, qmake is in / usr / local / bin, include is in / usrt / include / qt4, etc.). In principle, the behavior of the unofficial Qt package is standard, but in this case it is difficult to deal with several versions, which is probably why Qt-shniki decided not to scatter the package throughout the system. There are two methods to fix this: when creating a project, just change all the paths to Include and qmake, but you can make it easier, or rather make symbolic links:
for qmake (I have a typo in the comments on the video, instead of “dev”, it’s necessary to write “Bin”, alas, I can’t fix it for technical reasons):
verify that qmake is available without specifying a path:
a prompt for qmake should appear, and the version of Qt is indicated at the beginning, there should be 4.6.2
for include:
it is necessary for ESBox.
You need to perform this operation for each purpose of scratchbox assembly (ARMEL and X86), so that it doesn’t turn out that in the terminal you are debugging with one version of Qt, and on the device with another :-). You remember that to switch the target in scratchbox you need to use the sb-menu utility.
Then we build our application for the emulator (X86-develop) and create a debug configuration (local). We start, we agree to the invitation to launch the emulator. You will see that the program stopped at the entry point to the "main" function and earned HelloWorld. Everything works well. Hurrah!!!
Now run debugging on the device. First I decided to demonstrate debugging over the network. All that is needed is to install the gdb server on the device (for debugging) and ssh server (and the client will not hurt either).
Open SSH client and server can be installed using this metapackage: maemo.org/downloads/product/Maemo5/openssh . It is located in the repository repository.maemo.org/extras . You can spy on how to install a new repository in my article. You can also follow the link to the application and click the “Install” button directly on the device.
You can install gdb from maemo repositories directly on the device, it is located in the repositories
Just add these lines to the /etc/apt/sources.list file on the device (or through the standard package manager), for this you need to be superuser, to enter this mode on the device you need to enter the command:
and then enter:
All this can be done via ssh, it is not necessary to write all this with your hands on the keyboard :-).
The second way is to manually download the gdb package and install it using dpkg (I did just that).
We go in and download the package to the device from this link . And save to your device. Therefore, in the console (again via ssh), go there and enter:
In scratchbox, GDB is already on.
In the ESBox settings, create a device and set IP N900 as the “Host Name”. We create the launch configuration on the remote host (in our case it is N900), we set the SSH application delivery method.
There are two options - SBRSH and SSH.
SBRSH is when the device mounts the folder with the application in its file system and starts from this place. Plus: faster everything happens. Minus: the device should see your computer (for the virtual system, it should be in Bridge mode and not NAT or transfer ports) and the SSH server should be on the SDK host.
SSH - the project is copied by SCP to N900 and is launched from there. Plus: the virtual machine can be in Bridge mode. Minus: a little slower.
I chose the second option, but you can choose for yourself, the settings there are not much different (though in the video I first created SBRSH, but then changed it to SSH).
As “Remote Connection”, a remote connection, select a previously configured device and start debugging.
At startup, you will be asked to enter a password for the user user. (Password is "maemo"). It’s better to click on the “Save password” checkbox, otherwise it will ask for a password many times, it
annoys :-) And voaaaallaing, it started and stopped at the breakpoint, and the application appeared on the device’s screen as on the emulator (take my word for it and better check for yourself :-)).
Lack of network debugging: slow. But the USB connection will come to the rescue. In fact, this is also debugging over the network, since a network interface is created via USB, through which the application is debugged. But since it is in fact "point-to-point", it is due to this and faster.
Preparation: you need to install the pc-connectivity package on the device, it is already on the virtual machine. It is located in the Extras repository. A very powerful tool inherited from previous versions of Maemo. In short: it allows you to create connection profiles, for each profile you can separately configure connections via USB, Wifi and Bluetooth. Yes, you can debug using bluetooth, but I have not tried it. Wifi debugging creates an access point with a DHCP server. Full documentation can be found here.. But do not be alarmed by the very large amount of documentation. In our case, it is not necessary to read it :-).
You need to start from the status bar (the menu that appears if you click on the area where the watch is :-)) pc-connectivity and set the “USB” checkbox, click the “Apply” button and connect the device via USB to the computer (it wasn’t possible to make a screenshot , took a picture on another phone).
After that, we will have a new “usb” network interface. By default, everything is already configured and as devices in ESBox you can use a pre-installed USB device c with a network address of 192.168.2.15, the virtual table will receive the address 192.168.2.14. But if you already have this address space occupied, you will have to change it to another one. PC-connectivity settings can be found in the standard N900 settings menu.
After that, we check the connection - we go to the device via SSH.
Well, all that remains is to create a debug configuration for this connection and run directly on the device.
As you can see, everything is very simple. Starting writing for Maemo5 with or without a device is easy. But personally, I don’t like that I can’t use Qt-creator. Of course, you can edit the code even on shared folders between the virtual machine and the host, and then run it all with your hands either in the emulator or on the device and debug it in Gdb with your hands, or use ESBox. But I'm already very used to Qt-Creator.
But there is a solution - MADDE. This is a completely different SDK and there is no official support yet (located in the Developer Preview) and there is no MADDE support in the Qt-Creator (in the official release), but all this is promised by the release of Qt 4.7. But nevertheless, you can use all this right now (using the main branch from the git repository or using the latest “snapshots”), and on any OS without using virtual machines. Qt-Creator in Gitorious in the master branch already works pretty well with MADDE. MADDE currently lacks two main things - the emulator and package updates. If you have a device on which you want to debug and are ready to install the necessary packages with your hands, then MADDE will suit you.
In the next article for developers, I will describe the process of setting up and working with MADDE.
Have a nice coding for everyone :-)
PS: as always, I invite you to visit my blog , there is information in English (though belatedly). You can find the English version on my blog erudenko.com
PS: I apologize for the 6 emoticons in the article, I understand that the site is serious, but I am a very fun little man and I can not resist :-) (oh smiley again :-), oh again. ....)
Some thought it was hard to start programming for Maemo. That’s why I decided to start by demonstrating the easy way “Easy way” © to show how easy it is to get started. Further, given the release of the official release of t 4.6.2 for maemo 5 , I will show how to put this release on the Fremantle SDK. I will demonstrate debugging in the emulator. And most importantly, how to debug the application on the device using a regular network connection and USB connection.
The result of our work will be such a window on the device:
Note: Scratchbox is used as an IDE, since this is a Fremantle SDK. QtQreator can be used, but as such Fremantle support is not and will not be. Why? Yes, because they make it support the new, cross-platform SDK - MADDE, which I already mentioned (and I will mention in the conclusion).
Well, since you are under the cut, it means you decided to read my article.
1. Install the SDK and launch HelloWorld in the emulator.
All videos here are not of very good quality, on YouTube you can watch them in HD format, just double-click on the video to do this.
Let's start from the beginning, at this point, suppose that you either didn’t read the previous article or decided not to go through the
But if
If you already have the Fremantle SDK, you can skip this step and go directly to the second step.
To install the SDK you need to download:
- Fremantle SDK Virtual Image - a file called Maemo_Ubuntu_Intrepid_Desktop_SDK_Virtual_Image_Final.7z .
- optional 7ip archiver, if you do not have it (take any).
- VirtualBox or quemu or VMWare. In my example, I am using VirtualBox.
and then proceed according to the video, everything seems to be clear there:
Notes: Install add-ons for the guest OS directly from VirtualBox itself, and not those included in the SDK itself (link to them on the desktop). They do not need to be downloaded anywhere, they already come with VirtualBox itself and the distribution is connected as a virtual disk image.
As you can see, installing, configuring, and launching the application takes less than 10 minutes, unlike the method I described earlier. Everything is very simple
2. Installing Qt 4.6.2, and creating and running the Qt application in the emulator.
From this point on, it doesn’t matter if you use the installation method proposed from the previous article or from point 1. Everything is relevant for both installation cases.
here the sequence is as follows:
First, we remove the Qt 4.5 installed in the SDK.
fakeroot apt-get remove libqtv4 *
and then install the official Qt 4.6.2 for Maemo5:
fakeroot apt-get install libqt4-maemo5-dev
And you need to do this for both purposes ARMEL and x86. The x86 target is needed to run and debug in the emulator, and the ARMEL target is to run and debug on the device (cross-compilation). You can switch between goals in scratchbox using the menu:
sb-menu
Now attention !!!! The network in scratchbox may not work (there may be errors with the network when running the command to install packages). This is due to minor problems in scratchbox. They are easy to eliminate. To do this, outside the scratchbox, you need to copy the resolv.conf file that you received via DHCP or generated in the process of setting up a static network (explicitly or indirectly through utilities) for each purpose and for the scratchbox itself:
sudo cp /etc/resolv.conf / scratchbox / etc
sudo cp /etc/resolv.conf / scratchbox / users / maemo / targets / FREMANTLE_ARMEL / etc
sudo cp /etc/resolv.conf / scratchbox / users / maemo / targets / FREMANTLE_X86 / etc
Also keep in mind that in case of using a proxy, you need to export environment variables:
export http_proxy = ...
export https_proxy = ...
You can put this into a separate script or add these lines to the ~ / .bashrc file or specify a proxy for apt-get:
echo 'Acquire :: http :: Proxy "http: // aptcache: 3142";' > /etc/apt/apt.conf.d/99proxy
In this case, apt-get will work through this proxy.
Also, before installing packages, Qt will not be out of place to update packages for each target in scratchbox (in general, all commands starting with “fakeroot” are executed only inside scratchbox, and sudo outside it):
fakeroot apt-get update
After that, we create the Qt project - “Qt Hello World” and select all targets for ARMEL and X86 as build configurations (after all, we plan to debug both in the emulator and on the device).
3. Configuring and launching the application in the local emulator and on the device via the network (via WiFi in my case).
This is not enough to build a Qt project, the fact is that ESBox does not know about the existence of official Qt, which is installed in / opt / qt4-maemo5, unlike the unofficial Qt, which integrates into the system (it is scattered in different directories, qmake is in / usr / local / bin, include is in / usrt / include / qt4, etc.). In principle, the behavior of the unofficial Qt package is standard, but in this case it is difficult to deal with several versions, which is probably why Qt-shniki decided not to scatter the package throughout the system. There are two methods to fix this: when creating a project, just change all the paths to Include and qmake, but you can make it easier, or rather make symbolic links:
for qmake (I have a typo in the comments on the video, instead of “dev”, it’s necessary to write “Bin”, alas, I can’t fix it for technical reasons):
ln -s / opt / qt4-maemo5 / bin / qmake / usr / local / bin
verify that qmake is available without specifying a path:
qmake
a prompt for qmake should appear, and the version of Qt is indicated at the beginning, there should be 4.6.2
for include:
ln -s / opt / qt4-maemo5 / include / usr / local / qt4
it is necessary for ESBox.
You need to perform this operation for each purpose of scratchbox assembly (ARMEL and X86), so that it doesn’t turn out that in the terminal you are debugging with one version of Qt, and on the device with another :-). You remember that to switch the target in scratchbox you need to use the sb-menu utility.
Then we build our application for the emulator (X86-develop) and create a debug configuration (local). We start, we agree to the invitation to launch the emulator. You will see that the program stopped at the entry point to the "main" function and earned HelloWorld. Everything works well. Hurrah!!!
Now run debugging on the device. First I decided to demonstrate debugging over the network. All that is needed is to install the gdb server on the device (for debugging) and ssh server (and the client will not hurt either).
Open SSH client and server can be installed using this metapackage: maemo.org/downloads/product/Maemo5/openssh . It is located in the repository repository.maemo.org/extras . You can spy on how to install a new repository in my article. You can also follow the link to the application and click the “Install” button directly on the device.
You can install gdb from maemo repositories directly on the device, it is located in the repositories
deb repository.maemo.org fremantle / sdk free non-free
deb repository.maemo.org fremantle / tools free non-free
Just add these lines to the /etc/apt/sources.list file on the device (or through the standard package manager), for this you need to be superuser, to enter this mode on the device you need to enter the command:
sudo gainroot
and then enter:
apt-get update
apt-get install gdb
All this can be done via ssh, it is not necessary to write all this with your hands on the keyboard :-).
The second way is to manually download the gdb package and install it using dpkg (I did just that).
We go in and download the package to the device from this link . And save to your device. Therefore, in the console (again via ssh), go there and enter:
dpkg -i gdb_6.8.50.20090417-0maemo2 + 0m5_armel.deb
In scratchbox, GDB is already on.
In the ESBox settings, create a device and set IP N900 as the “Host Name”. We create the launch configuration on the remote host (in our case it is N900), we set the SSH application delivery method.
There are two options - SBRSH and SSH.
SBRSH is when the device mounts the folder with the application in its file system and starts from this place. Plus: faster everything happens. Minus: the device should see your computer (for the virtual system, it should be in Bridge mode and not NAT or transfer ports) and the SSH server should be on the SDK host.
SSH - the project is copied by SCP to N900 and is launched from there. Plus: the virtual machine can be in Bridge mode. Minus: a little slower.
I chose the second option, but you can choose for yourself, the settings there are not much different (though in the video I first created SBRSH, but then changed it to SSH).
As “Remote Connection”, a remote connection, select a previously configured device and start debugging.
At startup, you will be asked to enter a password for the user user. (Password is "maemo"). It’s better to click on the “Save password” checkbox, otherwise it will ask for a password many times, it
annoys :-) And voaaaallaing, it started and stopped at the breakpoint, and the application appeared on the device’s screen as on the emulator (take my word for it and better check for yourself :-)).
4. Configure and launch the application on the device via a USB connection.
Lack of network debugging: slow. But the USB connection will come to the rescue. In fact, this is also debugging over the network, since a network interface is created via USB, through which the application is debugged. But since it is in fact "point-to-point", it is due to this and faster.
Preparation: you need to install the pc-connectivity package on the device, it is already on the virtual machine. It is located in the Extras repository. A very powerful tool inherited from previous versions of Maemo. In short: it allows you to create connection profiles, for each profile you can separately configure connections via USB, Wifi and Bluetooth. Yes, you can debug using bluetooth, but I have not tried it. Wifi debugging creates an access point with a DHCP server. Full documentation can be found here.. But do not be alarmed by the very large amount of documentation. In our case, it is not necessary to read it :-).
You need to start from the status bar (the menu that appears if you click on the area where the watch is :-)) pc-connectivity and set the “USB” checkbox, click the “Apply” button and connect the device via USB to the computer (it wasn’t possible to make a screenshot , took a picture on another phone).
After that, we will have a new “usb” network interface. By default, everything is already configured and as devices in ESBox you can use a pre-installed USB device c with a network address of 192.168.2.15, the virtual table will receive the address 192.168.2.14. But if you already have this address space occupied, you will have to change it to another one. PC-connectivity settings can be found in the standard N900 settings menu.
After that, we check the connection - we go to the device via SSH.
Well, all that remains is to create a debug configuration for this connection and run directly on the device.
Conclusion
As you can see, everything is very simple. Starting writing for Maemo5 with or without a device is easy. But personally, I don’t like that I can’t use Qt-creator. Of course, you can edit the code even on shared folders between the virtual machine and the host, and then run it all with your hands either in the emulator or on the device and debug it in Gdb with your hands, or use ESBox. But I'm already very used to Qt-Creator.
But there is a solution - MADDE. This is a completely different SDK and there is no official support yet (located in the Developer Preview) and there is no MADDE support in the Qt-Creator (in the official release), but all this is promised by the release of Qt 4.7. But nevertheless, you can use all this right now (using the main branch from the git repository or using the latest “snapshots”), and on any OS without using virtual machines. Qt-Creator in Gitorious in the master branch already works pretty well with MADDE. MADDE currently lacks two main things - the emulator and package updates. If you have a device on which you want to debug and are ready to install the necessary packages with your hands, then MADDE will suit you.
In the next article for developers, I will describe the process of setting up and working with MADDE.
Have a nice coding for everyone :-)
PS: as always, I invite you to visit my blog , there is information in English (though belatedly). You can find the English version on my blog erudenko.com
PS: I apologize for the 6 emoticons in the article, I understand that the site is serious, but I am a very fun little man and I can not resist :-) (oh smiley again :-), oh again. ....)