Page 1 of 1

usb flsh and fat32

Posted: Fri Feb 12, 2016 1:48 am
by ammar
that is code my bootloader use fat32
i am using that code for loading kernel from usb flash
i am copy boot loader in first sector(512) in flash memory by linux
sudo dd if=boot.bin bs=512 conv=notrunc count=1 of=/dev/sdb
but code kernel.bin where put in usb flash
sudo dd if=kernel.bin bs=? conv=notrunc count=? of/dev/sdb

Re: usb flsh and fat32

Posted: Fri Feb 12, 2016 2:36 am
by Combuster
The following command fixes everything:

Code: Select all

man dd

Re: usb flsh and fat32

Posted: Fri Feb 12, 2016 10:22 am
by SpyderTL
It depends on what "logical block" or Cylinder/Head/Sector values your boot loader is passing to the INT 13h BIOS method. If your boot loader is in the first block, and your kernel is in the second block, then you should write your kernel starting at position 512. (Because each block is 512 bytes long)

try:

Code: Select all

dd if=boot.bin bs=512 conv=notrunc skip=1 count=1 of=/dev/sdb

Re: usb flsh and fat32

Posted: Fri Feb 12, 2016 12:18 pm
by ammar
thank you for replying
Do you mean that skipe = 1 means the index increased by 512
Did me use the usb flash with int 13h and dl=0 true
here use the flashe same the floppy disk

Re: usb flsh and fat32

Posted: Fri Feb 12, 2016 1:05 pm
by SpyderTL
Yes, I believe that skip=1 will skip a whole block, which you specified is 512 bytes. But I'm no expert, so someone else may chime in with the actual correct answer. :)

When your bootloader is loaded into memory and executed, the BIOS is responsible for putting the correct "boot drive number" in the DL register. So as long as you don't change the DL register (or you save it and restore it before calling INT 13h), your code should work for a floppy drive, a hard drive, or a USB drive. (It *may* also work for a CD drive, but there are a few issues that you will need to be aware of when trying to read from a CD drive, so you may need to deal with booting from a CD separately if it doesn't work immediately.)

Re: usb flsh and fat32

Posted: Fri Feb 12, 2016 2:21 pm
by Octocontrabass
Instead of asking us how to use that bootloader, why don't you ask the person who wrote it? They probably included some documentation somewhere that tells you how it's supposed to work.

Re: usb flsh and fat32

Posted: Fri Feb 12, 2016 4:06 pm
by SpyderTL
Looking at the bootloader code that you linked to, I see where it is reading from the [DriveNumber], but I don't see where it is being set. It looks like it is always going to be set to 0x00.

You need to add a line at the top of the code, after the stack is created, to copy the value from DL to the [DriveNumber] variable.

Also, this code looks like it is expecting the kernel to be the first file in the root directory of the FAT32 file system. So, you will need to format your device as FAT32 first, then use the "dd" command to copy the first block, like you are doing now. Then you need to mount this device as FAT32, and then copy your kernel.bin file to the root folder.

Let us know if you need any more details on how to do this.