Bug#870430: linux-image-4.9.0-3-marvell: Couldn't find DTB in /usr/lib/linux-image-4.9.0-3-marvell or /etc/flash-kernel/dtbs
On Wed, 2017-08-02 at 21:29 +0200, noone never wrote:
> Please find my answers inline.
Thanks! In particular for...
> > The message:
> > Couldn't find DTB in /usr/lib/linux-image-4.9.0-3-marvell or
> > /etc/flash-kernel/dtbs
> > is interesting since the double space in "DTB in" is supposed to
> > contain $dtb_name, i.e. the path to look for, but it doesn't not.
> > Please could you attach the full output of running `sh -x
> > /usr/sbin/flash-kernel`, maybe that will include a clue as to where
> > things have gone astray.
> Log is attached
Looking at uses of dtb in you trace:
$ grep dtb ~/tmp/flash-kernel-log.txt
+ '[' -n kirkwood-sheevaplug.dtb ']'
+ echo 'Using DTB: kirkwood-sheevaplug.dtb'
Using DTB: kirkwood-sheevaplug.dtb
So dtb_name is successfully assigned and reported here.
+ '[' xkirkwood-sheevaplug.dtb = x ']'
+ local dtb
+ local dtb_name
But here it is redeclared as a local shadowing the original, but
++ local dtb
++ case "$dtb_name" in
+++ find /etc/flash-kernel/dtbs -name
++ error 'Couldn'\''t find DTB in /usr/lib/linux-image-4.9.0-3-marvell or /etc/flash-kernel/dtbs'
++ echo 'Couldn'\''t find DTB in /usr/lib/linux-image-4.9.0-3-marvell or /etc/flash-kernel/dtbs'
Couldn't find DTB in /usr/lib/linux-image-4.9.0-3-marvell or /etc/flash-kernel/dtbs
and we end up using the blank version here.
I have a suspicious this was introduced by the fix to #836697 in 
which seems to have added the shadowing "local dtb_name".
It's a bit naughty but if you edit /usr/share/flash-kernel/functions
and near the top of handle_dtb() change the:
local dtb_name=$(basename $dtb_name)
and then remove the "dtb_name=$(basename $dtb_name)" from both halves
of the following if statement, does that fix it?
Martin, does that fix seem correct to you?
I think the "local dtb" bit could also move into the else have with the
"dtb=$(find_dtb_file)" as well, but that would be an unrelated change.
This ultimately seems to be down to a difference in the behaviour of
/bin/dash vs /bin/bash, which I suppose is why it has not been widely
$ cat > t.sh <<EOF
echo "c.a = \"$a\""
echo "b.a = \"$a\""
echo "a.a = \"$a\""
$ dash t.sh
a.a = "foo"
b.a = "foo"
c.a = "foo"
$ bash t.sh
a.a = "foo"
b.a = ""
c.a = "foo"
I s uppose you have /bin/sh as a link to /bin/bash on your system still.
So an alternative workaround would probably be "sudo dpkg-reconfigure
dash" and make dash the system shell.