Problem on real hardware

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.
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: Problem on real hardware

Post by Combuster »

romfox wrote:Using EXACTLY the code I posted on page 4, it doesn't spawn anything now, how can it do that ?? Gonna burn my computer x_x.
We have version control for that. If something makes things worse, you undo it and you complain to whomever made that suggestion.
Sleeping a night has a tendency to work as well. Especially since I'm pretty sure what time it is right now at your place.

At least your bootloader + stub kernel works on real hardware for me with the modifications provided, which is something I would like to recommend others as well: if your suggestion does not work on your own hardware, don't post it. There is way too much nonsense in this thread as every noob that comes in here will end up with worse code rather than better code.

The more people that get it working, the bigger the chance it will work on your particular setup as well.


I'll post my entire version for reference to eliminate all copy errors (no I did not substitute the french yet):

romfox_bootfn.asm

Code: Select all

; -------------------------------------------------------------
; Fonction d'affichage qui utilise le BIOS
; -------------------------------------------------------------
print16:

   push ax
   push bx

.debut:
   lodsb
   or al, al ; zero=end of str
   jz .end   ; get out
   mov ah, 0x0E
   mov bl, 0xff
   int 0x10
   jmp .debut

.end:
   pop bx
   pop ax
   ret

; -------------------------------------------------------------
; Fonction d'affichage qui utilise le BIOS
; -------------------------------------------------------------

print_reg16:
    pusha
    mov di, buff16
    mov ax, [reg16]
    mov si, hexch
    mov cx, 4

.debut:
    rol ax, 4
    mov bx, ax
    and bx, 0x0f
    mov bl, [si+bx]
    mov [di], bl
    inc di
    dec cx
    jnz .debut

    mov si, buff16
    call print16
    popa
    ret
   

reg16: dw 0
buff16: db '0000', 0
hexch: db '0123456789abcdef'
romfox_stage1.asm

Code: Select all

%define BASE    0x100  ; 0x0100:0x0 = 0x1000
%define KSIZE   17 ; nombre de secteurs a charger

[BITS 16]
[ORG 0x7c00]

jmp 0x0:start
%include "romfox_bootfn.asm"
start:

; initialisation des segments en 0x07c0
; >> actually, zeroed 
    xor ax, ax
    mov ds, ax
    mov es, ax
    mov fs, ax
    mov ss, ax
    mov sp, 0xf000

; recuparation de l'unite de boot
    mov [bootdrv], dl   

; affiche un msg
    mov si, msgDebut
    call print16

    push es
    push ds

initialise_disque: ; Initialise le lecteur de disque
    xor ax, ax
    mov dl, [bootdrv]
    int 0x13
    jc initialise_disque ; En cas d'erreur on recommence (sinon, de toute façon, on ne peut rien faire)

    mov si, msg2
    call print16

    pop ds
    push ds
