Skip to content

Commit 7fc5933

Browse files
committed
Testing flash
1 parent 983ff2d commit 7fc5933

File tree

8 files changed

+93
-7
lines changed

8 files changed

+93
-7
lines changed

openocd.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
adapter_nsrst_assert_width: 100
22

3-
riscv.flash
3+
1
44
debug_level: 2
55

66
Info : Listening on port 6666 for tcl connections

scripts/gd32vf103/flash-app.ocd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# Application address must sync with hw/bsp/gd32vf103c-start/bsp.yml
88
echo "Flashing Application..."
99
flash bank bin/targets/gd32vf103c-start_my_sensor/app/apps/my_sensor_app/my_sensor_app.img gd32vf103 0x08001000 0 0 0 $_TARGETNAME
10+
riscv expose_csrs 3040-3071
1011
echo ""
1112

1213
# Connect to the MCU

scripts/gd32vf103/flash-boot.ocd

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,28 @@
44
# "flash gd32vf103" requires the RISC-V version of OpenOCD: https://github.com/riscv-mcu/riscv-openocd
55
# Based on https://github.com/Tencent/TencentOS-tiny/blob/master/doc/RISC-V%20eclipse%20%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA.md
66

7+
init
8+
9+
echo "Stopping..."
10+
halt
11+
echo ""
12+
13+
#echo "flash protect..."
14+
#flash protect 0 0 last off
15+
#echo ""
16+
717
# Bootloader address must sync with hw/bsp/gd32vf103c-start/bsp.yml
818
echo "Flashing Bootloader..."
9-
flash bank bin/targets/gd32vf103c-start_boot/app/apps/boot_stub/boot_stub.elf.bin gd32vf103 0x08000000 0 0 0 $_TARGETNAME
19+
program bin/targets/gd32vf103c-start_boot/app/apps/boot_stub/boot_stub.elf.bin 0x08000000 verify
1020
echo ""
1121

22+
# mww 0xe004200c 0x4b5a6978
23+
# mww 0xe0042008 0x01
24+
25+
#flash bank bin/targets/gd32vf103c-start_boot/app/apps/boot_stub/boot_stub.elf.bin gd32vf103 0x08000000 0 0 0 $_TARGETNAME
26+
#riscv expose_csrs 3040-3071
27+
#echo ""
28+
1229
# Connect to the MCU
1330
echo "Connecting..."
1431
riscv set_reset_timeout_sec 1

scripts/gd32vf103/flash-boot.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ riscv-openocd/src/openocd \
1010
-f interface/cmsis-dap.cfg \
1111
-f scripts/gd32vf103/gd32vf103.ocd \
1212
-f scripts/gd32vf103/flash-boot.ocd
13+
14+
# openocd/bin/openocd \
15+
# -f scripts/gd32vf103/flash-init.ocd \
16+
# -f interface/cmsis-dap.cfg \
17+
# -f scripts/gd32vf103/gd32vf103.ocd \
18+
# -f scripts/gd32vf103/flash-boot.ocd

scripts/gd32vf103/flash-init.ocd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Disable all openocd messages.
44
#debug_level 0
55
debug_level 2
6+
#debug_level 4
67

78
# From https://github.com/Tencent/TencentOS-tiny/blob/master/doc/RISC-V%20eclipse%20%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA.md
89
adapter_khz 1000

scripts/gd32vf103/gd32vf103.ocd

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ set _CHIPNAME riscv
77

88
# Change expected ID for other dev boards
99
# For GD32VF103C-START:
10-
# jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x1000563d
11-
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x1e200a6d
10+
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x1000563d
11+
# jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x1e200a6d
1212

1313
set _TARGETNAME $_CHIPNAME.cpu
1414
target create $_TARGETNAME riscv -chain-position $_TARGETNAME
1515
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 20480 -work-area-backup 0
16+
# $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 10000 -work-area-backup 1
1617

1718
# Work-area is a space in RAM used for flash programming
1819
if { [info exists WORKAREASIZE] } {
@@ -28,6 +29,3 @@ if { [info exists FLASH_SIZE] } {
2829
# autodetect size
2930
set _FLASH_SIZE 0
3031
}
31-
32-
# flash size will be probed
33-
set _FLASHNAME $_CHIPNAME.flash

scripts/gd32vf103/test.ocd

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
debug_level 4
2+
3+
adapter_khz 1000
4+
reset_config srst_only
5+
adapter_nsrst_assert_width 100
6+
7+
interface cmsis-dap
8+
9+
transport select jtag
10+
11+
#autoexit true
12+
13+
set _CHIPNAME riscv
14+
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x1000563d
15+
16+
set _TARGETNAME $_CHIPNAME.cpu
17+
target create $_TARGETNAME riscv -chain-position $_TARGETNAME
18+
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 20480 -work-area-backup 0
19+
20+
# Work-area is a space in RAM used for flash programming
21+
if { [info exists WORKAREASIZE] } {
22+
set _WORKAREASIZE $WORKAREASIZE
23+
} else {
24+
set _WORKAREASIZE 0x5000
25+
}
26+
27+
# Allow overriding the Flash bank size
28+
if { [info exists FLASH_SIZE] } {
29+
set _FLASH_SIZE $FLASH_SIZE
30+
} else {
31+
# autodetect size
32+
set _FLASH_SIZE 0
33+
}
34+
35+
# flash size will be probed
36+
set _FLASHNAME $_CHIPNAME.flash
37+
38+
flash bank bin/targets/gd32vf103c-start_boot/app/apps/boot_stub/boot_stub.elf.bin gd32vf103 0x08000000 0 0 0 $_TARGETNAME
39+
40+
#riscv expose_csrs 3040-3071
41+
42+
#init
43+
44+
#halt
45+
# We must turn on this because otherwise the IDE version debug cannot download the program into flash
46+
#flash protect 0 0 last off
47+
48+
exit

scripts/gd32vf103/test.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
# Flash Mynewt Bootloader on macOS and Linux
3+
4+
set -e # Exit when any command fails.
5+
set -x # Echo all commands.
6+
7+
riscv-openocd/src/openocd \
8+
-s riscv-openocd/tcl \
9+
-f scripts/gd32vf103/test.ocd
10+
11+
# openocd/bin/openocd \
12+
# -f scripts/gd32vf103/flash-init.ocd \
13+
# -f interface/cmsis-dap.cfg \
14+
# -f scripts/gd32vf103/gd32vf103.ocd \
15+
# -f scripts/gd32vf103/flash-boot.ocd

0 commit comments

Comments
 (0)