EEVblog Electronics Community Forum

Products => Computers => Programming => Topic started by: peter-h on July 16, 2023, 06:00:00 pm

Title: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 16, 2023, 06:00:00 pm
I have just updated Cube IDE, in a VM to avoid messing up my main project, from v12.1 to v13, and it has updated the GCC tools, from
arm-none-eabi-gcc (GNU Tools for STM32 10.3-2021.10.20211105-1100) 10.3.1 20210824 (release)
to
(https://peter-ftp.co.uk/screenshots/202307165517470019.jpg)

The one I have no idea about is
Project XXXX has no explicit encoding set
Lots of stuff on google but no obvious solutions (some for Eclipse but Cube is a modified version of that).

Next is
(https://peter-ftp.co.uk/screenshots/202307165217424518.jpg)
in
(https://peter-ftp.co.uk/screenshots/202307165317434818.jpg)

There is also a lot more buffer size checking like
(https://peter-ftp.co.uk/screenshots/202307162817445018.jpg)
which isn't necessarily a bug because if the destination code has been written right, it won't be extracting expected valid data past the end of the source buffer. It's interesting because I doubt the compiler is smart enough to see if the destination function is actually accessing the data; I expect it is complaining that you are passing the address of say a 20 byte buffer to a function which uses a 25 byte buffer. I would think this is common in programming since making buffers bigger than needed is common.
Otherwise, it is a worry that this is in MbedTLS!

This one is weird (not my code I should say)
(https://peter-ftp.co.uk/screenshots/202307164217455518.jpg)
(https://peter-ftp.co.uk/screenshots/202307162717465618.jpg)
What I don't get is why previous versions didn't complain. I also don't get the double cast - what is it meant to do?

I would much appreciate any pointers (no pun intended). I can turn off those error tests but it is better to fix them. Maybe GCC 11 treats some compiler option (or a default setting) differently?

Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: DavidAlfa on July 16, 2023, 06:49:21 pm
(https://peter-ftp.co.uk/screenshots/202307165217424518.jpg)
Nothing showing inputbuffer usage here? :-//
From GCC:
Quote
-Warray-parameter ¶
-Warray-parameter=n
Warn about redeclarations of functions involving arguments of array or pointer types of inconsistent kinds or forms, and enable the detection of out-of-bounds accesses to such parameters by warnings such as -Warray-bounds.

If the first function declaration uses the array form the bound specified in the array is assumed to be the minimum number of elements expected to be provided in calls to the function and the maximum number of elements accessed by it. Failing to provide arguments of sufficient size or accessing more than the maximum number of elements may be diagnosed by warnings such as -Warray-bounds. At level 1 the warning diagnoses inconsistencies involving array parameters declared using the T[static N] form.

For example, the warning triggers for the following redeclarations because the first one allows an array of any size to be passed to f while the second one with the keyword static specifies that the array argument must have at least four elements.

void f (int[static 4]);
void f (int[]);           // warning (inconsistent array form)

void g (void)
{
  int *p = (int *)malloc (4);
  f (p);                  // warning (array too small)
  …
}
At level 2 the warning also triggers for redeclarations involving any other inconsistency in array or pointer argument forms denoting array sizes. Pointers and arrays of unspecified bound are considered equivalent and do not trigger a warning.

void g (int*);
void g (int[]);     // no warning
void g (int[8]);    // warning (inconsistent array bound)
-Warray-parameter=2 is included in -Wall. The -Wvla-parameter option triggers warnings for similar inconsistencies involving Variable Length Array arguments.
So its seems probable you made a mistake somewhere!

(https://peter-ftp.co.uk/screenshots/202307162817445018.jpg)
Typical warning with sprintf. As long as you know the code is correct...

(https://peter-ftp.co.uk/screenshots/202307164217455518.jpg)
Pretty obvious, %x converts a 8 bit integer into hex.
But for some strange reason the argument converts it to uint32_t with (uint32_t)(uint8_t), so the format should be %02lx.
I'd just remove the (uint32_t).
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 16, 2023, 07:47:16 pm
Inputbuffer is referenced later in that function, in the memcpy (which copies 8 bytes)

Code: [Select]

/**
  * Write formatted datablock to STLED316S
  *
  * *** this is the only function which accesses the display ***
  *
  * @param  DisplayData_t data Array of STLED316S_DISPLAY_MEM (6) bytes (starting at address 0)
  *
  * The data is ASCII characters. All 6 get written to the chip but the number which appears obviously depends
  * on how many 7-seg LEDs are installed. The 655 board has an option for 5, if the light sensor position is used.
  *
  * There are two ways to display a decimal point:
  *
  * 1) if bit 7 = 1 then DP will be illuminated for that character
  *
  * 2) if a (non-first) char is '.' then the previous char's bit 7 is set, and remaining bytes are shuffled left, until 0x00
  * Only 1 decimal point is supported within the display string, and it must not be the 1st char (e.g  .1234)
  *
  * Note that sprintf puts a 0x00 at the end, so one needs the source buffer to be longer than the
  * 6 max digits of the STLED316. This function gets an address of the buffer only, so it doesn't care if the
  * source buffer has been overrun :) If printing decimal points, you will need 2 extra bytes (1 for the dp and 1 for the 0x00
  * which sprintf puts in at the end)
  *
  * @param  brightness integer 0-15
  * @return none
  */

void display_formatted_string(uint8_t *inputbuffer, uint8_t brightness)
{
int i;
bool dpfound=false;
uint8_t tempbuffer[STLED316S_DISPLAY_MEM+2];  // use local buffer to avoid corrupting the input buffer
static uint8_t dispbuffer[STLED316S_DISPLAY_MEM+3];  // this holds the raw segment format for the STLED316 chip
static const uint8_t brt_translate[16]  = { 0,1,2,8,3,9,4,5,6,7,10,11,12,13,14,15 };

brightness &= 0x0F;  // limit value 0..15
memcpy(tempbuffer,inputbuffer,STLED316S_DISPLAY_MEM+2);  // make a local copy of the display data

if (tempbuffer[0]==0x00) return;  // abandon if 1st char is a null

// Handle lone DP char detection and left shuffling

i=1;  // skip 1st char

do
{
if ( tempbuffer[i]=='.' ) { dpfound=true; }
i++;
}
while ( ( i < STLED316S_DISPLAY_MEM+2 ) && ( tempbuffer[i] != 0x00 ) && ( dpfound == false ) );

i--;  // if a DP was found, i now points at the DP char

if ( dpfound )
{
tempbuffer[i-1]|=0x80; // set the DP on previous digit
while ( ( i < STLED316S_DISPLAY_MEM+2 ) && ( tempbuffer[i] != 0x00 ) )
{
tempbuffer[i]=tempbuffer[i+1];  // shuffle 1 left
i++;
}
}

// Convert ASCII characters via the font table; without regard for any bit 7 set, and replacing < 20h with blank digits
// We fill dispbuffer after 1st byte

for (i = 0; i < STLED316S_DISPLAY_MEM; i++)
{
if ( tempbuffer[i] >= 0x20 )
{
dispbuffer[i+1] = FONT_7S[ ( tempbuffer[i] & 0x7F ) - 0x20];
}
else  // invalid char
{
dispbuffer[i+1] = 0x00;  // 0x00 to blank the digit
}
if ( tempbuffer[i] & 0x80 )
{
dispbuffer[i+1] |= 0x80;  // if bit 7 was set on input byte, set it now in the output
}
}


// re-order brightness values to get a monotonic rise
brightness = brt_translate[brightness];

// Values 0 to 7 select low current (10mA), 8 to 15 high current (40mA)
display_set_current(brightness > 7);

SPI3_Lock();

// If current SPI3 init is not this device, initialise it
if ( g_spi3_current_config != SPI_MODE_STLED316 )
{
spi3_set_mode(SPI_MODE_STLED316);
g_spi3_current_config = SPI_MODE_STLED316;
}

// STLED316S display duty cycle values for brightness are 0 to 7
display_set_global_brightness(brightness % 8);

// This delay (10us just works) is needed after loading the brightness data, before the rest
hang_around_us(20);

dispbuffer[0] = (STLED316S_ADDR_WR_CMD | STLED316S_IDX(STLED316S_DIG_PAGE, 0x00)); // Set Address at 0

// Write all digits in one go

display_cs(0);
hang_around_us(STLED_GEN_WAIT);

SPI3_DMA_TransmitReceive(dispbuffer, NULL, STLED316S_DISPLAY_MEM+1, true, false, RTOS_YIELD);

hang_around_us(STLED_GEN_WAIT);
display_cs(1);
hang_around_us(STLED_GEN_WAIT); // Min CS=1 time

SPI3_Unlock();

}


The compiler probably doesn't like the call to the function

Code: [Select]
display_formatted_string((uint8_t *) "APP   ", 15);

which supplies a null terminated string of 7 bytes total. But we are only reading the source buffer, not writing it. Yes I know it is bad practice to read past the end of a buffer. On the 32F417 it doesn't matter but would do if the said source buffer happened to sit on the very end of physical RAM and then you get a trap.

Re the buffer sizes I think something has been changed in the checking level. GCC v10 was fine with it. And the code runs fine, FWIW.

Doing some digging around compiler options. Nothing has changed

(https://peter-ftp.co.uk/screenshots/202307164117485221.jpg)

(https://peter-ftp.co.uk/screenshots/202307164517495321.jpg)

On the ST forum, some reports of people reverting back to GCC v10 to continue working. And no solution for the "explicit encoding set" - something to do with Java?
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: DavidAlfa on July 16, 2023, 09:17:00 pm
Warnings usually arise from bad coding practices or certain undefined condition.
Still it's just a warning, nothing is keeping you from working.
You can overcome it by manually setting the compiler flags.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: SiliconWizard on July 16, 2023, 09:44:03 pm
(https://peter-ftp.co.uk/screenshots/202307165217424518.jpg)
in
(https://peter-ftp.co.uk/screenshots/202307165317434818.jpg)

Normally this warning is triggered due to an inconsistency in how the function is declared.
Is there a prototype of this function somehwere else (like in a header file) that would happen to have a different declaration?

There is also a lot more buffer size checking like
(https://peter-ftp.co.uk/screenshots/202307162817445018.jpg)
which isn't necessarily a bug because if the destination code has been written right, (...)

This warning usually "just" means that from the format string passed to sprintf(), the worst case could overflow the buffer passed as a first argument.
It's not ultra-clever, but false positives are relatively rare.
Of course, in practice the code may ensure that the worst case is never reached, but software is full of bugs that should never happen, so.

After making sure the buffer is properly sized, one better approach is to use snprintf() and pass the size of the buffer to it. Avoids any potential overflow.
As Youtubers would say: "Stop using sprintf() !"

This one is weird (not my code I should say)
(https://peter-ftp.co.uk/screenshots/202307164217455518.jpg)
(https://peter-ftp.co.uk/screenshots/202307162717465618.jpg)
What I don't get is why previous versions didn't complain. I also don't get the double cast - what is it meant to do?

The %x format expects an 'unsigned int' as an argument.
uint32_t is not equivalent to an unsigned int in general (in a portable way). So you get a warning.
The proper C printf formats for stdint integers '(u)intxx_t' are macros of the type 'PRIxyy' that are found in the inttypes.h standard header, so you need to '#include <inttypes.h>'.

In this piece of code, since buffer's pointer base type is uint8_t, the cast (uint8_t) is useless. (I'm assuming the base type of 'buffer' is uint8_t, but is it? If not, then the cast may be warranted.)
The cast (uint32_t) is, strictly speaking, not correct as said above. You should replace it with (unsigned int).
Can it be done without entirely? In your case, yes. You can remove both casts.

But if you wanted your code to compile keeping the two casts as is without warning, you'd need to  '#include <inttypes.h>', and use the following format string instead:
Code: [Select]
" %02" PRIx32
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 17, 2023, 05:33:57 am
Thank you all.

I do understand the reasons for the warnings.

What I don't understand is why not on GCC 10 but yes on GCC 11. Compiler flags have not changed.

The MbedTLS case is more concerning since I would expect the coders to be good :)

Re that KDE_display_formatted_string() 7 v. 8 issue: the function displays 6 digits on a 7 seg LED display e.g. 123456. If a DP is to be displayed, it becomes 7: 123.456
To handle the worst case, the memcpy copies 8 bytes (the 7 plus 0x00) into a local buffer. Hence I need to modify the calling function to always supply 7 plus the 0x00, to avoid this warning. But this is irrelevant; my point is that GCC default options appear to have changed v10 to v11.


EDIT: I found it here
https://gcc.gnu.org/gcc-11/changes.html

New warnings:
-Wmismatched-dealloc, enabled by default, warns about calls to deallocation functions with pointers returned from mismatched allocation functions.
-Wsizeof-array-div, enabled by -Wall, warns about divisions of two sizeof operators when the first one is applied to an array and the divisor does not equal the size of the array element.
-Wstringop-overread, enabled by default, warns about calls to string functions reading past the end of the arrays passed to them as arguments. In prior GCC releases most instances of his warning are diagnosed by -Wstringop-overflow.

So that leaves just the "Project XXXX has no explicit encoding set". I fixed that also using the Eclipse ctrl-1 feature: highlight the error and this shows the fix. Amazing! The video here
https://stackoverflow.com/questions/72692978/eclipse-project-project-name-has-no-explicit-encoding-set
shows it.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 17, 2023, 02:34:29 pm
Getting back to this, for MbedTLS... Just four warnings left now:

(https://peter-ftp.co.uk/screenshots/20230717165473315.jpg)

Predictably others have been digging around this already
https://github.com/Mbed-TLS/mbedtls/issues/4130

The MbedTLS devs are IMHO somewhat full of themselves in not supporting a widely deployed version of the product and expecting people (who have a real life and a real business and need to sell boxes with frozen firmware at some point) to spend weeks upgrading the thing and doing days or weeks of testing...

Does anyone know whether one can have a compiler option (to disable this check) inside a .c source file? I don't really want to make it global because one day it might pick up a real error of mine. And I don't want to set it up inside Cube IDE because it is messy and is likely to bite somebody in the bum in the future.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: dkonigs on July 17, 2023, 02:47:31 pm
Does anyone know whether one can have a compiler option (to disable this check) inside a .c source file? I don't really want to make it global because one day it might pick up a real error of mine. And I don't want to set it up inside Cube IDE because it is messy and is likely to bite somebody in the bum in the future.

If you're willing to edit the offending source file, GCC has some pragmas that can be used for this:
https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html (https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html)
http://dbp-consulting.com/tutorials/SuppressingGCCWarnings.html (http://dbp-consulting.com/tutorials/SuppressingGCCWarnings.html)

One common trend with GCC over the years is that older versions were more permissive, and newer versions have become more strict. This has generally been happening for over 20 years now.  It is generally a good thing, IMHO, but I can see how it can be annoying if you're not willing to fix the nitpicky issues in your code (or someone else's code you're building).  The solution there may simply be to add compiler flags to disable whatever new warnings they've decided to turn on by default.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 17, 2023, 03:01:43 pm
I've been looking around this but it looks like

#pragma "-Wno-stringop-overflow"

or

__attribute__(("-Wno-stringop-overflow")) (various versions)

is not supported.

Or it is wrong :)

Every imaginable version is online e.g.
https://stackoverflow.com/questions/3378560/how-to-disable-gcc-warnings-for-a-few-lines-of-code

These options are not generic GCC; they are compiler specific. Basically I need

#pragma("-Wno-stringop-overflow")
#pragma("-Wno-array-parameter")

but so far no luck.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: Siwastaja on July 17, 2023, 03:29:52 pm
See this example how I have silenced specific warnings in the past, successfully:

Code: [Select]
#define IO_SET_ALTFUNC(port, pin, af) do{ _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wshift-count-negative\"")  _Pragma("GCC diagnostic ignored \"-Wshift-count-overflow\"") \
if((pin)<8) {uint32_t _tmp_ = (port)->AFR[0]; _tmp_ &= ~(0b1111UL<<((pin)*4));     _tmp_ |= af<<((pin)*4);     (port)->AFR[0] = _tmp_;} \
        else {uint32_t _tmp_ = (port)->AFR[1]; _tmp_ &= ~(0b1111UL<<(((pin)-8)*4)); _tmp_ |= af<<(((pin)-8)*4); (port)->AFR[1] = _tmp_;} _Pragma("GCC diagnostic pop") }while(0)
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 17, 2023, 03:44:12 pm
No luck

(https://peter-ftp.co.uk/screenshots/20230717315484316.jpg)

I am putting this at the start of the .c file.

The above error suggests _Pragma and #pragma are equivalent, but this doesn't work either

(https://peter-ftp.co.uk/screenshots/20230717025494516.jpg)

I can edit the TLS source in a couple of cases, apparently safely, by replacing fred[48] with *fred, but in other places it is much less obvious, and reading the MbedTLS stuff on these GCC 11 warnings it doesn't appear that simple.

Predictably, this works, for about half of it

(https://peter-ftp.co.uk/screenshots/20230717415505316.jpg)
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: Siwastaja on July 17, 2023, 03:58:01 pm
One quite PRAGMAtic way (pun intended) to get forward is to remove the warning entirely and then try to remember every now and then temporarily enable it for checking if your own code has developed any new such warnings.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 17, 2023, 04:03:37 pm
This removes it all entirely, just for the one file

(https://peter-ftp.co.uk/screenshots/20230717505510017.jpg)

i.e. putting the stuff on the compiler command line does work (the non yellow options were already there).

What a waste of time, issuing a compiler with tightened warnings and not providing a way to disable them. Lots of people have to use 3rd party code which they don't want to hack around due to the amount of regression testing needed.

Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: SiliconWizard on July 17, 2023, 09:42:08 pm
Thank you all.

I do understand the reasons for the warnings.

What I don't understand is why not on GCC 10 but yes on GCC 11. Compiler flags have not changed.

From version to version, GCC keeps adding new warnings, and for warnings that were already supported, they keep changing the list of warnings that are enabled: by default, with -Wall, with -Wextra, and so on.
That's all there is to it.

The MbedTLS case is more concerning since I would expect the coders to be good :)

MbedTLS code sucks.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 18, 2023, 07:43:27 am
I am not qualified to judge but it looks horrible.

But the application is truly horrible; you mutually negotiate the auth crypto, hoping that you will agree on something, and then mutually negotiate the session crypto, hoping that you will agree on something.

On the internet everybody is a security expert and stuff gets "deprecated" because somebody read on the internet that it is insecure and deprecated, so everybody copies this BS on their own website. So you remove e.g. hash algorithm X because it is deprecated and insecure, and then you find you cannot connect to some hugely popular service because they are using exactly that hash to sign their certificate.

So I don't know how anybody can write half decent code for all that.

It's also fairly obvious that they collected the various crypto algos by trawling the internet.

It's been a bit of a lesson for me too, because I would have regarded it as perfectly normal to e.g. sprintf a 5 byte string, 0x00 at the end, into a 10 byte buffer which ultimately ends up on a 10 digit LED display and whose code is written to blank any digits after the 5th one. Well, you can't do that anymore. Both src and dest need to have a 11 byte buffer. Even more fun if you want to support decimal points; to support just one you need a 12 byte buffer.

The compiler writers must have put in a vast amount of work detecting what the code is doing; they are not just comparing static buffer lengths.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: ejeffrey on July 18, 2023, 02:52:34 pm
Yes, basically 99% of what compiler writers do is try to figure out how to better understand what your code is doing.  Compiling correctly written C code into assembly is something an undergraduate can do for a class project in a few weeks.  The hard part is inspecting the code to try to figure out what it is doing so it can more effectively apply optimizations, provide better error messages when things fail, and provide better warnings about legal but probably wrong code.

It's also probably not as smart as you imagine. 

You should be able to sprintf a short buffer into a long one, but I don't think it usually checks the used length, only the allocated length.  Possibly if you initialize it with a literal it tracks the actual length but anything more complicated and I think it just assumes the whole buffer is used. Passing a buffer to a function prototyped to take an array of a specified size will assume that the function will access the entire array.  If you pass something too short it should complain.  If what you actually mean is that this function takes a null terminated string or variable length string with a maximum of 10 characters, just change the signature to char* or char* plus a length parameter.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: eutectique on July 18, 2023, 03:06:51 pm
The hard part is inspecting the code to try to figure out what it is doing ...

As the comment in the Open Watcom source files (https://github.com/open-watcom/open-watcom-v2/blob/master/bld/wdisasm/c/wdismsg.c) says:

Code: [Select]
* ...
*
* Description:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
*               DESCRIBE IT HERE!
* ...
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: paulca on July 18, 2023, 06:01:31 pm
As a general rule in static code analysis we would ban all usage of sprintf in favour of snprintf.

"I can prove it will never overflow".  is not accepted as an answer.  Because "all things change".  It's the same with "null checks" on pointers.  You might be able to prove your code path means the function will never be called with a null... the point is "it can be called with a null", so it must protect itself from them.

The same goes for the other functions which have an operating length limited version. There is one of them which has no such variant and it can cause issues, it might be sscanf how no snscanf so can continue to roll through memory, there are other ways to limit it with the extraction format.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: ejeffrey on July 18, 2023, 08:26:21 pm
Yes, snprintf is the easiest and best solution to all sprintf length issues and there is basically no downside.  Even if you don't add error detection / handling, silently truncating the output is better than overflow.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: paulca on July 19, 2023, 10:47:04 am
https://owasp.org/www-community/attacks/Format_string_attack
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 19, 2023, 11:08:32 am
For sure; there is an absolutely vast number of attack vectors on a public server.

But nobody should be running an embedded box as a public server. Even if you are running TLS on it, it should be only as an HTTPS client, calling up some private server. That is the usage model for what I am doing. The box will either be behind NAT or be equivalently firewalled. There is an HTTP server (which I wrote, using the netconn API of LWIP, and thus assume to be totally insecure) and that is documented to never be on an open port too (and use a VPN for any remote access).

Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: paulca on July 19, 2023, 01:48:39 pm
And yes, that's fine.

As long as you don't need to sell it to any companies with security compliance requirements and ISO certs etc.  Some bureaucracy extends far beyond it's immediately means.  For example any system which processes payment information must comply with various certifications (in the UK and other countries have similar eCommerce requirements).  These expand out to many parts of the system and in some instance require total compliance across the board.  Such as encryption "in flight" and "at rest".  "No unauthenticated end points period."

You don't want people 'UART hacking' card transaction machines or any component in that entire hardware and software chain.

It's sector specific, well not specific, but different sectors place more emphasis on security.  However the industry trends towards  security at every layer and on ever interface.  SSL, Encryption, Authentication and authorisation at each stage, each end point, each application, each database.  The only place you can have data unencrypted is in memory and even then you have to be careful with it.

The expansion of crypto features and encrypted storage on MCUs I'd say the embedded space are well on board with modern security.
 
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 19, 2023, 02:56:11 pm
Quote
as you don't need to sell it to any companies with security compliance requirements and ISO certs etc

That would be totally meaningless in the context of any "industrial" embedded system.

Which is not to say that some customer won't ask the question... Actually I really struggle to think of the use of TLS anyway. It enables you to create systems which stop running one day because some certificate has expired, and then it's panic all around while everybody is going crazy and hunting around whoever might know about it. A simple shared key and AES256 would be much better. But that's a whole other topic.

Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: paulca on July 19, 2023, 03:28:54 pm
In my software engineering degree the "Professional ethics" module included a case study.  I could look it up but in short...

Cocky embedded engineer works with his colleges during a company dinner to design algorythms for "bonding box" calculations for a robot....  on a napkin... the court heard.  Said engineer the next morning decided to write the code, upload it to the robotics system and.. a robot instead of turning right 10 degrees, turned left 350 degrees.  Except it didn't.  It encountered first a person and then a wall.  The person was killed instantly.

Cocky embedded engineer by my calculations is still in prison.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 19, 2023, 04:04:48 pm
There is a name for arguing against a point nobody is making. Google says it is a Straw Man argument; I am not 100% sure.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: paulca on July 19, 2023, 05:33:28 pm
You said that compliance and quality certificates are invalid concept in embedded systems. 

I gave you a real example where someone went to prison for poor quality code.  It was meant as a cautionary tale on professional negligence and it's civil and criminal ramifications for embedded systems and industrial systems in particular. 

Industrial systems, I would imagine, have to comply with various health and safety regulations or the insurance will not cover it's liability etc. etc.  Such as a control system with no "STOP" button.  No false-safes and lockouts.  Even, maybe, to the extent of ensuring that your device can only be accessed/configured or used by authorised and trained personnel.

Does your system not do reporting?  Does it have any external management interfaces?  If so, they need secured. if it's only to prevent "Accidental or malicous tampering by internal bad actors"

Do you have professional liability insurance?
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 19, 2023, 08:20:21 pm
I think those building life critical systems are not going to be posting on EEVBLOG :)

Quote
Does it have any external management interfaces?  If so, they need secured

They are and this is documented.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: Siwastaja on July 20, 2023, 09:10:06 am
I think those building life critical systems are not going to be posting on EEVBLOG :)

I have seen you say something similar a few times before, and I think it's quite arrogant. This is a surprisingly popular forum among some world-class experts, of course many don't make a big deal about it. A few posters who build safety critical systems where failure would result in loss of life come into mind, and they have discussed how tight the regulatory processes are. I'm glad I'm not one of them - at least yet - because of how stressful it must be.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: paulca on July 20, 2023, 10:00:22 am
I don't develop life critical systems, but I do develop critical infrastructure with billions of dollars in flight daily.

I am also under international legal regulation, and need to comply with a raft of stuff around money laundering, sanctions, foreign actors, insider trading, tipping, etc. etc. etc.  There is mention of 15 years jail time, plus fines totalling twice the profited amount.

However, appealing to extremes asides.  Software license agreements have to be VERY carefully written.  Software development contracts have to be very carefully written.  When I say, "very carefully written" I mean your contract terms and conditions must be compatible with your insurance company, in addition to any local regulations and laws.

An EXTREMELY important aspect is the "Limited liability" clauses.  If they don't hold like concrete in court you can be screwed over for whatever the customer believes your software cost them.  So if your devices goes "dead" for 48 hours and it brings a production line to a halt for 48 hours, that could amount to $500,000 in lost revenue claimed against your failure to provide what you contract stated you would. 

A "fair" limit on liability to strive for is "Liabilities not exceeding the total contract cost.".  So if after the software + consulting + support they have paid you (invoiced) $16,000.  If that software deletes all their company records and causes $3 million in damage, you only get screwed for $16,000.

Get insurance.  Make sure your contracts are written well.  Spending a few hundred dollars to have a lawyer review your contracts might save you a few thousand in legal fees later.  Legal fee insurance as part of your professional and third party liability insurance package is usually standard.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: paulca on July 20, 2023, 10:05:32 am
They are and this is documented.

You pushed back on the security and said you didn't see a need for it.

So it's either secured or not.  If the security is inadequate it will not matter if it was documented or not.  It will result in damages being filed your way in civil court.

If they get an industry expert to take your code apart in that court.  God help you.

Do note, by selling them software services you are operating as a software professional.  As that is an recognised engineering discipline (in most circles), it comes with inherent professional conduct and integrity implications which the court will lean on.  That is how "Professional negligence" is a real criminal thing.  Engineers need to hold a reputation to hold trust.  Engineers who are fraudulent or incompetent need to be called out and dissociated, distanced.

Software industry is rampant with "free spirits" and I wouldn't stop them, honestly.  Tear away.  Just be aware, if you embarrass the industry, no expert engineer will get in the stand to defend you.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 20, 2023, 03:50:07 pm
Quote
of course many don't make a big deal about it.

Sure there will be some but they will make sure they don't post the details, due to e.g.

- company social media policy - likely to be extra tight in high legal liability cases
- a "big money" business will not want to advertise their next product (I have seen amazing contrary cases and they are still on google but they were posted ~20 years ago, along with full company name, and people learnt their lesson since)
- most devs doing complex work don't want to do "free education" (I know contrary cases but they are rare)
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: paulca on July 20, 2023, 06:38:07 pm
Its a problem which is detrimental in ways to the industry.  That which means the higher engineers are more likely to be restricted in what they can discuss.

EEVBlog is really an excelent forum.  In software beyond beginner level or maybe intermediate level in open source projects...  In the real bleeding edges it's either in University or in a private company and entirely proprietary and thus, there are very, very few places on the internet you can discuss these things.  People just don't talk about these things because they are buried under NDAs and regulation.

I play a more dangerous game.  As long I don't make it clear where I work or who for and as long as I keep my topics to "generic technological" / "professional discussions" with no context which relates that towards any company I have worked for in the last few years.  I should be fine. Based on how I read the disclosure documentation.

I might use a Rabbit MQueue pattern to deliver a proprietary system.  I feel I am free as a software profressional to discuss, even in public Rabbit MQueue patterns and practices.  As long as I don't get too close to the proprietaries.

The risk that I personally run with that is "doxing".  That could change a few things.    i think I'm okay.  I don't believe I have ever devulged any information which was not effectively public.

The worst is when someone thinks they are calling you out by saying you provide no evidence that you are even what you say.  That's why in the past my response is "You don't pay my salary, luckily."  The reality is, I could probably point to a few real world systems which people would be aware of, which I may or may not have worked on.  I just choose, profressionally to avoid doing so and only from a graceful period in the past.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 21, 2023, 08:31:05 am
Quote
Its a problem which is detrimental in ways to the industry.  That which means the higher engineers are more likely to be restricted in what they can discuss.
EEVBlog is really an excelent forum.  In software beyond beginner level or maybe intermediate level in open source projects...  In the real bleeding edges it's either in University or in a private company and entirely proprietary and thus, there are very, very few places on the internet you can discuss these things.  People just don't talk about these things because they are buried under NDAs and regulation.

I agree, and have written this loads of times. It is why so much open source code is junk and with nobody supporting it. People get so far, post it, and then

- they abandon it (working or not) but leave it published
- the continue with it as a commercial product but don't publish anything beyond the original (working or not) code

Anyway, back to topic, v11 generates slightly smaller code than v10 - about 1% less.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: DiTBho on July 21, 2023, 08:53:10 am
you are the prototype of the ignorant person who doesn't even spend half a minute studying by himself, doesn't pay for personal tecnical courses, doesn't thank people when they teach something, instead prefers to (ab)use other people's time for every stupid things, even complaining about open source.

congratulation :clap:
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: peter-h on July 21, 2023, 09:54:55 am
You are very wrong, but you are welcome :)
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: Siwastaja on July 21, 2023, 10:32:06 am
Remember when I said I think you are the one who is rude, peter-h, and you dismissed it as me being a mental health case, demonstrating said rudeness. See? I'm not the only one who thinks that way.

Complaining and self-victimization is a thing, I used to do that a lot but it's a huge productivity killer. I still sometimes end up on those wrong tracks when stressed out, finding myself using my cognitive capacity to come up with clever ways of explaining why something is crap, when I should be using that very power to find ways around that crappiness.

I can't fully remove my inner pessimist, but I have learned to make my rants quick. So I write a short, aggressive comment in code of something being crap, and then try to move on ASAP. If I already wasted a day due to some stupid bug or poor documentation, then I don't want to waste another day in aftermath. Just keep going on.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: paulca on July 21, 2023, 12:04:41 pm
I still sometimes end up on those wrong tracks when stressed out, finding myself using my cognitive capacity to come up with clever ways of explaining why something is crap, when I should be using that very power to find ways around that crappiness.


This.

For better or for worse I find the ratio of requests for help on forums that I start and the ones I send is about 100:1.  Because, most times, writing the message and explaining the problem clearly to an audience is enough to solve the problem or uncover a new lead or a new direction and so ... you don't send the message, you go off and investigate that lead first.

The other type of message I am (hands up) guilty for is the "pre-emptive help" style message.  I see something and I know it's going to take me days and days of research to understand and so I will often put up a generic discussion topic to see if I can learn anything the quick way... aka cheating.  While at the same time starting into that research in parallel.   Different audiences appreciate these types of messages in different ways.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: DiTBho on July 21, 2023, 03:40:58 pm
You are very wrong, but you are welcome :)

now you are in my ignore list.
Title: Re: STM32F4 GCC v10 to v11 - some weird error messages
Post by: Simon on July 21, 2023, 08:02:01 pm
I think those building life critical systems are not going to be posting on EEVBLOG :)

Quote
Does it have any external management interfaces?  If so, they need secured

They are and this is documented.

cough, cough, cough, guilty! It was life support actually! what was worse was that me posting here was utter sanity compared to what went on at the company some times.