The same uart port is used to communicate with mcu which send new program to send other data.
So you need a protocol to switch the MCU to bootloader operation, or to tell it to accept new programming data to be written to the SPI Flash.
Flash used SPI .
And? It's just another serial protocol. You can read bytes from the UART and write them to the SPI. You need to buffer the data into whatever block size the SPI Flash supports and add the correct command sequences.
Have you used SPI before?
Have you used a bootloader before?
Yes, I use SPI (4 wire), there is no problem with receive by uart and wrote to flash by SPI. As You suggest, I need make buffer - I reveive in part all data from uart, after I reveive 1 part, I write it to flash by SPI, after that I do the same with 2 part of data etc. as I write to flash all data.
2. I've never used bootloader - I needn't do that, but I know that is basicly skill :)
I read AN1157 "A Serial Bootloader for PIC24F Devices"
3. uart in my mcu need to be used in two cases:
a) other mcu send request for data from some sensors - > send for example control byte 0x05 , then my mcu send data from sensors.
There is mo problem with that.
b) other mcu send control byte for example 0x03 to inform my mcu - new program can be send.
After that my mcu need to receive new program, send it to flash by SPI. After that program from flash need to be write to my mcu.
I have problem with all that operation:
- my mcu is 16-bit mcu, what format new program need to be send by uart from other mcu ?
- where I could download or how I can make own bootloader (maybe try to make own bootloader doesnt make sense? ) which can be used in my device ?
- after I write all program to flash by SPI, what I need to do next with that ?
I've never used bootloader in mcu ,could You help me ? Thanks :).