AnsweredAssumed Answered

[F2 1.6.0] USB CDC works only with -os flags?

Question asked by Valentin on Jul 24, 2017

Hi everyone.

 

I have stumbled across an odd problem and would like to share it here and ask if someone knows a solution.

 

Following scenario:

I created an empty Project for my custom pcb F2 (see project's .ioc) and imported it into Atollic TrueStudio (8.0.0). Compiles fine, PC detects it correctly when I plug the USB cable in.

 

Here's the funny part:

As soon as I change the compiler optimization flags from the default -os to -og or none the CDC device doesn't get recognized in windows anymore. I can see on the scope that there's still traffic on the bus but it simply does nothing for ~20sec and then I get a warning message in windows telling me that the USB device has failed for an unknown reason.

 

If I set the optimization flag back to -os it's all good again.

Did anybody experience this before?

 

I cannot remember this being an issue back with FW 1.4.0. But it doesn't look like anything changed with regards to the usb driver in 1.6.0.

 

I found this about the -os flag:


-OsOptimize for size. -Os enables all -O2 optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size.

-Os disables the following optimization flags:

          -falign-functions  -falign-jumps  -falign-loops            -falign-labels  -freorder-blocks  -fprefetch-loop-arrays           

 

So maybe it's one of the disabled flags causing this?

 

Edit: Just confirmed that this doesn't happen with v1.4.0 Firmware.

By the way, it seems that the generation process is broken for 1.4.0 using most recent CubeMX. It still seems to use a new sd card api and also for the timer configuration. I had to manually copy the old bsp_driver_sd.c/.h and comment out the line

//  htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;

in tim.c. (AutoReloadPreload was set to enabled in Cube btw).

 

That's with the completely empty, freshly generated project straight out of CubeMX. @ could you please fix backwards compatibility at least for 1.4.0 until USB and SD drivers are back to normal?

Thanks!

Attachments

Outcomes