lire:
    mov ax, BASE
    mov es, ax
    mov [reg16], es
    call print_reg16
    xor bx, bx
    mov ah, 2           ; Fonction 0x02 : chargement mémoire
    mov al, KSIZE       ; On lit KSIZE secteurs
    xor ch, ch          ; Premier cylindre (n° 0)
    mov cl, 2           ; Premier secteur (porte le n° 2, le n° 1, on est dedans, et le n° 0 n'existe pas)
    xor dh, dh          ; Tête de lecture n° 0
    mov dl, 0 ;>>[bootdrv]   
    ; bios might not clear it
    CLC
    int 0x13            ; Lit !
    jc lire             ; En cas d'erreur, on recommence

    pop ds
    pop es

    mov si, msg3
    call print16

; passage en modep
    cli
    mov ax, 0
    mov ds, ax
    lgdt [gdtptr]    ; charge la gdt
    mov eax, cr0
    or  ax, 1
    mov cr0, eax        ; PE mis a 1 (CR0)

    jmp 0x8:next
[BITS 32]
next:
    mov ax, 0x10        ; segment de donne
    mov ds, ax
    mov fs, ax
    mov gs, ax
    mov es, ax
    mov ss, ax
;   >>> don't touch bios
;    mov esp, 0x9F000
    mov esp, 0x1000

; Affichage d'un message par ecriture dans la RAM video
    mov byte [0xB8140], 'H'
    mov byte [0xB8141], 0x57

.wait:
    in al, 0x64
    and al, 1
    jz .wait

    jmp BASE << 4

;--------------------------------------------------------------------
bootdrv:  db 0
msgDebut: db "Loading kernel...", 13, 10, 0

msg2: db "Step 2", 0
msg3: db "Step 3", 0
;--------------------------------------------------------------------
gdt:
    db 0, 0, 0, 0, 0, 0, 0, 0
gdt_cs:
    dd 0xffff, 0x00cf9a00
gdt_ds:
    dd 0xffff, 0x00cf9200
gdtend:
;--------------------------------------------------------------------
gdtptr:
    dw gdtend - gdt -1
    dd gdt  ; base
;--------------------------------------------------------------------

;; NOP jusqu'a 510
times 510-($-$$) db 144
dw 0xAA55
romfox_stage2.asm

Code: Select all

[BITS 32]
[ORG 0x1000]
    mov byte [0xB8040], 'K'
    mov byte [0xB8041], 0x57
    jmp $



--------------
DavidCooper wrote:Many EBDAs start at 9F000
I have yet to see one myself. My complaint about stupid suggestions applies in particular to people like you. It is a bug and it needs a fix, not ignoring because it just works for you.
"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 ]
romfox
Member
Member
Posts: 50
Joined: Wed Nov 16, 2011 8:14 am

Re: Problem on real hardware

Post by romfox »

Yep not a problem ^^ Just that I spend all my time to make it work for 1 week and it doesn't work...
I don't understand now placing an infinite loop before enabling protected mode still shows me nothing starts...
Edit : trying with yours.

Edit : No... nothing works anymore, can't understand why (I use dd for windows), gonna try with Cygwin's dd.
User avatar
DavidCooper
Member
Member
Posts: 1150
Joined: Wed Oct 27, 2010 4:53 pm
Location: Scotland

Re: Problem on real hardware

Post by DavidCooper »

Combuster wrote:
DavidCooper wrote:Many EBDAs start at 9F000
I have yet to see one myself. My complaint about stupid suggestions applies in particular to people like you. It is a bug and it needs a fix, not ignoring because it just works for you.
I'm using a machine right now with its EBDA starting at 9F000 (assuming that's 4K under the screen memory - as you probably know, I'm not great with hex, so I wouldn't bet on being right). I've spent this whole thread trying to make sensible suggestions as to how to debug this, and trying not to be rude when not getting adequate information back to be able to tell if Romfox has actually done what I've told him to. Because of the lack of precise information coming back, it's taken a long time to get this far, but I don't like suggesting people are incompetent when their replies show sufficient signs of competence to suggest that the problems may just be down to them being uncomfortable working in English. Maybe that's the wrong approach and I should just be downright rude like you:-
Let's get this whole mess of stupid suggestions over with:
You followed that with a list of your own, superior suggestions:-
Reads can not cross track boundaries, so I turned it down to 17 (sectors 2-18)
Something I'd told him to do already, twice. Then:-
Comment has not been updated
which doesn't affect the code. Then:-
Get out of the bios area
which is a good point, but it can't be causing the failure to load because the stack's only set to this value after the code that does the loading has already done its job. Then:-
GPF with the top 16 bits of edi being nonzero. In other words, your debugging code was breaking more stuff.
That is indeed important - there's a real chance they aren't zero. Even so, debugging a new addition to the code was never going to solve the as-yet-unsolved problem that was already there. Clearly none of these changes you've made give you grounds to start your post with, "Let's get this whole mess of stupid suggestions over with". You've certainly come in with some valuable contributions, of course, but everyone else in this thread has been trying to do the same.
Last edited by DavidCooper on Wed Dec 07, 2011 10:48 pm, edited 1 time in total.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
romfox
Member
Member
Posts: 50
Joined: Wed Nov 16, 2011 8:14 am

Re: Problem on real hardware

Post by romfox »

Sorry for no thanking you everybody who help me, and yes I keep trying all the suggestions you give me, but now using the code I used many hours before (which worked) it doesn't work anymore, I think I should sleepand see that tomorrow but it makes me crazy...

Edit : And it can be hard even we speak the same language, but we don't speak the same so it's verry hard but I learn english so :p
User avatar
DavidCooper
Member
Member
Posts: 1150
Joined: Wed Oct 27, 2010 4:53 pm
Location: Scotland

Re: Problem on real hardware

Post by DavidCooper »

romfox wrote:Sorry for no thanking you everybody who help me, and yes I keep trying all the suggestions you give me, but now using the code I used many hours before (which worked) it doesn't work anymore, I think I should sleepand see that tomorrow but it makes me crazy...
At the risk of making another idiotic suggestion, maybe you didn't change the BIOS settings back to the way they originally were: that might be blocking it now.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
romfox
Member
Member
Posts: 50
Joined: Wed Nov 16, 2011 8:14 am

