1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> 4<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css"> 5<base target="main"> 6<title>NADK Sample Demos</title> 7</head> 8 9<body> 10 11<h1>NADK Sample Demos</h1> 12<h2>Location</h2> 13<p> 14<code>$REVOLUTION_SDK_ROOT/build/demos/cntdemo</code> 15</p> 16 17<h2>Example of a NAND Application Development Procedure Using the Sample Demos</h2> 18<p>The following introduces the procedures to develop NAND applications using the sample demos (located in <CODE>/build/demos/cntdemo</CODE>).<br>This development procedure uses the CNT API to easily convert disc applications to NAND applications.<br>(If <CODE>DvdRoot</CODE> is not <CODE>dvddata</CODE>, please switch to it and re-read.)</p> 19<H3>1. Creating the application</H3> 20<p> 21Create the source in the same way the disc application (ELF file) is normally created. In this case, place the file to be used in <CODE>dvddata/content2/</CODE> and use CNT API to access the file. (See <a href=./list.html>CNT API Function Reference</a> or the sample program source for specific information on using the functions.) Since running <CODE>make</CODE> as usual (without setting any special options) creates a disc application, it can be executed with <CODE>ndrun</CODE>. <br> 22<TABLE border="1" width="100%"> 23 <TBODY> 24 <TR> 25 <TD width="100%"> 26 <PRE><CODE> 27% make 28% ndrun bin/RVL/cntdemoD.elf</CODE></PRE> 29 </TD> 30 </TR> 31 </TBODY> 32</TABLE> 33</p> 34<H3>2. Converting to a NAND application</H3> 35<p> 36A NAND application (WAD file) is created by specifying <CODE>NANDAPP=TRUE</CODE> as a <CODE>make</CODE> option. If the application loads a file, as in the demo, specify a content file. (Here, the contents directory is specified with the <CODE>CNT_IDX</CODE> option.) Because <CODE>cntdemo</CODE> uses the two files <CODE>test1.txt</CODE> and <CODE>test2.txt</CODE> located under <CODE>/dvddata/content2/</CODE>, <CODE>CNT_IDX</CODE> is set to 2. (For details on <CODE>make</CODE> command options, see <a href="./tools/make.html"><CODE>make</CODE> Command Options</a>.) <br> If <CODE>make</CODE> is run at this point, an application is created that corresponds to the <CODE>cntdemo.o</CODE> object file for disk applications, so execute <CODE>make clean</CODE> once and begin the build from the start. <br> 37</p> 38<TABLE border="1" width="100%"> 39 <TBODY> 40 <TR> 41 <TD width="100%"> 42 <PRE><CODE> 43% make clean 44% make NANDAPP=TRUE CNT_IDX=2</CODE></PRE> 45 </TD> 46 </TR> 47 </TBODY> 48</TABLE> 49<br> 50<p> 51This procedure causes the following processes to be performed, and in the end, a WAD file is created. Similar commands are described in the <CODE>makewad</CODE> target of <CODE>Makefile</CODE> (change <CODE>DVDROOT_DIR</CODE> as necessary according to your environment). <br><br><br> 52<ol> 53<li> 54Building of the file, with the CNT APIs set for use with a NAND application (<CODE>bin/RVL/cntdemoD.elf</CODE> is created).<br><br><CODE>% make NANDAPP=TRUE NOEXPORT=TRUE</CODE><br><br>Note that the only purpose here is the build, so <CODE>NOEXPORT</CODE> is defined.<br><br> 55</li> 56<li> 57Conversion from an ELF file to a DOL file (<CODE>bin/RVL/cntdemoD.dol</CODE> is created).<br><br> <CODE>% makedol -f bin/RVL/cntdemoD.elf -d bin/RVL/cntdemoD.dol</CODE><br><br> 58</li> 59<li> 60Compression of the DOL file (<CODE>bin/RVL/cntdemoD.dol.lz7</CODE> is created). The system is set so that LZ77 extended compression is specified for the compression format and the size is aligned to a 32-byte boundary by using the <CODE>-A</CODE> option.<br><br><CODE>% ntcompress -lex -A32 -o bin/RVL/cntdemoD.dol.lz7 bin/RVL/cntdemoD.dol</CODE><br><br> 61</li> 62<li> 63Archiving of the files in the <CODE>dvddata/content2</CODE> directory (<CODE>/dvddata/archives/content2.arc</CODE> is created).<br><br> <code>% cd ../../../dvddata/content2; darchD -c * ../archives/content2.arc<br></code> <br> 64</li> 65<li> 66Packaging of the compressed DOL file and the content file and creation of the WAD file. (<CODE>bin/RVL/cntdemoD.wad</CODE> is created.)<br><br> <code>% makeWad -n cntdemoD -l bin/RVL/cntdemoD.dol.lz7,../../../dvddata/archives/content2.arc</code><br><br> 67</li> 68</ol> 69</p> 70<H3>3. Preparing for import</H3> 71<p> 72Copy the WAD file to the <CODE>dvddata/viewer</CODE> directory (if <CODE>DvdRoot</CODE> is different and the <CODE>viewer</CODE> directory does not exist, please create it). Next, start <CODE>Nmenu</CODE> (<CODE>Nmenu.elf</CODE>). 73<TABLE border="1" width="100%"> 74 <TBODY> 75 <TR> 76 <TD width="100%"> 77 <PRE><CODE> 78% mv bin/RVL/cntdemoD.wad ../../../dvddata/viewer 79% ndrun ../../../RVL/bin/tools/Nmenu.elf </CODE></PRE> 80 </TD> 81 </TR> 82 </TBODY> 83</TABLE> 84</p> 85<H3>4. Importing and executing</H3> 86<p> 87<CODE>Nmenu</CODE> starts in Import Mode. In Import Mode, the WAD file in <CODE>DvdRoot/viewer</CODE> can be imported. Press A and import <CODE>cntdemoD.wad</CODE>. Next, press B to enter Title List Mode. Pressing the A button at this time causes the application to execute. (Click <a href="./Nmenu.html">here</a> for information on <CODE>Nmenu</CODE>.) The following log is output to the serial port. 88<TABLE border="1" width="100%"> 89 <TBODY> 90 <TR> 91 <TD width="100%"> 92 <PRE><br> 93read end<br><br> 94First file:<br> 95abcdefghijklmnopqrstuvwxyz<br><br> 96abcdefghijklmnopqrstuvwxyz<br><br> 97abcdefghijklmnopqrstuvwxyz<br><br> 98abcdefghijklmnopqrstuvwxyz<br><br> 99Second file:<br> 100ABCDEFGHIJKLMNOPQRSTUVWXYZ<br><br> 101ABCDEFGHIJKLMNOPQRSTUVWXYZ<br><br> 102ABCDEFGHIJKLMNOPQRSTUVWXYZ<br><br> 103ABCDEFGHIJKLMNOPQRSTUVWXYZ<br><br> <br><br> 104End of demo in "cntdemo.c" on line 197. 105</PRE> 106 </TD> 107 </TR> 108 </TBODY> 109</TABLE> 110</p> 111 112<H3>5. Adding various settings</H3> 113<p> 114The procedures up through Step 4 have resulted in the creation of an operational NAND application. Here, as an example, we show how to specify an initial code of RABA and a company code of ZZ for a WAD file. For more about configuring the other items, refer to <a href="tools/makeWad.html"><CODE>makeWad</CODE></a>.<br><br> 115<ul> 116<li> 117<b>Specify directly with options when executing <CODE>makeWad</CODE></b><br><br>Specify them with options when executing <CODE>makeWad</CODE> in Step 2. Since <CODE>-gc</CODE> specifies the initial code and <CODE>-g</CODE> is used for the company code, the command to be executed is as follows.<br> 118<TABLE border="1" width="100%"> 119 <TBODY> 120 <TR> 121 <TD width="100%"> 122 <PRE><br><code>% makeWad -n cntdemoD -l bin/RVL/cntdemoD.dol,../../../dvddata/archives/content2.arc <font color=red>-gc RABA -g ZZ</font></code><br></PRE> 123 </TD> 124 </TR> 125 </TBODY> 126</TABLE><br> 127</li> 128<li> 129<b>Specify with the <CODE>WAD_OPTION</CODE> option of <CODE>make</CODE> during the build</b><br><br> You can configure the settings and pass the options to <CODE>makeWad</CODE> by specifying <CODE>WAD_OPTION</CODE> when building the application.<br> 130<TABLE border="1" width="100%"> 131 <TBODY> 132 <TR> 133 <TD width="100%"> 134<PRE><br><code>% make NANDAPP=TRUE CNT_IDX=2 <font color=red>WAD_OPTION="-gc RABA -g ZZ"</font></code><br></PRE> 135 </TD> 136 </TR> 137 </TBODY> 138</TABLE><br> 139</li> 140</ul> 141</p> 142 143 144<h2>Debugging in CodeWarrior</h2> 145<p> 146Using <CODE>cntdemo</CODE> as an example, the following will show an example method for making the settings for debugging a NAND application in CodeWarrior. 147</p> 148<H3>1. Running CodeWarrior and loading the executable file</H3> 149<p> 150Start CodeWarrior from the shell. 151<TABLE border="1" width="100%"> 152 <TBODY> 153 <TR> 154 <TD width="100%"> 155 <PRE><CODE> 156% rvl_ide.sh 157</CODE></PRE> 158 </TD> 159 </TR> 160 </TBODY> 161</TABLE> 162Next, drag and drop an ELF file (<font color="red">not a WAD file</font>) into CodeWarrior to load it. 163</p> 164 165<H3>2. Execution script settings (for execution only)</H3> 166<p> 167From the <B>Edit</B> menu, select <B>Default Wii Project Settings</B>. Alternatively, press ALT+F7 or use the settings tab to open the default Wii project settings. Change the execution script to <CODE>wadbuildrun.bat</CODE> or <CODE>wadbuildrun.bat</CODE> as shown in the image, and remove <CODE>$P</CODE>. <a href="tools/wadrun.html"><CODE>wadrun.bat</CODE></a> will execute only; <a href="tools/wadbuildrun.html"><CODE>wadbuildrun.bat</CODE></a> will perform a build before executing. For details, see appropriate sections in the manual.<br> Note that even if you press the <B>Build</B> button in CodeWarrior, the build that is performed will not be for NAND application use.<br><br> <img src="img/CWSetting.png" alt="Default Wii Project Settings Screen"> 168</p> 169 170<H3>3. Executing and debugging</H3> 171<p> 172To debug a NAND application, press the <B>Debug Execution</B> button or the F5 key, which will start up the N menu; after a WAD file is imported, the NAND application will be started in debugger mode. Afterwards, debugging may be performed using a debugger in the same way as a normal disc application. 173</p> 174 175<H3>4. Execution script settings (for build and execution)</H3> 176<p> 177As discussed previously, <CODE>wadbuildrun.bat</CODE> should be specified when one wishes to perform a build before execution. Therefore, to perform a build and execute, specify <CODE>wadbuildrun.bat</CODE> in Step 2. This batch command will also call <CODE>buildwad.bat</CODE> from the same directory as Makefile; <CODE>buildwad.bat</CODE> is a batch command for building WAD files.<br>The settings for building a NAND application may be changed by editing this batch file. For example, a batch file that generates WAD files with a game code of <CODE>RABA</CODE> and a company code of <CODE>ZZ</CODE> would look like the following. For more information on options, see <a href="tools/make.html"><CODE>make</CODE> command options</a> and <a href="tools/makeWad.html"><CODE>makeWad</CODE></a>. 178<TABLE border="1" width="100%"> 179 <TBODY> 180 <TR> 181 <TD width="100%"> 182 <PRE><CODE> 183make NANDAPP=TRUE CNT_IDX=2 <font color="red">WAD_OPTION="-gc RABA -g ZZ"</font> 184move bin\RVL\%1 %REVOLUTION_SDK_ROOT%\dvddata\viewer\ 185</CODE></PRE> 186 </TD> 187 </TR> 188 </TBODY> 189</TABLE> 190</p> 191 192 193<h2>Note</h2> 194<p>It is also mentioned in the demo program source, but the end of the archive file is not 32-byte aligned. Accordingly, a specified 32-byte aligned value is returned as the <CODE>CNTRead</CODE> return value for DVD applications, but a different value, the actual size that was read, is returned for NAND applications.</p> 195 196<h2>Revision History</h2> 197<p> 1982008/03/14 Corrected links.<br>2008/01/08 Added a section about compression of programs. Standardized the use of "Nmenu."<BR>2007/11/20 Standardized the use of the term "content file".<BR>2007/09/12 Corrected a typo.<br>2007/08/06 Added descriptions of how to configure various settings.<br>2007/05/10 Added a description on methods for debugging in CodeWarrior.<br>2006/08/15 Initial version. 199</p> 200 201 202<hr><p>CONFIDENTIAL</p></body> 203</html> 204