AnsweredAssumed Answered

IAP- not receiving binary file data packets from hyperterminal

Question asked by Harsha Jagadish on Aug 23, 2017
Latest reply on Aug 23, 2017 by Clive One

Clive One



I am having trouble receiving 1024 bytes of data into the buffer inside HAL_UART_Receive(). Here are the details of the controller and the example code used:


  • Controller: STM32L031k6t6
  • Example code: X-CUBE-IAP-USART/AN4657-STM32Cube_IAP_using_UART/Projects/STM32L073Z_EVAL/IAP_Main/MDK-ARM
  • Toolchain : keil 5.0


Using the example code the project is tailored according to the controller used.


Changes made: removed uint32_t FLASH_If_GetWriteProtectionStatus(void); and 
uint32_t FLASH_If_WriteProtectionConfig(uint32_t protectionstate); from flash_if.c since L031 does not support dual bank feature. Apart from this nothing else has been changed.


UART pins used are PA2 --> TX and PA15--> RX


The user input from tera term works fine when 1,2, or 3 is entered for serial_download(); serial_upload() or jump to application.

When binary file is sent using teraterm ymodem protocol, the following is the flow of the program

  • HAL_StatusTypeDef ReceivePacket(uint8_t *p_data, uint32_t *p_length, uint32_t timeout) gets called
  •  the packet_size gets received --SOH, STX ..
  • when it starts to receive the data packet contents,the receive gets timed out.
    • if (packet_size >= PACKET_SIZE )

      status = HAL_UART_Receive(&UartHandle, &p_data[PACKET_NUMBER_INDEX], packet_size + PACKET_OVERHEAD_SIZE, timeout);


      /* Simple packet sanity check */

      if (status == HAL_OK ) {.... performs CRC check
  • Here the HAL_UART_Receive gets timed out everytime it should receive a 1k packet and never puts the status as HAL_OK. Always returns TIMED_OUT 


  • Tera term stops sending the binary file


Note: I have set the user application to the flash address to which I am trying to download and also changed the VECTOR_TAB_OFFSET value to the same address location.


Is there any other setting I am missing for binary file transfer through UART? Any suggestions or help is much appreciated.