[LEDE-DEV] Kirkwood Audi U-Boot fw_setenv errors
Claudio Leite
leitec at gmail.com
Sun Jun 26 16:07:58 PDT 2016
Hello David,
* David Gilman (dgilman at gilslotd.com) wrote:
> Claudio, I have a Kirkwood EA3500 (Audi) board and it seems that at some
> point the patches for this board have regressed the uboot fw_setenv
> utility and semi-bricked my machine. I've been digging into this issue
> and I suspect there was some value missed somewhere but I would like to
> hear some feedback from you and am willing to dig around on this box to
> help you troubleshoot the issue.
>
> I find it pretty tricky to time the dual firmware resetting feature in
> the board's uboot (I think I've gotten it to work for me once...) so I
> prefer to set the uboot variables directly to switch what partition I'm
> booting from. When I do so with a `fw_setenv boot_part 1':
>
> Read error on /dev/mtd1: No error information
> Error: can't write fw_env to flash
>
> At one point I think this worked, but I'm not sure when it regressed.
> The "No error information" is from an errno of 0, so the read worked,
> but uboot bailed out anyway. I ran the utility under strace:
>
> _llseek(4, 0, [0], SEEK_SET) = 0
> read(4, "7b\23\200bootdelay=0\0baudrate=115200\0"..., 131072) = 16384
> writev(2, [{"Read error on /dev/mtd1: No erro"..., 46}, {NULL, 0}], 2) = 46
> close(4) = 0
> writev(2, [{"", 0}, {"Error: can't write fw_env to fla"..., 35}], 2) = 35
>
> The read() there returned 16384 (0x4000) although we asked it for 131072
> bytes (0x20000). That is why fw_setenv fails, if you look at the source
> code inside uboot it bails out like this when those two aren't equal.
What does your /etc/fw_env.config look like? Did you perhaps restore a
saved config backup at some point which could've contained that file?
It should look like:
/dev/mtd1 0x0 0x4000 0x4000
If I change the last value to 0x20000 (which would've been the correct
size on the previous partition layout) I get the same error:
root at ea3500:/etc# fw_setenv blah test
Read error on /dev/mtd1: No error information
Error: can't write fw_env to flash
root at ea3500:/etc#
> For reference, this is fw_env.c line 734 in uboot:
>
> https://github.com/trini/u-boot/blob/master/tools/env/fw_env.c#L734
>
> The 0x20000 argument comes from CUR_ENVSIZE which is where I lose the
> trail on where these magic numbers are coming from. However, I am
> seeing these magic numbers in a patch you authored: "kirkwood: rework
> Linksys EA[34]500 DTS". If you look at the diff there, you'll see those
> magic numbers 0x4000 and 0x20000 popping up again. So I am not sure
> what's the way to go forward here but at the moment I can't write to any
> flash (to change uboot variables or flash a new root partition) so I am
> sort of stuck.
The change was due to the changed size of the u_env partition after the
re-work. The previous dts had a much larger u_env partition, sized at
0x20000 despite the env taking up just the first 0x4000 bytes.
(0x4000 is also the erasesize for the flash chip)
I resized them to match the factory firmware's idea and to allow access
to the s_env partition, which was previously contained within the
oversized u_env.
-Claudio
More information about the Lede-dev
mailing list