Bug after commit 12752 Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
0x3333
Posts: 57
Joined: Thu Mar 07, 2019 10:19 pm
Has thanked: 7 times
Been thanked: 6 times

Bug after commit 12752  Topic is solved

Postby 0x3333 » Thu May 02, 2019 6:48 pm

After commit #12752(Fixed bug #1027), I'm unable to compile my project with CH_DBG_ENABLE_STACK_CHECK enabled.

Code: Select all

In file included from ./lib/chibios/os/common/ports/ARMCMx/chcore.h:195,
                 from ./lib/chibios/os/rt/include/ch.h:110,
                 from ./lib/chibios/os/common/ports/ARMCMx/chcore_v7m.c:28:
./lib/chibios/os/common/ports/ARMCMx/chcore_v7m.c: In function '_port_set_region':
./lib/chibios/os/common/ports/ARMCMx/mpu.h:209:3: error: 'MPU' undeclared (first use in this function); did you mean 'MPU_H'?
   MPU->RNR  = ((uint32_t)region);                                           \
   ^~~
./lib/chibios/os/common/ports/ARMCMx/chcore_v7m.c:127:3: note: in expansion of macro 'mpuSetRegionAddress'
   mpuSetRegionAddress(PORT_USE_MPU_REGION,
   ^~~~~~~~~~~~~~~~~~~
./lib/chibios/os/common/ports/ARMCMx/mpu.h:209:3: note: each undeclared identifier is reported only once for each function it appears in
   MPU->RNR  = ((uint32_t)region);                                           \
   ^~~
./lib/chibios/os/common/ports/ARMCMx/chcore_v7m.c:127:3: note: in expansion of macro 'mpuSetRegionAddress'
   mpuSetRegionAddress(PORT_USE_MPU_REGION,
   ^~~~~~~~~~~~~~~~~~~
make[1]: *** [out/obj/chcore_v7m.o] Error 1

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Bug after commit 12752

Postby Giovanni » Thu May 02, 2019 8:53 pm

Hi,

I am unable to reproduce the problem.

"MPU" is exported by CMSIS headers. Are you using those included with ChibiOS?

Giovanni

0x3333
Posts: 57
Joined: Thu Mar 07, 2019 10:19 pm
Has thanked: 7 times
Been thanked: 6 times

Re: Bug after commit 12752

Postby 0x3333 » Thu May 02, 2019 8:57 pm

Well, I believe so, I did not change anything in my build since this commit.

Here is my makefile, maybe something missing:

Code: Select all

##############################################################################
# Build global options
# NOTE: Can be overridden externally.
#

# Compiler options here.
ifeq ($(USE_OPT),)
   USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
endif

# C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),)
   USE_COPT =
endif

# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
   USE_CPPOPT = -fno-rtti
endif

# Enable this if you want the linker to remove unused code and data.
ifeq ($(USE_LINK_GC),)
   USE_LINK_GC = yes
endif

# Linker extra options here.
ifeq ($(USE_LDOPT),)
   USE_LDOPT =
endif

# Enable this if you want link time optimizations (LTO).
ifeq ($(USE_LTO),)
   USE_LTO = yes
endif

# Enable this if you want to see the full log while compiling.
ifeq ($(USE_VERBOSE_COMPILE),)
   USE_VERBOSE_COMPILE = no
endif

# If enabled, this option makes the build process faster by not compiling
# modules not used in the current configuration.
ifeq ($(USE_SMART_BUILD),)
   USE_SMART_BUILD = yes
endif

#
# Build global options
##############################################################################

##############################################################################
# Architecture or project specific options
#

# Stack size to be allocated to the Cortex-M process stack. This stack is
# the stack used by the main() thread.
ifeq ($(USE_PROCESS_STACKSIZE),)
   USE_PROCESS_STACKSIZE = 0x400
endif

# Stack size to the allocated to the Cortex-M main/exceptions stack. This
# stack is used for processing interrupts and exceptions.
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
   USE_EXCEPTIONS_STACKSIZE = 0x400
endif

# Enables the use of FPU (no, softfp, hard).
ifeq ($(USE_FPU),)
   USE_FPU = no
endif

# FPU-related options.
ifeq ($(USE_FPU_OPT),)
   USE_FPU_OPT = -mfloat-abi=$(USE_FPU) -mfpu=fpv4-sp-d16
endif

#
# Architecture or project specific options
##############################################################################

##############################################################################
# Project, target, sources and paths
#

# Define project name here
PROJECT = TEMPLATE

# Target settings.
MCU  = cortex-m3

# Imported source files and paths.
LIBDIR    := ./lib
CONFDIR   := ./cfg
RESDIR    := ./res
SRCDIR    := ./src
SRCINCDIR := ./inc
BUILDDIR  := ./out
DEPDIR    := ./.dep
CHIBIOS   := $(LIBDIR)/chibios

# Licensing files.
include $(CHIBIOS)/os/license/license.mk
# Startup files.
include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f1xx.mk
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
# Board files.
include $(CHIBIOS)/os/hal/ports/STM32/STM32F1xx/platform.mk
include $(CHIBIOS)/os/hal/boards/STM32F103C8_MINIMAL/board.mk
# RTOS files (optional).
include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Other files (optional).
include $(CHIBIOS)/os/hal/lib/streams/streams.mk
# Project
include app.mk

LDSCRIPT = $(RESDIR)/STM32F103xB_BOOT.ld

# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CSRC =   $(ALLCSRC) \
      $(TESTSRC) \
      $(SRCDIR)/main.c \
      $(APPSRC)

# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CPPSRC = $(ALLCPPSRC)

# List ASM source files here.
ASMSRC = $(ALLASMSRC)

# List ASM with preprocessor source files here.
ASMXSRC = $(ALLXASMSRC)

# Inclusion directories.
INCDIR = $(CONFDIR) $(SRCINCDIR) $(ALLINC) $(TESTINC) $(APPINC)

# Define C warning options here.
CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes

# Define C++ warning options here.
CPPWARN = -Wall -Wextra -Wundef

#
# Project, target, sources and paths
##############################################################################

##############################################################################
# Start of user section
#

# List all user C define here, like -D_DEBUG=1
UDEFS = -D_DEBUG=TRUE

# Define ASM defines here
UADEFS = $(UDEFS)

# List all user directories here
UINCDIR =

# List the user directory to look for the libraries here
ULIBDIR =

# List all user libraries here
ULIBS =

#
# End of user section
##############################################################################

##############################################################################
# Common rules
#

RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
include $(RULESPATH)/arm-none-eabi.mk
include $(RULESPATH)/rules.mk

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Bug after commit 12752

Postby Giovanni » Thu May 02, 2019 9:02 pm

Could you try to add stack check to one of the M4 demos and try to compile? just to check if it is something missing or an environment difference.

You are also specifying PORT_ENABLE_GUARD_PAGES, right?

Giovanni

0x3333
Posts: 57
Joined: Thu Mar 07, 2019 10:19 pm
Has thanked: 7 times
Been thanked: 6 times

Re: Bug after commit 12752

Postby 0x3333 » Thu May 02, 2019 9:08 pm

Building the demos/STM32/RT-STM32F429-DISCOVERY works OK when enabling CH_DBG_ENABLE_STACK_CHECK.

No, I'm not specifying PORT_ENABLE_GUARD_PAGES. It is FALSE per default.

Same error as mine when building MapleMini demo:

Code: Select all

$ chibios/demos/STM32/RT-STM32F103-MAPLEMINI $ make
Compiler Options
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -DUSE_MAPLEMINI_BOOTLOADER= -ffunction-sections -fdata-sections -fno-common -flto -Wall -Wextra -Wundef -Wstrict-prototypes -Wa,-alms=./build/lst/ -DCORTEX_USE_FPU=FALSE -MD -MP -MF ./.dep/build.d -I. -I./cfg -I../../../os/license -I../../../os/common/portability/GCC -I../../../os/common/startup/ARMCMx/compilers/GCC -I../../../os/common/startup/ARMCMx/devices/STM32F1xx -I../../../os/common/ext/ARM/CMSIS/Core/Include -I../../../os/common/ext/ST/STM32F1xx -I../../../os/hal/include -I../../../os/hal/ports/common/ARMCMx -I../../../os/hal/ports/STM32/STM32F1xx -I../../../os/hal/ports/STM32/LLD/CANv1 -I../../../os/hal/ports/STM32/LLD/DACv1 -I../../../os/hal/ports/STM32/LLD/DMAv1 -I../../../os/hal/ports/STM32/LLD/GPIOv1 -I../../../os/hal/ports/STM32/LLD/I2Cv1 -I../../../os/hal/ports/STM32/LLD/RTCv1 -I../../../os/hal/ports/STM32/LLD/SDIOv1 -I../../../os/hal/ports/STM32/LLD/SPIv1 -I../../../os/hal/ports/STM32/LLD/TIMv1 -I../../../os/hal/ports/STM32/LLD/USARTv1 -I../../../os/hal/ports/STM32/LLD/USBv1 -I../../../os/hal/ports/STM32/LLD/xWDGv1 -I../../../os/hal/boards/MAPLEMINI_STM32_F103 -I../../../os/hal/osal/rt-nil -I../../../os/rt/include -I../../../os/oslib/include -I../../../os/common/ports/ARMCMx -I../../../os/common/ports/ARMCMx/compilers/GCC -I./source/ -I../../../os/hal/lib/streams -I../../../os/various/shell -I../../../test/lib -I../../../test/rt/source/test -I../../../test/oslib/source/test main.c -o main.o

Compiling crt0_v7m.S
Compiling vectors.S
Compiling chcoreasm_v7m.S
Compiling crt1.c
Compiling hal.c
Compiling hal_st.c
Compiling hal_buffers.c
Compiling hal_queues.c
Compiling hal_flash.c
Compiling hal_mmcsd.c
Compiling hal_pal.c
Compiling hal_serial_usb.c
Compiling hal_usb.c
Compiling nvic.c
Compiling stm32_isr.c
Compiling hal_lld.c
Compiling hal_efl_lld.c
Compiling stm32_dma.c
Compiling hal_pal_lld.c
Compiling hal_st_lld.c
Compiling hal_usb_lld.c
Compiling board.c
Compiling osal.c
Compiling chsys.c
Compiling chdebug.c
Compiling chtrace.c
Compiling chvt.c
Compiling chschd.c
Compiling chthreads.c
Compiling chregistry.c
Compiling chsem.c
Compiling chmtx.c
Compiling chcond.c
Compiling chevents.c
Compiling chmsg.c
Compiling chdynamic.c
Compiling chmboxes.c
Compiling chmemcore.c
Compiling chmemheaps.c
Compiling chmempools.c
Compiling chpipes.c
Compiling chfactory.c
Compiling chcore.c
Compiling chcore_v7m.c
In file included from ../../../os/common/ports/ARMCMx/chcore.h:195,
                 from ../../../os/rt/include/ch.h:110,
                 from ../../../os/common/ports/ARMCMx/chcore_v7m.c:28:
../../../os/common/ports/ARMCMx/chcore_v7m.c: In function '_port_set_region':
../../../os/common/ports/ARMCMx/mpu.h:209:3: error: 'MPU' undeclared (first use in this function); did you mean 'MPU_H'?
   MPU->RNR  = ((uint32_t)region);                                           \
   ^~~
../../../os/common/ports/ARMCMx/chcore_v7m.c:127:3: note: in expansion of macro 'mpuSetRegionAddress'
   mpuSetRegionAddress(PORT_USE_MPU_REGION,
   ^~~~~~~~~~~~~~~~~~~
../../../os/common/ports/ARMCMx/mpu.h:209:3: note: each undeclared identifier is reported only once for each function it appears in
   MPU->RNR  = ((uint32_t)region);                                           \
   ^~~
../../../os/common/ports/ARMCMx/chcore_v7m.c:127:3: note: in expansion of macro 'mpuSetRegionAddress'
   mpuSetRegionAddress(PORT_USE_MPU_REGION,
   ^~~~~~~~~~~~~~~~~~~
make: *** [build/obj/chcore_v7m.o] Error 1

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Bug after commit 12752

Postby Giovanni » Thu May 02, 2019 9:22 pm

Ah OK, now I can reproduce the problem thanks, it is an error in the conditional expression.

Code: Select all

#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) ||                                  \
    (PORT_ENABLE_GUARD_PAGES == TRUE) ||                                    \
    defined(__DOXYGEN__)
/**
 * @brief   Setting up MPU region for the current thread.
 */
void _port_set_region(void) {

  mpuSetRegionAddress(PORT_USE_MPU_REGION,
                      chThdGetSelfX()->wabase);
}
#endif


It should be an &&...

It is only triggered when the device does not have an MPU, I will open a ticket about this.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Bug after commit 12752

Postby Giovanni » Sat May 04, 2019 9:26 am

Hi,

Fixed as bug #1028.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 40 guests