Skip to content
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

Rpi3 - Enable JTAG in config.txt #1634

Closed
jogarock opened this Issue Jun 26, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@jogarock
Copy link

jogarock commented Jun 26, 2017

The Raspberry Pi 3 allows one to enable JTAG on the GPIO via the enable_jtag_gpio=1 flag in the config.txt. This provides the ability to debug the boot process remotely even before the first instruction is executed.

This seems preferable to enabling JTAG in U-Boot as it reduces the amount of divergence from upstream.

Ref: raspberrypi/firmware#639

@jforissier

This comment has been minimized.

Copy link
Contributor

jforissier commented Jun 26, 2017

Hi @jogarock,

So what?

@jogarock

This comment has been minimized.

Copy link
Author

jogarock commented Jun 27, 2017

Hi @jforissier, perhaps this issue is better for the build and/or linaro-swg/u-boot repos. Apologies.

However, I'm only raising this due to the fact that enabling JTAG in U-Boot is a non-optimal solution when building given that it has been supported in the Rpi config.txt for some time now and probably doesn't belong upstream (if there is still a desire to try and upstream). Documentation should point the developer to the option and give them the ability to enable or disable JTAG as they please.

It's clearly not an important or pressing issue, I just wanted to bring it to the developers' attention since it (if even slightly) reduces the divergence from upstream code and is generally "easier" for the user.

@jforissier

This comment has been minimized.

Copy link
Contributor

jforissier commented Jun 27, 2017

@jogarock thanks for clarifying!
I'm not maintaining the Linaro u-boot repo, but I can merge stuff into https://github.com/OP-TEE/build.

Are you suggesting just this?

diff --git a/rpi3/firmware/config.txt b/rpi3/firmware/config.txt
index 1c3885d..dc5c772 100644
--- a/rpi3/firmware/config.txt
+++ b/rpi3/firmware/config.txt
@@ -1,3 +1,4 @@
+enable_jtag_gpio=1
 enable_uart=1
 arm_control=0x200
 kernel_old=1

Or maybe it's not OK to enable JTAG unconditionally? In this case how about this:

diff --git a/docs/rpi3.md b/docs/rpi3.md
index 12e7622..cb5a53f 100644
--- a/docs/rpi3.md
+++ b/docs/rpi3.md
@@ -292,13 +292,13 @@ need to reboot the RPi after a rebuild.
 # 6. OpenOCD and JTAG
 First a word of warning here, even though this seems to be working quite good as
 of now, it should be well understood that this is based on incomplete and out of
-tree patches. So what are the major changes that enables this? First [OpenOCD]
-currently doesn't contain ARMv8-A / AArch64 support in the upstream tree. A
-couple of different people have put something together that gets the job done.
-But to get in a shape for upstream, there is still quite a lot left to do. The
-other change needed is in U-Boot, that is where we configure the [RPi3 GPIO
-pins] so that they will talk JTAG. The pin configuration and the wiring for the
-cable looks like this:
+tree patches. Indeed, [OpenOCD] currently doesn't contain ARMv8-A / AArch64
+support in the upstream tree. A couple of different people have put something
+together that gets the job done. But to get in a shape for upstream, there is
+still quite a lot left to do.
+To enable JTAG you need to uncomment the line: `enable_jtag_gpio=1` in
+`rpi3/firmware/config.txt`.
+The pin configuration and the wiring for the cable looks like this:
 
 |JTAG pin|Signal|GPIO   |Mode |Header pin|
 |--------|------|-------|-----|----------|
diff --git a/rpi3/firmware/config.txt b/rpi3/firmware/config.txt
index 1c3885d..6ff00b5 100644
--- a/rpi3/firmware/config.txt
+++ b/rpi3/firmware/config.txt
@@ -1,3 +1,4 @@
+#enable_jtag_gpio=1
 enable_uart=1
 arm_control=0x200
 kernel_old=1
@jogarock

This comment has been minimized.

Copy link
Author

jogarock commented Jun 27, 2017

The actual patch requires a few more changes:

  • The enable_jtag_gpio flag enables JTAG on only the ALT4 pins, whereas the U-boot code enables it on a mix of ALT4/ALT5 pins. This is a funny relic of a project from a few years ago where someone chose those GPIO pins and that decision has propagated into many projects since.

  • U-boot needs to be built without the CONFIG_JTAG_ENABLE macro.

I can try and put in a pull request tonight; however, it looks like CONFIG_JTAG_ENABLE is defined by default in the linaro-swg/u-boot repo.

@jogarock

This comment has been minimized.

Copy link
Author

jogarock commented Jun 29, 2017

See:
OP-TEE/build#155
linaro-swg/u-boot#1

Both have been tested on an Rpi3 with the Flyswatter 2 JTAG debugger.

igoropaniuk added a commit to igoropaniuk/u-boot that referenced this issue Aug 25, 2017

rpi3: remove jtag enable code
Remove JTAG enable switches for Rpi3. The Raspberry Pi 3 allows to
enable JTAG on the GPIO via the enable_jtag_gpio=1 flag in the
config.txt, which is more prefarable.

Fixes: OP-TEE/optee_os#1634

Suggested-by: Joseph Pantoga <jp@redballoonsecurity.com>
Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
Tested-by: Igor Opaniuk <igor.opaniuk@linaro.org> (RPi3)

igoropaniuk added a commit to igoropaniuk/u-boot that referenced this issue Aug 28, 2017

rpi3: remove jtag enable code
Remove JTAG enable switches for Rpi3. The Raspberry Pi 3 allows to
enable JTAG on the GPIO via the enable_jtag_gpio=1 flag in the
config.txt, which is more prefarable.

Fixes: OP-TEE/optee_os#1634

Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Suggested-by: Joseph Pantoga <jp@redballoonsecurity.com>
Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
Tested-by: Igor Opaniuk <igor.opaniuk@linaro.org> (RPi3)

jforissier added a commit to linaro-swg/u-boot that referenced this issue Aug 28, 2017

rpi3: remove jtag enable code
Remove JTAG enable switches for Rpi3. The Raspberry Pi 3 allows to
enable JTAG on the GPIO via the enable_jtag_gpio=1 flag in the
config.txt, which is more prefarable.

Fixes: OP-TEE/optee_os#1634

Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Suggested-by: Joseph Pantoga <jp@redballoonsecurity.com>
Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
Tested-by: Igor Opaniuk <igor.opaniuk@linaro.org> (RPi3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.