Flashing nxp controller using PIC controller through SPI

Thread Starter

davidmeetsall

Joined Dec 1, 2016
24
Dear Friends,

I am working on a 8-bit PIC microcontroller and 16-bit MC56F82748 nxp controller. PIC microcontroller is associated with bluetooth module but nxp microcontroller is not associated with bluetooth module.

I have to flash nxp controller without connecting any emulator. I have been working on a concept . Please let me know if its possible?

Concept is : This can be achieved using bluetooth module of PIC. Unified host can be used to send hex file(.elf file) to PIC using bluetooth and keep transferring this hex file to nxp microcontroller via SPI. Once MC56F82748 nxp controller gets this hex file(.elf file) bootloader of this particular controller can flash it.

Could you please help me to know how to send hex file from PIC to nxp controller via SPI without losing data?
Also, appropriate bootloader code for MC56F82748 nxp controller.

Please help.

Regards,
David.
 

Sensacell

Joined Jun 19, 2012
3,785
Ahhh Boot-loaders...

Yes it can be done, but it's one of the more difficult things to get working.

It's hard because there are multiple independent elements involved, debugging is nightmarish.
You generally need to run multiple debugging tools at once to have the slightest clue what's going wrong.

You have to monitor:

1) The Host, which has to serve up the code.
2) The communications layer- to transport the code between devices
3) The Target, which needs to self-write the new code to exactly the right place.

This also requires a really intimate familiarity with the target MCU's memory configuration, compiler scripts and a host of other nasties that the average programmer rarely needs to understand.

I have written lots of code in my days, nothing kicks my ass harder than boot-loaders!
 

spinnaker

Joined Oct 29, 2009
7,830
Dear Friends,

I am working on a 8-bit PIC microcontroller and 16-bit MC56F82748 nxp controller. PIC microcontroller is associated with bluetooth module but nxp microcontroller is not associated with bluetooth module.

I have to flash nxp controller without connecting any emulator. I have been working on a concept . Please let me know if its possible?

Concept is : This can be achieved using bluetooth module of PIC. Unified host can be used to send hex file(.elf file) to PIC using bluetooth and keep transferring this hex file to nxp microcontroller via SPI. Once MC56F82748 nxp controller gets this hex file(.elf file) bootloader of this particular controller can flash it.

Could you please help me to know how to send hex file from PIC to nxp controller via SPI without losing data?
Also, appropriate bootloader code for MC56F82748 nxp controller.

Please help.

Regards,
David.


1. Have 2 SPI ports. One sends from the host. The second one receives back what was sent to the client. Host compares what was sent to what was received. You could also do this with one SPI. Send the file then receive it back.

2. Send a CRC byte after you send the data. You might want to break your data up into block and send a CRC at the end of each block., Also do a validation at the end of each block.

3. A combination of methods 1 and 2.


Option 3 will be most accurate followed by option 1.


But you first need to figure out how to get the file into the host. This is not a trivial matter on the Pic.
 

Thread Starter

davidmeetsall

Joined Dec 1, 2016
24
Hi Sensacall and Spinakker,

Thanks for the guidance. I will try the way you both have suggested.

Spinakker, could you please let me know how file transfer can be done from pic to nxp controller through spi ?
Please let me know any example code in C as I am using xc8 compiler.

I will try these concepts and ask if any help is required.

Regards,
David.
 

shteii01

Joined Feb 19, 2010
4,644
Hi Sensacall and Spinakker,

Thanks for the guidance. I will try the way you both have suggested.

Spinakker, could you please let me know how file transfer can be done from pic to nxp controller through spi ?
Please let me know any example code in C as I am using xc8 compiler.

I will try these concepts and ask if any help is required.

Regards,
David.
lol
If they do all that, what the point of you doing it?
And half of what you asked is in the datasheet or NXP website in the application notes, they might even have the whole thing written out, someone just have to read it.
 

spinnaker

Joined Oct 29, 2009
7,830
Hi Sensacall and Spinakker,

Thanks for the guidance. I will try the way you both have suggested.

Spinakker, could you please let me know how file transfer can be done from pic to nxp controller through spi ?
Please let me know any example code in C as I am using xc8 compiler.

I will try these concepts and ask if any help is required.

Regards,
David.

You transfer a file just like any other block of data.

You first need to open the file.

http://elm-chan.org/fsw/ff/00index_e.html

My suggestion. Make the host and Arduino instead.
 

Thread Starter

davidmeetsall

Joined Dec 1, 2016
24
Dear Friends,

I worked further on the bootloader flashing for nxp MC56F82748 via PIC SPI. I identified two tools which can send elf/hex file to PIC via usart.
Once PIC gets this file, it would be transferred to MC56F82748 using SPI. Here are the two issues I am facing with these two tools.

1. First, Rappid BL tool can send elf.s file which is recommended by MC56F82748. But when I configure tool and transfer file via usart, connection with the tool goes off. It might be due to PIC has to accept this data first, which might be not compatible with Rappid BL tool.

2. Second, Unified Bootloader app, whcih can only send .hex file. I used burner.exe tool to convert elf.s file into .hex and sent it via usart. I am able to get data and transfers the same to MC56F82748 via SPI. Here the problem is hex file has data like :2103028 and I am receiving at PIC data like 1, vv, aa, etc....Why is the difference in data?

Here is the code snippet i used:
SSPBUF = RCREG; //USART to PIC in PIC code
fs_rcv_data= QSPI0_SPDRR; //From PIC to FS in FS code

Please help me in finding the correct solution of above two issues.
Bootloader needs elf.s file to be flashed so ultimately at nxp MCU, .elf.s file is needed.

Thanks
David.
 

Thread Starter

davidmeetsall

Joined Dec 1, 2016
24
Hi,

I wanted to add some more information. Baud rate is set to 9600 both sides.
I shared only snippet of code. I checked if a simple command I send via bluetooth, it reaches to PIC correctly and from there to FS via SPI correctly too.
Does .hex file need any conversion once it reaches to PIC before reading?
How can i send .elf.s file instead correctly?

Thanks,
David.
 

Sensacell

Joined Jun 19, 2012
3,785
Open a .hex file with notepad, look at the data.

https://en.wikipedia.org/wiki/Intel_HEX

The PIC needs the data in raw binary form, each byte needs to be loaded in EXACTLY the right memory location.
A .HEX file is coded with data in ASCII and contains lots of other codes that must be parsed out.

Learn the INHEX format inside and out.
 
Top