-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add pico-debug support #239
Conversation
It only took 3 local rebuilds (one out-of-disk-space error, one typo in the release name, and one final build), but #241 will get the openocd binaries sorted. Would it be possible to get a short writeup on how to use this in the docs? Even an unformatted |
@earlephilhower, your efforts in updating the binaries are much appreciated. Added documentation will be forthcoming. |
Thanks for the update and docs! I will give it a try tonight and if all's well there will be a new release w/this included before tomorrow. |
The code changes look good! Maybe you'd like to add a URL to the pico-debug repo somewhere? However, I gave this a try this morning and am not getting anywhere. I've manually uploaded the MAXRAM .UF2 release from your repo, adjusted the Is there a different linker
|
Don't use MAXRAM; use the GIMMECACHE linked to in the README.md. The MAXRAM variant exists in the cache memory, and the arduino-pico builds operate with the cache enabled. In contrast, the GIMMECACHE leaves the cache alone and resides in the top of the SRAM. |
I think the linker |
You are right. In addition to it must be GIMMECACHE used, the memmap needs changing as well to avoid the 16kB at the top. I could have sworn the linker script was different in pico-sdk (at least in January). Please give me the chance to revise the PR. |
@earlephilhower, I have added a commit to address the memmap issue. At the same time, I added the URL that you also suggested. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One request, please: You can get rid of the copy (git rm memmap_picodebug.ld
) of the linker file with a simple define substitution. Here's the git diff
(minus boards.txt rebuild):
diff --git a/lib/memmap_default.ld b/lib/memmap_default.ld
index 28e77f1..8749c75 100644
--- a/lib/memmap_default.ld
+++ b/lib/memmap_default.ld
@@ -24,7 +24,7 @@
MEMORY
{
FLASH(rx) : ORIGIN = 0x10000000, LENGTH = __FLASH_LENGTH__
- RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k
+ RAM(rwx) : ORIGIN = 0x20000000, LENGTH = __RAM_LENGTH__
SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k
}
diff --git a/platform.txt b/platform.txt
index f2edea9..302ca9d 100644
--- a/platform.txt
+++ b/platform.txt
@@ -107,7 +107,7 @@ archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
## Generate the linker map with specific flash sizes/locations
-recipe.hooks.linking.prelink.1.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/simplesub.py" --input "{runtime.platform.path}/lib/memmap_default.ld" --out "{build.path}/memmap_default.ld" --sub __FLASH_LENGTH__ {build.flash_length} --sub __EEPROM_START__ {build.eeprom_start} --sub __FS_START__ {build.fs_start} --sub __FS_END__ {build.fs_end}
+recipe.hooks.linking.prelink.1.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/simplesub.py" --input "{runtime.platform.path}/lib/memmap_default.ld" --out "{build.path}/memmap_default.ld" --sub __FLASH_LENGTH__ {build.flash_length} --sub __EEPROM_START__ {build.eeprom_start} --sub __FS_START__ {build.fs_start} --sub __FS_END__ {build.fs_end} --sub __RAM_LENGTH__ {build.ram_length}
## Compile the boot stage 2 blob
recipe.hooks.linking.prelink.2.pattern="{compiler.path}{compiler.S.cmd}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} -c "{runtime.platform.path}/boot2/{build.boot2}.S" "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_regs/include/" "-I{runtime.platform.path}/pico-sdk/src/common/pico_binary_info/include" -o "{build.path}/boot2.o"
diff --git a/tools/makeboards.py b/tools/makeboards.py
index bd6797d..f0ef7b4 100755
--- a/tools/makeboards.py
+++ b/tools/makeboards.py
@@ -78,10 +78,8 @@ def BuildHeader(name, vendor_name, product_name, vidtouse, pidtouse, vid, pid, b
print("%s.build.led=" % (name))
print("%s.build.core=rp2040" % (name))
print("%s.build.mcu=rp2040" % (name))
- if ramsize == (256 * 1024):
- print("%s.build.ldscript=memmap_default.ld" % (name))
- else:
- print("%s.build.ldscript=memmap_picodebug.ld" % (name))
+ print("%s.build.ldscript=memmap_default.ld" % (name))
+ print("%s.build.ram_length=%dk" % (name, ramsize / 1024))
print("%s.build.boot2=%s" % (name, boot2))
print("%s.build.vid=%s" % (name, vid))
print("%s.build.pid=%s" % (name, pid))
I just ran w/the gimmecache.uf2 one and the above change and it worked a charm. Very cool and pretty painless!
Thanks @earlephilhower for the excellent suggestion. I've committed the requested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just ran the latest push and was able to bring up a 1-board debug session on blink.ino. Thanks!
Release 1.9.2 should be auto-published in a couple minutes with this update and the supporting toolchain. |
Fantastic! Thanks so much. |
At a minimum, this depends on 7855b0c pico-quick-toolchain for CMSIS-DAP support.
Although this PR is functional, I suspect that some further tweaking may be desired, as I had to hack up a few files (in particular ./tools/makeboards.py) in a way that might offend the original author(s). For this reason (and the toolchain dependency), I marked this as draft.
I believe that I followed the No USB intent of #233 through the use of a NO_USB define, but by modifying the script rather than the boards.txt result. This macro is used in ./cores/RP2040USB.cpp, ./cores/SerialUSB.cpp, and ./cores/main.cpp
I also added a NO_MULTICORE define, as ./cores/main.cpp presently causes the 2nd CPU core to run new code. Since the 2nd CPU core is already running the debugger when pico-debug is used, this existing behavior doesn’t go down too well.
With this PR, usage of arduino-pico with pico-debug is to initially load the pico-debug .uf2 (nominally pico-debug-gimmecache.uf2) onto the target. (Keep in mind that pico-debug is a RAM-only program, so copying the .uf2 does not alter the flash in any way.)
In the Arduino IDE, select a pico-debug Board/target.
From that point on, you should be able to Sketch > Upload your sketches like one would with picoprobe, but without needing two RP2040 and wiring between the two boards.