authorNathael Pajani <nathael.pajani@ed3l.fr>
Thu, 3 Oct 2013 13:17:15 +0000 (15:17 +0200)
committerNathael Pajani <nathael.pajani@ed3l.fr>
Thu, 3 Oct 2013 13:17:15 +0000 (15:17 +0200)
Adding parameter to parts definition file to do so.

isp_commands.c
isp_commands.h
isp_wrapper.c
lpcisp.c
lpctools_parts.def
parts.h
prog_commands.c

index 1019569..4cf1cbc 100644 (file)
@@ -464,7 +464,7 @@ int isp_read_memory(char* data, uint32_t addr, unsigned int count)
  * perform write-to-ram operation
  * send 'count' bytes from 'data' to 'addr' in RAM
  */
-int isp_send_buf_to_ram(char* data, unsigned long int addr, unsigned int count)
+int isp_send_buf_to_ram(char* data, unsigned long int addr, unsigned int count, unsigned int perform_uuencode)
 {
        /* Serial communication */
        int ret = 0, len = 0;
@@ -496,6 +496,17 @@ int isp_send_buf_to_ram(char* data, unsigned long int addr, unsigned int count)
                if (datasize >= MAX_DATA_BLOCK_SIZE) {
                        datasize = MAX_DATA_BLOCK_SIZE;
                }
+               if (perform_uuencode == 0) {
+                       if (isp_serial_write(data + total_bytes_sent, datasize) != (int)datasize) {
+                               printf("Error sending raw binary data.\n");
+                               ret = -7;
+                               break;
+                       } else {
+                               /* No checks required */
+                               return ret;
+                       }
+               }
+
                /* uuencode data */
                encoded_size = isp_uu_encode(buf, data + total_bytes_sent, datasize);
                /* Add checksum */
@@ -505,12 +516,12 @@ int isp_send_buf_to_ram(char* data, unsigned long int addr, unsigned int count)
                        printf("Encoded Data :\n");
                        isp_dump((unsigned char*)buf, encoded_size);
                }
-
                if (isp_serial_write(buf, encoded_size) != (int)encoded_size) {
                        printf("Error sending uuencoded data.\n");
                        ret = -6;
                        break;
                }
+
                usleep( 20000 );
                len = isp_serial_read(repbuf, REP_BUFSIZE, 4);
                if (len <= 0) {
index 74a8ebe..93d755c 100644 (file)
@@ -83,7 +83,7 @@ int isp_cmd_write_to_ram(int arg_count, char** args);
  * perform write-to-ram operation
  * send 'count' bytes from 'data' to 'addr' in RAM
  */
-int isp_send_buf_to_ram(char* data, unsigned long int addr, unsigned int count);
+int isp_send_buf_to_ram(char* data, unsigned long int addr, unsigned int count, unsigned int perform_uuencode);
 
 
 int isp_cmd_compare(int arg_count, char** args);
index 0cfcedd..0715973 100644 (file)
@@ -91,8 +91,8 @@ int isp_cmd_read_memory(int arg_count, char** args)
 
 /*
  * write-to-ram
- * aruments : address file
- * send 'file' to 'address' in ram
+ * aruments : address file do_not_perform_uuencode
+ * send 'file' to 'address' in ram with or without uuencoding data
  */
 int isp_cmd_write_to_ram(int arg_count, char** args)
 {
@@ -102,9 +102,10 @@ int isp_cmd_write_to_ram(int arg_count, char** args)
        char file_buff[RAM_MAX_SIZE];
        unsigned int bytes_read = 0;
        int ret = 0;
+       int uuencode = 1;
 
        /* Check write-to-ram arguments */
-       if (arg_count != 2) {
+       if (arg_count < 2) {
                printf("write-to-ram command needs ram address. Must be multiple of 4.\n");
                return -15;
        }
@@ -117,6 +118,9 @@ int isp_cmd_write_to_ram(int arg_count, char** args)
                return -14;
        }
        in_file_name = args[1];
+       if (arg_count > 2) {
+               uuencode = strtoul(args[2], NULL, 0);
+       }
 
        /* Read data */
        bytes_read = isp_file_to_buff(file_buff, RAM_MAX_SIZE, in_file_name);
@@ -134,7 +138,7 @@ int isp_cmd_write_to_ram(int arg_count, char** args)
        }
 
        /* And send to ram */
-       ret = isp_send_buf_to_ram(file_buff, addr, bytes_read);
+       ret = isp_send_buf_to_ram(file_buff, addr, bytes_read, uuencode);
 
        return ret;
 }
index c7f7d48..500da9b 100644 (file)
--- a/lpcisp.c
+++ b/lpcisp.c
@@ -53,10 +53,10 @@ void help(char *prog_name)
                "  <device> is the (host) serial line used to programm the device\n" \
                "  <command> is one of:\n" \
                "  \t unlock, write-to-ram, read-memory, prepare-for-write, copy-ram-to-flash, go, erase,\n" \
