cancel
Showing results for 
Search instead for 
Did you mean: 

__IO, gcc and core_cm0.h

pgregson1
Associate III
Posted on March 04, 2015 at 01:13

Hello,

I am porting the Custom HID demo project that is included with STM32_USB-FS-Device_Lib_V4.0.0 library to work with my gcc-based toolchain.  I have previously successfully ported other code (specifically, from Olimex for the EW-ARM 5.11 toolchain) to work with my toolchain with little difficulty.  

Both the new code and the previously ported code uses the __IO directive in places, and the library routines such as stm32f10x_adc.c also use it and were properly compiled and built in the previously ported code.  However, the new code throws a large number of errors when it tries to compile usb_pwr.c.  The first such error is:

In file included from ./inc/usb_lib.h:37:0,

                 from src/usb_pwr.c:31:

./inc/usb_regs.h:617:1: error: unknown type name '__IO'

./inc/usb_regs.h:617:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'wIstr'

In file included from ./inc/usb_lib.h:39:0,

                 from src/usb_pwr.c:31:

I can make these and a large number of my subsequent errors go away by putting

#define __IO volatile

in usb_pwr.c.  However, this makes that function non-standard which I don't want to do.

After much searching I found that an identical definition is provided in the CMSIS/Include directory in core_cm0.h.  

Where and how is this header normally included in the demo code?  Or is it included in the toolchain configuration?  It must be included somewhere to compile the demo.  I would like to duplicate that inclusion in my port or toolchain without modifying the distributed STM32_USB-FS-Device_Lib_V4.0.0 because that might give me major issues when that distribution is upgraded.

Any help would be appreciated.

Best regards,

Peter

5 REPLIES 5
Posted on March 04, 2015 at 01:50

On F4 parts, stm32f4xx.h #include's ''core_cm4.h''

On F1 parts, stm32f1xx.h #include's ''core_cm3.h''
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pgregson1
Associate III
Posted on March 04, 2015 at 03:18

Thanks, clive1.  Most helpful.

Best regards,

Peter

Md Mubdiul Hasan
Associate III
Posted on November 07, 2016 at 08:26

Dear Sir Clive1,

Looking at this user fact, one question arise my mind,

If someone has this kind of error,

error: unknown type name '__IO'

What does it means accordance with header file?

Afterwords, if you get  , warning: control reaches end of non-void function [-Wreturn-type]

This time would you mean, 

 functions are returning without providing a value when one is expected.?

Kindly answer please.

Regards

Hasan

Posted on November 07, 2016 at 09:39

The first suggests one or more include file is not being pulled, perhaps due to the absence of a define or other selective compilation.

The second suggests an int foo()  function has multiple exit paths and one of those doesn't return an int.

 
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Md Mubdiul Hasan
Associate III
Posted on November 07, 2016 at 10:03

Dear Sir Clive1,

Thank you once again.

If I add those header files in include folder and linked with build path, again another problem arise.

Regarding the returns issues, this has no efffect?

#ifdef USE_FULL_ASSERT

void assert_failed(uint8_t* file, uint32_t line)

{

*/

/* USER CODE END 6 */

}

#endif

Most funny thing is, all errors come from header files, even I include by # in main.c!

I want to ask you , if I removed some folder ( previous project) which has similar include files that already exists in project properties path in C, would I face any problem?

Regards

Hasan