STM32 flashes after flashing code without R / W protection

I have experience using the StdPeriph libraries for stm32 programming. But now I tried STM32Cube HAL with the STM32CubeMX code generator. I created a project with the following parameters:

  • Middleware: FreeRTOS and FatFS via SDIO
  • The compiler is GCC
  • stm32f103ret6 MCU

I imported the generated code into an Eclipse environment. I made binary code and flashed it using "st-flash write ...", as usual. My test program successfully wrote "Hello" to USART1 in a loop - this is not a problem. But then, when I tried to flash another code, it failed with an “unknown id chip”. If I manually connect NRST to GND, st-flash gives:

...Flash: 0 bytes (0 KiB) in pages of 2048 bytes

Full conclusion:

2015-06-14T16:07:29 INFO src/stlink-common.c: Loading device parameters....
2015-06-14T16:07:29 INFO src/stlink-common.c: Device connected is: F1 High-density device, id 0x10036414
2015-06-14T16:07:29 INFO src/stlink-common.c: SRAM size: 0x10000 bytes (64 KiB), Flash: 0 bytes (0 KiB) in pages of 2048 bytes

ST-Link Windows, MCU ( stm32). USART1, .

, , , . 2 MCU, .

MCU - ?

+4
3

JTAG/SWD (, SYS_JTDI, SYS_JTDO-TRACESWO ..) STM32CubeMX, JTAG/SWD.

+3

!

HAL, STM32CubeMX:

void HAL_MspInit(void)
{
  /* USER CODE BEGIN MspInit 0 */

  /* USER CODE END MspInit 0 */

  __HAL_RCC_AFIO_CLK_ENABLE();

  HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);

  /* System interrupt init*/
/* SysTick_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

    /**DISABLE: JTAG-DP Disabled and SW-DP Disabled 
    */
  __HAL_AFIO_REMAP_SWJ_DISABLE();

  /* USER CODE BEGIN MspInit 1 */

  /* USER CODE END MspInit 1 */
}

!

/**DISABLE: JTAG-DP Disabled and SW-DP Disabled 
*/
__HAL_AFIO_REMAP_SWJ_DISABLE();

SWD JTAG, stm321xx_hal_gpio_ex.h:

#define __HAL_AFIO_REMAP_SWJ_DISABLE()  MODIFY_REG(AFIO->MAPR, AFIO_MAPR_SWJ_CFG, AFIO_MAPR_SWJ_CFG_DISABLE) 

CubeMX , / SWD/JTAG, ! STM32CubeMX!

+4

He (BURIED) under the conclusion | Sys | Debugging STM32CubeMX ... installed on Serial Wire or something else.

0
source

All Articles