@@ -49,6 +49,9 @@ GDB_ARGS ?= -ex "target extended-remote localhost:3333"
4949# GHDL simulation run arguments
5050GHDL_RUN_FLAGS ?=
5151
52+ # Serial device for UART bootloader upload
53+ UART_TTY ?= /dev/ttyUSB1
54+
5255# -----------------------------------------------------------------------------
5356# NEORV32 framework
5457# -----------------------------------------------------------------------------
@@ -120,8 +123,8 @@ SET = set
120123CP = cp
121124RM = rm
122125MKDIR = mkdir
123- SH = sh
124126WC = wc
127+ CHMOD = chmod
125128
126129# NEORV32 executable image generator
127130IMAGE_GEN = $(NEORV32_EXG_PATH ) /image_gen
@@ -160,7 +163,7 @@ mem: $(APP_MEM)
160163mif : $(APP_MIF )
161164image : $(APP_VHD )
162165install : image install-$(APP_VHD )
163- all : $( APP_ELF ) $( APP_ASM ) $( APP_EXE ) $( APP_HEX ) $( APP_BIN ) $( APP_COE ) $( APP_MEM ) $( APP_MIF ) $( APP_VHD ) install hex bin
166+ all : clean_all elf asm exe hex bin coe mem mif image install
164167
165168# -----------------------------------------------------------------------------
166169# Verbosity
@@ -186,6 +189,7 @@ endif
186189$(IMAGE_GEN ) : $(NEORV32_EXG_PATH ) /image_gen.c
187190 $(ECHO ) Compiling image generator...
188191 $(Q )$(CC_HOST ) $< -o $(IMAGE_GEN )
192+ $(Q )$(CHMOD ) +rx $(IMAGE_GEN )
189193
190194# -----------------------------------------------------------------------------
191195# Build targets: Assemble, compile, link, dump
@@ -296,7 +300,8 @@ bootloader: bl_image
296300
297301sim : $(APP_VHD )
298302 $(ECHO ) " Simulating processor using default testbench..."
299- $(Q )$(SH ) $(NEORV32_SIM_PATH ) /ghdl.sh $(GHDL_RUN_FLAGS )
303+ $(Q )$(CHMOD ) +rx $(NEORV32_SIM_PATH ) /ghdl.sh
304+ $(Q ) ./$(NEORV32_SIM_PATH ) /ghdl.sh $(GHDL_RUN_FLAGS )
300305
301306# Install VHDL memory initialization file
302307install-$(APP_VHD ) : $(APP_VHD )
@@ -309,7 +314,8 @@ install-$(APP_VHD): $(APP_VHD)
309314# -----------------------------------------------------------------------------
310315
311316hdl_lists :
312- $(Q )$(SH ) $(NEORV32_RTL_PATH ) /generate_file_lists.sh
317+ $(Q )$(CHMOD ) +rx $(NEORV32_RTL_PATH ) /generate_file_lists.sh
318+ $(Q ) ./$(NEORV32_RTL_PATH ) /generate_file_lists.sh
313319
314320# -----------------------------------------------------------------------------
315321# Show final ELF details (just for debugging)
@@ -321,6 +327,14 @@ elf_info: $(APP_ELF)
321327elf_sections : $(APP_ELF )
322328 $(Q )$(READELF ) -S $(APP_ELF )
323329
330+ # -----------------------------------------------------------------------------
331+ # Upload to bootloader via UART
332+ # -----------------------------------------------------------------------------
333+
334+ upload : $(APP_EXE )
335+ $(Q )$(CHMOD ) +rx $(NEORV32_EXG_PATH ) /uart_upload.sh
336+ $(Q ) ./$(NEORV32_EXG_PATH ) /uart_upload.sh $(UART_TTY ) $(APP_EXE )
337+
324338# -----------------------------------------------------------------------------
325339# Run GDB
326340# -----------------------------------------------------------------------------
@@ -430,27 +444,31 @@ help:
430444 $(ECHO ) " "
431445 $(ECHO ) " Targets:"
432446 $(ECHO ) " "
433- $(ECHO ) " help show this text"
434- $(ECHO ) " check check toolchain and list supported ISA extensions"
435- $(ECHO ) " info show project/makefile configuration"
436- $(ECHO ) " gdb start GNU debugging session"
437- $(ECHO ) " asm build and generate <$( APP_ASM) > assembly listing file"
438- $(ECHO ) " elf build and generate <$( APP_ELF) > ELF file"
439- $(ECHO ) " exe build and generate <$( APP_EXE) > executable file for bootloader upload"
440- $(ECHO ) " bin build and generate <$( APP_BIN) > executable memory image"
441- $(ECHO ) " hex build and generate <$( APP_HEX) > executable memory image"
442- $(ECHO ) " coe build and generate <$( APP_COE) > executable memory image"
443- $(ECHO ) " mem build and generate <$( APP_MEM) > executable memory image"
444- $(ECHO ) " mif build and generate <$( APP_MIF) > executable memory image"
445- $(ECHO ) " image build and generate VHDL IMEM application memory image <$( APP_VHD) > in local folder"
446- $(ECHO ) " install build, generate and install VHDL IMEM application memory image <$( APP_VHD) >"
447+ $(ECHO ) " help show this text"
448+ $(ECHO ) " check check toolchain and list supported ISA extensions"
449+ $(ECHO ) " info show project/makefile configuration"
450+ $(ECHO ) " gdb start GNU debugging session"
451+ $(ECHO ) " asm build and generate <$( APP_ASM) > assembly listing file"
452+ $(ECHO ) " elf build and generate <$( APP_ELF) > ELF file"
453+ $(ECHO ) " exe build and generate <$( APP_EXE) > executable file for bootloader upload"
454+ $(ECHO ) " bin build and generate <$( APP_BIN) > executable memory image"
455+ $(ECHO ) " hex build and generate <$( APP_HEX) > executable memory image"
456+ $(ECHO ) " coe build and generate <$( APP_COE) > executable memory image"
457+ $(ECHO ) " mem build and generate <$( APP_MEM) > executable memory image"
458+ $(ECHO ) " mif build and generate <$( APP_MIF) > executable memory image"
459+ $(ECHO ) " image build and generate VHDL IMEM application memory image <$( APP_VHD) > in local folder"
460+ $(ECHO ) " install build, generate and install VHDL IMEM application memory image <$( APP_VHD) >"
461+ $(ECHO ) " clean clean up project home folder"
462+ $(ECHO ) " clean_all clean up project home folder and image generator"
463+ $(ECHO ) " all clean_all + elf + asm + exe + hex + bin + coe + mem + mif + image + install"
464+ $(ECHO ) " "
465+ $(ECHO ) " Additional targets:"
466+ $(ECHO ) " "
447467 $(ECHO ) " sim in-console simulation using default testbench (sim folder) and GHDL"
448468 $(ECHO ) " hdl_lists regenerate HDL file-lists (*.f) in NEORV32_HOME/rtl"
449- $(ECHO ) " all exe + install + hex + bin + asm "
469+ $(ECHO ) " upload upload executable to bootloader via UART ( $( UART_TTY ) ) "
450470 $(ECHO ) " elf_info show ELF layout info"
451471 $(ECHO ) " elf_sections show ELF sections"
452- $(ECHO ) " clean clean up project home folder"
453- $(ECHO ) " clean_all clean up project home folder and image generator"
454472 $(ECHO ) " bl_image build and generate VHDL BOOTROM bootloader memory image <$( BLD_VHD) > in local folder"
455473 $(ECHO ) " bootloader build, generate and install VHDL BOOTROM bootloader memory image <$( BLD_VHD) >"
456474 $(ECHO ) " "
@@ -469,5 +487,6 @@ help:
469487 $(ECHO ) " RISCV_PREFIX Toolchain prefix: \" $( RISCV_PREFIX) \" "
470488 $(ECHO ) " NEORV32_HOME NEORV32 home folder: \" $( NEORV32_HOME) \" "
471489 $(ECHO ) " GDB_ARGS GDB arguments: \" $( GDB_ARGS) \" "
490+ $(ECHO ) " UART_TTY Serial port for upload to bootloader: \" $( UART_TTY) \" "
472491 $(ECHO ) " GHDL_RUN_FLAGS GHDL simulation run arguments: \" $( GHDL_RUN_FLAGS) \" "
473492 $(ECHO ) " "
0 commit comments