ISP Support

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

ISP Support

1,491 次查看
MichaelBMiner
Contributor IV

I am having trouble getting my ISP upgrades going. I can properly Sync, Prepare, Erase and Send a Write Command. 

 

Synchronized
OK
10000
OK
U 23130
0
P 0 31
0
E 0 31
0
W 268436224 1200
0

 

When I try to write my 1200 bytes to the device followed by my checksum I get nothing. 

 

Here is a high level description of my process.

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)) > 0) {     // read in 45 bytes at a time from my .bin

	for(uint32_t i=0; i<buffer_len; i++) {
	     checksum += buffer[i];
	}

	uu_buffer[line_count].line = line_count;
	uuencode_buffer(buffer, bytes_read, uu_buffer[line_count].data, &output_size);
	transmit_size += bytes_read;

	line_count++;
	if((line_count == 20) || (bytes_read < READ_BUFFER_LEN)) {
		isp_write(uu_buffer, 20, flash_addr, transmit_size);

		if(bytes_read < 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(&cmd[2], "%u", flash_addr);
	sprintf(&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<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);
}

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. 

标签 (1)
标记 (1)
0 项奖励
回复
2 回复数

1,480 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @MichaelBMiner 

 

How about use Flash Magic to erase/program in ISP mode?

https://www.flashmagictool.com/  

 

BR

Alice

0 项奖励
回复

1,473 次查看
MichaelBMiner
Contributor IV

I came to delete this as I sorted out my issue. 

 

I cannot use an external tool as I am using two micros on a single board. One is going to be programming the other. 

0 项奖励
回复