Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flash erase command can't suport STM32H7 #26

Open
JesseLliang opened this issue Jul 26, 2021 · 1 comment
Open

flash erase command can't suport STM32H7 #26

JesseLliang opened this issue Jul 26, 2021 · 1 comment

Comments

@JesseLliang
Copy link

As title,when I use flash erase command on STM32H745, it deosn't work as all

@Rotule666
Copy link

Rotule666 commented Jul 26, 2021

For STM32H7 I have changed the erase flash with the following , notive that I keep one full sector in bank 1 for the bootloader

/* Erase flash ---------------------------------------------------------------*/
uint8_t btld_EraseFlash(void) {
	uint32_t SectorError = 0;
	FLASH_EraseInitTypeDef pEraseInit;
	HAL_StatusTypeDef status = HAL_OK;

	HAL_FLASH_Unlock();

	if (status == HAL_OK) {

		// Bank 0
		pEraseInit.Banks = FLASH_BANK_1;
		pEraseInit.Sector = 1;
		pEraseInit.NbSectors = 7;
		pEraseInit.TypeErase = FLASH_TYPEERASE_SECTORS;
		pEraseInit.VoltageRange = FLASH_VOLTAGE_RANGE_3;

		status = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);

		// Bank1
		pEraseInit.Banks = FLASH_BANK_2;
		pEraseInit.Sector = 0;
		pEraseInit.NbSectors = 8;
		pEraseInit.TypeErase = FLASH_TYPEERASE_SECTORS;
		pEraseInit.VoltageRange = FLASH_VOLTAGE_RANGE_3;

		status = HAL_FLASHEx_Erase(&pEraseInit, &SectorError);
	}

	HAL_FLASH_Lock();

	return (status == HAL_OK) ? BL_OK : BL_ERASE_ERROR;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants