diff --git a/bin/buildtime.py b/bin/buildtime.py new file mode 100755 index 0000000..2a667de --- /dev/null +++ b/bin/buildtime.py @@ -0,0 +1,25 @@ +#!/usr/bin/python2 + + +## This is a quick and dirty script for placing the build time into +## the GoodWatch's source code, much as we put the git tag. +## Previously, we just wrote the compile time to memory at 0xff00, but +## that left it out of the ELF file, causing some confusion. + +import time, sys; + + +lt=time.localtime() +#See firmware/rtc.c for the format. +timestr=( + #Hour, Minute, Second first. + chr(lt.tm_hour)+chr(lt.tm_min)+chr(lt.tm_sec)+"\xFF"+ + #u16 Year, u8 Month, u8 Day + chr(lt.tm_year&0xFF)+chr(lt.tm_year>>8)+chr(lt.tm_mon)+chr(lt.tm_mday) +); + +sys.stdout.write("#define BUILDTIME \""); +for b in timestr: + sys.stdout.write("\\x%02x"%ord(b)); +sys.stdout.write("\"\n"); + diff --git a/bin/cc430-bsl.py b/bin/cc430-bsl.py index ad06726..a2f09ff 100755 --- a/bin/cc430-bsl.py +++ b/bin/cc430-bsl.py @@ -336,8 +336,6 @@ if __name__=='__main__': help='Prints the dmesg.',action='count'); parser.add_argument('-u','--unlock', help='Unlock BSL.',action='count'); - parser.add_argument('-t','--time', - help='Set the Time.',action='count'); parser.add_argument('-r','--rate', help='Baud Rate', default=9600); @@ -371,16 +369,22 @@ if __name__=='__main__': if args.file!=None: print "Writing %s as Intel hex." % args.file bsl.writeihexfile(args.file); - if args.time!=None: - lt=time.localtime() - #See firmware/rtc.c for the format. - timestr=( - #Hour, Minute, Second first. - chr(lt.tm_hour)+chr(lt.tm_min)+chr(lt.tm_sec)+"\xFF"+ - #u16 Year, u8 Month, u8 Day - chr(lt.tm_year&0xFF)+chr(lt.tm_year>>8)+chr(lt.tm_mon)+chr(lt.tm_mday) - ); - bsl.write(0xFF00,timestr); + + ## Peviously, we manually wrote the time to 0xFF00. This is now + ## handled by buildtime.h, but I wouldn't object to writing the + ## time to SRAM. --Travis + + # if args.time!=None: + # lt=time.localtime() + # #See firmware/rtc.c for the format. + # timestr=( + # #Hour, Minute, Second first. + # chr(lt.tm_hour)+chr(lt.tm_min)+chr(lt.tm_sec)+"\xFF"+ + # #u16 Year, u8 Month, u8 Day + # chr(lt.tm_year&0xFF)+chr(lt.tm_year>>8)+chr(lt.tm_mon)+chr(lt.tm_mday) + # ); + # bsl.write(0xFF00,timestr); + if args.dump!=None: coredump(bsl); if args.dmesg!=None: diff --git a/firmware/.gitignore b/firmware/.gitignore index 79ed636..66230e3 100644 --- a/firmware/.gitignore +++ b/firmware/.gitignore @@ -1,2 +1,3 @@ config.h +buildtime.h libs/assembler diff --git a/firmware/Makefile b/firmware/Makefile index a0eb4e7..04d33c2 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -87,10 +87,13 @@ apps= $(APPS_OBJ) all: goodwatch.hex -*.c: githash.h +*.c: githash.h buildtime.h githash.h: echo "#define GITHASH" 0x`git rev-parse HEAD | head -c7` > githash.h +buildtime.h: + ../bin/buildtime.py >buildtime.h + goodwatch.elf: $(modules) $(apps) *.h $(CC) -T msp430.x -o goodwatch.elf $(modules) $(apps) ../bin/printsizes.py goodwatch.elf || echo "Please install python-pyelftools." @@ -99,14 +102,14 @@ goodwatch.hex: goodwatch.elf msp430-objcopy -O ihex goodwatch.elf goodwatch.hex clean: - rm -rf *~ */*~ *.hex *.elf *.o */*.o goodwatch githash.h html latex goodwatch.elf energytrace.png energytrace.txt + rm -rf *~ */*~ *.hex *.elf *.o */*.o goodwatch githash.h buildtime.h html latex goodwatch.elf energytrace.png energytrace.txt erase: $(BSL) -e sbwflash: goodwatch.hex codeplug.hex mspdebug tilib "prog goodwatch.elf" "load codeplug.hex" flash: goodwatch.hex - $(BSL) -etf goodwatch.hex + $(BSL) -ef goodwatch.hex dmesg: $(BSL) -P goodwatch.hex -uD sbwdmesg: diff --git a/firmware/rtc.c b/firmware/rtc.c index f400f26..8e222e0 100644 --- a/firmware/rtc.c +++ b/firmware/rtc.c @@ -9,12 +9,15 @@ #include "api.h" #include "apps/calibrate.h" +//Automatically generated, not a part of the git repo. +#include "buildtime.h" + //! If this is 0xdeadbeef, the ram time is good. static unsigned long magicword __attribute__ ((section (".noinit"))); //! Time and date, in case of a reboot. static unsigned char ramsavetime[8] __attribute__ ((section (".noinit"))); //! ROM copy of the manufacturing time. -unsigned char *romsavetime=(unsigned char*) 0xFF00; +unsigned char *romsavetime=(unsigned char*) BUILDTIME; // Alarm tone status static unsigned int alarm_ringing = 0;