Blue Pill quirks

Mavrick.J
Wed Jul 11, 2018 7:54 am
Hello everyone
sorry if the subject is out of place where already mentioned.

in my quest to exploit the best of the STM32F103, I read a lot and test.

In the project that occupies me I meet several oddities, peharps buggs! especially on statements that would not be used and others that have already been treated on this forum (warning timer in LTO for exemple)

So Stm32F103C8T6 “blue Pill”
Arduino IDE v1.8.5

– the option “SMALLEST (default)” gives a code bigger than 4ko than the option smallest with LTO. is it normal?

– “SMALLEST (default)” option gives different warning of smallest with LTO option

After several tests it turns out that with the option “Smallest (default”) the code sent to a Blue Pill claiming to have 128Ko plants. the code is well loaded but crashes in some portion of the code (led flashes).

the same code compiled in smallest with LTO, works without problem.

so either a problem compikation, or STM32C8T6 who say do 128Ko do not work or memory errors!

What do you think about?

PS: sorry for my english (google). :oops:


stevestrong
Wed Jul 11, 2018 8:00 am
[Mavrick.J – Wed Jul 11, 2018 7:54 am] –
– the option “SMALLEST (default)” gives a code bigger than 4ko than the option smallest with LTO. is it normal?

Yes.

[Mavrick.J – Wed Jul 11, 2018 7:54 am] –
– “SMALLEST (default)” option gives different warning of smallest with LTO option

What kind of warnings? Please paste them here.


Mavrick.J
Wed Jul 11, 2018 5:04 pm
Thank’s
For “timer” I read that it was “normal”, but “Spi” I saw nothing to look well.
But for the definition there is something that I do not understand because looking in the library I see nothing abnormal!

List of warning :

Warning for Smallest with LTO

WARNING: Category 'Device' in library ParPrinter is not valid. Setting to 'Uncategorized'
WARNING: Category 'Device' in library Radar is not valid. Setting to 'Uncategorized'
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src/SPI.h:163:16: warning: 'ff' defined but not used [-Wunused-variable] static uint8_t ff = 0XFF;
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src/SPI.h:164:15: warning: '_spi1_this' defined but not used [-Wunused-variable] static void (*_spi1_this);
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src/SPI.h:165:15: warning: '_spi2_this' defined but not used [-Wunused-variable] static void (*_spi2_this);
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src\SPI.cpp: In function 'spi_baud_rate determine_baud_rate(spi_dev*, uint32_t)':

C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src\SPI.cpp:762:12: warning: enumeration value 'RCC_AHB' not handled in switch [-Wswitch]

switch (rcc_dev_clk(dev->clk_id))

^

In file included from C:\Code Arduino Travail\Code Source Arduino\libraries\SD\src\utility\Sd2Card.cpp:31:0:

C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src/SPI.h:163:16: warning: 'ff' defined but not used [-Wunused-variable]

static uint8_t ff = 0XFF;
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src/SPI.h:164:15: warning: '_spi1_this' defined but not used [-Wunused-variable]

