mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
app -> apps and new function to send boot command on serial port to start run mode
This commit is contained in:
parent
1e5b381c75
commit
c625b77909
3 changed files with 45 additions and 5 deletions
|
|
@ -9,6 +9,7 @@ from commands.monitor import cmd_monitor
|
|||
from commands.flash import cmd_flash
|
||||
from commands.doctor import cmd_doctor
|
||||
from commands.artifacts import cmd_artifacts
|
||||
from commands.boot import cmd_boot
|
||||
|
||||
VERSION = "0.1.1"
|
||||
|
||||
|
|
@ -33,7 +34,7 @@ def main():
|
|||
# monitor
|
||||
m = sub.add_parser("monitor", help="Open a serial monitor")
|
||||
m.add_argument("-p", "--port", required=True, help="Serial port (e.g., COM5, /dev/ttyUSB0)")
|
||||
m.add_argument("-b", "--baud", type=int, default=115200, help="Baud rate")
|
||||
m.add_argument("-b", "--baud", type=int, default=1000000, help="Baud rate")
|
||||
m.add_argument("--ts", action="store_true", help="Show timestamps on received lines")
|
||||
m.add_argument("--save", help="Append output to a file")
|
||||
m.add_argument("--reset", action="store_true", help="Toggle DTR/RTS on open")
|
||||
|
|
@ -52,9 +53,15 @@ def main():
|
|||
# flash
|
||||
f = sub.add_parser("flash", help="Copy UF2 file(s) to a mounted drive")
|
||||
f.add_argument("--dest", required=True, help="Mount path of the UF2 boot drive (e.g., D:\\)")
|
||||
f.add_argument("files", nargs="+", help="One or more UF2 files to copy (e.g., loader.uf2 xous.uf2 app.uf2)")
|
||||
f.add_argument("files", nargs="+", help="One or more UF2 files to copy (e.g., loader.uf2 xous.uf2 apps.uf2)")
|
||||
f.set_defaults(func=cmd_flash)
|
||||
|
||||
# boot
|
||||
boot = sub.add_parser("boot", help="Send 'boot' to the bootloader serial port to start run mode")
|
||||
boot.add_argument("-p", "--port", required=True, help="Bootloader serial port (e.g., COM7, /dev/ttyACM0)")
|
||||
boot.add_argument("-b", "--baud", type=int, default=1000000, help="Baud rate (default 1000000)")
|
||||
boot.set_defaults(func=cmd_boot)
|
||||
|
||||
args = ap.parse_args()
|
||||
|
||||
log_level = logging.DEBUG if getattr(args, "verbose", False) else logging.WARNING
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
Return release UF2 images for flashing.
|
||||
|
||||
Scans the release directory for UF2 images:
|
||||
<xous-core>/target/riscv32imac-unknown-xous-elf/release/{loader.uf2,xous.uf2,app.uf2}
|
||||
<xous-core>/target/riscv32imac-unknown-xous-elf/release/{loader.uf2,xous.uf2,apps.uf2}
|
||||
|
||||
Outputs JSON if --json is set:
|
||||
{
|
||||
"images": [
|
||||
{ "path": ".../loader.uf2", "role": "loader" },
|
||||
{ "path": ".../xous.uf2", "role": "xous" },
|
||||
{ "path": ".../app.uf2", "role": "app" }
|
||||
{ "path": ".../apps.uf2", "role": "apps" }
|
||||
]
|
||||
}
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ TRIPLE: str = "riscv32imac-unknown-xous-elf"
|
|||
FILENAMES: List[Tuple[str, str]] = [
|
||||
("loader.uf2", "loader"),
|
||||
("xous.uf2", "xous"),
|
||||
("app.uf2", "app"),
|
||||
("apps.uf2", "apps"),
|
||||
]
|
||||
|
||||
EXIT_OK = 0
|
||||
|
|
|
|||
33
tools-bao/commands/boot.py
Normal file
33
tools-bao/commands/boot.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import sys
|
||||
import time
|
||||
import logging
|
||||
import serial
|
||||
|
||||
def cmd_boot(args) -> None:
|
||||
port = args.port
|
||||
baud = args.baud
|
||||
try:
|
||||
ser = serial.Serial(port, baud, timeout=0.2)
|
||||
except Exception as e:
|
||||
logging.error(f"[bao] cannot open {port}: {e}")
|
||||
sys.exit(2)
|
||||
|
||||
try:
|
||||
with ser:
|
||||
try:
|
||||
ser.reset_input_buffer()
|
||||
ser.reset_output_buffer()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Send the boot command to leave bootloader mode and start firmware (run mode)
|
||||
ser.write(b"boot\r\n")
|
||||
ser.flush()
|
||||
# tiny grace period to ensure the device processes it
|
||||
time.sleep(0.1)
|
||||
except Exception as e:
|
||||
logging.error(f"[bao] boot command failed on {port}: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
print(f"[bao] sent 'boot' on {port}")
|
||||
sys.exit(0)
|
||||
Loading…
Reference in a new issue