Page 1 of 1

Creating a disk image which can be written to an SD card and loaded on the X16

Posted: Tue Oct 24, 2023 12:04 am
by nulcow
I'm making a very large program for the Commander X16 that runs off of an SD card and stores user data on it. I'm testing it in the emulator, using the -sdcard input.
How do I make a disk image (.img file format) that can be written to an SD card or loaded through the emulator using command-line tools available on a standard Unix system?

Re: Creating a disk image which can be written to an SD card and loaded on the X16

Posted: Tue Oct 24, 2023 1:49 pm
by Microdriver
Easiest approach:
Download image from:
https://github.com/X16Community/x16-emu ... rd.img.zip

Code: Select all

unzip sdcard.img.zip
x16emu -sdcard sdcard.img
...
LOAD "$",8
LIST
READY.
https://www.8bitcoding.com/p/files-in-b ... aving.html
Or:
https://www.commanderx16.com/forum/viewtopic.php?t=6752
Couldn't manage to create a suitable image on Linux yet, though. Used the first approach.

Re: Creating a disk image which can be written to an SD card and loaded on the X16

Posted: Tue Oct 24, 2023 2:45 pm
by nulcow

Re: Creating a disk image which can be written to an SD card and loaded on the X16

Posted: Tue Oct 24, 2023 3:25 pm
by kelli217
dd should be a useful starting point.

If you have an actual SD card attached to the host system, you can basicaly dump the entire contents of the card into a file, and that file will look to the emulator just like the card itself would look to the hardware.

The command should look something like...

dd if=/dev/sdb1 of=~/x16stuff/sdcard.img

(You will of course want to replace the file identifiers above with the correct paths and file names for your system and situation.)

Re: Creating a disk image which can be written to an SD card and loaded on the X16

Posted: Wed Oct 25, 2023 10:30 pm
by voidstar
Looks like you have a workable solution for this.

But just for reference, I'll add some notes from the Windows side of thing: A build of "dd" that I found native to Windows 10 didn't work for me. I just did if on the listed volume and of and bs=1M.
http://www.chrysocome.net/dd

To clarify about "didn't work": it did create an output file, but whatever it was it wasn't compatible with the x16emu. But even if it did work, the image was 1:1 (meaning an 8GB SD was an 8GB img file- you could zip it, but that's annoying).

So, what I did is:

#1) use "Windows Disk Manager" (or "Disk Mangement"). Select Action|CreateVHD, specify an appropriate size (like 128MB). VHD (not VHDX), Fixed size (not Dynamic). Since it has to be Fixed, it's why you want to keep the IMG/VHD as small as needed (but under 32MB might not work for some systems, so 64 or 128MB good for many PRGs; maybe 256MB if also want to store some PDFs on there).

#2) The partition/image is "mounted" by default but not initialized (no drive letter). So right click on that, Initialize Disk from the menu, and chose MBR.

#3) Right click, New Simple Volume. Label as appropriate or blank.

#4) Now transfer your content to the just created VHD.

Right click in the Windows Disk Manager to Detach VHD when you're done with it (moved all the desired content on it). Next time you need it, go to Windows Disk Manager and do Action|Attach VHD.

But here's the thing: one stupid thing is Windows insistent that the file extension be .vhd or it won't Attach/mount the file. At least the build of Windows I have. I changed the extension to .img and changed nothing also about the file, and Windows refused to attach it (and the error message said the extension was "unsupported" or "invalid"). But whatever that .vhd format is, I've found it to be compatible with the X16 emulator (just you have to "deploy it" with that dumb .vhd extension).