Page 1 of 1

[SOLVED] code for Nucleo G431KB does not run with binary code size > ~65140 bytes

Posted: Tue Mar 23, 2021 10:25 am
by fro
Code with binary size larger than approximately 65140 bytes does not work on Board Nucleo-32 with Board Part Number: "Nucleo G431KB". Forum search did not yield any results. I've reproduced the behaviour with Serial to make the steps to reproduce easier.

Steps to reproduce:
1. Unzip the attached g4size.ino.zip and use the uncompressed code as a sketch.
2. Configure the board/settings as on the screenshot below.
3. Upload.
4. Verify the code is not executed.
5. Remove a single character from any string printed.
6. Upload.
7. Verify the code is executed.

Environment:
- Arduino 1.8.13
- STM32 core 1.9.0
- Board: NUCLEO-G431KB
g431kb.png
g431kb.png (33.71 KiB) Viewed 2856 times
Upload logs snippet:

Code: Select all

Sketch uses 65144 bytes (49%) of program storage space. Maximum is 131072 bytes.
Global variables use 908 bytes (2%) of dynamic memory, leaving 31860 bytes for local variables. Maximum is 32768 bytes.
The attached g4size.ino.zip effectively contains a sketch like shown below, the full sketch can't be inlined because of the size limit.

Code: Select all

void setup() {
  Serial.begin(115200);
  Serial.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb1");
  Serial.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb2");
  Serial.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb3");
  Serial.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb4");
  Serial.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb5");
  Serial.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb6");
  Serial.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb7");
  Serial.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb8");
  Serial.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb9");
  Serial.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb10");
  // and so on to bring the binary size to more than 65144 bytes
}

void loop() {
}
Am I missing something obvious?

Re: code for Nucleo G431KB does not run with binary code size > ~65140 bytes

Posted: Tue Mar 23, 2021 2:02 pm
by fpiSTM
Hi @fro
Could you try to upload you binary with the STM32Cube Programmer (SWD)?
You could also try to update your STlink fw.

Re: code for Nucleo G431KB does not run with binary code size > ~65140 bytes

Posted: Tue Mar 23, 2021 2:59 pm
by mlundin
You can also take a look at the .map in the build directory to see if anything looks strange.

Re: code for Nucleo G431KB does not run with binary code size > ~65140 bytes

Posted: Tue Mar 23, 2021 3:42 pm
by fro
Thanks @fpiSTM, STM32Cube Programmer (SWD) as upload method nicely works as expected.

Re: code for Nucleo G431KB does not run with binary code size > ~65140 bytes

Posted: Tue Mar 23, 2021 3:50 pm
by fro
mlundin wrote: Tue Mar 23, 2021 2:59 pm You can also take a look at the .map in the build directory to see if anything looks strange.
Thanks @mlundin, I'm periodically running "arm-none-eabi-nm --size-sort" on the binary but there's not much I can quickly shave off at the moment for the code I'm working on. The sketch reproducing the behaviour, attached here, won't have any surprises in .text :)

Re: [SOLVED] code for Nucleo G431KB does not run with binary code size > ~65140 bytes

Posted: Tue Mar 23, 2021 4:17 pm
by fpiSTM
Did you try to update the STlink fw ? This will update the mass Storage upload method and probably fix the issue you met.

Re: [SOLVED] code for Nucleo G431KB does not run with binary code size > ~65140 bytes

Posted: Tue Mar 23, 2021 5:12 pm
by fro
After updating STLink from V3J2M1 to V3J2M3 Mass Storage update method also works, thanks again @fpiSTM!