Probable bug in OpenGD77

Discussions related to the firmware code development
JP7NJT
Posts: 32
Joined: Wed Oct 18, 2023 12:44 pm

Probable bug in OpenGD77

Post by JP7NJT » Mon Sep 02, 2024 9:14 pm

Hi all,

I think I found 2 bugs in opengd77. Is there a way to correct them?

The first BUG may be in the USB buffer.

In codec_interface.c

I put:

#include "usb/usb_com.h"

then in:
void codecDecode(uint8_t *indata_ptr, int numbBlocks)
{

soundSetupBuffer();// this just sets currentWaveBuffer but the compiler seems to optimise out the code if I try to do it in this file
r2 = (int)bitbuffer_decode;
r0 = (int)currentWaveBuffer;
r1 = (int)ambebuffer_decode;

USB_DEBUG_printf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d %c%c",bitbuffer_decode[0],bitbuffer_decode[1],bitbuffer_decode[2],bitbuffer_decode[3],bitbuffer_decode[4],bitbuffer_decode[5],bitbuffer_decode[6],bitbuffer_decode[7],bitbuffer_decode[8],bitbuffer_decode[9],bitbuffer_decode[10],bitbuffer_decode[11],bitbuffer_decode[12],bitbuffer_decode[13],bitbuffer_decode[14],bitbuffer_decode[15],bitbuffer_decode[16],bitbuffer_decode[17],bitbuffer_decode[18],bitbuffer_decode[19],bitbuffer_decode[20],bitbuffer_decode[21],bitbuffer_decode[22],bitbuffer_decode[23],bitbuffer_decode[24],bitbuffer_decode[25],bitbuffer_decode[26],bitbuffer_decode[27],bitbuffer_decode[28],bitbuffer_decode[29],bitbuffer_decode[30],bitbuffer_decode[31],bitbuffer_decode[32],bitbuffer_decode[33],bitbuffer_decode[34],bitbuffer_decode[35],bitbuffer_decode[36],bitbuffer_decode[37],bitbuffer_decode[38],bitbuffer_decode[39],bitbuffer_decode[40],bitbuffer_decode[41],bitbuffer_decode[42],bitbuffer_decode[43],bitbuffer_decode[44],bitbuffer_decode[45],bitbuffer_decode[46],bitbuffer_decode[47],bitbuffer_decode[48],0x0d,0x0a);

asm volatile (
"PUSH {R4-R11}\n"
"SUB SP, SP, #0x10\n"
"STR R1, [SP, #0x08]\n"
"LDR R1, =1\n"
"STR R1, [SP, #0x04]\n"
"LDR R1, =0\n"
"STR R1, [SP, #0x00]\n"
"LDR R3, =0\n"
"LDR R1, =80\n"
"BL " QU(AMBE_DECODE)
"ADD SP, SP, #0x10\n"
"POP {R4-R11}"
);
[...]
}

If I put this in the old source code that was published here downloads/releases/MDUV380/R20230311 it works fine and in Putty I get 49 bits of the AMBE frame.
If I put this in the new source code of 12/31/2023, then as soon as a frame is received, Opengd77 freeze completely I am obliged to remove the battery and put it back on.
Tested on a DM1701 and MDUV390.
Last edited by JP7NJT on Mon Sep 02, 2024 9:49 pm, edited 3 times in total.

JP7NJT
Posts: 32
Joined: Wed Oct 18, 2023 12:44 pm

Re: Probable bug in OpenGD77

Post by JP7NJT » Mon Sep 02, 2024 9:18 pm

The second BUG is located at the reception level.

For the test I modify the emission and I emit AMBE frames only at 0 (49 bits at zero).
If I check the emission with DSD-FME, the AMBE frames emitted are all at 0.
frames.png
frames.png (32.48 KiB) Viewed 6966 times
But the reception is never correct on 3 bits, always the same: I randomly receive bits at 1 in position 37 and 33 and from time to time also on the 38 bit.
Tested on multiple DM1701s and multiple MDUV380, MDUV390. It is therefore not a hardware problem.

Example of RX:

Code: Select all

0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000001000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000100100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000100100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000010000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
To generate the null frames, i put :

