Forum: Compiler & IDEs STM32 UART - Compiler Problem


von STM32 UART - Compiler Problem (Gast)


Lesenswert?

Hallo zusammen,

ich bin mit meinem Mikrocontroller Projekt im Thema UART weitergekommen.

Ich habe mich in das Thema eingelesen und mir mit dem STM32CubeMX das 
Grundgerüst dafür erstellen lassen.

das Problem ist jetzt nur beim kompiliern in meiner Entwicklungsumgebung 
(JumpStart C) bekomme ich an folgender Stelle einen Fehler:
1
/**************************************************************************//**
2
 * @file     core_cm4.h
3
 * @brief    CMSIS Cortex-M4 Core Peripheral Access Layer Header File
4
 * @version  V4.30
5
 * @date     20. October 2015
6
 ******************************************************************************/
7
/* Copyright (c) 2009 - 2015 ARM LIMITED
8
9
   All rights reserved.
10
   Redistribution and use in source and binary forms, with or without
11
   modification, are permitted provided that the following conditions are met:
12
   - Redistributions of source code must retain the above copyright
13
     notice, this list of conditions and the following disclaimer.
14
   - Redistributions in binary form must reproduce the above copyright
15
     notice, this list of conditions and the following disclaimer in the
16
     documentation and/or other materials provided with the distribution.
17
   - Neither the name of ARM nor the names of its contributors may be used
18
     to endorse or promote products derived from this software without
19
     specific prior written permission.
20
   *
21
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
   ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25
   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
   POSSIBILITY OF SUCH DAMAGE.
32
   ---------------------------------------------------------------------------*/
33
34
35
#if   defined ( __ICCARM__ )
36
 #pragma system_include         /* treat file as system include file for MISRA check */
37
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
38
  #pragma clang system_header   /* treat file as system include file */
39
#endif
40
41
#ifndef __CORE_CM4_H_GENERIC
42
#define __CORE_CM4_H_GENERIC
43
44
#include <stdint.h>
45
46
#ifdef __cplusplus
47
 extern "C" {
48
#endif
49
50
/**
51
  \page CMSIS_MISRA_Exceptions  MISRA-C:2004 Compliance Exceptions
52
  CMSIS violates the following MISRA-C:2004 rules:
53
54
   \li Required Rule 8.5, object/function definition in header file.<br>
55
     Function definitions in header files are used to allow 'inlining'.
56
57
   \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
58
     Unions are used for effective representation of core registers.
59
60
   \li Advisory Rule 19.7, Function-like macro defined.<br>
61
     Function-like macros are used to allow more efficient code.
62
 */
63
64
65
/*******************************************************************************
66
 *                 CMSIS definitions
67
 ******************************************************************************/
68
/**
69
  \ingroup Cortex_M4
70
  @{
71
 */
72
73
/*  CMSIS CM4 definitions */
74
#define __CM4_CMSIS_VERSION_MAIN  (0x04U)                                      /*!< [31:16] CMSIS HAL main version */
75
#define __CM4_CMSIS_VERSION_SUB   (0x1EU)                                      /*!< [15:0]  CMSIS HAL sub version */
76
#define __CM4_CMSIS_VERSION       ((__CM4_CMSIS_VERSION_MAIN << 16U) | \
77
                                    __CM4_CMSIS_VERSION_SUB           )        /*!< CMSIS HAL version number */
78
79
#define __CORTEX_M                (0x04U)                                      /*!< Cortex-M Core */
80
81
82
#if   defined ( __CC_ARM )
83
  #define __ASM            __asm                                      /*!< asm keyword for ARM Compiler */
84
  #define __INLINE         __inline                                   /*!< inline keyword for ARM Compiler */
85
  #define __STATIC_INLINE  static __inline
86
87
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
88
  #define __ASM            __asm                                      /*!< asm keyword for ARM Compiler */
89
  #define __INLINE         __inline                                   /*!< inline keyword for ARM Compiler */
90
  #define __STATIC_INLINE  static __inline
91
92
#elif defined ( __GNUC__ )
93
  #define __ASM            __asm                                      /*!< asm keyword for GNU Compiler */
94
  #define __INLINE         inline                                     /*!< inline keyword for GNU Compiler */
95
  #define __STATIC_INLINE  static inline
96
97
#elif defined ( __ICCARM__ )
98
  #define __ASM            __asm                                      /*!< asm keyword for IAR Compiler */
99
  #define __INLINE         inline                                     /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
100
  #define __STATIC_INLINE  static inline
101
102
#elif defined ( __TMS470__ )
103
  #define __ASM            __asm                                      /*!< asm keyword for TI CCS Compiler */
