I can't use PARTCOPY

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
omar
Posts: 8
Joined: Fri Aug 22, 2014 12:22 pm

I can't use PARTCOPY

Post by omar »

Well, I finally came back to Windows 7 and I get Virtual Floppy Drive, Microsoft Virtual PC and PARTCOPY.

I made a bootloader that loads a second stage from floppy disks and the second stage is more like a "Hello world" program

I compiled:
nasm -f bin boot.asm -o boot.bin
nasm -f bin stage2.asm -o stage2.bin

Then I made virtual floppy drive A and I copy the stuff...
copy stage2.bin A:\stage2.bin

I make it bootable with
partcopy boot.bin 0 200 -f0

All works, but after that if I try to go to drive A, it says "unknown filesystem" and if I run the command format A:, it says the current filesystem is RAW and the new filesystem is FAT12
If I format, I lose the stage2 and the bootloader. When I put them back, the same thing happens again and again... :(

Any help please anyone? Thanks in advance!
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: I can't use PARTCOPY

Post by neon »

Hello,

partcopy boot.bin 0 200 -f0 is wrong. After formatting the disk you should merge your boot record with the existing file system structures like so,

Code: Select all

partcopy bootsect.bin 0 3 -f0 0 
partcopy bootsect.bin 3E 1C2 -f0 3E
You can also easily write your own program (you will need to for the installer.)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
omar
Posts: 8
Joined: Fri Aug 22, 2014 12:22 pm

Re: I can't use PARTCOPY

Post by omar »

neon wrote:Hello,

partcopy boot.bin 0 200 -f0 is wrong. After formatting the disk you should merge your boot record with the existing file system structures like so,

Code: Select all

partcopy bootsect.bin 0 3 -f0 0 
partcopy bootsect.bin 3E 1C2 -f0 3E
You can also easily write your own program (you will need to for the installer.)
Sorry but instead of fixing the problem, this actually prevented my floppy from booting correctly at all. Now, all it just does is have that flashing underscore in text mode. It used to show a message before it loads. :(
But anyways, thanks for trying to help, I appreciate it :)
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: I can't use PARTCOPY

Post by alexfru »

omar wrote: All works, but after that if I try to go to drive A, it says "unknown filesystem" and if I run the command format A:, it says the current filesystem is RAW and the new filesystem is FAT12
If I format, I lose the stage2 and the bootloader. When I put them back, the same thing happens again and again... :(
DOS and Windows expect a few things in the boot sector, namely a short jump instruction that skips over the BPB.

This is what I have at the beginning of my FAT12 boot sector (the BPB values are not initialized here because I take them as-is from a formatted floppy):

Code: Select all

[BITS 16]

[SECTION .text]
[ORG 0]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Boot sector starts here ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        jmp     short   start
        nop
bsOemName               DB      "BootProg"      ; 0x03

;;;;;;;;;;;;;;;;;;;;;
;; BPB starts here ;;
;;;;;;;;;;;;;;;;;;;;;

bpbBytesPerSector       DW      ?               ; 0x0B
bpbSectorsPerCluster    DB      ?               ; 0x0D
bpbReservedSectors      DW      ?               ; 0x0E
bpbNumberOfFATs         DB      ?               ; 0x10
bpbRootEntries          DW      ?               ; 0x11
bpbTotalSectors         DW      ?               ; 0x13
bpbMedia                DB      ?               ; 0x15
bpbSectorsPerFAT        DW      ?               ; 0x16
bpbSectorsPerTrack      DW      ?               ; 0x18
bpbHeadsPerCylinder     DW      ?               ; 0x1A
bpbHiddenSectors        DD      ?               ; 0x1C
bpbTotalSectorsBig      DD      ?               ; 0x20

;;;;;;;;;;;;;;;;;;;
;; BPB ends here ;;
;;;;;;;;;;;;;;;;;;;

bsDriveNumber           DB      ?               ; 0x24
bsUnused                DB      ?               ; 0x25
bsExtBootSignature      DB      ?               ; 0x26
bsSerialNumber          DD      ?               ; 0x27
bsVolumeLabel           DB      "NO NAME    "   ; 0x2B
bsFileSystem            DB      "FAT12   "      ; 0x36

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Boot sector code starts here ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

start:
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: I can't use PARTCOPY

Post by neon »

Hello,
omar wrote:Sorry but instead of fixing the problem, this actually prevented my floppy from booting correctly at all. Now, all it just does is have that flashing underscore in text mode. It used to show a message before it loads.
That is fine. What I provided is what you should be using in order to maintain proper formatting structure. It is the responsibility of the formatting software to determine proper configuration of the BPB structure not your installer. If it causes additional problems it indicates the problem is elsewhere.

Format the disk image, then install the boot record correctly in a way as to not overwrite the file system structures (the Bios Parameter Block) that was installed by the formatting software. Make sure that you have reserved space in your boot record file for the BPB.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: I can't use PARTCOPY

Post by Combuster »

omar wrote:All works, but after that if I try to go to drive A, it says "unknown filesystem" and if I run the command format A:, it says the current filesystem is RAW and the new filesystem is FAT12
That only means that either your bootloader does not support FAT in the first place - in which case you'll be stuck with this behaviour, or your BPB layout isn't properly filled. You can "steal" it from a formatted image as Neon does, but since a floppy layout is known and fixed you can just as easily incorporate it in the bootloader code itself so you don't have to do any tricky cutting.

The best way to check is to grab the bootsector from a floppy that is formatted, and check if every meaningful byte is set in your code as well - in the exact same position.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
omar
Posts: 8
Joined: Fri Aug 22, 2014 12:22 pm

Re: I can't use PARTCOPY

Post by omar »

alexfru wrote:
omar wrote: All works, but after that if I try to go to drive A, it says "unknown filesystem" and if I run the command format A:, it says the current filesystem is RAW and the new filesystem is FAT12
If I format, I lose the stage2 and the bootloader. When I put them back, the same thing happens again and again... :(
DOS and Windows expect a few things in the boot sector, namely a short jump instruction that skips over the BPB.

This is what I have at the beginning of my FAT12 boot sector (the BPB values are not initialized here because I take them as-is from a formatted floppy):

Code: Select all

[BITS 16]

[SECTION .text]
[ORG 0]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Boot sector starts here ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        jmp     short   start
        nop
bsOemName               DB      "BootProg"      ; 0x03

;;;;;;;;;;;;;;;;;;;;;
;; BPB starts here ;;
;;;;;;;;;;;;;;;;;;;;;

bpbBytesPerSector       DW      ?               ; 0x0B
bpbSectorsPerCluster    DB      ?               ; 0x0D
bpbReservedSectors      DW      ?               ; 0x0E
bpbNumberOfFATs         DB      ?               ; 0x10
bpbRootEntries          DW      ?               ; 0x11
bpbTotalSectors         DW      ?               ; 0x13
bpbMedia                DB      ?               ; 0x15
bpbSectorsPerFAT        DW      ?               ; 0x16
bpbSectorsPerTrack      DW      ?               ; 0x18
bpbHeadsPerCylinder     DW      ?               ; 0x1A
bpbHiddenSectors        DD      ?               ; 0x1C
bpbTotalSectorsBig      DD      ?               ; 0x20

;;;;;;;;;;;;;;;;;;;
;; BPB ends here ;;
;;;;;;;;;;;;;;;;;;;

bsDriveNumber           DB      ?               ; 0x24
bsUnused                DB      ?               ; 0x25
bsExtBootSignature      DB      ?               ; 0x26
bsSerialNumber          DD      ?               ; 0x27
bsVolumeLabel           DB      "NO NAME    "   ; 0x2B
bsFileSystem            DB      "FAT12   "      ; 0x36

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Boot sector code starts here ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

start:
Yeah thanks, it works! :D
Post Reply