Build for C7000 based radio

New users must post here first and let us know a little bit about yourself.
R3MDG
Posts: 27
Joined: Tue Jun 11, 2024 3:07 pm

Re: Build for C7000 based radio

Post by R3MDG » Mon Jun 02, 2025 1:20 am

Thank you, the vocoder code has fixed addresses, when the firmware is launched it transfers this code from flash to IRAM, since the code works faster there, I realized that I need to deal with the linker script and do something like this:

Code: Select all

    .init_array :
    {
    . = ABSOLUTE(0x17000) ;
    *(.codec_bin_section_1)
    KEEP (*(.init_array*))
    . = ALIGN(0x4) ;
    } > REGION_TEXTINRAM
and already in the source code add:

Code: Select all

__attribute__((section(".init_array"))) uint8_t Codec[15000];
something like this

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

Re: Build for C7000 based radio

Post by VK3KYY » Mon Jun 02, 2025 4:25 am

R3MDG wrote: ↑
Mon Jun 02, 2025 1:20 am
Thank you, the vocoder code has fixed addresses, when the firmware is launched it transfers this code from flash to IRAM, since the code works faster there, I realized that I need to deal with the linker script and do something like this:

Code: Select all

    .init_array :
    {
    . = ABSOLUTE(0x17000) ;
    *(.codec_bin_section_1)
    KEEP (*(.init_array*))
    . = ALIGN(0x4) ;
    } > REGION_TEXTINRAM
and already in the source code add:

Code: Select all

__attribute__((section(".init_array"))) uint8_t Codec[15000];
something like this
So... Do you still have a problem with the codec using RAM that is used by compiler variables etc?

R3MDG
Posts: 27
Joined: Tue Jun 11, 2024 3:07 pm

Re: Build for C7000 based radio

Post by R3MDG » Mon Jun 02, 2025 11:04 am

at the moment i am ready for trial tests, i have one question about stack, stack frame needs to be prepared?

Code: Select all

	asm volatile (
			"push r4-r11\n"
			"subi sp, sp, 0x14\n"
			"stw r1, (sp, 0x0C)\n"
			"movi r1, 0x00002000\n"
			"stw r1, (sp, 0x08)\n"
			"movi r1, 1\n"
			"stw r1, (sp, 0x04)\n"
			"movi r1, 0x00000800\n"
			"stw r1, (sp, 0x00)\n"
			"movi r3, 0x50\n"
			"movi r1, 0\n"
			"jsri " QU(AMBE_ENCODE)
			"addi sp, sp, 0x14\n"
			"pop r4-r11"
		);

EA3ITA
Posts: 3
Joined: Tue Oct 10, 2023 7:30 pm

Re: Build for C7000 based radio

Post by EA3ITA » Mon Jun 02, 2025 3:36 pm

Hi! Is the source code available for the 008?

I'd be willing to help if I can download the repo and compile it as is one of the radios that I own

R3MDG
Posts: 27
Joined: Tue Jun 11, 2024 3:07 pm

Re: Build for C7000 based radio

Post by R3MDG » Mon Jun 02, 2025 3:52 pm

Hi, in addition to the source code, I also need an IDE, the native one uses a very old version of GCC 6.3.0, I had to rebuild 13.0 now I will compile everything and send it

EA3ITA
Posts: 3
Joined: Tue Oct 10, 2023 7:30 pm

Re: Build for C7000 based radio

Post by EA3ITA » Mon Jun 02, 2025 4:01 pm

I guess you use the CDS workbench? Otherwise maybe we can set up a github and explain all the steps to compile the code. As I said I'm willing to join and as more people join, the easier would be to get a working version for this.

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

Re: Build for C7000 based radio

Post by VK3KYY » Mon Jun 02, 2025 8:54 pm

R3MDG wrote: ↑
Mon Jun 02, 2025 11:04 am
at the moment i am ready for trial tests, i have one question about stack, stack frame needs to be prepared?

Code: Select all

	asm volatile (
			"push r4-r11\n"
			"subi sp, sp, 0x14\n"
			"stw r1, (sp, 0x0C)\n"
			"movi r1, 0x00002000\n"
			"stw r1, (sp, 0x08)\n"
			"movi r1, 1\n"
			"stw r1, (sp, 0x04)\n"
			"movi r1, 0x00000800\n"
			"stw r1, (sp, 0x00)\n"
			"movi r3, 0x50\n"
			"movi r1, 0\n"
			"jsri " QU(AMBE_ENCODE)
			"addi sp, sp, 0x14\n"
			"pop r4-r11"
		);
This assembler code calls the function and passes a pointer to a buffer, and probably some other parameters

Someone posted a pure C version of this to the forum, but we did not use it because I think it caused the code size to increase

However you should probably use the C version, because this would be easier than porting the ARM code to CSky

R3MDG
Posts: 27
Joined: Tue Jun 11, 2024 3:07 pm

Re: Build for C7000 based radio

Post by R3MDG » Tue Jun 03, 2025 2:16 am

EA3ITA wrote: ↑
Mon Jun 02, 2025 4:01 pm
I guess you use the CDS workbench? Otherwise maybe we can set up a github and explain all the steps to compile the code. As I said I'm willing to join and as more people join, the easier would be to get a working version for this.
IDE CDS latest version: https://drive.google.com/file/d/1twAQ-W ... sp=sharing

