-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[K32W] Improve debugging + CPU speed #7717
Conversation
src/platform/K32W/Logging.cpp
Outdated
if (chipCategory != kLogCategory_None) | ||
{ | ||
switch (chipCategory) | ||
{ | ||
case kLogCategory_Error: | ||
memcpy(buf, "[Error]", 7); | ||
memcpy(buf + strlen(buf), "[Error]", 7); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how this was supposed to work before or how it works now. buf isn't length delimited, but no null terminator is explicitly written.
Why not just use strcpy? That would give you the null character and also alleviate the need to count chars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a strcat() scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@msandstedt @jelderton , agree that the old code was messy. I refactored it using the snprintf function.
src/platform/K32W/Logging.cpp
Outdated
@@ -21,26 +21,29 @@ | |||
static bool isLogInitialized; | |||
extern uint8_t gOtLogUartInstance; | |||
extern "C" void K32WWriteBlocking(const uint8_t * aBuf, uint32_t len); | |||
extern "C" uint32_t otPlatAlarmMilliGetNow(void); | |||
|
|||
namespace chip { | |||
namespace Logging { | |||
namespace Platform { | |||
|
|||
void GetMessageString(char * buf, uint8_t chipCategory, uint8_t otLevelLog) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a buffer length parameter please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mspang, done. Thanks!
f64ddd1
to
0b54c6c
Compare
Add a timestamp for platform logging. Also increase the CPU speed from 32Mhz to 48Mhz. Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com>
0b54c6c
to
6ada606
Compare
Size increase report for "gn_qpg6100-example-build" from 336533f
Full report output
|
Size increase report for "esp32-example-build" from 336533f
Full report output
|
Size increase report for "nrfconnect-example-build" from 336533f
Full report output
|
const char * categoryString; | ||
|
||
writtenLen = snprintf(buf, bufLen, "[%lu]", otPlatAlarmMilliGetNow()); | ||
assert((writtenLen > 0) && (writtenLen < bufLen)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this assert valid? What guarantees that writtenLen >= bufLen
can't happen here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this assert valid? What guarantees that
writtenLen >= bufLen
can't happen here?
We can calculate the minimum size and document this as a precondition?
} | ||
|
||
writtenLen = snprintf(buf + writtenLen, bufLen, "[%s]", categoryString); | ||
assert((writtenLen > 0) && (writtenLen < bufLen)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, what guaratees the assert holds? I don't see anything.
} | ||
|
||
writtenLen = snprintf(buf + writtenLen, bufLen, "[%s]", module); | ||
assert((writtenLen > 0) && (writtenLen < bufLen)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This stale pull request has been automatically closed. Thank you for your contributions. |
* decrease stack size (allocated dinamically) for most of the tasks (by using the Stack Water Mark feature in FreeRTOS); * improve debugging by adding more logging related to timestamps and increase the CPU speed to 48Mhz (see project-chip#7717) Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com> [THREADIP-3532] Improve debugging + CPU speed Add a timestamp for platform logging. Also increase the CPU speed from 32Mhz to 48Mhz. Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com>
* decrease stack size (allocated dinamically) for most of the tasks (by using the Stack Water Mark feature in FreeRTOS); * improve debugging by adding more logging related to timestamps and increase the CPU speed to 48Mhz (see project-chip#7717) Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com> [THREADIP-3532] Improve debugging + CPU speed
.#### Problem
Change overview
Add a timestamp for platform logging. Also increase the CPU speed
from 32Mhz to 48Mhz
Testing