I already have been successful to use ChibiOS with the STM32F103 and STMF411 pills.
But I currently struggle a bit with this board :
https://stm32-base.org/boards/STM32F407VET6-STM32F4XX-M
My board version uses a STM32F407VGT6.
I’ve copied the RT-STMF4-discovery example project, which has the same MCU, and started to setup the board with the board configuration tool, as I did for my other projects.
I’ve simplified it as the simplest possible, just starting the OS and blink the LED.
The HAL and MCU config also the simplest, with only PAL activated.
The sleep in the main function is 1000ms, and the blinker is 500ms ON and 500ms OFF.
When I debug the program, I see the first sleep in the main is executed correctly, but when it comes to the first sleep of the blinker thread, the board reboots as I can see it executes again the init function where I set a breakpoint.
It seems to fail when the context switch happens as I can enter the context switch function.
Code: Select all
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "ch.h"
#include "hal.h"
/*
* This is a periodic thread that does absolutely nothing except flashing
* a LED.
*/
static THD_WORKING_AREA(waThread1, 128);
static THD_FUNCTION(Thread1, arg) {
(void)arg;
chRegSetThreadName("HeartBeat");
while (true) {
palSetPad(GPIOA, GPIOA_ONBOARD_LED_D2); /* green. */
chThdSleepMilliseconds(500);
palClearPad(GPIOA, GPIOA_ONBOARD_LED_D2); /* green. */
chThdSleepMilliseconds(500);
}
}
/*
* Application entry point.
*/
int main(void) {
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
chSysInit();
/*
* Creates the example thread.
*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO - 1, Thread1, NULL);
/*
* Normal main() thread activity, in this demo it does nothing except
* sleeping in a loop and check the button state.
*/
while (true) {
/*palWaitLineTimeout(PAL_LINE(GPIOA, GPIOA_ONBOARD_BUTTON_K1), TIME_INFINITE);*/
chThdSleepMilliseconds(1000);
}
}
If I set the sleep in the main function is 100ms and the blinker to both 50ms, the program runs fine.
According to the website above, the HSE osc is 16Mhz.
Whereas the F4 discovery has a 8Mhz osc.
It would be better if I read correctly the specs....
Could it come from this difference ?
Could the PLL setup is totally to rethink in this case ?
I have just dumbly copied the mcuconf.h from the F4 disco.
Or would it have another reason ?
The option bytes show a HW or SW watchdog option.
I’ve modified it, but seems to have no effect here.
Any suggestion to debug it would be very welcome.
Thank you very much.