STM32 tutorial - write and read internal FLASH memory + Bootloader jump function

preview_player
Показать описание


0:00 - Introduction
1:22 - Quick demonstration
4:40 - Prove that the data are actually stored on FLASH
6:50 - FLASH origin, FLASH offset and page size
8:27 - Explaining functions for writing and reading from FLASH memory
14:18 - Bootloader
Рекомендации по теме
Комментарии
Автор

As I'm just starting with Embedded, this was very helpful! Thanks

blahri
Автор

whoa, nice tutorial. this is what i need. let me try first. i will let you know the result. hope this works.

OctaRudin
Автор

You should change the strlen() in the code if the datas contain the byte 0000 0000 it will consider this as the end of a string. So if you have a 0x0000 in the the middle of your datas, only the beginig will be wrote in the flash memory.

mohamedalglawi
Автор

I dont know why we need to erase the flash before writing it. Can we just write a single word into a single direction? ;)

lucasmarjona
Автор

what changes should make for STM32WB55?

samalrandula
Автор

I have an STM32H7, and despite a HAL_OK for every write,

HAL_FLASH_Unlock();
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, 0x081E0000+ (32*fw), (uint32_t)(pBuffer)) != HAL_OK)
{
Error_Handler();
}
HAL_FLASH_Lock();

OCCASIONALLY, the write appears to cause an alignment/ECC error. Simply *READING* from the sector, will cause a Hard-Fault/IRQ0. The only way to recover, is to erase the chip.

For testing, I'm writing an incrementing pattern, and the fault seems to happen randomly at a different address/data each time.

Any idea if there's a way to disable the ECC on the sector.. or if it's a CACHE issue?

bennguyen
Автор

hi, I hope you are well, I have a project to do which is to retrieve a binary file from github using the sim7600 then flash it into the stm32f446re flash memory and execute it, for example in 0x8002000 how to do it Please. thanks

mahdidjennad
Автор

Please explain this procedure for NXP S32K146 MCU

sushmasush
Автор

did you write the functions save_to_flash and read_flash by yourself?

ESEben
Автор

Firstly, I would like to say thank you for your sharing this video. Secondly, I have one concern in your code. You have used Erase command to erase flash memory. But as you known that command will be erased data in full page. That other data will be erased in same this page. It doesn’t belong to data as “Hello”. Do you have any solution for this ? I don’t want to use RAN to resolve this issue.

MicrocontrollerAZ
Автор

Thanks a lot! Trying to apply this to USB HOST MSC firmware update right now.

soundforce_nicolas
Автор

#define FLASH_STORAGE 0x08000400
#define page_size 0x400

#define pages 1



IS THIS OK FOR MY MICRO WHICH IS STM32F103C8 ?

safiakhan
Автор

The Stm32h7 has a 32-byte flash word.. so I keep a buffer,

uint32_t buffer [ 8 ] =, , , , , , ,

where anytime I want to write to flash, I use the next empty index in the buffer and then pass it all to the flash:
HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, 0x081E0000, buffer) == HAL_OK)

This mostly works except randomly after so a few writes or so, HAL_FLASH_Program corrupts the flash, even though it returns HAL_OK. Don't know exactly how it corrupts it because if I try to read the flash I get a hard fault. Stm32CubeProgrammer can't read it either.

Seems to happen randomly.. not sure if it's a cache issue but how would I disable it to test? Or maybe an issue with the buffer.. how can align it to test? Or declare it as volatile? I don't think it's a voltage issue as I'm using an ST Disco board.

bennguyen
Автор

Спасибо, все доступно и понятно, в x2 отлично воспринимается

uriydolgonogiy
Автор

Thank you very much! But I think: Firstly, you much fix size of flash in *.ld file. It will prevent us from conflicting data, which you want to save and data of application program.

tuananhpham
Автор

on line 61 of the code i am getting an error: use of undeclaired indetifier "data" why.

safiakhan
Автор

do you got any tutorial of external flash for disco stm32f469

hIMAShShA
Автор

Hello man,
How can we write sensor data either on the memory of the board or on the pc?

amineleking
Автор

hi sir how to read & copy hex file from STM32F103C8T6

sandeepthorvat
Автор

Hello great video

I have a problem.
when I try to store this array in flash memory,
char write_data [50] = {0x7E, 0xAA, 0x01, 0x00, 0XBB, 0XAA, 0XCC, 0X11, 0X22};

it only saves me up to the position (write_data [3] of the array) in memory

How can I solve this problem?

andresceballos