Adding parameter to parts definition file to do so.
* 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;
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 */
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) {
* 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);
/*
* 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)
{
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;
}
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);
}
/* 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;
}
" <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" \
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},
# 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
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
write_size = 512;
} else if (write_size >= 256) {
write_size = 256;
+ } else if (write_size >= 64) {
+ write_size = 64;
} else {
write_size = 0;
}
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;
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);