104
  #define __STATIC_INLINE  static inline
105
106
#elif defined ( __TASKING__ )
107
  #define __ASM            __asm                                      /*!< asm keyword for TASKING Compiler */
108
  #define __INLINE         inline                                     /*!< inline keyword for TASKING Compiler */
109
  #define __STATIC_INLINE  static inline
110
111
#elif defined ( __CSMC__ )
112
  #define __packed
113
  #define __ASM            _asm                                      /*!< asm keyword for COSMIC Compiler */
114
  #define __INLINE         inline                                    /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */
115
  #define __STATIC_INLINE  static inline
116
117
#else
118
  #error Unknown compiler
119
#endif

die Zeile

#error Unknown compiler

wird mir dabei ausgegeben.

Ich stell mir jetzt die Frage, warum muss ich hier etwas auswählen ?

Die Software kompiliert standardmäßig mit "ImageCraft Cortex Compiler".

Muss ich hier etwas anderes auswählen ? Weil eigentlich will ich schon 
bei diesem Compiler bleiben.


Danke für Hilfe.

von PaSi (Gast)


Lesenswert?

Moin,

du wirst wohl einen der unterstützen Compile nutzen müssen (z.B. Armgcc) 
oder das File so anpassen das dein Compiler auch zugelassen wird.

Gruß

von STM32 UART - Compiler Problem (Gast)


Angehängte Dateien:

Lesenswert?

Klappt immer noch nicht. Welchen würdest du aus der Liste empfehlen ?

von Niklas G. (erlkoenig) Benutzerseite


Lesenswert?

STM32 UART - Compiler Problem schrieb im Beitrag #5532488:
> Klappt immer noch nicht.
Sicher, dass es mit Auswählen getan ist? Muss der nicht auch installiert 
werden?

STM32 UART - Compiler Problem schrieb im Beitrag #5532488:
> Welchen würdest du aus der Liste empfehlen ?
Die GNU Compiler (GCC) sind weit verbreitet.

Versuche es vielleicht mal mit dem mittlerweile kostenlosen Atollic True 
Studio, das funktioniert direkt mit STM32CubeMX und bringt auch den 
Compiler mit.

von W.S. (Gast)


Lesenswert?

STM32 UART - Compiler Problem schrieb im Beitrag #5532488:
> Klappt immer noch nicht. Welchen würdest du aus der Liste empfehlen ?

Ich würde dir empfehlen, als Allererstes all dieses CMSIS Zeugs und auch 
das von Cube erzeugte Zeugs vorläufig wegzulassen. Falls du das später 
tatsächlich benötigen solltest, dann kannst du das DANN noch immer dort 
einbinden, wo du es wirklich brauchen solltest.

Aber nach dem, was du gepostet hast, scheiterst du ja schon an der 
beschränkten Compilerauswahl, die die Autoren so vorgesehen haben.

Ansonsten schmeiß einfach das "unknown compiler raus und ersetze es 
durch
#define __ASM     __asm
#define __INLINE  inline
#define __STATIC_INLINE  static inline

und guck dann, ob und wo dein Compiler sich über eine ihm nicht passende 
Syntax beklagt.

Merke dir an diesem Beispiel, wie ein wirklich SCHLECHTER Quellcode 
aussieht - nämlich genau so wie dieser (ganz egal ob er von ARM 
höchstselbst kommt oder von Hein Blöd).

Dieser ganze Affentanz mit ganzen Breitseiten von #ifdef und Konsorten 
schafft nur Konstrukte, die den Code sowohl unleserlich als auch 
fehleranfällig machen.

Nochmal: Pfeife ertsmal auf hinzukopiertes und automatisch generiertes 
und schreib am Anfang dein Zeugs ohne solches. Bei den von den diversen 
Herstellern dargebotenen riesengroß aufgeblasenen Chip-Header-Files 
(sowas wie z.B. STM32F10Xall.h) wirst du ohnehin mit sowas belästigt. 
Auch dort wäre es für dich weitaus einfacher, dir die 
HW-Register-Adressen aus dem RefManual zu entnehmen oder so eine 
aufgetakelte .h rigoros zu editieren und allen überflüssigen Schmonzes 
rauszuschmeißen.

Wenn du das NICHT tust, dann wirst du zu 90% gegen IDE, Toolchain und 
Herstellerfiles kämpfen müssen und nur 10% deiner Kraft für deine 
eigentliche Aufgabe haben - und zum schluß wirst du feststellen müssen, 
daß man dir ja doch einen Ring durch die Nase gezogen hat, um dich 
dorthin zu zerren, wo andere dich hinhaben wollen.

W.S.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.