Skip to content

Commit 6c5503c

Browse files
committed
Flash OK
1 parent 8245586 commit 6c5503c

File tree

5 files changed

+79
-30
lines changed

5 files changed

+79
-30
lines changed

scripts/gd32vf103/flash-app.ocd

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
11
# This is an OpenOCD script that flashes the Application ROM.
22
# Used by tasks.json for "Load Application" command.
33
# Equivalent to "newt load -v gd32vf103c-start_my_sensor".
4-
# "flash gd32vf103" requires the RISC-V version of OpenOCD: https://github.com/riscv-mcu/riscv-openocd
54
# 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
65

6+
# Connect to the device and halt
7+
init
8+
echo "Stopping..."
9+
reset halt
10+
echo ""
11+
12+
# TODO: This may be needed for Sipeed
13+
# echo "Unprotecting Flash..."
14+
# flash protect 0 0 last off
15+
# echo ""
16+
717
# Application address must sync with hw/bsp/gd32vf103c-start/bsp.yml
818
echo "Flashing Application..."
9-
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
19+
program bin/targets/gd32vf103c-start_my_sensor/app/apps/my_sensor_app/my_sensor_app.img 0x08001000 verify
1120
echo ""
1221

13-
# Connect to the MCU
22+
# TODO: This may be needed for Sipeed
23+
# mww 0xe004200c 0x4b5a6978
24+
# mww 0xe0042008 0x01
25+
26+
# Connect to the device
1427
echo "Connecting..."
1528
riscv set_reset_timeout_sec 1
1629
init
1730
echo ""
1831

19-
# Restart the device.
32+
# Restart the device and halt
2033
echo "Restarting..."
2134
reset halt
2235
echo ""

scripts/gd32vf103/flash-boot.ocd

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
11
# This is an OpenOCD script that flashes the Bootloader ROM.
22
# Used by tasks.json for "Load Bootloader" command.
33
# Equivalent to "newt load -v gd32vf103c-start_my_sensor".
4-
# "flash gd32vf103" requires the RISC-V version of OpenOCD: https://github.com/riscv-mcu/riscv-openocd
54
# 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
65

6+
# Connect to the device and halt
77
init
8-
98
echo "Stopping..."
10-
halt
9+
reset halt
1110
echo ""
1211

13-
#echo "flash protect..."
14-
#flash protect 0 0 last off
15-
#echo ""
12+
# TODO: This may be needed for Sipeed
13+
# echo "Unprotecting Flash..."
14+
# flash protect 0 0 last off
15+
# echo ""
1616

1717
# Bootloader address must sync with hw/bsp/gd32vf103c-start/bsp.yml
1818
echo "Flashing Bootloader..."
1919
program bin/targets/gd32vf103c-start_boot/app/apps/boot_stub/boot_stub.elf.bin 0x08000000 verify
2020
echo ""
2121

22+
# TODO: This may be needed for Sipeed
2223
# mww 0xe004200c 0x4b5a6978
2324
# mww 0xe0042008 0x01
2425

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-
29-
# Connect to the MCU
26+
# Connect to the device
3027
echo "Connecting..."
3128
riscv set_reset_timeout_sec 1
3229
init
3330
echo ""
3431

35-
# Restart the device.
32+
# Restart the device and halt
3633
echo "Restarting..."
3734
reset halt
3835
echo ""

scripts/gd32vf103/flash-init.ocd

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

87
# 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
98
adapter_khz 1000

scripts/gd32vf103/gd32vf103.ocd

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
1-
# 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
1+
# GD32VF103 Target Definition
2+
# "flash gd32vf103" requires the RISC-V version of OpenOCD: https://github.com/riscv-mcu/riscv-openocd
3+
# 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
24

35
# Select JTAG transport
46
transport select jtag
57

8+
# Used to name the target
69
set _CHIPNAME riscv
710

