OpenVG- baremetal VG

Anything and everything about programming graphics with Ultibo
Gavinmc42
Posts: 1625
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Tue Jul 04, 2017 11:50 am

Code: Select all

Value:=PLongWord(BCM2835_PERIPHERALS_BASE + V3D_BASE + V3D_IDENT0)^;
 Output:=IntToHex(Value,8)  ;
 ConsoleWindowWriteLn(WindowHandle,'V3D_IDENTO = ' + Output);       


Ok, this gives me DEADBEEF
So, done something wrong, suspect it is beginners mistake.

And no pik33, I refuse to do it in assembler, putting that off as long as possible ;)
There is baremetal and then there is totally bare, whipping oneself with a cat of nine tails baremetal :lol:
User avatar
Ultibo
Site Admin
Posts: 2257
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: OpenVG- baremetal VG

Postby Ultibo » Tue Jul 04, 2017 11:56 am

Gavinmc42 wrote:Ok, this gives me DEADBEEF
So, done something wrong, suspect it is beginners mistake.

What is it meant to return according to Peter's example?

0xDEADBEEF sounds very much like a standard programmer joke to me :roll:
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1625
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Tue Jul 04, 2017 12:10 pm

Peter's code returns $02443356

DEADBEEF is an embedded error code, last time I saw it was decades ago, playing with an early Arm7TDMI eval board.
That was a very dusty memory.

Peter's kernel.img require a config.txt with this in it.

Code: Select all

kernel_old=1
disable_commandline_tags=1
disable_overscan=1
framebuffer_swap=0


Pretty sure it is important, suspect "kernel_old=1" is the clue?
Gavinmc42
Posts: 1625
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Tue Jul 04, 2017 12:11 pm

Page 96 ;)
User avatar
Ultibo
Site Admin
Posts: 2257
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: OpenVG- baremetal VG

Postby Ultibo » Tue Jul 04, 2017 12:25 pm

Gavinmc42 wrote:Peter's code returns $02443356

Which is Version 2 plus "V3D" in ASCII.

Gavinmc42 wrote:Pretty sure it is important, suspect "kernel_old=1" is the clue?

Nope, that just loads the kernel at 0x00000000 instead and does no setup at all. Won't boot an Ultibo image like that.

Gavinmc42 wrote:

Code: Select all

Value:=PLongWord(BCM2835_PERIPHERALS_BASE + V3D_BASE + V3D_IDENT0)^;


I don't have a Pi right now to test with so I'll ask the obvious question, this is a Pi A/B/A+/B+/Zero that you are trying? Otherwise you need to use the BCM2836 or BCM2837 peripherals base instead.
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1625
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Tue Jul 04, 2017 12:33 pm

Er, had me worried I had another senior moment.
Yep, still set on ARMv6 Zero.

Hmm, cannot attach my v3D.pas file with constants
Gavinmc42
Posts: 1625
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Tue Jul 04, 2017 1:11 pm

Forgot to check for GiGo

Code: Select all

Address:=BCM2835_PERIPHERALS_BASE + V3D_BASE + V3D_IDENT0 ;
 Value:=PLongWord(BCM2835_PERIPHERALS_BASE + V3D_BASE + V3D_IDENT0 )^;
 Output1:=IntToHex(Address,8);
 Output2:=IntToHex(Value,8);
 ConsoleWindowWriteLn(WindowHandle,'Address = ' + Output1 + ' V3D_IDENTO = ' + Output2);   


V3D_BASE = $C00000 ; //V3D Base Address ($20C00000 PHYSICAL, $7EC00000 BUS)

I get 20C00000 for the address. The register offsets seem to work too, V3D_IDENT1 gives 20C00004.
User avatar
Ultibo
Site Admin
Posts: 2257
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: OpenVG- baremetal VG

Postby Ultibo » Wed Jul 05, 2017 12:32 am

Ultibo wrote:I don't have a Pi right now to test with so I'll ask the obvious question, this is a Pi A/B/A+/B+/Zero that you are trying? Otherwise you need to use the BCM2836 or BCM2837 peripherals base instead.

Ok so I tested it on a Pi and I get the same result, the interesting thing is the QPUs need to be enabled in order to read any of the registers.

So here's a working EnableQPU() function, it's really the same as the version develone ended up with in this post I just thought I would put it here for clarity (it also means we can prove 100% that this function works now).

Note that this is for Pi A/B/Zero etc, for a Pi2 or Pi3 the BCM2835 needs to be changed to 2836 or 2837.

Code: Select all

//Some important extras for the uses clause, these are in addition to any you already have
uses
 BCM2835,
 HeapManager;
 
function EnableQPU(Enable:LongWord):LongWord;
{Enable QPUs using the Mailbox property tags channel}
var
 Size:LongWord;
 Status:LongWord;
 Response:LongWord;
 Header:PBCM2835MailboxHeader;
 Footer:PBCM2835MailboxFooter;
 Tag:PBCM2835MailboxTagEnableQPU;
begin
 {}
 Result:=LongWord(-1);
 
 {Calculate Size}
 Size:=SizeOf(TBCM2835MailboxHeader) + SizeOf(TBCM2835MailboxTagEnableQPU) + SizeOf(TBCM2835MailboxFooter);
 
 {Allocate Mailbox Buffer}
 {$IFDEF CPUARMV6}
 Header:=GetSharedAlignedMem(Size,SIZE_16); {Must be 16 byte aligned}
 {$ELSE}
 Header:=GetNoCacheAlignedMem(Size,SIZE_16); {Must be 16 byte aligned}
 {$ENDIF}
 if Header = nil then Header:=GetAlignedMem(Size,SIZE_16); {Must be 16 byte aligned}
 if Header = nil then Exit;
 try
  {Clear Buffer}
  FillChar(Header^,Size,0);
 
  {Setup Header}
  Header^.Size:=Size;
  Header^.Code:=BCM2835_MBOX_REQUEST_CODE;
 
  {Setup Tag}
  Tag:=PBCM2835MailboxTagEnableQPU(PtrUInt(Header) + PtrUInt(SizeOf(TBCM2835MailboxHeader)));
  Tag^.Header.Tag:=BCM2835_MBOX_TAG_ENABLE_QPU;
  Tag^.Header.Size:=SizeOf(TBCM2835MailboxTagEnableQPU) - SizeOf(TBCM2835MailboxTagHeader);
  Tag^.Header.Length:=SizeOf(Tag^.Request);
  Tag^.Request.Enable:=Enable;
 
  {Setup Footer}
  Footer:=PBCM2835MailboxFooter(PtrUInt(Tag) + PtrUInt(SizeOf(TBCM2835MailboxTagEnableQPU)));
  Footer^.Tag:=BCM2835_MBOX_TAG_END;
 
  {Call Mailbox}
  Status:=MailboxPropertyCall(BCM2835_MAILBOX_0,BCM2835_MAILBOX0_CHANNEL_PROPERTYTAGS_ARMVC,Header,Response);
  if Status <> ERROR_SUCCESS then
   begin
    if PLATFORM_LOG_ENABLED then PlatformLogError('EnableQPU: MailboxPropertyCall failed (Status=' + ErrorToString(Status) + ')');
   
    Exit;
   end;

  {Get Result}
  Result:=Tag^.Response.Status;
 finally
  FreeMem(Header);
 end;
end;

So with that function in place you can change your code to enable the QPU first like this:

Code: Select all

 
 EnableQPU(1);
 
 Value:=PLongWord(BCM2835_PERIPHERALS_BASE + V3D_BASE + V3D_IDENT0)^;
 Output:=IntToHex(Value,8)  ;
 ConsoleWindowWriteLn(WindowHandle,'V3D_IDENTO = ' + Output);       

And you should see the value 02443356 instead of DEADBEEF.
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1625
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Wed Jul 05, 2017 2:24 am

QPU's disabled to save power?

Glad you know what you are talking about.
This sheds some light on develone's code?
Tried to follow that but gave up early on :oops:
When I started that thread I did not expect anyone to run with it for 8 pages, glad you guys know what you are doing.

Will have to regenerate my working code from home, no luck yet.
Nice hardware version of bouncing blocks in the examples please, then I might get some where ;)
As I understand (barely) we need to get the Z stuff sorted too, so bouncing boxes go over or under others?

To use VG mode 41/42 we only have a few primitives. RHTs and Triangles.

3rd on google search, a new OS, nope 2 year old one?
https://github.com/mntmn/interim/blob/m ... rol_list.h

4th on google RHT patent
https://www.google.com/patents/US20110261059

This stuff must be bleeding edge because I came up 5th on the search :ugeek:
Nope, number 1 now :lol:

I think RHT's are curves, from curves circles/ovals can be made.
I suspect I opened a big can of worms?
More fuel to the fire, 48, the Compressed Primitives Lists look interesting too.

Will this change the survey?
OpenVG/GL with external libraries looks to be a big pain.
A simple VG option might shed some light into how these blob things works.

Garry, as much as I don't want to distract you from the important stuff (QEMU, TCP, SSH) ;)
A few hardware VG examples would be a big Graphics boost for non coders like me.
Lines, rects, oval? The basics for GUI's etc. Now hard is that going to be?
Plus it would lay the ground for the 3D,vector stuff later on.

Even if you get the OpenGLES stuff working I would still have to learn OpenGLES, not sure there is room left in my head.
If Peter can do this stuff in a few hundred bytes, do we need big blobs of library code right now?

Of course having both(more) options is the part of your master plan?
Gavinmc42
Posts: 1625
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Wed Jul 05, 2017 6:03 am

Found this, not sure if the Raspberry Pi website has it.
https://www.raspberrypi.org/forums/view ... 72&t=71261
https://rawgit.com/msperl/rpi-registers ... sters.html

Is this the best place to put it?

Return to “Graphics”

Who is online

Users browsing this forum: No registered users and 1 guest