cancel
Showing results for 
Search instead for 
Did you mean: 

IAP- not receiving binary file data packets from hyperterminal

Harsha Jagadish_2
Associate
Posted on August 23, 2017 at 20:56

Turvey.Clive.002

‌

Hi,

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.

Thanks,

Harsha

null
1 REPLY 1
Posted on August 23, 2017 at 22:12

Can't really debug Cube issues for you.

Make sure the timeout is adequate for the number of bytes and baud rate you are attempting to read. Consider breaking the transfer into smaller pieces, ie each HAL_UART_Receive deals with 32 bytes, advancing into the buffer at each iteration.

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