toolchain gcc 13.3.0 overwrite MinGW folder: https://drive.google.com/file/d/1tljmQ4 ... sp=sharing

R3MDG
Posts: 27
Joined: Tue Jun 11, 2024 3:07 pm

Re: Build for C7000 based radio

Post by R3MDG » Tue Jun 03, 2025 2:19 am

VK3KYY wrote: ↑
Mon Jun 02, 2025 8:54 pm
R3MDG wrote: ↑
Mon Jun 02, 2025 11:04 am
at the moment i am ready for trial tests, i have one question about stack, stack frame needs to be prepared?

Code: Select all

	asm volatile (
			"push r4-r11\n"
			"subi sp, sp, 0x14\n"
			"stw r1, (sp, 0x0C)\n"
			"movi r1, 0x00002000\n"
			"stw r1, (sp, 0x08)\n"
			"movi r1, 1\n"
			"stw r1, (sp, 0x04)\n"
			"movi r1, 0x00000800\n"
			"stw r1, (sp, 0x00)\n"
			"movi r3, 0x50\n"
			"movi r1, 0\n"
			"jsri " QU(AMBE_ENCODE)
			"addi sp, sp, 0x14\n"
			"pop r4-r11"
		);
This assembler code calls the function and passes a pointer to a buffer, and probably some other parameters

Someone posted a pure C version of this to the forum, but we did not use it because I think it caused the code size to increase

However you should probably use the C version, because this would be easier than porting the ARM code to CSky
this is already code for C-SKY, it just often uses the stack to store variables and you may have to make a copy of the stack

R3MDG
Posts: 27
Joined: Tue Jun 11, 2024 3:07 pm

Re: Build for C7000 based radio

Post by R3MDG » Tue Jun 03, 2025 2:32 am

EA3ITA wrote: ↑
Mon Jun 02, 2025 4:01 pm
I guess you use the CDS workbench? Otherwise maybe we can set up a github and explain all the steps to compile the code. As I said I'm willing to join and as more people join, the easier would be to get a working version for this.
The full source code of the project, to make it clearer, all comments like //*** or /*** are only mine, so as not to confuse with the author's
for example how it was and how I did it:

Code: Select all

void HRC7000InitDTMF(void)
{
/***	SPI0WritePageRegByteExtended(0x01, 0x11B, 0x05);				//configure 697 Hz tone
	SPI0WritePageRegByteExtended(0x01, 0x11A, 0x93);				//
	SPI0WritePageRegByteExtended(0x01, 0x11D, 0x06);				//configure 770 Hz tone
	SPI0WritePageRegByteExtended(0x01, 0x11C, 0x29);				//
	SPI0WritePageRegByteExtended(0x01, 0x11F, 0x06);				//configure 852 Hz tone
	SPI0WritePageRegByteExtended(0x01, 0x11E, 0xD1);				//
	SPI0WritePageRegByteExtended(0x01, 0x121, 0x07);				//configure 941 Hz tone
	SPI0WritePageRegByteExtended(0x01, 0x120, 0x87);				//

	SPI0WritePageRegByteExtended(0x01, 0x123, 0x09);				//configure 1209 Hz tone
	SPI0WritePageRegByteExtended(0x01, 0x122, 0xAC);				//
	SPI0WritePageRegByteExtended(0x01, 0x125, 0x0A);				//configure 1336 Hz tone
	SPI0WritePageRegByteExtended(0x01, 0x124, 0xB0);				//
	SPI0WritePageRegByteExtended(0x01, 0x127, 0x0B);				//configure 1447 Hz tone
	SPI0WritePageRegByteExtended(0x01, 0x126, 0xD1);				//
	SPI0WritePageRegByteExtended(0x01, 0x129, 0x0D);				//configure 1633 Hz tone
	SPI0WritePageRegByteExtended(0x01, 0x128, 0x10);				//
***/
	*FM_TONE1 = 0x05930629;
	*FM_TONE2 = 0x06D10787;
	*FM_TONE3 = 0x09AC0AB0;
	*FM_TONE4 = 0x0BD10D10;
}
or:

Code: Select all

void radioPowerOn(void)
{
	//Turn off Tx Voltages to prevent transmission.
//***	HAL_GPIO_WritePin(PA_EN_1_GPIO_Port, PA_EN_1_Pin, GPIO_PIN_RESET);
//***	HAL_GPIO_WritePin(PA_EN_2_GPIO_Port, PA_EN_2_Pin, GPIO_PIN_RESET);
	GPIO_DRV_SetOutput( PA_SEL_VHF, 0);
	GPIO_DRV_SetOutput( PA_SEL_UHF, 0);
	GPIO_DRV_SetOutput( PA_SEL_SW, 0);

	//Turn on all receiver voltages. (thats what the TYT firmware does, both receivers are on together)

	radioSetRxLNAForDevice(currentRadioDeviceId);

//****	HAL_GPIO_WritePin(C6000_PWD_GPIO_Port, C6000_PWD_Pin, GPIO_PIN_RESET);// Power On the C6000

	//Turn on the Microphone power
//***	HAL_GPIO_WritePin(MICPWR_SW_GPIO_Port, MICPWR_SW_Pin, GPIO_PIN_SET);
}
https://drive.google.com/file/d/1pvdw26 ... sp=sharing

in fact, the C6000 and C7000 are very similar, the only difference is that the C7000 has direct addressing to registers and buffers, and not through SPI and I2S like the C6000