STM32F1 IAP upgrade sample tutorial

STM32F1 IAP upgrade sample tutorial

Routine download

Go to the link below to download the sample

https://witpic-1253369323.cos.ap-guangzhou.myqcloud.com/wit-cloud/ep/uploadFile/wit_iap-1675391001394.rar

https://github.com/WITMOTION/WitStandardProtocol_JY901

Routine introduction

This routine introduces how to use the STM32F1 development board to upgrade the firmware of the Wt-motion sensor.

o This routine is to simulate the Wit IAP upgrade protocol through the single-chip microcomputer to realize the firmware upgrade for the sensor

o The firmware in the SD card needs to be put into the upgrade firmware of the sensor

Before viewing this routine, please read the relevant operating instructions to understand the precautions during use and the search ideas for problems encountered

Modify the upgrade firmware name

1、Change the JY901S_ZKD_44309.bin file name in the GetUpdateData and GetUpdateFileSize functions in the interface.c file in the project to the firmware file name you need to upgrade (the upgrade firmware name in the SD card), recompile the project, and download it to the development board.

2. If you don’t want to modify the project, you can change the firmware name of the code to be upgraded to JY901S_ZKD_44309.bin

connect device

1. To connect the sensor, pay attention to connect the sensor serial port to the development board serial port 2, PA2 (RX), PA3 (TX) pins, do not connect the pins reversely, and connect the sensor power supply. Description: Upgrade the sensor through this serial port

2. Connect the serial port 1 to the computer. Note: it is used to view the printing prompt information during the upgrade

3. Insert the SD card

IAP upgrade

Power on the development board

After compiling and downloading the program to the development board, power on the development board again, and the LCD screen prompts

If it prompts SD card error:

1 Need to check whether the SD card is inserted well,

2 Check whether the SPI port used by the SD card is consistent with that in the program.

3 Check if the SD card is damaged

upgrade

If there is no response for a long time, and the start update is always displayed, you can power on the development board again and reinstall the SD card

Update completed

If the normal upgrade is successful, it will display iap update success, and print the upgrade progress on serial port 1 (the baud rate of serial port 1 is 115200)

If it prompts iap update fail, it means the upgrade failed, check whether the sensor is connected properly

Function description

If you use other boards, modify the instructions:

Mainly implement the following functions in interface.c

void IapUartInit(unsigned int uiBaud);//Initialize the serial port used for upgrading

void IapUartSend(unsigned char *p_data, unsigned int uiSize);//serial port sends specified byte data to realize serial port sending function

int IapUartGetChar(unsigned char *p_data, unsigned int uiTimeOut);//The serial port obtains a byte of data, realizing the function of serial port obtaining data

void DelayMs(unsigned int uiMs);//delay

int GetUpdateData(unsigned char *p_data, unsigned int uiOffset, unsigned int uiSize);

// Get the updated firmware

int GetUpdateFileSize(void);//Get the upgraded firmware size

Last updated