Jump to content

Ugfx with Chibistudio (Chibios) Embest STM32F4 BB


Sinalco94

Recommended Posts

Hello everyone,

I have got a problem. I am trying to setup a new Chibistudio Project with integrated ugfx for the Embest STM32F4 Discovery Base Board LCD. 
I followed the tutorial for "Using Chibistudio" on the Ugfx Website https://wiki.ugfx.io/index.php/Using_ChibiStudio

I just took the Embest Board files instead of the Mikromedia...

Now i tried to compile everything and I get two Errors:

undefined reference to `boardInit' '
undefined reference to 'pal_default_config'

I found out that there is a missing link in the makefile to the boardfile but I couldn't find where it is missing.
Here is my makefile:

# Possible Targets:	all clean Debug cleanDebug Release cleanRelease

##############################################################################################
# Settings
#

# General settings
	# See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables
	OPT_OS					= chibios
	OPT_THUMB				= yes
	OPT_LINK_OPTIMIZE		= no
	OPT_CPU					= stm32m4

# uGFX settings
	# See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables
	GFXLIB					= ../../ugfx
	GFXBOARD				= Embest-STM32-DMSTF4BB
	GFXDEMO					= modules/gdisp/basics

# ChibiOS settings
ifeq ($(OPT_OS),chibios)
	# See $(GFXLIB)/tools/gmake_scripts/os_chibios_x.mk for the list of variables
	CHIBIOS				= ../../chibios26
	CHIBIOS_VERSION		= 2
	CHIBIOS_BOARD		=
	CHIBIOS_PLATFORM	= STM32F4xx
	CHIBIOS_PORT		= GCC/ARMCMx/STM32F4xx
	CHIBIOS_LDSCRIPT	= STM32F407xG.ld
endif

##############################################################################################
# Set these for your project
#

ARCH     = arm-none-eabi-
SRCFLAGS = -ggdb -O0
CFLAGS   =
CXXFLAGS = -fno-rtti
ASFLAGS  =
LDFLAGS  =

SRC      =
OBJS     =
DEFS     =
LIBS     =
INCPATH  =
LIBPATH  =
LDSCRIPT =

##############################################################################################
# These should be at the end
#

include $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk
include $(GFXLIB)/tools/gmake_scripts/os_$(OPT_OS).mk
include $(GFXLIB)/tools/gmake_scripts/compiler_gcc.mk
# *** EOF ***


Can anyone help me with this?

Thank you.

Link to comment
Share on other sites

Hello @Sinalco94 and welcome to the µGFX community!

Could you please attach a plain text file containing the entire compiler & linker output of a clean build (make clean!) so we can have a look at that?

A couple of things come to mind in form of wild guesses:

  • Are you sure that you're using ChibiOS 2.6?
  • Did you enable the corresponding components (eg. PAL) in the halconfig.h of ChibiOS?
Link to comment
Share on other sites

Sorry I couldn't make it the last few days.

Here is the Complete Output.

 

09:11:33 **** Incremental Build of configuration Default for project EmbestLCD ****
make -j4 all 
.
C Compiler Options....
Linking .build/EmbestLCD.elf
arm-none-eabi-gcc -c -ggdb -O0 -mcpu=cortex-m4 -falign-functions=16 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -fomit-frame-pointer -Wall -Wextra -Wstrict-prototypes -fverbose-asm -MMD -MP -MF .build/dep/fakethumbfile.o.d -I. -I../../ugfx -I../../ugfx/3rdparty/tinygl-0.4-ugfx/include -I../../ugfx/boards/base/Embest-STM32-DMSTF4BB -I../../ugfx/drivers/gdisp/SSD2119 -I../../ugfx/demos/modules/gdisp/basics -I../../chibios26/os/ports/common/ARMCMx/CMSIS/include -I../../chibios26/os/ports/common/ARMCMx -I../../chibios26/os/ports/GCC/ARMCMx -I../../chibios26/os/ports/GCC/ARMCMx/STM32F4xx -I../../chibios26/os/kernel/include -I../../chibios26/os/hal/include -I../../chibios26/os/hal/platforms/STM32F4xx -I../../chibios26/os/hal/platforms/STM32 -I../../chibios26/os/hal/platforms/STM32/GPIOv2 -I../../chibios26/os/hal/platforms/STM32/I2Cv1 -I../../chibios26/os/hal/platforms/STM32/OTGv1 -I../../chibios26/os/hal/platforms/STM32/RTCv2 -I../../chibios26/os/hal/platforms/STM32/SPIv1 -I../../chibios26/os/hal/platforms/STM32/TIMv1 -I../../chibios26/os/hal/platforms/STM32/USARTv1 -DGFX_USE_CHIBIOS=TRUE -DGFX_USE_OS_CHIBIOS=TRUE -DCORTEX_USE_FPU=TRUE -DUSE_FPU=hard -DTHUMB_PRESENT -DTHUMB_NO_INTERWORKING -mthumb -DTHUMB fakethumbfile.c -o .build/obj/fakethumbfile.o
.
Linker Options........
arm-none-eabi-gcc -Wl,--defsym=__process_stack_size__=0x400 -Wl,--defsym=__main_stack_size__=0x400 -mcpu=cortex-m4 -falign-functions=16 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -nostartfiles -mthumb -T../../chibios26/os/ports/GCC/ARMCMx/STM32F4xx/ld/STM32F407xG.ld -lm .build/obj/fakethumbfile.o -o .build/EmbestLCD.elf
.
.build/obj/CHIBIOS/os/hal/src/hal.o: In function `halInit':
C:\ChibiStudio\workspace26\EmbestLCD/../../chibios26/os/hal/src/hal.c:127: undefined reference to `boardInit'
C:\ChibiStudio\workspace26\EmbestLCD/../../chibios26/os/hal/src/hal.c:128: undefined reference to `pal_default_config'
collect2.exe: error: ld returned 1 exit status
make: *** [.build/EmbestLCD.elf] Error 1

