cancel
Showing results for 
Search instead for 
Did you mean: 

Firmware upgrade through Y modem

MBhir.11
Associate III

Hi ,

i am new to some of the peripherals of STM32 controllers...

I am using STM32L151RCT6 MCU in STMCube IDE for my application..

My requirement is like i need to receive the new firmware binary file via Y modem and need to write into the flash and need to run that application by sending one of the CLI from the UART..

I tried with some examples but not getting proper working of Y modem for receiving the binary file..

Please suggest me if any example codes along with reference document, it will be helpful for me..

it is very much necessary for me....

7 REPLIES 7
Mike_ST
ST Employee

Hello,

you have some ymodem implementations in the firmware packages:

STM32Cube_FW_F1_V1.8.4\Projects\STM3210E_EVAL\Applications\IAP\IAP_Main

STM32Cube_FW_F0_V1.11.3\Projects\STM32091C_EVAL\Applications\IAP\IAP_Main

STM32Cube_FW_F4_V1.26.2\Projects\STM324x9I_EVAL\Applications\IAP\IAP_Main

There is a readme.txt file in those examples.

MBhir.11
Associate III

Hi Mike,

Thanks for your reply , based on the above examples i prepared one project for STM32L151RCT6 MCU and i loaded it.

passing the binary file from the Y modem Tera term , it is receiving half of the file and stopped shown bellow.

i tried the uart baud rate for both 9600 and 115200 both are showing same behaviour , i am not getting what is problem..

please help me for this .. it is needed for me.

consider the attached y modem function.

MBhir.11
Associate III

Here Y modem h file is attached

MBhir.11
Associate III

0693W00000DmdMJQAZ.png 

It is stopping as shown above

MBhir.11
Associate III
/**
  ******************************************************************************
  * @file    IAP_Main/Inc/flash_if.h 
  * @author  MCD Application Team
  * @version 1.0.0
  * @date    8-April-2015
  * @brief   This file provides all the headers of the flash_if functions.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
  *
  * Redistribution and use in source and binary forms, with or without modification,
  * are permitted provided that the following conditions are met:
  *   1. Redistributions of source code must retain the above copyright notice,
  *      this list of conditions and the following disclaimer.
  *   2. Redistributions in binary form must reproduce the above copyright notice,
  *      this list of conditions and the following disclaimer in the documentation
  *      and/or other materials provided with the distribution.
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
  *      may be used to endorse or promote products derived from this software
  *      without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ******************************************************************************
  */
 
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __FLASH_IF_H
#define __FLASH_IF_H
 
/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx_hal.h"
#include "stm32l1xx_hal_conf.h"
 
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
 
 
/* Error code */
enum 
{
  FLASHIF_OK = 0,
  FLASHIF_ERASEKO,
  FLASHIF_WRITINGCTRL_ERROR,
  FLASHIF_WRITING_ERROR,
  FLASHIF_PROTECTION_ERRROR
};
 
/* protection type */  
enum{
  FLASHIF_PROTECTION_NONE         = 0,
  FLASHIF_PROTECTION_PCROPENABLED = 0x1,
  FLASHIF_PROTECTION_WRPENABLED   = 0x2,
  FLASHIF_PROTECTION_RDPENABLED   = 0x4,
};
 
/* protection update */
enum {
	FLASHIF_WRP_ENABLE,
	FLASHIF_WRP_DISABLE
};
 
/* Define the address from where user application will be loaded.
   Note: this area is reserved for the IAP code                  */
#define FLASH_PAGE_STEP         FLASH_PAGE_SIZE           /* Size of page : 2 Kbytes */
#define APPLICATION_ADDRESS     (uint32_t)0x08004000      /* Start user code address: ADDR_FLASH_PAGE_8 */
 
/* Notable Flash addresses */
#define FLASH_START_BANK1             ((uint32_t)0x08000000)
#define WORDS_IN_HALF_PAGE            ((uint32_t)16)
#define FLASH_HALF_PAGE_SIZE          ((uint32_t)WORDS_IN_HALF_PAGE*4)
#define FLASH_LAST_SECTOR_BANK1       ((uint32_t)0x08017000)
#define FLASH_LAST_PAGE_BANK1         ((uint32_t)0x08017F00)
#define FLASH_END_BANK1               ((uint32_t)0x08017FFF)
#define FLASH_START_BANK2             ((uint32_t)0x08018000)
#define USER_FLASH_END_ADDRESS        ((uint32_t)0x08030000)
#define FLASH_BANK1_MASK              ((uint32_t)0xF0FFFFFF)
 
/* Define the user application size */
#define USER_FLASH_SIZE               ((uint32_t)0x00003000) /* Small default template application */
 
 
/* Exported macro ------------------------------------------------------------*/
/* ABSoulute value */
#define ABS_RETURN(x,y)               (((x) < (y)) ? (y) : (x))
 
/* Get the number of sectors from where the user program will be loaded */
#define FLASH_SECTOR_NUMBER           ((uint32_t)(ABS_RETURN(APPLICATION_ADDRESS,FLASH_START_BANK1))>>12)
 
/* Compute the mask to test if the Flash memory, where the user program will be
  loaded, is write protected */
#define FLASH_PROTECTED_SECTORS       (~(uint32_t)((1 << FLASH_SECTOR_NUMBER) - 1))
/* Exported functions ------------------------------------------------------- */
void FLASH_If_Init(void);
uint32_t FLASH_If_Erase(uint32_t StartSector);
uint32_t FLASH_If_GetWriteProtectionStatus(void);
uint32_t FLASH_If_Write(uint32_t destination, uint32_t *p_source, uint32_t length);
uint32_t FLASH_If_WriteProtectionConfig(uint32_t protectionstate);
void FLASH_ClearFlag(uint32_t FLASH_FLAG);
 
#endif  /* __FLASH_IF_H */
 
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

These are flash memory definitions

Mike_ST
ST Employee

Hello,

Please, try with Teraterm version 4.85, just to check whether it works. I know that later Teraterm ymodem implementation has changed a bit.

You'll probably have to learn a bit about ymodem protocol too to see why it is stalling.

Hi,

Thanks for reply , i tried with same version of Tera term what you suggested but not solved the issue..

is it related to flash programming ? or any address assigning?