-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2024 ETH Zurich and University of Bologna. | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Cheshire disk flashing script for use with GDB. | ||
|
||
target extended-remote localhost:3333 | ||
|
||
# Load flashing program | ||
load sw/boot/flash.spm.elf | ||
|
||
# Load disk image to DRAM | ||
eval "restore %s binary 0x80000000", $img | ||
|
||
# Write flash parameters to scratch regs | ||
set *0x03000000=$target | ||
set *0x03000004=0x80000000 | ||
set *0x03000008=$offs | ||
set *0x0300000c=$len | ||
|
||
# Launch payload and quit after return | ||
continue | ||
quit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#! /usr/bin/env bash | ||
# | ||
# Copyright 2024 ETH Zurich and University of Bologna. | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Cheshire disk flashing script invoking OpenOCD and GDB. | ||
# | ||
# Arguments: | ||
# $1: target board | ||
# $2: target disk | ||
# $3: (optional): disk image | ||
# $4: (optional): copy length | ||
# $5: (optional): copy offset | ||
|
||
set -e | ||
|
||
# Determine the image name and size | ||
img=${3:-sw/boot/linux.${1}.gpt.bin} | ||
# Ensure the image exists and determine rounded-up size | ||
len=${4:-$(stat -c%s ${img})} | ||
len=$((len/512+1)) | ||
|
||
# Run OpenOCD and GDB | ||
openocd -f util/openocd.${1}.tcl & | ||
sleep 2 | ||
riscv64-unknown-elf-gdb --batch \ | ||
-ex "set \$target = ${2:-1}" \ | ||
-ex "set \$img = \"${img}\"" \ | ||
-ex "set \$len = ${len}" \ | ||
-ex "set \$offs = ${5:-0}" \ | ||
-ex "source util/flash_disk.gdb" | ||
wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters