port stm32 write to flash for esp...

Yuriy_m
Posts: 9
Joined: Tue Apr 19, 2022 8:38 am

port stm32 write to flash for esp...

Postby Yuriy_m » Tue Jan 24, 2023 10:39 am

sorry for my English. there is a piece of code that works for me to write directly to the stm32 flash. I need to transfer to esp32 without changing the addressing. How to do it. I can't solve it for the second week.

Code: Select all

void write_block(u16 number)                                                  //Запись в FLASH
{ 
	u16 temp,wait_write,appoint_address;
	if(number<17)			                                                          //10 блоков должны быть записаны в параметр
	{
		FLASH_Unlock();		                                                         //
		FLASH_ErasePage(PARAM_RAM_ADDR+number*0x800);                                 //Стереть часть данных занимает 2K
		for(temp=0;temp<1024;temp++)	                                             //Операция для 16 бит, только в 1024 раза завершена работа программы
		{
			appoint_address=PARAM_RAM_ADDR+number*0x800+temp*2;                       //Стартовый адрес плюс адрес блока плюс малый адрес блока равны целевой позиции
			wait_write=prog_write_buffer[temp*2]+prog_write_buffer[temp*2+1]*0X100;   //Запись 16 бит на вспышку
			FLASH_ProgramHalfWord(appoint_address,wait_write);                        //Подождите, пока программа завершит запись
		}
		FLASH_Lock();	                                                              //Завершить работу программы
	}
}
void backup_block(u16 number)		                                              //Резервное копирование блока программы, назначение программы перед записью перед резервной копией
{
	u16 temp,appoint_address;
	if(number<17)
	{
		for(temp=0;temp<2048;temp++)
		{
			appoint_address=number*0x800+temp;                                       //Начальный адрес плюс адрес блока плюс небольшой адрес блока
			prog_write_buffer[temp]=plc_programCodeBuf[appoint_address];	                          //Резервное копирование программы
		}
	}
}
thanks !

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

Re: port stm32 write to flash for esp...

Postby ESP_Sprite » Tue Jan 24, 2023 11:26 am

Not sure what you mean by 'without changing the addressing', but depending on what you want specifically, you can either use the NVS subsystem to store your variables, or the SPI flash subsystem to flash the data to a separate partition.

Yuriy_m
Posts: 9
Joined: Tue Apr 19, 2022 8:38 am

Re: port stm32 write to flash for esp...

Postby Yuriy_m » Tue Jan 24, 2023 12:24 pm

I have an esp32-s3 with built-in memory. In stm32f103, it is written to memory at physical addresses. then it is read from there into a program that accesses a specific memory address. how to do this in esp ?
NVS - не очень хорошо, судя по описанию...

Image
Attachments
2023-01-24_15-21-59.png
2023-01-24_15-21-59.png (207.55 KiB) Viewed 3622 times
2023-01-24_15-03-44.png
2023-01-24_15-03-44.png (1.37 MiB) Viewed 3622 times

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

Re: port stm32 write to flash for esp...

Postby ESP_Sprite » Wed Jan 25, 2023 2:01 am

Do you mean that your variables point directly to the flash that you're writing? Esp-idf does not support that, because of a variety of reasons. You can write your values to flash and read them back into RAM when needed either using 'raw' SPI flash or partition access, or preferably using NVS. NVS has some advantages to the STM32 method: it's atomic (so there's no chance of corruption because of power loss or a crash; the NVS will always be in a consistent state) and it does wear leveling so you don't need to worry about the longevity of your flash.

lbernstone
Posts: 831
Joined: Mon Jul 22, 2019 3:20 pm

Re: port stm32 write to flash for esp...

Postby lbernstone » Wed Jan 25, 2023 9:07 pm

If you are simply looking for something to make it easy to port your code, the EEPROM library uses location based addressing (https://github.com/espressif/arduino-es ... ies/EEPROM). It is built on top of the NVS storage system, so it can store ~15K without any modification. If you need more than that, you can do some custom partitioning to give yourself a larger nvs partition. It is not going to be quite as performant as directly writing to the flash, but most of the time the flash is much slower than your code anyhow.

Yuriy_m
Posts: 9
Joined: Tue Apr 19, 2022 8:38 am

Re: port stm32 write to flash for esp...

Postby Yuriy_m » Mon Feb 13, 2023 6:11 pm

there is one more question. in stm32 there is direct addressing to RAM as well. Starts with 0x2000000. For example - u16 prg_16BitBuf[4095] __at (0x20001000); Is it possible in esp32-s3 to allocate direct addressing in RAM ?

Yuriy_m
Posts: 9
Joined: Tue Apr 19, 2022 8:38 am

Re: port stm32 write to flash for esp...

Postby Yuriy_m » Tue Feb 21, 2023 6:05 am

to paraphrase... There is an array, it should be in RAM. Let's assume prg_16BitBuf[4095] from the address 0x00001000. respectively, the end address is 0x00001FFF. how to do it?

Who is online

Users browsing this forum: No registered users and 40 guests