Z80-Retro / Z80-Retro-Manual

2 stars 3 forks source link

Small mistake in the manual #14

Closed Ericounet closed 1 month ago

Ericounet commented 1 month ago

hi @productiondave , I followed the manual you wrote, the part on the emulator (I read it all of course). I think, there is a typo in the chapter on the emulator. Here : ./2063 -r boot/firmware.bin -S filesystem/SDcard.img I tried and could not get the result you showed just below the command. And that's because there is a mistake in the command line : the parameter "filesystem/SDcard.img" is wrong, it must be /dev/sda (or the letter where your sdcard is connected; for me, sdc. Thanks a lot for the manual ! It helped. 😄

Here are the steps I followed, and the error I encountered ; you can find the line of the error below at the line : Error!Error!

Using the Etched Pixels Emulator Kit

The Etched Pixels Emulator kit supports the “Z80-Retro!” along with many other homebrew projects.

Clone and Build

Clone the Etched Pixels Emulator Kit github repository here from here: https://github.com/EtchedPixels/EmulatorKit

  1. $ cd EmulatorKit
  2. $ make
  3. < compilation takes a while>
  4. $ cp 2063 ../2063-Z80-cpm

Compilation takes a while as it compiles all the emulators for the different supported projects.

Testing

eric@aldebaran:~/Projets-Z80-retro/z80-retro$ cd EmulatorKit/
eric@aldebaran:~/Projets-Z80-retro/z80-retro/EmulatorKit$ make
cc -Wall -pedantic -g3 -Werror -Ilib65c816 -c rcbus-65c816-mini.c
cc -g3 rcbus-65c816-mini.o ide.o 6522.o rtc_bitbang.o acia.o 16x50.o ttycon.o w5100.o lib65c816/src/lib65816.a -o rcbus-65c816-mini
cc -Wall -pedantic -g3 -Werror -Ilib65c816 -c rcbus-65c816.c
cc -g3 rcbus-65c816.o sram_mmu8.o ide.o 6522.o rtc_bitbang.o acia.o 16x50.o ttycon.o w5100.o lib65c816/src/lib65816.a -o rcbus-65c816
cc -Wall -pedantic -g3 -Werror -Ilib65c816 -c pz1.c
cc -g3 pz1.o lib65c816/src/lib65816.a -o pz1
eric@aldebaran:~/Projets-Z80-retro/z80-retro/EmulatorKit$ cp 2063 ../2063-Z80-cpm
eric@aldebaran:~/Projets-Z80-retro/z80-retro/EmulatorKit$

Done and OK

Now that you have the emulator binary you should be ready to go.

Preparing the firmware and the sdcard image

You will need to prepare the firmware image and the SD Card image for use with the emulator. As we don’t have a real formatted SD Card to work with we need to create an SDcard.img file that will have the correctly formatted partitions on it.

Create the ROM Image

The emulator expects the firmware image to be exactly 16KB in size. Use the truncate command in Linux to do that.

  1. $ cd 2063-Z80-cpm/boot
  2. $ make
  3. $ truncate -s 16K firmware.bin
  4. $ hexdump -C firmware.bin| tail -n 3 000009b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  5. *
  6. 00004000

Validate that the last line is 00004000 (0x4000 in hex) or 16K.

Testing

eric@aldebaran:~/Projets-Z80-retro/z80-retro$ cd 2063-Z80-cpm/boot
eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/boot$ make
make: rien à faire pour « all ».
eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/boot$ truncate -s 16K firmware.bin
eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/boot$ $ hexdump -C firmware.bin| tail -n 3
bash: $ : commande introuvable
eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/boot$ hexdump -C firmware.bin| tail -n 3
000009b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00004000
eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/boot$

Done and OK

Create the SD Card Image

!!! WARNING !!! This process can damage your host file system if you get it wrong. Make sure you only format the loop device after setting it up.

This step is a bit more complicated and these steps are definitely ONLY going to work on a Linux host.

  1. $ cd 2063-Z80-cpm/filesystem
  2. $ make
  3. $ dd if=/dev/zero of=SDcard.img bs=1024 count=512000
  4. $ sudo losetup -Pf SDcard.img
  5. $ (
  6. echo n # Add a new partition
  7. echo p # Primary partition
  8. echo 1 # Partition number
  9. echo # First sector (Accept default)
  10. echo +128M # Last sector (Accept default: varies)
  11. echo n # Add a new partition
  12. echo p # Primary partition
  13. echo 2 # Partition number
  14. echo # First sector (Accept default)
  15. echo # Last sector (Accept default: varies)
  16. echo t # Partition Type
  17. echo 1 # First partition
  18. echo db # Type = CP/M
  19. echo t # Partition Type
  20. echo 2 # Second partition
  21. echo 06 # Fat 16
  22. echo w # Write changes
  23. ) | sudo fdisk /dev/loop0

Testing

eric@aldebaran:~/Projets-Z80-retro/z80-retro$ cd 2063-Z80-cpm/filesystem
eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/filesystem$ make
make: rien à faire pour « all ».
eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/filesystem$ dd if=/dev/zero of=SDcard.img bs=1024 count=512000
512000+0 enregistrements lus
512000+0 enregistrements écrits
524288000 octets (524 MB, 500 MiB) copiés, 1,38205 s, 379 MB/s
eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/filesystem$ sudo losetup -Pf SDcard.img
[sudo] Mot de passe de eric : 
eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/filesystem$ 

My loop device is loop4. So I change the line 23 with : 

) | sudo fdisk /dev/loop4

Bienvenue dans fdisk (util-linux 2.38.1).
Les modifications resteront en mémoire jusqu'à écriture.
Soyez prudent avant d'utiliser la commande d'écriture.

Le périphérique ne contient pas de table de partitions reconnue.
Created a new DOS (MBR) disklabel with disk identifier 0x69609cd0.

