Skip to content

Conversation

Josar
Copy link
Contributor

@Josar Josar commented Oct 16, 2018

This PR adds debug pins to probe this test with an oscilloscope.
This helps debugging #9211

When runnig this on main branch it can be observed that the xtimer are not fired when they are expected. The whole system is interrupted for a whole timer circle untill the set target is reached again.

image

This is solved by #9211

What we wold expect is that the main pin is on for ca. 100ms and that in a regular interval
Also we would expect the worker to be after 1ms and 1.1ms. (As this falls in the XTIMER_ISR_BACKOFF the first timer is delayed untill the second is ready. Thus the time interval is longer.)

The second figure also shows cicled in red when there is a hardware interrupt before the second worker thread timer is set. This leads to a separation of the timer interrupts, As we only count 7 until they are in the same hardware interrupt again we lost one worker time 2, which is expected as it has a lower priority then worker timer 1. And thus in the moment when the hardware interrupt for the 2 worker is executet it has to wait for the 1 worker timer because of the XTIMER_ISR_BACKOFF and ten the first timer is executed first as it has the higher priority.

image

@PeterKietzmann PeterKietzmann added Area: timers Area: timer subsystems Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: tests Area: tests and testing framework labels Oct 17, 2018
@PeterKietzmann
Copy link
Member

@leandrolanzieri is this helpful? Mind to have a look?

@PeterKietzmann PeterKietzmann requested a review from kYc0o October 17, 2018 07:06
@@ -38,14 +43,31 @@ char stack_timer2[TEST_TIMER_STACKSIZE];

void* timer_func(void* arg)
{
#ifdef WORKER_THREAD_PIN
printf("Debug worker thread port 0x%02x pin %d\n", WORKER_THREAD_PORT, WORKER_THREAD_PIN);
gpio_t worker_pin = GPIO_PIN(WORKER_THREAD_PORT, WORKER_THREAD_PIN);
Copy link
Member

@basilfx basilfx Oct 17, 2018

Choose a reason for hiding this comment

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

Instead of

gpio_t worker_pin = GPIO_PIN(WORKER_THREAD_PORT, WORKER_THREAD_PIN);

why not

gpio_t worker_pin = WORKER_THREAD_PIN;

and define

-DWORKER_THREAD_PIN=GPIO_PIN\(PORTF, 6\)

in the Makefile? It's shorter and more consistent. We do that at several places.

(@kYc0o what do you think?)

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 on defining WORKER_THREAD_PIN and also MAIN_THREAD_PIN

@leandrolanzieri
Copy link
Contributor

I believe this is an interesting feature to have. @Josar maybe a note could be added on what to expect on the pins, like you did here #9211 (comment) ?

@Josar
Copy link
Contributor Author

Josar commented Oct 18, 2018

@basilfx @leandrolanzieri done.

@kYc0o
Copy link
Contributor

kYc0o commented Oct 22, 2018

@leandrolanzieri would you mind to ACK if you agree with this PR? Have you tested?

@leandrolanzieri
Copy link
Contributor

Yes, I tested both with master and #9211, and observed the expected changes. So ACK.
Maybe it could be useful if a summary of this expected results is included in the README.md of the test.

@Josar
Copy link
Contributor Author

Josar commented Oct 23, 2018

@leandrolanzieri tried to explain what is expected.

So your ACK is for this PR. Are you also acknowledging #9211 ?

@kYc0o
Copy link
Contributor

kYc0o commented Oct 30, 2018

Please squash and @leandrolanzieri please set the label for CI when it's squashed.

Copy link
Contributor

@MichelRottleuthner MichelRottleuthner left a comment

Choose a reason for hiding this comment

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

Tested on arduino-mega2560 and z1 works as described. Just some minor things below - feel free to directly squash

@@ -6,4 +6,19 @@ USEMODULE += xtimer

TEST_ON_CI_WHITELIST += all

# Port and pin configuration for probing with oscilloscope
# Define Test pin for hardware timer interrupt, hardware dependent
# ATmega
Copy link
Contributor

Choose a reason for hiding this comment

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

which atmega exactly? or does this apply for all of them?

#FEATURES_REQUIRED += periph_gpio
# Jiminy probing Pins
#CFLAGS += -DWORKER_THREAD_PIN=GPIO_PIN\(PORT_F,7\)
#CFLAGS += -DMAIN_THREAD_PIN=GPIO_PIN\(PORT_F,6\)
Copy link
Contributor

Choose a reason for hiding this comment

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

as the gpio API is used here it may be better to suggest HW-independent port numbers like GPIO_PIN(5,7)

@Josar Josar force-pushed the pr/xtimer_hang/debug_pins branch from 841dc87 to c658ec6 Compare October 31, 2018 01:09
@Josar
Copy link
Contributor Author

Josar commented Oct 31, 2018

Squashed and rebased.

This leads to a separation of the timer interrupts until they again fall in the same interrupt.
It might happen that from the seperation of the interrupts till the merge there is only a uneven count of
WORKER_THREAD_PIN toggles, which means a loss of one worker time 2, which is expected as it has a lower priority then
worker timer 1. And thus in the moment when the hardware interrupt for the 2 worker is executet it has to wait for the
Copy link
Contributor

Choose a reason for hiding this comment

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

Trailing whitespace here. Please remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Add the option to use debug pins to investigate timing issues.
@Josar Josar force-pushed the pr/xtimer_hang/debug_pins branch from c658ec6 to 162d17c Compare October 31, 2018 11:42
@leandrolanzieri leandrolanzieri added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines labels Oct 31, 2018
Copy link
Contributor

@leandrolanzieri leandrolanzieri left a comment

Choose a reason for hiding this comment

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

All looks good, tested and CI passing. ACK.

@MichelRottleuthner MichelRottleuthner merged commit 1606e16 into RIOT-OS:master Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: tests Area: tests and testing framework Area: timers Area: timer subsystems CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants