Raspberry Pi | Error: backward ref to unknown label "1:"

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
User avatar
Sammyueru
Posts: 6
Joined: Wed Jun 09, 2021 2:25 pm

Raspberry Pi | Error: backward ref to unknown label "1:"

Post by Sammyueru »

Hello I am trying to make a raspberry pi OS from scratch but I get this error for the boot.s file when building with a makefile:

Code: Select all

..//src/kernel/boot.s: Assembler messages:
..//src/kernel/boot.s:32: Error: backward ref to unknown label "1:"
make: *** [Makefile:95: ..//build/objects/boot.o] Error 1
Whenever I look up the error it seems to be that the script cannot figure out that its supposed to be a number or something like that.
Sorry if this something only an asm noob could miss.


Boot.s Script:

Code: Select all

// AArch64 mode
 
// To keep this in the first portion of the binary.
.section ".text.boot"
 
// Make _start global.
.globl _start
 
    .org 0x80000
// Entry point for the kernel. Registers:
// x0 -> 32 bit pointer to DTB in memory (primary core only) / 0 (secondary cores)
// x1 -> 0
// x2 -> 0
// x3 -> 0
// x4 -> 32 bit kernel entry point, _start location
_start:
    // set stack before our code
    ldr     x5, =_start
    mov     sp, x5
 
    // clear bss
    ldr     x5, =__bss_start
    ldr     w6, =__bss_size
3:  cbz     w6, 4f
    str     xzr, [x5], #8
    sub     w6, w6, #1
    cbnz    w6, 3b
 
    // jump to C code, should not return
4:  bl      kernel_main
    // for failsafe, halt this core too
    b 1b 

Anyways thanks in advance.
-Sam()

Code: Select all

{
    Programmer();
}
Octocontrabass
Member
Member
Posts: 5567
Joined: Mon Mar 25, 2013 7:01 pm

Re: Raspberry Pi | Error: backward ref to unknown label "1:"

Post by Octocontrabass »

Where did you get this code?
User avatar
Sammyueru
Posts: 6
Joined: Wed Jun 09, 2021 2:25 pm

Re: Raspberry Pi | Error: backward ref to unknown label "1:"

Post by Sammyueru »

Octocontrabass wrote:Where did you get this code?
I got it from Raspberry Pi bare bones on OSDev
-Sam()

Code: Select all

{
    Programmer();
}
Octocontrabass
Member
Member
Posts: 5567
Joined: Mon Mar 25, 2013 7:01 pm

Re: Raspberry Pi | Error: backward ref to unknown label "1:"

Post by Octocontrabass »

It looks like someone put untested code on the wiki again.

I'm no Raspberry Pi expert, but I think adding one line of code should fix it:

Code: Select all

    // for failsafe, halt this core too
1:  wfe
    b 1b 
User avatar
Sammyueru
Posts: 6
Joined: Wed Jun 09, 2021 2:25 pm

Re: Raspberry Pi | Error: backward ref to unknown label "1:"

Post by Sammyueru »

Octocontrabass wrote:It looks like someone put untested code on the wiki again.

I'm no Raspberry Pi expert, but I think adding one line of code should fix it:

Code: Select all

    // for failsafe, halt this core too
1:  wfe
    b 1b 
Thank you I’ll try that
-Sam()

Code: Select all

{
    Programmer();
}
Post Reply