Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

doru91
Copy link
Contributor

@doru91 doru91 commented Jun 17, 2021

.#### Problem

  • Improve logging capabilities
  • Increase CPU speed

Change overview

Add a timestamp for platform logging. Also increase the CPU speed
from 32Mhz to 48Mhz

Testing

  • manually tested

if (chipCategory != kLogCategory_None)
{
switch (chipCategory)
{
case kLogCategory_Error:
memcpy(buf, "[Error]", 7);
memcpy(buf + strlen(buf), "[Error]", 7);
Copy link
Contributor

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.

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.

Copy link
Contributor Author

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.

@@ -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)
Copy link
Contributor

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?

Copy link
Contributor Author

@doru91 doru91 Jun 25, 2021

Choose a reason for hiding this comment

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

@mspang, done. Thanks!

@doru91 doru91 force-pushed the fix/k32w_log_speed branch from f64ddd1 to 0b54c6c Compare June 25, 2021 09:50
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>
@doru91 doru91 force-pushed the fix/k32w_log_speed branch from 0b54c6c to 6ada606 Compare June 25, 2021 09:54
@github-actions
Copy link

Size increase report for "gn_qpg6100-example-build" from 336533f

File Section File VM
chip-qpg6100-lighting-example.out .text 24 24
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-qpg6100-lighting-example.out and ./pull_artifact/chip-qpg6100-lighting-example.out:

sections,vmsize,filesize
.text,24,24
.debug_info,0,-1
.debug_str,0,-2
.debug_frame,0,-4
.debug_line,0,-9
.debug_abbrev,0,-17
[Unmapped],0,-24
.debug_loc,0,-115

Comparing ./master_artifact/chip-qpg6100-lighting-example.out.map and ./pull_artifact/chip-qpg6100-lighting-example.out.map:

BLOAT EXECUTION FAILED WITH CODE 1:
bloaty: unknown file type for file './pull_artifact/chip-qpg6100-lighting-example.out.map'


@github-actions
Copy link

Size increase report for "esp32-example-build" from 336533f

File Section File VM
chip-all-clusters-app.elf .flash.rodata 16 16
chip-all-clusters-app.elf .flash.text 4 4
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-all-clusters-app.elf and ./pull_artifact/chip-all-clusters-app.elf:

sections,vmsize,filesize
.flash.rodata,16,16
.flash.text,4,4
.debug_loc,0,-4
[Unmapped],0,-16

Comparing ./master_artifact/chip-pigweed-app.elf and ./pull_artifact/chip-pigweed-app.elf:

sections,vmsize,filesize


@github-actions
Copy link

Size increase report for "nrfconnect-example-build" from 336533f

File Section File VM
chip-shell.elf rodata 16 16
chip-lock.elf rodata 24 20
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-shell.elf and ./pull_artifact/chip-shell.elf:

sections,vmsize,filesize
rodata,16,16
.debug_info,0,-1
.debug_frame,0,-4
.debug_line,0,-6
.debug_abbrev,0,-17
.debug_loc,0,-116

Comparing ./master_artifact/chip-lock.elf and ./pull_artifact/chip-lock.elf:

sections,vmsize,filesize
rodata,20,24
.debug_info,0,-1
.debug_frame,0,-4
.debug_line,0,-10
.debug_abbrev,0,-17
.debug_loc,0,-120


const char * categoryString;

writtenLen = snprintf(buf, bufLen, "[%lu]", otPlatAlarmMilliGetNow());
assert((writtenLen > 0) && (writtenLen < bufLen));
Copy link
Contributor

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?

Copy link
Contributor

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));
Copy link
Contributor

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));
Copy link
Contributor

Choose a reason for hiding this comment

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

And here.

@stale
Copy link

stale bot commented Jul 7, 2021

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.

@stale stale bot added the stale Stale issue or PR label Jul 7, 2021
@stale
Copy link

stale bot commented Jul 14, 2021

This stale pull request has been automatically closed. Thank you for your contributions.

@stale stale bot closed this Jul 14, 2021
doru91 added a commit to doru91/connectedhomeip that referenced this pull request Jul 15, 2021
* 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>
@doru91 doru91 mentioned this pull request Jul 15, 2021
doru91 added a commit to doru91/connectedhomeip that referenced this pull request Jul 15, 2021
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants