echo "Generating Memories Files"



gcc -Wall -O -g %1\image_gen.c -o %1\image_gen.exe
ECHO OFF

if exist %1\image_gen.exe (
	cd %1
	echo "Generationg APP BIN"
	image_gen.exe -app_bin %3\main.bin %3\neorv32_exe.bin
	
	if exist %3\neorv32_exe.bin (
		echo "OK - APP BIN"
	)else (
		echo "FAILED - APP BIN"
	)

	echo "Generationg APP IMG VHD"
	image_gen.exe -app_img %3\main.bin %3\neorv32_application_image.vhd
	if exist %3\neorv32_application_image.vhd (
		echo "OK - APP IMG VHD"
	)else (
		echo "FAILED - APP IMG VHD"
	)


	REM cp %3\neorv32_application_image.vhd %2

	echo "Generationg RAW HEX"
	image_gen.exe -raw_hex %3\main.bin %3\neorv32_raw_exe.hex
	if exist %3\neorv32_raw_exe.hex (
		echo "OK - RAW HEX"
	)else (
		echo "FAILED - RAW HEX"
	)
	
	echo "Generationg RAW BIN"
	image_gen.exe -raw_bin %3\main.bin %3\neorv32_raw_exe.bin
	if exist %3\neorv32_raw_exe.bin (
		echo "OK - RAW BIN"
	)else (
		echo "FAILED - RAW BIN"
	)

	echo "Generationg BOOT IMG VHD"
	image_gen.exe -bld_img %3\main.bin %3\neorv32_bootloader_image.vhd
	if exist %3\neorv32_bootloader_image.vhd (
		echo "OK - BOOT IMG VHD"
	)else (
		echo "FAILED - BOOT iMG VHD"
	)

	REM cp %3\neorv32_bootloader_image.vhd %2
	
	echo "Memories Generated"
) else (
  echo "GCC is not configured, please install GCC and register on the PATH"
)





exit