Failed to erase sectors 0 @ address 0x00000000 ((erase error)) of RA6M1

Hello,

I'm currently facing a problem regarding the erase-part of my flash process. An older version of my code (with the same Debug configuration/ Makefile etc...)used to work perfectly fine. After working on my USB peripheral I noticed that neither the current state, nor the older state of my code, flashes properly anymore. When Debuggin/Flashing the Device i get the following output:

SEGGER J-Link GDB Server V7.94j Command Line Version

JLinkARM.dll V7.94j (DLL compiled Feb 14 2024 15:36:06)

Command line: -if swd -device R7FA6M1AD -endian little -speed auto -port 2331 -swoport 2332 -telnetport 2333 -vd -ir -localhostonly 1 -singlerun -strict -timeout 0 -nogui
-----GDB Server start settings-----
GDBInit file:                  none
GDB Server Listening port:     2331
SWO raw output listening port: 2332
Terminal I/O port:             2333
Accept remote connection:      localhost only
Generate logfile:              off
Verify download:               on
Init regs on start:            on
Silent mode:                   off
Single run mode:               on
Target connection timeout:     0 ms
------J-Link related settings------
J-Link Host interface:         USB
J-Link script:                 none
J-Link settings file:          none
------Target related settings------
Target device:                 R7FA6M1AD
Target device parameters:      none
Target interface:              SWD
Target interface speed:        auto
Target endian:                 little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link OB-S124 compiled Dec 13 2023 14:39:54
Hardware: V1.00
S/N: 831729554
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target...
Initializing CPU registers...Connected to target
Waiting for GDB connection...Connected to 0000:0000:0000:0000:0000:0000:0000:0001
GDB client (conn. 956) requested target.xml from GDB Server
Reading common registers: Read register 'r0' (4 bytes) from hardware: 0x00000000
Read register 'r1' (4 bytes) from hardware: 0x00000000
Read register 'r2' (4 bytes) from hardware: 0x00000000
Read register 'r3' (4 bytes) from hardware: 0x00000000
Read register 'r4' (4 bytes) from hardware: 0x00000000
Read register 'r5' (4 bytes) from hardware: 0x00000000
Read register 'r6' (4 bytes) from hardware: 0x00000000
Read register 'r7' (4 bytes) from hardware: 0x00000000
Read register 'r8' (4 bytes) from hardware: 0x00000000
Read register 'r9' (4 bytes) from hardware: 0x00000000
Read register 'r10' (4 bytes) from hardware: 0x00000000
Read register 'r11' (4 bytes) from hardware: 0x00000000
Read register 'r12' (4 bytes) from hardware: 0x00000000
Read register 'sp' (4 bytes) from hardware: 0x00000000
Read register 'lr' (4 bytes) from hardware: 0x00000000
Read register 'pc' (4 bytes) from hardware: 0x00000000
Read register 'xpsr' (4 bytes) from hardware: 0x00000001
Read 4 bytes @ address 0x00000000 (Data = 0x1FFE3580)
Read 2 bytes @ address 0x00000000 (Data = 0x3580)
Received monitor command: speed 1000
Target interface speed set to 1000 kHz
Received monitor command: clrbp
Received monitor command: reset
Resetting target
Received monitor command: halt
Halting target CPU...
...Target halted (PC = 0x000005B4)
Received monitor command: regs
R0 = 1FFE3578, R1 = 0000FFC3, R2 = 00000000, R3 = 4001C11C
R4 = 1FFE0904, R5 = 1FFE0924, R6 = 1FFE0924, R7 = 1FFE3578
R8 = 3CD9DB0A, R9 = 97383CD9, R10= 829F9F7C, R11= 2AFEB3C2
R12= 1FFE0888, R13= 1FFE3580, MSP= 1FFE3580, PSP= AA621784
R14(LR) = FFFFFFFF, R15(PC) = 000005B4
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00

Security extension regs:
MSP_S  = 00000000, MSPLIM_S  = 00000000
PSP_S  = 00000000, PSPLIM_S  = 00000000
MSP_NS = 1FFE3580, MSPLIM_NS = 00000000
PSP_NS = AA621784, PSPLIM_NS = 00000000
CONTROL_S  00, FAULTMASK_S  00, BASEPRI_S  00, PRIMASK_S  00
CONTROL_NS 00, FAULTMASK_NS 00, BASEPRI_NS 00, PRIMASK_NS 00

