Reprogram error after clear sector 11 of flash in runtime

Sysprogs forums Forums VisualGDB Reprogram error after clear sector 11 of flash in runtime

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #25408
    ExtSol
    Participant

    Dear Support,

     

    I try to write my FLASH driver to write my setting to FLASH memory.

    I select the sector 11 (0x080E0000 – 0x080FFFF) for storage my datas.

    Before i writing new datas to the area, the flash is need to erase the sector.

    Here is my erase function, based on ST reference manual: https://pastebin.com/dxcSr0NX

    After this function run, the VisualGDB can not reprogram the device. I get a following error while i starting debugging:

    VisualGDB is licensed to ………………….
    Error erasing flash with vFlashErase packet

     

    After this issue, the device is need to mass erase with STlinkUtility and VisualGDB can reprogram the device.

     

    VisualGDB why not erase the flash after my code?

     

    Best Regards:

    ExtSol

    #25411
    support
    Keymaster

    It is hard to say what exactly is going on, as VisualGDB uses an external tool (OpenOCD to program the FLASH memory and manage debugging), but most likely you set some FLASH attributes (e.g. sector protection) to a state that would prevent OpenOCD from reprogramming it.

    Unfortunately, we are not able to review your projects as a part of our regular product support, however we can suggest some relevant documentation:

    1. You can read about OpenOCD’s commands for managing FLASH memory on this page.
    2. You can build OpenOCD from source code and step through it as shown in this tutorial.

    Please also feel free to check on the ST’s forum. The OpenOCD’s FLASH memory driver for most of the STM32 devices was contributed by ST engineers, so they might be able to explain what is going on.

    #25414
    ExtSol
    Participant

    Dear Support,

    After your answer, i generate code with STM32CubeMx and imported to Visual Studio with VisualGDB.

    Now, the code is using the original ST engineers driver, name is HAL.

    I only call functions:

    HAL_FLASH_Unlock();
    FLASH_Erase_Sector(FLASH_SECTOR_11, VOLTAGE_RANGE_3);
    HAL_FLASH_Lock();

    in main, before loop while(1).

     

    First start of debugging is ok, when i restart the debugging, i get the some error:

    GDB Session window:

    VisualGDB is licensed to …………………….
    Error erasing flash with vFlashErase packet

    OpenOCD window:

    Open On-Chip Debugger 0.10.0 (2019-07-15) [https://github.com/sysprogs/openocd]
    Licensed under GNU GPL v2
    For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
    WARNING: interface/stlink-v2-1.cfg is deprecated, please switch to interface/stlink.cfg
    Info : auto-selecting first available session transport “hla_swd”. To override use ‘transport select <transport>’.
    Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
    Info : clock speed 2000 kHz
    Info : STLINK V2J32S7 (API v2) VID:PID 0483:3748
    Info : Target voltage: 3.243329
    Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
    Info : Listening on port 54327 for gdb connections
    Info : Unable to match requested speed 2000 kHz, using 1800 kHz
    Info : Unable to match requested speed 2000 kHz, using 1800 kHz
    target halted due to debug-request, current mode: Thread
    xPSR: 0x01000000 pc: 0x08001348 msp: 0x20020000
    Info : Unable to match requested speed 8000 kHz, using 4000 kHz
    Info : Unable to match requested speed 8000 kHz, using 4000 kHz
    VisualGDB_OpenOCD_Ready
    Info : Listening on port 6666 for tcl connections
    Info : Listening on port 54328 for telnet connections
    Info : accepting ‘gdb’ connection on tcp/54327
    Info : device id = 0x10036413
    Info : flash size = 1024 kbytes
    Info : flash size = 512 bytes
    Info : Unable to match requested speed 2000 kHz, using 1800 kHz
    Info : Unable to match requested speed 2000 kHz, using 1800 kHz
    Error: timed out while waiting for target halted
    TARGET: stm32f4x.cpu – Not halted
    Info : device id = 0x10036413
    Warn : STM32 flash size failed, probe inaccurate – assuming 1024k flash
    Info : flash size = 1024 kbytes
    Info : flash size = 512 bytes
    flash_bank_summary:0x8000000|0x100000|stm32f4x.flash
    flash_bank_summary:0x1fff7800|0x200|stm32f4x.otp
    FLASH progress reporting is now on

    Error: jtag status contains invalid mode value – communication failure
    Polling target stm32f4x.cpu failed, trying to reexamine
    Examination failed, GDB will be halted. Polling again in 100ms
    Info : Unable to match requested speed 2000 kHz, using 1800 kHz
    Info : Unable to match requested speed 2000 kHz, using 1800 kHz
    Error: mem2array: Read @ 0xe0042004, w=4, cnt=1, failed
    Error executing event examine-end on target stm32f4x.cpu:
    mem_helper.tcl:6: Error:
    in procedure ‘ocd_process_reset’
    in procedure ‘ocd_process_reset_inner’ called at file “embedded:startup.tcl”, line 214
    in procedure ‘mmw’ called at file “target/stm32f4x.cfg”, line 79
    in procedure ‘mrw’ called at file “mem_helper.tcl”, line 36
    at file “mem_helper.tcl”, line 6
    Error executing event gdb-flash-erase-start on target stm32f4x.cpu:

    Info : Erasing FLASH: 0x08000000-0x08004000…
    Error: Target not halted
    Error: failed erasing sectors 0 to 0
    Error: flash_erase returned -304
    Info : Previous state query failed, trying to reconnect
    target halted due to debug-request, current mode: Thread
    xPSR: 0x01000000 pc: 0x08001348 msp: 0x20020000
    Polling target stm32f4x.cpu failed, trying to reexamine
    Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints

     

     

    #25415
    support
    Keymaster

    As mentioned above, this looks like an incompatibility between the OpenOCD FLASH driver and the custom FLASH programming code you are using.

    As both of those components are external to VisualGDB, unfortunately is it not covered by our product support. Please consider contacting ST support for further help on this.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.