How To: Create an SD Card Image

Tutorials and help articles.

(Posts require approval. See pinned post.)
Forum rules
Post guides, tutorials, and other instructional content here.

This topic area requires approval, so please be patient while we review content to make sure it fits the expectations for this topic area.

Tech support questions should be asked in Hardware or Software support.
TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

How To: Create an SD Card Image

Post by TomXP411 »

Note: while this method works fine, I no longer recommend using an SD card image. Instead, use HostFS.

To use HostFS, load your files to a subdirectory (or "folder") on your computer, and use the -fsroot parameter to tell the emulator where to find those files. My launch command looks like this:

C:\cx16\emulator\x16emu.exe -fsroot C:\cx16\root -scale 2 -echo

If you DO need an image file, here's how to create one in Windows:

Here's how to create a VHD file that you can mount as an SD image for the Commander X16 emulator:

This method requires Windows 10, and the resulting VHD file will be mountable on a Windows 10 computer by just double-clicking it. (Remember to "Eject" it from File Explorer before trying to run the emulator.)

  • Open Computer Management (click start and type the name)
  • Select Disk Management on the left side
  • Pull down Action and select Create VHD
  • Enter the location and filename in the box. I used CX16_40MB.vhd and placed this in the same directory as my emulator.
  • Select VHD (not VHDX) and Fixed Size
  • Make the file at least 40MB. 
  • This will create the VHD and attach it as a drive in the list on the bottom half of the Disk Management window.
  • Right click in the box on the left column for that new disk.
  • Select Initialize. 
  • Select MBR and click OK
  • Now right click on the RIGHT side (the 40MB Unallocated side) and select New Simple Volume
  • Use the defaults on the first page and second page of the wizard (click Next twice)
  • In the third page, select Format the volume with the following settings
    • File System: FAT32
    • Allocation unit size: Default
    • Volume label: whatever you want
    • UN-check Perform a quick format. (If you're distributing this, you want the sectors cleared, to make this file easier to compress.)
  • Click Next


You should now have a new drive letter.
  • Copy files in the usual way; this works like a floppy or USB drive.
  • When you're done, eject the virtual drive by right-clicking the drive letter in File Explorer and selecting Eject. (You can't mount it in
  • the emulator until you eject it from Windows.)
  • Later, you can re-mount this image in Disk Management.
Use this command line to mount the SDcard in your system

x16emu -sdcard CX16_40MB.vhd -scale 2 -echo

Replace CX16_40MB.vhd with the name of the image file you created, if needed.

Finally, I've attached a 40MB disk image. Feel free to copy and use this image with your emulator.
Attachments
CX16_40MB.zip
(50.26 KiB) Downloaded 307 times
RDuckey
Posts: 3
Joined: Sun Feb 07, 2021 2:51 am

How To: Create an SD Card Image

Post by RDuckey »


Thank you.  I've actually been looking for the method to do this with various images. 

User avatar
svenvandevelde
Posts: 488
Joined: Wed Dec 23, 2020 6:30 am
Location: Belgium, Antwerpen

How To: Create an SD Card Image

Post by svenvandevelde »


Thank you. This is a great help. Such a simple solution.

Is there a way to automatically start a prg from an sdcard when you load the emulator? Or is this not possible?

KICKC home page by Jesper Gravgaard.
My KICKC alpha with Commander X16 extensions.
pzembrod
Posts: 94
Joined: Sat Aug 29, 2020 9:21 pm

How To: Create an SD Card Image

Post by pzembrod »



On 2/9/2021 at 11:53 AM, svenvandevelde said:




Thank you. This is a great help. Such a simple solution.



Is there a way to automatically start a prg from an sdcard when you load the emulator? Or is this not possible?



Yes, that is entirely possible. Either use the -prg <path/to/program> and -run flag, in case you just want to start a program; actually, it will then not load the program from the sdcard but from the host's file system. Or, if you want to start a program and subsequently send some input in the form of keystrokes to the program, then use the -bas <path/to/textfile> flag with a text file containing PETSCII or ISO (depending on the X16 mode) Basic commands (in this case a LOAD"prg" and a RUN) plus whatever keys you want to send to the program.

In https://github.com/pzembrod/cc64/blob/master/emulator/run-in-x16emu.sh you can look at an example of this. The "just run" variant is in line 28 (autostart="-prg ${x16filesdir}/${executable} -run"), and the "load, run and type input" variant is from line 45 where a script is put together, converted to PETSCII and passed in with -bas.

Incidentally, since we had a recipe in the opening post on how to create an SD card in Windows (IIUC), here's a link to a script that does the same on Linux, using sfdisk and the mformat tool from mtools:

https://github.com/pzembrod/cc64/blob/master/emulator/mk-sdcard.sh

Gerry
Posts: 39
Joined: Sat Feb 17, 2024 8:54 am
Location: Dallas, Tx.

Re: How To: Create an SD Card Image

Post by Gerry »

I'm not sure if this is the right place to ask this, so if it's wrong, please relocate my post to the right place. I got the sdimage_root loaded onto the SD card and plugged into my hardware X16 (my board came with a blank SD card) and was able to run the demo basic programs successfully. Yah! Now I'm running the X16 emulator on my M1 Mac and I've unzipped the sdcard.img.zip to sdcard.img. But when I run the M1 emulator and use the DOS" $=D" command to see the SD's contents, the file list I get is somewhere else in the Mac filesystem not the sd card image (I am assuming the contents of the sdcard.img and the sdimage_root subdirectory would have similar contents. I'm also assuming the the sdcard image has to be in the same directory as the x16emu application. The sdcard.img.zip was included with the M1 emu package so what am I doing wrong? Do I need to unpack the sdcard.img? If so, how do I do that?

Thank you,
Gerry
TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

Re: How To: Create an SD Card Image

Post by TomXP411 »

The SD card image included with the emulator has no relationship to the SD Card Starter kit you downloaded. IIRC, it's basically a "blank disk" that you can use for whatever.

Also, you need to actually hook up the image file by using the -sdcard command line option.

I haven't bothered with the SD card image since MooingLemur got HostFS working reliably, but you can start the emulator with an SD card mounted with something like this: x16emu -sdcard sdcard.img (assuming your terminal session is in the same directory as the emulator and SD card.)
Gerry
Posts: 39
Joined: Sat Feb 17, 2024 8:54 am
Location: Dallas, Tx.

Re: How To: Create an SD Card Image

Post by Gerry »

I apologize for asking questions that are a challenge to find an answer. I've tried running the Mac M1 version of the x16emu and it does run but the directory it is looking at to run DOS commands is my user root directory, not the directory x16emu is in. I've tried running x16emu using these mac command line switches; -sdcard sdcard.img, .../sdcard sdcard.img. ...--sdcard sdcard.img, without any change.

Is there any documentation on the Mac M1 version of the X16 emulation program and how it's suppose to work? I can figure it out if I just had the documentation for running the emulator.

Thank you for your time. I really appreciate it.

Gerry
User avatar
ahenry3068
Posts: 1136
Joined: Tue Apr 04, 2023 9:57 pm

Re: How To: Create an SD Card Image

Post by ahenry3068 »

Gerry wrote: Tue May 14, 2024 3:17 am I apologize for asking questions that are a challenge to find an answer. I've tried running the Mac M1 version of the x16emu and it does run but the directory it is looking at to run DOS commands is my user root directory, not the directory x16emu is in. I've tried running x16emu using these mac command line switches; -sdcard sdcard.img, .../sdcard sdcard.img. ...--sdcard sdcard.img, without any change.

Is there any documentation on the Mac M1 version of the X16 emulation program and how it's suppose to work? I can figure it out if I just had the documentation for running the emulator.

Thank you for your time. I really appreciate it.

Gerry
Not a MAC guy. BUT.. MAC is BSD based. and I am a bit of a .Nix guy.. :)

Are you clicking the icon to start. ? I'm assuming that is the case.

Try opening a terminal Window. cd to the directory you want to be in.

Start the emulator with ./x16emu on the command line. (Plus any command line options).
Gerry
Posts: 39
Joined: Sat Feb 17, 2024 8:54 am
Location: Dallas, Tx.

Re: How To: Create an SD Card Image

Post by Gerry »

Thank you for your time and answers. That worked for me, I got the x16emu to run with the sdcard.img image and it loaded. That image is blank with no files. So the next questions; where do I find the latest .img file with files or how do I turn the latest SDcard_root subdirectory into an .img file on a Mac?

Thanks again,
Gerry
User avatar
JimmyDansbo
Posts: 476
Joined: Sun Apr 26, 2020 8:10 pm
Location: Denmark
Contact:

Re: How To: Create an SD Card Image

Post by JimmyDansbo »

Gerry wrote: Tue May 14, 2024 8:35 pm ... where do I find the latest .img file with files ...
The official SD card release can be found here:
viewtopic.php?p=33401
Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
Post Reply