Author Topic: STM32 uTaskerBoot Project  (Read 977 times)

Offline TeeYi

  • Newbie
  • *
  • Posts: 6
    • View Profile
STM32 uTaskerBoot Project
« on: November 23, 2021, 03:03:05 PM »
Hello Mark,
   I download the STM32 package from its GIT repository (V1.4.11)  which in uTasker-Kinetic-master/Applications/uTaskerBoot/ only have the project file for for Kinetis, but don't have project file for SMT32. And in the uTaskerSerialBoot folder & uTaskerV1.4 folder have project file for both Kinetis & SMT32.
    Is this  uTaskerBoot support for STM32? If yes, where I can get the project file for this STM32 uTaskerBoot?
    Thanks.
    Tee 

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3187
    • View Profile
    • uTasker
Re: STM32 uTaskerBoot Project
« Reply #1 on: November 27, 2021, 03:34:56 AM »
Hi

I just checked in some changes that add "STM32 BM Loader target" to the VisualStudio project (VS2019) and also a GCC make file build that can be started from the VS project (when STM32 + GCC Build target is selected).

Both Kinetis and STM32 targets built successfully in the simulator and cross-compiled to their binary images.

There are only a few actual STM32 HW targets in config.h but it is relatively easy to add new ones if needed.

Regards

Mark

Offline TeeYi

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: STM32 uTaskerBoot Project
« Reply #2 on: November 29, 2021, 11:52:08 AM »
Hi Mark,
    Thanks for your reply. Could you please create the project for IAR which I'm using IAR for this STM32 uTaskerBoot.
    Thanks & best regards.
     Tee

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3187
    • View Profile
    • uTasker
Re: STM32 uTaskerBoot Project
« Reply #3 on: November 29, 2021, 05:12:28 PM »
Hi

I have checked in an IAR9 project for STM32.

Regards

Mark

Offline TeeYi

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: STM32 uTaskerBoot Project
« Reply #4 on: November 30, 2021, 02:12:33 PM »
Hi Mark,
   Successful compile the project using IAR9.2.
   Thanks.
    Tee

Offline TeeYi

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: STM32 uTaskerBoot Project
« Reply #5 on: December 10, 2021, 10:36:25 AM »
Hi Mark,
    I try to use uTaskerCombine tool to combine the uTaskerBoot.bin (from uTaskerBoot Project) with uTakserBM.bin (from uTaskerV1.4 Project) as below: (STM32)

   uTaskerCombine uTaskerboot.bin uTaskerBM.bin 0x1000 STM32.bin STM32.out 0x80000000

and 

   uTaskerCombine uTaskerboot.bin uTaskerBM.bin 0x1000 STM32.bin

but both command only generated STM32.bin file with 0 byte size.


    I attached both file for your reference & testing. Please advice how to generate the .out format file that required by IAR to program the firmware into the STM32 MCU.
    I am using Window 7 Professional (64bit) & uTaskerCombine V1.6 .

     Thanks.
     Tee
     
       
   

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3187
    • View Profile
    • uTasker
Re: STM32 uTaskerBoot Project
« Reply #6 on: December 12, 2021, 11:03:16 PM »
Hi

When this command is executed there is the message "Boot code too long (> 1000). Terminating" and so no output content is generated.
The problem is that the "uTaskerBoot.bin" is 50k in size and the command tried to add the second file "uTaskerBM.bin" at the location 0x1000, which is not possible since this would be in the middle of the first file.

The basic issue is that the boot loader is being built with a linker script that locates the reset vector at the 0x08000000 but he reset of the code at 0x080c000 and so leaves a large gap between the two which makes the file large (this can be seen by opening the binary file in a hex editor and shows a large amount of 0x00 being inserted).

I believe the line in the linker script doing this is:

define symbol __ICFEDIT_region_CODE_start__ = 0x0800c000;

and is designed for use by programs that leave two flash sectors free for use by the parameter system. Since the boot loader doesn't use the parameter system this line is not appropriate and if you remove it it will presumably then generate loader code that is all in the first flash sector (and small).


The IAR out format is ELF format, which is not generated. You will therefore need to use a different loading technique than IAR's (which only allows loading files that it has created). ST Micro has a utility that is often used for this and, once the loader and the initial application are installed subsequent uploads can be performed by the application's loading method.

Regards

Mark


Offline TeeYi

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: STM32 uTaskerBoot Project
« Reply #7 on: December 14, 2021, 03:24:23 PM »
Hi Mark,
    Thanks for your clarification.

    By using Segger J-Flash, I manage to combine the both file & program on the MCU. But it still not working.
    After that by using IAR, I try to debug on the uTaskerBoot which I found two problem on (uTaskerBootLoader.c):

1)   The firmware never run the " start_application(UTASKER_CODE_START) " when compile for STM32, so I add defined _SMT32  as
       as below for the compiler.


#elif defined _STM32 || defined _HW_AVR32 || defined _RX6XX || defined _KINETIS || defined _LM3SXXXX || defined _LPC17XX || (defined _M5223X && (defined _GNU || defined _COMPILE_IAR)) // {14}{17}{19}{20}{21}
    #if !defined _WINDOWS
    start_application(UTASKER_CODE_START);                               // jump to the application
    #endif
#endif


2) when the program run  [ if (fnCheckNewCode(&file_header))], it will cause HardFault exception
    static void irq_hard_fault(void)
   {
    }
   I attached the print screen (IAR) for your reference.

   When I change the routine as below,

static int fnCheckNewCode(UPLOAD_HEADER *file_header)
{
    return 0;
   
}
      After compile again & combine both file (uTaskserBM and uTaskerBoot), my board success boot up and running my program.
   
      Please advice how to solve the problem for fnCheckNewCode(UPLOAD_HEADER *file_header) routine.
     
      For your information, I am using SMT32F407ZET6 .
      Thanks & best regards.
   
       Tee
     
   

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3187
    • View Profile
    • uTasker
Re: STM32 uTaskerBoot Project
« Reply #8 on: December 26, 2021, 02:07:55 AM »
Hi

I am sorry that i didn't respond earlier:

1. I also found that the jump was not enabled for STM32 and the new dependency is correct.

2. I don't see the code causing the hard fault but I assume that it is due to the routine checking the flash content at an incorrect address/range (if you look at the call stack you can see the routine that resulted in the error - and also if you single step out of the hard fault handler (in disassembly mode) it will return to the instruction causing the error. You can see what address the instruction is using and verify that the range set up for the check is suitable for the part in question (like uFILE_START and UTASKER_APP_START).

Regards

Mark

Offline TeeYi

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: STM32 uTaskerBoot Project
« Reply #9 on: December 28, 2021, 07:35:59 AM »
Hi Mark,
    Thanks for your reply.
    I already found the problem which cause the firmware halt (when call this function fnCheckNewCode(&file_header)). Basically it cause by stack overflow, and it can be solved by increase the stack size (in .lcf file)

define symbol __ICFEDIT_size_cstack__ = 0x400;
    Thanks.
    Tee

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3187
    • View Profile
    • uTasker
Re: STM32 uTaskerBoot Project
« Reply #10 on: December 28, 2021, 07:38:50 PM »
Hi

That is strange since the project uses a stack pointer at the top of SRAM and not the stack size that is given in the linker script file (this allows its stack to automatically have the size of all unused RAM).
Possibly it is the specific IAR version overwriting this?

Regards

Mark