void codecEncodeBlock(uint8_t *outdata_ptr)
{
asm volatile (
"PUSH {R4-R11}\n"
"SUB SP, SP, #0x14\n"
"STR R1, [SP, #0x0C]\n"
"LDR R1, =0x00002000\n"
"STR R1, [SP, #0x08]\n"
"LDR R1, =1\n"
"STR R1, [SP, #0x04]\n"
"LDR R1, =0x00000800\n"
"STR R1, [SP, #0x00]\n"
"LDR R3, =80\n"
"LDR R1, =0\n"
"BL " QU(AMBE_ENCODE)
"ADD SP, SP, #0x14\n"
"POP {R4-R11}"
);

for (int i = 0; i < 49; i++)
{
bitbuffer_encode [ i ]=0;
}


r0 = (int)bitbuffer_encode;
r1 = (int)ambebuffer_encode_ecc;

asm volatile (
"PUSH {R4-R11}\n"
"SUB SP, SP, #0x14\n"
"MOV R3, R1\n"
"LDR R2, =0\n"
"MOV R1, R0\n"
"BL " QU(AMBE_ENCODE_ECC)
"ADD SP, SP, #0x14\n"
"POP {R4-R11}"
);

VK3KYY
Posts: 8682
Joined: Sat Nov 16, 2019 3:25 am
Location: Melbourne, Australia

Re: Probable bug in OpenGD77

Post by VK3KYY » Mon Sep 02, 2024 10:57 pm

JP7NJT wrote: ↑
Mon Sep 02, 2024 9:14 pm
Hi all,

I think I found 2 bugs in opengd77. Is there a way to correct them?

The first BUG may be in the USB buffer.

In codec_interface.c

I put:

#include "usb/usb_com.h"

then in:
void codecDecode(uint8_t *indata_ptr, int numbBlocks)
{

soundSetupBuffer();// this just sets currentWaveBuffer but the compiler seems to optimise out the code if I try to do it in this file
r2 = (int)bitbuffer_decode;
r0 = (int)currentWaveBuffer;
r1 = (int)ambebuffer_decode;

USB_DEBUG_printf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d %c%c",bitbuffer_decode[0],bitbuffer_decode[1],bitbuffer_decode[2],bitbuffer_decode[3],bitbuffer_decode[4],bitbuffer_decode[5],bitbuffer_decode[6],bitbuffer_decode[7],bitbuffer_decode[8],bitbuffer_decode[9],bitbuffer_decode[10],bitbuffer_decode[11],bitbuffer_decode[12],bitbuffer_decode[13],bitbuffer_decode[14],bitbuffer_decode[15],bitbuffer_decode[16],bitbuffer_decode[17],bitbuffer_decode[18],bitbuffer_decode[19],bitbuffer_decode[20],bitbuffer_decode[21],bitbuffer_decode[22],bitbuffer_decode[23],bitbuffer_decode[24],bitbuffer_decode[25],bitbuffer_decode[26],bitbuffer_decode[27],bitbuffer_decode[28],bitbuffer_decode[29],bitbuffer_decode[30],bitbuffer_decode[31],bitbuffer_decode[32],bitbuffer_decode[33],bitbuffer_decode[34],bitbuffer_decode[35],bitbuffer_decode[36],bitbuffer_decode[37],bitbuffer_decode[38],bitbuffer_decode[39],bitbuffer_decode[40],bitbuffer_decode[41],bitbuffer_decode[42],bitbuffer_decode[43],bitbuffer_decode[44],bitbuffer_decode[45],bitbuffer_decode[46],bitbuffer_decode[47],bitbuffer_decode[48],0x0d,0x0a);

asm volatile (
"PUSH {R4-R11}\n"
"SUB SP, SP, #0x10\n"
"STR R1, [SP, #0x08]\n"
"LDR R1, =1\n"
"STR R1, [SP, #0x04]\n"
"LDR R1, =0\n"
"STR R1, [SP, #0x00]\n"
"LDR R3, =0\n"
"LDR R1, =80\n"
"BL " QU(AMBE_DECODE)
"ADD SP, SP, #0x10\n"
"POP {R4-R11}"
);
[...]
}

If I put this in the old source code that was published here downloads/releases/MDUV380/R20230311 it works fine and in Putty I get 49 bits of the AMBE frame.
If I put this in the new source code of 12/31/2023, then as soon as a frame is received, Opengd77 freeze completely I am obliged to remove the battery and put it back on.
Tested on a DM1701 and MDUV390.

Are you saying that when you added code to print to USB then the code now crashes?

The code never contained the usb debug function.

You can't simply add USB debug functions into time critical parts of the firmware and expect it to function correctly

VK3KYY
Posts: 8682
Joined: Sat Nov 16, 2019 3:25 am
Location: Melbourne, Australia

Re: Probable bug in OpenGD77

Post by VK3KYY » Mon Sep 02, 2024 11:00 pm

JP7NJT wrote: ↑
Mon Sep 02, 2024 9:18 pm
The second BUG is located at the reception level.

For the test I modify the emission and I emit AMBE frames only at 0 (49 bits at zero).
If I check the emission with DSD-FME, the AMBE frames emitted are all at 0.

frames.png

But the reception is never correct on 3 bits, always the same: I randomly receive bits at 1 in position 37 and 33 and from time to time also on the 38 bit.
Tested on multiple DM1701s and multiple MDUV380, MDUV390. It is therefore not a hardware problem.

Example of RX:

Code: Select all

0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000001000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000100100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000100100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000010000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
To generate the null frames, i put :

void codecEncodeBlock(uint8_t *outdata_ptr)
{
asm volatile (
"PUSH {R4-R11}\n"
"SUB SP, SP, #0x14\n"
"STR R1, [SP, #0x0C]\n"
"LDR R1, =0x00002000\n"
"STR R1, [SP, #0x08]\n"
"LDR R1, =1\n"
"STR R1, [SP, #0x04]\n"
"LDR R1, =0x00000800\n"
"STR R1, [SP, #0x00]\n"
"LDR R3, =80\n"
"LDR R1, =0\n"
"BL " QU(AMBE_ENCODE)
"ADD SP, SP, #0x14\n"
"POP {R4-R11}"
);

for (int i = 0; i < 49; i++)
{
bitbuffer_encode [ i ]=0;
}


r0 = (int)bitbuffer_encode;
r1 = (int)ambebuffer_encode_ecc;

asm volatile (
"PUSH {R4-R11}\n"
"SUB SP, SP, #0x14\n"
"MOV R3, R1\n"
"LDR R2, =0\n"
"MOV R1, R0\n"
"BL " QU(AMBE_ENCODE_ECC)
"ADD SP, SP, #0x14\n"
"POP {R4-R11}"
);

What is the bug in normal operation ?

I don't really understand what you are saying

I think you are saying you wrote 0x00 into the entire AMBE frame ???

I don't know an entirely 0x00 AMBE frame is valid


AMBE is handled by the binary section of the official firmware. We have no control of what this binary code does. We also can't control the internal processing of the C6000 DMR chip.

JP7NJT
Posts: 32
Joined: Wed Oct 18, 2023 12:44 pm

Re: Probable bug in OpenGD77

Post by JP7NJT » Mon Sep 02, 2024 11:16 pm

Are you saying that when you added code to print to USB then the code now crashes?

The code never contained the usb debug function.

You can't simply add USB debug functions into time critical parts of the firmware and expect it to function correctly
In this version downloads/releases/MDUV380/R20230311 I can print with the USB debug function. The frames here are printed with the debug function :
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000100000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000001000100000000000
You mean that in the latest version of 12/31/2023 you removed the debug usb function?
Last edited by JP7NJT on Mon Sep 02, 2024 11:44 pm, edited 3 times in total.

JP7NJT
Posts: 32
Joined: Wed Oct 18, 2023 12:44 pm

Re: Probable bug in OpenGD77

Post by JP7NJT » Mon Sep 02, 2024 11:23 pm

I think you are saying you wrote 0x00 into the entire AMBE frame ???

I don't know an entirely 0x00 AMBE frame is valid


AMBE is handled by the binary section of the official firmware. We have no control of what this binary code does. We also can't control the internal processing of the C6000 DMR chip.
you can send whatever you want in the AMBE frames. Zeros are just one attempt among many.

I mean that OpenGD77 modifies bits in reception when it shouldn't. If I use another opensource firmware like MD380Tools then the bits are not changed and my zeros or other things, arrive at their destination unaltered.

So OpenGD77 alters the sound on 3 bits, which is not normal.
so I mean if it's not code of yours, then the code that comes from the MD9600 for the decoding of voice frames is not 100% compatible with the DM1701, MDUV390 and others.
in your old code a few years ago (the one where you used mbelib and not the extracted code of the MD9600 firmware) there is no problem of bits being altered when receiving.
What is the bug in normal operation ?
The bug is that I lose 3 bits. if I send a fixed signal of 1000Hz (when you use a tone generator, the AMBE frames are fixed), the signal arrives at its destination altered by 3 bits randomly.

VK3KYY
Posts: 8682
Joined: Sat Nov 16, 2019 3:25 am
Location: Melbourne, Australia

Re: Probable bug in OpenGD77

Post by VK3KYY » Tue Sep 03, 2024 2:13 am

JP7NJT wrote: ↑
Mon Sep 02, 2024 11:23 pm
I think you are saying you wrote 0x00 into the entire AMBE frame ???

I don't know an entirely 0x00 AMBE frame is valid


AMBE is handled by the binary section of the official firmware. We have no control of what this binary code does. We also can't control the internal processing of the C6000 DMR chip.
you can send whatever you want in the AMBE frames. Zeros are just one attempt among many.

I mean that OpenGD77 modifies bits in reception when it shouldn't. If I use another opensource firmware like MD380Tools then the bits are not changed and my zeros or other things, arrive at their destination unaltered.

So OpenGD77 alters the sound on 3 bits, which is not normal.
so I mean if it's not code of yours, then the code that comes from the MD9600 for the decoding of voice frames is not 100% compatible with the DM1701, MDUV390 and others.
in your old code a few years ago (the one where you used mbelib and not the extracted code of the MD9600 firmware) there is no problem of bits being altered when receiving.
What is the bug in normal operation ?
The bug is that I lose 3 bits. if I send a fixed signal of 1000Hz (when you use a tone generator, the AMBE frames are fixed), the signal arrives at its destination altered by 3 bits randomly.
We never used mbelib.
We always use the codec from the TYT binaries. The all STM32 based versions use the official MD9600 firmware as the donor for the AMBE codec and all MK22 versions use the official GD77 firmware as the donor.

FYI. AFIK. AMBE is a voice only codec and is not designed to pass single frequency tones, or SSTV or music etc.
I think the TYT implementation of the AMBE standard does partially pass some tones, but this operation is not guaranteed and AFIK the AMBE3000 chips will not pass audio tones at all

What other fireware e.g. MD380Tools does is not relevant, because this is hacked firmware and may or may not use the official TYT codec, and even if it does use a version of the TYT codec, it is unlikely to be the same version of codec that TYT use in the official MD9600 firmware

AFIK. You are not using the firmware for its intended purpose, which is for voice communication. It won't work for sending tones or music or SSTV etc etc

JP7NJT
Posts: 32
Joined: Wed Oct 18, 2023 12:44 pm

Re: Probable bug in OpenGD77

Post by JP7NJT » Tue Sep 03, 2024 1:57 pm

I continued my testing and this is not a problem with the AMBE codec and it causes the problem even with voice frames or silent frames.
This is either a hardware issue with the C6000 or a problem with the initialization of the C6000. But it would be surprising if it was a hardware issue since the issue does not occur with the MD380Tools firmware.

Are there multiple ways to initialize the C6000?

Example of a silence frame that is also received with incorrect bits (always the same) at random:

1111100000000001101010011001111110001100111000010
1111100000000001101010011001111110001100111000000
1111100000000001101010011001110110001100111000000
1111100000000001101010011001111110001100111000000
1111100000000001101010011001111110001100111000001
1111100000000001101010011001111110001100111000001
1111100000000001101010011001111110001100111000001
1111100000000001101010011001111110001100111000001
1111100000000001101010011001111110001100111000000
1111100000000001101010011001110110001100111000000
1111100000000001101010011001111110001100111000000
1111100000000001101010011001111110001100111000001
1111100000000001101010011001111110001100111000100

I tested directly at the source in the HR-C6000.c file:

Code: Select all

SPI1ReadPageRegByteArray(0x03, 0x00, DMR_frame_buffer + LC_DATA_LENGTH, AMBE_AUDIO_LENGTH);

USB_DEBUG_printf("%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X%c%c",DMR_frame_buffer[0],DMR_frame_buffer[1],DMR_frame_buffer[2],DMR_frame_buffer[3],DMR_frame_buffer[4],DMR_frame_buffer[5],DMR_frame_buffer[6],DMR_frame_buffer[7],DMR_frame_buffer[8],DMR_frame_buffer[9],DMR_frame_buffer[10],DMR_frame_buffer[11],DMR_frame_buffer[12],DMR_frame_buffer[13],DMR_frame_buffer[14],DMR_frame_buffer[15],DMR_frame_buffer[16],DMR_frame_buffer[17],DMR_frame_buffer[18],DMR_frame_buffer[19],DMR_frame_buffer[20],DMR_frame_buffer[21],DMR_frame_buffer[22],DMR_frame_buffer[23],DMR_frame_buffer[24],DMR_frame_buffer[25],DMR_frame_buffer[26],0x0d,0x0a);
And here again, the silence frame is wrongly received on some bits:

000000000001000001102DADB9E881526173002A6CF9E881526173
000000000001000001102DADB9E881526173002A6F39F881526173
000000000001000001102DADB9E881526173002A6BFDEC81527173
000000000001000001102DADB9E881526173002A6F39F881526173
000000000001000001102DADB9E881526173002A6EB1E881526173
000000000001000001102DADB9E88152617B002A7EF9E881526173
000000000001000001102DADF9F881526173002A6EB1E881526173
000000000001000001102DADB9E881526173002A6CF9E881526173
000000000001000001102DADB9E881526173002A6F39F881526173
000000000001000001102DADB9E881526173002A6EF1E881526173
000000000001000001102DADB9E88152617B002A7AF9E881526173
000000000001000001102DADB9E881526173002A6AF9EC81526173
000000000001000001102DADB9E88152617B002A6BB9E881527173
000000000001000001102DADB9E881526173002A6EB1E881526173
000000000001000001102DADB9E881526173002A6CF9E881526173
000000000001000001102DADB9E881526173002A6F39F881526173
000000000001000001102DADB9E881526173002A6EF1E881526173
000000000001000001102DADB9E88152617B002A7AF9E881527173
000000000001000001102DADB9E881526173002A6F39F881527173

Do you have the possibility to reproduce this problem on your radios?

just change the AMBE frame to sending with a null frame (before the FEC):

Code: Select all

[...]
uint8_t nullframe[49]={1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,0,0,1,1,0,0,1,1,1,1,1,1,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0,0};

for (int i = 0; i < 49; i++)
{
bitbuffer_encode [ i ]=nullframe [ i ];
}

r0 = (int)bitbuffer_encode;
r1 = (int)ambebuffer_encode_ecc;

[..]

and on a second radio to display the AMBE frame received (after the FEC) :

Code: Select all

void codecDecode(uint8_t *indata_ptr, int numbBlocks)
{

soundSetupBuffer();// this just sets currentWaveBuffer but the compiler seems to optimise out the code if I try to do it in this file
r2 = (int)bitbuffer_decode;
r0 = (int)currentWaveBuffer;
r1 = (int)ambebuffer_decode;

USB_DEBUG_printf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d %c%c",bitbuffer_decode[0],bitbuffer_decode[1],bitbuffer_decode[2],bitbuffer_decode[3],bitbuffer_decode[4],bitbuffer_decode[5],bitbuffer_decode[6],bitbuffer_decode[7],bitbuffer_decode[8],bitbuffer_decode[9],bitbuffer_decode[10],bitbuffer_decode[11],bitbuffer_decode[12],bitbuffer_decode[13],bitbuffer_decode[14],bitbuffer_decode[15],bitbuffer_decode[16],bitbuffer_decode[17],bitbuffer_decode[18],bitbuffer_decode[19],bitbuffer_decode[20],bitbuffer_decode[21],bitbuffer_decode[22],bitbuffer_decode[23],bitbuffer_decode[24],bitbuffer_decode[25],bitbuffer_decode[26],bitbuffer_decode[27],bitbuffer_decode[28],bitbuffer_decode[29],bitbuffer_decode[30],bitbuffer_decode[31],bitbuffer_decode[32],bitbuffer_decode[33],bitbuffer_decode[34],bitbuffer_decode[35],bitbuffer_decode[36],bitbuffer_decode[37],bitbuffer_decode[38],bitbuffer_decode[39],bitbuffer_decode[40],bitbuffer_decode[41],bitbuffer_decode[42],bitbuffer_decode[43],bitbuffer_decode[44],bitbuffer_decode[45],bitbuffer_decode[46],bitbuffer_decode[47],bitbuffer_decode[48],0x0d,0x0a);

asm volatile (
"PUSH {R4-R11}\n"
"SUB SP, SP, #0x10\n"
"STR R1, [SP, #0x08]\n"
"LDR R1, =1\n"
"STR R1, [SP, #0x04]\n"
"LDR R1, =0\n"
"STR R1, [SP, #0x00]\n"
"LDR R3, =0\n"
"LDR R1, =80\n"
"BL " QU(AMBE_DECODE)
"ADD SP, SP, #0x10\n"
"POP {R4-R11}"
);
[...]
}

G4EML
Posts: 1056
Joined: Sat Nov 16, 2019 10:01 am

Re: Probable bug in OpenGD77

Post by G4EML » Tue Sep 03, 2024 3:37 pm

It is unlikely to be a HRC-6000 configuration issue because we are using the same initialisation data as used by the official firmware. (Captured from the original radio) .

As has been mentioned before the HRC-6000 is very poorly documented so most of what we have found has been from observing the original firmware behaviour.

However there may of course be a bug in the code somewhere that has not been found. AMBE packets are very error tolerant so occasional single bit errors will be corrected by the vocoder and not noticed.

I doubt that any of the developers has the time to try to reproduce your findings. It sounds like you are probably the person best equipped to trace further. If you do manage to find the cause it may well help the project overall.

One point mentioned previously by Roger, the USBDebug_printf function was never intended to be used in time critical parts of the code. It can slow things down a lot and may affect normal operation. Whilst it may appear to be working at the moment I would be very cautious when using it.

Colin G4EML

VK3KYY
Posts: 8682
Joined: Sat Nov 16, 2019 3:25 am
Location: Melbourne, Australia

Re: Probable bug in OpenGD77

Post by VK3KYY » Wed Sep 04, 2024 12:20 am

MD380 uses a different DMR chip. C5000 not the C6000 as used in the UV380. The initialisation of the C5000 is significantly different from the C6000, and its also possible that the C6000 has bugs that the C5000 does not and vice versa.

If you are saying that the data from the C5000 and C6000 are different, this is entirely possible, as they are different chips.


How are you transmitting the silence frames. I presume you have modified the MD380 firmware to send silence frames ?
What is your RF / audio connection between the MD380 and the UV380 ? Have you looked at the received audio signal from the AT1846S Tx/Rx chip, and decoded this using some other means e.g. DSD

Your presumption that there is a in the code presumes that the C6000 is receiving clean audio from the receiver and that your modulation is clean, or have you already verified this ?

The TRx chip used in the UV380 is totally different from the Tx Rx system in the MD380 and the Rx side of the TRx chip is known to be poor quality and also susepetable to interference both in band and out of band, and also is not tollerant of signal overloading.

Even if DSD can demodulate the signal, it does not guarantee that the C6000 can demodulate the signal.

Currently there are many places in the process where your 'silence frame' data could have errors introduced. I don't understand your presumption that this must be a bug in the firmware, when it could be a RF / AF problem

To remove the possiblity that its a RF / AF problem you would need to generate the 4FSK AF encoded signal some other way, and directly inject this into the PCB of the radio, and then adjust the modulation level and attempt to confirm whether this problem is AF/RF


You may be able to use USB Debug print, if you increase the CPU clock frequency. The CPU frequency is controlled by the clock manager code and is changed during Tx and Rx and is always significantly lower than the maximum frequency that the CPU supports.

You should also change the code to prevent the radio entering its Eco / Power saving mode, as this will change the CPU frequency to much lower.
Possibly changing the code so that the firmware leaves the CPU freq at the same it uses for Tx (in DMR mode) may be fast enough to allow USB serial to work in the location you want to view it.

If this is not fast enough you will need to change the clock settings for the entire chip. If you change the CPU clock frequency so that everything runs faster, that you need to ensure that the clock multiplier and divider frequencies provide the correct clock speed for the USB subsystem in the STM32, otherwise USB won't work. Also check the GPIO / SPI / I2C subsystem clock dividers etc to ensure you are not overclocking them if you increase the CPU core frequency.



Generally however, USB serial should not be used in sections of code which have high CPU load or are time critical.
If you have a JLink or STLink there are methods to use the SWD print functionality, however the bootloader disables SWD, so you would need to patch the and reflash the bootloader, or relocate the code to not use the bootloader at all.
Or you can use other methods