Tag Archives: MCU

[Solved] STM8L151 IAR Project Compile Error: Fatal Error[Pe035]: #error directive: “Please select first the target STM8L…

Project scenario:

STM8L151G4XX MCU IAR engineering compilation error


Problem description

Fatal Error[Pe035]: #error directive: “Please select first the target STM8L device used in your application (in stm8l15x.h file)”
Open stm8l15x.h, and we can see the following code:

#if !defined (STM8L15X_MD) && !defined (STM8L15X_MDP) && !defined (STM8L15X_HD) && !defined (STM8L15X_LD) \
&& !defined (STM8L05X_LD_VL) && !defined (STM8L05X_MD_VL) && !defined (STM8L05X_HD_VL) && !defined (STM8AL31_L_MD)
 #error "Please select first the target STM8L device used in your application (in stm8l15x.h file)"
#endif
/* Uncomment the line below according to the target STM8L15x device used in your
   application
  */
/* #define STM8L15X_LD */     /*!< STM8L15X_LD: STM8L15x Low density devices */
/* #define STM8L15X_MD */     /*!< STM8L15X_MD: STM8L15x Medium density devices */
/* #define STM8L15X_MDP */    /*!< STM8L15X_MDP: STM8L15x Medium density plus devices */
/* #define STM8L15X_HD */     /*!< STM8L15X_HD: STM8L15x/16x High density devices */
/* #define STM8L05X_LD_VL */  /*!< STM8L05X_LD_VL: STM8L051xx3 Low density value line devices */
/* #define STM8L05X_MD_VL */  /*!< STM8L05X_MD_VL: STM8L052xx6 Medium density value line devices */
/* #define STM8L05X_HD_VL */  /*!< STM8L05X_HD_VL: STM8L052xx8 High density value line devices */
/* #define STM8AL31_L_MD */   /*!< STM8AL31_L_MD: STM8AL3x Medium density devices */


/*  Tip: To avoid modifying this file each time you need to switch between these
        devices, you can define the device in your toolchain compiler preprocessor.

 - Low density STM8L15x devices are STM8L151C3, STM8L151K3, STM8L151G3, STM8L151F3,
   STM8L151C2, STM8L151K2, STM8L151G2 and STM8L151F2 microcontrollers where the 
   Flash memory density ranges between 4 and 8 Kbytes.
 - Medium density STM8L15x devices are STM8L151C4, STM8L151C6, STM8L152C4,
   STM8L152C6, STM8L151K4, STM8L151K6, STM8L152K4, STM8L152K6, STM8L151G4,
   STM8L151G6, STM8L152G4 and STM8L152G6 microcontrollers where the Flash memory
   density ranges between 16 and 32 Kbytes.
 - Medium density Plus devices are STM8L151R6, STM8L152R6 microcontrollers where
  the Flash memory density is fixed and equal to 32 Kbytes and a wider range of
  peripheral than the medium density devices.
 - High density STM8L15x devices are STM8L151x8, STM8L152x8, STM8L162R8 and STM8L162M8
   microcontrollers where the Flash memory density is fixed and equal to 64 Kbytes with 
   the same peripheral set than Medium Density Plus devices.
 - Value line low density STM8L05xx devices are STM8L051x3 microcontrollers
   with 8-KB Flash
 - Value line medium density STM8L05xx devices are STM8L052x6 microcontrollers 
   with 32-KB Flash
 - Value line high density STM8L05xx devices: STM8L052x8 microcontrollers
   with 64-KB Flash
 - Medium density STM8AL31xx/STM8AL3Lxx devices: STM8AL3168, STM8AL3166, 
   STM8AL3148,STM8AL3146, STM8AL3138, STM8AL3136, STM8AL3L68, STM8AL3L66, 
   STM8AL3L48, STM8AL3L46 microcontrollers with 8-KB, 16-KB or 32-KB Flash
 */

Solution:

Method 1:
Modify directly in the stm8l15x.h file, delete the comment symbols of the macro definition needed, take STM8L151G4XX as an example, according to the above description, the model belongs to Medium density.

/* Uncomment the line below according to the target STM8L15x device used in your
   application
  */
/* #define STM8L15X_LD */     /*!< STM8L15X_LD: STM8L15x Low density devices */
 #define STM8L15X_MD   		/*!< STM8L15X_MD: STM8L15x Medium density devices */
/* #define STM8L15X_MDP */    /*!< STM8L15X_MDP: STM8L15x Medium density plus devices */
/* #define STM8L15X_HD */     /*!< STM8L15X_HD: STM8L15x/16x High density devices */
/* #define STM8L05X_LD_VL */  /*!< STM8L05X_LD_VL: STM8L051xx3 Low density value line devices */
/* #define STM8L05X_MD_VL */  /*!< STM8L05X_MD_VL: STM8L052xx6 Medium density value line devices */
/* #define STM8L05X_HD_VL */  /*!< STM8L05X_HD_VL: STM8L052xx8 High density value line devices */
/* #define STM8AL31_L_MD */   /*!< STM8AL31_L_MD: STM8AL3x Medium density devices */

Method 2:
Set the path: Options->C/C++ Compiler->Preprocessor-Defined symbols

