RetroBSD

2.11BSD operating system for microcontrollers
It is currently Thu Feb 20, 2020 12:14 am

All times are UTC




Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sat Sep 26, 2015 7:57 pm 
Committer
User avatar

Joined: Thu Oct 11, 2012 8:45 am
Posts: 1801
Location: Room 217, Floor 8, Arm 8, Wheel S7, Mars Base Alpha 3
Quote:
I can't remember how to make a new topic, so I guess this will have to do?

You go to the section where you want to post the topic and press the great big
Image
button.

What's so hard to remember about that?

_________________
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".


Top
 Profile  
 
PostPosted: Sat Sep 26, 2015 8:48 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Updated the zip file above - the i2c.h needs delays between transitions to work reliably with 6 chips hanging on the bus.

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sat Sep 26, 2015 10:17 pm 
Contributor

Joined: Mon Nov 12, 2012 1:34 pm
Posts: 1092
Hi Matt,

Thanks.

I use Dillo as my browser of choice.


Big fat button is only on Big FAT BROWSER :).

When I start Firefox it all gets VERY slow ( multiple minutes ).

Seamonkey is much better but still a PIG.

I guess I need a few terabytes of ram and maybe a multiple gigahertz cpu? And maybe a direct connect to the Google giggle monitoring system :).


So I guess I will have to do without the big fat button, sigh :).

Are you close to having an MZ..EF board for me to order?

Lots of fun.

Wiz


Top
 Profile  
 
PostPosted: Sat Sep 26, 2015 10:27 pm 
Committer
User avatar

Joined: Thu Oct 11, 2012 8:45 am
Posts: 1801
Location: Room 217, Floor 8, Arm 8, Wheel S7, Mars Base Alpha 3
Maybe you should upgrade your computer out of the stone age... You don't have a multiple GHz CPU?! It mist be ancient! Mine is old and is a quad core 2.8GHz Xeon...

You're supposed to be using silicon to create microchips, not monoliths :P

_________________
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".


Top
 Profile  
 
PostPosted: Sun Sep 27, 2015 12:39 pm 
Contributor

Joined: Mon Nov 12, 2012 1:34 pm
Posts: 1092
Hi Matt,

I gotta get some friends like you to 'discard' their old computers in my direction :). Actually a friend gave me an old box computer dual whatever. No hard drive, but boots great from SD/memory stick. Fastest computer I own, but at factory not at home.

Booting from SD is NICE!! I can image copy the OS and then play and easily get back to something working when some software update kills things. This has saved me a LOT of time already!!

This box is an old Dell with 'only' 384MB of ram. Gotta wonder where PIC32 sits in this bloated world?

Not sure if you have any real connections at chipkit.org, but it stopped working except with BIG WEB BROWSER, so I don't look at it anymore.... I can still see most news sites and slashdot so at least these still work.

Any comments on PIC32MZ...EF stuff?

Lots of fun :).

Wiz


Top
 Profile  
 
PostPosted: Sun Sep 27, 2015 12:46 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Wiz, I've opened a new topic for you here:
"Request to open a new topic"
viewtopic.php?f=1&t=37296&p=41986#p41986
Just go there and post the Subject of a topic you want to start, and I will do for you.
;)

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sun Sep 27, 2015 12:53 pm 
Committer
User avatar

Joined: Thu Oct 11, 2012 8:45 am
Posts: 1801
Location: Room 217, Floor 8, Arm 8, Wheel S7, Mars Base Alpha 3
384MB of RAM?! How do you cope?! What do you run - Windows 3.1???

(and yes, I do have a Windows 3.1 VM on my computer :P Well, WFW 3.11 anyway - one of the best versions of Windows MS ever did...!)

To run modern software you require at least 1GB of RAM. Anything less and you're just asking to thrash your hard drive. And the cost of RAM these days is so low there's no excuse.

Even SSDs are now getting cheap. I ordered one for my netbook last night - equivalent of 25p per GB. Insane!

And for an old computer like yours there's plenty of memory for almost free on eBay. And if you want to buy it new then there's always Crucial. I upgraded my old Dell box from 4GB to 12GB and now I can run Linux as the native OS, plus a VM of Windows 10 and a VM of OS X all at the same time without breaking a sweat.

