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

Add cycle counter driver and test app #386

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hudson-ayers
Copy link
Contributor

This PR adds a driver for the cycle counter capsule, for which kernel support is being added in tock/tock#3934. It also adds a basic test application which prints the number of cycles required to toggle an LED, after checking that the ability to start and stop the driver has not already been claimed by another app.

Tested by adding the capsule to the nrf52840dk and running this app. It takes about 4000 cycles to toggle an LED from userspace.

Comment on lines 11 to 15
bool cycle_counter_exists(void);
int cycle_counter_start(void);
int cycle_counter_stop(void);
int cycle_counter_reset(void);
int cycle_counter_read(int *count);
Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably best to document these in the header file.

It's also worth saying that stop does not reset the counter and it needs to manually be reset

@bradjc
Copy link
Contributor

bradjc commented Apr 2, 2024

Can I ask you follow the new guide? https://github.com/tock/libtock-c/blob/43525b8fedff3531685dbb20b08916addcca0997/doc/guide.md

Maybe not the syscalls folder but the naming convention?

@hudson-ayers hudson-ayers force-pushed the hudson.ayers/cycle_counter branch from 21d0830 to f8e7bb0 Compare April 6, 2024 21:21
Also adds a helper function for SuccessU64 syscall return values
@hudson-ayers hudson-ayers force-pushed the hudson.ayers/cycle_counter branch from f8e7bb0 to 8fd8e7d Compare April 6, 2024 21:38
Copy link
Member

@ppannuto ppannuto left a comment

Choose a reason for hiding this comment

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

Little ergonomic patch, but o/w looks good pending the kernel impl

} else if (rc == RETURNCODE_ERESERVE) {
printf("Cycle counter claimed by another app\n");
} else if (rc != 0) {
printf("Cycle counter: other error: %d\n", rc);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
printf("Cycle counter: other error: %d\n", rc);
printf("Cycle counter: other error: %d (%s)\n", rc, tock_strerr(rc));

Copy link
Contributor

@bradjc bradjc left a comment

Choose a reason for hiding this comment

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

new libtock format

@hudson-ayers hudson-ayers marked this pull request as draft April 24, 2024 02:54
@hudson-ayers
Copy link
Contributor Author

I will come back to this once the new libtock format is merged

@ppannuto
Copy link
Member

ppannuto commented Oct 2, 2024

@hudson-ayers is this still on your queue?

@hudson-ayers
Copy link
Contributor Author

@hudson-ayers is this still on your queue?

Yeah it is, just have had limited time for Tock stuff and have focused more on kernel stuff. I will get back to this eventually

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.

4 participants