2025-11-19 7:06 AM
Hi,
I have a toubles with a debuging my program.
I started from the begining... so I create a empty project in VSCode for this MCU (setup is CLANG only). I build the empty program. It has 702 B. Debuging is working at this point.
But after create a "data" in flash with this code:
#include <stdint.h>
#include <sys/cdefs.h>
#define TARGET_FLASH_SIZE_B (64*1024)
extern const uint8_t size_filler[TARGET_FLASH_SIZE_B];
void __attribute__((noinline)) force_data_use(void)
{
volatile const uint8_t *ptr = size_filler;
uint8_t dummy = ptr[0];
}
const uint8_t size_filler[TARGET_FLASH_SIZE_B] = {
[0] = 0xAA,
[TARGET_FLASH_SIZE_B - 1] = 0x55
};
int main(void)
{
/* Loop forever */
force_data_use();
for(;;);
}#define TARGET_FLASH_SIZE_B (63*1024)it works...
So I think there is some problem with flash size erasing / flashing. The MCU has 2 kB per page and two banks.
Here is DEBUG CONSOLE:
STMicroelectronics ST-LINK GDB server. Version 7.11.0
Copyright (c) 2025, STMicroelectronics. All rights reserved.
Starting server with the following options:
Persistent Mode : Disabled
Logging Level : 1
Listen Port Number : 61234
Status Refresh Delay : 15s
Verbose Mode : Disabled
SWD Debug : Enabled
InitWhile : Enabled
Waiting for debugger connection...
GNU gdb (GNU Tools for STM32 13.3.rel1.20250523-0900) 14.2.90.20240526-git
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
add-symbol-file "C:/<my_path>/empty/build/Debug/empty.elf"
add symbol table from file "C:/<my_path>/empty/build/Debug/empty.elf"
(y or n) [answered Y; input not from terminal]
Reading symbols from C:/<my_path>/empty/build/Debug/empty.elf...
Debugger connected
Waiting for debugger connection...
0x1fff5048 in ?? ()
connected to remote target localhost:61234
Note: automatically using hardware breakpoints for read-only addresses.
load "C:/<my_path>/empty/build/Debug/empty.elf"
Loading section .isr_vector, size 0x1d8 lma 0x8000000
Loading section .text, size 0xec lma 0x80001d8
Loading section .rodata, size 0x10000 lma 0x80002c4
Loading section .ARM, size 0x18 lma 0x80102c4
Loading section .preinit_array, size 0x4 lma 0x80102e0
-------------------------------------------------------------------
STM32CubeProgrammer v2.20.0
-------------------------------------------------------------------
3
Log output file: C:\Users\<username>\AppData\Local\Temp\STM32CubeProgrammer_a13408.log
ST-LINK SN : 50FF70067867515350350467
ST-LINK FW : V2J46S7
Board : --
Voltage : 3.44V
SWD freq : 4000 KHz
Connect mode: Under Reset
Reset mode : Hardware reset
Device ID : 0x469
Revision ID : Rev X
Device name : STM32G47x/G48x/G414
Flash size : 128 KBytes
Device type : MCU
Device CPU : Cortex-M4
BL Version : 0xD5
Debug in Low Power mode enabled
3
Opening and parsing file: ST-LINK_GDB_server_a13408.srec
2
Memory Programming ...
File : ST-LINK_GDB_server_a13408.srec
Size : 64.72 KB
Address : 0x08000000
2
Erasing memory corresponding to segment 0:
Error: Operation exceeds memory limits
2
Error: failed to erase memory
Encountered Error when opening C:/Users/<username>/AppData/Local/stm32cube/bundles/programmer/2.20.0/bin\STM32_Programmer_CLI.exe
Error in STM32CubeProgrammer
Error finishing flash operation
cube is killed by signal SIGTERM
Mass erase is working with ST-Link Utility and with STM32CubeProgrammer. So Option Bytes are OK.
I think there is a bug with flashing procedure...
2025-11-19 7:56 AM - edited 2025-11-19 7:56 AM
What is the part number of the chip you are using?
In title, missed it.
2025-11-19 7:59 AM
The chip has two 64 kB sections of contiguous flash and your project exceeds those limits. STM32CubeProgrammer will not flash portions of the memory that are not guaranteed to work correctly. You will be limited to a program size of 64 kB, or you can split the program up into two sections of up to 64 kB each, but this requires some work with the linker file.
2025-11-19 8:04 AM
Hello,
128K with two flash banks of 64K but NOT contiguous, that is the issue here.
But as you said, you can use the other 64K but you need to specify the linker with correct sections.
Rgds,
Laurent