Skip to content

Conversation

pguyot
Copy link
Collaborator

@pguyot pguyot commented Aug 31, 2025

The bundled newlib doesn't print 64 bits integers so logging macros displayed garbage.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

The bundled newlib doesn't print 64 bits integers so logging macros
displayed garbage.

Signed-off-by: Paul Guyot <[email protected]>
@UncleGrumpy
Copy link
Collaborator

UncleGrumpy commented Aug 31, 2025

The bundled newlib doesn't print 64 bits integers so logging macros displayed garbage.

I am confused, are you using the nano version of newlib? We do not use -specs=nano.specs (we use -specs=nosys.specs) so printing 64 bit integers should be possible as long as the build isn't configured with -DAVM_NEWLIB_NANO=on (which disables logging).

@pguyot
Copy link
Collaborator Author

pguyot commented Aug 31, 2025

I am confused, are you using the nano version of newlib? We do not use -specs=nano.specs (we use -specs=nosys.specs) so printing 64 bit integers should be possible as long as the build isn't configured with -DAVM_NEWLIB_NANO=on (which disables logging).

Sorry for the confusion. I'm not sure it's coming from newlib.

What I noticed is that if I used macros, the first argument ended up into the INFO brackets (where the timestamp should be), as if register passing with a 64bits value was broken.

@UncleGrumpy
Copy link
Collaborator

What I noticed is that if I used macros, the first argument ended up into the INFO brackets (where the timestamp should be), as if register passing with a 64bits value was broken.

Is this with additional changes you made or just the current logging macros in general? Do you have an example that I can replicate this with to investigate?

@pguyot
Copy link
Collaborator Author

pguyot commented Aug 31, 2025

Is this with additional changes you made or just the current logging macros in general? Do you have an example that I can replicate this with to investigate?

It was just current logging macros, but in the emulator.
I was printing the AVM_APP_ADDRESS value. I can try on a physical STM32.

@UncleGrumpy
Copy link
Collaborator

Oh, it sounds like the emulator may have been built with newlib-nano. The emulator looks like it was built with 3d-printer firmware in mind which typically wouldn’t need to printf 64-bit integers.

Copy link
Collaborator

@bettio bettio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if it is not a newlib releated issue or we are not sure, I suggest updating the commit message so we don't leave misleading information.

@UncleGrumpy
Copy link
Collaborator

UncleGrumpy commented Sep 2, 2025

I am still not convinced these changes are necessary, it sounds more like an issue with the simulator that was being tested. I have never seen the problem it addresses on real hardware.

@UncleGrumpy
Copy link
Collaborator

It might make more sense to change the log format based on if AVM_NEWLIB_NANO=on is defined, rather than disable logging completely when newlib nano is enabled, then the sim (or any other nano enabled build) could have working logs, without crashing non nano builds later when the milliseconds overflow an unsigned long. I realize this could take a couple months, but I would like to think that a well written application could continue to run for this long without crashing.

@pguyot pguyot marked this pull request as draft September 3, 2025 04:55
@pguyot
Copy link
Collaborator Author

pguyot commented Sep 3, 2025

I changed this to draft. I need to run the test on real hardware and investigate further. This was a default build of stm32 code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants