<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ISP Support in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/ISP-Support/m-p/1638242#M52286</link>
    <description>&lt;P&gt;I came to delete this as I sorted out my issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot use an external tool as I am using two micros on a single board. One is going to be programming the other.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Apr 2023 20:28:44 GMT</pubDate>
    <dc:creator>MichaelBMiner</dc:creator>
    <dc:date>2023-04-21T20:28:44Z</dc:date>
    <item>
      <title>ISP Support</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/ISP-Support/m-p/1637308#M52266</link>
      <description>&lt;P&gt;I am having trouble getting my ISP upgrades going. I can properly Sync, Prepare, Erase and Send a Write Command.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Synchronized&lt;BR /&gt;OK&lt;BR /&gt;10000&lt;BR /&gt;OK&lt;BR /&gt;U 23130&lt;BR /&gt;0&lt;BR /&gt;P 0 31&lt;BR /&gt;0&lt;BR /&gt;E 0 31&lt;BR /&gt;0&lt;BR /&gt;W 268436224 1200&lt;BR /&gt;0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;When I try to write my 1200 bytes to the device followed by my checksum I get nothing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a high level description of my process.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;struct uu_buffer {
	uint8_t line;
	uint8_t data[128];
};

struct uu_buffer uu_buffer[20];

lpc_request_isp();

lpc_synchronize();

while ((bytes_read = fread(buffer, 1, 45, fp)) &amp;gt; 0) {     // read in 45 bytes at a time from my .bin

	for(uint32_t i=0; i&amp;lt;buffer_len; i++) {
	     checksum += buffer[i];
	}

	uu_buffer[line_count].line = line_count;
	uuencode_buffer(buffer, bytes_read, uu_buffer[line_count].data, &amp;amp;output_size);
	transmit_size += bytes_read;

	line_count++;
	if((line_count == 20) || (bytes_read &amp;lt; READ_BUFFER_LEN)) {
		isp_write(uu_buffer, 20, flash_addr, transmit_size);

		if(bytes_read &amp;lt; READ_BUFFER_LEN) {
			sprintf(checksum_buffer, "%u", transmit_size);
		} else {
			sprintf(checksum_buffer, "%u", checksum);
		}

		serial_tx(checksum_buffer, strlen(checksum_buffer));

		bool response_ok = serial_response_received(ISP_OK);
		bool response_resend = serial_response_received(ISP_RESEND_RESP);
		
		// determine how to proceed
	}
}

static void isp_write(struct uu_buffer *uu_buffer, uint32_t buffer_len, uint32_t start_flash_addr, uint32_t bytes_to_tx) {
	char cmd[50] = {0};
	cmd[0] = 'W';
	cmd[1] = ' ';

	uint32_t flash_addr = start_flash_addr;
	uint32_t bytes_sent = 0;

	sprintf(&amp;amp;cmd[2], "%u", flash_addr);
	sprintf(&amp;amp;cmd[strlen(cmd)], " %u\r\n", bytes_to_tx);
	serial_tx(cmd, strlen(cmd));
	isp_cmd_response_enum response = parse_command_response(CMD_RESPONSE_TOKEN_COUNT);
	if(response == RESPONSE_CMD_SUCCESS) {
		for(uint32_t i=0; i&amp;lt;buffer_len; i++) {
			bytes_sent += serial_tx(uu_buffer[i].data, strlen(uu_buffer[i].data));
		}
	}
	printf("Device expects %d bytes, we send %d bytes", bytes_to_tx, bytes_sent);
}&lt;/LI-CODE&gt;&lt;P&gt;My confusion and I think error lies in the number of bytes to send. The data sheet states we should send 20 uuencoded lines. Each line contains 45 bytes of data but 61 characters. So is my tx size 45*20 or 60*20? Neither of these seem to work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 13:32:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/ISP-Support/m-p/1637308#M52266</guid>
      <dc:creator>MichaelBMiner</dc:creator>
      <dc:date>2023-04-20T13:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: ISP Support</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/ISP-Support/m-p/1637753#M52278</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/193268"&gt;@MichaelBMiner&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about use Flash Magic to erase/program in ISP mode?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.flashmagictool.com/" target="_blank"&gt;https://www.flashmagictool.com/&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 06:23:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/ISP-Support/m-p/1637753#M52278</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2023-04-21T06:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: ISP Support</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/ISP-Support/m-p/1638242#M52286</link>
      <description>&lt;P&gt;I came to delete this as I sorted out my issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot use an external tool as I am using two micros on a single board. One is going to be programming the other.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 20:28:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/ISP-Support/m-p/1638242#M52286</guid>
      <dc:creator>MichaelBMiner</dc:creator>
      <dc:date>2023-04-21T20:28:44Z</dc:date>
    </item>
  </channel>
</rss>