Re: Problem on real hardware

Post by romfox »

That wasn't the BIOS options :s
But one time HDD launch windows (no bootsector found I think), one time it handles and I just have to press CTRL ALT DEL (not in any bootsector I think), but I doesn't launch any bootsector ><
Keep trying...

Edit : Even formatting and booting to my HDD I don't get the "No boot, press any key" message when starting, just handling waiting for CTRL ALT DEL...
romfox
Member
Member
Posts: 50
Joined: Wed Nov 16, 2011 8:14 am

Re: Problem on real hardware

Post by romfox »

It looks I have problems with my USB HDD cause I format it and I CAN see it has a bootloader but booting on from my OR my girlfriend's computer (so 2 computers) it just hangs.
guyfawkes
Member
Member
Posts: 93
Joined: Mon Jul 18, 2011 9:47 am

Re: Problem on real hardware

Post by guyfawkes »

romfox wrote:It looks I have problems with my USB HDD cause I format it and I CAN see it has a bootloader but booting on from my OR my girlfriend's computer (so 2 computers) it just hangs.
So after all that it could be down to hardware :( .
May you could make it Dos bootable just to check
romfox
Member
Member
Posts: 50
Joined: Wed Nov 16, 2011 8:14 am

Re: Problem on real hardware

Post by romfox »

YEah cause using codes from Flat asm forum it doesn't boot anyway (?) but it worked before... And when I formatted it and booted from it it worked too.
Now I can't got my or the format boot loader =/
What can it be.
Cause it is a 500 gb USB HDD Windows doesnt let me using the "make DOS floppy" option when formatting, and I don't have any other USB dev for the now.
guyfawkes
Member
Member
Posts: 93
Joined: Mon Jul 18, 2011 9:47 am

Re: Problem on real hardware

Post by guyfawkes »

You can use this tool
http://www.dex-os.com/dos2x/DexUsbBoot.zip

But you need to format it fat16 with the HP tool included in the zip.
Once you have formated it fat16 (FAT in the list), use the usbdex to install the test OS (DexOS).
note: in win7 you need to be admin.
You can also use the included HPformat tool to add Dos, by clicking make bootable and then pointing to a dir thats has the dos file or freedos files in it.

Note you can use the usbdex.exe unless the usb hdd is formated FAT (fat16)
User avatar
DavidCooper
Member
Member
Posts: 1150
Joined: Wed Oct 27, 2010 4:53 pm
Location: Scotland

Re: Problem on real hardware

Post by DavidCooper »

romfox wrote:I don't have any other USB dev for the now.
Any cheap USB flash drive should do. If your attempts to boot with a test OS then fail both with a USB HDD and a USB flash drive, and if they fail on both computers, that would make it look as if the test OS isn't being written to the right place on the drives. Even if you're using the right instructions, it's just possible that the software you're using to write to the USB drive has become corrupted, so testing by installing DexOS using its own tools would be well worth a go, if you haven't tried that already.

Whatever it is that's wrong, don't give up until you've managed to pin the blame on something specific - whatever you find out may be of help to others. It might also be worth naming the make and model of both the computers and the HDD.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
guyfawkes
Member
Member
Posts: 93
Joined: Mon Jul 18, 2011 9:47 am

Re: Problem on real hardware

Post by guyfawkes »

DavidCooper wrote:
romfox wrote:I don't have any other USB dev for the now.
Any cheap USB flash drive should do. If your attempts to boot with a test OS then fail both with a USB HDD and a USB flash drive, and if they fail on both computers, that would make it look as if the test OS isn't being written to the right place on the drives. Even if you're using the right instructions, it's just possible that the software you're using to write to the USB drive has become corrupted, so testing by installing DexOS using its own tools would be well worth a go, if you haven't tried that already.

Whatever it is that's wrong, don't give up until you've managed to pin the blame on something specific - whatever you find out may be of help to others. It might also be worth naming the make and model of both the computers and the HDD.
Note: the DexOS tool is designed to only write OS to USB fobs not USB hard drives (for safety i think), if you want it to write to hard drives using that tool, you need to get the code from the webs site and mod it.
romfox
Member
Member
Posts: 50
Joined: Wed Nov 16, 2011 8:14 am

Re: Problem on real hardware

Post by romfox »

Hello all,
It's a good day for me. I came back on my problem (cause I could continue my kernel which works in Bochs) and simply adding bs=512 to my "dd" command and selecting floppy emulation all works, but only using 1 of my USB entries, can it be ? Yes but I don't understand why.
Post Reply