Welcome! Log In Create A New Profile

Advanced

setting the hardwareclock

Posted by sLOID 
setting the hardwareclock
February 11, 2016 06:46PM
hi there,

i'm a big fan of this forum and got a few devices allready running successfully bodhi's great debian stuff - thank you for all your work :-)

my latest project is a broken (hdd - crashed) lacie networkspace 2 lite devices. i flashed the mainline u-boot (from lacie-side) and got
it running with a new drive and bodhi's latest rootfs and kernel 4.4.0

my only problem is, that the hardwareclock is on 2018 .. when i try to set it up automatically with:

ntpdate de.pool.ntp.org

i got the error: Can't adjust the time of day: Invalid argument

tried to set it up manualy worked: date -s 2016-02-12

debian replied with: Fr 12. Feb 00:00:00 CET 2016

when i entered 2 seconds later: date

debian replied: Fr 31. Aug 01:54:27 CEST 2018

i played around with hwclock but without any luck. can some of you guys tell me what the heck is going on with it ???

thank you in advanced.

greetz, sLOID.
Re: setting the hardwareclock
February 13, 2016 08:03PM
sLOID Wrote:
-------------------------------------------------------
> hi there,
>
> i'm a big fan of this forum and got a few devices
> allready running successfully bodhi's great debian
> stuff - thank you for all your work :-)
>
> my latest project is a broken (hdd - crashed)
> lacie networkspace 2 lite devices. i flashed the
> mainline u-boot (from lacie-side) and got
> it running with a new drive and bodhi's latest
> rootfs and kernel 4.4.0
>
> my only problem is, that the hardwareclock is on
> 2018 .. when i try to set it up automatically
> with:
>
> ntpdate de.pool.ntp.org
>
> i got the error: Can't adjust the time of day:
> Invalid argument
>
> tried to set it up manualy worked: date -s
> 2016-02-12
>
> debian replied with: Fr 12. Feb 00:00:00 CET 2016
>
> when i entered 2 seconds later: date
>
> debian replied: Fr 31. Aug 01:54:27 CEST 2018
>
> i played around with hwclock but without any luck.
> can some of you guys tell me what the heck is
> going on with it ???
>
> thank you in advanced.
>
> greetz, sLOID.

Dooes dmesg show it is set to 2018 during boot?

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: setting the hardwareclock
February 14, 2016 03:34AM
hi bodhi,

yes, it does:

rtc-mv f1010300.rtc: setting system clock to 2018-08-30 21:39:56 UTC (1535665196)

what does it mean ??
Re: setting the hardwareclock
February 14, 2016 01:55PM
sLOID Wrote:
-------------------------------------------------------
> hi bodhi,
>
> yes, it does:
>
> rtc-mv f1010300.rtc: setting system clock to
> 2018-08-30 21:39:56 UTC (1535665196)
>
> what does it mean ??

The RTC is running, so it meant your hwclock command did not transfer the datetime to clock. It seems the Lacie uses Marvell SoC RTC so rtc-mv works in demsg:
rtc-mv f1010300.rtc: setting system clock to 2018-08-30 21:39:56 UTC (1535665196)

Have you tried to use option such as:
hwclock --systohc

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: setting the hardwareclock
February 14, 2016 04:31PM
hi bodhi,

yeah, i did. while playing around i found other frightened stuff: commands like:

fw_setenv bootdelay=5

end up with:

Warning: Bad CRC, using default environment
MTD erase error on /dev/mtd0: Invalid argument

i think it is a bigger problem and not only with the rtc. do you have another hint for me ??

thank you. sLOID.



Edited 1 time(s). Last edit at 02/14/2016 04:34PM by sLOID.
Re: setting the hardwareclock
February 14, 2016 05:13PM
sLOID,

> yeah, i did. while playing around i found other
> frightened stuff: commands like:
>
> fw_setenv bootdelay=5
>

This should be
fw_setenv bootdelay 5
But it is not related to the error below.

> end up with:
>
> Warning: Bad CRC, using default environment
> MTD erase error on /dev/mtd0: Invalid argument

No worry. This only means that the area that contains the u-boot envs in mtd0 can not be accessed from Debian, because it has not been initialized properly. And the reason for this could be that the u-boot you are running does not use this area, or the Debian location setting for mtd0 in /etc/fw_env.config is not correct.

So what u-boot you are running? do you have serial console? if yes, please post the entire boot log. If no, post output of dmesg.

Also
cat /etc/fw_env.config
cat /proc/mtd

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: setting the hardwareclock
February 14, 2016 05:53PM
ah i see. thank you for explaining.

