Status of Raspberry Pi native support

NinjaCowboy · 77529

pixie

  • Junior Member
  • **
    • Posts: 83
    • Karma: +2/-4
Reply #75 on: June 22, 2023, 02:21:40 AM
Yes but you can't test AROS 68k with distributions where there is a lot of OS3 software and very little native AROS 68k software "of system" :)

In the end you will never understand, where the incompatibilities come from.
I hope with time more and more x86 binaries get compiled over 68k



deadwood

  • AROS Developer
  • Legendary Member
  • *****
    • Posts: 1524
    • Karma: +118/-0
Reply #76 on: June 22, 2023, 02:53:48 AM
So, I swapped the include order in cpu_init.c so that kernel_cpu.h is included before kernel_base.h, and that seemed to fix that one error.

But there's another issue.
Code: [Select]
make[1]: *** No rule to make target 'scanf-examples.c', needed by '/home/ninja/programming/aros-rpi/AROS/bin/raspi-arm/gen/developer/debug/test/crt/posixc/scanf-examples.o'.  Stop.
[MMAKE] make --no-print-directory TOP=/home/ninja/programming/aros-rpi/AROS SRCDIR=/home/ninja/programming/aros-rpi/AROS CURDIR=developer/debug/test/crt/posixc TARGET=test-crt-posixc-posix1-scanf --file=mmakefile test-crt-posixc-posix1-scanf failed: 512
[MMAKE] Error: Error while running make in developer/debug/test/crt/posixc: No such file or directory
make: *** [Makefile:125: all] Error 10

These error most likely comes from not initialized gitmodules. Try this

Code: [Select]
git submodule update --init --recursive

