STM32L01 series microcontrollers are programmed via serial port (ISP)

Publisher:mlgb999Latest update time:2018-08-22 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The official ISP software (serial port burning software) FlashLoader Demonstrator does not support the stm32l01 series of microcontrollers. So how can we use the serial port to burn the program for this type of microcontroller through the serial port? 

I recently did a project that required this, so I studied this method and shared it with those who need it. To prepare the tools, you only need the mcuisp (also known as flymcu) software and the serial port assistant. 

Provide mcuisp software for lazy people mcuisp 

After my experiment, mcuisp can program this microcontroller but cannot erase the chip. Later, I found that the erase instruction of this chip is different. Students who are interested can read this document AN3155 (USART protocol used in the STM32 bootloader) and search it on Baidu. 

So our task now is to find a way to erase this chip and then download it through the mcuisp software (my idea is that it is okay to use the existing tools directly after knowing the principle). The AN3155 document introduces the usage of each instruction in detail. We mainly read the erase instruction part 

This chip supports Extended Erase Memory Command, but it does not support the advanced commands in this command, so if you want to erase this chip, you must use the most troublesome step. Erase page by page. My chip has 16k flash and each page has 128b, so there are a total of 128 pages that need to be erased. If you send commands one by one, at least 129 commands are required. So I used Qt to write a serial port host computer to help me complete this tedious process. I am not very proficient in using Qt and basically have not seen the threshold. Here is a solution. If you want to learn from it, please reply below this post and I can share the main code. 

In addition, the chip I use supports user-defined boot options, so it is more convenient to use with this. The code for selecting the boot area is as follows:


void BOOTCONF_User() //Determine where the system is booted from. If booting from systemflsh, change the option byte to boot from //Flash program memory

{

    HAL_StatusTypeDef status = HAL_OK;

     uint32_t tmp = 0U, tmp1 = 0U;

    if (LL_SYSCFG_GetBootMode() == LL_SYSCFG_BOOTMODE_SYSTEMFLASH)

    {

        tmp = OB->USER & (~0XE000);

        tmp |= (1u << 15);

        tmp1 = (~tmp) << 16;

        tmp |= tmp1;

        HAL_FLASH_OB_Unlock();

        status = FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE);


        {

            OB->USER = tmp;

            FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE);

        }       

        HAL_FLASH_OB_Launch();

        HAL_FLASH_OB_Lock();

    }

}


void BOOTCONF_System()//How to trigger your own definition after receiving the programming instruction to let the chip enter the system bootloader

{

    HAL_StatusTypeDef status = HAL_OK;

    uint32_t tmp = 0U, tmp1 = 0U;


    tmp = OB->USER | 0X00E000;

    tmp &= 0X00BFFF;

    tmp1 = (~tmp) << 16;

    tmp |= tmp1;

    HAL_FLASH_OB_Unlock();


    FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE);

    {

        OB->USER = tmp;

        FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE);

    }

    HAL_FLASH_OB_Launch();

    HAL_FLASH_OB_Lock();

}


Reference address:STM32L01 series microcontrollers are programmed via serial port (ISP)

Previous article:Experience in tuning the serial port ISP of STM32
Next article:Several issues with stm32j_link and serial port download

Recommended ReadingLatest update time:2024-11-16 13:07

Solution to Handshake Failure during ISP Download of STC MCU
I encountered a very frustrating problem today. When downloading the HEX file to the microcontroller, although the microcontroller information, such as the main frequency, etc., can be detected, the teacher prompted that the handshake failed during the download. I checked a lot of information, but still couldn't solve
[Microcontroller]
AVR's Journey - 1. Serial Port ISP Burner
Recently, some small projects require the use of embedded micro-control circuits. I have played with AVR development in 2010 and became very proficient in it, so I decided to get familiar with AVR again. If you want to do your work well, you must first sharpen your tools. To start AVR development, you need to prepar
[Microcontroller]
AVR's Journey - 1. Serial Port ISP Burner
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components
Guess you like

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号