This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32F103 - In Application Programing RTX from SD card Help

Hi every one,

I have a STM32F103 Board with an SD card . My project has a simple idea.( Im not sue, I could be simple for begginers like me)
New firmware has to be copied Sdcard like “Firmware.bin”

When MCU starts ,

If the file is exist
        Start firmwareupdate
else
        Jump user App

I’m using FLASH-FS to read firmware file from SD CARD, and write is mcu flash. I inspired AN2557 IAP from USART application and , MCBSTM32 RTX_Blinky projects. Is that possible to IAP using RTX ?

I can read firmware file and write is flash, but I can’t handle jump application. Im stuck now.

This is code what I try,


if(checkfile("firmware.bin")==1){
      os_dly_wait(50);
      firmware_update("firmware.bin ",0,2048);

 }else{

      JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);
      Jump_To_Application = (pFunction) JumpAddress;
      /* Initialize user application's Stack Pointer */
      __set_MSP(*(__IO uint32_t*) ApplicationAddress);
      Jump_To_Application();

 }

I got error message ;

Blinky.c(114): error: #20: identifier "__IO" is undefined
Blinky.c(117): warning: #223-D: function "__set_MSP" declared implicitly

Do you have any suggestion to set mainStackPointer and __IO for RTX blinky project. And please some details about what I must do with jump part

Thanks your help

  • Also ,
    I saw one keil forum post, core_cm3.h and core_cm3.c file has to be include project for defination __set_MSP and __IO . But When I add these file , I have got more complex error. It interlace with FS_CM3.lib

    these are ERRORS when I add core_cm3 files

    core_cm3.h(715): warning: #47-D: incompatible redefinition of macro "SCS_BASE" (declared at line 687 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_map.h")
    core_cm3.h(723): warning: #47-D: incompatible redefinition of macro "SCB" (declared at line 935 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_map.h")
    core_cm3.h(724): warning: #47-D: incompatible redefinition of macro "SysTick" (declared at line 930 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_map.h")
    core_cm3.h(725): warning: #47-D: incompatible redefinition of macro "NVIC" (declared at line 934 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_map.h")

  • Note that you should add version control and integrity control.

    Without version control, every boot will try to program that binary without checking if that is already the currently installed one.

    Without integrity control, some fool will manage to get a short file, or a file that hasn't been transmitted in a binary-safe way. And then you brick your unit.

    Next thing - it is often (not always, it depends on the full scope of your boot loaders) a good idea to just take a watchdog reset after you have reprogrammed the chip. But it depends on who is responsible for the programming - if you have the boot loader do it, or if you have two application areas and have the application do the second application area before doing a reboot to get the boot loader to start the newer application area instead.

  • Thanks Per,

    Version and integrity control is important issue. I will keep them in my mind.
    Probably I will add some additinal line in binary or new checksumfile ( file lenght,linecount, versiyon information maybe try smilar MD5 hashing alg.)

    I try to create two application. I will use for it FOTA prosess

    App one ( bootloader from SD ) ( 0x8000000 - 0x8002FFF) *maybe I need bigger area for FS..

    - check firmware from SD card - if new one appear flash it second APP area

    App two ( main App ) (0x8003000 - ... )

    - It is just helloworld for now. - It will download firmware from FTP to SD. - After download and verification, it will restart and App one handle update prosess - I have to configure Target options and vector table for 0x8003000)

    My problem is, I can't handle jump prosess. I have found old post on this forum.

    http://www.keil.com/forum/16355/ , it hadn't much information. It kind of dead topic.

    - How I set Master Stack pointer to new Application Adress Keil Flash-FS

    I cant understand very well jump app prosess AN2557. Is it enough to set MSP to 0x8003000 to start App two.

    Thanks

  • You shouldn't need to set any stack pointer. Your application (that you downloaded) should be complete with startup code.

    So you should make sure the boot loader leaves the interrupts off, and not in user mode. Then pick up the reset vector from the start of the application region and jump there. That code is responsible for setting up the stack. It's your new application that should take responsibility for deciding how much RAM should be stack and how much RAM should be variables, buffers, ...

  • Hi Per,

    AN2557 IAP example said, assing a new application base adress to MSP. I try to develop same structure.My fisrt message has "AN2557 jump user app" codes.

    As you said, it has to be enough set reset vector to downloaded App base adress. How downloaded application will start. Do I have to wait watchdog in while loop.

    Im looking for forum, how to set reset vector.. Hope it will be easy

    thanks

  • The Application Note shows you that.