krom
Posts: 61
Joined: Wed Dec 05, 2012 9:12 am
Contact: Website

Trying Bare Metal on Raspberry Pi 3

Sat Mar 12, 2016 2:10 am

Hi everyone,
I got my Raspberry Pi 3, and tested out all my demos from here:
https://github.com/PeterLemon/RaspberryPi

It seems backwards compatible with all my Raspberry Pi 2 "kernel7.img" files.

I tried out SMP with NEON instructions, and the cpu setup for these have stayed the same, so they run.

My GPU V3D demos all still work, as they are using the same Broadcom GPU, the GPU is also clocked higher.

Also my sound demos using PWM all work, so the registers for them have stayed the same.

Next step for me is to investigate ARM's new 64-bit instruction set aarch64, on bare-metal.
This is a whole new instruction set, with 32 general purpose registers for us to program in assembly with =D

I have tried to find out what stage FASMARM is at to support these instructions,
as the author revolution has stated previously he has been working on implementing these instructions:
http://board.flatassembler.net/topic.php?p=178744

Anyway, I'll update you guys here with anything cool I do for Raspberry Pi 3, I hope you are all having fun =D

krom
Posts: 61
Joined: Wed Dec 05, 2012 9:12 am
Contact: Website

Re: Trying Bare Metal on Raspberry Pi 3

Thu May 26, 2016 7:09 pm

Great news FASMARM now supports aarch64 instructions: http://arm.flatassembler.net/

I have started converting all of my R-Pi GitHub source to 64-bit ARM code.

I found out that just renaming the kernel image file to kernel8.img, automatically sets the Raspberry Pi 3 into the 64-bit state, ready to run the code.
So it was much easier than I thought it would be, with no changes to my config.txt boot file.

You can find all my new kernel8.img files inside the directories here: https://github.com/PeterLemon/RaspberryPi

I have not yet converted my NEON code to the new advanced SIMD 64-bit instructions yet, but I will get them done soon.

I used these PDF documents to help me understand the new aarch64 instruction set:
ARMv8 Instruction Set Overview - https://www.element14.com/community/ser ... Manual.pdf

Programmer’s Guide for ARMv8-A - http://infocenter.arm.com/help/topic/co ... ure_PG.pdf

Technical Reference Manual - http://infocenter.arm.com/help/topic/co ... p2_trm.pdf

Advanced SIMD and Floating-point Extension - http://infocenter.arm.com/help/topic/co ... pu_trm.pdf

ARMv8, for ARMv8-A architecture profile - https://people.mozilla.org/~sstangl/arm ... Manual.pdf

I am having lots of fun learning aarch64, so I thought I'd let you guys know how easy it is with the new FASMARM.
I hope this helps a few of you out there, & I'll update with any new stuff I do here =D

krom
Posts: 61
Joined: Wed Dec 05, 2012 9:12 am
Contact: Website

Re: Trying Bare Metal on Raspberry Pi 3

Sun Jul 24, 2016 2:10 am

Hi everyone,

I just thought I'd bring to your attention this new project by a friend of mine Jaymin Kessler which can be found here:
http://maisonikkoku.com/jaystation2/blog_main.html

He is using a R-Pi 2 in bare metal, to try to create a new gaming console called the Jaystation 2!

He is breaking down all the hard GPU bare metal stuff & explaining it really well, if you are interested in this sort of thing, I really recommend checking out his blog posts.
The last couple of posts detail exactly how he is starting to use the GPU, hope this helps anyone out there who want todo similar stuff.

Anyway take care, I'll try todo some more RPi-3 stuff soon, happy hacking =D

krom
Posts: 61
Joined: Wed Dec 05, 2012 9:12 am
Contact: Website

Re: Trying Bare Metal on Raspberry Pi 3

Wed Mar 20, 2019 4:22 am

Hi everyone,

Sorry for the lack of updates on my GPU work recently...

I thought I'd let you know with the help of my friend Jaymin Kessler's Jaystation 2 blog:
http://maisonikkoku.com/jaystation2/chapter_11.html

I managed to get my 1st bare metal textured triangle demo working here:
https://github.com/PeterLemon/Raspberry ... le/Texture