yes i have serial access. unfortunately not at the moment. the lacie is at home. but i have to work next few days.
what i have is ssh access. so here are the outputs:

cat /etc/fw_env.config

# MTD device name Device offset Env. size Flash sector size Number of sectors
/dev/mtd0 0xc0000 0x20000 0x20000


cat /proc/mtd

dev: size erasesize name
mtd0: 00080000 00001000 "spi0.0"


here's the dmesg output: pastebin

u-boot is the original (not stock) from the lacie page. you may want to take a look hier: ftp://lacie-nas.org/u-boot
it's a mainline version from 2011.

thank you for your time.

sLOID.
Re: setting the hardwareclock
February 14, 2016 06:45PM
sLOID,

This mtd0 will not work with the current /etc/fw_env.config. So definitely fw_printenv/setenv will not work. The above link pointed to u-boot images, so I really can't tell what the correct settings should be.

However, we've strayed far from original topic!

Getting back to the RTC, what is the exact name of this Lacie DTB?

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: setting the hardwareclock
February 15, 2016 01:03AM
hi bodhi,

it's the "LaCie Networkspace 2 lite". I include the specified name of the dtb-file in the DTS folder while building the image.
(kirkwood-ns2lite.dtb). Everything went without errors, so it should be the right one.

sLOID
Re: setting the hardwareclock
February 15, 2016 01:51AM
sLOID Wrote:
-------------------------------------------------------
> hi bodhi,
>
> it's the "LaCie Networkspace 2 lite". I include
> the specified name of the dtb-file in the DTS
> folder while building the image.
> (kirkwood-ns2lite.dtb). Everything went without
> errors, so it should be the right one.
>
> sLOID

Now this is a puzzle, it's the Marvell SoC RTC just like a many other Kirkwood boxes.

Do you see ntpd starts running to sync the clock in the kernel message log? and ntpdate running once before that.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: setting the hardwareclock
February 15, 2016 10:42AM
hi bodhi,

don't know exactly what you mean. isn't the dmesg output the kernel log ??? in the /var/log folder is the following:

apt dmesg dmesg.2.gz dpkg.log messages wtmp boot dmesg.0 dmesg.3.gz fsck ntpstats
alternatives.log btmp dmesg.1.gz dmesg.4.gz lastlog syslog

let me know where to look. and dmesg doesnt show anything up after the ntpdate command.

thank you.
Re: setting the hardwareclock
February 15, 2016 12:02PM
sLOID,

Yes dmesg for kernel messages and also use logread to print out Debian messages (this log file is normally in var/log/messages, but we are logging to RAM so logread will print it)..

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: setting the hardwareclock
February 15, 2016 12:47PM
hi bodhi,

learning will never end. thank you for that :-)

had to install the busybox-syslog pakage. here's the result:

first the ntpdate command with the unlikely known error:

ntpdate ptbtime1.ptb.de

3 Sep 19:48:00 ntpdate[28423]: Can't adjust the time of day: Invalid argument

and here the output from logread right after ntpdate:

Sep 3 19:47:26 LaCie syslog.info syslogd started: BusyBox v1.22.1
Sep 3 19:47:27 LaCie user.notice kernel: klogd started: BusyBox v1.22.1 (Debian 1:1.22.0-9+deb8u1)


seems to me, that nothing happend there except of starting the service few seconds ago.

should i do the whole install stuff again ?? is there a way to set the rtc over the serial-connection after interrupting the boot sequence ??

thank you.
Re: setting the hardwareclock
February 16, 2016 12:17AM
sLOID,

Which rootfs are you running? if you are running my 3.18.5 rootfs then your ntpd should be running. Could you post the whole dmesg output and logread output here or pastebin them. I don't think I can guess the problem without seeing the whole picture.

> is
> there a way to set the rtc over the
> serial-connection after interrupting the boot
> sequence ??

Not likely with stock u-boot. I have sntp support in my u-boot-2015.10 images, but not sure if you can run them with the LaCie.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: setting the hardwareclock
February 16, 2016 03:35AM
hi bodhi,

here is the dmesg: - klick -

and the logread: - klick -

and yes, it's yours rootfs 3.18.5

thank you.



Edited 1 time(s). Last edit at 02/16/2016 03:36AM by sLOID.
Re: setting the hardwareclock
February 16, 2016 04:22AM
sLOID,

It is a classical problem with ntpd and ntpdate resource fighting.
Sep  4 10:14:56 LaCie daemon.err ntpd[1502]: unable to bind to wildcard address 0.0.0.0 - another process may be running - EXITING

