In this method bin file of STM32 was added to the ESP32 script. This method use for overcome the limitation of HTTP and MQTT methods.
- read the .bin file
- define the header file
- 8bit data type used to creat veriables
- store read data in 8 bit 2D array with lenght of 1024 and width according to bin file size (2d matrix)
- place .py file in same folder that .bin file placed
- run the pyhton file with first argument with the .bin file name. ex - ( python3 bin_to_hex.py stm32_bin_file.bin)
- stm32_bin.h file now creat in the folder
- move the stm32_bin.h file to the main directory of the espidf project
- init_uart_2() - UART configuration ( baud rate -115200)
- gpio_init_2() - gpio pin initializing
- gpio_boot_set() - enable boot mode of the stm32
- gpio_boot_rset() - disable boot mode of the stm32
- write_address_checksum() - checksum of the 32bit address
- enter_bootmode_2() - flasing process
- stm32_flash()
- stm32_check() - check the stm32 firmware version
- BOOT0 to 1
- RESET to 1
- RESET to 0
- TX 0x7F
- RX 0x79
- TX 0x43
- TX 0xBC
- RX 0x79 // erasing flash
- TX 0xFF
- TX 0x00
- RX 0x79 // flash Erase success
- TX 0x31
- TX 0xCE
- RX 0x79
0x12345678
|31-----------24|23-----------16|15------------8|7---------bit 0|
+---------------+---------------+---------------+---------------+
|0 0 0 1 0 0 1 0|0 0 1 1 0 1 0 0|0 1 0 1 0 1 1 0|0 1 1 1 1 0 0 0|
+---------------+---------------+---------------+---------------+
-
TX -
1byte - 0 0 0 1 0 0 1 0
2byte - 0 0 1 1 0 1 0 0
3byte - 0 1 0 1 0 1 1 0
4byte - 0 1 1 1 1 0 0 0
5byte - XOR (|0 0 0 1 0 0 1 0|0 0 1 1 0 1 0 0|0 1 0 1 0 1 1 0|0 1 1 1 1 0 0 0|) -
RX 0x79 // address send
-
TX number of bytes --- (128 -1)
-
Tx 128 byte send
- RX 0x79 // packet send done .........................
------------ loop end ------------------------
- BOOT0 to 0
- RESET to 1
- RESET to 0