Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SRC OBDH TMTC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Robin Mueller
SRC OBDH TMTC
Commits
c6c7ce2e
Commit
c6c7ce2e
authored
4 years ago
by
Robin Mueller
Browse files
Options
Downloads
Patches
Plain Diff
added little script to write bin size into arm vector
parent
7368edfb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
utility/binary_writer.py
+55
-0
55 additions, 0 deletions
utility/binary_writer.py
with
55 additions
and
0 deletions
utility/binary_writer.py
0 → 100644
+
55
−
0
View file @
c6c7ce2e
import
os
import
struct
from
glob
import
glob
def
main
():
"""
Was written to assign sixth arm vector to binary size for bootloader.
@return:
"""
# Parse for binaries
file_path
=
file_selector
(
"
../../_bin
"
,
'
*.bin
'
)
file_size
=
os
.
path
.
getsize
(
file_path
)
print
(
"
File size:
"
+
str
(
file_size
))
size_uint32
=
struct
.
pack
(
"
<I
"
,
file_size
)
print
(
"
File size as uint32:
"
+
'
'
.
join
(
map
(
'
{:02X}
'
.
format
,
size_uint32
)))
with
open
(
file_path
,
"
rb+
"
)
as
file
:
# Read the first seven ARM vectors. The sixth one will be replaced.
arm_vectors
=
file
.
read
(
4
*
7
)
arm_vector_6
=
arm_vectors
[
5
*
4
:
5
*
4
+
4
]
print
(
"
ARM vectors:
"
)
# print(''.join('{:02x}'.format(x) for x in arm_vectors))
for
x
in
range
(
0
,
28
,
4
):
print
(
'
'
.
join
(
map
(
'
{:02X}
'
.
format
,
arm_vectors
[
x
:
x
+
4
])))
file
.
seek
(
5
*
4
)
file
.
write
(
size_uint32
)
file
.
seek
(
0
)
arm_vectors
=
file
.
read
(
4
*
7
)
print
(
"
New ARM vector:
"
)
for
x
in
range
(
0
,
28
,
4
):
print
(
'
'
.
join
(
map
(
'
{:02X}
'
.
format
,
arm_vectors
[
x
:
x
+
4
])))
pass
def
file_selector
(
path
:
str
,
pattern
:
str
)
->
str
:
result
=
[
y
for
x
in
os
.
walk
(
path
)
for
y
in
glob
(
os
.
path
.
join
(
x
[
0
],
pattern
))]
print
(
"
Files found in _bin folder:
"
)
for
idx
,
path
in
enumerate
(
result
):
print
(
"
Selection
"
+
str
(
idx
)
+
"
:
"
+
str
(
path
))
selection
=
input
(
"
Please enter desired selection [c to cancel]:
"
)
while
True
:
if
selection
==
'
c
'
:
return
""
if
not
selection
.
isdigit
():
selection
=
input
(
"
Invalid input, try again [c to cancel]:
"
)
if
selection
.
isdigit
():
if
int
(
selection
)
<
len
(
result
):
return
result
[
int
(
selection
)]
else
:
selection
=
input
(
"
Invalid input, try again [c to cancel]:
"
)
if
__name__
==
"
__main__
"
:
main
()
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