Skip to main content
Visitor II
April 21, 2022
Question

STM32 Code update through in built CAN Bootloader

  • April 21, 2022
  • 4 replies
  • 2273 views

Hii Everyone

I saw this post about software jump to DFU Bootloader.

 typedef void (*pFunction)(void);
 pFunction JumpToApplication;
 uint32_t JumpAddress;
 HAL_RCC_DeInit();
 SysTick->CTRL = 0;
 SysTick->LOAD = 0;
 SysTick->VAL = 0; /** * Step: Disable all interrupts */
 __disable_irq(); /* ARM Cortex-M Programming Guide to Memory Barrier Instructions.*/
 __DSB();
 __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH(); /* Remap is bot visible at once. Execute some unrelated command! */
 __DSB();
 __ISB();
 JumpToApplication = (void (*)(void))(*((uint32_t *)(0x1FFF0000 + 4))); /* Initialize user application's Stack Pointer */
 __set_MSP(*(__IO uint32_t *)0x1FFF0000);
 JumpToApplication();
 void (*SysMemBootJump)(void);

My scenario: I am trying the same using above code snippet of jump but i want to use CAN Bootloader

Observation:

  • When i perform jump to system bootloader, and after pausing debugger, i see the stack pointer is executing instructions in system flash bootloader area.

My question:

  • Does this observation tells the jump was succesful and bootloader is waiting for CAN frame on Rx pin?

Another Scenario: I am assuming the jump was succesful based on observation, So

  • Now i am sending CAN ACK frame as described in AN2606 from another MCU to can bus

NOTE:CAN BAUD RATE: 125kbps, NODES:2, COMMUNICATION: Verified

  • After sending can frame i get transmission error for same frame.
  • And the mcu the one who did jump to bootloader genearates reset.

My question:

  • Any idea where i am doing wrong or any help you can provide

THANKS

    This topic has been closed for replies.

    4 replies

    Graduate II
    April 21, 2022

    The loader doesn't re-enable the interrupts.

    You don't mention a specific part.

    You can check if the boot loader works by booting directly into it​, rather than this method.

    You can test CAN method using the ST-LINK/V3SET​ and the STM32 Cube Programmer.

    Gsing.2Author
    Visitor II
    April 21, 2022

    part: STM32L462VET6

    How can i test CAN method through ST_LINK/stm32 cube programmer?

    boot pins are unreachable

    Graduate II
    April 21, 2022

    Pretty sure there are manuals for the ST-LINK/V3 and the Programming tool. The programming tools has a "CAN" connectivity mode, in the same fashion as it does for "ST-LINK", "COM" and "USB"

    https://www.st.com/resource/en/user_manual/dm00526767-stlink-v3set-debugger-programmer-for-stm8-and-stm32-stmicroelectronics.pdf

    >>boot pins are unreachable

    That's a bit of an oversight, not to test points, or board-edges?

    If you're building CAN products, surely you can come up with your own update protocol, apps and connectivity. The CAN boot loader in ROM is more generally targeted at production programming, not consumer field programming. The protocol is described in a manual, but you'd still generally want to control the user side experience.

    I think the L4 is more apt to re-enter the user application if present than to stay in the loader ROM. There are ways around that, but perhaps beyond the scope of the forum.

    Gsing.2Author
    Visitor II
    April 25, 2022

    i have confirmed that stm32 is entering into bootloader.

    I tried using usart and it worked easily.

    But when it comes to CAN i am receving no response from stm32.

    Here is brief:

    • enter boot mode
    • send sync frame from another mcu as described in AN3154 at 125kbps
    • Response:
      • Transmission Error with error code 4096 in HAL CAN Error codes

    Graduate II
    April 21, 2022

    Lines 3 and 16 in your code seems to be useless.

    Because APB buses run at lower frequencies and has an intermediate synchronization buffers, after remapping one must read back that (or any other from the same peripheral) register to ensure the write operation has been completed. DSB and/or ISB does not ensure that!

    __DSB();
    __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
    SYSCFG->MEMRMP;
    __DSB();
    __ISB();

    Gsing.2Author
    Visitor II
    April 25, 2022

    Thanks for your response.

    Gsing.2Author
    Visitor II
    April 29, 2022

    Hii,

    I have found the problem, it was related to CAN bus getting off on transmission error in STM32f072 causing timeout of waiting in stm32l462 for ACK fame and hence generating reset.

    Solution: By enabling auto retransmission and auto wakeup in stm32f072, i got the problem resolved. Hence Now i am communicating with bootloader.