An Introduction to the Symbian Virtual Platform

Retweet Share on Facebook

Hi, I’m Tyson Key, a college student currently residing somewhere in the north of England.

When I’m not studying, I happen to advocate and contribute to open source, and open platforms and enjoy spending time testing and documenting software, and exploring various aspects of low-level operating system and computer networking technology – all whilst trying to be a generally reasonable and agreeable person…

Of course, I also happen to be a heavy user, and advocate of the Symbian platform, and have been involved with the Symbian Foundation to varying extents, since its announcement.

Introduction aside, I’ve been invited to introduce the Symbian Virtual Platform. This is a project that I’ve been involved in beta testing, prior to the release of the Symbian Kernel Taster Kit.

What’s the Symbian Virtual Platform?

The Symbian Virtual Platform consists of a customised version of QEMU (an Open Source CPU instruction set and hardware emulator), containing several additional features, along with a corresponding baseport referred to as Syborg.

This combination potentially represents the future of inexpensive, accurate, user-level application testing, and low-level debugging and experimentation on the Symbian Platform, without the need for additional hardware.

As a bonus, some of the hallmark causes of frustration with the older Windows-based emulator (commonly referred to as WINS or WINSCW dependant upon toolchain used) are removed, such as:

  • Low performance
  • Simulation inaccuracy (e.g. differing memory models with various limitations, behavioural differences from real hardware, and disabled/restricted software functionality)
  • Platform dependence – QEMU is well-supported under Windows, most Linux distributions and Mac OS X, and also runs under many other operating systems

What can it do for you?

The “official”/mainline version of QEMU already emulates an ARMv5 architecture CPU, and a number of hardware features including – but not limited to:

  • Serial ports – complete with the ability to redirect traffic to a file, which is essential for Symbian Platform debugging and problem diagnosis
  • Ethernet chipsets – a driver for which is included in Syborg, although additional work is necessary, before being suitable for intensive use
  • Various forms of Flash memory devices (e.g. MultiMediaCard/SD Card, and SPI NAND Flash)
  • An audio chipset – support for this in the baseport was recently contributed by Johnathan White of Accenture

However, the version supplied by Symbian also adds a number of useful features that enhance this functionality to potentially save development time and effort, and let users/enthusiasts test software quickly and easily without access to a physical handset, including:

  • The ability to run real Symbian OS binaries “as-is” – meaning that you no longer also need to rebuild software to run within an x86 and Windows-only simulator
  • A host file system-backed emulated drive (S:\ on the QEMU guest, which maps to \svphostfs on the host) that acts as an extension of firmware when custom executables are added, and allows for quickly moving files between the host and guest whilst the Platform is running
  • A Python-based dynamic hardware modelling system that allows for varying degrees of control over the behaviour of the emulated system at runtime, without needing to modify QEMU source code and rebuild

The source code for these enhancements, and the baseport are available in the Symbian Foundation repositories.

Intrigued? Here’s what it looks like…

An EShell session, showing the output of various utilities, on a Windows XP host

What have I done with QEMU?

  • Built several ROM images containing various Platform components, and documented the results on the Symbian forums so that others can assist in resolving problems, and enhancing the results
  • Spent time debugging the execution of various binaries using serial port file redirection, and resolving dependency issues, as they arose

Which leads nicely on to a practical example, based upon a problem that I faced…

Getting the EUserHL Walkthrough test suite running

A forum thread that I started, with additional suggestions from the community, prior to writing this post is available here for reference. I’ll now attempt to explain how I answered a not-too-uncommon question using several features of the Symbian Virtual Platform, and a process of elimination -

How can I test a Platform component (in this case – EUserHL), when I don’t have access to the source code?

The initial steps involved boil down to:

  • Install and configure the Symbian Kernel Taster Kit and RVCT 4.0 according to the instructions on the Symbian Wiki
  • Create a directory on the host file system at \svphostfs and a set of subdirectories to hold executables and DLLs inside: sys\bin
  • Copy \epoc32\release\armv5\urel\euserhl_walkthrough.exe and \epoc32\release\armv5\urel\euserhl.dll to \svphostfs\sys\bin
  • Start a cmd.exe prompt session, and switch to \symbian-qemu-0.9.1\bin\
  • Run QEMU using the prebuilt Syborg ROM image using: arm-none-symbianelf-qemu-system -M \sf\adaptation\qemu\baseport\syborg\syborg.dtb -kernel \epoc32\rom\syborg.img within the active cmd.exe session
  • Once the ROM has booted to EShell, attempt to invoke euserhl_walkthrough.exe
  • Notice that execution simply bails, before printing a rather vague, generic “Not found” error message

