Nil: system clock failed to restart from 0 Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
User avatar
aGuegu
Posts: 29
Joined: Thu Dec 07, 2017 4:15 am
Has thanked: 1 time
Been thanked: 5 times

Nil: system clock failed to restart from 0  Topic is solved

Postby aGuegu » Thu Dec 07, 2017 5:28 pm

Running test with ChibiOS svn revison: 11133
Platform: STM32F103C8_MINIMAL (stm32c8t6)
Toolchain: gcc-arm-none-eabi-6-2017-q2-update

Code: Select all

#include "hal.h"
#include "ch.h"
#include "chprintf.h"

THD_WORKING_AREA(waThread1, 32);
THD_FUNCTION(Thread1, arg) {
  (void)arg;
  palSetPadMode(GPIOC, GPIOC_LED, PAL_MODE_OUTPUT_OPENDRAIN);

  while (true) {
    palTogglePad(GPIOC, GPIOC_LED);
    chThdSleepMilliseconds(250);
  }
}

THD_WORKING_AREA(waThread2, 128);
THD_FUNCTION(Thread2, arg) {
  (void)arg;
  uint8_t buff;
  BaseSequentialStream* chp = (BaseSequentialStream*) &SD1;
  sdStart(&SD1, NULL);
  palSetPadMode(GPIOA, 9, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);       // USART1 TX
  palSetPadMode(GPIOA, 10, PAL_MODE_INPUT);                          // USART1 RX

  while (true) {
    uint8_t len = sdReadTimeout(&SD1, &buff, 1, 500);
    if (len) {
      chprintf(chp, "%02x\r\n", buff);
    } else {
      chnWrite(&SD1, (const uint8_t *)"Hello World, ", 13);
      chprintf(chp, "%u\r\n", chVTGetSystemTimeX());
    }
  }
}

THD_TABLE_BEGIN
  THD_TABLE_ENTRY(waThread1, "blinker1", Thread1, NULL)
  THD_TABLE_ENTRY(waThread2, "hello", Thread2, NULL)
THD_TABLE_END


int main(void) {
  halInit();
  chSysInit();

  while(1) {
  }
  return 0;
}


If you want to check other files like chconf.h, the code repo is https://github.com/aguegu/stm32-bluepil ... /nil-hello .

It is a simple demo. While onboard led is blinking, SD1 prints the 'hello, world' and the system time. If SD1 read chars within 500 ms, it will echo the input in hex mode.

At first, it runs okay. if I did not type in any character. The system timer would restart from zero when it overflows.

But if I typed a few keys, the hex output works, when the system timer close to its maximum, like 65071, it failed to restart, and the led stop blinking.

It looks like the system is halting.

User avatar
aGuegu
Posts: 29
Joined: Thu Dec 07, 2017 4:15 am
Has thanked: 1 time
Been thanked: 5 times

Re: Nil: system clock failed to restart from 0

Postby aGuegu » Fri Dec 08, 2017 4:28 am

I rebuilt this code with Release 17.6.3, it works fine.

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

Re: Nil: system clock failed to restart from 0

Postby Giovanni » Fri Dec 08, 2017 4:58 pm

Hi,

The problem is confirmed, I am working on it.

You can mitigate it by setting CH_CFG_INTERVALS_SIZE to 16 in chconf.h. It does not affect released versions, only trunk.

Giovanni

User avatar
aGuegu
Posts: 29
Joined: Thu Dec 07, 2017 4:15 am
Has thanked: 1 time
Been thanked: 5 times

Re: Nil: system clock failed to restart from 0

Postby aGuegu » Fri Dec 08, 2017 6:40 pm

cool, happy to help. :D

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

Re: Nil: system clock failed to restart from 0

Postby Giovanni » Sat Dec 09, 2017 11:07 am

Hi,

It should be fixed now. My previous suggestion was wrong, CH_CFG_INTERVALS_SIZE does not work with NIL (removed it).

Giovanni

User avatar
aGuegu
Posts: 29
Joined: Thu Dec 07, 2017 4:15 am
Has thanked: 1 time
Been thanked: 5 times

Re: Nil: system clock failed to restart from 0

Postby aGuegu » Mon Dec 11, 2017 5:11 pm

Yes, my hello demo works with SVN revision: 11139. Well done.


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 20 guests