Carlos III University of Madrid

Telematic/Audiovisual Syst./Communication Syst. Engineering

Systems Architecture

September 2012 - January 2013

Chapter 17.  The Maemo Architecture

TO BE WRITTEN!

17.1.  Activities

17.1.1.  Debate: Graphical interfaces in Maemo

Resources

Work Plan

  • In class, the lecturer is going to group you randomly in five-people groups and you will have to organize your work.

  • Playing in turns, you will comment the graphical interface of Maemo.

  • The questions the lecturer is going to work with are the following: (50 minutes)

    1. Could you explain figure 4.1? Which are the main differences between this figure and figure 3.4?

    2. What is GNOME?

    3. Is the process of designing a graphical application for Desktop PC and Maemo identical? Support your response.

    4. What is GTK?

    5. What is Hildon?

    6. Why does Hildon have four different kinds of views (normal view, with toolbar, Full Screen, Full Screen with toolbar)?

    7. How does GTK communicate with the application? Could give an example?

    8. Explain figure 4.7. What is an event-loop model?

    9. How does Gnome-VFS make easier the communication with graphical applications?

    10. In a graphical application, what is the role of D-BUS?

  • You must write the explanations that arise during the class.

17.1.2.  Individual reading: Linux Architecture

Resources

Work Plan

The work you are facing is to deduct the structure of certain system taking as departing point a real documentation. Instead of using a text explaining in detail Linux's innards, this text follows an inverse approach: from Maemo's manuals, students examine the architecture of a real Linux System. Therefore, only those parts relevant from the perspective of a student are introduced in this exercise.

To achieve this goal, the following steps are proposed:

  1. Read Chapter 3 (Linux System Model) with approximately 10 pages (45 minutes).

  2. Do a quick second read to the chapter and write down the main concepts of each page (10 minutes)

  3. Focusing on those selected concepts, write a summary of the chapter (45 minutes). You can do it by hand in a sheet of paper or in the computer. If you do it in a sheet, remember to show it to the teacher; if in the computer, upload your summary to your repository.

Once at class, the lecturer will discuss about a set of topics. Spend some time before class reading the following set of questions (chosen by the lecturer after reading the proposed text). (15 minutes)

  1. Why do we need "kernels"? Which is their mission? What are their main goals?

  2. Why Maemo has a Linux inside?

  3. Why a user and an application space? Which advantage does this separation contributes to the application?

  4. What is a system call?

  5. What is a process? What internal information does it manage?

  6. What is the PID? How are the processes created? When do they finish?

  7. How is a new process initiated? How does this process end? What type of signals can it receive?

  8. What do you understand by mounting a filesystem?

  9. What three types of pseudo-filesystems are in Linux?

  10. What is an inode? Why were they defined?

  11. What is a symbolic link?

  12. What types of permissions are in Linux?

  13. Why are there several kinds of permissions in Linux, each one for a different kind of user?

  14. What is the difference between a program, a daemon and a library? Which is their relationship?

  15. Why we say that httpd, lpd and cron are daemons? What kind of services do they offer?

  16. Which is the difference between static and dynamic linking?

  17. Which is the structure of an application that only uses command-line interface?

Activity

When you finish this assignment, please, upload the documents to the MaemoLinux folder in Subversion. If you do it by hand, show it to your teacher in class.

17.1.3.  Participative commentary in Class:Linux Architecture

Resources

Work Plan

In this activity, you will deal with certain concepts of the Architecture of Linux in group.

In class, the work is organized as follows:

  • The lecturer is going to group you in small groups (four or three) leaving some time aside for self-organization

  • Setting up a rotary turn among the different groups, s/he will ask you some questions.

    • In your turn, you will have to answer to the question s/he has asked you.

    • In others turn, you will have to write down the main ideas explained by your colleagues.

  • At the end of the class, you will have to hand your notes.

This is the preliminary list of questions you will work with:

  1. Why do we need "kernels"? Which is their mission? What are their main goals?

  2. Why Maemo has a Linux inside?

  3. Why a user and an application space? Which advantage does this separation contributes to the application?

  4. What is a system call?

  5. What is a process? What internal information does it manage?

  6. What is the PID? How are the processes created? When do they finish?

  7. How is a new process initiated? How does this process end? What type of signals can it receive?

  8. What do you understand by mounting a filesystem?

  9. What three types of pseudo-filesystems are in Linux?

  10. What is an inode? Why were they defined?

  11. What is a symbolic link?

  12. What types of permissions are in Linux?

  13. Why are there several kinds of permissions in Linux, each one for a different kind of user?

  14. What is the difference between a program, a daemon and a library? Which is their relationship?

  15. Why we say that httpd, lpd and cron are daemons? What kind of services do they offer?

  16. Which is the difference between static and dynamic linking?

  17. Which is the structure of an application that only uses command-line interface?

Evaluation

Remember to give the lecturer your manuscript before you leave the class.

17.1.4.  Maemo's emulator - Previous reading

