Both codebases restructured for testing, then the IEC 62304 file written on top.
We refactored the desktop application and the embedded firmware into a modular architecture, with dependency injection and a simulation mode so tests run without the hardware.
On that structure we wrote the validation plan for the trials and the IEC 62304 documentation: requirements specifications, verification plan, test reports and an end to end traceability matrix.