• Pi Zero (2) VPU clock frequency and instruction set

    From Computer Nerd Kev@3:770/3 to All on Tue Nov 8 15:25:20 2022
    The VPU is a processor core in the Pi's GPU. I've been messing
    around with trying to execute code on it for precise timing (no
    interrupts etc. from Linux).

    After much research online, I've got two questions still
    unanswered. I can probably get by without answers to them, but it's
    annoying because they seem basic.

    1) Is there a specification for the VPU clock frequency of the Pi
    Zero and Zero 2 stated somewhere? All that I've found is 400MHz
    on the Raspberry Pi Wikipedia page, but that's unreferenced so I
    don't really trust it.

    2) Is this really the only copy of the instruction set (the
    public Broadcom documentation doesn't cover the VPU)?
    https://github.com/hermanhermitage/videocoreiv/wiki/VideoCore-IV-Programmers-Manual
    The formatting isn't very easy to read as a quick reference.
    This instruction set should be common to all the Pi models
    pre-Pi4.

    --
    __ __
    #_ < |\| |< _#

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From A. Dumas@3:770/3 to Computer Nerd Kev on Tue Nov 8 09:22:56 2022
    On 08-11-2022 06:25, Computer Nerd Kev wrote:
    1) Is there a specification for the VPU clock frequency of the Pi
    Zero and Zero 2 stated somewhere? All that I've found is 400MHz
    on the Raspberry Pi Wikipedia page, but that's unreferenced so I
    don't really trust it.

    It's variable. See e.g. here (first google hit so presumably you've seen
    this? so then maybe I don't understand the scope of your question) https://forums.raspberrypi.com/viewtopic.php?t=281840

    As always, "jamesh" is not particularly helpful.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Theo@3:770/3 to Computer Nerd Kev on Tue Nov 8 10:38:52 2022
    Computer Nerd Kev <not@telling.you.invalid> wrote:
    2) Is this really the only copy of the instruction set (the
    public Broadcom documentation doesn't cover the VPU)?
    https://github.com/hermanhermitage/videocoreiv/wiki/VideoCore-IV-Programmers-Manual
    The formatting isn't very easy to read as a quick reference.
    This instruction set should be common to all the Pi models
    pre-Pi4.

    It's reverse engineered, and Herman is the one who did the reverse
    engineering (~2014 or so). So I'm not surprised that it's the only documentation.

    I see there are some QPU assemblers but not sure if anyone has written any toolchain for the VPU. If so, they might have the ISA better represented.

    Theo

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Computer Nerd Kev@3:770/3 to A. Dumas on Wed Nov 9 07:24:22 2022
    A. Dumas <alexandre@dumas.fr.invalid> wrote:
    On 08-11-2022 06:25, Computer Nerd Kev wrote:
    1) Is there a specification for the VPU clock frequency of the Pi
    Zero and Zero 2 stated somewhere? All that I've found is 400MHz
    on the Raspberry Pi Wikipedia page, but that's unreferenced so I
    don't really trust it.

    It's variable. See e.g. here (first google hit so presumably you've seen this? so then maybe I don't understand the scope of your question) https://forums.raspberrypi.com/viewtopic.php?t=281840

    If I saw it, I probably assumed it was a false result because I
    didn't realise that the "core" frequency is also the VPU clock
    frequency (I vagely associated it with the peripheral controllers,
    which seems also to be correct).

    Now I've found what I was looking for in the Overclocking section
    of the config.txt docs, where it indeed lists the core_freq setting
    as being 400Mhz by default on both Pi Zero models.

    https://www.raspberrypi.com/documentation/computers/config_txt.html

    Thanks!

    --
    __ __
    #_ < |\| |< _#

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Computer Nerd Kev@3:770/3 to Theo on Wed Nov 9 07:53:10 2022
    Theo <theom+news@chiark.greenend.org.uk> wrote:
    Computer Nerd Kev <not@telling.you.invalid> wrote:
    2) Is this really the only copy of the instruction set (the
    public Broadcom documentation doesn't cover the VPU)?
    https://github.com/hermanhermitage/videocoreiv/wiki/VideoCore-IV-Programmers-Manual
    The formatting isn't very easy to read as a quick reference.
    This instruction set should be common to all the Pi models
    pre-Pi4.

    It's reverse engineered, and Herman is the one who did the reverse engineering (~2014 or so). So I'm not surprised that it's the only documentation.

    I was hoping that someone had at least rearranged the info into
    more of a table structure, like you'd get from a chip manufacturer
    that doesn't insist on keeping most of their docs soopa secret.
    There are a handful of example assembly routines out there that
    people have written for the VPU. It seems like some would have been
    very hard to write with only a reference like that, but maybe
    everyone just makes their own version and keeps it to themselves,
    or they're just vastly better at remembering instruction sets
    than me.

    On the other hand I read that it's based on ARM, so maybe there are
    some rules by which you can easily tell which ARM instructions are
    valid or equivalent for the VPU?

    I see there are some QPU assemblers but not sure if anyone has written any toolchain for the VPU. If so, they might have the ISA better represented.

    Sure, I've found three so far, and I have gone looking though the
    sources of some in the hope of finding useful comments, but so far
    I've just seen lists of instruction names without descriptions of
    what they do.

    https://github.com/itszor/vc4-toolchain https://github.com/christinaa/LLVM-VideoCore4
    http://www.compilers.de/vbcc.html

    Really everything I want to do is in the examples anyway, but a
    convenient instruction set reference would make things easier and
    probably save some guesswork.

    Or I could use one of those toolchains and write the code in C,
    but I suspect that might just introduce more uncertainties because
    none of them claim to be near release-quality. Plus I'm starting
    with something very simple anyway.

    --
    __ __
    #_ < |\| |< _#

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From A. Dumas@3:770/3 to Computer Nerd Kev on Wed Nov 9 09:09:00 2022
    On 08-11-2022 22:24, Computer Nerd Kev wrote:
    https://www.raspberrypi.com/documentation/computers/config_txt.html

    Ah yes. But I'd be wary of its variability. At a minimum (heh), set the core_freq_min to be the same, I suppose.

    And will enabling the mini-uart override that and chug it in 250 MHz
    anyway? Who knows.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Computer Nerd Kev@3:770/3 to A. Dumas on Thu Nov 10 07:56:22 2022
    A. Dumas <alexandre@dumas.fr.invalid> wrote:
    On 08-11-2022 22:24, Computer Nerd Kev wrote:
    https://www.raspberrypi.com/documentation/computers/config_txt.html

    Ah yes. But I'd be wary of its variability. At a minimum (heh), set the core_freq_min to be the same, I suppose.

    Good point, I'm not sure how the "dynamic frequency clocking" works
    for the GPU, but I'll set that to 400 and hope that stops it. It
    sounds like it's only enabled when the CPU is in frequency scaling
    mode as well.

    And will enabling the mini-uart override that and chug it in 250 MHz
    anyway? Who knows.

    Well for me the main thing is just to know that it will run at the
    same speed on both the original Pi Zero and the Pi Zero 2 in the
    same configuration, so it gives me more confidence with that.
    Compared to the Wikipedia page where I worried that someone could
    have just guessed that it was the same as the old model.

    But now I've got a 1MHz square wave generator program running on
    the VPU, so actually it's easy enough to measure any difference now
    anyway.

    I see now that the VPUs seem to be known as the "GPU Core" in
    RPi the docs, whereas the GPU itself seems to refer to the QPUs.
    It's especially confusing given that some VideoCore IV GPUs exist
    without a VPU (the one that Broadcom released the docs for), so
    those are a VideoCore without a core.

    --
    __ __
    #_ < |\| |< _#

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)