Skip to content

LibOpenCM3#269

Merged
rokath merged 2 commits intorokath:masterfrom
kraiskil:libopencm3
Mar 29, 2022
Merged

LibOpenCM3#269
rokath merged 2 commits intorokath:masterfrom
kraiskil:libopencm3

Conversation

@kraiskil
Copy link
Copy Markdown
Contributor

Thank you for Trice. It looks like a very cool logging solution.

This PR adds a test/example port of triceConfig to the LibOpenCM3 (my favourite :)) runtime environment. The triceConfig.h is based on the MDK-ARM_STM32F030R8 example.

For now, only 'mode 0' works, I didn't look into the interrupt based modes (more than that they don't work, out of the box at least). But I thought even this limited port might be worth adding since I think it is enough for me now, and I'm not sure I'll find time to look into the interrupts in the close future.

I have two questions though:

First: a print of a string without arguments does not work. Compiling a TRICE("Hello, TRICE\n"); gives

main.trice.c:56:1: error: macro "TRICE32_1" requires 3 arguments, but only 2 given
   TRICE( Id(42549),"Hello, TRICE\n");

Adding a "dummy" %d argument makes this error go away. Is this a configuration error on my part or a bug in Trice?

Second, I'm still getting a warning when compiling:

In file included from ../../pkg/src/trice.h:18,
                 from main.trice.c:11:
main.trice.c: In function 'main':
./triceConfig.h:58:15: warning: declaration of 'TriceBufferWritePosition' shadows a global declaration [-Wshadow]
     uint32_t* TriceBufferWritePosition = co + (TRICE_DATA_OFFSET>>2);
               ^~~~~~~~~~~~~~~~~~~~~~~~
../../pkg/src/trice.h:287:20: note: in expansion of macro 'TRICE_ENTER'
 #define TRICE_INTO TRICE_ENTER TRICE_PUT_PREFIX;
                    ^~~~~~~~~~~

I could remove the extern uint32_t *TriceBuffferWritePosition; in trice.h to silence this, but the interrupt based modes seem to need it.
I can't see off hand where the warning is coming from, but it would be nice if this warning could be silenced too.

@rokath rokath merged commit 7e1fecb into rokath:master Mar 29, 2022
@rokath
Copy link
Copy Markdown
Owner

rokath commented Mar 29, 2022

Concerning your 2 questions I have no answer right now. I am using the ARMKeil compiler and it silently compiles all without warnings. What you could check is, if TRICE("Hello, world\n"); works well in your environment. In any case TRICE0("Hello, TRICE\n"); should work. I hope to find some time in the next days to play around with gcc and maybe Linux too to get a clue.

@rokath
Copy link
Copy Markdown
Owner

rokath commented Mar 29, 2022

What I am wondering too is, that only mode 0 works for you. The other modes have nothing to do with hardware despite TRICE_ENTER_CRITICAL_SECTION and TRICE_LEAVE_CRITICAL_SECTION what you can set empty if trice not using inside interrupts. Of course you need to have an eye on the buffer depth.

@kraiskil
Copy link
Copy Markdown
Contributor Author

kraiskil commented Apr 7, 2022

Thank you for the feedback.
Indeed, TRICE0("hello") works fine. It seems to be the argument counting macro COUNT_ARGUMENTS that doesn't count to zero correctly. (Redefining it as #define COUNT_ARGUMENTS(...) 0 would make the TRICE("hello") work). My compiler is GCC 8 if that turns out to be a compiler bug. I'll try to find time to dig deeper into this.

I managed to get the mode 200 working too. But doing a Trice log in the systick handler causes the log stream to freeze.
Should this work, if the TRICE_ENTER_CRITICAL_SECTION is set up correctly? (even leaving it defined to just a { causes the freeze, so I am worried I'm abusing this somehow).

void sys_tick_handler(void)
{
	system_millis++;
	#if TRICE_MODE == 200
	TRICE("systick happened at system_millis: %d\n", system_millis);
	triceTriggerTransmit();
	#endif
}

@rokath
Copy link
Copy Markdown
Owner

rokath commented Apr 8, 2022

You are the only one reporting such issues. Do you have the chance to change the compiler, just for checking the COUNT_ARGUMENT issue?

@rokath
Copy link
Copy Markdown
Owner

rokath commented Apr 8, 2022

The critical sections are essential for trice usage inside interrupts. But with empty macros you should see a result, even the data stream could get corrupted. Could it be, you produce too much data? You could try to use TRICE( "hi" ); only every 100ms inside the systick. Does this work?

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