Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
The Swadge has three options for serial debug output which are configured by running idf.py menuconfig
, navigating to the Swadge Configuration
menu, and then the Select Debug Output
menu. After the debug output option is selected, the firmware should be clean, built, and flashed as normal. The three options are as follows.
This option will route serial debug output through the ESP32-S2's default UART pin (GPIO 43). This is exposed as SMD pad on the back of the Swadge and must be soldered to be used.
To bridge this output to a computer, a UART to USB converter must be used, like an FT232 board or an FTDI cable. Any serial terminal program, like PuTTY should work. When opening up the port, use the following settings:
Once the Swadge is connected, assuming everything worked, it should look something like this:
This option will route serial debug output through a pin on the Simple Add-On (SAO) connector (GPIO 18). It's functionally the same as DEBUG_OUTPUT_UART
, but in a more physically accessible location. The two pins used are:
This option will route serial debug output over the USB header. In general you can perform the following two steps to accomplish flashing and logging over the USB interface while the swadge is operating.
This command will install udev rules on Linux to allow you to use the swadge for printf and other advanced USB features. You only need to call it once
Then any time you wish to reboot the swadge into bootloader, flash, reboot back into code and monitor, execute the following:
For more background, the Swadge doesn't enumerate as a regular serial port, so you must run our own serial monitor, swadgeterm
to view the output. To build swadgeterm
from the root of this repository, run:
To run swadgeterm
after building:
To do build and run in one command:
You should run swadgeterm
before plugging in or powering on the Swadge. Assuming everything worked, it should look something like this:
To figure out where your last crash was, execute the xtensa-esp32s2-elf-addr2line
line as it appears in the log. I.e.
Note that the reflash_and_monitor.bat
batch launches swadgeterm
and assumes the firmware was compiled with DEBUG_OUTPUT_USB
.
Also note that USB output is needs to be initialized during the startup process, so you may miss very early system debug messages before USB: USB initialization DONE
.
If the Swadge crashes, the system will print crash information on the non-USB UART. This will not be printed on when using DEBUG_OUTPUT_USB
. It will look something like this:
You can interpret the backtrace with the program xtensa-esp32s2-elf-addr2line
and the exact elf
file that was flashed. This will print a detailed stack trace noting exactly where the crash occurred.
crashwrap
When DEBUG_OUTPUT_USB
is used, the Swadge will save crash information when it crashes and print it the next time it boots up. It will look something like this:
You can copy/paste the last line into your terminal to get a full stack trace to get the function name / line numbers of all the calls.