2023-10-11 04:59 AM - edited 2023-10-11 05:13 AM
We are updating our buildtools to GNU Tools for STM32 11.3.rel1 for a new project that is using an existing SBSFU 2.4.0 based bootloader from a previous project that was using an older compiler. Trying to compile the bootloader gives following errors:
data_init.c: In function 'LoopCopyDataInit':
data_init.c:46:29: error: array subscript 'uint32_t {aka volatile long unsigned int}[0]' is partly outside array bounds of 'uint8_t[1]' {aka 'unsigned char[1]'} [-Werror=array-bounds]
46 | dst[i] = src[i];
| ~~~^~~
data_init.c:36:24: note: while referencing '_sidata'
36 | extern uint8_t _sidata asm("_sidata");
| ^~~~~~~
data_init.c:46:20: error: array subscript 'uint32_t {aka volatile long unsigned int}[0]' is partly outside array bounds of 'uint8_t[1]' {aka 'unsigned char[1]'} [-Werror=array-bounds]
46 | dst[i] = src[i];
| ~~~^~~
data_init.c:82:24: note: while referencing '_sdata'
82 | extern uint8_t _sdata asm("_sdata");
| ^~~~~~
data_init.c: In function 'LoopFillZerobss':
data_init.c:63:20: error: array subscript 'uint32_t {aka volatile long unsigned int}[0]' is partly outside array bounds of 'uint8_t[1]' {aka 'unsigned char[1]'} [-Werror=array-bounds]
63 | dst[i] = 0;
| ~~~^~~
data_init.c:56:24: note: while referencing '_sbss'
56 | extern uint8_t _sbss asm("_sbss");
| ^~~~~
data_init.c: In function 'LoopCleanDataInit':
data_init.c:89:20: error: array subscript 'uint32_t {aka volatile long unsigned int}[0]' is partly outside array bounds of 'uint8_t[1]' {aka 'unsigned char[1]'} [-Werror=array-bounds]
89 | dst[i] = 0;
| ~~~^~~
data_init.c:82:24: note: while referencing '_sdata'
82 | extern uint8_t _sdata asm("_sdata");
| ^~~~~~
I don't really understand what "partly outside array bounds" means and is this a false positive. Google doesn't really help. I am able to disable the errors with "#pragma GCC diagnostic" macros around the functions in data_init.c. Is it safe to ignore these errors? I would really prefer to avoid updating SBSFU version.
2023-10-13 01:42 AM
Hello @sute,
I could reproduce this compilation issue.
The problem comes from the type of the externals that is set as uint8_t instead of uint32_t.
Replacing in data_init.c, uint8_t by uint32_t in all extern references will solve the issue.
Best regards
Jocelyn
2023-10-13 02:44 AM
Yes, this fixed the issue. Thanks! Still a bit confused about the warning though.
2023-10-16 02:53 AM
After some testing, this modification actually seems to break SBSFU. It will compile fine but seems to just crash after starting and endlessly restart.