diff --git a/bin/cc430-bsl.py b/bin/cc430-bsl.py index 068f8c0..a99c932 100755 --- a/bin/cc430-bsl.py +++ b/bin/cc430-bsl.py @@ -11,7 +11,7 @@ import serial, time, sys, argparse, progressbar; class BSL: def __init__(self, port): - print("Opening %s" % port); + #print("Opening %s" % port); self.serial=serial.Serial(port, baudrate=9600, parity=serial.PARITY_EVEN, @@ -107,9 +107,7 @@ class BSL: #Password must be 32 bytes; read from a file otherwise. if len(password)!=32: - print "Loading password from %s." % password; password=self.passwordfromfile(password); - print len(password); assert(len(password)==32); @@ -260,14 +258,11 @@ def coredump(bsl): print bulk.encode('hex'); def dmesg(bsl): - """Prints all of memory.""" + """Prints the dmesg buffer.""" - print "\n\n\nDumping most of memory as a read test."; - ##Dump RAM - bulk=bsl.readbulk(0x1C00,4096) - print "Got %d bytes of RAM." % len(bulk); - print bulk.encode('hex'); + bulk=bsl.readbulk(0x2400,2048) + print bulk; def writetest(bsl): """Tests writing an image to Flash.""" @@ -303,7 +298,7 @@ if __name__=='__main__': bsl.masserase(); bsl.unlock(); if args.unlock!=None: - print "Unlocking." + #print "Unlocking." bsl.unlock(args.password); if args.file!=None: print "Writing %s as Intel hex." % args.file diff --git a/firmware/Makefile b/firmware/Makefile index e0fe767..e8a555c 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -28,5 +28,7 @@ erase: $(BSL) -e flash: goodwatch.hex $(BSL) -etf goodwatch.hex +dmesg: + ../bin/cc430-bsl.py -P goodwatch.hex -uD diff --git a/firmware/dmesg.c b/firmware/dmesg.c index a8e3455..68f15f0 100644 --- a/firmware/dmesg.c +++ b/firmware/dmesg.c @@ -5,7 +5,7 @@ #include #include -#define DMESGLEN 1024 +#define DMESGLEN 2048 /* These three buffers are declared to be in the .noinit section so that a reboot will not wipe the buffer. Because the memory will be @@ -13,12 +13,13 @@ startup if the magic is corrupted or if the index is unreasonable. */ -//! DMESG buffer itself. -char dmesg_buffer[DMESGLEN] __attribute__ ((section (".noinit"))); -//! Index within that buffer. -int dmesg_index __attribute__ ((section (".noinit"))); //! Ought to be 0xdeadbeef except after power loss. uint32_t dmesg_magic __attribute__ ((section (".noinit"))); +//! Index within that buffer. +int dmesg_index __attribute__ ((section (".noinit"))); + +//! DMESG buffer itself. +char *dmesg_buffer=(char*)0x2400; //! Writes a character to the dmesg buffer. int putchar(int c){ @@ -36,4 +37,5 @@ void dmesg_clear(){ void dmesg_init(){ if(dmesg_magic!=0xdeadbeef || dmesg_index>=DMESGLEN) dmesg_clear(); + printf("dmesg_init();\n"); } diff --git a/firmware/memory.x b/firmware/memory.x index 4bf12f8..f00b1b4 100644 --- a/firmware/memory.x +++ b/firmware/memory.x @@ -1,3 +1,7 @@ +/*! \file memory.x + \brief Fork of linker script to reserve 2kB for dmesg. +*/ + MEMORY { sfr : ORIGIN = 0x0000, LENGTH = 0x0010 /* END=0x0010, size 16 */ peripheral_8bit : ORIGIN = 0x0010, LENGTH = 0x00f0 /* END=0x0100, size 240 */ @@ -8,7 +12,9 @@ MEMORY { infoc : ORIGIN = 0x1880, LENGTH = 0x0080 /* END=0x1900, size 128 */ infob : ORIGIN = 0x1900, LENGTH = 0x0080 /* END=0x1980, size 128 */ infoa : ORIGIN = 0x1980, LENGTH = 0x0080 /* END=0x1a00, size 128 */ - ram (wx) : ORIGIN = 0x1c00, LENGTH = 0x0ffe /* END=0x2bfe, size 4094 */ +/*ram (wx) : ORIGIN = 0x1c00, LENGTH = 0x0ffe /* END=0x2bfe, size 4094 */ + ram (wx) : ORIGIN = 0x1c00, LENGTH = 0x0800 /* We use half of RAM for C code. */ + dmesg (wx) : ORIGIN = 0x2400, LENGTH = 0x0800 /* Second half just for dmesg. */ rom (rx) : ORIGIN = 0x8000, LENGTH = 0x7f80 /* END=0xff80, size 32640 */ vectors : ORIGIN = 0xff80, LENGTH = 0x0080 /* END=0x10000, size 128 as 64 2-byte segments */ /* Remaining banks are absent */ @@ -19,6 +25,7 @@ MEMORY { } REGION_ALIAS("REGION_TEXT", rom); REGION_ALIAS("REGION_DATA", ram); +REGION_ALIAS("REGION_DMESG", dmesg); REGION_ALIAS("REGION_FAR_ROM", far_rom); PROVIDE (__info_segment_size = 0x80); PROVIDE (__infod = 0x1800);