Strange problem writing flash on STM32L4xx

Comments

1 comment

  • Avatar
    Jolyon Latham

    Finally got to the bottom of this, so I'll update in-case anyone has the same problem.

    The problem was being caused by the blank DWord actually not being blank as far as the chip was concerned, I had previously written 0xFFFFFFFFFFFFFFFF to it. This fact was presumably recorded in the ECC bits and was the reason the chip would only allow me to write 0x0 to it afterwards.

     

    Fix was to check for a "blank" right in my flash library thus:

     

    BOOL flash_program_double(u32_t address, u64_t data) {
      BOOL ret = FALSE;
    
      // Don't write all FFs as this will not allow them to be cleared afterwards
      if (data == 0xFFFFFFFFFFFFFFFF) {
        return (TRUE);
      }
    
      ret = (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, address, data) == HAL_OK);
      return (ret);
    }

    0
    Comment actions Permalink

Please sign in to leave a comment.