Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CCS
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marko Mecina
CCS
Commits
3f47512b
Commit
3f47512b
authored
1 month ago
by
Marko Mecina
Browse files
Options
Downloads
Patches
Plain Diff
add utilities for ARIEL ASW on-board image generation
parent
86fd6fff
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Ccs/tools/asw_upload/asw_image_lib_ariel.py
+100
-0
100 additions, 0 deletions
Ccs/tools/asw_upload/asw_image_lib_ariel.py
with
100 additions
and
0 deletions
Ccs/tools/asw_upload/asw_image_lib_ariel.py
0 → 100644
+
100
−
0
View file @
3f47512b
import
crcmod
import
ctypes
HEADER_VERSION
=
0x01
FILLER
=
0x00
N_SECT_HEADERS
=
8
SECTION_HEADER_SIZE
=
16
HEADER_SIZE
=
8
+
N_SECT_HEADERS
*
SECTION_HEADER_SIZE
MEM_MRAM_ID
=
2
MEM_MRAM_START
=
0x10000000
MEM_MRAM_SIZE
=
0x200000
MEM_RAM_ID
=
6
MEM_RAM_START
=
0x40000000
MEM_RAM_SIZE
=
0x1000000
ASW_IMG_OFFSET
=
0x80000
puscrc
=
crcmod
.
predefined
.
mkPredefinedCrcFun
(
'
crc-ccitt-false
'
)
class
SectionHeaderFields
(
ctypes
.
BigEndianStructure
):
_pack_
=
1
_fields_
=
[(
"
TARGET_ADDR
"
,
ctypes
.
c_uint32
),
(
"
SIZE
"
,
ctypes
.
c_uint32
),
(
"
SOURCE_ADDR
"
,
ctypes
.
c_uint32
),
(
"
SOURCE_SECT_ID
"
,
ctypes
.
c_uint8
),
(
"
FILLER
"
,
ctypes
.
c_uint8
),
(
"
CRC16
"
,
ctypes
.
c_uint16
)]
class
ImageHeaderFields
(
ctypes
.
BigEndianStructure
):
_pack_
=
1
_fields_
=
[(
"
HEADER_CRC16
"
,
ctypes
.
c_uint16
),
(
"
HEADER_VERSION
"
,
ctypes
.
c_uint8
),
(
"
FILLER
"
,
ctypes
.
c_uint8
),
(
"
ENTRY_POINT
"
,
ctypes
.
c_uint32
),
(
"
SECTION1
"
,
SectionHeaderFields
),
(
"
SECTION2
"
,
SectionHeaderFields
),
(
"
SECTION3
"
,
SectionHeaderFields
),
(
"
SECTION4
"
,
SectionHeaderFields
),
(
"
SECTION5
"
,
SectionHeaderFields
),
(
"
SECTION6
"
,
SectionHeaderFields
),
(
"
SECTION7
"
,
SectionHeaderFields
),
(
"
SECTION8
"
,
SectionHeaderFields
)]
class
ImageHeader
(
ctypes
.
Union
):
_pack_
=
1
_fields_
=
[(
"
fields
"
,
ImageHeaderFields
),
(
"
bin
"
,
ctypes
.
c_ubyte
*
HEADER_SIZE
)]
def
__init__
(
self
,
memid
,
entrypoint
,
data
,
data_addr_offset
=
HEADER_SIZE
):
super
().
__init__
()
self
.
fields
.
HEADER_VERSION
=
HEADER_VERSION
self
.
fields
.
FILLER
=
FILLER
self
.
fields
.
ENTRY_POINT
=
entrypoint
self
.
set_section
(
1
,
data
,
entrypoint
,
data_addr_offset
,
memid
)
self
.
fields
.
HEADER_CRC16
=
puscrc
(
bytes
(
self
.
bin
[
2
:]))
def
set_section
(
self
,
n
,
data
,
target_addr
,
source_addr
,
memid
):
sect
=
getattr
(
self
.
fields
,
"
SECTION{}
"
.
format
(
n
))
sect
.
TARGET_ADDR
=
target_addr
sect
.
SOURCE_ADDR
=
source_addr
sect
.
SOURCE_SECT_ID
=
memid
# assert len(data) % 4 == 0
sect
.
SIZE
=
len
(
data
)
sect
.
CRC16
=
puscrc
(
data
)
class
AswImage
:
def
__init__
(
self
,
memid
,
entrypoint
,
aswfile
,
skip_bytes
=
0
):
assert
isinstance
(
aswfile
,
str
)
data
=
open
(
aswfile
,
'
rb
'
).
read
()[
skip_bytes
:]
self
.
header
=
ImageHeader
(
memid
,
entrypoint
,
data
)
self
.
data
=
data
@property
def
img
(
self
):
return
bytes
(
self
.
header
)
+
self
.
data
@property
def
size
(
self
):
"""
Total size of ASW image, including header
"""
return
len
(
self
.
img
)
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