-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflash_openocd.cfg
70 lines (48 loc) · 1.84 KB
/
flash_openocd.cfg
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
#/****************************************************************************
# *
# * Copyright (C) 2023 bsvtgc@gmail.com. All rights reserved.
# * Author: Vincent <bsvtgc@gmail.com>
# *
# ****************************************************************************/
# WORK IN PROGRESS script
#As shipped, the OTP memory at the boot location is preprogrammed to
#jump immediately to the end of the OTP memory, which contains the
#following code to jump to the beginning of the SPI-Flash at 0x2000 0000:
#fence 0,0
#li t0, 0x20000000
#jr t0
# ----------------------------------------------------#
# CONFIGURATION STAGE
# ----------------------------------------------------#
echo "----------------------WARNING-----------------------------"
echo "THIS SCRIPT WOULD OVERWRITE FROM ADDR 0x2000_0000 IN FLASH"
adapter speed 4000
adapter driver jlink
transport select jtag
set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000913
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME
# set work area in RAM 0x8000_0000 with size 0x4000
$_TARGETNAME.0 configure -work-area-phys 0x80000000 -work-area-size 0x4000 -work-area-backup 0
# No virtual to mem conversion
riscv set_enable_virt2phys off
riscv set_enable_virtual off
# flash bank name driver base size chip_width bus_width target [driver_options]
flash bank spi0 fespi 0x20000000 0 0 0 riscv.cpu.0 0x10014000
# ----------------------------------------------------#
# RUN STAGE
# ----------------------------------------------------#
init
# set JTAG command version 3 to be used
jlink jtag 3
halt 100
# flash erase sector num first last
echo [flash erase_sector 0 0 1]
riscv.cpu.0 mem2array buf 8 0x20000000 0x1000
foreach idx [array names buf] {
if {$buf($idx) != 0xff} {
echo "FLASH not erased"
}
}
halt