Oh, and no I don't have anything to do with the site design of chipkit.net, only some of the content. It's not a big site and doesn't require a "big" browser - it just requires a computer that's not from the stone age.

Come on, pull yourself into the 20th century! (yes, I know we're in the 21st now, but one step at a time, eh?)

I am not developing for the MZ at the moment. There's not really any point until we have full support for the USB since I don't like adding external UART interface chips. We're part way there - we are testing the Harmony USB stack on MX devices at the moment - in fact I am typing this using an old Amiga 500 keyboard that I have interfaced to a WF32 that is appearing as a keyboard and a mouse to my computer. Joyous typing on a proper keyboard for once instead of suffering a spongy modern piece of crud.

Once we have full support for the USB on the MZ and full support for the EF chips I will start working on boards for them again. As it is I can't even get the EF to run (or I couldn't last time I tried, but we have some new startup code for them now I think).

_________________
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".


Top
 Profile  
 
PostPosted: Fri Oct 09, 2015 10:44 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Trying to introduce the dst into the driver, but confused.
The new rtc3231rd2os.c
Code:
// rtc3231rd2os.c
// Simple DS3231 RTC READING (or DS1307)
// Sets the RetroBSD system time
// Use: rtc3231rd2os minuteswest dsttime
// minuteswest is a time difference from GMT towards West in minutes
// dsttime is a type of dst correction
/* DST_NONE    0   not on dst
   DST_USA     1   USA style dst
   DST_AUST    2   Australian style dst
   DST_WET     3   Western European dst
   DST_MET     4   Middle European dst
   DST_EET     5   Eastern European dst
   DST_CAN     6   Canada
*/
// ie. "rtc3231rd2os -60 4" takes the GMT time (out of your DS3231)
//   and sets the MET timezone with dst correction
// Epochtime is the GMT unix time (as set in your DS3231)
// Compiled under SmallerC
// Pito 9/2015, 10/2015

unsigned char decToBcd(unsigned char val){
   return ( (val/10*16) + (val%10) );
}

unsigned char bcdToDec(unsigned char val){
   return ( (val/16*10) + (val%16) );
}

unsigned char hh, mn, ss, yy, mm, dd, wd, cm;

#include "i2c.h"
#include "DS3231.h"
#include <sys/time.h>

// Time starts for RetroBSD on 1970-1-1
const int EPOCH_YEAR = 1970;
// Days since Epoch
int daysSinceEpoch(int y, int m, int d) {
   y = y + 2000;
   if (m < 3) {
   m += 12;
   y--;
  }
   return (365 * (y + 1 - EPOCH_YEAR)  + y / 4 - (EPOCH_YEAR - 1) / 4
   + (153 * m - 2) / 5 + d - 398);
}
// Seconds since Epoch */
int secondsSinceEpoch(   int year,
            int month,
            int day,
            int hour,
            int minute,
            int second) {
  int days = daysSinceEpoch(year, month, day);
  return (second + 60 * (minute + 60 * (hour + 24 * days)));
}


int main (int argc, char **argv)
{
   int epoch_time;
   
   struct timeval now;
   struct timezone tz;
   
   int mwest, dst;
   
   mwest = atoi(argv[1]);
   dst = atoi(argv[2]);
   
   // init the pins driver !!
   if (pinsinit() < 0) return -1;
   // init i2c driver
   I2CInit();

   if (DS3231_Read()< 0){
      printf("### RTC NOT AVAILABLE!\n");
      pinsclose();
      return -1;
   }

   ss = bcdToDec(ss & 0x7F);
   mn = bcdToDec(mn & 0x7F);
   hh = bcdToDec(hh & 0x3F);
   dd = bcdToDec(dd & 0x3F);
   wd = bcdToDec(wd & 0x07);
   cm = bcdToDec(cm & 0x1F);
   yy = bcdToDec(yy);
   
   epoch_time = secondsSinceEpoch(yy, cm, dd, hh, mn, ss); // comes from RTC's regs
   
   now.tv_sec = (long)(epoch_time);  // in seconds since 1970-1-1
   now.tv_usec = 0L;

   tz.tz_minuteswest = mwest;  // ie. mwest = -60 is MET
   tz.tz_dsttime = dst;  // ie. dst = 4 is MET dst
   
   if(settimeofday(&now, &tz) == 0) {
       // printf("..settimeofday() successful..\r\n");
   }
   else {
       // printf("..settimeofday() failed..\r\n");
        return -1;
   }
   //printf("Epochtime %d\r\n", epoch_time);
   //printf("%02d%02d%02d%02d%02d.%02d\n",yy,cm,dd,hh,mn,ss);

   pinsclose();

   return 0;
}