Our member restamp did a really good job with his explanation:
http://forum.doozan.com/read.php?2,20817,20828#msg-20828

If you were running one of my new u-boot images, then SNTP probably is the solution. However you are running stock u-boot, you need to solve it the kernel or at Linux shell. The idea is to work around the conflict (ntpd could not run because ntpdate was holding on to the ports).

Since hwclock did not work for you, all I can think of is a work around: after boot, kill ntpd, and run ntpdate, wait a while and start ntpd. See if that will update the RTC, and keep it stay that way.

If ntpdate does not work while ntpd is not running, you might want to look at the ntp pool in /etc/ntp.conf, and adjust the ntp servers, or make sure other settings in this ntp.conf file are correct. Or you just might want to restart ntpd any way without using ntpdate. ... Hope this made sense :)

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 2 time(s). Last edit at 02/16/2016 04:25AM by bodhi.
Re: setting the hardwareclock
February 16, 2016 06:08AM
hi bodhi,

i tried your workaround but without success. i'll give your actual u-boot a try and when i return home i'll do the flashing.
hope this will work then.

thank you for your work. i'll let you know.

greetz, sLOID.
Re: setting the hardwareclock
February 16, 2016 12:12PM
sLOID,

> i tried your workaround but without success. i'll
> give your actual u-boot a try

Don't flash :) they are not built for the LaCie! do only UART booting see if it works.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: setting the hardwareclock
February 17, 2016 02:43AM
hi bodhi,

ok ok ... got it. i won't do any flashing :-)
i'll report later that weekend.

greetz.
Re: setting the hardwareclock
February 17, 2016 01:11PM
sLOID,

Here you go, use this u-boot image for LaCie ns2l to run kwboot with option -p:

./kwboot -t -B 115200 /dev/ttyUSB0 -b uboot.2015.10-tld-1.ns2l.mtd0.kwb  -p

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 1 time(s). Last edit at 02/17/2016 01:15PM by bodhi.
Attachments:
open | download - uboot.2015.10-tld-1.ns2l.mtd0.kwb (287 KB)
Re: setting the hardwareclock
February 18, 2016 01:15AM
hi bodhi.

thank you very much for your work. i'll instantly try this out this evening, when i return back home.

best regards, sLOID.
Re: setting the hardwareclock
February 23, 2016 10:06AM
hi bodhi,

sry for my late response, but unlikely: i had to do other things at the weekend, I'm sorry for the delay.

the lacie boots up fine with your u-boot image via uart. unfortunately the rtc problem is pending. can you please tell me, what i have to do, to flash your image to nand ?? i know i have to erase the address block before. but how do i find out, what the right address it is within the flash ???
i looked at davygravy's instructions here: UART Booting HowTo for Selected Kirkwood Devices but i'm too scared to brick the lacie.

thank you.

greets, sLOID.



Edited 1 time(s). Last edit at 02/23/2016 12:27PM by sLOID.
Re: setting the hardwareclock
February 23, 2016 12:44PM
sLOID Wrote:
-------------------------------------------------------
> hi bodhi,
>
> sry for my late response, but unlikely: i had to
> do other things at the weekend, I'm sorry for the
> delay.
>
> the lacie boots up fine with your u-boot image via
> uart. unfortunately the rtc problem is pending.
> can you please tell me, what i have to do, to
> flash your image to nand ?? i know i have to erase
> the address block before. but how do i find out,
> what the right address it is within the flash ???
> i looked at davygravy's instructions here:
>
> UART Booting HowTo for Selected Kirkwood
> Devices
but i'm too scared to brick the
> lacie.
>
> thank you.
>
> greets, sLOID.

For now, please post the serial console log when you use kwboot to boot the box. This is SPI so the flash command is different.

If you can boot with kwboot then you have a recovery path.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: setting the hardwareclock
February 23, 2016 04:32PM
hi bodhi,

here it is:

Sending boot message. Please reboot the target...|
Sending boot image...
0 % [......................................................................]
3 % [......................................................................]
6 % [......................................................................]
9 % [......................................................................]
12 % [......................................................................]
15 % [......................................................................]
18 % [......................................................................]
21 % [......................................................................]
24 % [......................................................................]
27 % [......................................................................]
30 % [......................................................................]
33 % [......................................................................]
36 % [......................................................................]
39 % [......................................................................]
42 % [......................................................................]
45 % [......................................................................]
48 % [......................................................................]
51 % [......................................................................]
54 % [......................................................................]
57 % [......................................................................]
60 % [......................................................................]
63 % [......................................................................]
67 % [......................................................................]
70 % [......................................................................]
73 % [......................................................................]
76 % [......................................................................]
79 % [......................................................................]
82 % [......................................................................]
85 % [......................................................................]
88 % [......................................................................]
91 % [......................................................................]
94 % [......................................................................]
97 % [..........................................................]
[Type Ctrl-\ + c to quit]