Commande (m pour l'aide) : Type de partition
   p   primaire (0 primaire, 0 étendue, 4 libre)
   e   étendue (conteneur pour partitions logiques)
Sélectionnez (p par défaut) : Numéro de partition (1-4, 1 par défaut) : Premier secteur (2048-1023999, 2048 par défaut) : Dernier secteur,  +/-secteurs ou +/-taille{K,M,G,T,P} (2048-1023999, 1023999 par défaut) : 
Une nouvelle partition 1 de type « Linux » et de taille 128 MiB a été créée.

Commande (m pour l'aide) : Type de partition
   p   primaire (1 primaire, 0 étendue, 3 libre)
   e   étendue (conteneur pour partitions logiques)
Sélectionnez (p par défaut) : Numéro de partition (2-4, 2 par défaut) : Premier secteur (264192-1023999, 264192 par défaut) : Dernier secteur, +/-secteurs ou +/-taille{K,M,G,T,P} (264192-1023999, 1023999 par défaut) : 
Une nouvelle partition 2 de type « Linux » et de taille 371 MiB a été créée.

Commande (m pour l'aide) : Numéro de partition (1,2, 2 par défaut) : Code Hexa ou synonyme (taper L pour afficher tous les codes) :
Type de partition « Linux » modifié en « CP/M / CTOS / ... ».

Commande (m pour l'aide) : Numéro de partition (1,2, 2 par défaut) : Code Hexa ou synonyme (taper L pour afficher tous les codes) :
Type de partition « Linux » modifié en « FAT16 ».

Commande (m pour l'aide) : La table de partitions a été altérée.
Appel d'ioctl() pour relire la table de partitions.
Synchronisation des disques.

eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/filesystem$

Done and OK

Whew! Now that you have an image file with partitions on it, you can copy the retro.img CP/M file system on to it.

  1. $ sudo mkfs.msdos /dev/loop4p1
  2. $ sudo mkfs.msdos /dev/loop4p2
  3. $ sudo dd if=retro.img of=/dev/loop4p1 bs=512

Testing

eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/filesystem$ sudo mkfs.msdos /dev/loop4p1

[sudo] Mot de passe de eric : mkfs.fat 4.2 (2021-01-31) eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/filesystem$ sudo mkfs.msdos /dev/loop4p2 mkfs.fat 4.2 (2021-01-31)

Done and OK

eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/filesystem$ sudo dd if=retro.img of=/dev/loop4p1 bs=512

Error!Error!

**dd: impossible d'ouvrir 'retro.img': Aucun fichier ou dossier de ce type**
eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/filesystem$ 

Done and NOT OK : the retro.img is not existant at this stage.

Correction

eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/filesystem$ sudo dd if=drive.img of=/dev/loop4p1 bs=512 800+0 enregistrements lus 800+0 enregistrements écrits 409600 octets (410 kB, 400 KiB) copiés, 0,00302325 s, 135 MB/s eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm/filesystem$

Finally unmount the loopback disk.

  1. $ sudo losetup -d /dev/loop4

Testing

Done and OK.

You should now have a 500MB SDcard.img file.

Running the Emulator

To distinguish this “Z80-Retro!” project from a different Z80-Retro project, the author has named the emulator 2063 after the board number.

$ cd d 2063-Z80-cpm
$ ./2063 -r boot/firmware.bin -S filesystem/SDcard.img
Z80 Retro Board 2063.3
git: v20230317.1-0-g8bcf644 2023-03-17 22:20:02 -0500
build: 2023-04-23 18:03:16+12:00
Booting SD card partition 1
Partition Table:
C1BE: 00 20 21 00 7F 71 21 10 00 08 00 00 00 00 04 00
C1CE: 00 71 22 10 06 BC 3D 3F 00 08 04 00 00 98 0B 00
C1DE: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
C1EE: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Partition 1 starting block number: 00000800
Partition 1 number of blocks:
00040000
Loading 0x20 512-byte blocks into 0xC000 - 0xFFFF
................................
Z80 Retro BIOS Copyright (C) 2021 John Winans
CP/M 2.2 Copyright (C) 1979 Digital Research
git: v20230317.1-0-g8bcf644 2023-03-17 22:20:02 -0500
build: 2023-04-22 17:56:49+12:00
NOTICE: rw_dmcache library installed.
a>

Exit the emulator by typing CTRL+\

Testing

eric@aldebaran:~/Projets-Z80-retro/z80-retro/2063-Z80-cpm$ ./2063 -r boot/firmware.bin -S filesystem/SDcard.img

##############################################################################
Z80 Retro Board 2063.3
  git: v20240714.1-1-g510485c 2024-07-14 18:07:50 -0500
build: 2024-09-27 12:16:29+0200

Booting SD card partition 1

Partition Table:
C1BE: 00 20 21 00 DB 71 21 10 00 08 00 00 00 00 04 00
C1CE: 00 71 22 10 06 BC 3D 3F 00 08 04 00 00 98 0B 00
C1DE: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
C1EE: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Partition 1 starting block number: 00000800
Partition 1 number of blocks:      00040000

Loading 0x20 512-byte blocks into 0xC000 - 0xFFFF
................................

Z80 Retro BIOS Copyright (C) 2021 John Winans
CP/M 2.2 Copyright (C) 1979 Digital Research
  git: v20240714.1-1-g510485c 2024-07-14 18:07:50 -0500
build: 2024-09-27 12:16:29+0200

a>

Done and OK

Exit the emulator by typing CTRL+\

linuxplayground commented 1 month ago

The whole point of using an emulator is that you don't need an sdcard.

I'll double-check the instructions, but you should not need to mount or insert an sdcard at all for running the emulator. There should be no need to use the /dev/sd? mount points. You should use the SDCard.img file you created.

It's possible the instructions for creating this image file are broken and I will check them.