NADK Sample Demos

Location

$REVOLUTION_SDK_ROOT/build/demos/cntdemo

Example of a NAND Application Development Procedure Using the Sample Demos

The following introduces the procedures to develop NAND applications using the sample demos (located in /build/demos/cntdemo).
This development procedure uses the CNT API to easily convert disc applications to NAND applications.
(Read dvddata as DvdRoot if they are not the same.)

1. Creating the Application

Create the source in the same way the disc application (ELF file) is normally created. In this case, place the file to be used in dvddata/content2/ and use CNT API to access the file. (See CNT API Function Reference or the sample program source for specific information on using the functions.) Since running make as usual (without setting any special options) creates a disc application, it can be executed with ndrun.

% make
% ndrun bin/RVL/cntdemoD.elf

2. Converting to a NAND Application

A NAND application (WAD file) is created by specifying NANDAPP=TRUE as a make option. If the application loads a file, as in the demo, specify a content file. (Here, the contents directory is specified with the CNT_IDX option.) Because cntdemo uses the two files test1.txt and test2.txt located under /dvddata/content2/, CNT_IDX is set to 2. (For details on make command options, see make Command Options.)
If make is run at this point, an application is created that corresponds to the cntdemo.o object file for disk applications, so execute make clean once and begin the build from the start.


% make clean
% make NANDAPP=TRUE CNT_IDX=2

This procedure causes the following processes to be performed, and in the end, a WAD file is created. Similar commands are described in the makewad target of Makefile (change DVDROOT_DIR as necessary according to your environment).


  1. Building of the file, with the CNT APIs set for use with a NAND application (bin/RVL/cntdemoD.elf is created).

    % make NANDAPP=TRUE NOEXPORT=TRUE

    Note that the only purpose here is the build, so NOEXPORT is defined.

  2. Conversion from an ELF file to a DOL file (bin/RVL/cntdemoD.dol is created).

    % makedol -f bin/RVL/cntdemoD.elf -d bin/RVL/cntdemoD.dol

  3. Compression of the DOL file (bin/RVL/cntdemoD.dol.lz7 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 -A option.

    % ntcompress -lex -A32 -o bin/RVL/cntdemoD.dol.lz7 bin/RVL/cntdemoD.dol

  4. Archiving of the files in the dvddata/content2 directory (/dvddata/archives/content2.arc is created).

    % cd ../../../dvddata/content2; darch -c * ../archives/content2.arc

  5. Packaging of the compressed DOL file and the content file and creation of the WAD file. (bin/RVL/cntdemoD.wad is created.)

    % makeWad -n cntdemoD -l bin/RVL/cntdemoD.dol.lz7,../../../dvddata/archives/content2.arc

3. Preparing for Import

Copy the WAD file to the dvddata/viewer directory (if DvdRoot is different and the viewer directory does not exist, please create it). Next, start Nmenu (Nmenu.elf).

% mv bin/RVL/cntdemoD.wad ../../../dvddata/viewer
% ndrun ../../../RVL/bin/tools/Nmenu.elf	

4. Importing and Executing

Nmenu starts in Import Mode. In Import Mode, the WAD file in DvdRoot/viewer can be imported. Press A and import cntdemoD.wad. Next, press B to enter Title List Mode. Pressing the A button at this time causes the application to execute. (Click here for information on Nmenu.) The following log is output to the serial port.

read end

First file:
abcdefghijklmnopqrstuvwxyz

abcdefghijklmnopqrstuvwxyz

abcdefghijklmnopqrstuvwxyz

abcdefghijklmnopqrstuvwxyz

Second file:
ABCDEFGHIJKLMNOPQRSTUVWXYZ

ABCDEFGHIJKLMNOPQRSTUVWXYZ

ABCDEFGHIJKLMNOPQRSTUVWXYZ

ABCDEFGHIJKLMNOPQRSTUVWXYZ



End of demo in "cntdemo.c" on line 197.

5. Adding Various Settings

The 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 makeWad.

Debugging in CodeWarrior

Using cntdemo as an example, the following will show an example method for making the settings for debugging a NAND application in CodeWarrior.

1. Running CodeWarrior and Loading the Executable File

Start CodeWarrior from the shell.

% rvl_ide.sh
Next, drag and drop an ELF file (not a WAD file) into CodeWarrior to load it.

2. Execution Script Settings (For Execution Only)

From the Edit menu, select Default Wii Project Settings. Alternatively, press ALT+F7 or use the settings tab to open the default Wii project settings. Change the execution script to wadbuildrun.bat or wadbuildrun.bat as shown in the image, and remove $P. wadrun.bat will execute only; wadbuildrun.bat will perform a build before executing. For details, see appropriate sections in the manual.
Note that even if you press the Build button in CodeWarrior, the build that is performed will not be for NAND application use.

Default Wii Project Settings Screen

3. Executing and Debugging

To debug a NAND application, press the Debug Execution 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.

4. Execution Script Settings (For Build and Execution)

As discussed previously, wadbuildrun.bat should be specified when one wishes to perform a build before execution. Therefore, to perform a build and execute, specify wadbuildrun.bat in Step 2. This batch command will also call buildwad.bat from the same directory as Makefile; buildwad.bat is a batch command for building WAD files.
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 RABA and a company code of ZZ would look like the following. For more information on options, see make command options and makeWad.

make NANDAPP=TRUE CNT_IDX=2 WAD_OPTION="-gc RABA -g ZZ"
move bin\RVL\%1 %REVOLUTION_SDK_ROOT%\dvddata\viewer\

Note

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 CNTRead return value for DVD applications, but a different value, the actual size that was read, is returned for NAND applications.

Revision History

2009/01/15 Changed darchD to darch.
2008/03/14 Corrected links.
2008/01/08 Added a section about compression of programs. Standardized the use of "Nmenu."
2007/11/20 Standardized the use of the term "content file".
2007/09/12 Corrected a typo.
2007/08/06 Added descriptions of how to configure various settings.
2007/05/10 Added a description on methods for debugging in CodeWarrior.
2006/08/15 Initial version.


CONFIDENTIAL