Radioberry firmware and gateware source code questions

453 views
Skip to first unread message

qrp73

unread,
Mar 5, 2024, 12:47:29 PM3/5/24
to Radioberry
Hi, I'm trying to find the code which processes HPSDR protocol packets, especially I'm interesting on how gain setting is processed.

The gain setting in HPSDR protocol is passed as a byte 4 in control bytes at page 10.
This byte has 6 lower bits (bits 0-5, mask 0x3F) for gain value and bit 6 to enable or disable gain.

But I cannot find the code which process this byte. Could you please point me, which file in the source code has the code to process it?

Best regards
Alex

pa3gsb

unread,
Mar 5, 2024, 1:50:23 PM3/5/24
to Radioberry

Hi Alex,

As you may have seen since the introduction of the RPI-4 i decided to use the nice variant fpga code structure of the hl-2.

For the radioberry some specialities are added.



and there you will find your answer:

  // Linear mapping from 0to255 to 0to39, like Hermes-Lite 1
  tx_gain_computed = ((cmd_data[31:24]+4) >> 3) + (cmd_data[31:24] >> 5);

To make the tx gain more lineair you need to change the following lines:

Just 2 lines to change in the gateware code.

ad9866ctrl.v:

  initarray[16] = {1'b0,8'h84}; // Address 0x10, Select TX gain
  initarray[17] = {1'b0,8'h00}; // Address 0x11, Select TX gain


Some weeks ago i found the reason why the tx gain is not lineair.  I did not have the time do the fix and making a new release.

The gain distrubution when using the driver looks now something about (thanks to yado-san for the diagram)



gain rb.PNG

Enjoy the radio

73 Johan
PA3GSB

Op dinsdag 5 maart 2024 om 18:47:29 UTC+1 schreef qrp73:

Wim PE1PWR

unread,
Mar 5, 2024, 2:03:29 PM3/5/24
to qrp73, Radioberry
Hi Alex.
Contact Johan the maker of the project for it.
He must now what you are looking for.
pa3...@gmail.com is his email address.
Hopes this helps you.
KR
Wim


Op 5 mrt. 2024, om 18:47, qrp73 <qrp...@gmail.com> schreef:

qrp73

unread,
Mar 5, 2024, 3:14:08 PM3/5/24
to Radioberry
Hm, now I'm confused.

I'm looking at source code in this repository: https://github.com/pa3gsb/Radioberry-2.x
According to installation script it uses already compiled gateware from this path: https://github.com/pa3gsb/Radioberry-2.x/tree/master/SBC/rpi-4/releases/dev/CL025

Where I can find the source code of this gateware?

Where is the rpi4 code which receive UDP packet from SDR app, process it and sends to gateware?

```
        push(command);
sem_post(&spi_msg);
```

does it means that linux firmware sends HPSDR packet as is to the gateware and it is processed on gateware side?

qrp73

unread,
Mar 5, 2024, 3:22:22 PM3/5/24
to Radioberry
```
icmd_data[5:0]  = rx_gain[6] ? rx_gain[5:0] : (rx_gain[5] ? ~rx_gain[5:0] : {1'b1,rx_gain[4:0]});
```

It seems that bit 6 is used to select gain encoding type? I thought this bit is used to disable/enable attenuator.

Best regards,
Alex

pa3gsb

unread,
Mar 6, 2024, 10:52:03 AM3/6/24
to Radioberry

Hi,

The code from HL-2 is compiled and the result radioberry.rbf is indeed copied into release folder of radioberry.

You pointed to the right firmware ; there the  udp (or even tcpip connection for running with pihpsdr) is received and transferred to the gateware using the radioberry driver; the driver does communicate via SPI with the gateware. Your code points to the place where the command from the ethernet packet (from SDR program) is placed in a queue which is indeed transferred to the gateware via ioctl to the driver.


How the rx gain is handled is described here : https://github.com/softerhardware/Hermes-Lite2/wiki/Protocol

The rxPGA is having a gain of -12dB to 48dB which is controlled via the rx_gain bits.

Hope this helps.

73 Johan
PA3GSB
Op dinsdag 5 maart 2024 om 21:14:08 UTC+1 schreef qrp73:

qrp73

unread,
Mar 6, 2024, 4:00:50 PM3/6/24
to Radioberry
Thanks, now it's clear. Previously I thought that it uses custom protocol between firmware and gateware and processes packets in software on rpi side. But now I see that it passes HPSDR packets to gateware and it is processed on gateware side.

Best regards,
Alex
Reply all
Reply to author
Forward
0 new messages