Also please note that raspi-armhf target is failing to build on nightly builds right now (https://github.com/aros-development-team/AROS, bottom of page)



AMIGASYSTEM

  • Global Moderator
  • Legendary Member
  • *****
    • Posts: 3762
    • Karma: +69/-2
  • AROS One
    • AROS One
Reply #77 on: June 22, 2023, 04:05:32 AM

I am sure. It was official OS on Apollo V4 before they officially switched to ApolloOS. Pedro Cotter then continued for its own

To be sure of what you write you have to try it for yourself.


Read this review of CaffeineOS Testing Online Updater Versione vampiro:

https://www.youtube.com/watch?v=pvphkgy-J9w

Starting with CaffeineOS_Vampire Version 852, the updates can be performed On Line.
Aros version is next.




CaffeineOS 797 ( Amiga Emulation on the next level)

CaffeineOS is a great Amiga OS filled with many application and games and it runs very stable. you should try this out !!!

https://youtu.be/MV6snYm-NLk
« Last Edit: June 22, 2023, 05:20:36 AM by AMIGASYSTEM »



AMIGASYSTEM

  • Global Moderator
  • Legendary Member
  • *****
    • Posts: 3762
    • Karma: +69/-2
  • AROS One
    • AROS One
Reply #78 on: June 22, 2023, 04:28:46 AM
This means that the versions of CaffeineOS released in recent times did not include AROS 68k, in my screenshot of CaffeineOS downloaded a few months ago, as you can see there is no AROS 68k system software, also only starts with kickstart 3.1

So a distinction must be made between "Aros Caffeine (ApolloOS)" and "CaffeineOS"

« Last Edit: June 22, 2023, 05:31:27 AM by AMIGASYSTEM »



OlafS3

  • Legendary Member
  • *****
    • Posts: 544
    • Karma: +50/-8
Reply #79 on: June 22, 2023, 06:18:31 AM
that indeed looks like something based on 3.X and not on Aros 68k. It seems he changed it. Low level stuff like MCP not works in Aros 68k and Overscan not exists on Aros 68k. And typical Aros prefs like Zune are not existing. It explains why f.e. IBrowse works in it. I have read a little on discord. It seems he supported different platforms in past with it (Apollo, PiStorm, WinUAE) and reduced it to PiStorm where only 3.X is working.
« Last Edit: June 22, 2023, 06:56:11 AM by OlafS3 »



NinjaCowboy

  • Junior Member
  • **
    • Posts: 66
    • Karma: +18/-0
Reply #80 on: June 22, 2023, 07:35:36 AM
So, I swapped the include order in cpu_init.c so that kernel_cpu.h is included before kernel_base.h, and that seemed to fix that one error.

But there's another issue.
Code: [Select]
make[1]: *** No rule to make target 'scanf-examples.c', needed by '/home/ninja/programming/aros-rpi/AROS/bin/raspi-arm/gen/developer/debug/test/crt/posixc/scanf-examples.o'.  Stop.
[MMAKE] make --no-print-directory TOP=/home/ninja/programming/aros-rpi/AROS SRCDIR=/home/ninja/programming/aros-rpi/AROS CURDIR=developer/debug/test/crt/posixc TARGET=test-crt-posixc-posix1-scanf --file=mmakefile test-crt-posixc-posix1-scanf failed: 512
[MMAKE] Error: Error while running make in developer/debug/test/crt/posixc: No such file or directory
make: *** [Makefile:125: all] Error 10

These error most likely comes from not initialized gitmodules. Try this

Code: [Select]
git submodule update --init --recursive

Also please note that raspi-armhf target is failing to build on nightly builds right now (https://github.com/aros-development-team/AROS, bottom of page)
Thanks. Is there a compiling guide besides the one here, which is probably really out of date (it mentions gcc 3.2.2 lol)?

Just for the heck of it, I tried building hosted AROS on my Pi, but ran into an error with the compiler options. I don't think the compiler version I have installed would matter, since the build system downloads and builds gcc 6.5.0 anyway. I just ran ./configure with no args to build hosted.
Code: [Select]
Compiling  /home/pi/AROS/compiler/libinit/libentry.c
arm-aros-gcc: error: missing argument to '-mfpu='
arm-aros-gcc: error: missing argument to '-mfpu='
arm-aros-gcc: error: unrecognized command line option '-marmlittle-endian'; did you mean '-mlittle-endian'?
arm-aros-gcc: error: unrecognized command line option '-marmlittle-endian'; did you mean '-mlittle-endian'?
make[1]: *** [mmakefile:574: /home/pi/AROS/bin/linux-arm/gen/compiler/libinit/libentry.o] Error 1
[MMAKE] make --no-print-directory TOP=/home/pi/AROS SRCDIR=/home/pi/AROS CURDIR=compiler/libinit TARGET=libinit-libentry --file=mmakefile libinit-libentry failed: 512
[MMAKE] Error: Error while running make in compiler/libinit: No such file or directory
make: *** [Makefile:125: all] Error 10
« Last Edit: June 22, 2023, 07:39:25 AM by NinjaCowboy »



deadwood

  • AROS Developer
  • Legendary Member
  • *****
    • Posts: 1524
    • Karma: +118/-0
Reply #81 on: June 22, 2023, 08:27:54 AM
@NinjaCowboy

Unfortunately I don't think there is a newer guide. I also never tried building hosted directly on the Pi. I did build armhf-hosted some time ago on my  x86 64-bit machine. If you have one you can try following these instructions

https://github.com/deadw00d/AROS/blob/master/INSTALL.md

and selecting first the armhf toolchain and them armhf hosted. I do remember I had to uninstall some package from linux or I was getting conflicts during compilation. The armhf targets are not officially supported/maintained in my repo.



NinjaCowboy

  • Junior Member
  • **
    • Posts: 66
    • Karma: +18/-0
Reply #82 on: June 22, 2023, 10:45:29 PM
So, apparently, I was able to get raspi-armhf native to build with few issues by configuring in a separate build directory (Well, actually I did have to comment out the build rule for workbench-datatypes-heic, since that library tries to use C++ exceptions, even though they are disabled in the compiler flags). No idea why it decided to work this time.

I've started debugging with qemu and gdb, but I've noticed something strange. Many of the jump labels are offset by +8, and this seems to make function calls not work properly (basically skipping the function prologue), and I can't breakpoint on functions either because of this. You can see this in the objdump output (notice the +0x8 on all the bl instructions).
Code: [Select]
AROS-build/bin/raspi-arm/gen/rom/boot/aros-arm-raspi.img.elf:     file format elf32-littlearm


Disassembly of section .text:

00008000 <bootstrap>:
    8000: e10f4000 mrs r4, CPSR
    8004: e204401f and r4, r4, #31
    8008: e3a0801a mov r8, #26
    800c: e1540008 cmp r4, r8
    8010: 0a000007 beq 8034 <leave_hyper>

00008014 <continue_boot>:
    8014: f1020013 cps #19
    8018: e59fd030 ldr sp, [pc, #48] ; 8050 <tmp_stack_ptr>
    801c: ee114f50 mrc 15, 0, r4, cr1, cr0, {2}
    8020: e384460f orr r4, r4, #15728640 ; 0xf00000
    8024: ee014f50 mcr 15, 0, r4, cr1, cr0, {2}
    8028: e3a04101 mov r4, #1073741824 ; 0x40000000
    802c: eee84a10 vmsr fpexc, r4
    8030: ea000096 b 8290 <boot+0x8>

00008034 <leave_hyper>:
    8034: e24f4028 sub r4, pc, #40 ; 0x28
    8038: e12ef304 .word 0xe12ef304
    803c: e10f4000 mrs r4, CPSR
    8040: e204401f and r4, r4, #31
    8044: e3844013 orr r4, r4, #19
    8048: e16ef304 .word 0xe16ef304
    804c: e160006e .word 0xe160006e

00008050 <tmp_stack_ptr>:
    8050: 00000ff0 45562400 61203a52 72736f72     .....$VER: arosr
    8060: 69707361 676d692e 30347620 2036342e     aspi.img v40.46
    8070: 6e754a28 20323220 33323032 00000029     (Jun 22 2023)...

00008080 <query_vmem>:
    8080: e92d40f0 push {r4, r5, r6, r7, lr}
    8084: e30d0244 movw r0, #53828 ; 0xd244
    8088: e24dd014 sub sp, sp, #20
    808c: e3400000 movt r0, #0
    8090: e3076000 movw r6, #28672 ; 0x7000
    8094: e3406003 movt r6, #3
    8098: eb0003c0 bl 8fa0 <kprintf+0x8>
    809c: e3a03a01 mov r3, #4096 ; 0x1000
    80a0: e3a05000 mov r5, #0
    80a4: e3a04008 mov r4, #8
    80a8: e3a02020 mov r2, #32
    80ac: e5832000 str r2, [r3]
    80b0: e5835004 str r5, [r3, #4]
    80b4: e3a02006 mov r2, #6
    80b8: e3402001 movt r2, #1
    80bc: e5832008 str r2, [r3, #8]
    80c0: e583400c str r4, [r3, #12]
    80c4: e1a02003 mov r2, r3
    80c8: e5835010 str r5, [r3, #16]
    80cc: e30b7880 movw r7, #47232 ; 0xb880
    80d0: e5835014 str r5, [r3, #20]
    80d4: e1a01004 mov r1, r4
    80d8: e5835018 str r5, [r3, #24]
    80dc: e583501c str r5, [r3, #28]
    80e0: e5960000 ldr r0, [r6]
    80e4: e0870000 add r0, r7, r0
    80e8: eb000444 bl 9200 <vcmb_write+0x8>
    80ec: e5960000 ldr r0, [r6]
    80f0: e1a01004 mov r1, r4
    80f4: e0870000 add r0, r7, r0
    80f8: e3a07003 mov r7, #3
    80fc: eb000427 bl 91a0 <vcmb_read+0x8>
    8100: e1a04000 mov r4, r0
    8104: e5901014 ldr r1, [r0, #20]
    8108: e5942018 ldr r2, [r4, #24]
    810c: e30d025c movw r0, #53852 ; 0xd25c
    8110: e3400000 movt r0, #0
    8114: eb0003a1 bl 8fa0 <kprintf+0x8>
    8118: e596c004 ldr ip, [r6, #4]
    811c: e3a0301c mov r3, #28
    8120: e34833d0 movt r3, #33744 ; 0x83d0
    8124: e3a0201d mov r2, #29
    8128: e34823d0 movt r2, #33744 ; 0x83d0
    812c: e58c3000 str r3, [ip]
    8130: e3a03001 mov r3, #1
    8134: e5941014 ldr r1, [r4, #20]
    8138: e28cc010 add ip, ip, #16
    813c: e50c2008 str r2, [ip, #-8]
    8140: e594e014 ldr lr, [r4, #20]
    8144: e5942018 ldr r2, [r4, #24]
    8148: e50c100c str r1, [ip, #-12]
    814c: e5940014 ldr r0, [r4, #20]
    8150: e08ee002 add lr, lr, r2
    8154: e5941014 ldr r1, [r4, #20]
    8158: e5942018 ldr r2, [r4, #24]
    815c: e50ce004 str lr, [ip, #-4]
    8160: e586c004 str ip, [r6, #4]
    8164: e58d5008 str r5, [sp, #8]
    8168: e88d00a0 stm sp, {r5, r7}
    816c: eb00035d bl 8ee8 <mmu_map_section+0x8>
    8170: e28dd014 add sp, sp, #20
    8174: e8bd80f0 pop {r4, r5, r6, r7, pc}
It seems the raspi-armhf-system nightly from April 30th also has this issue.



deadwood

  • AROS Developer
  • Legendary Member
  • *****
    • Posts: 1524
    • Karma: +118/-0
Reply #83 on: June 23, 2023, 03:45:48 AM
If these are local functions, you might be looking at some form of optimization (not creating a new stack frame). Have you tried building with optimizations disabled? --enable-debug should do the trick. You can check OPTIMIZATION_CFLAGS in gen/config/target.cfg.




NinjaCowboy

  • Junior Member
  • **
    • Posts: 66
    • Karma: +18/-0
Reply #84 on: June 23, 2023, 09:48:42 AM
Ah, that makes sense. Most of my ARM coding experience is from GameBoy Advance programming, so I'm not familiar with compiler optimizations for modern ARM CPUs. Even if this code is correct, it does make debugging harder, since gdb is unable to break on the function name when the code jumps inside of it.

I recompiled everything after configuring with --enable-debug, but those branch instructions still have the +0x8 offset. In target.cfg, I see KERNEL_OPTIMIZATION_CFLAGS    := -O0 and OPTIMIZATION_CFLAGS           = $(strip -O0), so I assume it's disabling optimizations. How do I run make in verbose mode to see the full compiler commands as they are run to be sure?


EDIT: I figured out that make Q='' will print the compiler commands, but it shows that boot.c is still getting compiled with -O2 somehow.

It seems that these files are hardcoded to use -O2. https://github.com/aros-development-team/AROS/blob/master/arch/arm-raspi/boot/mmakefile.src#L13
I changed that to -O0. While that successfully disabled optimizations, the branches are still being offset by 8, skipping prologues and causing the stack to not be initialized properly.

I'd like to add the -S compiler option to output assembly, but I'm not familiar enough with this build system to know where the compile command is defined.
« Last Edit: June 23, 2023, 01:30:22 PM by NinjaCowboy »



deadwood

  • AROS Developer
  • Legendary Member
  • *****
    • Posts: 1524
    • Karma: +118/-0
Reply #85 on: June 23, 2023, 02:58:27 PM
A hacky way is to add #error directive in .c file. This will fail the build but you will get the full command line displayed then. You can can copy-paste this command line to modify/get what you want.



NinjaCowboy

  • Junior Member
  • **
    • Posts: 66
    • Karma: +18/-0
Reply #86 on: June 23, 2023, 04:57:23 PM
In ARM, the PC register always points two instructions (8 bytes) ahead of the currently executing one due to prefetch. Any instructions that use the PC (such as branches) need to compensate for this by subtracting 8 from the offset.
I'm mainly looking at this "b boot" instruction in boot.c (https://github.com/aros-development-team/AROS/blob/master/arch/arm-raspi/boot/boot.c#L65), since it's the first one in the file but basically all function calls are affected.
The .o file seems to be compiled correctly with a R_ARM_JUMP24 reloc pointing to boot-0x8.
Code: [Select]
Disassembly of section .aros.startup:

00000000 <bootstrap>:
   0:   e10f4000        mrs     r4, CPSR
   4:   e204401f        and     r4, r4, #31
   8:   e3a0801a        mov     r8, #26
   c:   e1540008        cmp     r4, r8
  10:   0a000007        beq     34 <leave_hyper>

00000014 <continue_boot>:
  14:   f1020013        cps     #19
  18:   e59fd030        ldr     sp, [pc, #48]   ; 50 <tmp_stack_ptr>
  1c:   ee114f50        mrc     15, 0, r4, cr1, cr0, {2}
  20:   e384460f        orr     r4, r4, #15728640       ; 0xf00000
  24:   ee014f50        mcr     15, 0, r4, cr1, cr0, {2}
  28:   e3a04101        mov     r4, #1073741824 ; 0x40000000
  2c:   eee84a10        vmsr    fpexc, r4
  30:   ea000000        b       23c <boot+0x8>
                        30: R_ARM_JUMP24        boot-0x8

00000034 <leave_hyper>:
  34:   e24f4028        sub     r4, pc, #40     ; 0x28
  38:   e12ef304        msr     ELR_hyp, r4
  3c:   e10f4000        mrs     r4, CPSR
  40:   e204401f        and     r4, r4, #31
  44:   e3844013        orr     r4, r4, #19
  48:   e16ef304        msr     SPSR_hyp, r4
  4c:   e160006e        eret
but then it's wrong in aros-arm-raspi.img.elf
Code: [Select]
Disassembly of section .text:

00008000 <bootstrap>:
    8000:       e10f4000        mrs     r4, CPSR
    8004:       e204401f        and     r4, r4, #31
    8008:       e3a0801a        mov     r8, #26
    800c:       e1540008        cmp     r4, r8
    8010:       0a000007        beq     8034 <leave_hyper>

00008014 <continue_boot>:
    8014:       f1020013        cps     #19
    8018:       e59fd030        ldr     sp, [pc, #48]   ; 8050 <tmp_stack_ptr>
    801c:       ee114f50        mrc     15, 0, r4, cr1, cr0, {2}
    8020:       e384460f        orr     r4, r4, #15728640       ; 0xf00000
    8024:       ee014f50        mcr     15, 0, r4, cr1, cr0, {2}
    8028:       e3a04101        mov     r4, #1073741824 ; 0x40000000
    802c:       eee84a10        vmsr    fpexc, r4
    8030:       ea000096        b       8290 <boot+0x8>
                        8030: R_ARM_JUMP24      .text+0x280

00008034 <leave_hyper>:
    8034:       e24f4028        sub     r4, pc, #40     ; 0x28
    8038:       e12ef304        msr     ELR_hyp, r4
    803c:       e10f4000        mrs     r4, CPSR
    8040:       e204401f        and     r4, r4, #31
    8044:       e3844013        orr     r4, r4, #19
    8048:       e16ef304        msr     SPSR_hyp, r4
    804c:       e160006e        eret

...

00008288 <boot>:
    8288:       e92d4ef0        push    {r4, r5, r6, r7, r9, sl, fp, lr}
    828c:       e3083050        movw    r3, #32848      ; 0x8050
                        828c: R_ARM_MOVW_ABS_NC .LANCHOR1
    8290:       e24dd038        sub     sp, sp, #56     ; 0x38
    8294:       e3403000        movt    r3, #0
                        8294: R_ARM_MOVT_ABS    .LANCHOR1
    8298:       e3025000        movw    r5, #8192       ; 0x2000
                        8298: R_ARM_MOVW_ABS_NC .LANCHOR0
    829c:       e3405005        movt    r5, #5
                        829c: R_ARM_MOVT_ABS    .LANCHOR0
    82a0:       e58d3024        str     r3, [sp, #36]   ; 0x24
    82a4:       e1a09001        mov     r9, r1
    82a8:       e5933000        ldr     r3, [r3]
    82ac:       e1a06002        mov     r6, r2
    82b0:       e58d2020        str     r2, [sp, #32]
    82b4:       e2433c0e        sub     r3, r3, #3584   ; 0xe00
    82b8:       e5853004        str     r3, [r5, #4]
The ea000096 instruction is a branch to pc+0x258 (0x96 * 4 = 0x258), but since pc is always 8 bytes ahead of the current instruction, it jumps to 0x8030+8+0x258 = 0x8290, which ends up being 8 bytes ahead of where it should be. The linker seems to ignore the addend (which is -8 here) for R_ARM_JUMP24 relocations. I also tried putting "b boot-8" in the source, but the linker still keeps ignoring the relocation addend for some reason.



NinjaCowboy

  • Junior Member
  • **
    • Posts: 66
    • Karma: +18/-0
Reply #87 on: June 23, 2023, 06:47:40 PM
I did some more experimentation, this appears to be a compiler issue, not a linker issue. If I edit arch/arm-raspi/boot/mmakefile.src and add add this after the include to simply use my system's ARM compiler instead of the AROS one, the relocations in aros-arm-raspi.img.elf and aros-arm-raspi.img resolve correctly!
Code: [Select]
TARGET_CC := arm-none-eabi-gcc \
-isystem $(AROSDIR)/Developer/include/aros/posixc \
-isystem $(AROSDIR)/Developer/include/aros/stdc \
-isystem $(AROSDIR)/Developer/include
I will test and see if any of the other AROS compilers besides the default gcc 6.5.0 produce the correct output.



deadwood

  • AROS Developer
  • Legendary Member
  • *****
    • Posts: 1524
    • Karma: +118/-0
Reply #88 on: June 24, 2023, 01:26:11 AM
From the builds page it looks like the nightly build is using GCC 9.1.0 in this case (and probably a different binutils as well)



NinjaCowboy

  • Junior Member
  • **
    • Posts: 66
    • Karma: +18/-0
Reply #89 on: June 24, 2023, 07:11:33 AM
I just tried with 9.1.0, and it still has the relocation bug. The last successful Raspberry Pi nightly from April also has the relocation bug. I wonder if it's something with how the compiler is configured. @mschulz was apparently able to get something to boot on the Pi. Not sure how he did it.

Actually, it's possible that it could be a problem with the assembler as well, since gcc doesn't produce .o files directly. It just generates assembly and calls "as" to assemble it into a .o file. I'll experiment with combinations of these more today.

Trying to build with llvm is probably not worth it, since there are no successful nightly builds done with it.
« Last Edit: June 24, 2023, 07:19:11 AM by NinjaCowboy »