-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprci.mk
More file actions
97 lines (74 loc) · 2.95 KB
/
prci.mk
File metadata and controls
97 lines (74 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#RISCVGNU ?= riscv32-unknown-elf
# requires $(RISCVGNU)-ld option -b elf32-littleriscv
RISCVGNU ?= riscv64-unknown-elf
AOPS = -march=rv32imac -mabi=ilp32 -g
COPS = -march=rv32imac -mabi=ilp32 -g -Wall -O2 -nostdlib -nostartfiles -ffreestanding
#AOPS = -mabi=ilp32
#COPS = -mabi=ilp32 -Wall -O2 -nostdlib -nostartfiles -ffreestanding
OPENOCD_WIN = openocd
OPENOCD_LIN = sudo openocd
OPENOCD = $(OPENOCD_WIN)
DELCMD_WIN = del
DELCMD_LIN = rm -f
DELCMD = $(DELCMD_WIN)
PROGRAM := main
all :
#
# Program Definition
#
clean :
$(DELCMD) start.o
$(DELCMD) prci.o
$(DELCMD) $(PROGRAM).o
$(DELCMD) $(PROGRAM)-ram.elf
$(DELCMD) $(PROGRAM)-ram.bin
$(DELCMD) $(PROGRAM)-ram.lst
$(DELCMD) $(PROGRAM)-ram.hex
$(DELCMD) $(PROGRAM)-ram.map
$(DELCMD) $(PROGRAM)-rom.elf
$(DELCMD) $(PROGRAM)-rom.bin
$(DELCMD) $(PROGRAM)-rom.lst
$(DELCMD) $(PROGRAM)-rom.hex
$(DELCMD) $(PROGRAM)-rom.map
start.o : start.s
$(RISCVGNU)-as $(AOPS) start.s -o start.o
prci.o : prci.s
$(RISCVGNU)-as $(AOPS) prci.s -o prci.o
$(PROGRAM).o : $(PROGRAM).c
$(RISCVGNU)-gcc $(COPS) -c $(PROGRAM).c -o $(PROGRAM).o
#
# RAM link and load
#
ram : fe310-g002-ram.lds start.o prci.o $(PROGRAM).o
$(RISCVGNU)-ld start.o prci.o $(PROGRAM).o -T fe310-g002-ram.lds -o $(PROGRAM)-ram.elf -Map $(PROGRAM)-ram.map -b elf32-littleriscv
$(RISCVGNU)-objdump -D $(PROGRAM)-ram.elf > $(PROGRAM)-ram.lst
$(RISCVGNU)-objcopy $(PROGRAM)-ram.elf -O ihex $(PROGRAM)-ram.hex
$(RISCVGNU)-objcopy $(PROGRAM)-ram.elf -O binary $(PROGRAM)-ram.bin
ifeq (LOAD, $(tgt))
# @openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f fe310-g002.cfg -c init -c "asic_ram_load $(PROGRAM)" -c shutdown -c exit
# @openocd -f fe310-g002.cfg -c init -c "asic_ram_load $(PROGRAM)"
@openocd -f unbrick.cfg -c init
@echo "target RAM programmed"
else
@echo "target not changed"
endif
#
# ROM link and load
#
rom : fe310-g002-rom.lds start.o prci.o $(PROGRAM).o
$(RISCVGNU)-ld start.o prci.o $(PROGRAM).o -T fe310-g002-rom.lds -o $(PROGRAM)-rom.elf -Map $(PROGRAM)-rom.map -b elf32-littleriscv
$(RISCVGNU)-objdump -D $(PROGRAM)-rom.elf > $(PROGRAM)-rom.lst
$(RISCVGNU)-objcopy $(PROGRAM)-rom.elf -O ihex $(PROGRAM)-rom.hex
$(RISCVGNU)-objcopy $(PROGRAM)-rom.elf -O binary $(PROGRAM)-rom.bin
ifeq (LOAD, $(tgt))
# $(eval SECSZ=$(shell echo "ibase=16; 1000" | bc))
# $(eval LEN=$(shell <${PROGRAM}-rom.bin wc -c))
# $(eval ENDSEC=$(shell echo "(${LEN}/${SECSZ})+((${LEN}-(${LEN}/${SECSZ})*${SECSZ})>0)-1" | bc))
# @echo "secsz=${SECSZ} len=${LEN} endsec=${ENDSEC}"
# @openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f fe310-g002.cfg -c init -c "asic_rom_load $(PROGRAM)" -c shutdown -c exit
# @openocd -f fe310-g002.cfg -c init -c "asic_rom_load $(PROGRAM)" -c shutdown -c exit
@openocd -f unbrick.cfg -c init
@echo "target ROM programmed"
else
@echo "target not changed"
endif