Page 1 of 1

Can't create SD Card image

Posted: Wed Aug 16, 2023 11:29 am
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?

Re: Can't create SD Card image

Posted: Wed Aug 16, 2023 1:21 pm
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

Re: Can't create SD Card image

Posted: Sat Aug 19, 2023 6:01 pm
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