static void (*_spi1_this);
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src/SPI.h:165:15: warning: '_spi2_this' defined but not used [-Wunused-variable] static void (*_spi2_this);
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/include/libmaple/timer.h:150:18: warning: type of 'timer4' does not match original declaration [enabled by default] extern timer_dev timer4;
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\cores\maple\libmaple\timer.c:67:11: note: previously declared here
timer_dev timer4 = GENERAL_TIMER(4);
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/include/libmaple/timer.h:138:18: warning: type of 'timer1' does not match original declaration [enabled by default] extern timer_dev timer1;
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\cores\maple\libmaple\timer.c:52:11: note: previously declared here
timer_dev timer1 = ADVANCED_TIMER(1);
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/include/libmaple/timer.h:146:18: warning: type of 'timer3' does not match original declaration [enabled by default] extern timer_dev timer3;
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\cores\maple\libmaple\timer.c:62:11: note: previously declared here
timer_dev timer3 = GENERAL_TIMER(3);
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/stm32f1/include/series/adc.h:45:16: warning: type of 'adc1' does not match original declaration [enabled by default] extern adc_dev adc1;
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\cores\maple\libmaple\adc_f1.c:43:9: note: previously declared here
adc_dev adc1 = {
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/include/libmaple/timer.h:142:18: warning: type of 'timer2' does not match original declaration [enabled by default] extern timer_dev timer2;
^
C:\Program Files (x86)\arduino\hardware\Arduino_STM32\STM32F1\cores\maple\libmaple\timer.c:57:11: note: previously declared here
timer_dev timer2 = GENERAL_TIMER(2);
^


stevestrong
Wed Jul 11, 2018 5:47 pm
There is nothing dangerous there.
But I wonder why do you get this messages, since other users do not complain.
Which OS?

Mavrick.J
Fri Jul 13, 2018 9:12 am
Ok, :oops:
Os Windows Seven

:ugeek:


fpiSTM
Fri Jul 13, 2018 9:25 am
Probably not the arm gcc 4.8.3 but an updated one.

stevestrong
Fri Jul 13, 2018 9:35 am
How did you install the Roger’s core?
I just saw you have extracted the files to wrong directory, it should have been under the Arduino sketch directory, which normally is
c:\Users\[user]\Documents\Arduino.
Then the sub-directory \hardware.
And which Arduino board have you installed additionally for the gcc?

Mavrick.J
Fri Jul 13, 2018 9:48 am
for GCC it’s ver 4.8.3-2014q1

for installation i use instruction from Roger’s wiki. but I could make a mistake, despite several checks.

i have installed : AVR, SAM (Arm Cortex M3), SAMD (M0+)

:geek:


stevestrong
Fri Jul 13, 2018 11:14 am
The directory
C:\Program Files (x86)\arduino\hardware\

Mavrick.J
Fri Jul 13, 2018 2:38 pm
thank you but
if I put the packages in the specified place they are not recognized.

and I tried several installations.

SAM and SAMD packages install in C: \ [Users …] \ AppData \ Local \ Arduino15 \ packages \ arduino \ hardware

if I put the stm32 hardwares there, they are not recognized either.

the only place they are loaded is in C: \ Program Files (x86) \ arduino \ hardware

Same for the libraries.

When I tell you weird :? :oops:


stevestrong
Fri Jul 13, 2018 3:19 pm
Last suggestion:
delete all existing Arduino folders (including … \AppData\Local\Arduino15), and Arduino_STM32, too.
and make a new fresh install of Arduino IDE:
– download and unzip Arduino IDE to: [user]\Downloads\Arduino
– Arduino sketch folder should be: [user]\Documents\Arduino
– Arduino_STM32 should go to: [user]\Documents\Arduino\hardware
– any further additional (non-default STM32) library to: [user]\Documents\Arduino\libraries.

Then open Arduino IDE, install SAM boards for Cortex-M3, select “Generic STM32F103C” board form IDE board options, and you should be able to compile the blinky sketch warning free.


fpiSTM
Fri Jul 13, 2018 3:32 pm
[stevestrong – Wed Jul 11, 2018 5:47 pm] –
There is nothing dangerous there.
But I wonder why do you get this messages, since other users do not complain.
Which OS?

I just understood, other users do not complain because they probably do not set compiler warning to “All” :mrgreen:

I’ve the same warnings using the master of Roger’s core.


stevestrong
Fri Jul 13, 2018 4:40 pm
How do you enable all warnings in Roger’s core? Per default, it is disabled.

Mavrick.J
Sat Jul 14, 2018 7:42 am
Hi all,

[stevestrong – Fri Jul 13, 2018 3:19 pm] –
Last suggestion:
delete all existing Arduino folders (including … \AppData\Local\Arduino15), and Arduino_STM32, too.
….

I have already tried this solution, because there is a moment that I try to understand.
I even install a brand new Windows ! Can be the language or a paremeter in the system?

[fpiSTM – Fri Jul 13, 2018 3:32 pm] –

[stevestrong – Wed Jul 11, 2018 5:47 pm] –

I just understood, other users do not complain because they probably do not set compiler warning to “All” :mrgreen:

I’ve the same warnings using the master of Roger’s core.

Phew, I’m not the only one :D :lol:
But i’m not in “All” option only “More” :roll: in “all” there’s more incomprehensible Warning :o

[stevestrong – Fri Jul 13, 2018 4:40 pm] –
How do you enable all warnings in Roger’s core? Per default, it is disabled.

File / Preference / Compiler Warning : More

I activated the display of the errors because of the STM32 crashes while the compilation was good. and that by adding or removing a simple line of style ” int A = 3; ” the STM32 no longer crashed!

In short I looked at the libraries and I do not understand why it is warning, which do not exist to exist!

:oops:

Regards


stevestrong
Sat Jul 14, 2018 8:07 am
Again, those warnings are not critical, I run several programs with that.
It must be something wrong with your code.
It is really hard to achieve 128kB code. How did you manage?
However, more critical is the RAM consumption.
If you use a lot of static constant initialization within a function, remove that.
Also try to get rid of new String variable declaration within a function, because this will consume a lot of heap, which can be a reason why it crashes.

Mavrick.J
Sat Jul 14, 2018 9:19 am
Yes, I understand that this is not a critical warning, but it does not make sense to appear.

Sketch uses 70772 bytes (53%) of program storage space. Maximum is 131072 bytes.
Global variables use 5912 bytes (28%) of dynamic memory, leaving 14568 bytes for local variables. Maximum is 20480 bytes.

I try all the tricks I know to reduce the code and the memory size.

The problem seems to appear at 54% of space use. I will try with a Stm32f103cBt6 to see if the crash is still there.

Thank you
Regards


mrburnette
Sat Jul 14, 2018 5:09 pm
Mavrick.J

When asking such questions about code compliation, linking, errors &warning, and binary size … it is my opinion that you should use one of the examples which gets loaded with the core.

Now, if you use an example, others can easily repeat the tests.
Otherwise, you need to provide specific code & libraries in a zip.

We may have some Win 7 users in the forum who have not upgraded to Win 10, but years ago I used Win8.1 and had no issues with stm32duino. I have performed the installation on my 1 (one lone) Windows 10 PC without any issues. But, I am a Linux person and hence why there is only 1 Win PC … just for testing. Note that a “custom” installation or running with an old core can really screw up the results you achieve.

Also, there is a possibility your Blue Pill may have some characteristics different from other Blue Pills: I have read that several vendors are supplying the blue pill look-a-likes. You are pretty much on your own with clones of clones and potential hardware issues. For reference, when enquiring about weird stuff, a link to where you procured your board could be useful.

On the issue of “soft compiler warnings” you can find such things on your own using Google.

Ray


Mavrick.J
Mon Jul 16, 2018 1:12 pm
hello and thank you for all these valuable tips

Regards


zoomx
Tue Jul 17, 2018 8:39 am
I have one PC with Seven but my Arduino installation is in “portable mode”.
So I have an Arduino folder, inside there is afolder named portable, inside there is a folder named sketchbook, inside there is a folder named hardware, inside there are all cores that I have installed manually, Roger and STM32GENERIC cores and ESP32 core. The others were installed by the core manager.
So Roger core is here:
D:\arduino\portable\sketchbook\Hardware\Arduino_STM32

fpiSTM
Tue Jul 17, 2018 8:44 am
https://www.arduino.cc/en/Guide/PortableIDE

Mavrick.J
Sat Jul 21, 2018 5:00 pm
Hello,
First of all thank you all for your tracks, even if some moves away from the subject of departure with the versions “portable” or so it is me who translates badly ;-)

So as a result of my investigations, and the remark of mrburnette, I again reviewed all my code is it turns out that the crash seemed to be due to a pointer on a variable STRING type, passed in parameter of a function whose size was not good!

I know I see the purists say: “STRING not good”, but it’s easier. :lol:

And in some cases the value returned to the stack was no longer good, hence the stack overflow. :roll:

But always a question: why with some options of compilation it worked and not with others?

In short I added to my basket a STMLINK we will see if it helps to understand this phenomenon.

Thanking you again
regards


Rick Kimball
Sat Jul 21, 2018 6:09 pm
Easier to do what? If you mean printing there is the <Streaming.h> library that lets you do simple concatenation without stressing too much

http://arduiniana.org/libraries/streaming/


Mavrick.J
Sun Jul 22, 2018 7:03 am
Hello,
easier for me, in terms of integration and management in the code that occupies me without relying too much third-party library.

But thank you for the interresting links.
Regards


Leave a Reply

Your email address will not be published. Required fields are marked *