Resources

Work Plan

Read the section 1 of the guide offered as resource, where a brief explanation of the Maemo development environment is explained (10 min.).

The first figure of the guide shows the basic steps in an ordinary development environment.

After reading section 1, think about which commands/tools of these ones: "gedit", "sb2 -e ./runnable_file", "sb2 gcc" and "sb2 -eR cp", we are going to use to: edit a file, build, copy and execute. (10 minutes)

The second figure shows the three universes defined in the development of applications: (1) host, (2) cross-compilation, and (3) execution.

For each universe, choose the environment that you think it is going to be used in the lab: (1) i386, (2) ARM and/or (3) both. Please, explain your choice. (10 minutes)

Read the other sections of the guide (20 min.), to have an idea which tools we can use.

17.1.5.  Individual reading: Graphical interfaces on Maemo

Resources

Work Plan

In this task you are going to continue your previous reading and you will read about the graphical interface model supported by Maemo. These interfaces are strongly based on software already existing in Linux which was readapted for Maemo.

  1. Read chapter 4 (The GUI components of Maemo). (30 minutes)

  2. Try to explain in a Word document the main parts of a GUI. (15 minutes)

The following list of questions may help you organize your information. They are questions suggested by the person who has read the proposed document. Revise them. (15 minutes)

  1. Could you explain figure 4.1? Which are the main differences between this figure and figure 3.4?

  2. What is GNOME?

  3. Is the process of designing a graphical application for Desktop PC and Maemo identical? Support your response.

  4. What is GTK?

  5. What is Hildon?

  6. Why does Hildon have four different kinds of views (normal view, with toolbar, Full Screen, Full Screen with toolbar)?

  7. How does GTK communicate with the application? Could give an example?

  8. Explain figure 4.7. What is an event-loop model?

  9. How does Gnome-VFS make easier the communication with graphical applications?

  10. In a graphical application, what is the role of D-BUS?

17.1.6.  The architecture of Maemo

Resources

Work Plan

Read "Chapter 5: Maemo platform overview". (30 minutes)

The following figure is labeled as "the Architecture of Maemo".

  • Your first work is to reproduce this figure on a sheet. (15 minutes)

  • Next, you should write a brief description of the following elements of the architecture. You can use Internet when necessary.

    • Initfs

    • Bootloader

    • Core Daemon

    • GNU C Library

    • GPS

    • Core-Libs

    • Linux-Kernel

    • Sockets

    • Help Framework

17.1.7.  Maemo's emulator - guided tutorial

In this guided tutorial you will learn how to:

  • Compile this applications using the compiler of a cross-development environment.

  • Run this application inside an emulator.

  • Copy the executable within a simulated runtime environment, in such a way it is available until its removal.

  • Install this application using the package manager.

Resources

The following resources are to support the workplan but they not need to be read before starting to work.

Work Plan

Edit in the host universe

In this tutorial, the application you have to implement is called helloworld and it will be stored in a directory called project.

  1. Create the project folder using mkdir in your account:

    Note: if this folder already exists, this command shows an error in the console.

  2. The next step is change our current position to the folder created.

  3. Create the source file (with kate or any editor) in order to print "Hello world! We are..." and your names. Remember to save before exiting the editor.

Compile in the cross-compilation universe

Creating an application from this source code to be executable in the Nokia device is easy, you only have to:

  1. Invoke the gcc ... compilation command inside the cross compilation universe or environment of the emulator, with the command sb2 gcc .... This command changes the universe or environment of our PC to the cross-compilation one. In this universe there are special tools (like the compilator for ARM) that allow the compilation of a file for N810.

    Notes: Using the ls command, we can check if the runnable file helloworld was created in the current directory.

  2. Notice the runnable file is for ARM architecture and not for I386, which is the architecture emulated in the VirtualBox image or the architecture of the PCs in the lab.

    Note: The file command shows the type of file generated. As you can see in this particular case, it is a runnable file for ARM.

In general, to execute a certain command in the universes of the emulator, you only have to put that command after the sb2 command if you want to use the cross-compilation universe, or the sb2 -e command if you want to use the simulated runtime environment. For instance, to run the ls command on the cross-compilation universe, you simply execute sb2 ls.

Universe execution: Simulated runtime execution environment
  1. The current working directory (i.e. the project folder) is shared among the hor universe and the universes of the ScratchBox emulator. Then, you do not have to copy any file to the emulator in order to run it. You can run the application using the following command: sb2 -e ./helloworld.

  2. Notice that if we try to run the file in the host environment, the code does not run because it was compiled for an ARM.

  3. Notice that you can also run the application in the cross-compiler universe. This is possible because the cross-compiler environment runs also an ARM.

Copy executable in the emulator

