Yeah, nah, aye

Main categories:

Enabling debug for the U-Boot shell

Printing commands as they execute

Preface

This is a quick post to note some poorly documented behaviour in the hush U-Boot shell. I think the right keywords aren't present in the docs and forum posts that do exist.

Enabling set -x type behaviour

If you're running into issues with a U-Boot script, it can be hard to figure out which command(s) are failing and what result that has on execution flow. Especially with scripts baked into environment variables, this can become a nightmare of copy-pasting and manual execution. Instead, why can't there be a way of enabling bash-like set -x behaviour?

It turns out there is, and it's easy if you look for the right keywords. It's called xtrace, and instead of being enabled through set -x, it can be enabled with setenv xtrace yes:

=> printenv example_scriptvar
example_scriptvar=if test "$stderr" serial ; then setenv hello bar ; fi
=> run example_scriptvar
=> setenv xtrace yes
=> run example_scriptvar
+ run example_scriptvar
+ test serial serial
+ setenv hello bar

This lets you follow along and debug each statement in scripts as they run. Note that xtrace doesn't need to be set to "yes", but any non empty value.

Hope this helps someone out there.