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_3
I will add details in case I forgot something.
Giovanni
[INFO] ChibiOS 2.6->3.0 porting guide
- 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: [INFO] ChibiOS 2.6->3.0 porting guide
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)
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)
- 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: [INFO] ChibiOS 2.6->3.0 porting guide
Thanks, changes done, if you find obsolete descriptions could you write them all in ticket or here on the forum?
Giovanni
Giovanni
Re: [INFO] ChibiOS 2.6->3.0 porting guide
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.
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
Hi ,
please tell how to port application which use fatfs binding ? i do not see fatfs_binding in various directory ? is it deprecated?
please tell how to port application which use fatfs binding ? i do not see fatfs_binding in various directory ? is it deprecated?
- 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: [INFO] ChibiOS 2.6->3.0 porting guide
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:
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:
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
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?
- 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: [INFO] ChibiOS 2.6->3.0 porting guide
Probably a stack overflow, are debug options enabled?
You don't have to use LTO, it must work either ways.
Giovanni
You don't have to use LTO, it must work either ways.
Giovanni
Return to “Development and Feedback”
Who is online
Users browsing this forum: No registered users and 9 guests