To copy the application in the programs directory of the emulator (/usr/bin) permanently, you have to follow the next steps:

  1. Just before copying, you should check if the file already exists in the bin directory of the emulator using ls in the execution universe

  2. After that, we copy the runnable file from the current folder project to another folder inside the emulator (/usr/bin) using the cp command. Notice that this command must be preceeded by sb2 -eR because we want it to be run inside the execution universe.

    The option R executes the command as root (i.e., running under special privileges). This special option is necessary in this particular case to copy the file into the /usr/bin folder, which can be written only with root privileges.

  3. Let's run the installed file directly as a program, inside the execution universe of ScrathBox; that is, in the simulated runtime environment.

    Notice that we do not need -R. This is so because we do not need root privileges to run the application.

  4. Now, the file is also installed (or just copied) in the simulated runtime environment.

  5. Remember files are shared among the emulator universes, so you can check that the program is also installed in the "/usr/bin" dir in the cross-compilation environment, even though is not necessary.

  6. Notice that if the program is executed in the host universe (without sb2), this command fails because it cannot find the runnable file.

  7. To remove the installed file, you can use rm (preceded by sb2 -eR).

    Once more, you need root privileges to accomplish the execution of the command.

Packaging the application

There is the possibility of installing the application as a package. The advantage that stems from the use of a package is that the package can be installed directly from the application manager using specific tools. In this particular tutorial, we are going to create the "helloworld" package using alien.

  1. First, we create a directory hierarchy similar to the one used in the final environment. That is, a hierarchy with the same directories of the execution universe of the target device (or the simulated runtime environment), which is "usr" and "usr/bin".

    Note: The semicolon enables the execution of the two commands (one after the other) in a single step.

  2. We copy the helloworld file in this hierarchy of files.

  3. We compress all the hierarchy in a "tar.gz" file which includes the version of the package.

    Pay attention to the following details:

    • The tar options we use to compress the file are cvfz.

    • The name of the package must be the one of the newly created "tar" file.

    • The version of the package should appear in the name of the file (helloworld-1.0.0.tar.gz).

  4. Once compressed, we use "alien" to transform a "tar.gz" file to a ".deb" one. This tool generates a simple package (it does not check dependencies, but the generated file can be managed by the package manager).

    Notice that alien command is preceded by fakeroot. If we use alien without fakeroot, the shell will remind us that we need to be root to execute this command. To solve this problem, one solution is to use fakeroot, a command that simulates that we own root privileges.

  5. The resulting package is available in the current directory.

Install/Uninstall the application

Installing and uninstalling the "helloworld" package is quite simple. You only have to use "apt-get" and "dpkg" inside the execution universe of the emulator.

  1. Before installing the package, we check if the application is installed or not.

  2. Next, we install the package using dpkg -i name-of-the-package.deb preceded by sb2 -eR.

  3. After installing, we can invoke helloworld in the simulated runtime environment.

  4. We can uninstall the package invoking the following command apt-get remove on the execution universe in root mode (that is, using sb2 -eR).

If you have reached to this point, it means that you can build, execute and install applications on your Maemo's emulator.

CONGRATULATIONS!

Universe execution: Target device

To finish, install your Debian package in an N810 and show it to your teacher:

  1. Upload your .deb package to your repository, directory DebianPackage, download it then in your Nokia by putting the URL of the repository into the brouser, then you will be able to select the .deb package, it will be downladed to the folder /home/usr/MyDocs/.documents, and finally you will be able to execute it through the command line the same you have executed in the emulator.

  2. To install the package (dpkg command) in the Nokia, you will have to do it as root, not as user. To change the user to root, make an ssh to the Nokia itself: ssh root@localhost with password teleco and, once as root, you will be able to use dpkg with the option -i. After connecting as root, you are in the root directory (but your .deb package is on the user home). Therefore, you will have to go to /home/user, and there you will have to enter into the user documents.

  3. Probably your Nokia has a "helloworld" package (check it writing helloworld in the command line). If so, remove it first.

  4. To finish, install it with dpkg and execute it.

If your Nokia does not know the ssh command, you will have to install it. To do that, activate the Maemo extras options and install the openssh application.

Evaluation

Upload to the SVN folder DebianPackage the following files:

  • A screenshot file of the commands line that shows the output of the helloworld program.

  • helloworld-1.0.0.deb file

17.1.8.  Final auto-evaluation questions

  1. What are the System Calls?

    • The Systems calls are generic functions for the memory management, process management and devices management of the Linux operating systems. Anyone can implement these types of functions.

    • The Systems calls are generic functions for the memory management, process management and devices management.

    • System calls are the type of fucntions that we usually implement in our programs.

  2. Which is the objective of separating the virtual memory of the system into two spaces,the kernel space and the user space?.

    • One of the objectives is to protect the memory space reserved for the system functionalities.

    • One of the objectives is to organize the memory system to facilitate the implementation of new programs.

    • One of the objectives is to facilitate the implementation of new functionalities for the Kernel.

  3. The processes consists of:

    • An executable program code.

    • An executable program code, a bunch of resources, an address space,internal data for kernel, possibly threads and a data section.

    • A set of resources