2023-10-24 11:51 PM
Hello,
I wanted to put some complicated calculation into CCM SRAM in my STM32G474RE MCU. I basically followed instructions of AN4296, unfortunately I found an issue when programming the MCU.
A few attaches as below:
1. The link script
2. The code change
3. The error reported
The updated code can compile and link successfully, but I just report an error when click "Download and Debug" button
4. The map file
As the map file indicated, the link successfully put the function into CCM SRAM.
Any help would be greatly appreciated.
Thanks
Solved! Go to Solution.
2023-10-26 12:37 PM
2023-10-25 06:32 AM
Hello @YWang.15
It seems there is an issue linked to generation of flash loader input. Are you executing interrupt handler?
It is possible that the issue is linked to data structure being defined SUD_t.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-10-25 07:24 PM
The code is not executed in interrupt handler. Code snippet for SUD and its instance as below
SUD_Info_t SUD_Info = {
.shunt_resistor = 0.01f,
.vbus = 24.0f,
};
SUD_Data_t SUD_Data =
{
.state_machine = SUD_SM_IDLE,
.status = 0,
};
SUD_t const SUD_Instance = {
.info = &SUD_Info,
.data = &SUD_Data,
};
typedef struct str_SUD_t{
SUD_Info_t *info;
SUD_Data_t *data;
}SUD_t;
Is it caused by the "SUD_Instance"? since it is a constant variable that shall be initialized(copied)to CCM SRAM as well?
2023-10-25 10:34 PM
Hi,
Just a thought here:-
If your CPU is anything like the F407 (it looks like your CPU is in the same family), then code can't run from the CCM - the CCM is only connected to the Data databus (as in can only access the CCM as a data address - not an execution address)..
Just a thought...
Tone
2023-10-25 11:27 PM - edited 2023-10-25 11:29 PM
From the error message it looks like the IAR debugger tries to "flash" the stuff in the .ccmram section. Of course this won't work. Data and code in internal RAMs should be placed in the flash image and initialized by the app startup by copying from the flash image.
Your link script contains "initialize by copy {readwrite, section .cmram}" - but this does not have the desired effect. Check the IAR fine manual for correct syntax?
2023-10-26 12:37 PM
2023-10-27 04:11 PM
The icf file in that example looks same as in the OP (what concerns the ccmram)
2023-10-30 02:49 AM
Indeed, it works as mentioned in the application note. .ccmram section should be initialized by copy at startup since the code is located in an internal CCM SRAM.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-10-30 07:05 PM
Hi All,
I am sorry I was OOO last couple of days. I tried the code from F.Belaid. It worked well with my nucleoG4 board. I even did some further modifications, and it still worked as expected. This means that there must be something wrong with my previous code. I need to set back and review that code again.
typedef struct {
uint32_t time;
GPIO_TypeDef *port;
uint16_t pin;
}toggle_info_t;
const toggle_info_t player = {
.time = 200u,
.port = LD2_GPIO_Port,
.pin = LD2_Pin,
};
#pragma location=".ccmram"
void toggle_led(toggle_info_t const *t)
{
HAL_GPIO_TogglePin(t->port, t->pin);
HAL_Delay(t->time);
}