compilation of tests fails with CH_CFG_USE_TIMESTAMP disabled Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
Thargon
Posts: 135
Joined: Wed Feb 04, 2015 5:03 pm
Location: CITEC, Bielefeld University, germany
Has thanked: 15 times
Been thanked: 24 times
Contact:

compilation of tests fails with CH_CFG_USE_TIMESTAMP disabled  Topic is solved

Postby Thargon » Thu Dec 02, 2021 10:03 am

Hi,
when the compilation flag CH_CFG_USE_TIMESTAMP is set to FALSE, the test suite does still try to compile those tests (rt_test_sequence_004), resulting in compiler errors, obviously. The fix, however, is very simple:

In test/rt/source/test/rt_test_sequence_004.c a guard needs to be added:

Code: Select all

#if (CH_CFG_USE_TIMESTAMP == TRUE) || defined(__DOXYGEN__)

/* content of the file */

#endif /* CH_CFG_USE_TIMESTAMP == TRUE */

Furthermore, in test/rt/source/test/rt_test_root.c, test sequence 004 needs to be guarded as well:

Code: Select all

/**
 * @brief   Array of test sequences.
 */
const testsequence_t * const rt_test_suite_array[] = {
...
#if (CH_CFG_USE_TIMESTAMP == TRUE)
  &rt_test_sequence_004,
#endif
...
};

I am currently porting my project* from 20.3.x to 21.11.x, so I don't know whether the issue was already present in 21.6.x. Also, I did not check the NIL side of things.

Cheers
Thomas

* there are still several patches waiting to get merged ;)

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: compilation of tests fails with CH_CFG_USE_TIMESTAMP disabled

Postby Giovanni » Thu Dec 02, 2021 10:45 am

Hi,

Fixed as bug #1205.

Will look into the patches.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: compilation of tests fails with CH_CFG_USE_TIMESTAMP disabled

Postby Giovanni » Thu Dec 02, 2021 11:04 am

About patches:

chprintf(): Introduces a dependency on math.h, is isfinite() standard?

QEI: There is already a QEI driver in the community repository. It is very STM32-specific so it has not been merged.

chTimeAddX(): please explain the problem you are trying to address.

threads hierarchy: what is the use case?

I2C: probably it is OK.

Giovanni

Thargon
Posts: 135
Joined: Wed Feb 04, 2015 5:03 pm
Location: CITEC, Bielefeld University, germany
Has thanked: 15 times
Been thanked: 24 times
Contact:

Re: compilation of tests fails with CH_CFG_USE_TIMESTAMP disabled

Postby Thargon » Thu Dec 02, 2021 2:20 pm

Hi,

thank you for checking the patches so quickly!

  • chprintf()
    AFAIK isinf() as well as isnan() are standard, yes. In theory, there might be issues with exotic float implementations, which do not support those special values. But then again those functions still have to return something - even if it's always the same value.
  • QEI
    I was not aware of that, thank you for the hint. At the time those patches were developed, there was no implementation in the community repository, I think.
  • chTimeAddX()
    In case CH_CFG_ST_RESOLUTION is smaller than CH_CFG_INTERVAL_SIZE (e.g. 16 bit HW timer but 32 bit interval representation) a call of the original chTimeAddX() could result in a panic. IMHO, that should not be the case, since such a setup is a legitimate scenario. With my patch the function always returns a value, but there may have been arbitrary overflows. For instance:
    Given 16 bit systime_t and 32 bit sysinterval_t, the call chTimeAddX(0x8000, 0x00100000) would return 0x8000, even though there were 16 virtual overflows.
    I you don't like that, I would propose another API function:

    Code: Select all

    systime_t chTimeAddSafeX(systime_t systime, sysinterval_t interval, size_t* overflows) {
      if (overflows) {
        *overflows = interval / ((sysinterval_t)1 << CH_CFG_ST_RESOLUTION)
      }
    #if CH_CFG_ST_RESOLUTION < CH_CFG_INTERVALS_SIZE
      return  systime + (systime_t)(interval % ((sysinterval_t)1 << CH_CFG_ST_RESOLUTION));
    #else
      return systime + interval;
    #endif
    }
  • threads hierarchy
    Originally, I needed some way to terminate threads recursively. So when thread A had spawned further threads B and C and at some point, thread A was requested to terminate, that request would be propagated to B and C as well. Of course, one could do this as well by tracking such hierarchy within each thread function, but I found it more suitable to put this right into the kernel. Note that it is completely optional and does not break anything with existing code when disabled.
    The only issue I could not solve in an elegant way is that my patch changes the footprint of the chThdCreateStatic() method, since a parent thread is required. For most cases this should be the calling thread, so chThdGetSelfX() could be used to implicitely determine the parent, but than it would be impossible to setup multiple threads in a custom hierarchy from a single point (e.g. initial system setup). I guess this patch should be discussed with further members of the community.
  • I2C
    This is basically a straight-forward implementation of the missing states according to data sheet.
Be aware that the versions in the repository still apply for ChibiOS 20.6.x. I will give a brief updated as soon as I have ported everything to 21.11.x.

Thargon
Posts: 135
Joined: Wed Feb 04, 2015 5:03 pm
Location: CITEC, Bielefeld University, germany
Has thanked: 15 times
Been thanked: 24 times
Contact:

Re: compilation of tests fails with CH_CFG_USE_TIMESTAMP disabled

Postby Thargon » Mon Dec 06, 2021 2:02 pm

I've ported all patches to 21.11.x: https://gitlab.ub.uni-bielefeld.de/AMiR ... el/patches

Regarding the thread hierarchy patch, I noticed that it is somewhat incomplete. I only adapted the chThdCreateStatic() method, but none of the remaining thread creation API. However, as long as the topic needs to be discussed further and the current patch works for me (I do static initialization only), I'd not put further effort in there.

I you decide to apply the feature in ChibiOS, I gladly offer some help ;)

- Thomas

Thargon
Posts: 135
Joined: Wed Feb 04, 2015 5:03 pm
Location: CITEC, Bielefeld University, germany
Has thanked: 15 times
Been thanked: 24 times
Contact:

Re: compilation of tests fails with CH_CFG_USE_TIMESTAMP disabled

Postby Thargon » Mon Feb 07, 2022 5:14 pm

I've updated some of my patches, so here is a small updated on the topic:

  • chTimeAddX()
    I could remove this patch and fix the issues (the reasons for this patch in the first place) in the test suite. See this post for details: https://forum.chibios.org/viewtopic.php?f=2&t=5981#p40941
  • threads hierarchy
    I've modified the patch so it will no longer change any API. The drawback is that it is no longer possible to set an explicit parent thread (calling thread is implicit parent). As a major benefit, however, all existing API now supports the hierarchy, not just the chThdCreateStatic() method.

All patches are up to date for ChibiOS 21.11.1.

- Thomas

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: compilation of tests fails with CH_CFG_USE_TIMESTAMP disabled

Postby Giovanni » Mon Feb 07, 2022 5:44 pm

Hi,

I would appreciate if you could open topics for each subject, this one is closed. Please also distinguish between actual bugs and change requests.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 9 guests