Can't create SD Card image

Get technical support from the community & developers with specific X16 programs if you can't find the solution elsewhere
(for general non-support related chat about programs please comment directly under the program in the software library)
Post Reply
Dacobi
Posts: 292
Joined: Sun Dec 19, 2021 1:44 am
Location: Samsø, Denmark
Contact:

Question Can't create SD Card image

Post by Dacobi »

I'm currently trying to create an SD Card image in Linux, using fdisk and mkfs.vfat.

I have something that mounts and looks identical to the image from the x16emu package, but when listing the content with DOS"$" in r43 I either get garbled data or the emulator prints an error along with garbled data.

My approach for creating the image is to make an empty file of zeros, 100MB using

Code: Select all

	dd if=/dev/zero of=test.img count=100 bs=1M
I then open the file in fdisk and create a DOS MBR partition table with the "o" option.
Then I create a primary partition at 2048 sectors using "n" then "p" and the default values.
Then I change the type to Fat32 using "t" and then "c" and "w" to write the changes to the file.

Then I run:

Code: Select all

	mkfs.vfat --mbr=y --offset 2048 test.img
I can now mount the image and "fdisk -l" shows the exact same info as the image from x16emu, yet it can't list the files and folder I copy onto the image in x16emu.

Can anyone spot anything I'm doing wrong?
Dacobi
Posts: 292
Joined: Sun Dec 19, 2021 1:44 am
Location: Samsø, Denmark
Contact:

Re: Can't create SD Card image

Post by Dacobi »

I managed to get it working by specifying sector size and fat type as 32

Code: Select all

	mkfs.vfat -F 32 -S 512 --offset 2048 -n "X16 DISK" minim.img
Xark
Posts: 5
Joined: Thu Jul 21, 2022 2:43 am

Re: Can't create SD Card image

Post by Xark »

Hello,

I am glad you got it working. FWIW, I thought I would share the technique I have been using that works on Linux and macOS (which doesn't have mkfs.vfat). It does require "mtools" (available on macOS with homebrew).

This makes an 8MB SD image (16384 is number of 1/2 K sectors, so MB size * 2048), copies some test files and starts emulator with the SD card image mounted:

Code: Select all

dd if=/dev/zero of=sdcard.img bs=512 count=16384 status=none    # make empty image file
mformat -i sdcard.img -v "SDIMAGE-IMG" -F ::                    # format image file
mcopy -i sdcard.img -s YOURPROG.PRG testdir ::                  # copy whatever test files/folders to image
x16emu -scale 2 -quality nearest -sdcard sdcard.img             # run x16-emu with SD card image
-Xark
Post Reply