Developing Software with the NetCard SDK

$Revision: 1.19 $
$Date: 2007/09/07 20:22:36 $

Introduction

vnproxy, ncshell and ncprint

vnproxy is the USB proxy server for diverting USB traffic to different applications on your PC - ncshell and ncprint are two such applications. ncshell is the host application for managing the NC and its file system. It accepts commands from PC and communicates with (sends requests  to /receives responses from) NC via USB. For the list of supported commands in ncshell, type "help" once you start ncshell.

ncprint serves printfs for GBA, DS or NC applications through USB. In release 1.1 of the NetCard SDK, vnproxy can handle printfs directly when invoked with the -p option, so ncprint is optional. It may still be desirable to run ncprint in a separate window if the interleaving of printf messages with other messages generated by vnproxy makes the output hard to read.

NetCard Supports both DS and GBA Games

As of release 1.13, the SDK supports development of games for both the GBA and DS platforms. DS games are published and imported onto the NetCard in the same fashion as GBA games. There are some flags that need to be specified to allow the NetCard to recognize the correct platform for each game. Sample viewer programs are provided for both the DS and GBA platforms.

Publishing and Launching the Sample DS Viewer

The source for the sample DS viewer is under:

The Makefile in that directory will produce an srl file containing the DS ROM image of the viewer: ncviewer/bin/ARM9-TS/Release/main.srl. It then uses arm-elf-merge and publish.py to publish this for NetCard. Please import the resulting wad file as follows:

    ncshell
    > import ncviewer.bwf
    > quit

Looking at the rules in the Makefile, the following things are noteworthy:

In order to launch GBA games from the DS viewer, an additional application called gba-switch is needed. To create and import gba-switch, do the following:
        cd $(NITROSDK_ROOT)/build/tools/gba-switch-arm7
        make
        cd $(NITROSDK_ROOT)/build/tools/gba-switch
        make
        ncshell
        > import gba-switch.bwf
        > quit
Note that both the DS and GBA viewers need to be updated to SDK 1.15 or later in order to launch GBA games from the DS viewer.

Publishing and Launching a DS Game

The steps for a DS game are the same as for the DS Viewer, except that the "-Z" flag is not used in the publish step:

    arm-elf-merge -D main.srl -o mygame.mrg
    publish.py -n mygame -l mygame.mrg
    ncshell
    > import mygame.bwf
    > quit

Powercycle the DS and restart it in DS mode. The DS NC viewer will show a list of the available games, including the one just imported. Use the up and down keys to select a game and then press the "A" key to launch it.

As of SDK 1.14, the NitroSDK libraries support printing over USB through the NetCard. Simply call printf in the DS game and the output should appear in the vnproxy window.

Publishing and Launching the Sample GBA Viewer

Publishing and Launching a GBA Game

About the Sample Viewer

The sample viewer demonstrates how to use ES and ISFS APIs such as title listing, eTicket listing, title launching, as well as meta file accessing calls. Note all the parameters passed to ES and ISFS APIs need to be declared in the GBA .data section. Please refer to ES and ISFS API doc for more details.

Each title can be published with a meta file containing the description for the title (for example, the title string and the thumbnail image). Viewer should define what goes into a meta file. Meta file is stored as /meta/titleId/metaCid.met on Flash. Viewer can use ISFS APIs to read the meta file. To publish a title using a meta file, use the "-m" option for "publish.py". By default, "publish.py" uses the -n option as the title string in the meta file. The sample viewer demonstrates how to use the ISFS APIs to read the meta file associated with a title, and renders the title string on screen.

Debugging Viewer and Applications

The current SDK supports the ability for an application on the GBA to use printf for debugging. To use this facility, start vnproxy -p to communicate with the NetCard. Then launch the GBA game using the viewer. The printf messages should appear in the vnproxy window.

If the GBA application calls printf, include an additional library on the link command (ld) for the game ELF file: libvio_usb.a (-lvio_usb).

Tools Reference

The SDK uses several critical tools. For the most part these tools are used in makefiles, so you do not need to understand all their functions to get started. Below are the help lines from the tools as a reference.

publish.py - a python script that can be used to create all the necessary information to publish and ticket an application
arm-elf-merge - a program which is used to create an elf file which the system can load and execute.
ncshell - an interactive program which allows the user to interact with the development shell on the NC
ncprint - a non-interactive program which displays the results of printf calls executed in a program on the NC/GBA (no longer needed if you use the -p option of vnproxy.
vnproxy - a program which handles direct communication with the NC. It must be running for ncshell and ncprint to function

publish.py - publishing tool for NetCard

$ROOT/usr/bin/x86/publish.py -n <name> [-l <elf1>,<elf2>,...] [-m <metaFile>] [-s stateMode] [-r] [-v] [-i] [-D devcert.sys] [-t] [-p] [-W] [-Z]
input: -n <titleName>: name of the title to be published
       -l <elf1,elf2,...>: list of ELF files for the title
          do not use -l if you only want to generate ticket
       -m <metaFile>: meta file for the title (default to titleName)
       -s <stateMode>
          1: sram 256K
          2: flash 512K
          3: flash 1024K
          4: eerom 4K
          5: eerom 64K
       -r: title requires RTC
       -v: title is the GBA viewer
       -W: title is a DS game
       -Z: title is the DS viewer (implies -W)
       -i: issue individualized ticket
       -D devcert.sys: device certificate for individualized ticket
       -t: issue ticket with random ticketId than default
       -p: publish title only, do not ticket
output: <titleName>.bwf file for import using ncshell
        ticket file <ticketId>.tik
        TMD file <tmdCid>.tmd
        meta file <metaCid>.met
        encrypted content files <cids>.app

arm-elf-merge - tool for merging various pieces of ELF file into one launchable ELF file for NetCard

$ROOT/usr/bin/x86/arm-elf-merge
    -n, --nc filename - NC executable file.
    -g, --gba filename - GBA ELF executable file.
    -G, --GBA filename - GBA ROM file.
    -D, --DS filename - DS ROM file.
    -l, --viewer filename - Viewer executable file.
    -o, --outfile filename - output file.
    -h, --help - print this message.

ncshell - tool for managing NetCard from windows command line via USB connection to NetCard

$ROOT/usr/bin/x86/ncshell [-b] [-i ip_address] [-p port_number] [-s script(batch mode)]
    -b enable boot operation
    -i ip_address specify vnproxy ip address
    -p port_number specify vnproxy port number
    -s script run given script file
NC shell command:
    h - help
    cd [new dir] - change current directory
    diag [aud|flash|rtc|gba] - run given diagnostics
    format - format file system
    import pc_wad_file - import a published app from pc to nc
    ls - list file or directory
    pwd - get current directory
    mkdir dir - create directory
    mv old new - rename file (cp + rm) or dir
    cp old new - cp file
    ping - handshake
    put pc_file nc_file - upload pc file to nc
    get nc_file pc_file - download nc_file to pc
    rm [file/dir] - remove file or directory
    rb which_boot file - download given boot and write to file
    s filename - run given cmd script
    ver - display build time
    q - quit

API Reference

The main API's used for initial development of the viewer are the Eticket services API and the File system API. These are documented in:

    Eticket Services and Secure File System API

For NUP and Ecommerce development the following documents are relevant:

    Network Update API
    Ecommerce Library API

Known Issues