rem prog.cmd  PeterJ,    02-Jul-2020.
@prompt $$$s

if not exist "%1%" (
  @echo ### %1% ### bit file not found
  @echo Usage: do_vivado_mmi_elf <bitfile>.bit <elffile>.elf
  exit /B
)
if not "%~x1%"==".bit" (
  @echo ### %1% ### bit file not found
  @echo Usage: do_vivado_mmi_elf <bitfile>.bit <elffile>.elf
  exit /B
)

if not exist "%2%" (
  @echo ### %2% ### elf file not found
  @echo Usage: do_vivado_mmi_elf <bitfile>.bit <elffile>.elf
  exit /B
)
if not "%~x2%"==".elf" (
  @echo ### %2% ### elf file not found
  @echo Usage: do_vivado_mmi_elf <bitfile>.bit <elffile>.elf
  exit /B
)

rem ### Cleanup old log files and stuff
del vivado_mmi_elf.log
del updatemem*.jou
del updatemem*.log

set proj_name=%~n1%
set lm32_wrpc_elf=%2%
set lm32_wrpc_instpath="lm32_wrpc_memory"

rem ### note that environment variable "VIVADO" must be set to something like "E:\Xilinx\Vivado\2017.1\bin\"
rem ### in your (User) Environment Variables
%VIVADO%updatemem -meminfo %proj_name%.mmi -data %lm32_wrpc_elf% -bit %proj_name%.bit -proc %lm32_wrpc_instpath% -out %proj_name%_elf.bit -force >> vivado_mmi_elf.log