Obviously, this a rather sorry state of affairs – but there’s hope.  So, let’s move on:

  • Halt the previous QEMU session
  • This time, run QEMU again using arm-none-symbianelf-qemu-system -M \sf\adaptation\qemu\baseport\syborg\syborg.dtb -kernel \epoc32\rom\syborg.img -serial file:”EUserHLDebug.txt” to redirect serial port output to a file
  • Within the EShell session, invoke trace /L 4 to enable debugging of executable loading and DLL iteration
  • Attempt to invoke euserhl_walkthrough.exe once again within EShell, to receive the familiar “Not found” error
  • Open \symbian-qemu-0.9.1\bin\EUserHLDebug.txt on the host, using your favourite text editor
  • Following the chain of execution, from euserhl_walkthrough.exe onwards, to euserhl.dll, we can see that various dependency DLLs are located successfully (demarcated by “New image found“)
  • However, if we closely follow euserhl.dll, the fact that a critical dependency is missing at a late stage is alluded to by “No suitable image found” – although reattempts are constantly being made to locate the missing DLL
  • Unfortunately, this debug output does not tell us exactly which DLL we require – so we turn to another useful tool (elftran)
  • At this stage, it would be a good idea to halt the QEMU session, to avoid some rather confusing behaviour that arises from the handling of the S:\ drive, and executable caching when copying additional DLLs and executables to \sys\bin within it

Now, we should be on the home stretch:

  • Within another cmd.exe session, run: elftran \svphostfs\sys\bin\euserhl.dll > EUserHLDeps.txt to create a file containing information related to the dependencies of the euserhl.dll binary, amongst other attributes
  • Searching for “imports from” within the EUserHLDeps.txt file will reveal that euserhl.dll depends upon estor.dll – which doesn’t exist in the prebuilt ROM image, or in \svphostfs\sys\bin
  • Copy \epoc32\release\armv5\urel\estor.dll to \svphostfs\sys\bin
  • Run arm-none-symbianelf-qemu-system -M \sf\adaptation\qemu\baseport\syborg\syborg.dtb -kernel \epoc32\rom\syborg.img once again
  • With a little luck, attempting to invoke euserhl_walkthrough.exe should result in:
  • Partial output from running the EUserHL Walkthrough test suite

  • Have fun exploring the serial debugging and tracing tracing functionality, and the host-bound file system

If that’s not enough, you can even try to build these components into a ROM image:

  • Copy \sf\os\kernelhwsrv\kernel\eka\rombuild\tshell.oby to \sf\os\kernelhwsrv\kernel\eka\rombuild\tshellwitheuserhl.oby
  • Add the following lines to the bottom of \sf\os\kernelhwsrv\kernel\eka\rombuild\tshellwitheuserhl.oby:
    file=\epoc32\release\armv5\udeb\estor.dll \sys\bin\estor.dll
    file=\epoc32\release\armv5\udeb\euserhl_walkthrough.exe\sys\bin\euserhl_walkthrough.exe
    file=\epoc32\release\armv5\udeb\euserhl.dll \sys\bin\euserhl.dll

  • Delete euserhl_walkthrough.exeeuserhl.dll and estor.dll from \svphostfs\sys\bin\ to ensure that the contents of the ROM are not being supplemented/overridden with the contents of S:\sys\bin on the guest at boot time
  • Within a cmd.exe session, switch to \sf\os\kernelhwsrv\kernel\eka\rombuild
  • Run rom –variant=syborg –inst=armv5 –build=udeb –type=tshellwitheuserhl –name=\epoc32\rom\tshellwitheuserhl.img to attempt to build a new ROM image containing the EUserHL DLL, walkthrough/demo application, and the EStor DLL
  • If everything worked according to plan, you should be able to run your new ROM image using: arm-none-symbianelf-qemu-system -M \sf\adaptation\qemu\baseport\syborg\syborg.dtb -kernel \epoc32\rom\tshellwitheuserhl.img within the \symbian-qemu-0.9.1\bin\ directory
  • Invoking euserhl_walkthrough.exe for the final time should produce the same result as the previous exercise!

Additional Resources and Information

  • A series of forum threads related to PIPS and networking, and the legacy, development-specific TechView GUI, in addition to the aforementioned EUserHL thread that I started, and continue to contribute to
  • A list of backlog items and planned features for the Symbian Virtual Platform are available, here
  • Johnathan’s presentation about the Symbian Virtual Platform at SEE 2009:

Posted: November 20, 2009 at 4:51 pm

Last updated: February 5, 2010 at 3:19 pm

Categories: Tech Themes

Tags: ,, , , , ,

Short Link: http://wp.me/pqgpU-Q5