I just used a non swizzled RAW RGBA8888 32-Bit Texture, which you can see at the bottom of the FASMARM src.
(Just a white arrow pointing upwards, with Red/Green/Blue/Yellow pixels in the corners)

I setup the v3d to use all the info I learned from Jaymin, but I used a special option which let me use non Swizzled Textures.
I also made my own commented assembly QPU texture shader:

Code: Select all

FRAGMENT_SHADER_CODE:
  ; Texture Shader

  ; Tex S: ACC0 = S * W (R15A)
  ; Add Op: No Operation, Add Cond: Never
  ; Mul Pipe: Floating Point Multiply, ACC0, R15, VARYING_READ, Cond: Always
  dw $203E3037
  dw $100049E0 ; nop; fmul r0, ra15, vary; nop

  ; Tex S Coord: ACC0 = S * W + C, Tex T: ACC1 = T * W (R15A)
  ; Add Pipe: Floating Point Add, ACC0, ACC R0, ACC R5, Cond: Always
  ; Mul Pipe: Floating Point Multiply, ACC1, R15, VARYING_READ, Cond: Always
  ; Signal: Wait For Scoreboard
  dw $213E3177
  dw $40024821 ; fadd r0, r0, r5; fmul r1, ra15, vary; sbwait

  ; Tex T Write Reg = T * W + C, Trigger First Sampler Param Uniform Read
  ; Add Pipe: Floating Point Add, TMU0_T, ACC R1, ACC R5, Cond: Always
  ; Mul Op: No Operation, Mul Cond: Never
  dw $019E7340
  dw $10020E67 ; fadd t0t, r1, r5; nop; nop

  ; Moving S coord (In ACC0) To S Register, Trigger Second Sampler Param Uniform Read, & Kick It All Off
  ; Add Pipe: Bitwise OR, TMU0_S_RETIRING, ACC R0, ACC R0, Cond: Always
  ; Mul Op: No Operation, Mul Cond: Never
  dw $159E7000
  dw $10020E27 ; mov t0s, r0; nop; nop

  ; Signal TMU Texture Read
  ; Add Op: No Operation, Add cond: Never
  ; Mul Op: No Operation, Mul cond: Never
  ; Signal: Load Data From TMU0 To R4
  dw $009E7000
  dw $A00009E7 ; nop; nop; ldtmu0

  ; Exporting Read Texture Data To MRT0
  ; Add Pipe: Bitwise OR, TLB_COLOUR_ALL, ACC R4, ACC R4, Cond: Always
  ; Mul Op: No operation, Mul Cond: Never
  ; Signal: Program End
  dw $159E7900
  dw $30020BA7 ; mov tlbc, r4; nop; thrend

  ; Thread End Delay Slot 1
  ; Add Op: No Operation, Add cond: Never
  ; Mul Op: No Operation, Mul cond: Never
  dw $009E7000 ;
  dw $100009E7 ; nop; nop; nop

  ; Thread End Delay Slot 2
  ; Add Op: No Operation, Add cond: Never
  ; Mul Op: No Operation, Mul cond: Never
  ; Signal: Scoreboard Unlock
  dw $009E7000 ;
  dw $500009E7 ; nop; nop; sbdone


As always I have demos for R-Pi 1 (kernel), R-Pi 2/3 ARM32 (kernel7), & R-Pi 3 ARM64/AARCH64 (kernel8).

Please checkout Jaymin's Jaystation 2 src here for more examples:
https://bitbucket.org/okonomiyonda/jays ... public/src

Next for me to try is:
1. Shaded textured triangles (QPU assembly will be a combination of my shaded triangle shader, & this textured triangle shader)
2. Using the HW Z-Buffer (Need to read up on Z-Buffer tile rendering, & setup the V3D Z-Buffer options correctly)

bzt
Posts: 393
Joined: Sat Oct 14, 2017 9:57 pm

Re: Trying Bare Metal on Raspberry Pi 3

Sat Mar 23, 2019 3:23 pm

Hi krom,

Thanks for sharing! And thanks for your tutorials, FASM is also my favourite assembler, for a good reason :-)

Cheers,
bzt

Return to “Bare metal, Assembly language”