Mercurial > pihelp
diff main.c @ 41:d07aa7644c66
bit more fiddling
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 28 Jun 2013 23:16:00 +0800 |
parents | 9e888708f33d |
children | 082c8294c86b |
line wrap: on
line diff
--- 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); - } }