811
# Change expected ID for other dev boards
912
# For GD32VF103C-START:
10-
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x1000563d
11-
# jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x1e200a6d
13+
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x1e200a6d
14+
# jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x1000563d
1215

16+
# Create target named "riscv.cpu"
1317
set _TARGETNAME $_CHIPNAME.cpu
1418
target create $_TARGETNAME riscv -chain-position $_TARGETNAME
15-
$_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
1719

18-
# Work-area is a space in RAM used for flash programming
20+
# Use smaller work area size in RAM to handle Sipeed
21+
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 10000 -work-area-backup 1
22+
# $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 20480 -work-area-backup 0
23+
24+
# Allow overriding of work area size, the a space in RAM used for flash programming
1925
if { [info exists WORKAREASIZE] } {
2026
set _WORKAREASIZE $WORKAREASIZE
2127
} else {
22-
set _WORKAREASIZE 0x5000
28+
set _WORKAREASIZE 0x2710
2329
}
2430

25-
# Allow overriding the Flash bank size
31+
# Allow overriding of flash bank size
2632
if { [info exists FLASH_SIZE] } {
2733
set _FLASH_SIZE $FLASH_SIZE
2834
} else {
2935
# autodetect size
3036
set _FLASH_SIZE 0
3137
}
38+
39+
# Define a flash bank named "riscv.flash" at 0x08000000, size will be probed if not overridden
40+
set _FLASHNAME $_CHIPNAME.flash
41+
flash bank $_FLASHNAME gd32vf103 0x08000000 0 0 0 $_TARGETNAME
42+
43+
riscv set_reset_timeout_sec 1
44+
riscv expose_csrs 3040-3071

scripts/gd32vf103/test.ocd

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
debug_level 3
1+
debug_level 2
22

33
adapter_khz 1000
44
reset_config srst_only
@@ -33,18 +33,45 @@ if { [info exists FLASH_SIZE] } {
3333
set _FLASH_SIZE 0
3434
}
3535

36+
#debug_level 4
37+
38+
#set _FLASH_SIZE 0x1000
39+
3640
# flash size will be probed
3741
set _FLASHNAME $_CHIPNAME.flash
3842

39-
flash bank bin/targets/gd32vf103c-start_boot/app/apps/boot_stub/boot_stub.elf.bin gd32vf103 0x08000000 0 0 0 $_TARGETNAME
43+
flash bank $_FLASHNAME gd32vf103 0x08000000 0 0 0 $_TARGETNAME
44+
flash banks
45+
flash list
46+
47+
#flash bank bin/targets/gd32vf103c-start_boot/app/apps/boot_stub/boot_stub.elf.bin gd32vf103 0x08000000 0 0 0 $_TARGETNAME
4048

41-
riscv set_reset_timeout_sec 1
49+
program bin/targets/gd32vf103c-start_boot/app/apps/boot_stub/boot_stub.elf.bin 0x08000000 verify
50+
51+
#riscv set_reset_timeout_sec 1
4252
# riscv expose_csrs 3040-3071
4353

44-
init
54+
#init
4555

4656
#halt
4757
# We must turn on this because otherwise the IDE version debug cannot download the program into flash
4858
#flash protect 0 0 last off
4959

5060
exit
61+
62+
#flash
63+
# flash bank bank_id driver_name base_address size_bytes chip_width_bytes
64+
# bus_width_bytes target [driver_options ...]
65+
# flash banks
66+
# flash init
67+
# flash list
68+
#gd32vf103
69+
# gd32vf103 lock bank_id
70+
# gd32vf103 mass_erase bank_id
71+
# gd32vf103 unlock bank_id
72+
#gdb_flash_program ('enable'|'disable')
73+
#mflash
74+
# mflash bank soc_type base_addr pin_id target
75+
#mflash init
76+
#nand
77+
#program <filename> [address] [verify] [reset] [exit]

0 commit comments

Comments
 (0)