[INFO] ChibiOS 2.6->3.0 porting guide

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
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:

[INFO] ChibiOS 2.6->3.0 porting guide

Postby Giovanni » Wed May 07, 2014 1:52 pm

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

steved
Posts: 825
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: [INFO] ChibiOS 2.6->3.0 porting guide

Postby steved » Thu May 15, 2014 8:05 am

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)

User avatar
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

Postby Giovanni » Thu May 15, 2014 8:48 am

Thanks, changes done, if you find obsolete descriptions could you write them all in ticket or here on the forum?

Giovanni

steved
Posts: 825
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: [INFO] ChibiOS 2.6->3.0 porting guide

Postby steved » Tue May 20, 2014 12:23 pm

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.

steved
Posts: 825
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: [INFO] ChibiOS 2.6->3.0 porting guide

Postby steved » Wed May 28, 2014 10:20 am

In the I2C driver, the 'I2CD_XXX' status/error codes have become 'I2C_XXX'

Legath
Posts: 21
Joined: Thu Oct 17, 2013 3:24 pm
Location: Russia, Ryazan

Re: [INFO] ChibiOS 2.6->3.0 porting guide

Postby Legath » Wed Jun 25, 2014 12:48 pm

Hi ,
please tell how to port application which use fatfs binding ? i do not see fatfs_binding in various directory ? is it deprecated?

User avatar
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

Postby Giovanni » Wed Jun 25, 2014 1:05 pm

Hi,

Just not yet ported over 3.0, see: viewtopic.php?f=2&t=1991

User avatar
part1zan_
Posts: 44
Joined: Sun Sep 08, 2013 9:04 pm
Location: Saint Petersburg, Russia

Re: [INFO] ChibiOS 2.6->3.0 porting guide

Postby part1zan_ » Fri Jun 27, 2014 6:11 pm

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;
}

User avatar
part1zan_
Posts: 44
Joined: Sun Sep 08, 2013 9:04 pm
Location: Saint Petersburg, Russia

Re: [INFO] ChibiOS 2.6->3.0 porting guide

Postby part1zan_ » Fri Jun 27, 2014 6:13 pm

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?

User avatar
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

Postby Giovanni » Fri Jun 27, 2014 6:14 pm

Probably a stack overflow, are debug options enabled?

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