mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-10-05 07:27:33 +02:00
Week 4-BN: free the probe (pkill/taskkill) in the Step 21 and 29 console flash snippets
Step 29's snippet had no pkill, so with the debug-server OpenOCD still attached the flash failed with 'CMSIS-DAP command CMD_INFO failed / OpenOCD init failed'. Add the pkill to Step 29 and both Step 21 blocks.
This commit is contained in:
1 parent
e25104a1b0
commit
0594cde63b
2 files changed
+5
No files matched your search
@@ -995,11 +995,14 @@ age: 70
|
||||
> root = open(os.path.expanduser("~/.embedded-hacking-repo")).read().strip()
|
||||
> bin_path = os.path.join(os.path.join(root, "0x0005_intro-to-variables", "build"), "0x0005_intro-to-variables-h.bin")
|
||||
> log = os.path.join(os.path.join(root, "0x0005_intro-to-variables", "build"), "flash.log")
|
||||
> subprocess.run(["pkill", "-TERM", "-f", "openocd"]) # free the probe first
|
||||
> p = subprocess.Popen([os.path.join(root, "flash.sh"), bin_path],
|
||||
> stdout=open(log, "w"), stderr=subprocess.STDOUT, start_new_session=True)
|
||||
> print("flashing in the background; log:", log)
|
||||
> ```
|
||||
>
|
||||
> The `pkill` frees the probe first; on Windows use `subprocess.run(["taskkill", "/F", "/IM", "openocd.exe"])`.
|
||||
>
|
||||
> The console is free the moment this returns. Check it with `print(p.poll())` (`None` = still running, `0` = done) or read `flash.log` — success ends with `** Verified OK **`. (Verified: `Popen` returns in ~1 ms; the flash itself takes ~2 s.)
|
||||
>
|
||||
> The same non-blocking form without the script:
|
||||
@@ -1009,6 +1012,7 @@ age: 70
|
||||
> ocd = os.path.expanduser("~/.pico-sdk/openocd/0.12.0+dev")
|
||||
> bin_path = os.path.join(os.path.join(root, "0x0005_intro-to-variables", "build"), "0x0005_intro-to-variables-h.bin")
|
||||
> log = os.path.join(os.path.join(root, "0x0005_intro-to-variables", "build"), "flash.log")
|
||||
> subprocess.run(["pkill", "-TERM", "-f", "openocd"]) # free the probe first
|
||||
> p = subprocess.Popen([f"{ocd}/openocd", "-s", f"{ocd}/scripts",
|
||||
> "-f", "interface/cmsis-dap.cfg", "-f", "target/rp2350.cfg",
|
||||
> "-c", "adapter speed 5000",
|
||||
@@ -1478,6 +1482,7 @@ import os, subprocess
|
||||
root = open(os.path.expanduser("~/.embedded-hacking-repo")).read().strip()
|
||||
bin_path = os.path.join(os.path.join(root, "0x0008_uninitialized-variables", "build"), "0x0008_uninitialized-variables-h.bin")
|
||||
log = os.path.join(os.path.join(root, "0x0008_uninitialized-variables", "build"), "flash.log")
|
||||
subprocess.run(["pkill", "-TERM", "-f", "openocd"]) # free the probe first
|
||||
p = subprocess.Popen([os.path.join(root, "flash.sh"), bin_path],
|
||||
stdout=open(log, "w"), stderr=subprocess.STDOUT, start_new_session=True)
|
||||
print("flashing in the background; log:", log)
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user