Помощь - Поиск - Пользователи - Календарь
Полная версия этой страницы: STM32F4/F3 Discovery getting started problems
Форум разработчиков электроники ELECTRONIX.ru > Cистемный уровень проектирования > Операционные системы > scmRTOS
devnow
First of all hi all together,
I don't speak any Russian so I will stick to English (or swissGerman :b ) apologizes in advance for any inconvenience. Google/~N~s~A~ (automatic translation) was a big help for navigating/reading through this forum.

I started to play around with scmRTOS, I like the cleanness of the source and the liberal licences, it may be possible to use it in future commercial projects. But right now it is more a private side project to get in touch with C++ bare metal microcontroller programming.

I "ported" scmRTOS to the STM32F3 Discovery Board (based on F4, no fancy Template/Bitband GPIO handling yet) but it didn't work at the beginning, so I switched to the F4 and used the provided sample code (EventFlag). This worked very well as long as I used the included Makefile, but my one configuration (GCC ARM Embedded 4.7 update 2 https://launchpad.net/gcc-arm-embedded, Eclipse 4.3, CDT, GDB HW Debug, OpenOCD 0.7) always made problems. I compared compiler/linker flags and Include paths and so on until I found the problem. The code doesn't work if you set optimization to zero with the -O0 flag.
If you disable the compiler optimization (OPTIMIZE = -O0 Flag) follow errors occur:
1) Error during linking (tested with my own configuration and the makefile provided with scmRTOS)
CODE
--- linking...
./obj/main.o: In function `Pin<(char)68, 15, (char)72, (PinSpeed)3>::SetMode(PinMode)':
C:\xyz\scmrtos-code-581-trunk\Samples\CortexM4F\GCC\STM32F4XX\1-EventFlag/../SamplesCommon/pin_stm32F4xx.h:485: undefined reference to `Pin<(char)68, 15, (char)72, (PinSpeed)3>::BBBits'
C:\xyz\scmrtos-code-581-trunk\Samples\CortexM4F\GCC\STM32F4XX\1-EventFlag/../SamplesCommon/pin_stm32F4xx.h:485: undefined reference to `Pin<(char)68, 15, (char)72, (PinSpeed)3>::BBBits'
C:\xyz\scmrtos-code-581-trunk\Samples\CortexM4F\GCC\STM32F4XX\1-EventFlag/../SamplesCommon/pin_stm32F4xx.h:486: undefined reference to `Pin<(char)68, 15, (char)72, (PinSpeed)3>::BBBits'
C:\xyz\scmrtos-code-581-trunk\Samples\CortexM4F\GCC\STM32F4XX\1-EventFlag/../SamplesCommon/pin_stm32F4xx.h:486: undefined reference to `Pin<(char)68, 15, (char)72, (PinSpeed)3>::BBBits'

This one of multiple similar errors message block, for Pin D15 and D14. As sone as I increase Optimization -O1 or -O3 the code works

2) Program stays in a infinity loop in TKernel::sched() (teseted only with my own configuration for STM32F4 [I disabled all LEDs and use brake points to test the functionality for the F4] and F3 because I haven't setup the openocd debugger for the original scmRTOS makefile)
CODE
do
{
enable_context_switch();
DUMMY_INSTR();
disable_context_switch();
}
while(CurProcPriority != SchedProcPriority); // until context switch done

The program is calling each Process once and than stops to make any context switches. I couldn't nail down the source of the problem sad.gif, I increased the Stack size for each Process (including Idle) to 2KByte but the problem remains. SchedProcPriority is in Register r3 for comparing with r2 (CurProcPriority). r2 has a value of 0 and r3 has a value of 0x20002f14 which looks more like a address to the RAM. Checking the map file it is indeed in the OS::Kernel Object.
CODE
.bss._ZN2OS6KernelE
0x20002f14 0x14 ./scmRTOS/Common/OS_Kernel.o
0x20002f14 OS::Kernel


As soon as I increase the Optimization Level back to -O3 both errors as gone and scmRTOS is working with my configuration and the original scmRTOS makefile.

I know I'm not a big help here. First -O0 optimization level is more a theoretical setting but it may point to a time critical code section which may can be triggered by a bad cache flushing/interrupt occurrence. Any suggestion is highly appreciated.
Second I need to go back to school to get my C programming brain ready for Object Oriented Programming. Implementations like TCritSect cs; is just neat, no room for errors, simple to understand.

Greetings
Jonathan

PS:
My configuration: Windows 7, Eclipse Kepler with CDT, GDB HW Debug, GNU ARM CDT support and EmbSys Register View Plugin, OpenOCD 0.7 as gdb server, GCC ARM Embedded 4.7 update 2 (4.7 2013q2) from launchpad, STM32F3/F4 Development board, EventFlag Sample Code, FPU activated in HW and sometimes in SW (#define PROC1_FPA)
AHTOXA
Hi, Jonathan, glad to see you here!
I just never tested scmRTOS sample projects with -O0 setting, because I do not use -O0 at all:)
First group of errors you get is from pin.h code, which is not part of OS. You can avoid this errors by not using pin.h (and you did it).
But error with looping in TKernel::sched() is more serious. It seems that OS internal logic is broken.
This is because of fact that scmRTOS is not supposed to work with -O0 optimization level. It uses a inline functions very intensively.
There is a number of posts in this forum where people got problems trying to run scmRTOS with optimization turned off.
I suggest you not to use -O0.
devnow
Thanks for the information Anton, I need to dig a little deeper into the GNU GCC optimization and the scmRTOS inline code.

In brief for other users:
Don't use Optimization Level None -O0
I successfully run scmRTOS on STM32F3 and F4 (both Cortex M4F) with Optimization Level -O1 to -O3

Link to the same problem for other ports (AVR):
http://electronix.ru/forum/lofiversion/index.php/t47036.html

Is it possible to change the name of the Topic to Solved/отвя́занный? sm.gif : ... I haven't found the Edit Button for the Topic.

Thanks
AHTOXA
Цитата(devnow @ Sep 15 2013, 16:08) *
Is it possible to change the name of the Topic to Solved/отвя́занный? sm.gif : ... I haven't found the Edit Button for the Topic.

Editing is allowed only within short period of time after message creation (1 or 2 hours for new users, AFAIK).
PS. Solved = "решено" sm.gif
Для просмотра полной версии этой страницы, пожалуйста, пройдите по ссылке.
Invision Power Board © 2001-2025 Invision Power Services, Inc.