Ika Shouyu Poppoyaki - LPC82x supported
Fork of ika_shouyu_poppoyaki by
Revision 29:96e28bc1bd99, committed 2013-09-20
- Comitter:
- okano
- Date:
- Fri Sep 20 01:48:26 2013 +0000
- Parent:
- 28:689c3880e0e4
- Child:
- 30:e0d7524661ca
- Commit message:
- parameter added to writing and verifying functions to report transferred size
Changed in this revision
--- a/_user_settings.h Fri Sep 20 00:40:08 2013 +0000 +++ b/_user_settings.h Fri Sep 20 01:48:26 2013 +0000 @@ -1,3 +1,5 @@ +#ifndef MBED_ISP___USER_SETTINGS__ +#define MBED_ISP___USER_SETTINGS__ #define SOURCE_FILE "/local/bin" @@ -15,3 +17,5 @@ #define AUTO_PROGRAM_START + +#endif // MBED_ISP___USER_SETTINGS__ \ No newline at end of file
--- a/command_interface.cpp Fri Sep 20 00:40:08 2013 +0000 +++ b/command_interface.cpp Fri Sep 20 01:48:26 2013 +0000 @@ -2,6 +2,7 @@ #include "command_interface.h" #include "serial_utilities.h" #include "ika.h" +#include "_user_settings.h" int try_and_check( char *command, char *expected_return_str, int mode )
--- a/error_code.h Fri Sep 20 00:40:08 2013 +0000 +++ b/error_code.h Fri Sep 20 01:48:26 2013 +0000 @@ -21,4 +21,4 @@ ERROR_DATA_DOES_NOT_MATCH }; -#endif +#endif // MBED_ISP__ERROR_CODE__
--- a/main.cpp Fri Sep 20 00:40:08 2013 +0000 +++ b/main.cpp Fri Sep 20 01:48:26 2013 +0000 @@ -81,6 +81,7 @@ target_param *tpp; int data_size; int last_sector; + int transferred_size; int err; if ( NULL == (tpp = open_target( ISP_BAUD_RATE )) ) { @@ -109,14 +110,19 @@ printf( "\r\n ==== flash writing ====\r\n" ); - if ( err = write_flash( fp, tpp ) ) + if ( err = write_flash( fp, tpp, &transferred_size ) ) return ( err ); + + printf( " -- %d bytes data are written\r\n", transferred_size ); + printf( "\r\n ==== flash reading and verifying ====\r\n" ); - if ( err = verify_flash( fp, tpp ) ) + if ( err = verify_flash( fp, tpp, &transferred_size ) ) return ( err ); + printf( " -- %d bytes data are read and verified\r\n", transferred_size ); + fclose( fp ); post_writing_process( tpp );
--- a/serial_utilities.cpp Fri Sep 20 00:40:08 2013 +0000 +++ b/serial_utilities.cpp Fri Sep 20 01:48:26 2013 +0000 @@ -107,7 +107,7 @@ *b++ = target.getc(); toggle_led( 1 ); } - + if ( timeout_flag ) return ( i ); }
--- a/target_table.h Fri Sep 20 00:40:08 2013 +0000 +++ b/target_table.h Fri Sep 20 01:48:26 2013 +0000 @@ -23,5 +23,6 @@ target_param *find_target_param( char *device_id_string ); -#endif +#endif // MBED_ISP__TARGET_TABLE__ +
--- a/verification.cpp Fri Sep 20 00:40:08 2013 +0000 +++ b/verification.cpp Fri Sep 20 01:48:26 2013 +0000 @@ -8,21 +8,21 @@ #include "error_code.h" -int verify_binary_data( FILE *fp ); -int verify_uucoded_data( FILE *fp ); +int verify_binary_data( FILE *fp, int *transferred_size_p ); +int verify_uucoded_data( FILE *fp, int *transferred_size_p ); void get_binary_from_uucode_str( char *b, int size ); -int verify_flash( FILE *fp, target_param *tpp ) +int verify_flash( FILE *fp, target_param *tpp, int *transferred_size_p ) { if ( tpp->write_type == BINARY ) - return ( verify_binary_data( fp ) ); + return ( verify_binary_data( fp, transferred_size_p ) ); else - return ( verify_uucoded_data( fp ) ); + return ( verify_uucoded_data( fp, transferred_size_p ) ); } -int verify_binary_data( FILE *fp ) +int verify_binary_data( FILE *fp, int *read_size_p ) { char command_str[ STR_BUFF_SIZE ]; int read_size = 0; @@ -34,6 +34,7 @@ unsigned long checksum = 0; unsigned long checksum_count = 0; + fseek( fp, 0, SEEK_SET ); // seek back to beginning of file flash_reading_size = 128; @@ -83,23 +84,20 @@ break; read_size += size; - -// printf( " total %d bytes read\r\n", read_size ); } error_state |= error_flag; - printf( " total %d bytes read\r", read_size ); - printf( " verification result : \"%s\"\r\n", error_flag ? "Fail" : "Pass" ); - free( bf ); free( br ); + *read_size_p = read_size; + return ( error_flag ? ERROR_DATA_DOES_NOT_MATCH : NO_ERROR ); } -int verify_uucoded_data( FILE *fp ) +int verify_uucoded_data( FILE *fp, int *read_size_p ) { char command_str[ STR_BUFF_SIZE ]; int read_size = 0; @@ -147,17 +145,14 @@ break; read_size += size; -// printf( " total %d bytes read\r", read_size ); } error_state |= error_flag; - - printf( " total %d bytes read\r", read_size ); - printf( " verification result : \"%s\"\r\n", error_flag ? "Fail" : "Pass" ); - free( bf ); free( br ); + *read_size_p = read_size; + return ( error_flag ? ERROR_DATA_DOES_NOT_MATCH : NO_ERROR ); }
--- a/verification.h Fri Sep 20 00:40:08 2013 +0000 +++ b/verification.h Fri Sep 20 01:48:26 2013 +0000 @@ -1,5 +1,5 @@ #include "target_table.h" -int verify_flash( FILE *fp, target_param *tpp ); +int verify_flash( FILE *fp, target_param *tpp, int *transferred_size_p );
--- a/writing.cpp Fri Sep 20 00:40:08 2013 +0000 +++ b/writing.cpp Fri Sep 20 01:48:26 2013 +0000 @@ -8,28 +8,28 @@ #include "error_code.h" -int write_uuencoded_data( FILE *fp, int ram_size, int sector_size, unsigned int ); -int write_binary_data( FILE *fp, int ram_size, int sector_size, unsigned int ram_start ); +int write_uuencoded_data( FILE *fp, int ram_size, int sector_size, unsigned int ram_start, int *total_size_p ); +int write_binary_data( FILE *fp, int ram_size, int sector_size, unsigned int ram_start, int *total_size_p ); int get_flash_writing_size( int ram_size, unsigned int ram_start ); -int write_flash( FILE *fp, target_param *tpp ) +int write_flash( FILE *fp, target_param *tpp, int *transferred_size_p ) { if ( tpp->write_type == BINARY ) - return ( write_binary_data( fp, tpp->ram_size, tpp->sector_size, tpp->ram_start_address ) ); + return ( write_binary_data( fp, tpp->ram_size, tpp->sector_size, tpp->ram_start_address, transferred_size_p ) ); else // UUENCODE - return ( write_uuencoded_data( fp, tpp->ram_size, tpp->sector_size, tpp->ram_start_address ) ); + return ( write_uuencoded_data( fp, tpp->ram_size, tpp->sector_size, tpp->ram_start_address, transferred_size_p ) ); } -int write_uuencoded_data( FILE *fp, int ram_size, int sector_size, unsigned int ram_start ) +int write_uuencoded_data( FILE *fp, int ram_size, int sector_size, unsigned int ram_start, int *total_size_p ) { #define BYTES_PER_LINE 45 char command_str[ STR_BUFF_SIZE ]; long checksum = 0; + int size; int total_size = 0; - int size; int flash_writing_size; int lines_per_transfer; @@ -37,6 +37,7 @@ char *b; + initialize_uue_table(); flash_writing_size = get_flash_writing_size( ram_size, ram_start ); @@ -96,19 +97,21 @@ } free( b ); + *total_size_p = total_size; return ( NO_ERROR ); } -int write_binary_data( FILE *fp, int ram_size, int sector_size, unsigned int ram_start ) +int write_binary_data( FILE *fp, int ram_size, int sector_size, unsigned int ram_start, int *total_size_p ) { char command_str[ STR_BUFF_SIZE ]; - int total_size = 0; + int total_size = 0; int size; int flash_writing_size; char *b; + flash_writing_size = 256; if ( NULL == (b = (char *)malloc( flash_writing_size * sizeof( char ) )) ) @@ -143,6 +146,7 @@ } free( b ); + *total_size_p = total_size; return ( NO_ERROR ); }
--- a/writing.h Fri Sep 20 00:40:08 2013 +0000 +++ b/writing.h Fri Sep 20 01:48:26 2013 +0000 @@ -1,7 +1,7 @@ #include "target_table.h" -int write_flash( FILE *fp, target_param *tpp ); +int write_flash( FILE *fp, target_param *tpp, int *transferred_size ); void add_isp_checksum( char *b ); int post_writing_process( target_param *tpp );