Home

Awesome

ed64log

enables printf() logging over usb from homebrew games built using the n64 sdk, while running on an everdrive 64 device.

getting started

at a high level, the steps involved are:

then to run your game with logging:

implement usb logging in your n64 game

synchronous logging

asynchronous logging

you can see an example of implementing logging in a game in this commit to goose64.

osSyncPrintf support

you can override nintendo's implementation of osSyncPrintf with an ed64log-based version by calling ed64ReplaceOSSyncPrintf() once as part of your game's startup process. this will allow all osSyncPrintf() calls to work, including debug error messages in libultra_d and libmus_d.

exception logger

optionally, you can set up an exception handler thread to automatically log details when an exception occurs (eg. invalid memory access) by calling ed64StartFaultHandlerThread(), passing the thread priority to run at (typically, the same as the main thread) like this. for usage details, see the example app readme.

OS error logger

optionally, you can override the default N64 OS error handler which prints errors in calls to libultra functions to osSyncPrintf, with one that prints to ed64SyncPrintf instead, by calling ed64RegisterOSErrorHandler() once in the initialization of your progam.

note: this is not needed if you override osSyncPrintf() as described above.

watchdog timer

if you experience a freeze/hang in your game which doesn't produce any useful error message, you can create a watchdog timer to detect when the game has frozen and then print out useful information about the application state.

ed64StartWatchdogThread takes a pointer to an integer value which should continually change while the program is working correctly (eg. a counter of the absolute frame number) and an interval in milliseconds at which the watchdog will check if the program is still running. when the watchdog timer interrupts the program it will check if the current value of the integer has changed since the last check. if the program has frozen (for example, having entered an infinite loop), the watchdog thread will print the current state of each thread, and a stacktrace of the thread's execution.

example:

ed64StartWatchdogThread(&intValueThatIncrements, 500);

connecting from your computer (all platforms, node.js based)

on any OS, you can use the node.js-based client to receive logs

first install node and npm

then install ed64logjs:

npm install -g ed64logjs

then, after starting the game on the everdrive, run

ed64logjs

connecting from your computer (macOS native)

install required libraries from homebrew:

brew install libftdi libusb

then, after starting the game on the everdrive, run

./ed64log

this will output the logs as they are sent from the everdrive

connecting from your computer (linux native)

install libftdi from your package manager of choice (including headers). eg for ubuntu:

sudo apt-get install libftdi1 libftdi1-dev

compile the ed64log tool from source:

./make.sh

then, to start tailing the logs:

# needs sudo to access usb device
sudo ./ed64log

acknowledgements

the source of the ed64log client is based on loader64 by saturnu tt@anpa.nl