09:11:39 Build Finished (took 6s.747ms)

-> Yes I am sure that I use ChibiOS 2.6 but I don't know exactly what you mean with enabling all corresponding components. I didn't change anything in the halconfig.h

Link to comment
Share on other sites

I think you forgot to add the ChibiOS board files to your compilation tree and include path. Check out the \boards\base\Embest-STM32-DMSTF4BB\example_chibios_2.x directory inside the µGFX library. You'll find the ChibiOS board files that we used back then in there. pal_default_config and boardInit() are defined in there.

Link to comment
Share on other sites

  • 4 weeks later...

I have been on holidays the last few weeks so I couldn't work on my project until now.
I added the board.c and board.h file form \boards\base\Embest-STM32-DMSTF4BB\example_chibios_2.x to the compilation tree but it still doesn't work. How do I add it to the include path?

My Compilation tree looks like this:

Unbenannt.PNG.0fd838cec13724a950e68a4ef402e641.PNG

 

I couldn't find any solution to fix this problem. Could you please help me?

Link to comment
Share on other sites

Update: I was able to fix the problem. I just added #include "board.c" in the "hal.c" file.
Now everything compiles without any errors.

But now I have got another Problem. After Compiling and Debugging the LCD turns white.
I used the gfxdemo:

GFXDEMO					= modules/gdisp/basics

 

when i look at the main.c file I see that there should be something else instead of the white LCD Screen? 
Do i miss something? Do I have to include the STMPE811 Controller Files and the SSD2119?

Link to comment
Share on other sites

Hi @Sinalco94,

Once in a while I've tried to run the ugfx demos on the same board as you. I've had experienced some problems to run them, but luckily I was able to sort them. The last one you've mentioned (the white screen) seems familiar to me. Have you tried debugging the program? In my case, when I had white screens the program was stucked on a Hard Fault handler. The reason was that the linker script assigned few stack and process memory to the processor. Try to go to the STM32F407xG.ld (or similar, it depends on the processor - the path is C:\ChibiStudio\chibios26\os\ports\GCC\ARMCMx\STM32F4xx\ld in my case) and modify

__main_stack_size__     = 0x0200;
__process_stack_size__  = 0x0200;

with

__main_stack_size__     = 0x0800;
__process_stack_size__  = 0x0800;

Please notify me if that works for you.

 

Best wishes,

Leandro

