[[PageOutline]] = !BlackBerry 10 = This document describes the porting progress of modRana & other related Python & QML based applications (Mieru, !RePho, Panora) to the !BlackBerry 10 operating system. The information also of course applies to porting any other Python & QML based application to BB10. :) '''This is a work in progress - if you find some errors & or missing information, [wiki:WikiStart#Contactthedeveloper let me know] so I can fix it! :)''' === Dependencies === What needs to be available for modRana to run. ==== Python ==== Python is available on-device in version 3.2. !ModRana has not yet been tested running on Python 3, but any changes that would be needed should be fairly minor. ==== Qt ==== Qt is available either on-device or a custom-compiled Qt libraries can be bundled in the package. Related links: [http://qt-project.org/wiki/QNX Qt@QNX overview] (BB10 is based on QNX) [[BR]] [http://qt-project.org/wiki/Building-Qt4-for-Blackberry Building Qt4 for BB10] Weather the on-device Qt version can be used, or custom Qt version needs to be used to run modRana still needs to be determined. If using the on-device version is possible, the resulting installation package would be quite a bit smaller as the Qt libraries would not need to be included. ==== Making sure the right Qt is used ==== By default (when just running the bbndk environment script before build), Shiboken & !PySide pick-up the Qt libraries that are included in the BB10NDK target, completely ignoring your local Qt build. If you want for both Shiboken & PySide to use the proper build, you need to modify ''PATH'' & ''LD_LIBRARY_PATH'' so that it is preferred to the one in the BB10NDK target: {{{ source /bbndk-env.sh export QTDIR= export LD_LIBRARY_PATH="$QTDIR/lib:$LD_LIBRARY_PATH" export PATH="$QTDIR/bin:$PATH" }}} You need to either run this in your shell (or put it in a script ''source'' it to your shell) before issuing the ''configure'' commands for Shiboken & !PySide. ===== Using the on-device Qt libraries ===== If you decide to use the on-device Qt libs (they are in version 4.8.4 and should theoretically be sufficient) don't use the above mentioned tweak and just source your environment from the bbndk-env.sh script: {{{ source /bbndk-env.sh }}} As a result, Shiboken & PySide will compile against the Qt in the NDK target and you don't have to include the Qt libraries in your installation package, making it much smaller. Next modify the os.environe statements in ''blackberry-py/bbpy/__init__.py'' like this: {{{ os.environ['LD_LIBRARY_PATH'] = '/usr/lib/qt4/lib:%s' % os.path.join(BBPYPATH, 'lib') os.environ['QT_PLUGIN_PATH'] = '/usr/lib/qt4/plugins' os.environ['QML_IMPORT_PATH'] = '/usr/lib/qt4/imports' }}} This tells bbpy too look for the Qt libraries on device. Then remove all 'libQt*.so' files from the ''blackberry-py/lib'' folder for you package as they are no longer needed. This should make your package much smaller. A python hello-world with included Qt libraries has about 16 MB, without the librairies it has 3.7 MB. Unfortunately even applications packaged using this (eq. using on-device Qt libraries) still result in the same segfault as packages with Qt libraries built-in. See this example package content (just package & deploy it): http://modrana.org/platforms/bb10/examples/using_on_device_qt.zip '''If it doesn't segfault for you & or if you find some workaround, please [wiki:WikiStart#Contactthedeveloper let me know] ! ==== !PySide ==== Just follof the [http://hg.microcode.ca/blackberry-py/wiki/Building%20PySide building PySide] guide, the few changes that are needed for the whole thing to compile, are described below or in the [wiki:BB10#MakingsuretherightQtisused Making sure the right Qt is used] section: '''Building Shiboken''' comment out tests in these CMake files on around these line numbers: {{{ /usr/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake :45 /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake :52 }}} Yeah, really - this means modifying you system installation of CMake - make sure to have a backup ! :) === Packaging === ==== Getting the debug token ==== To install correctly to the BB10 device, the package needs to be signed with a valid debug token. 1. ''source'' the ''bbndk-env.sh'' script to your shell, so that you have the various BlackBerry utilities in your ''$PATH'' {{{ source bbndk-env.sh }}} 2. fill in the online form for signing keys Note the PIN you've entered somewhere. 3. generate a keypair '''NOTE: This step is very important, as it is completely omitted in the official BB10 documentation and without it the debug token generation will fail with a ''author.p12 file missing'' error''' '''NOTE2: use only lowercase letters and numbers in the store password as reportedly uppercase letters cause problems. ''' {{{ blackberry-keytool -genkeypair -storepass 3 -author }}} 4. register the signing keys {{{ blackberry-debugtokenrequest -register -csjpin -cskpass client-RDK-*.csj }}} The following is probably only needed for the Playbook ? {{{ blackberry-debugtokenrequest -register -csjpin -cskpass client-PBDT-*.csj }}} 6. find you device PIN Should be visible on-device in settings->About->Harware 5. generate the debug token {{{ blackberry-debugtokenrequest -storepass -devicepin debug_token.bar }}} The debug_token.bar file now contains the debug token you can use to build packages (just for) your BB10 device. Plain and easy, not needlessly convoluted at all. :) ==== Package contents ==== The package needs to contain the application and any other libraries modRana needs to run. The libraries are stored in the folder the application gets installed into and are loaded by manipulating the ''PATH'' and ''LD_LIBRARY_PATH'' variables. For modRana the package would contain the modRana application files, the !PySide Qt bindings and Qt (if the built-in Qt install can't be used). Mieru will probably need a BB10 compiled unrar binary to correctly open RAR compressed manga/comic book files. BB-Py packaging tutorial: http://hg.microcode.ca/blackberry-py/wiki/Building%20HelloWorld ==== Examples ==== These archives contain package content examples. Just unpack them, copy you debug token to the resulting folder & run the packaging and publishing commands. '''Example with included Qt 4.8.1 libraries''' http://modrana.org/platforms/bb10/examples/with_qt_4.8.1.zip '''Example that uses on-device Qt libraries''' http://modrana.org/platforms/bb10/examples/using_on_device_qt.zip '''Both don't work at the moment :)''' Unfortunately, at least on my BB10 packages generated from both of these examples install correctly, but segfault when started. ==== Application not starting ==== The application is not starting at the moment. After clicking on the icon a black window briefly shows up and then closes at once. This is the content of the log that resides in the ''/accounts/1000/appdata//logs/log'' file: {{{ Process 30396593 (python3.2) terminated SIGSEGV code=1 fltno=11 ip=783abf7c(/base/lib/libcpp.so.4@_ZNKSt6locale9_GetfacetEj+0x27) mapaddr=0002bf7c. ref=00000010 }}} There were also two Python 3.2 core dumps, they are available from this folder: http://modrana.org/platforms/bb10/coredumps/ '''If it doesn't segfault for you & or if you find some workaround or even if you just got an idea what else to try, please [wiki:WikiStart#Contactthedeveloper let me know] ! Any help will be much appreciated as I'm starting to run out of ideas. :D === Notes === '''Where are applications installed ?''' Applications are installed - in paths like this: {{{ /accounts/1000/appdata/ca.microcode.bbpy.HelloWorld.testDev__HelloWorld7b0107f8/app/python/blackberry-py/ }}} '''Filesystem access''' Each application is basically running in some sort of sandbox. There are various folders that that can be used for various purposes by the application. Some of them are only visible by the application and others are shared between applications and can be used to exchange data. For more information see the [http://developer.blackberry.com/native/documentation/bb10/com.qnx.doc.native_sdk.devguide/com.qnx.doc.native_sdk.devguide/topic/accessible_folders.html BB10 filesystem access article]. '''Running applications from the command line''' It looks like it is not possible to run applications directly from the command line. But it is possible to run an application right after its package is installed through the command-line installation tool. === Debugging === Applications are started in a sandbox with some preade folder structure. The folder called ''log'' in the sandbox contains stdout for the program. '''Checking out the log''' (The path seems to partially random-generated, so don't forget to change it to the path corresponding to you application). {{{ cd /accounts/1000/appdata/ca.microcode.bbpy.HelloWorld.testDev__HelloWorld7b0107f8/ $ ls app data db logs pps shared tmp }}} The ''logs'' folder contains the logs. '''Shared log folder''' If you don't want to fish for the log folder, you con redirect stdout to a log file in the ''data/Downloads'' folder, which should be accessible for all applications. '''Creating a package''' If you are getting icon related errors during package installation, ad these argument to the packager: {{{ -e icon.png icon.png }}} '''Using gdb''' It is possible to deploy an application and launch it in debugging mode on the BB10 device. First source your shell envrionment from the BB10 NDK environment script: {{{ source bbndk-env.sh }}} Then deploy the application with debugging enabled: {{{ blackberry-deploy -installApp -launchApp -debugNative -password -package HelloWorld.bar }}} In the ourput of this command you should get something like this at the end: {{{ result::32395406 }}} The number is the application PID you will use for debugging it with gdb. Next, start the BB10 NDK gdb: {{{ ntoarm-gdb }}} From inside the gdb shell: {{{ echo target qnx :8000 attach }}} The result: {{{ (gdb) attach 32395406 Attaching to pid 32395406 "/usr/bin/python3.2": not in executable format: File format not recognized (gdb) run ../../gdb/thread.c:72: internal-error: inferior_thread: Assertion `tp' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) n ../../gdb/thread.c:72: internal-error: inferior_thread: Assertion `tp' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? (y or n) y }}} So its not really that usable for debugging Python applications but probably could be somehow fixed to provide some meaningful output. Related link: http://qt-project.org/wiki/Remote_debugging_on_Blackberry_devices === Helpful commands === Pack, install and run: {{{ blackberry-pythonpackager -package HelloWorld.bar -devMode -env PYTHONPATH=app/python/blackberry-py bar-descriptor.xml main.py main.qml -e ../icon.png icon.png -e ../blackberry-py/ blackberry-py/ -debugToken ~/token.bar -device -password -launchApp -list -installApp }}} Deploy package: {{{ blackberry-deploy -installApp -password -package HelloWorld.bar }}} === Secondary dependencies === ==== Qt Components ==== While the modRana QML GUI is largely independent on Qt Components, working set of Qt Components would simplify porting quite a lot. Also other applications, such as Mieru, currently depend on functioning Qt Components. ===== Symbian Qt Components ===== https://qt.gitorious.org/~conny/qt-components/connys-qt-components/commits/bb10 Should compile using these parameters: {{{./configure -symbian -no-mobility -nomake tests -nomake demos -nomake example}}} ===== !MeeGo/Harmattan Qt Components ===== Looks like !MeeGo/Harmattan Qt Components should also work with some tweaks & would be the preferred choice, considering that is what modRana & co are currently using. Links: http://zwong.de/2012/06/using-meego-qt-components-on-blackberry-10-and-playbook/ http://supportforums.blackberry.com/t5/Native-Development/qt-components-for-BB10/td-p/1798349 http://supportforums.blackberry.com/t5/Native-Development/QML-symbian-qt-components-for-PlayBook/td-p/1574275i ===== BBX Qt Components ===== A port of MeeGo Qt Components for BBX devices:[[BR]] http://qt.gitorious.org/~pasnox/qt-components/bbx-qt-components [[BR]] Seems to be in early stages and no code has been comited yet.