From: Tom Evans <tom@ceos.com.au>
To: u-boot@lists.denx.de
Subject: [U-Boot] U-Boot Scripting suggestions to decrement counter in EEPROM. Alignment bug in itest on ARM.
Date: Tue, 03 Mar 2009 17:40:28 +1100 [thread overview]
Message-ID: <49ACD0DC.10309@ceos.com.au> (raw)
In-Reply-To: <20080827053319.18025.qmail@devel>
I'm implementing a rather complex boot that involves flags and counters
in EEPROM.
This is to detect multiple boot failures and to then revert to a
previous Linux kernel and sysroot.
The Hush shell and applications almost support this by using scripts
(even autoscripting), but not quite.
"ee read" and "ee write" let me read and write the counters and flags to
memory.
From there, "if itest *$buf_addr == 1" (and so on) can be used to test
the values of flags in the EEPROM (except for bad bug in itest, listed
later). "mw.b" can write flags into memory to then be written to eeprom.
The only way I can currently think of to "read" a byte from EEPROM into
a shell variable so it can be decremented (with setexpr) and then
written back is to use something like the following:
READ_ADDR=0x82000000
setenv FN_READ_BYTE 'setenv DATA; DATA=0; while itest \
*$READ_ADDR != $DATA; do setexp DATA $DATA + 1; done'
mw.l 0x82000000 254
run FN_READ_BYTE
echo $DATA
Yes, it is comparing every value from zero and incrementing until it
gets a match! That results in $DATA being set to "254" (the value I
wrote to memory) but it takes 9 seconds to run on an 800MHz ARM core!
Am I missing a simpler way or am I going to have to add some new
commands, like a "memory read" variant that reads into an environment
variable. If setexpr took a "*" to be a pointer (to be consistent with
itest) it might be the easiest addition.
BUG IN ITEST
------------
itest crashes ARM chips. I can "iread.b *82000000 == 0", but
"iread.b *82000001 == 0" throws an alignment exception that kills the
box. The code in itest.c is:
static long evalexp(char *s, int w)
{
long l, *p;
/* if the parameter starts with a * then assume is a
pointer to the value we want */
if (s[0] == '*') {
p = (long *)simple_strtoul(&s[1], NULL, 16);
l = *p;
} else {
l = simple_strtoul(s, NULL, 16);
}
return (l & ((1 << (w * 8)) - 1));
}
"l = *p" works on a 486 but not on an ARM. It is a simple change - a
three-way case on the width reading through the "right pointer".
Yes, I should fix this and submit a patch, but I'm not working on
anything close to the distribution tree unfortunately. I'm pretty sure
this hasn't been fixed lately though.
--
===
Tom Evans Tom.Evans@ceos.com.au
CEOS Pty Ltd www.ceos.com.au
3/17 Burgundy St, Heidelberg,
Victoria 3084, Australia
next prev parent reply other threads:[~2009-03-03 6:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080827053319.18025.qmail@devel>
2008-12-30 4:31 ` [U-Boot] Minor bug found in board/zylonite/lowlevel_init.S. 0x300 changed to 300 Tom Evans
2009-01-27 21:24 ` Wolfgang Denk
2009-03-03 6:40 ` Tom Evans [this message]
2009-03-03 8:33 ` [U-Boot] U-Boot Scripting suggestions to decrement counter in EEPROM. Alignment bug in itest on ARM Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49ACD0DC.10309@ceos.com.au \
--to=tom@ceos.com.au \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox