Code to load a LPC1114 over tx/rx. I have only tested with a 1114 chip but it should work with other LPC uControllers

Dependencies:   DirectoryList MODSERIAL mbed

Fork of ika_shouyu_poppoyaki by Tedd OKANO

Files at this revision

API Documentation at this revision

Comitter:
okano
Date:
Thu Sep 26 11:51:03 2013 +0000
Parent:
33:ce9fff4cbf09
Child:
35:0b434ef4af49
Commit message:
[1]; fix: verification function was having a bug. 3/4 of the code was having chance of verification fail.; ; [2]; "ENABLE_WRITING" option added (see "_user_setting.h"). Verifying-only operation can be done with disabling this word

Changed in this revision

_user_settings.h Show annotated file Show diff for this revision Revisions of this file
isp.cpp Show annotated file Show diff for this revision Revisions of this file
isp.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
verification.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/_user_settings.h	Wed Sep 25 04:00:04 2013 +0000
+++ b/_user_settings.h	Thu Sep 26 11:51:03 2013 +0000
@@ -19,6 +19,10 @@
 #define     AUTO_PROGRAM_START
 
 
+//  disabling "ENABLE_WRITING" can be used for "verification only" operation.
+#define     ENABLE_WRITING
+
+
 //  enable "ENABLE_VERIFYING" to let perform verification by comparing "bin" file and flash read data.
 #define     ENABLE_VERIFYING
 
--- a/isp.cpp	Wed Sep 25 04:00:04 2013 +0000
+++ b/isp.cpp	Thu Sep 26 11:51:03 2013 +0000
@@ -63,6 +63,8 @@
     printf( "  data size = %d bytes, it takes %d secotrs in flash area\r\n", data_size, last_sector + 1 );
     printf( "  resetting target\r\n" );
 
+
+#ifdef ENABLE_WRITING
     if ( erase_sectors( last_sector ) )
         return ( ERROR_AT_SECTOR_ERASE );
 
@@ -72,6 +74,11 @@
         return ( err );
 
     printf( "  -- %d bytes data are written\r\n", transferred_size );
+    leds_off();
+#else
+    printf( "\r\n  ==== writing is disabled ====\r\n\r\n" );
+#endif
+
 
 #ifdef ENABLE_VERIFYING
     printf( "\r\n  ==== flash reading and verifying ====\r\n" );
@@ -80,10 +87,12 @@
         return ( err );
 
     printf( "  -- %d bytes data are read and verified\r\n", transferred_size );
+    leds_off();
 #else
     printf( "\r\n  ==== verifying has been skipped ====\r\n\r\n" );
 #endif
 
+
     fclose( fp );
 
     post_writing_process( tpp );
@@ -169,3 +178,8 @@
     leds    = leds ^ (0x1 << v);
 }
 
+
+void leds_off( void )
+{
+    leds    = 0x0;
+}
--- a/isp.h	Wed Sep 25 04:00:04 2013 +0000
+++ b/isp.h	Thu Sep 26 11:51:03 2013 +0000
@@ -6,6 +6,7 @@
 void    start_target_in_normal_mode( int baud_rate );
 void    start_success_indicator( void );
 void    toggle_led( char v );
+void    leds_off( void );
 
 
 enum {
--- a/main.cpp	Wed Sep 25 04:00:04 2013 +0000
+++ b/main.cpp	Thu Sep 26 11:51:03 2013 +0000
@@ -2,7 +2,7 @@
  *  Sample of ISP operation for NXP MCUs
  *
  *  @author  Tedd OKANO
- *  @version 0.95
+ *  @version 0.96
  *  @date    Sep-2013
  *
  *  This program programs MCU flash memory through UART. It uses
--- a/verification.cpp	Wed Sep 25 04:00:04 2013 +0000
+++ b/verification.cpp	Thu Sep 26 11:51:03 2013 +0000
@@ -94,6 +94,11 @@
 }
 
 
+#define     LINE_BYTES  44
+#define     N_OF_LINES   4
+#define     READ_SIZE   (LINE_BYTES * N_OF_LINES)
+
+
 int verify_uucoded_data( FILE *fp, int *read_size_p )
 {
     char    command_str[ STR_BUFF_SIZE ];
@@ -104,7 +109,7 @@
     char    *br;
     int     error_flag  = 0;
 
-    flash_reading_size  = 176;
+    flash_reading_size  = READ_SIZE;
 
     initialize_uud_table();
 
@@ -155,9 +160,7 @@
 
 void get_binary_from_uucode_str( char *b, int size )
 {
-#define N   4
-
-    char    s[ N ][ STR_BUFF_SIZE ];
+    char    s[ N_OF_LINES ][ STR_BUFF_SIZE ];
     char    ss[ STR_BUFF_SIZE ];
     long    checksum    = 0;
     int     line_count  = 0;
@@ -167,7 +170,8 @@
 
     while ( retry_count-- ) {
 
-        for ( int i = 0; i < N; i++ )
+//        for ( int i = 0; i < N_OF_LINES; i++ )
+        for ( int i = 0; i < ((READ_SIZE < size) ? N_OF_LINES : ((size - 1) / LINE_BYTES) + 1) ; i++ )
             get_string( s[ i ] );
 
         get_string( ss );