changeset 41:d07aa7644c66

bit more fiddling
author Matt Johnston <matt@ucc.asn.au>
date Fri, 28 Jun 2013 23:16:00 +0800
parents 5a7a0ef8a958
children 082c8294c86b
files Makefile main.c pihelp.graffle
diffstat 3 files changed, 42 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Thu Jun 27 19:25:38 2013 +0800
+++ b/Makefile	Fri Jun 28 23:16:00 2013 +0800
@@ -38,8 +38,8 @@
 #LOCKBIT
 # prevent bootloader write protect:
 # -U lock:w:0x2f:m
-# 0  unused bit7
-# 0  unused
+# X  unused bit7
+# X  unused
 # 1 blb12  no writing to bootloader
 # 0 blb11
 # 1 blb02  bootloader can write to app
@@ -61,8 +61,8 @@
 # ATMega8 fuse bits used above (fuse bits for other devices are different!):
 # Example for 8 MHz internal oscillator
 # Fuse high byte:
-# 0xd9 = 1 1 0 1   1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000)
-#        ^ ^ ^ ^   ^ ^ ^------ BOOTSZ0
+# 0xdb = 1 1 0 1   1 0 1 1 <-- BOOTRST (boot reset vector at 0x0000)
+#        ^ ^ ^ ^   ^ ^ ^------ BOOTSZ0 (2048 bytes bootloader)
 #        | | | |   | +-------- BOOTSZ1
 #        | | | |   +---------- EESAVE (set to 0 to preserve EEPROM over chip erase)
 #        | | | +-------------- WDTON
--- a/main.c	Thu Jun 27 19:25:38 2013 +0800
+++ b/main.c	Fri Jun 28 23:16:00 2013 +0800
@@ -175,6 +175,8 @@
 
     DDR_PI_WARNING |= _BV(PIN_PI_WARNING);
 
+    DDR_PI_RESET &= ~_BV(PIN_PI_RESET); 
+
 #if 0
     // set pullup
     PORTD |= _BV(PD2);
@@ -303,7 +305,13 @@
 hmac_file(const char* fn)
 {
     uint8_t res;
-    struct partition_struct* partition = partition_open(sd_raw_read, sd_raw_read_interval, 0, 0, 0);
+
+    struct sd_raw_info disk_info;
+    sd_raw_get_info(&disk_info);
+    sd_serial = disk_info.serial;
+    printf_P(PSTR("serial %lx\n"), sd_serial);
+
+    struct partition_struct* partition = partition_open(sd_raw_read, sd_raw_read_interval, sd_raw_write, sd_raw_write_interval, 1);
 
     if (!partition)
     {
@@ -325,10 +333,6 @@
         return;
     }
 
-    struct sd_raw_info disk_info;
-    sd_raw_get_info(&disk_info);
-    sd_serial = disk_info.serial;
-
     struct fat_dir_struct* dd = fat_open_dir(fs, &directory);
     if (!dd)
     {
@@ -342,7 +346,7 @@
         return;
     }
 
-    fat_read_file(fd, conf_start, sizeof(conf_start)-1);
+    fat_read_file(fd, (uint8_t*)conf_start, sizeof(conf_start)-1);
     conf_start[sizeof(conf_start)-1] = '\0';
 
     fat_close_file(fd);
@@ -372,13 +376,17 @@
 {
     PORT_PI_RESET &= ~_BV(PIN_PI_RESET);
     DDR_PI_RESET |= _BV(PIN_PI_RESET);
-    _delay_ms(200);
+    long_delay(200);
+
+    printf_P(PSTR("about to raw init\n"));
 
     sd_raw_init();
+    printf_P(PSTR("done raw init\n"));
     hmac_file(param);
+    printf_P(PSTR("conf_start '%s'\n"), conf_start);
     sd_raw_deinit();
 
-    _delay_ms(200);
+    long_delay(200);
 
     DDR_PI_RESET &= ~_BV(PIN_PI_RESET);	
 }
@@ -767,6 +775,7 @@
 
     // disable wdt
     wdt_disable();
+    MCUSR = 0;
 
     // disable interrupts
     TIMSK0 = 0;
@@ -1010,7 +1019,6 @@
     LOCAL_PSTR(status);
     LOCAL_PSTR(random);
     LOCAL_PSTR(prog);
-    LOCAL_PSTR(testsd);
     LOCAL_HELP(set_params, "<long_limit> <short_limit> <newboot_limit>");
     LOCAL_HELP(set_key, "20_byte_hex>");
     LOCAL_HELP(oneshot, "<timeout>");
@@ -1018,7 +1026,6 @@
     LOCAL_HELP(random, "<admux> <nbytes>");
     LOCAL_HELP(hmac, "<key_index> <20_byte_hex_data>");
     LOCAL_HELP(decrypt, "<key_index> <20_byte_hmac|16_byte_aes_block>");
-    LOCAL_HELP(testsd, "<filename>");
 
     static const struct handler {
         PGM_P name;
@@ -1040,7 +1047,6 @@
         {random_str, cmd_random, random_help},
         {vcc_str, cmd_vcc, NULL},
         {reset_str, cmd_reset, NULL},
-        {testsd_str, cmd_testsd, testsd_help},
         {prog_str, cmd_prog, prog_help},
     };
 
@@ -1234,7 +1240,6 @@
     {
         // pull it low
         DDR_PI_RESET |= _BV(PIN_PI_BOOT);
-
     }
 }
 