Reading common registers: Read register 'r0' (4 bytes) from hardware: 0x7835FE1F
Read register 'r1' (4 bytes) from hardware: 0xC3FF0000
Read register 'r2' (4 bytes) from hardware: 0x00000000
Read register 'r3' (4 bytes) from hardware: 0x1CC10140
Read register 'r4' (4 bytes) from hardware: 0x0409FE1F
Read register 'r5' (4 bytes) from hardware: 0x2409FE1F
Read register 'r6' (4 bytes) from hardware: 0x2409FE1F
Read register 'r7' (4 bytes) from hardware: 0x7835FE1F
Read register 'r8' (4 bytes) from hardware: 0x0ADBD93C
Read register 'r9' (4 bytes) from hardware: 0xD93C3897
Read register 'r10' (4 bytes) from hardware: 0x7C9F9F82
Read register 'r11' (4 bytes) from hardware: 0xC2B3FE2A
Read register 'r12' (4 bytes) from hardware: 0x8808FE1F
Read register 'sp' (4 bytes) from hardware: 0x8035FE1F
Read register 'lr' (4 bytes) from hardware: 0xFFFFFFFF
Read register 'pc' (4 bytes) from hardware: 0xB4050000
Read register 'xpsr' (4 bytes) from hardware: 0x00000001
Received monitor command: speed auto
Select auto target interface speed (2000 kHz)
Received monitor command: flash breakpoints 1
Flash breakpoints enabled
Received monitor command: semihosting enable
Semi-hosting enabled (Handle on breakpoint instruction hit)
Received monitor command: semihosting IOClient 1
Semihosting I/O set to TELNET Client
Received monitor command: SWO DisableTarget 0xFFFFFFFF
SWO disabled successfully.
Received monitor command: SWO EnableTarget 0 0 0x1 0
SWO enabled successfully.
Read 4 bytes @ address 0x000005B4 (Data = 0xAF00B580)
Downloading 16112 bytes @ address 0x00000000 - Verified OK
Downloading 7672 bytes @ address 0x00003EF0 - Verified OK
Downloading 8 bytes @ address 0x00005CE8 - Verified OK
Downloading 1128 bytes @ address 0x00005CF0 - Verified OK
Writing register 'pc' = 0x0000385C
Comparing flash   [....................] Done.
Erasing flash     [....................] Done.
ERROR: Failed to erase sectors 0 @ address 0x00000000 ((erase error))
Failed to erase sectors.

Read 4 bytes @ address 0x0000385C (Data = 0x37084618)
Reading 64 bytes @ address 0x00000800
Read 2 bytes @ address 0x0000081C (Data = 0xF3C2)
Reading 64 bytes @ address 0x00003840
Read 2 bytes @ address 0x00003864 (Data = 0xB480)
Reading 64 bytes @ address 0x00000580
Read 2 bytes @ address 0x000005B8 (Data = 0xF000)
Read 2 bytes @ address 0x000005E4 (Data = 0xFA5F)
Read 2 bytes @ address 0x0000081C (Data = 0xF3C2)
Read 2 bytes @ address 0x000005E0 (Data = 0xF867)
Received monitor command: clrbp
Received monitor command: reset
Resetting target
Received monitor command: halt
Halting target CPU...
...Target halted (PC = 0x000005B4)
Read 2 bytes @ address 0x000005B8 (Data = 0xF000)
Received monitor command: regs
R0 = 00000000, R1 = 0000FFC3, R2 = 00000000, R3 = 4001C11C
R4 = 1FFE0904, R5 = 1FFE0924, R6 = 1FFE0924, R7 = 1FFE3578
R8 = 3CD9DB0A, R9 = 97383CD9, R10= 829F9F7C, R11= 2AFEB3C2
R12= 1FFE0888, R13= 1FFE3580, MSP= 1FFE3580, PSP= AA621784
R14(LR) = FFFFFFFF, R15(PC) = 000005B4
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00

Security extension regs:
MSP_S  = 00000000, MSPLIM_S  = 00000000
PSP_S  = 00000000, PSPLIM_S  = 00000000
MSP_NS = 1FFE3580, MSPLIM_NS = 00000000
PSP_NS = AA621784, PSPLIM_NS = 00000000
CONTROL_S  00, FAULTMASK_S  00, BASEPRI_S  00, PRIMASK_S  00
CONTROL_NS 00, FAULTMASK_NS 00, BASEPRI_NS 00, PRIMASK_NS 00