Link to comment
Share on other sites

The previous advice may be correct for ChibiOS V2, but for V3 and later there's a different way to set stack sizes (and one of the names has changed), assuming your make file is based on the ChibiOS standard.

At the top of the project makefile, simply add any options you want to override; for example I have:

USE_LTO = no
USE_FPU	= no
USE_PROCESS_STACKSIZE = 0x600

(Using SSD1963, I didn't find any need to increase USE_EXCEPTIONS_STACKSIZE - it defaults to 0x400

Link to comment
Share on other sites

I tried the first tip I changed the stack_size to 0x0800, but now I got the info while debugging "Unable to match requested speed 8000 kHz, using 4000 kHz" So I changed the file back to default and I still get the message "Unable to match requested speed 8000 kHz, using 4000 kHz". 

The Debugger alwas stops at "_gdispInit();".

As I use ChibiOS V2 the first advice should be the right one. 
But it still doesn't work.

 

 

Edited by Sinalco94
Link to comment
Share on other sites

I'd recommend you to properly debug this. step through the code (eg. through gfxInit()) and figure out where it halts. Then, get a level deeper. There are literally hundreds of problems that can lead to this. It would already be helpful to know whether the driver finishes initialization and so on.

We are happy to help wherever we can, but we need to know what the actual issue is.

Link to comment
Share on other sites

Thanks for reply.

 

Update: I debugged the whole Project with :

__main_stack_size__     = 0x0800;
__process_stack_size_   = 0x0800;

but i added it to the makefile(LDFLAGS).

The Debugger always stops at the Hardware Reset in "gdisp_lld_SSD2119.c", at the second "gfxSleepMilliseconds(20)".

 

.Unbenannt.PNG.ab8efd4e04a1c593756ce3d1f734c0ae.PNG.



 

Link to comment
Share on other sites

What do you mean by "the debugger stops"? Are you getting a hard-fault or can you just not move to the next line? The latter would indicate that the delay is not properly working. As you are using ChibiOS/RT the gfxSleepMilliseconds() function is really just a wrapper around chThdSleepMilliseconds() (or whatever it is called these days).

Could you please try to run one or both of the GOS tests that you can find in the /demos/modules/GOS directory? Those tests only test the OS abstractions (eg. the threading and the delays). The GDISP module and all the other modules are completely disabled.

Link to comment
Share on other sites

There is no hard-fault, it just stops there and i can't move to the next line.

I tried to run threads and threads_advanced in the gos directory.

Both return an error, here is the output for threads:
 

make -j4 all 
.
Compiling ../../ugfx/demos/modules/gos/threads/main.c
C Compiler Options....
arm-none-eabi-gcc -c -ggdb -O0 -mcpu=cortex-m4 -falign-functions=16 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -fomit-frame-pointer -Wall -Wextra -Wstrict-prototypes -fverbose-asm -MMD -MP -MF .build/dep/fakethumbfile.o.d -I. -I../../ugfx -I../../ugfx/3rdparty/tinygl-0.4-ugfx/include -I../../ugfx/boards/base/Embest-STM32-DMSTF4BB -I../../ugfx/drivers/gdisp/SSD2119 -I../../ugfx/demos/modules/gos/threads -I../../chibios26/os/ports/common/ARMCMx/CMSIS/include -I../../chibios26/os/ports/common/ARMCMx -I../../chibios26/os/ports/GCC/ARMCMx -I../../chibios26/os/ports/GCC/ARMCMx/STM32F4xx -I../../chibios26/os/kernel/include -I../../chibios26/os/hal/include -I../../chibios26/os/hal/platforms/STM32F4xx -I../../chibios26/os/hal/platforms/STM32 -I../../chibios26/os/hal/platforms/STM32/GPIOv2 -I../../chibios26/os/hal/platforms/STM32/I2Cv1 -I../../chibios26/os/hal/platforms/STM32/OTGv1 -I../../chibios26/os/hal/platforms/STM32/RTCv2 -I../../chibios26/os/hal/platforms/STM32/SPIv1 -I../../chibios26/os/hal/platforms/STM32/TIMv1 -I../../chibios26/os/hal/platforms/STM32/USARTv1 -DGFX_USE_CHIBIOS=TRUE -DGFX_USE_OS_CHIBIOS=TRUE -DCORTEX_USE_FPU=TRUE -DUSE_FPU=hard -DTHUMB_PRESENT -DTHUMB_NO_INTERWORKING -mthumb -DTHUMB fakethumbfile.c -o .build/obj/fakethumbfile.o
.
Linker Options........
In file included from ../../chibios26/os/kernel/include/ch.h:110:0,
                 from ../../ugfx/src/gos/gos_chibios.h:18,
                 from ../../ugfx/src/gos/gos.h:483,
                 from ../../ugfx/gfx.h:200,
                 from ../../ugfx/demos/modules/gos/threads/main.c:1:
./chconf.h:531:0: warning: "CORTEX_USE_FPU" redefined
 #define CORTEX_USE_FPU                  FALSE
 ^
<command-line>:0:0: note: this is the location of the previous definition
arm-none-eabi-gcc -Wl,--defsym=__process_stack_size__=0x0800 -Wl,--defsym=__main_stack_size__=0x0800 -Wl,--defsym=__process_stack_size__=0x400 -Wl,--defsym=__main_stack_size__=0x400 -mcpu=cortex-m4 -falign-functions=16 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -nostartfiles -mthumb -T../../chibios26/os/ports/GCC/ARMCMx/STM32F4xx/ld/STM32F407xG.ld -lm .build/obj/fakethumbfile.o -o .build/Embest.elf
.
../../ugfx/demos/modules/gos/threads/main.c:13:3: warning: #warning "You must alter this demo to define a DEBUGWRITE macro for your platform." [-Wcpp]
  #warning "You must alter this demo to define a DEBUGWRITE macro for your platform."
   ^
../../ugfx/demos/modules/gos/threads/main.c:14:3: warning: #warning "Be careful of using C library functions as they sometimes crash if they are not expecting stack changes (if possible use a multi-thread aware C library)" [-Wcpp]
  #warning "Be careful of using C library functions as they sometimes crash if they are not expecting stack changes (if possible use a multi-thread aware C library)"
   ^
../../ugfx/demos/modules/gos/threads/main.c:15:3: warning: #warning "You might flash LED's instead if that is better for your platform." [-Wcpp]
  #warning "You might flash LED's instead if that is better for your platform."
   ^
../../ugfx/demos/modules/gos/threads/main.c:16:3: error: #error "--"
  #error "--"
   ^
../../ugfx/demos/modules/gos/threads/main.c: In function 'heartbeat1':
../../ugfx/demos/modules/gos/threads/main.c:24:6: warning: implicit declaration of function 'DEBUGWRITE' [-Wimplicit-function-declaration]
      DEBUGWRITE("thread 1\n");
      ^
make: *** [.build/obj/GFXLIB/demos/modules/gos/threads/main.o] Error 1

and here for threads_advanced:

make -j4 all 
.
C Compiler Options....
Compiling ../../ugfx/demos/modules/gos/threads_advanced/main.c
arm-none-eabi-gcc -c -ggdb -O0 -mcpu=cortex-m4 -falign-functions=16 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -fomit-frame-pointer -Wall -Wextra -Wstrict-prototypes -fverbose-asm -MMD -MP -MF .build/dep/fakethumbfile.o.d -I. -I../../ugfx -I../../ugfx/3rdparty/tinygl-0.4-ugfx/include -I../../ugfx/boards/base/Embest-STM32-DMSTF4BB -I../../ugfx/drivers/gdisp/SSD2119 -I../../ugfx/demos/modules/gos/threads_advanced -I../../chibios26/os/ports/common/ARMCMx/CMSIS/include -I../../chibios26/os/ports/common/ARMCMx -I../../chibios26/os/ports/GCC/ARMCMx -I../../chibios26/os/ports/GCC/ARMCMx/STM32F4xx -I../../chibios26/os/kernel/include -I../../chibios26/os/hal/include -I../../chibios26/os/hal/platforms/STM32F4xx -I../../chibios26/os/hal/platforms/STM32 -I../../chibios26/os/hal/platforms/STM32/GPIOv2 -I../../chibios26/os/hal/platforms/STM32/I2Cv1 -I../../chibios26/os/hal/platforms/STM32/OTGv1 -I../../chibios26/os/hal/platforms/STM32/RTCv2 -I../../chibios26/os/hal/platforms/STM32/SPIv1 -I../../chibios26/os/hal/platforms/STM32/TIMv1 -I../../chibios26/os/hal/platforms/STM32/USARTv1 -DGFX_USE_CHIBIOS=TRUE -DGFX_USE_OS_CHIBIOS=TRUE -DCORTEX_USE_FPU=TRUE -DUSE_FPU=hard -DTHUMB_PRESENT -DTHUMB_NO_INTERWORKING -mthumb -DTHUMB fakethumbfile.c -o .build/obj/fakethumbfile.o
.
Linker Options........
arm-none-eabi-gcc -Wl,--defsym=__process_stack_size__=0x0800 -Wl,--defsym=__main_stack_size__=0x0800 -Wl,--defsym=__process_stack_size__=0x400 -Wl,--defsym=__main_stack_size__=0x400 -mcpu=cortex-m4 -falign-functions=16 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -nostartfiles -mthumb -T../../chibios26/os/ports/GCC/ARMCMx/STM32F4xx/ld/STM32F407xG.ld -lm .build/obj/fakethumbfile.o -o .build/Embest.elf
In file included from ../../chibios26/os/kernel/include/ch.h:110:0,
                 from ../../ugfx/src/gos/gos_chibios.h:18,
                 from ../../ugfx/src/gos/gos.h:483,
                 from ../../ugfx/gfx.h:200,
                 from ../../ugfx/demos/modules/gos/threads_advanced/main.c:41:
./chconf.h:531:0: warning: "CORTEX_USE_FPU" redefined
 #define CORTEX_USE_FPU                  FALSE
 ^
<command-line>:0:0: note: this is the location of the previous definition
.
../../ugfx/demos/modules/gos/threads_advanced/main.c:56:3: warning: #warning "You must alter this demo to define a DEBUGWRITE macro for your platform." [-Wcpp]
  #warning "You must alter this demo to define a DEBUGWRITE macro for your platform."
   ^
../../ugfx/demos/modules/gos/threads_advanced/main.c:57:3: warning: #warning "Be careful of using C library functions as they sometimes crash if they are not expecting stack changes (if possible use a multi-thread aware C library)" [-Wcpp]
  #warning "Be careful of using C library functions as they sometimes crash if they are not expecting stack changes (if possible use a multi-thread aware C library)"
   ^
../../ugfx/demos/modules/gos/threads_advanced/main.c:58:3: warning: #warning "You might flash LED's instead if that is better for your platform." [-Wcpp]
  #warning "You might flash LED's instead if that is better for your platform."
   ^
../../ugfx/demos/modules/gos/threads_advanced/main.c:59:3: error: #error "--"
  #error "--"
   ^
../../ugfx/demos/modules/gos/threads_advanced/main.c: In function 'Thread_function':
../../ugfx/demos/modules/gos/threads_advanced/main.c:73:3: warning: implicit declaration of function 'DEBUGWRITE' [-Wimplicit-function-declaration]
   DEBUGWRITE("Message from Thread\n");
   ^
make: *** [.build/obj/GFXLIB/demos/modules/gos/threads_advanced/main.o] Error 1

 

Link to comment
Share on other sites

On ‎7‎/‎06‎/‎2017 at 11:14, Sinalco94 said:

Update: I was able to fix the problem. I just added #include "board.c" in the "hal.c" file.
Now everything compiles without any errors.

You should not do this. It will work but altering the ChibiOS source files will give you alot of trouble (same goes for altering the µGFX source files).
The proper way of adding the board.c file is adding:

SRC		=	board.c

in your Makefile.

55 minutes ago, Sinalco94 said:

Do I understand that right that I have to change the macro "DEBUGWRITE" to something that is compatible to my platform?

Yes, the purpose of the debugwrite is to indicate that the thread is working and sleeps correctly every 500/900ms. As mentioned in the main.c you could blink a led as that is far easier than writing to a file.

For the errors you must remove the error message from the main.c file because it will always throw the error otherwise.
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...