When I set my RTC into GMT, and copy HW RTC into system time (-60 is MET and 4 is dst for MET)
Code:
# ./rtc3231rd2os -60 4
# date
Fri Oct 09 11:29:27 MET 2015
# date -un
Fri Oct 09 10:29:37 GMT 2015

I still do not see 2h difference (MET is +1h from GMT and DST is on, so it should be 12:29 MET).
:?

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sat Oct 24, 2015 9:43 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
The newest driver - we do not need to set minuteswest and dst, it will be done simply via TZ.
The new rtc3231rd2os.c
Code:
// rtc3231rd2os.c
// Simple DS3231 RTC READING (or DS1307)
// Sets the RetroBSD system time
// Use: rtc3231rd2os
// Always set your hw RTC to GMT time!
// Compiled under SmallerC
// Pito 9/2015, 10/2015

unsigned char decToBcd(unsigned char val){
   return ( (val/10*16) + (val%10) );
}

unsigned char bcdToDec(unsigned char val){
   return ( (val/16*10) + (val%16) );
}

unsigned char hh, mn, ss, yy, mm, dd, wd, cm;

#include "i2c.h"
#include "DS3231.h"
#include <sys/time.h>

// Time starts for RetroBSD on 1970-1-1
const int EPOCH_YEAR = 1970;
// Days since Epoch
int daysSinceEpoch(int y, int m, int d) {
   y = y + 2000;
   if (m < 3) {
   m += 12;
   y--;
  }
   return (365 * (y + 1 - EPOCH_YEAR)  + y / 4 - (EPOCH_YEAR - 1) / 4
   + (153 * m - 2) / 5 + d - 398);
}
// Seconds since Epoch */
int secondsSinceEpoch(   int year,
            int month,
            int day,
            int hour,
            int minute,
            int second) {
  int days = daysSinceEpoch(year, month, day);
  return (second + 60 * (minute + 60 * (hour + 24 * days)));
}


int main (void)
{
   int epoch_time;
   
   struct timeval now;

        initdelay();
   
   // init the pins driver !!
   if (pinsinit() < 0) exit(-1);

   // init i2c driver
   I2CInit();

   if (DS3231_Read()< 0){
      printf("### RTC NOT AVAILABLE!\n");
      pinsclose();
      exit(-1);
   }

   ss = bcdToDec(ss & 0x7F);
   mn = bcdToDec(mn & 0x7F);
   hh = bcdToDec(hh & 0x3F);
   dd = bcdToDec(dd & 0x3F);
   wd = bcdToDec(wd & 0x07);
   cm = bcdToDec(cm & 0x1F);
   yy = bcdToDec(yy);
   
   epoch_time = secondsSinceEpoch(yy, cm, dd, hh, mn, ss); // comes from RTC's regs
   
   now.tv_sec = (long)(epoch_time);  // in seconds since 1970-1-1
   now.tv_usec = 0L;

   if(settimeofday(&now, NULL) == 0) {
       // printf("..settimeofday() successful..\r\n");
   }
   else {
       // printf("..settimeofday() failed..\r\n");
        return -1;
   }
   //printf("Epochtime %d\r\n", epoch_time);
   //printf("%02d%02d%02d%02d%02d.%02d\n",yy,cm,dd,hh,mn,ss);

   pinsclose();

   return 0;
}

Code:
# TZ=CET
# export TZ
# rtc3231rd2os
# date
Sat Oct 24 11:46:20 CEST 2015
# date -u
Sat Oct 24 09:46:33 GMT 2015
#

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Tue Oct 27, 2015 6:49 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
Makes sense to convert your sources into a generic i2c-over-gpio library, parameterized for flexible pin asignment and RTC detection. Next step will be to add options to the standard date utility to set the system time from RTC clock.


Top
 Profile  
 
PostPosted: Tue Oct 27, 2015 7:39 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
My 5 i2c devices attached are ready for testing :)

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron




Powered by phpBB® Forum Software © phpBB Group

BSD Daemon used with permission