Failed to compile usb_lld.c in Keil

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
daemon
Posts: 35
Joined: Tue Oct 09, 2012 1:53 pm

Failed to compile usb_lld.c in Keil

Post by daemon »

Hello!

The last stable version 2.6.7 and unstable version 2.6.8 has the same compilation error in Keil MDK 5:
compiling usb_lld.c...
os\hal\platforms\STM32\OTGv1\usb_lld.c(539): warning: #111-D: statement is unreachable
__set_BASEPRI(0);
os\hal\platforms\STM32\OTGv1\usb_lld.c(1266): error: #268: declaration may not appear after executable statement in block
uint32_t pcnt = (isp->txsize + usbp->epc[ep]->in_maxsize - 1) /
os\hal\platforms\STM32\OTGv1\usb_lld.c: 1 warning, 1 error


NOTE: STM32_USB_OTGFIFO_FILL_BASEPRI was defined in mcuconf.h

"uint32_t pcnt" must be defined at the start of a function. (Its not a C++ code :D )

Another issue is that __set_BASEPRI(0); is unreachable in the code and it (seems) to hang the system when STM32_USB_OTGFIFO_FILL_BASEPRI is not 0.
GunterO
Posts: 24
Joined: Tue Feb 03, 2015 9:59 am

Re: Failed to compile usb_lld.c in Keil

Post by GunterO »

I think you need to enable the -C99 option in µVision.
The error "declaration may not appear after executable statement in block" is typical when the support for the ISO C99 standard is not enabled.
daemon
Posts: 35
Joined: Tue Oct 09, 2012 1:53 pm

Re: Failed to compile usb_lld.c in Keil

Post by daemon »

I think you need to enable the -C99 option in µVision.

Yes, you are right. The question arise because this was the only one place in the code with such error. Maybe because ChibiOS is ANSI C compliant.

Other question regarding __set_BASEPRI(0); is still actual.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Failed to compile usb_lld.c in Keil

Post by Giovanni »

Hi,

I forgot about this, it is misplaced, will fix in next version.

Giovanni
daemon
Posts: 35
Joined: Tue Oct 09, 2012 1:53 pm

Re: Failed to compile usb_lld.c in Keil

Post by daemon »

OK, thanks Giovanni!
Post Reply