Attiny 1634 Self Programmable Flash Problem

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

I'm trying to make a bootloader over wifi (uart from ESP8266).

 

From a web page I'm able to open a ".hex" file and transmit it to my mcu.

 

I copied the function "boot_program_page" from the code exemple in the "boot.h" file.

 

But I don't hunderstand how lenght must be the "buf" string.

 

I tryed different size (16,32,64,128) but the flash writen is splited and not complete:

 

left: original hex; right: flash read after the program is done.

 

 

There is my code below.

 

If the CRC is good I write to flash.

 

data contain exactly (first hex ligne example) "100000000C9438000C944A000C944A000C944A005A"

 

I check from the second uart what is sent to the "boot_program_page" fonction, there is no CRC error all the hex file is sent.

 

if(data[j-1] == crc)
{
	status=SUCCESS;

	if(page_offset==0)
	{
		page = ((data[1] << 8) + data[2])+0x1300;
	}

	memcpy(&page_data[page_offset], &data[4], data[0]);

	if(data[0]!=0x10)
	{
		uint8_t diff_octets_16 = (16-data[0]);
		uint8_t	diff_octets_64 = pagesize-page_offset;
		memset(&page_data[page_offset+data[0]],0xFF,(diff_octets_64+diff_octets_16));
		page_offset=(pagesize-16);
	}

	page_offset+=16;

	if(page_offset==pagesize)
	{
		page_offset=0;
		WRITE_UART_DEBUG((char*)page_data, pagesize,1);

		//***************************************
		//FLASH WRITE
		//***************************************

		boot_program_page (page, page_data);
	}
}

 

Thank you for help,

 

Eliott.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

I finally got my flash writing functional without the "boot_program_page" function:

 

 

But now I'm unable to jump to my written program.

 

I tryed:

 

-asm("JMP 4864");

-asm("JMP 1300");

-asm("JMP 0x1300");

 

Thank you for help.

 

Last Edited: Tue. Jan 16, 2018 - 08:00 PM