{"id":17,"date":"2007-01-25T19:16:00","date_gmt":"2007-01-25T18:16:00","guid":{"rendered":"http:\/\/www.tapper-ware.net\/blog\/?p=17"},"modified":"2010-03-04T00:29:46","modified_gmt":"2010-03-03T23:29:46","slug":"tutorial-for-native-arm-palmos-applications-using-prc-tools","status":"publish","type":"post","link":"https:\/\/www.tapper-ware.net\/blog\/tutorial-for-native-arm-palmos-applications-using-prc-tools\/","title":{"rendered":"Tutorial for native ARM PalmOS applications using PRC-Tools"},"content":{"rendered":"<p>Writing applications for PalmOS using native ARM code, especially using only free tools is something that seems impossible to most people. Well, with this tutorial I aim to prove them wrong: the aim is create a simple breakout tool using only free tools. It&#8217;s primarily aimed at people who have some experience with the programming language C, but have never developed for PalmOS. However if you have some understanding of how a computer works, you should be able to complete it without too many difficulties as well.<\/p>\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">Basically, this document is divided into the following parts:<\/p>\n<ol>\n<li>\n<p style=\"margin-bottom: 0cm;\">Tools Setup<\/p>\n<ol>\n<li>\n<p style=\"margin-bottom: 0cm;\">Cygwin<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0cm;\">PRC-Tools<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0cm;\">PalmOS SDK<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0cm;\">PEAL<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0cm;\">PARM Lib<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0cm;\">pilrc<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">The breakout game will be posted lateron \ud83d\ude42<\/p>\n<h1 class=\"western\">Tools<\/h1>\n<p>Naturally, the first thing you want to do is set up all the tools you&#8217;ll need to compile your code into a PalmOS application, While this is a bit of a task, most of it is pretty straightforward, the most difficult part is actually knowing what you are going to need:<\/p>\n<h2 class=\"western\">Cygwin (and PRC-Tools)<\/h2>\n<p>All the tools you are going to use are actually Linux tools, so the first thing you&#8217;re going to need is a Linux-like environment. Of course you could install Linux, but of course that&#8217;s not for everybody.<\/p>\n<p>Cygwin is basically an environment that translates Linux commands into their Windows counterparts, so that Linux apps can run under Windows. Think of it as a Linux emulator (Before the more experienced users start crying: I know that&#8217;s not the way it works, but for our purposes this comparison is sufficient).<\/p>\n<p>Installation is very simple, just download the installer from <a href=\"http:\/\/www.cygwin.com\/\">http:\/\/www.cygwin.com\/<\/a> (\u201cInstall or update now! (using setup.exe)\u201d) and run it. Chose the following options:<\/p>\n<p>\u201cNext\u201d -&gt;<\/p>\n<p>\u201cInstall from the Internet\u201d, \u201cNext\u201d -&gt;<\/p>\n<p>\u201cRoot Directory\u201d (Enter the path where you want to install Cygwin), \u201cInstall for All Users\u201d, \u201cDefault Text File Type Unix \/ binary\u201d, \u201cNext\u201d -&gt;<\/p>\n<p>\u201cLocal Package Directory\u201d (Enter path where downloaded files should be saved, so you can reuse them when reinstalling Cygwin), \u201cNext\u201d -&gt;<\/p>\n<p>\u201cDirect Connection\u201d or whatever you need to get a connection to the internet, \u201cNext\u201d -&gt;<\/p>\n<p>Enter \u201c<a href=\"http:\/\/prc-tools.sourceforge.net\/\">http:\/\/prc-tools.sourceforge.net<\/a>\u201d into the \u201cUser URL:\u201d field, press \u201cAdd\u201d, Locate \u201c<a href=\"http:\/\/prc-tools.sourceforge.net\/\">http:\/\/prc-tools.sourceforge.net<\/a>\u201d in the list, click to select, locate a different mirror, for example \u201c<a href=\"http:\/\/ftp.heanet.ie\/\">http:\/\/ftp.heanet.ie<\/a>\u201d is pretty reliable, hold down \u201cCTRL\u201d while selecting it, check if both \u201c<a href=\"http:\/\/prc-tools.sourceforge.net\/\">http:\/\/prc-tools.sourceforge.net<\/a>\u201d and \u201c<a href=\"http:\/\/ftp.heanet.ie\/\">http:\/\/ftp.heanet.ie<\/a>\u201d are selected, \u201cNext\u201d -&gt;<\/p>\n<p>Click on the \u201c+\u201d in front of \u201cDevel\u201d and find the packages \u201cGCC\u201d, \u201cMake\u201d, \u201cPRC-Tools\u201d and \u201cPRC-Tools-ARM\u201d. Click on the word \u201cSkip\u201d next to them until it says \u201cinstall\u201dor the latest version number (Don&#8217;t install \u201cpilrc\u201d), \u201cNext\u201d -&gt;<\/p>\n<p>\u201cInstallation Complete\u201d<\/p>\n<p>Now the compiler is installed and ready.<\/p>\n<h2 class=\"western\">PalmOS SDK<\/h2>\n<p>Unfortunately, you need a little more than just a compiler to create a working program. You also need some libraries that allow you access to the PalmOS system internals. These libraries are contained in the PalmOS SDK. To get it, you have to register at <a href=\"http:\/\/www.developerpavilion.com\/\">http:\/\/www.developerpavilion.com\/<\/a>. After you have registered, sign in and go to \u201cPalm OS Developer Tools\u201c. Chose \u201cCore Palm OS SDK\u201d and finally download \u201cPalm OS Garnet SDK (68K) R3 PRC tools Generic UNIX\u201d. Don&#8217;t worry about it saying \u201cUNIX\u201d, that includes Cygwin as well. Create a new directory inside your Cygwin installation and name it \u201cPalmDev\u201d. Save the file to that directory. (While you&#8217;re there, it&#8217;s probably a good idea to also get the PalmOS reference, companions and simulator)<\/p>\n<p>Open the Cygwin Bash Shell from your Start Menu and perform the following actions:<\/p>\n<p>cd \/PalmDev\/<\/p>\n<p>tar -xzf palmos-sdk-5.0r3-1.tar.gz<\/p>\n<p>palmdev-prep<\/p>\n<p>(Of course, if the archive has a different file name, use that instead of \u201cpalmos-sdk-5.0r3-1.tar.gz\u201d)<\/p>\n<p>After running palmdev-prep you should get something like this:<\/p>\n<p style=\"margin-left: 2.5cm;\">Checking SDKs in \/PalmDev<\/p>\n<p style=\"margin-left: 2.5cm;\">sdk-5r3       headers in &#8216;include&#8217;, libraries in &#8216;lib&#8217;<\/p>\n<p style=\"margin-left: 2.5cm;\">When GCC is given no -palmos options, SDK &#8216;5r3&#8217; will be used by default<\/p>\n<p style=\"margin-left: 2.5cm;\">Writing SDK details to configuration files&#8230;<\/p>\n<p style=\"margin-left: 2.5cm;\">&#8230;done<\/p>\n<p>OK, so now the SDK is installed and configured as the default option for the PalmOS compiler. Now you could already start writing code for the 68k plattform. But we want to do a little more than that.<\/p>\n<h2 class=\"western\">PEAL<\/h2>\n<p>Problem is that the arm-palmos-gcc compiler, aside from not working well with the SDK, is that it is pretty limited in what C features it supports. Especially global variables are a problem and this is where PEAL comes in. PEAL is a little parser that relocates data so that global variables work. To install it, just download the tar.gz archive from <a href=\"http:\/\/www.sealiesoftware.com\/peal\/\">http:\/\/www.sealiesoftware.com\/peal\/<\/a> and place it in PalmDev as well. Extract it with<\/p>\n<p>tar -xzf peal-2005_4_14.tar.gz<\/p>\n<p>(Or whatever you named that file).<\/p>\n<p>This will extract peal and create a directory named something like \u201cpeal-2005_4_14\u201d to rename it to just \u201cpeal\u201d enter<\/p>\n<p>mv peal-2005_4_14 peal<\/p>\n<p>Now, change to that directory with<\/p>\n<p>cd peal<\/p>\n<p>And go to the postlink directory<\/p>\n<p>cd postlink<\/p>\n<p>Now all you&#8217;ve got to do is compiling PEAL. Just type in<\/p>\n<p>make<\/p>\n<p>You&#8217;ll get a few warnings, but after a few seconds you&#8217;ll get back to the shell.<\/p>\n<p>Enter<\/p>\n<p>.\/peal-postlink<\/p>\n<p>and you get the help message for PEAL.<\/p>\n<h2 class=\"western\">PARM<\/h2>\n<p>Now we have to overcome the final (and most difficult) shortcoming of arm-palmos-gcc: It&#8217;s inability to communicate with PalmOS. PARM does some magic to do this&#8230; it&#8217;s rather complicated and you actually don&#8217;t need to understand it, so there&#8217;s no point trying to explain it. Installation is very simple, just download <a href=\"http:\/\/www.tapper-ware.net\/files\/PARM.zip\">http:\/\/www.tapper-ware.net\/files\/PARM.zip<\/a> and extract it to your PalmDev directory. It will create a PARM directory containing the necessary files and an example. Change to the example directory with<\/p>\n<p>cd \/PalmDev\/PARM\/example\/<\/p>\n<p>The sample code is contained in main.c, make68k.sh contains the information to build the application so that the PalmOS simulator can run it, while makepno.sh compiles the real ARM application. Try it. Run<\/p>\n<p>.\/make68k.sh<\/p>\n<p>and a main68k.prc file should appear in the directory. Drag it onto the simulator and run \u201cMyBreakout\u201d. It will display an empty screen and when you click somewhere it will draw \u201cHello World\u201d at that point.<\/p>\n<p>Now try to build the native application. Run<\/p>\n<p>.\/makepno.sh<\/p>\n<p>and it will first output a warning message<\/p>\n<p style=\"margin-left: 1.25cm;\">In file included from ..\/..\/pnotest.c:27:<\/p>\n<p style=\"margin-left: 1.25cm;\">..\/..\/pace_gen.c: In function `StrPrintF&#8217;:<\/p>\n<p style=\"margin-left: 1.25cm;\">..\/..\/pace_gen.c:133: warning: dereferencing type-punned pointer will break stri<\/p>\n<p style=\"margin-left: 1.25cm;\">ct-aliasing rules<\/p>\n<p>Just ignore it, that&#8217;s normal. You&#8217;ll get it every time you compile something, there&#8217;s nothing wrong with that. A mainpno.prc file should appear that&#8217;s identical to main68k.prc, but contains fast, native ARM code. Hotsync it and see if it works. If makepno.sh throws any more errors than it probably can&#8217;t find some file, because you placed it somewhere other than the default location. In that case you need to edit the make* scripts. You really only need a simple text-editor for that, but it has to support UNIX-style linebreaks&#8230; that&#8217;s something pretty much any editor besides notepad can do, but my favourite editor is SciTE ( <a href=\"http:\/\/scintilla.sourceforge.net\/SciTEDownload.html\">http:\/\/scintilla.sourceforge.net\/SciTEDownload.html<\/a> ), because it requires no installation and has pretty good source highlighting for about any programming language I know. Open makepno.sh in the editor of your choice and you&#8217;ll see the script&#8217;s source. The most common problem is that you installed PEAL somewhere else than \/PalmDev\/peal . Just look through it and most likely, you&#8217;ll spot the culprit within seconds.<\/p>\n<h2 class=\"western\">Pilrc<\/h2>\n<p>Pilrc is a resource editor for PalmOS. You&#8217;ll need it to add icons, forms, bitmaps and so on to your PRC file. Just download pilrc-3.2-win32.zip from <a href=\"http:\/\/sourceforge.net\/project\/showfiles.php?group_id=7404\">http:\/\/sourceforge.net\/project\/showfiles.php?group_id=7404<\/a> and extract it to your \\windows\\system32\\ directory. That&#8217;s it \ud83d\ude42 I&#8217;m not going to give you a sample now, but we&#8217;re going to need it when we do the breakout game next time.<\/p>\n<p>See you then \ud83d\ude42<\/p>\n<p>Hans<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Writing applications for PalmOS using native ARM code, especially using only free tools is something that seems impossible to most people. Well, with this tutorial I aim to prove them wrong: the aim is create a simple breakout tool using only free tools. It&#8217;s primarily aimed at people who have some experience with the programming &hellip; <a href=\"https:\/\/www.tapper-ware.net\/blog\/tutorial-for-native-arm-palmos-applications-using-prc-tools\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Tutorial for native ARM PalmOS applications using PRC-Tools<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/posts\/17"}],"collection":[{"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/comments?post=17"}],"version-history":[{"count":1,"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":60,"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/posts\/17\/revisions\/60"}],"wp:attachment":[{"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/media?parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/categories?post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/tags?post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}