Page 1 of 4
[INFO] ChibiOS 2.6->3.0 porting guide
Posted: Wed May 07, 2014 1:52 pm
by Giovanni
Hi,
I wrote a small guide about porting ChibiOS code/drivers from 2.6 to 3.0.
http://www.chibios.org/dokuwiki/doku.ph ... rom_2_to_3I will add details in case I forgot something.
Giovanni
Re: [INFO] ChibiOS 2.6->3.0 porting guide
Posted: Thu May 15, 2014 8:05 am
by steved
A few suggested additions:
1. Note that VirtualTimer becomes virtual_timer_t (as an example of a multi-word type)
2. chSemInit() becomes chSemObjectInit()
3. Return codes such as RDY_OK have become MSG_OK
(and some of the documentation in the code still shows the old values)
Re: [INFO] ChibiOS 2.6->3.0 porting guide
Posted: Thu May 15, 2014 8:48 am
by Giovanni
Thanks, changes done, if you find obsolete descriptions could you write them all in ticket or here on the forum?
Giovanni
Re: [INFO] ChibiOS 2.6->3.0 porting guide
Posted: Tue May 20, 2014 12:23 pm
by steved
Little one, partly reflecting use of LTO in some makefiles.
In testhal\STM32\STM32F4XX\RTC there are stubs for _kill(), _getpid(), _exit()
a) In the general case, they need to be prefixed with __attribute__((used)) otherwise if LTO is enabled they get optimised out and the linker can't find them.
b) _exit() is a 'noreturn' function, so should lock up in a loop:
__attribute__((used))void _exit(int status)
{
(void)status;
while (1) {
;
}
}
c) Not sure that the stubs are necessary in that particular example - they only appear to be needed if including C++ code.
On a related issue, a little note on use of C++ files would be helpful - I thought there was one somewhere, but can't find it. IIRC if instantiating objects at runtime you can just add the .cpp file to the correct section of the makefile, and add the stubs mentioned above.
Re: [INFO] ChibiOS 2.6->3.0 porting guide
Posted: Wed May 28, 2014 10:20 am
by steved
In the I2C driver, the 'I2CD_XXX' status/error codes have become 'I2C_XXX'
Re: [INFO] ChibiOS 2.6->3.0 porting guide
Posted: Wed Jun 25, 2014 12:48 pm
by Legath
Hi ,
please tell how to port application which use fatfs binding ? i do not see fatfs_binding in various directory ? is it deprecated?
Re: [INFO] ChibiOS 2.6->3.0 porting guide
Posted: Wed Jun 25, 2014 1:05 pm
by Giovanni
Hi,
Just not yet ported over 3.0, see:
viewtopic.php?f=2&t=1991
Re: [INFO] ChibiOS 2.6->3.0 porting guide
Posted: Fri Jun 27, 2014 6:11 pm
by part1zan_
I have a not-so-obvious comment regarding threads in ChibiOS/RT 3.x.
In 2.x, a thread like this will work just fine:
Code: Select all
static WORKING_AREA(waBtnThread, 128);
static msg_t BtnThread(void *arg) {
(void) arg;
chRegSetThreadName("btn");
while (TRUE) {
while (!palReadPad(GPIOB, GPIOB_BTN1)) {
// Here we do nothing, and everything works just fine <--- LOOK HERE
}
if (period <= 50) {
period = 1000;
} else {
period = period/2;
}
chThdSleepMilliseconds(250);
}
return 0;
}
In 3.x, this thread would lock everything up when BTN1 is not pressed. To make it work, add something like chTndSleepMilliseconds(1) instead of the comment containing 'LOOK HERE'. Thus, the working one for 3.x will look like this:
Code: Select all
static THD_WORKING_AREA(waBtnThread, 128);
static THD_FUNCTION(BtnThread, arg) {
(void) arg;
chRegSetThreadName("btn");
while (TRUE) {
while (!palReadPad(GPIOB, GPIOB_BTN1)) {
chThdSleepMilliseconds(1);
}
if (period <= 50) {
period = 1000;
} else {
period = period/2;
}
chThdSleepMilliseconds(250);
}
return 0;
}
Re: [INFO] ChibiOS 2.6->3.0 porting guide
Posted: Fri Jun 27, 2014 6:13 pm
by part1zan_
Also, are there any problems if I don't want to use LTO? What exactly will not be fine if I don't use it?
Re: [INFO] ChibiOS 2.6->3.0 porting guide
Posted: Fri Jun 27, 2014 6:14 pm
by Giovanni
Probably a stack overflow, are debug options enabled?
You don't have to use LTO, it must work either ways.
Giovanni