cancel
Showing results for 
Search instead for 
Did you mean: 

Touchgfx and external flash with quadspi

SGasp.1
Senior

Hi guys... I am trying to udpate an external flash during the booting process. We already developed an external loader which is working fine when we use it with stm32cube programmer. I developed a code for loading a file from a usb key and calling a routine which is already present in the external loader for writing the external flash. The poin is that I am able to write in the external flash but the pictures a bit wrong. You can see them in the attachments... Whst colud be wrong ? you can also find the .hex file that I am parsing.. Any idea or help ? thanks a lot ..

I The external flash memory map is shown in the attachments... I discovered that I am able to write correctly only the first 16 Sectors... then I start to see differences in the memory that I expect...

uint8_t CSP_QSPI_WriteMemory(uint8_t* buffer, uint32_t address,uint32_t buffer_size) {
 
	QSPI_CommandTypeDef sCommand;
	uint32_t end_addr, current_size, current_addr;
 
 
	current_addr = 0;
 
 
	//
	while (current_addr <= address) {
		current_addr += MEMORY_PAGE_SIZE;
	}
	current_size = current_addr - address;
 
	if (current_size > buffer_size) {
		current_size = buffer_size;
	}
 
 
	current_addr = address;
	end_addr = address + buffer_size;
 
	sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
	sCommand.AddressSize = QSPI_ADDRESS_24_BITS;
	sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
	sCommand.DdrMode = QSPI_DDR_MODE_DISABLE;
	sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
	sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
	sCommand.Instruction = QUAD_IN_FAST_PROG_CMD;
	sCommand.AddressMode = QSPI_ADDRESS_1_LINE;//QSPI_ADDRESS_4_LINES;
	sCommand.DataMode = QSPI_DATA_4_LINES;//QSPI_DATA_4_LINES;
	sCommand.NbData = buffer_size;
	sCommand.Address = address;
	sCommand.DummyCycles = 0;
 
 
 
	do {
		sCommand.Address = current_addr;
		sCommand.NbData = current_size;
 
		if (current_size == 0) {
			return HAL_OK;
		}
 
 
		if (QSPI_WriteEnable() != HAL_OK) {
			return HAL_ERROR;
		}
 
 
		if (HAL_QSPI_Command(&hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE)
				!= HAL_OK) {
 
			return HAL_ERROR;
		}
 
 
		if (HAL_QSPI_Transmit(&hqspi, buffer, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
 
			return HAL_ERROR;
		}
 
 
		if (QSPI_AutoPollingMemReady() != HAL_OK) {
			return HAL_ERROR;
		}
 
		current_addr += current_size;
		buffer += current_size;
		current_size =
				((current_addr + MEMORY_PAGE_SIZE) > end_addr) ?
						(end_addr - current_addr) : MEMORY_PAGE_SIZE;
	} while (current_addr <= end_addr);
 
	return HAL_OK;
 
}

0 REPLIES 0