Tiny Core Linux
Tiny Core Base => Raspberry Pi => Topic started by: cmurd 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?
-
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?
-
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:
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.
-
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
#!/bin/sh
export TZ=UTC
-
Good to hear.
Thanks for the shell script idea as well Béla!
-
In the next release TZ will be set to UTC by default