-               "  \t blank-check, read-part-id, read-boot-version, compare, and read-uid.\n" \
+               "  \t blank-check, read-part-id, read-boot-version, compare and read-uid.\n" \
                "  command specific arguments are as follow:\n" \
                "  \t unlock \n" \
-               "  \t write-to-ram address file : send 'file' to 'address' in ram\n" \
+               "  \t write-to-ram address file uuencode : send 'file' to 'address' in ram with or without uuencoding\n" \
                "  \t read-memory address count file : read 'count' bytes from 'address', store then in 'file'\n" \
                "  \t prepare-for-write first last : prepare sectors from 'first' to 'last' for write operation\n" \
                "  \t copy-ram-to-flash flash_addr ram_addr count : copy count bytes (256, 512, 1024 or 4096)\n" \
@@ -245,7 +245,7 @@ struct isp_command {
 
 static struct isp_command isp_cmds_list[] = {
        {0, "unlock", 0, NULL},
-       {1, "write-to-ram", 2, isp_cmd_write_to_ram},
+       {1, "write-to-ram", 3, isp_cmd_write_to_ram},
        {2, "read-memory", 3, isp_cmd_read_memory},
        {3, "prepare-for-write", 2, isp_cmd_prepare_for_write},
        {4, "copy-ram-to-flash", 3, isp_cmd_copy_ram_to_flash},
index a733d71..a1abef5 100644 (file)
@@ -6,16 +6,19 @@
 
 # Line format :
 
-#       part info             |        flash             | reset  |       ram         |    ram
-#                             |                      nb  | vector |                   |   buffer   
-# part_id      part name      | base addr    size   sect | offset | base addr   size  |  off   size 
+#       part info             |        flash             | reset  |       ram         |    ram      |   UU
+#                             |                      nb  | vector |                   |   buffer    | encode
+# part_id      part name      | base addr    size   sect | offset | base addr   size  |  off   size |   ?
 
+# LPC81X Familly
+0x00008100, LPC810M021FN8,      0x00000000, 0x1000, 4,     0x04,    0x10000000, 0x0400, 0x300, 0x100,   0
+0x00008122, LPC812M101JDH20,    0x00000000, 0x4000, 16,    0x04,    0x10000000, 0x1000, 0x800, 0x400,   0
 
 # LPC11XX Familly
-0x2540102B, LPC1114FHN33/302,   0x00000000, 0x8000,  8,    0x04,    0x10000000, 0x2000, 0x800, 0x400
+0x2540102B, LPC1114FHN33/302,   0x00000000, 0x8000,  8,    0x04,    0x10000000, 0x2000, 0x800, 0x400,   1
 
 # LPC12XX Familly
-0x3640C02B, LPC1224FBD48/101,   0x00000000, 0x8000,  8,    0x04,    0x10000000, 0x1000, 0x800, 0x400
+0x3640C02B, LPC1224FBD48/101,   0x00000000, 0x8000,  8,    0x04,    0x10000000, 0x1000, 0x800, 0x400,   1
 
 # LPC17XX Familly
-0x26011922, LPC1764FBD100,      0x00000000, 0x10000, 16,   0x04,    0x10000000, 0x4000, 0x800, 0x800
+0x26011922, LPC1764FBD100,      0x00000000, 0x10000, 16,   0x04,    0x10000000, 0x4000, 0x800, 0x800,   1
diff --git a/parts.h b/parts.h
index e702fd5..2dc07d3 100644 (file)
--- a/parts.h
+++ b/parts.h
@@ -32,6 +32,7 @@ struct part_desc {
        uint32_t ram_size;
        uint32_t ram_buff_offset; /* Used to transfer data for flashing */
        uint32_t ram_buff_size;
+       uint32_t uuencode;
 };
 
 /* When looking for parts description in a file ee do allocate (malloc) two memory
index 7b7f748..7dccf50 100644 (file)
@@ -166,6 +166,8 @@ static unsigned int calc_write_size(unsigned int sector_size, unsigned int ram_b
                write_size = 512;
        } else if (write_size >= 256) {
                write_size = 256;
+       } else if (write_size >= 64) {
+               write_size = 64;
        } else {
                write_size = 0;
        }
@@ -181,6 +183,7 @@ int flash_target(struct part_desc* part, char* filename, int calc_user_code)
        unsigned int write_size = 0;
        unsigned int sector_size = (part->flash_size / part->flash_nb_sectors);
        uint32_t ram_addr = (part->ram_base + part->ram_buff_offset);
+       uint32_t uuencode = part->uuencode;
        uint32_t* v = NULL; /* Used for checksum computing */
        uint32_t cksum = 0;
 
@@ -256,7 +259,7 @@ int flash_target(struct part_desc* part, char* filename, int calc_user_code)
                        return ret;
                }
                /* Send data to RAM */
-               ret = isp_send_buf_to_ram(&data[i * write_size], ram_addr, write_size);
+               ret = isp_send_buf_to_ram(&data[i * write_size], ram_addr, write_size, uuencode);
                if (ret != 0) {
                        printf("Unable to perform write-to-ram operation for block %d (block size: %d)\n",
                                        i, write_size);