BitMagic X16 Remote
Debug BitMagic programs on a real Commander X16, from VS Code, over the X16's WiFi card, and reach
its SD card while you're at it. Breakpoints go on source lines as normal, and the X16's screen and
VRAM are left alone while it's stopped. It's made for code that needs the real machine: hardware the
emulator doesn't have, such as an expansion card you're building, and anything that behaves
differently on the X16.
Full documentation: bitmagic.org/remote.
Preview. So far it's been tested against the BitMagic emulator's WiFi card, which runs the real
ZiModem firmware, but not yet on a real X16. If something doesn't work on yours, please
open an issue.
What you need
- A Commander X16 with the WiFi card (ZiModem firmware), on the same network as this PC.
- The .NET 10 runtime: the debugger's PC side runs on it.
- The BitMagic extension, which is
installed with this one.
What you get
- Breakpoints by source line (and by address in the disassembly view).
- Step over, into and out, continue and pause. The X16's NMI button stops the program too.
- The same variables layout as the BitMagic emulator's debugger: CPU (registers and flags), Kernal
(R0-R15), Locals and Globals (your
.var and .padvar data, typed and read from the X16).
Numbers can be changed. The call stack comes from the JSRs on the X16's stack.
- Your own hardware's registers: list the parts of the I/O area the debugger may read and write in
ioAccess (eg ["$9F60-$9F6F"]), and an I/O view shows every named register there. The WiFi card
is never touched.
- Memory and disassembly views, and hovering over a label to see its address and value.
- The X16's SD card in an X16 SD Card view in the Explorer: open, edit and save files, drag
files in from your PC, make folders, rename and delete.
- The program is built, uploaded and run each time you press F5.
Setting up
- Save your WiFi network on the card (once), in a terminal program on the X16:
ATW"YourNetwork,YourPassword", then AT&W.
- Run X16 Remote: Write the Debugger to an SD Card, pick the SD card (or a folder to copy to
it), then This PC. It writes
DEBUG.PRG, DBGSTUB.BIN, DBGTRAMP.BIN and DEBUGHOST.TXT,
with this PC's name if your network knows it (so the card keeps working when the PC's address
changes) and its address as the fallback.
- On the X16,
LOAD "DEBUG.PRG" and RUN. It shows the address it's dialling, and keeps trying
to reach VS Code until you connect. Press a key to give up.
Changing the PC's address
DEBUGHOST.TXT on the card holds the address the X16 dials: 192.168.1.10:6464, or a name such as
mypc.lan:6464, optionally followed by a space and a second one to try if the first doesn't answer.
Without a port it's 6464. Edit it in any text editor, or run X16 Remote: Change the PC Address on
an SD Card.
When it can't connect
The X16's screen says what's wrong:
NO PC ADDRESS: DEBUG.PRG was copied rather than written with the command above, so it doesn't
know where to dial. Write the files again, or put the address in DEBUGHOST.TXT.
NO WIFI CARD FOUND AT $9FE0: the card isn't fitted or isn't seen.
THE WIFI CARD ISN'T ANSWERING: the card is there but not replying.
NO ANSWER FROM THE PC: the card is working, but nothing answered at that address. Connect
from VS Code (start debugging, or open the X16 SD Card view), and check the address, that both
are on the same network, and that Windows Firewall lets dotnet accept connections on the port.
VS Code says what it's waiting for too, and after 30 seconds lists what to check.
Debugging
Add this to .vscode/launch.json (or just press F5 in a folder with a project.json):
{
"type": "x16remote",
"request": "launch",
"name": "Debug on the X16",
"program": "${workspaceFolder}/project.json"
}
Press F5. VS Code builds the project, waits for the X16, uploads the program and runs it. When you
stop debugging, the X16 holds the program where it was and waits for the next session.
stopOnEntry stops at the first instruction; port changes the port (the default is 6464, set
with x16remote.port, and must match what was written to the SD card).
The SD card
Open the X16 SD Card view in the Explorer and click Connect to the X16 (or run X16
Remote: Open the X16's SD Card). It connects without running anything, and once DEBUG.PRG has
dialled in the card's files appear. Stop the session (Shift+F5) when you're done.
Files go through the X16's own DOS, so they can only be reached while nothing is part way through
on it: just after connecting, or after a program has finished. Transfers run at a few KB a second,
the WiFi card's speed, so large files take a while.
Taking the debugger off the X16
Run X16 Remote: Unload the Debugger from the X16 (also on the debug toolbar and the SD Card
view). The X16 goes back to READY., or a program that's stopped carries on without the debugger.
On the X16 itself, pressing the NMI button while it's waiting for VS Code does the same. Run
DEBUG.PRG to load it again.
Settings
x16remote.port: the port the X16 dials in on (6464).
x16remote.bank: the RAM bank the debugger's stub uses on the X16 (63). Your program mustn't use it.
x16remote.ioAccess: parts of the I/O area the debugger may read and write, eg ["$9F60-$9F6F"].
None by default, as reading a register can change it. A launch configuration's ioAccess wins.
x16remote.dotnetPath: the dotnet to run the adapter with; it needs .NET 10.
Limits
- The program can't use the WiFi card while it's being debugged.
- Time doesn't stop when it's stopped: timers and audio carry on, and missed interrupts aren't
replayed.
- A program that replaces the KERNAL's BRK or NMI vectors takes the debugger with it.
Without VS Code
The x16remote command line tool does the same from a terminal, and can serve the SD card over FTP:
dotnet tool install -g BitMagic.X16Remote.Tool. See
bitmagic.org/remote/commandline.
Trying it without an X16
The BitMagic emulator has the WiFi card too. Run x16/stub/project.json from
the repository in the emulator: its DEBUGHOST.TXT
makes it dial 127.0.0.1:6464. Then connect from VS Code as normal.