WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: piCore-6.1beta1_v7-SSH TimeZone Not Found Issue  (Read 2433 times)

Offline cmurd

  • Newbie
  • *
  • Posts: 3
piCore-6.1beta1_v7-SSH TimeZone Not Found Issue
« on: June 05, 2015, 04:13:39 PM »
Hi,

Wasn't able to find anyone with a similar problem, so posting problem/resolution here.

I have written a Mono/C# application running on Raspberry Pi Model B+, originally developed and tested on piCore-6.0-SSH (Linux box 3.12.36-piCore+ #1 PREEMPT Mon Jan 19 22:46:45 CET 2015 armv6l GNU/Linux). Part of the program uses the system time, calling DateTime.UtcNow. I have transferred this program to a new Raspberry Pi 2 Model B V1.1, which required an update to piCore-6.1beta1_v7-SSH (Linux box 3.18.10_v7-piCore+ #1 SMP PREEMPT Thu Mar 26 15:14:54 CET 2015 armv7l GNU/Linux).

The program would no longer run on the new Raspberry Pi, throwing a TimeZoneNotFoundException. Digging around in the Mono source code, it seems there is a few places that a TimeZone will be looked up:
/usr/share/zoneinfo
/etc/localtime
environment variable TZ

I resolved the issue by editing cmdline.txt and inserting tz=UTC. Once rebooted, the Raspberry Pi was able to successfully run the application and use the DateTime class. However, I am wondering if the piCore-6.1beta1_v7-SSH release is missing a symbolic link, file, or environment variable for fetching time zone information, which was correctly set in previous ARM6 versions?

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: piCore-6.1beta1_v7-SSH TimeZone Not Found Issue
« Reply #1 on: June 06, 2015, 12:43:24 AM »
I do not aware any change in 6.1 related to TZ.

Can you provide a minimal C# test source code to reproduce the problem?

Which MONO version are you using?
« Last Edit: June 06, 2015, 12:48:09 AM by bmarkus »
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline cmurd

  • Newbie
  • *
  • Posts: 3
Re: piCore-6.1beta1_v7-SSH TimeZone Not Found Issue
« Reply #2 on: June 08, 2015, 10:06:54 AM »
The version of Mono on 6.1 is: Mono JIT compiler version 4.0.1 (tarball Thu May 14 14:43:09 UTC 2015)
The version of Mono on 6.0 is: Mono JIT compiler version 3.10.0 (tarball Tue Dec  2 14:27:05 UTC 2014)

Here is a small program which will reproduce issue on 6.1, when "tz=UTC" is not added to cmdline:

Code: [Select]
class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(DateTime.Now);
        Console.WriteLine(DateTime.UtcNow);
    }
}

The program is compiled using Visual Studio 2013. I haven't had the time to check differences of TimeZone classes in Mono 3.10.0 and 4.0.1, but there appears to be some recent changes in the relevant classes.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: piCore-6.1beta1_v7-SSH TimeZone Not Found Issue
« Reply #3 on: June 08, 2015, 10:37:57 AM »
Thanks for the code. The good point is that compiling it on piCore 6.1 (adding using System;) with Mono 4.0.1.18 behavior is the same :)

You can add TZ info to command line as you did, or add a small shell script to /etc/profile.d like

Code: [Select]
#!/bin/sh

export TZ=UTC
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline cmurd

  • Newbie
  • *
  • Posts: 3
Re: piCore-6.1beta1_v7-SSH TimeZone Not Found Issue
« Reply #4 on: June 08, 2015, 01:38:09 PM »
Good to hear.

Thanks for the shell script idea as well Béla!

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: piCore-6.1beta1_v7-SSH TimeZone Not Found Issue
« Reply #5 on: June 08, 2015, 02:29:23 PM »
In the next release TZ will be set to UTC by default
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."