cancel
Showing results for 
Search instead for 
Did you mean: 

What version of STM32-XCUBE-CLASSB should i use for stm32f412CGUx, project under STM32CubeIDE IDE Version: 1.10.1.

AMukh.3
Associate II

I wan't to add self tests for my project using your STM32-XCUBE-CLASSB library.

1 ACCEPTED SOLUTION

Accepted Solutions
Petr Sladecek
ST Employee

Standard GCC assembly startup performs next steps prior calling main:

  • setup stack pointer
  • call Startup_Copy_Handler procedure (C data initialization at RAM)

<HERE WE MODIFY STANDARD SEQUENCE BY INSERTED CALL OF STL_StartUp() >

  • call System Init procedure and
  • call __libc_init_array
  • call main

The sense of GotoCompilerStartUp() macro called at the end of the STL_StartUp procedure execution ("artificially inserted" into standard assembly GCC startup flow) is to simulate repeating of the upper standard startup sequence again since begin because RAM content is destroyed completely after STL startup test. In fact, the macro should perform smooth standard restart of the C-level code and enter to the main. The only problem here is declaration of procedures defined at the assembly GCC startup flow level (normally not used from C-level).

Those are declaration warnings only. Are you able to run the code?

You can try to declare them as external at the STLparam header file.

Best regards,

Petr

View solution in original post

21 REPLIES 21
Petr Sladecek
ST Employee

Hello,

from databrief (https://www.st.com/resource/en/data_brief/x-cube-classb.pdf) and the STL user manual (AN4435) both available for download at X-CUBE-CLASSB ST web page, you can find easily information that the STM32F4 family is supported by version 2.2.0 of the library. This version doesn't include CubeIDE integration example project but older SW4STM32 one based on GCC compiler, too, from which it can be ported easily. As the package is a bit obsolete, I strongly suggest performing adaptations of the library sources as described at the user manual at chapter 3.10 there.

Best regards,

Petr

AMukh.3
Associate II

I've adapted my startup and linker filesfor STM32f412CGUx to integrate the library - code snippets below. But i'm getting an error that i will attach in the following code snippet. Could you explain please where i'm doing wrong.

/*
******************************************************************************
**
** @file        : LinkerScript.ld
**
** @author      : Auto-generated by STM32CubeIDE
**
** @brief       : Linker script for STM32F412CGUx Device from STM32F4 series
**                      1024Kbytes FLASH
**                      256Kbytes RAM
**
**                Set heap size, stack size and stack location according
**                to application requirements.
**
**                Set memory bank area and size if external memory is used
**
**  Target      : STMicroelectronics STM32
**
**  Distribution: The file is distributed as is, without any warranty
**                of any kind.
**
******************************************************************************
** @attention
**
** Copyright (c) 2022 STMicroelectronics.
** All rights reserved.
**
** This software is licensed under terms that can be found in the LICENSE file
** in the root directory of this software component.
** If no LICENSE file comes with this software, it is provided AS-IS.
**
******************************************************************************
*/
 
/* Entry Point */
ENTRY(Reset_Handler)
 
/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
 
_Min_Heap_Size = 0x800 ; /* required amount of heap */
_Min_Stack_Size = 0x1000 ; /* required amount of stack */
 
/* Memories definition */
MEMORY
{
  FLASH    (rx)    : ORIGIN = 0x8000000,   LENGTH = 1024K
  CLASSBRAM (rw)   : ORIGIN = 0x20000000, LENGTH = 0x80
  RAM    (xrw)    : ORIGIN = 0x20000080,   LENGTH = 256K - 128
}
 
/* Sections */
SECTIONS
{
  /* The startup code into "FLASH" Rom type memory */
  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >FLASH
 
  /* The program code and other data into "FLASH" Rom type memory */
  .text :
  {
    . = ALIGN(4);
    *(.text)           /* .text sections (code) */
    *(.text*)          /* .text* sections (code) */
    *(.glue_7)         /* glue arm to thumb code */
    *(.glue_7t)        /* glue thumb to arm code */
    *(.eh_frame)
 
    KEEP (*(.init))
    KEEP (*(.fini))
 
    . = ALIGN(4);
    _etext = .;        /* define a global symbols at end of code */
  } >FLASH
 
  /* Constant data into "FLASH" Rom type memory */
  .rodata :
  {
    . = ALIGN(4);
    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
    . = ALIGN(4);
  } >FLASH
 
  .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH /* NOT SAME!*/
 
  .ARM : {
    . = ALIGN(4);
    __exidx_start = .;
    *(.ARM.exidx*)
    __exidx_end = .;
    . = ALIGN(4);
  } >FLASH
 
  .preinit_array     :
  {
    . = ALIGN(4);
    PROVIDE_HIDDEN (__preinit_array_start = .);
    KEEP (*(.preinit_array*))
    PROVIDE_HIDDEN (__preinit_array_end = .);
    . = ALIGN(4);
  } >FLASH
 
  .init_array :
  {
    . = ALIGN(4);
    PROVIDE_HIDDEN (__init_array_start = .);
    KEEP (*(SORT(.init_array.*)))
    KEEP (*(.init_array*))
    PROVIDE_HIDDEN (__init_array_end = .);
    . = ALIGN(4);
  } >FLASH
 
  .fini_array :
  {
    . = ALIGN(4);
    PROVIDE_HIDDEN (__fini_array_start = .);
    KEEP (*(SORT(.fini_array.*)))
    KEEP (*(.fini_array*))
    PROVIDE_HIDDEN (__fini_array_end = .);
    . = ALIGN(4);
  } >FLASH
 
  /* Used by the startup to initialize data */
  _sidata = LOADADDR(.data);
 
  /* Initialized data sections into "RAM" Ram type memory */
  .data :
  {
    . = ALIGN(4);
    _sdata = .;        /* create a global symbol at data start */
    *(stm32fxx_STLstartup.o)
    *(.data)           /* .data sections */
    *(.data*)          /* .data* sections */
 
    . = ALIGN(4);
    _edata = .;        /* define a global symbol at data end */
 
  } >RAM AT> FLASH
  
  /* check sum specified by user at the end of program in flash NOT SAME */
  .check_sum :
  {
    . = ALIGN(64); /* alignement must correspond to the size of tested block at FLASH run time test */
    PROVIDE( _Check_Sum = . );
    /* check sum defined by user - see user manual */
    LONG(0x26D762AD);
  } >FLASH
  
  /* Uninitialized data section into "RAM" Ram type memory */
  . = ALIGN(4);
  .bss :
  {
    /* This is used by the startup in order to initialize the .bss section */
    _sbss = .;         /* define a global symbol at bss start */
    __bss_start__ = _sbss;
    *(.bss)
    *(.bss*)
    *(COMMON)
 
    . = ALIGN(4);
    _ebss = .;         /* define a global symbol at bss end */
    __bss_end__ = _ebss;
  } >RAM
 
  /* User_heap_stack section, used to check that there is enough "RAM" Ram  type memory left */
  ._user_heap_stack :
  {
    . = ALIGN(8);
    PROVIDE ( end = . );
    PROVIDE ( _end = . );
    . = . + _Min_Heap_Size;
    *(.stack_bottom)
    *(.stack_bottom*)
    . = . + _Min_Stack_Size;
    . = ALIGN(8);
  } >RAM
 
  /* User class B RAM region NOT SAME */
  ._user_classb(NOLOAD) :
  {
    . = ALIGN(4);
    *(.run_time_ram_buf)
    *(.run_time_ram_buf*)
    *(.run_time_ram_pnt)
    *(.run_time_ram_pnt*)
    
    . = ALIGN(4);
    PROVIDE(_classb_start = . );
    
    *(.class_b_ram)
    *(.class_b_ram*)
    . = ALIGN(4);
    *(.class_b_ram_rev)
    *(.class_b_ram_rev*)
    
    . = ALIGN(4);
    PROVIDE(_classb_end = . );
  } >CLASSBRAM
  
  /* Remove information from the compiler libraries */
  /DISCARD/ :
  {
    libc.a ( * )
    libm.a ( * )
    libgcc.a ( * )
  }
 
  .ARM.attributes 0 : { *(.ARM.attributes) }
}
/home/strngr/Projects/CubeStethoscope/STL_STM32-CUBEX-CLASSB/stm32fxx_STLparam.h:283:74: warning: implicit declaration of function '__libc_init_array' [-Wimplicit-function-declaration]
  283 |   #define GotoCompilerStartUp()  { Startup_Copy_Handler(); SystemInit(); __libc_init_array(); main(); }    /* entry to  main() */
      |                                                                          ^~~~~~~~~~~~~~~~~
../STL_STM32-CUBEX-CLASSB/src/stm32fxx_STLstartup.c:571:4: note: in expansion of macro 'GotoCompilerStartUp'
  571 |    GotoCompilerStartUp();
      |    ^~~~~~~~~~~~~~~~~~~
/home/strngr/Projects/CubeStethoscope/STL_STM32-CUBEX-CLASSB/stm32fxx_STLparam.h:283:95: warning: implicit declaration of function 'main' [-Wimplicit-function-declaration]
  283 |   #define GotoCompilerStartUp()  { Startup_Copy_Handler(); SystemInit(); __libc_init_array(); main(); }    /* entry to  main() */
      |                                                                                               ^~~~
../STL_STM32-CUBEX-CLASSB/src/stm32fxx_STLstartup.c:571:4: note: in expansion of macro 'GotoCompilerStartUp'
  571 |    GotoCompilerStartUp();
      |    ^~~~~~~~~~~~~~~~~~~
AMukh.3
Associate II

startup file

Petr Sladecek
ST Employee

Standard GCC assembly startup performs next steps prior calling main:

  • setup stack pointer
  • call Startup_Copy_Handler procedure (C data initialization at RAM)

<HERE WE MODIFY STANDARD SEQUENCE BY INSERTED CALL OF STL_StartUp() >

  • call System Init procedure and
  • call __libc_init_array
  • call main

The sense of GotoCompilerStartUp() macro called at the end of the STL_StartUp procedure execution ("artificially inserted" into standard assembly GCC startup flow) is to simulate repeating of the upper standard startup sequence again since begin because RAM content is destroyed completely after STL startup test. In fact, the macro should perform smooth standard restart of the C-level code and enter to the main. The only problem here is declaration of procedures defined at the assembly GCC startup flow level (normally not used from C-level).

Those are declaration warnings only. Are you able to run the code?

You can try to declare them as external at the STLparam header file.

Best regards,

Petr

AMukh.3
Associate II

Thank you for detailed explanation. Can you please explain what value should i use and how can i get it for CRC flash test?

What i've got during STL_StartUp rooting Hex:0x80ce49e1

And here is what i've set in linker script settings (i've got this value from examples of library):

  /* check sum specified by user at the end of program in flash NOT SAME */
  .check_sum :
  {
    . = ALIGN(64); /* alignement must correspond to the size of tested block at FLASH run time test */
    PROVIDE( _Check_Sum = . );
    /* check sum defined by user - see user manual */
    LONG(0x26D762AD);
  } >FLASH

I just cannot understand what does the following explanation in library documentation means (my case is GCC):

The result of the CRC calculation has to be compared with the corresponding reference pattern provided either automatically by compiler (IAR™ case) or added by the end user from a computation handled externally (MDK-Arm® and GCC cases).

Does it mean that i have to experimentally calculate the expected value and insert it in linker script variable?

Petr Sladecek
ST Employee

Hello, if you continue with the reading of the AN4435, you can learn just from the paragraph following the one you have copy pasted from this document that ST integration examples include specific project post build batch files (crc_gen_gcc.bat at your case) which modify the hex files and upend the checksum values automatically. At some latest compilers, there could problem to force the debugger just for loading the modified hex file (instead of the default one) when you want to entry debug mode. At this case you can use some other methods how to cope with CRC checksum during debug process. Please read carefully chapter 3.10 of the document where you can learn about DEBUG_CRC_CALCULATION parameter. Optionally you can reverse/modify final comparison of the crc result at the code, too, what just simply ignores wrong crc calculation result temporary during debugging your software.

Best regards,

Petr

AMukh.3
Associate II

Hello @Petr Sladecek​,

I've returned to this task and tried to run the Example project from 2.2.0 CLASSB library version.

For that needs i've reintegrated STM32L0xx_Nucleo for Nucleo-l053r8 board to CubeIDE where i'm suposed to run my main project and integrate this library.

But now i'm facing the issue:

After  control_flow_call(CRC32_TEST_CALLER) in STL_StartUp function on line 238 of example stm32fxx_STLstartup.c file i'm running into HardFault_Handler() with unknown for me reason.

1) I've tried running simple elf file, generated by the project, running project_CRC.hex file generated by bat file - but all of them stops at the same place.

2) Tried also to run from LSI/HSE, disabling IWDG, WWDG tests - all of it doen't help.

Can you please provide some recomendations on how to debug this error.

Current state of project on github: https://github.com/Mukhin22/nucleol053_classB_cubeide

P.S. is it possible to debug the .hex loaded file using standard debugger of CubeIDE(1.11.0)?

Thank you:)

Petr Sladecek
ST Employee

Hello,

as you can see from definition

/* Exported macro ------------------------------------------------------------*/

#define init_control_flow() CtrlFlowCntInv = ~(CtrlFlowCnt = 0uL)

#define control_flow_call(a) CtrlFlowCnt += (a)

#define control_flow_resume(a) CtrlFlowCntInv -= (a)

there is nothing more than quite simple servicing content of the "Class B pair" of variables dedicated to check the program flow. As the same macro has passed correctly already at line 197, there should be nothing wrong with allocation of these variables.

The L0 FW (v2.2.0) is quite obsolete, are you sure you have applied all the suggestions summarized at chapter 3.10 of the AN4435 concerning protection of the preserved CPU registers especially?

Hard fault is fatal error usually connected with some wrong memory access via corrupted pointer (e.g., overwritten CPU register). I suggest switching into disassembly window and trying to understand which and why concrete instruction fails.

Rgds,

Petr

AMukh.3
Associate II

@Petr Sladecek​ I was trying to edit assembly for this but i get following error in case i'm inserting this code as it's recomended in AN4435:

../Core/Src/stm32l0xx_STLcpurunGCC.s:80: Error: selected processor does not support `stmdb SP!,{R4,R5,R6,R7,R8,R9,R10,R11}' in Thumb mode
../Core/Src/stm32l0xx_STLcpurunGCC.s:299: Error: cannot honor width suffix -- `ldmia SP!,{R4,R5,R6,R7,R8,R9,R10,R11}'

And also in case when i'm trying to replace it with PUSH and POP commands i get the following error:

in case i'm using:

PUSH(POP) {R4, R5, R6, R7, R8, R9, R10, R11}
or
PUSH(POP) {R4-R11}

i get the following error:

../Core/Src/stm32l0xx_STLcpurunGCC.s:82: Error: cannot honor width suffix -- `push {R4,R5,R6,R7,R8,R9,R10,R11}'
../Core/Src/stm32l0xx_STLcpurunGCC.s:302: Error: cannot honor width suffix -- `pop {R4,R5,R6,R7,R8,R9,R10,R11}'

 https://developer.arm.com/documentation/dui0497/a/BABIAJHJ

i've found here that such command procedure could not be executed for Cortex-M0+ architecture (STM32L053 based on).