U-Boot 2015.10tld-1 (Feb 17 2016 - 01:03:19 -0800) NS v2 Lite

SoC: Kirkwood 88F6192_A1
I2C: ready
SPI: ready
DRAM: 128 MiB (ECC not enabled)
WARNING: Caches not enabled
SF: Detected MX25L4005 with page size 256 Bytes, erase size 64 KiB, total 512 KiB
In: nc
Out: nc
Err: nc
Net: egiga0
88E1318 Initialized on egiga0
Hit any key to stop autoboot: 0
Lacie ns2>

thank you.



Edited 1 time(s). Last edit at 02/23/2016 04:32PM by sLOID.
Re: setting the hardwareclock
February 23, 2016 06:08PM
sLOID,

The idea is to use SNTP to query the time server (that command will automatically set the RTC) while in u-boot serial console. Somewhere in the forum I wrote instruction for this. If you can't find it I will look in one of my boxes.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: setting the hardwareclock
February 24, 2016 12:00AM
In this example, the router IP is 192.168.0.1, the time server to get the clock is montpelier.caltech.edu:
setenv set_rtc 'setenv dnsip 192.168.0.1;setenv gatewayip 192.168.0.1;setenv netmask 255.255.255.0; dns montpelier.caltech.edu ntpserver; sntp $ntpserver'
run set_rtc

BTW, I did not attend CalTech :)

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: setting the hardwareclock
February 24, 2016 01:58PM
YEEEEEEEAH !!!!!

hi bodhi ... all worked well (i replaced the timeserver in your commandline with a german one and set it to my routers ip) everything went well and the damn lacie has the right time now. thank you so much for your hard work. :-))))))

would love to write the u-boot file to the flash of the nas. can you tell me how ???

thank you. sLOID.
Re: setting the hardwareclock
February 24, 2016 03:12PM
sLOID Wrote:
-------------------------------------------------------
> YEEEEEEEAH !!!!!
>
> hi bodhi ... all worked well (i replaced the
> timeserver in your commandline with a german one
> and set it to my routers ip) everything went well
> and the damn lacie has the right time now. thank
> you so much for your hard work. :-))))))
>
> would love to write the u-boot file to the flash
> of the nas. can you tell me how ???
>
> thank you. sLOID.

Cool :)

Let me rebuild this (there is a typo in the banner), and you can try again one more time. If all goes well that will be the released version. And then we'll work on the flashing.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: setting the hardwareclock
February 24, 2016 06:18PM
sLOID,

Please boot back to stock u-boot to see if your RTC is still working. It seems there is more need to be included in the new u-boot to make it useful. So you might want to use stock for now until I can double check the commands.

However, if you still want to flash new u-boot then test kwboot this updated image (attached). There is no change other than the corrected u-boot version.

Update:

Change your rootfs /etc/fw_env.config to
# MTD device name	Device offset	Env. size	Flash sector size	Number of sectors
/dev/mtd0 0x70000 0x10000 0x1000

And get the listing of your envs and post here:
fw_printenv

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 4 time(s). Last edit at 02/24/2016 09:27PM by bodhi.
Attachments:
open | download - uboot.2015.10-tld-2.nsl2lite.mtd0.kwb (287 KB)
Re: setting the hardwareclock
March 07, 2016 11:32AM
hi bodhi,

sry for the late response. i didn't had any time for this project. and i think you were totally right. it doesn't matter what version of uboot the lacie uses, the clock is still out of range. in the last weeks it has no power. so the rtc should be clear. but it now says:

Do 13. Mai 12:28:50 CEST 2032

it's so frustrating. hope you have just another few things to try out to get it working. and yes, i would like to flash your uboot version and would like to know how.

you wrote:

Quote

# MTD device name Device offset Env. size Flash sector size Number of sectors
/dev/mtd0 0x70000 0x10000 0x1000

shouldn't the last address be "0x10000" ?? anyway ... i tried it with both settings without any differences in result.

here's the output from fw_printenv:

Quote

bootargs=
bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm
bootdelay=3
baudrate=115200
stdin=serial,cros-ec-keyb
stdout=serial,lcd
stderr=serial,lcd

thank you bodhi ...

greetz, sLOID



Edited 1 time(s). Last edit at 03/07/2016 11:35AM by sLOID.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: