= Building and Debugging PJSIP on Symbian S60 3rd Edition Device using Carbide C++ = [[Image(symbian_ua.JPG)]] == Introduction == Previously PJSIP did not support Carbide C++ as the development tools for Symbian target, since Carbide did not import PJSIP's MMP files properly. But with the release of Carbide C++ version 1.2, it seems that Carbide is now able to build PJSIP projects properly. And since it seems that Nokia strongly suggests to use Carbide for the development tools instead of !CodeWarrior, it may worth to write some small documentation to help you get started with developing PJSIP applications on Symbian using this tool. This document covers the following topics: [[PageOutline(2-3,,inline)]] ---- == Requirements == For this tutorial, we will need: - [http://www.forum.nokia.com/info/sw.nokia.com/id/4a7149a5-95a5-4726-913a-3c6f21eb65a5/S60-SDK-0616-3.0-mr.html Symbian S60 3rd Edition Maintenance Release (MR)]. Other SDK versions may work, but I did not test it. - [http://www.forum.nokia.com/info/sw.nokia.com/id/dbb8841d-832c-43a6-be13-f78119a2b4cb.html Carbide C++ version 1.2]. You will need the Developer Edition to do on-device debugging (21 days evaluation is available). - [http://europe.nokia.com/A4144903 Nokia PC Suite] for the connectivity between the device and your PC (I use version 6.85) - Latest PJSIP from SVN trunk - Nokia S60 3rd Edition device (I use Nokia E70, but any S60 3rd Edition device should do, I think) - Nokia data cable for on-device debugging (you can also use Bluetooth connection, but this tutorial will not cover it) ---- == Installations == === SDK === Follow the installation instructions in the SDK documentation (make sure that the SDK requisites, such as Perl version, are satisfied). Please install Symbian SDK on the same drive as PJSIP. === Carbide === Follow the installation instructions in the Carbide C++ documentation. The installation should be straightforward, but don't forget to '''select the Developer's Edition''' (instead of Personal Edition) to get the On-Device debugging/TRK Debugging feature. (There is a 21 days evaluation period for the Developers Edition. If you have installed Carbide before and your evaluation period is over, you may not be able to select the Developers Edition, and you will have to purchase the Developers license) === Nokia PC Suite === Install PC Suite, connect your device with the USB cable, and make sure your PC can access your device. Leave PC Suite running with the device connected throughout the session. === PJSIP === Checkout PJSIP from the usual location (see [http://www.pjsip.org/download.htm PJSIP Download page] for details). Fill in your {{{config_site.h}}} with: {{{ #include }}} ---- == Importing PJSIP Projects == Run Carbide C++. When it asks the workspace location, just accept the default value and press OK button: [[Image(carbide-workspace.JPG)]] You will now be presented with Carbide Welcome page. Now we need to import PJSIP's project files (the MMP files) into Carbide's workspace. Select File --> Import from the menu: [[Image(file_import.JPG)]] This dialog below will pop up. Select '''Symbian OS Bld.inf file''' from the list, then press '''Next''' button: [[Image(import.JPG)]] On the next dialog, click '''Browse..''' button to select '''bld.inf''' file from PJSIP's {{{build.symbian}}} directory, then press '''Next''' button: [[Image(import_bld.JPG)]] Then on the SDK selection dialog, select the build configurations that you want to support. For this tutorial, select WINSCW and GCCE from S60 3rd Edition MR SDK, and press '''Next''' button: [[Image(import_sdk.JPG)]] You will then presented with MMP selection dialog. Leave the default selection (normally it should select all MMPs) and press '''Next''': [[Image(import_mmp.JPG)]] The project now is ready to be imported, press the '''Finish''' button: [[Image(import_finished.JPG)]] Carbide is now exporting the MMP files into the workspace and this progress window will be displayed: [[Image(import_creating.JPG)]] Wait for the process to complete. Once it completes, you will see the PJSIP project tree on the bottom left part of the Carbide main window: [[Image(carbide_main.JPG)]] On the '''Problems''' pane (bottom center of the main window) you can see there is one ''Warning'' about duplicate path, but we can ignore this for now. The projects should now be ready to be build. ---- == Building the Projects == Lets try to build the project first to make sure that the source is okay. === Select the Build Configuration === First select the build target by selecting '''Project''' --> '''Active Build Configuration''' from main menu, or right clicking the ''Bld.inf'' or ''pjproject'' item from ''Symbian Project Navigator'' pane from the bottom left part of the main window. Select '''Phone Debug (GCCE) [S60_3rd_MR]''' from the menu: [[Image(build_config.JPG)]] === Build the Project === Then right click ''Bld.inf'' or ''pjproject'' item from ''Symbian Project Navigator'' pane from the bottom left part of the main window, and select '''Build Target Only''': [[Image(build.JPG)]] Wait for the build process to complete. Once it completes, watch out for any errors in the ''Problems'' pane (at the bottom center). There shouldn't be any errors, although there may be few warnings which I think can be ignored, for now: [[Image(build_problems.JPG)]] We are now ready to build the .SIS file to be deployed to the phone. ---- == Preparing the .sis File == The .sis file is the packaging for the executable to be deployed in the device. The .sis file can be created very easily with Carbide C++. === Set the .pkg File to be Used === First we'll need to configure the .pkg file to be used to generate the .sis file. PJSIP provides some sample .pkg files which can be used, however there may be few editing needed befor you can use them (this is because the .pkg file contains absolute directory path for your Symbian SDK, which may be different on your installation). Assign the .pkg file to be used by the project by selecting Project Properties: [[Image(project_properties_menu.JPG)]] Then Project Properties dialog will appear. On this dialog: 1. Select ''Carbide Build Configuration'' from the tree. 1. Make sure that the Active Configuration is set to '''Phone Debug (GCCE) [S60_3rd_MR]''' 1. Set the ''PKG File'' by clicking ''Browse...'' button, and choose {{{symbian_ua.pkg}}} from PJSIP's {{{build.symbian}}} directory. We can leave the SIS creation and Signing settings empty. The dialog window now should look like this: [[Image(project_properties.JPG)]] Press ''OK'' button to save the project configuration. Now right click '''bld.inf''' and click '''Refresh''': [[Image(project_refresh.JPG)]] Wait for few seconds (30 seconds on my computer) for Carbide to do its job, once it's done, you will see the .pkg file in the ''Project Navigator'' pane: [[Image(project_pkg.JPG)]] === Edit the PKG File === As said earlier, the PKG file contains absolute directory path for the SDK, so you may need to edit it if your SDK location is different than the one specified in the PKG. Edit the PKG by ''double clicking'' it in the ''Symbian Project Navigator'' pane. Check out these lines in the PKG file: {{{ ; Target "C:\Symbian\9.1\S60_3rd_MR\epoc32\release\gcce\UDEB\symbian_ua.exe"-"!:\sys\bin\symbian_ua.exe" }}} Check that: - the SDK path is correct - later, if you ever want to create the Release version of the application, you will need to rename '''UDEB''' to '''UREL'''. But we can leave this to '''UDEB''' for now, since we want the Debug version of the application. Once you are done with the modification, save the file. We can close the file editor window now. === Build the SIS File === Once PKG has been setup on the project, a SIS file will be created everytime we build the project. So lets build the project now. Right click ''pjproject'' and select '''Build Target Only''': [[Image(build.JPG)]] The build process will start. You can take a peek on the '''Console''' tab to see what's being done. Once the build process completes, you should see something like this on the '''Console''' tab: {{{ Signing ***SIS Creation Complete Total Time: 12 sec }}} Check the '''Problems''' tab again to see if we have any errors (there shouldn't). ---- == Configuring On-Device Debugging == === Connect Data Cable === Connect the USB cable to the phone, and on the phone, select '''PC Suite''': [[Image(phone_usb.JPG)]] If this is the first time you connect your phone to the PC, then it may take some time for Windows to install the USB drivers for the phone. Wait for it to complete and the Nokia PC Suite and PC Sync icons on the task bar tray become green: [[Image(pc_suite.JPG)]] === Installing TRK Application on the Phone === Install TRK support on the phone. The TRK application can be found in {{{C:\Program Files\Nokia\Carbide.c++ v1.2\plugins\com.nokia.carbide.trk.support_1.2.0.29\trk\s60}}} directory. For my phone, the one that works is {{{s60_3_0_app_trk_2_7.sisx}}}. Right click this .sisx file and select '''Install with Nokia Application Installer''': [[Image(trk_path.JPG)]] When asked if we want to install, click '''Yes''': [[Image(trk_install.JPG)]] On the PC, this window should be displayed. [[Image(trk_wait.JPG)]] Leave it this way, the installation will start on the phone now. Your phone should display something like this: [[Image(trk_p_install.JPG)]] Click Yes. Now the phone will display '''Details''' information: [[Image(trk_p_details.JPG)]] Click Continue. Your phone may now display the target memory location: [[Image(trk_p_mem.JPG)]] Select the memory and press '''Select''' menu. Now the phone will display license agreement: [[Image(trk_p_lic.JPG)]] Click '''OK''' (if you agree, of course). The phone should display installation progress window for couple of seconds now: [[Image(trk_p_progress.JPG)]] Once it's done, '''Installation Complete''' window will appear briefly: [[Image(trk_p_complete.JPG)]] TRK is now installed on the phone. Next step is to run it. === Running TRK Application on the Phone === 1. Run it from '''Menu''' --> '''Installations''' --> TRK (it may be different on your phone). 1. When it asks to switch on Blueetooth, click '''No'''. We use USB cable for this session. 1. The TRK window will appear. We can ignore the error message for now: [[Image(trk_r_welcome.JPG)]] 1. Select '''Options''' --> '''Settings''' menu. 1. Change the '''Connection''' to USB, and leave all settings unchanged: [[Image(trk_p_usb.JPG)]] 1. Click '''Back''' to get back to TRK main window. 1. Now select '''Options''' --> '''Connect''' from the menu. 1. TRK main window should display '''Status: Connected''' now: [[Image(trk_p_connected.JPG)]] Leave TRK running on the phone for the duration of this tutorial. === Finding the COM Port Mapping for the Phone Connection === Find out which COM port is the phone connection mapped to, in Device Manager: [[Image(dev_mgr_com.JPG)]] In this case, the COM port is COM3. Note this COM port number, as we will need to specify it in Carbide. === Configure the Debug Settings in Carbide === Back to Carbide. Next we will need to create a new on-device debugging configuration. Select '''Run''' --> '''Debug...''' from the main menu: [[Image(run_debug.JPG)]] '''Debug''' dialog will appear like below: [[Image(debug.JPG)]] ==== Create a new Debug configuration for on-device debugging ==== Right-click '''Symbian OS App TRK''', and click '''New'''. New configuration will appear on the dialog. We need to edit few things: 1. Rename the configuration name from '''pjproject Phone Debug...''' to '''symbian_ua Phone Debug...''', as seen in the picture below. (Hints: when we have different executable to debug, we will create different configuration). 1. Set the ''Executable'' 1. Set the ''Remote process to launch'' You should see something similar to the image below. [[Image(debug_main.JPG)]] Now click on '''Apply''' button. The configuration name on the left tree now will get updated. ==== Configure TRK Connection ==== Now select '''Connection''' tab. Choose the '''Serial Port''' to the COM port where your phone connection is mapped to, which you have found out from the step above (look at the Device Manager). In my case, it was COM3: [[Image(debug_connection.JPG)]] The ''Baud Rate'' setting should match the setting on the TRK application running on the phone. Since we have not changed this setting, just accept the default value (115200). Now click on '''Apply''' button. ==== Configure SIS File ==== Now select the '''Installation''' tab. Browse the .sisx file from PJSIP's {{{build.symbian}}} directory: [[Image(debug_installation.JPG)]] Now click '''Apply''' button We are now ready to perform on-device debugging! Get yourself some tea, you deserve some break. === Debugging Application === Still in the '''Debug''' dialog, press the '''Debug''' button. Hold your breath! Carbide now may rebuild the project (you may take a peek on what it's doing by looking at '''Console''' tab). Once it's done, Carbide will switch to ''Debug Perspective'' and the SIS file will be downloaded to the phone and this window will appear briefly: [[Image(debug_download.JPG)]] When this window dissappear, you should see the application runs on the phone: [[Image(symbian_ua.JPG)]] You may make calls, receive calls, do presence stuffs, etc. Full debugging should also be possible; you may set breakpoints, step into functions, etc. ---- == Common Problems == === Problem with Build/Clean === Sometimes Carbide does not build the project properly after we make some changes to the source. In this case, Project Clean should cause the project to be built properly. === Program failed to debug after it has been downloaded to the phone === I experienced this once, and in my case, I suspect it was caused by some other program is currently using an Access Point (in my case, it was the periodic mail checking on the phone). === IP address is not detected by symbian_ua === This causes symbian_ua to use 127.0.0.1 as its address. This is still an ongoing problem, but it may help if you start an Access Point on the phone (such as by opening the web browser) before starting the debugging. ---- == Other Resources == Checkout: - [http://newlc.com/Carbide-c-Setting-up-On-Target.html Carbide.c++: Setting up On Target Debugging | NewLC]