From: Grant Edwards <grante@visi.com>
To: ecos-discuss@sources.redhat.com
Subject: [ECOS] RedBoot: load.c srecord input offset fix
Date: Thu, 19 Apr 2001 13:19:00 -0000 [thread overview]
Message-ID: <20010419152033.A29215@visi.com> (raw)
The "offset" variable in load_srec_image() isn't incremented
properly (assuming its purpose is to keep track of the current
byte offset in the input stream). My version of load.c has
diverged enough that I can't generate a usable patch, so I'll
summarize the changes:
Increment at top of main while loop:
while ((c = (*getc)()) > 0) {
+ ++offset;
lp = line; len = 0;
// Start of line
if (c != 'S') {
Double the byte-count for the address field to get the
character count since calling _hex2(func,N,&sum) consumes 2N
characters from the input stream::
case '2':
case '3':
base_addr = addr = (unsigned char *)_hex2(getc, (type-'1'+2), &sum);
- offset += (type-'1'+2);
+ offset += (type-'1'+2)*2;
if (first_addr) {
if (base) {
addr_offset = (unsigned long)base - (unsigned long)addr;
Double the byte-count for the data field to get the character
count, and incrment by 2 instead of 1 for the checksum byte:
return;
}
count -= ((type-'1'+2)+1);
- offset += count;
+ offset += count*2;
while (count-- > 0) {
val = _hex2(getc, 1, &sum);
*addr++ = val;
}
cksum = _hex2(getc, 1, 0);
- offset += 1;
+ offset += 2;
sum = sum & 0xFF;
cksum = (~cksum & 0xFF);
if (cksum != sum) {
--
Grant Edwards
grante@visi.com
next reply other threads:[~2001-04-19 13:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-19 13:19 Grant Edwards [this message]
2001-04-19 13:24 ` [ECOS] " Grant Edwards
2001-04-19 13:37 ` Grant Edwards
2001-04-20 0:11 ` [ECOS] " Jonathan Larmour
2001-04-20 5:40 ` Gary Thomas
2001-04-20 7:31 ` Grant Edwards
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=20010419152033.A29215@visi.com \
--to=grante@visi.com \
--cc=ecos-discuss@sources.redhat.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).