Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lufa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Erik Strand
lufa
Commits
2e7fc37a
Commit
2e7fc37a
authored
12 years ago
by
Dean Camera
Browse files
Options
Downloads
Patches
Plain Diff
Fix incorrect HEX extended address parsing in the Printer class bootloader.
parent
d999ca8f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Bootloaders/Printer/BootloaderPrinter.c
+19
-4
19 additions, 4 deletions
Bootloaders/Printer/BootloaderPrinter.c
with
19 additions
and
4 deletions
Bootloaders/Printer/BootloaderPrinter.c
+
19
−
4
View file @
2e7fc37a
...
@@ -59,6 +59,8 @@ struct
...
@@ -59,6 +59,8 @@ struct
uint8_t
Checksum
;
uint8_t
Checksum
;
/** Starting address of the last addressed FLASH page. */
/** Starting address of the last addressed FLASH page. */
uint32_t
PageStartAddress
;
uint32_t
PageStartAddress
;
/** Current 32-bit byte extended base address in FLASH being targeted. */
uint32_t
CurrBaseAddress
;
/** Current 32-bit byte address in FLASH being targeted. */
/** Current 32-bit byte address in FLASH being targeted. */
uint32_t
CurrAddress
;
uint32_t
CurrAddress
;
}
HEXParser
=
}
HEXParser
=
...
@@ -117,7 +119,7 @@ static void ParseIntelHEXByte(const char ReadCharacter)
...
@@ -117,7 +119,7 @@ static void ParseIntelHEXByte(const char ReadCharacter)
if
((
HEXParser
.
ParserState
==
HEX_PARSE_STATE_WAIT_LINE
)
||
(
ReadCharacter
==
':'
))
if
((
HEXParser
.
ParserState
==
HEX_PARSE_STATE_WAIT_LINE
)
||
(
ReadCharacter
==
':'
))
{
{
HEXParser
.
Checksum
=
0
;
HEXParser
.
Checksum
=
0
;
HEXParser
.
CurrAddress
&
=
~
0xFFFF
;
HEXParser
.
CurrAddress
=
HEXParser
.
CurrBaseAddress
;
HEXParser
.
ParserState
=
HEX_PARSE_STATE_WAIT_LINE
;
HEXParser
.
ParserState
=
HEX_PARSE_STATE_WAIT_LINE
;
HEXParser
.
ReadMSB
=
false
;
HEXParser
.
ReadMSB
=
false
;
...
@@ -154,12 +156,12 @@ static void ParseIntelHEXByte(const char ReadCharacter)
...
@@ -154,12 +156,12 @@ static void ParseIntelHEXByte(const char ReadCharacter)
break
;
break
;
case
HEX_PARSE_STATE_ADDRESS_HIGH
:
case
HEX_PARSE_STATE_ADDRESS_HIGH
:
HEXParser
.
CurrAddress
|
=
((
uint16_t
)
HEXParser
.
Data
<<
8
);
HEXParser
.
CurrAddress
+
=
((
uint16_t
)
HEXParser
.
Data
<<
8
);
HEXParser
.
ParserState
=
HEX_PARSE_STATE_ADDRESS_LOW
;
HEXParser
.
ParserState
=
HEX_PARSE_STATE_ADDRESS_LOW
;
break
;
break
;
case
HEX_PARSE_STATE_ADDRESS_LOW
:
case
HEX_PARSE_STATE_ADDRESS_LOW
:
HEXParser
.
CurrAddress
|
=
HEXParser
.
Data
;
HEXParser
.
CurrAddress
+
=
HEXParser
.
Data
;
HEXParser
.
ParserState
=
HEX_PARSE_STATE_RECORD_TYPE
;
HEXParser
.
ParserState
=
HEX_PARSE_STATE_RECORD_TYPE
;
break
;
break
;
...
@@ -172,6 +174,14 @@ static void ParseIntelHEXByte(const char ReadCharacter)
...
@@ -172,6 +174,14 @@ static void ParseIntelHEXByte(const char ReadCharacter)
/* Track the number of read data bytes in the record */
/* Track the number of read data bytes in the record */
HEXParser
.
DataRem
--
;
HEXParser
.
DataRem
--
;
/* Protect the bootloader against being written to */
if
(
HEXParser
.
CurrAddress
>=
BOOT_START_ADDR
)
{
HEXParser
.
ParserState
=
HEX_PARSE_STATE_WAIT_LINE
;
PageDirty
=
false
;
return
;
}
/* Wait for a machine word (two bytes) of data to be read */
/* Wait for a machine word (two bytes) of data to be read */
if
(
HEXParser
.
DataRem
&
0x01
)
if
(
HEXParser
.
DataRem
&
0x01
)
{
{
...
@@ -210,9 +220,14 @@ static void ParseIntelHEXByte(const char ReadCharacter)
...
@@ -210,9 +220,14 @@ static void ParseIntelHEXByte(const char ReadCharacter)
}
}
break
;
break
;
case
HEX_RECORD_TYPE_ExtendedSegmentAddress
:
/* Extended address data - store the upper 12-bits of the new address */
HEXParser
.
CurrBaseAddress
=
(((
uint32_t
)
HEXParser
.
PrevData
<<
8
)
|
HEXParser
.
Data
)
<<
4
;
break
;
case
HEX_RECORD_TYPE_ExtendedLinearAddress
:
case
HEX_RECORD_TYPE_ExtendedLinearAddress
:
/* Extended address data - store the upper 16-bits of the new address */
/* Extended address data - store the upper 16-bits of the new address */
HEXParser
.
CurrAddress
|
=
(
uint32_t
)
HEXParser
.
Data
<<
(
HEXParser
.
Data
Rem
?
24
:
16
)
;
HEXParser
.
Curr
Base
Address
=
((
(
uint32_t
)
HEXParser
.
Prev
Data
<<
8
)
|
HEXParser
.
Data
)
<<
16
;
break
;
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment