cancel
Showing results for 
Search instead for 
Did you mean: 

IEC60355_STM8AS_V1.1.0, periodic RAM test error

FordFairlane
Associate III
Posted on February 23, 2015 at 18:27

I'm running

ST library IEC60335 STM8AS v1.1.0 in a STM8S105C6.

RAM March X periodic test is failing, I think there is an error in the library.

Class B RAM (from

CLASS_B_START=0x10 to CLASS_B_END=0x7F) is checked from TIM4 interrupt by ''ClassBTestStatus STL_TranspMarchX(void)'' function.

Firstly it copies 6 bytes from Class B RAM to RunTimeRamBuf[RT_RAM_BUF_SIZE]  @ ''RUN_TIME_RAM_CHCK''. Section RUN_TIME_RAM_CHCK is placed at 0x00-0x0F.

This is the loop that copies 6 bytes from Class B RAM to RunTimeRamBuf:

/* ------------------ Regular memory Self-check ----------------------- */

/*---------------------------- STEP 1 --------------------------------- */

     

/* Save the content of the 6 bytes to be tested and start MarchC-

 

         Write background with addresses increasing */

p_StartRamBlock

=

p_RunTimeRamChk;

p_EndRamBlock  

=

p_RunTimeRamChk

+

RT_RAM_BLOCKSIZE;

i

=

1u

;

do

{

               

RunTimeRamBuf[i

++

]

=

*

p_RunTimeRamChk;

               

*

p_RunTimeRamChk

++

=

BCKGRND;

}

while

(p_RunTimeRamChk

<

p_EndRamBlock);

p_StartRamBlock and p_EndRamBlock  are local variables placed at virtual registers (0x80…).

p_RunTimeRamChk is a global variable placed at Class B RAM, my linker places it @0x10. This variable is used in the above  loop that copies Class B RAM and then writes BCKGRND  (=0) in it, so the loop is writing to the variable that controls the loop. Result: it starts copying 6 bytes from 0x10 to 0x01 and writing 0 from 0x10 to 0x15, but when the loop writes 0 in 0x10 it is writing 0 in p_RunTimeRamChk. The loop copies more than 6 bytes and RAM is corrupted.

Is there an error in this library certified by VDE????

Regards

6 REPLIES 6
jdf25252
Associate II
Posted on February 24, 2015 at 17:57

p_RunTimeRamChk & its inversion should be placed OUTSIDE the ''CLASS_B'' sections precisely because of the problem you're seeing. 

jdf

FordFairlane
Associate III
Posted on February 26, 2015 at 09:56

OK John, but this variable is placed inside class B RAM in the ST library. Maybe it must be there because it is mandatory. I use a local variable that holds its value while RAM is being tested.

I think there are more errors, the loop writes outside class B RAM, so RAM is again corrupted, etc.

I hope it is my mistake, or I can't believe this library is VDE certified.

Best regards

jdf25252
Associate II
Posted on February 26, 2015 at 17:46

Here is a snippet from stm8s_stl_classB_var.h where p_RunTimeRamChk and its inversion are definitely declared in section .RUN_TIME_BUF..   I'm quite confidant in the library itself (I have one project certified under UL60730 using it & another in progress) however the demo projects as provided by ST seem to leave out some important stuff.  For example the Cosmic demo projects stm8_903.stp and stm8s_105.stp do not declare the RUN_TIME_BUF section.  Not to mention changing the linker files around which I've always found a particular challenge.  I use Cosmic for stm8 & st7 development so cannot offer opinions on others.  (well I could and often do, but they'd be of no value).

If you continue to have difficulty send a copy of your project file(*.stp) and any changes you've made to stl_classB_var.h & I'd be happy to take a look.

Have fun

jdf

/**

  ******************************************************************************

  * @file stm8s_stl_classB_var.h

  * @brief This file contains definition all class B variables

  * @author STMicroelectronics - MCD Application Team

  * @version V1.1.0

  * @date MAY-2012

  ******************************************************************************

  * @copyright

  *

  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>

  *

  * Licensed under MCD-ST Liberty SW License Agreement V2, (the ''License'');

  * You may not use this file except in compliance with the License.

  * You may obtain a copy of the License at:

  *

  *        http://www.st.com/software_license_agreement_liberty_v2

  *

  * Unless required by applicable law or agreed to in writing, software

  * distributed under the License is distributed on an ''AS IS'' BASIS,

  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  * See the License for the specific language governing permissions and

  * limitations under the License.

  */

/* Define to prevent recursive inclusion -------------------------------------*/

#ifndef __STL_CLASS_B_VAR_H

#define __STL_CLASS_B_VAR_H

#include ''stm8s_stl_param.h''

/* This avoids having mutiply defined global variables */

#ifdef ALLOC_GLOBALS

#define EXTERN

#else

#define EXTERN extern

#endif

/* Includes ------------------------------------------------------------------*/

/* Exported types ------------------------------------------------------------*/

/* Exported constants --------------------------------------------------------*/

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

/* Exported functions ------------------------------------------------------- */

/* Global variables --------------------------------------------------------- */

  /* Temporary RAM buffer used during transparent run-time tests */

  /* WARNING: Real reserved RAM location from 0x.... to 0x.... */

  /* ==============================================================================*/

  /* MISRA violation of rule 8.5 - Class B variables are defined at one place only

     defined just at begin of stm8l_stl_startup.c file, all other files include this

     header as a common reference */

#ifdef _IAR_

  #pragma diag_suppress=Pm123

#endif /* _IAR_ */

#ifdef _COSMIC_

#pragma section @near [RUN_TIME_BUF]

  /* Buffer to store original RAM content during run-time tests */

    EXTERN @near u8 RunTimeRamBuf[RT_RAM_BUF_SIZE];

  /* RAM pointer for run-time tests */

    EXTERN @near u8 *p_RunTimeRamChk;

    EXTERN @near u8 *p_RunTimeRamChkInv;

#ifdef STL_VERBOSE

    EXTERN @near u16 FreqDifDisplay;    // Not really a Class B variable, but useful for debugging

#endif /* STL_VERBOSE */

#pragma section @near [CLASS_B]

 

  EXTERN NEAR u16 MarchOverlayGap;    /* gap in memory due to March test overlay */

FordFairlane
Associate III
Posted on February 26, 2015 at 18:23

Thank you John

Variables are defined for 3 compilers and they are placed in different sections, the Cosmic definition seems good, but take a look at the IAR definition:

#ifdef

_IAR_

      EXTERN

__near

u8 RunTimeRamBuf[RT_RAM_BUF_SIZE]  @

''RUN_TIME_RAM_CHCK''

;

 

/* RAM pointer for run-time tests */

      EXTERN

__near

u8

*

p_RunTimeRamChkB               @

''CLASS_B_RAM''

;

      EXTERN

__near

u8

*

p_RunTimeRamChkInv             @

''CLASS_B_RAM_REV''

;

#ifdef

STL_VERBOSE

    EXTERN

__near

u16 FreqDifDisplay;   

/* Not reallya Class B variable, but useful for debugging */

#endif

/* STL_VERBOSE */

      EXTERN NEAR   u16 MarchOverlayGap                @

''CLASS_B_RAM''

;     

/* gap in memory due to March test overlay */

      EXTERN

__near

u16 CtrlFlowCnt                    @

''CLASS_B_RAM''

;  

/* program flow execution at start */

      EXTERN

__near

u16 ISRCtrlFlowCnt                 @

''CLASS_B_RAM''

;

/* program flow execution in interrupt */

      EXTERN

__near

u16 LSI_HSIStartUpFreqkHz          @

''CLASS_B_RAM''

;

/* First measure LSI over HSI stored */

      EXTERN

__near

u16 LSI_HSEStartUpFreqkHz          @

''CLASS_B_RAM''

;

/* First measure LSI over HSE stored */

      EXTERN

__near

u16 LSI_StartUpPeriod              @

''CLASS_B_RAM''

;

/* Initial measure of LSI - reference for run-time checks */

      EXTERN

__near

u16 TickCounter                    @

''CLASS_B_RAM''

;

/* Sofware time base used in main program (SysTick ISR) */

      EXTERN

__near

volatile

u8 TimeBaseFlag           @

''CLASS_B_RAM''

;

/* Indicates to the main routine a 100ms tick */

      EXTERN

__near

u16 LastCtrlFlowCnt                @

''CLASS_B_RAM''

;

/* Control flow counter from one main loop to the other */

      EXTERN

__near

const

u8

*

p_RunCrc16Chk            @

''CLASS_B_RAM''

;

/* Pointer to FLASH for crc16 run-time tests */

      EXTERN

__near

u16 CurrentCrc16                   @

''CLASS_B_RAM''

;     

/* Current FLASH 16-bit Crc */

      EXTERN

__near

u16 CurrentDesc                    @

''CLASS_B_RAM''

;     

/* Current Descriptor Address */

      EXTERN

__near

u16 CRCBlockIndex                  @

''CLASS_B_RAM''

;     

/* Counter needed for partial CRC test */

      EXTERN NEAR   u16 MarchOverlayGap_               @

''CLASS_B_RAM''

;     

/* gap in memory due to March test overlay */

      EXTERN

__near

volatile

u8 StackOverFlowPtrn[

4

]   @

''STACK_BOTTOM''

;

/* Magic pattern for Stack overflow in this array */

      EXTERN NEAR   u16 MarchOverlayGapInv             @

''CLASS_B_RAM_REV''

;

      EXTERN

__near

u16 CtrlFlowCntInv                 @

''CLASS_B_RAM_REV''

;

      EXTERN

__near

u16 ISRCtrlFlowCntInv              @

''CLASS_B_RAM_REV''

;

      EXTERN

__near

u8  LSI_HSIStartUpFreqkHzInv       @

''CLASS_B_RAM_REV''

;

      EXTERN

__near

u8  LSI_HSEStartUpFreqkHzInv       @

''CLASS_B_RAM_REV''

;

      EXTERN

__near

u16 LSI_StartUpPeriodInv           @

''CLASS_B_RAM_REV''

;

      EXTERN

__near

u16 TickCounterInv                 @

''CLASS_B_RAM_REV''

;

      EXTERN

__near

volatile

u8 TimeBaseFlagInv        @

''CLASS_B_RAM_REV''

;

      EXTERN

__near

u16 LastCtrlFlowCntInv             @

''CLASS_B_RAM_REV''

;

      EXTERN

__near

const

u8

*

p_RunCrc16ChkInv         @

''CLASS_B_RAM_REV''

;

      EXTERN

__near

u16 CurrentCrc16Inv                @

''CLASS_B_RAM_REV''

;

      EXTERN

__near

u16 CurrentDescInv                 @

''CLASS_B_RAM_REV''

;

      EXTERN

__near

u16 CRCBlockIndexInv               @

''CLASS_B_RAM_REV''

;

      EXTERN NEAR   u16 MarchOverlayGapInv_            @

''CLASS_B_RAM_REV''

;

#endif

 

/* _IAR_ */

I think

p_RunTimeRamChkB

placement is wrong for IAR compiler.

Should I use Cosmic compiler?

Best regards

jdf25252
Associate II
Posted on February 27, 2015 at 18:28

Hi

When I read your post my initial reaction was to recommend you use the compiler you're most familiar with.  But after looking at the IAR parts more closely I'm not sure.  If you're looking for certification under UL they won't blindly accept the VDE certificate so you could fix the IAR stuff though I'm not sure where I'd start as I've only used IAR with the Samsung Sam8.

I'm using Rev1.0.3 which was current when I started & going through UL had to test everything anyway so the lack of VDE wasn't an issue.  I did try to compile the demo projects for Rev1.1.0.  Only the 103 & 207_208 would build.  The 105 & 903 errored out at link time because segment RUN_TIME_BUF isn't defined. Easily fixable though.

This is typical of my experience with ST provided code.  Not well documented & tested and best avoided if you can.  STVD though is my favorite IDE.  Of course I only use it for compiling & debugging but rarely use foul language while doing so.

I'm really sorry I couldn't give you some definitive answer.  Use Cosmic if you can, the 16k free version is good. 

jdf

jdf25252
Associate II
Posted on February 27, 2015 at 20:48

ALSO

in stm8s_stl_param.h at line 314

/* Constants necessary for Transparent March tests */

#define CL_B_START  0x10u   /* memory area dedicated for Class B variables */

#define CL_B_END    0x7fu

These'll need to be adjusted to account for load address in different projects/compilers

jdf