cancel
Showing results for 
Search instead for 
Did you mean: 

How Can I Code For Boot-loader In STM32F030K6T6 Using I2C Protocol With Anther Board of STM32F030K6T6???

Kaushal
Associate II

Hello ,

I Am Working With Two STM32F030K6T6 Board ,Which is Used As a Boot-loader application With I2C protocol.

So I Can Communicate Small Data But Some How I Can Not Communicate A Long Data To Transmitted or Received From Master To Slave Or Slave To Master .

I Have Try Both the The Method Using Blocking mode And Non-Blocking Mode .

So Please suggest How To Make a Code For Long Data Transmission Using I2C Protocol In Both Board .

7 REPLIES 7

Break the "Long Data" into smaller sub-blocks?

Or are you talking about the ROM based system loader described in App Note AN4221 ?

https://www.st.com/resource/en/application_note/dm00072315-i2c-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Kaushal
Associate II

Yes I Have To Break All The Data In Small Blocks ,

But I Only Stuck in Communication Part To synchronous Of Two Board Which Time Which Board Is Selected For Transmitter Or Receiver The Data .

So I Want The Algorithm Of Communication Between Two Boards Using I2C Protocol.

The document does not display the protocol diagram of I2C. Do I need to send the device address before each command is sent?

Figure 1 seems to indicate that it doesn't..

Some of us just try things and experiment so we understand how things actually work. Send a couple of query type commands, and some reads, see how it responds.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I'm trying to reach the built-in bootloader through another microcontroller using I2C protocol.

RST set to 0, BOOT0 to 1 and let go of RST

//i2c 100kHz
 
HAL_StatusTypeDef status;
 
uint8_t tmp[2];
uint8_t dat[21];
uint8_t ACK;
 
	while(HAL_I2C_GetState(I2cHandle) != HAL_I2C_STATE_READY);
	status = HAL_I2C_Master_Transmit_IT(I2cHandle, 0xa6, dat, 1);
	while (HAL_I2C_GetState(I2cHandle) != HAL_I2C_STATE_READY) ;
	status = HAL_I2C_Master_Receive_IT(I2cHandle, 0xa6, &ACK, 1);
while(1)
	{
		tmp[0] = 1;//Get Version command
		tmp[1] = 0xfe;//XOR tmp[0]
		while (HAL_I2C_GetState(I2cHandle) != HAL_I2C_STATE_READY) ;
		status = HAL_I2C_Master_Transmit_IT(I2cHandle, 0xa6, tmp, 2);
		memset(dat, 0, sizeof(dat));
		while (HAL_I2C_GetState(I2cHandle) != HAL_I2C_STATE_READY) ;
		status = HAL_I2C_Master_Receive_IT(I2cHandle, 0xa6, &ACK, 1);
		if (ACK == 0x79)
		{			
			while (HAL_I2C_GetState(I2cHandle) != HAL_I2C_STATE_READY) ;
			status = HAL_I2C_Master_Receive_IT(I2cHandle, 0xa6, dat, 2);	
//Практиче�?ки в�?егда получаю нули. Иногда приходит 0x12 0xff
		}
		else if (ACK == 0x1f)//nack
		{
//Иногда попадаю �?юда
		}
		else if(ACK == 0x76)//busy
		{
		}
			else
		{
		}
}

In document AN2606, the slave address is 0b1010100x. I managed to reach out only at the address 0b1010011x. Is this a documentation error?

AN4221 has very little protocol information.

According to the code above, the slave often draws the SCL line up to 10 seconds.

ACK (0x76) I get, sometimes NACK.

The answer is zeros in the array. Sometimes slips 0x12 0xff

How to work with the boot using this protocol?

MCU STM32G474RE

I figured out how to receive a response from the bootloader. You need to take one byte.

if (ACK == 0x79)
		{			
			status = HAL_I2C_Master_Receive_IT(I2cHandle, 0xa6, &dat[0], 1);
//https://www.st.com/resource/en/application_note/dm00072315-i2c-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf
//page 11
//Byte 2: Bootloader version (0 < Version ≤ 255) (for example, 0x10 = Version 1.0)
                        while (HAL_I2C_GetState(I2cHandle) != HAL_I2C_STATE_READY) ;
                        status = HAL_I2C_Master_Receive_IT(I2cHandle, 0xa6, &dat[1], 1);	
//Byte 3: ACK
                        while (HAL_I2C_GetState(I2cHandle) != HAL_I2C_STATE_READY) ;
		}
  1.