I've 4 years experience in automotive software development , worked in too many projects with big OEMs in the automotive industry.
from my understandings ,you need to develop Flash bootloader over CAN using Diagnostics protocol (UDS).
Normally when i do similar tasks, the common approach is to develop the following services in the diagnostics protocol (UDS) to facilitate the flashing procedure.
-RequestDownload
-TrasnferData
-Request Transfer Exit
These services should be routed using the CAN messages, but the data to be sent is too big to use single can frame so a CAN TP should be used/developed to segment and reassemble the frames.
to be honest i never used due_can library so i don't know if it provides CAN TP or not.
then the part of the flash procedure will depend on the target memory architecture
I've only one big question ,it's about the storing of .hex file on SDcard. if the SDcard is already connected to the controller why do you need the CAN bus to send the .hex file.
normally you'd read the intel hex file via serial interface (SPI,I2C) and flash directly to the micro-controller.
I've expertise in these relevant topics to the project.
-FreeRTOS
-Diagnostics protocol UDS
-automotive transport layers CAN , LIN and flexray
-Flash bootloaders over CAN and LIN on many targets
-Interface of memories e.g. SDmemory ,external flash, RAM
-microcontroller peripherals e.g. SPI,I2C, DMA ,EBI,ADC,GIO,TMR,USART,SQI