[Solved] cortex_M3 freeRTOS Error: undefined reference to `_sbrk‘

Background: When cortex_m3 uses FreeRTOS to enable the running time statistics function.

Compilation error during compilation:

/Data/user_ Home//build_ Tools/GCC arm none eabi-/bin// Lib/gcc/arm-none-eabi/6.2.1/../../../../..// Arm-none-eabi/lib/thumb/v7-m/libc A (lib_a-sbrkr.o): in function`_ Sbrk_ R’:

Sbrkr c: (.Text.\u sbrk_r+0xc): undefined reference to`_ Sbrk’

Collect2: error: LD returned 1 exit status

Makefile:155: recipe for target’all’failed

Make: * * * [all] error 1


Cause: by default, arm GCC uses startfiles, which results in link compilation failure when calling some functions (malloc, free, sprintf…) that are not implemented at the bottom.

Promotion: if the compiler reports Error: undefined reference to `_sbrk’ `_read’ `_write’ `_lseek’ `_isatty’ `_fstat’ , it is the same reason.


Solution:

Method 1: if the project does not need these functions, find the direct mask function.

Method 2: once and for all. The link fails because these functions are not implemented, so you can rewrite these underlying functions or add library files with these functions, such as libnosys a. Add compilation parameter —specs=nosys.specs can be used.

After adding, if the compiler reports the following errors:

/Data/user_ Home/ /build_ Tools/GCC arm none eabi-/bin// Lib/gcc/arm-none-eabi/6.2.1/../../../../..// Arm-none-eabi/lib/thumb/v7-m/libnosys A (sbrk.o): in function`_ Sbrk’:

Sbrk c: (.Text.\u sbrk+0x18): undefined reference to `end’

Collect2: error: LD returned 1 exit status

Makefile:155: recipe for target’all’failed

Make: * * * [all] error 1

This is because the ‘end’ symbol is not defined in the .lds linker script, so find the project’s xx.lds file to set that script for the heap location, e.g.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
.heap :
{
. = ALIGN(4);
__HEAP_START = .;
. += 0x2000; __HEAP_MAX = .;
end = __HEAP_MAX;
PROVIDE(end = .);
} > ram
.heap : { . = ALIGN(4); __HEAP_START = .; . += 0x2000; __HEAP_MAX = .; end = __HEAP_MAX; PROVIDE(end = .); } > ram
  .heap :

  {

    . = ALIGN(4);

    __HEAP_START = .;

    . += 0x2000; __HEAP_MAX = .;

    end = __HEAP_MAX;

     PROVIDE(end = .);

  } > ram

[Solved] Rtthread DCM component dcm_cache_save interface Error: mkdir:/data failed

The rtthread dcm data persistence component was used in the project, but mkdir:/data failed was reported during dcm_cache_save

But this error log is not the code of this project, it is confirmed that it is the log printed inside the dcm interface

Then confirmed that the macro #define DCM_DEFAULT_STORAGE_NAME “/user/data/db/dcm” is already in rtconfig.h

Declare that this macro is also useful for business code at system startup

The final investigation is because dcm_default_storage_name needs to be assigned when the system starts, and the dcm_strg.o of the dcm component depends on

If this variable is not assigned, it will default to mkdir:/data, but if /data has no permission, it will report that error.

So dcm_default_storage_name = DCM_DEFAULT_STORAGE_NAME is solved (it needs to be called at startup)

How to Solve Keil Error: error: #29: expected an expression

About the solution of error: #29: expected an expression

Recently, a keil project was created, and an error occurred during compilation: #29: expected an expression

This problem is because keil MDK uses C90 by default. You need to modify the configuration to support C99 to solve this problem.

The specific solutions are as follows:

Magic Wand --> C/C++ --> Check 'C99 Mode' on the right to confirm  

Finally, recompile:

- 0 Error(s), 0 Warning(s).

<info> peer_manager_handler: Connection security failed

During the development of Nordic 52810, after the softdevice is re written, when nrfconnect for Mobile Connect is used, the connection fails, and the mobile phone displays peer removed pairing information. Device side log information:

< info> peer_ manager_ handler: Connection security failed: role: Peripheral, conn_ handle: 0x0, procedure: Encryption, error: 4102

Solution: in the Bluetooth settings of the mobile phone, find the device to be connected, select “ignore this device”, and re connect with nrfconnect. Success!

The firmware of the connected j-link does not support the following memory access)

directory
1. Encountered
2. Resolution


recently my tutor gave me a project related to UWB, using stm32 chip. When I downloaded The program with Keil5, The J-Link driver detected all that could be done, but ran out of The Firmware of The connected J-link does not support The following memory access. Later consult the elder brother also is to encounter this kind of problem for the first time, then turn to omnipotent Internet, discover also have similar problem.

(you can see that there is already a j-link driver in the device manager)

(Keil5’s magic wand can also be detected, note the DLL)


(download program, two error, mentality explosion)
2. When The firmware of The connected j-link does not support The following memory access, I received a second error (Flash download faied-taget DLL has been cancelled). Therefore, I tried to find out The reason from The DLL.
also refers to a lot of big guys’ solutions, basically is to replace the jlinkarm. DLL under the installation path of Keil5 with jlinkarm. DLL under the j-link installation path. So I tried it myself, and it worked.


(after modifying the DLL, it was ok)

later when using uwb serial port debugging, it was very happy to see that the data could be successfully sent!