Reading common registers: Read register 'r0' (4 bytes) from hardware: 0x00000000
Read register 'r1' (4 bytes) from hardware: 0xC3FF0000
Read register 'r2' (4 bytes) from hardware: 0x00000000
Read register 'r3' (4 bytes) from hardware: 0x1CC10140
Read register 'r4' (4 bytes) from hardware: 0x0409FE1F
Read register 'r5' (4 bytes) from hardware: 0x2409FE1F
Read register 'r6' (4 bytes) from hardware: 0x2409FE1F
Read register 'r7' (4 bytes) from hardware: 0x7835FE1F
Read register 'r8' (4 bytes) from hardware: 0x0ADBD93C
Read register 'r9' (4 bytes) from hardware: 0xD93C3897
Read register 'r10' (4 bytes) from hardware: 0x7C9F9F82
Read register 'r11' (4 bytes) from hardware: 0xC2B3FE2A
Read register 'r12' (4 bytes) from hardware: 0x8808FE1F
Read register 'sp' (4 bytes) from hardware: 0x8035FE1F
Read register 'lr' (4 bytes) from hardware: 0xFFFFFFFF
Read register 'pc' (4 bytes) from hardware: 0xB4050000
Read register 'xpsr' (4 bytes) from hardware: 0x00000001
Setting breakpoint @ address 0x000005B8, Kind = 2, Type = THUMB, BPHandle = 0x0001
Setting breakpoint @ address 0x000005E0, Kind = 2, Type = THUMB, BPHandle = 0x0002
Setting breakpoint @ address 0x000005E4, Kind = 2, Type = THUMB, BPHandle = 0x0003
Setting breakpoint @ address 0x0000081C, Kind = 2, Type = THUMB, BPHandle = 0x0004
Setting breakpoint @ address 0x00003864, Kind = 2, Type = THUMB, BPHandle = 0x0005
Starting target CPU...
...Breakpoint (set by 'GDB') reached @ address 0x000005B8
Reading common registers: Read register 'r0' (4 bytes) from hardware: 0x00000000
Read register 'r1' (4 bytes) from hardware: 0xC3FF0000
Read register 'r2' (4 bytes) from hardware: 0x00000000
Read register 'r3' (4 bytes) from hardware: 0x1CC10140
Read register 'r4' (4 bytes) from hardware: 0x0409FE1F
Read register 'r5' (4 bytes) from hardware: 0x2409FE1F
Read register 'r6' (4 bytes) from hardware: 0x2409FE1F
Read register 'r7' (4 bytes) from hardware: 0x7835FE1F
Read register 'r8' (4 bytes) from hardware: 0x0ADBD93C
Read register 'r9' (4 bytes) from hardware: 0xD93C3897
Read register 'r10' (4 bytes) from hardware: 0x7C9F9F82
Read register 'r11' (4 bytes) from hardware: 0xC2B3FE2A
Read register 'r12' (4 bytes) from hardware: 0x8808FE1F
Read register 'sp' (4 bytes) from hardware: 0x7835FE1F
Read register 'lr' (4 bytes) from hardware: 0xFFFFFFFF
Read register 'pc' (4 bytes) from hardware: 0xB8050000
Read register 'xpsr' (4 bytes) from hardware: 0x00000001
Removing breakpoint @ address 0x000005B8, Size = 2
Removing breakpoint @ address 0x000005E0, Size = 2
Removing breakpoint @ address 0x000005E4, Size = 2
Removing breakpoint @ address 0x0000081C, Size = 2
Removing breakpoint @ address 0x00003864, Size = 2
Read 4 bytes @ address 0x000005B8 (Data = 0xF80AF000)
Reading 64 bytes @ address 0x00000000
Reading 64 bytes @ address 0x00000040
Reading 64 bytes @ address 0x00000580
Reading 64 bytes @ address 0x000005C0
Reading 64 bytes @ address 0x00000600
Reading 64 bytes @ address 0x00000640

The Debugger opens up and allows me to step through code, but softwarechanges dont apply(I assume since erasing doesnt work). I also get problems with stepping through my code, I land in random spots of my application. I'm not properly going through startup-code and Jump into my main.c. Even Breakpoints do not work properly.

I already tried out swapping to another EK-RA6M1 Board and J-Link.

Anyone might have an Idea?