--- a/pihelp.graffle	Thu Jun 27 19:25:38 2013 +0800
+++ b/pihelp.graffle	Fri Jun 28 23:16:00 2013 +0800
@@ -2992,7 +2992,7 @@
 		</dict>
 		<dict>
 			<key>Bounds</key>
-			<string>{{642.06523940822649, 195.79799294748042}, {55, 20}}</string>
+			<string>{{650.50931573509411, 202.59816909112666}, {55, 20}}</string>
 			<key>Class</key>
 			<string>ShapedGraphic</string>
 			<key>FitText</key>
@@ -3017,8 +3017,10 @@
 			<dict>
 				<key>ID</key>
 				<integer>1450</integer>
+				<key>Offset</key>
+				<real>-6.8001761436462402</real>
 				<key>Position</key>
-				<real>0.85406345129013062</real>
+				<real>0.088183894753456116</real>
 				<key>RotationType</key>
 				<integer>0</integer>
 			</dict>
@@ -3026,6 +3028,11 @@
 			<string>Rectangle</string>
 			<key>Style</key>
 			<dict>
+				<key>fill</key>
+				<dict>
+					<key>Draws</key>
+					<string>NO</string>
+				</dict>
 				<key>shadow</key>
 				<dict>
 					<key>Draws</key>
@@ -3053,18 +3060,25 @@
 		<dict>
 			<key>Class</key>
 			<string>LineGraphic</string>
+			<key>Head</key>
+			<dict>
+				<key>ID</key>
+				<integer>1364</integer>
+				<key>Info</key>
+				<integer>5</integer>
+			</dict>
 			<key>ID</key>
 			<integer>1450</integer>
 			<key>OrthogonalBarAutomatic</key>
-			<true/>
+			<false/>
 			<key>OrthogonalBarPoint</key>
 			<string>{0, 0}</string>
 			<key>OrthogonalBarPosition</key>
-			<real>-1</real>
+			<real>45.686443328857422</real>
 			<key>Points</key>
 			<array>
 				<string>{702.24511708341549, 205.79799294748042}</string>
-				<string>{664.69325875965797, 206.76329169224098}</string>
+				<string>{584.76111409893213, 365.24458410714874}</string>
 			</array>
 			<key>Style</key>
 			<dict>
@@ -29416,7 +29430,7 @@
 	<key>MasterSheets</key>
 	<array/>
 	<key>ModificationDate</key>
-	<string>2013-06-27 11:14:51 +0000</string>
+	<string>2013-06-28 03:15:20 +0000</string>
 	<key>Modifier</key>
 	<string>Matt</string>
 	<key>NotesVisible</key>
@@ -29521,7 +29535,7 @@
 		<key>SidebarWidth</key>
 		<integer>120</integer>
 		<key>VisibleRegion</key>
-		<string>{{161.35266220843107, 0}, {918.84060934262232, 604.83093738010689}}</string>
+		<string>{{180.19324252618199, 12.077295075481366}, {918.84060934262232, 604.83093738010677}}</string>
 		<key>Zoom</key>
 		<real>1.0349999666213989</real>
 		<key>ZoomValues</key>