Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
iopupgrade
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IOPSYS
iopupgrade
Commits
d55c74de
Commit
d55c74de
authored
6 years ago
by
Kenneth Johansson
Browse files
Options
Downloads
Patches
Plain Diff
generalize header matching.
This matches any header not just the board name.
parent
31de0014
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+2
-2
2 additions, 2 deletions
README.md
src/board.c
+102
-24
102 additions, 24 deletions
src/board.c
with
104 additions
and
26 deletions
README.md
+
2
−
2
View file @
d55c74de
...
@@ -28,7 +28,7 @@ calls iopupgrade.
...
@@ -28,7 +28,7 @@ calls iopupgrade.
./iopupgrade [OPTION]..
./iopupgrade [OPTION]..
Options:
Options:
-f, --file=NAME image file to use. If not specified stdin is used.
-f, --file=NAME image file to use. If not specified stdin is used.
-
b
, --
board=name name of the board
-
M
, --
match=key=val,.... image headers needs to have this value
-q, --force do not do board name check
-q, --force do not do board name check
-u, --ubivol=NAME UBI volume device file to write rootfs to.
-u, --ubivol=NAME UBI volume device file to write rootfs to.
-U, --ubifs=NAME Extract ubifs image to file.
-U, --ubifs=NAME Extract ubifs image to file.
...
@@ -54,7 +54,7 @@ Options:
...
@@ -54,7 +54,7 @@ Options:
|----|-------|
|----|-------|
|Help|
`iopupgrade -h`
|
|Help|
`iopupgrade -h`
|
|Print headers|
`iopupgrade -f last.y3 -p`
|
|Print headers|
`iopupgrade -f last.y3 -p`
|
|match board name|
`iopupgrade -f last.y3 -M "board=DG400,dsl=A" `
|
### Broadcom target related examples ###
### Broadcom target related examples ###
|task|command|
|task|command|
...
...
This diff is collapsed.
Click to expand it.
src/board.c
+
102
−
24
View file @
d55c74de
...
@@ -27,41 +27,119 @@
...
@@ -27,41 +27,119 @@
#include
"consumer.h"
#include
"consumer.h"
#include
"cmd.h"
#include
"cmd.h"
static
char
*
board
;
static
int
force
;
static
int
force
;
#define MAX_KEYS 20
static
char
*
key_name
[
MAX_KEYS
];
static
char
*
key_value
[
MAX_KEYS
];
static
int
keys
;
static
int
init
(
struct
img_header
*
hdr
)
static
int
init
(
struct
img_header
*
hdr
)
{
{
char
*
p
;
char
*
p
;
int
index
;
/* skip snity check ? */
/* skip snity check ? */
if
(
force
)
return
0
;
if
(
force
)
return
0
;
if
(
!
board
){
/* Loop over all headers and compare values */
fprintf
(
stderr
,
"Board name needs to be given with -b or to skip test give -q (unsafe)
\n
"
);
for
(
index
=
0
;
index
<
keys
;
index
++
)
{
exit
(
EXIT_FAILURE
);
p
=
get_str_val
(
hdr
,
key_name
[
index
]);
if
(
p
==
NULL
){
fprintf
(
stderr
,
"Could not find header [%s] in y3 image
\n
"
,
key_name
[
index
]);
fprintf
(
stderr
,
"To skip test give -q (unsafe)
\n
"
);
exit
(
EXIT_FAILURE
);
}
if
(
strcmp
(
p
,
key_value
[
index
])){
fprintf
(
stderr
,
"Wrong value of header [%s] in y3 image, got [%s] wanted [%s]
\n
"
,
key_name
[
index
],
p
,
key_value
[
index
]);
fprintf
(
stderr
,
"To skip test give -q (unsafe)
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
return
0
;
}
static
void
usage
(
void
)
{
printf
(
" -M, --match=key=val,.... image headers needs to have this value
\n
"
);
printf
(
" -q, --force
\t
do not do header check
\n
"
);
}
static
void
parse_match
(
char
*
s
)
{
int
tot_len
=
strlen
(
s
);
int
index
=
0
;
char
*
p
=
s
,
tmp
;
/* find number of keys = 1 + number of , chars in string */
keys
=
1
;
for
(
int
i
=
0
;
i
<
tot_len
;
i
++
){
if
(
','
==
s
[
i
]
)
keys
++
;
}
}
p
=
get_str_val
(
hdr
,
"board"
);
if
(
keys
>
MAX_KEYS
)
{
fprintf
(
stderr
,
"To many header values to match, max %d allowed wanted %d
\n
"
,
MAX_KEYS
,
keys
);
exit
(
EXIT_FAILURE
);
}
if
(
p
)
{
while
(
1
){
if
(
0
==
strncmp
(
p
,
board
,
strlen
(
board
))){
char
*
e
;
return
0
;
char
*
c
;
}
else
{
fprintf
(
stderr
,
"Board header not matching board name
\n
"
);
/* copy key to index */
fprintf
(
stderr
,
"header [%s] but wanted [%s]
\n
"
,
p
,
board
);
e
=
strstr
(
p
,
"="
);
c
=
strstr
(
p
,
","
);
if
(
e
==
NULL
)
{
if
(
c
)
{
fprintf
(
stderr
,
"Header match error: expected = found , instread
\n
"
);
goto
error_print
;
}
else
break
;
fprintf
(
stderr
,
"Header match error: expected = found end of string
\n
"
);
goto
error_print
;
}
else
if
(
c
!=
NULL
&&
e
>
c
)
{
fprintf
(
stderr
,
"Header match error: Found , before = . missing a = ??
\n
"
);
goto
error_print
;
}
}
}
else
tmp
=*
e
;
*
e
=
0
;
fprintf
(
stderr
,
"Board header not found in image data. Aborting!
\n
"
);
key_name
[
index
]
=
strdup
(
p
);
*
e
=
tmp
;
exit
(
EXIT_FAILURE
);
/* copy value */
return
1
;
p
=
e
+
1
;
}
e
=
strstr
(
p
,
"="
);
c
=
strstr
(
p
,
","
);
static
void
usage
(
void
)
/* last value ?*/
{
if
(
c
==
NULL
)
{
printf
(
" -b, --board=name
\t
name of the board
\n
"
);
key_value
[
index
]
=
strdup
(
p
);
printf
(
" -q, --force
\t
do not do board name check
\n
"
);
index
++
;
break
;
}
tmp
=*
c
;
*
c
=
0
;
key_value
[
index
]
=
strdup
(
p
);
*
c
=
tmp
;
p
=
c
+
1
;
index
++
;
}
keys
=
index
;
#if 0
for (int i=0; i<keys;i++){
printf("%s=%s\n",key_name[i],key_value[i]);
}
#endif
return
;
error_print:
fprintf
(
stderr
,
"Trying to parse string [%s]
\n
"
,
s
);
exit
(
EXIT_FAILURE
);
}
}
static
void
opt
(
int
argc
,
char
**
argv
)
static
void
opt
(
int
argc
,
char
**
argv
)
...
@@ -71,19 +149,19 @@ static void opt( int argc, char **argv)
...
@@ -71,19 +149,19 @@ static void opt( int argc, char **argv)
while
(
1
)
{
while
(
1
)
{
int
option_index
=
0
;
int
option_index
=
0
;
static
struct
option
long_options
[]
=
{
static
struct
option
long_options
[]
=
{
{
"
board
"
,
required_argument
,
0
,
'
b
'
},
{
"
match
"
,
required_argument
,
0
,
'
M
'
},
{
"force"
,
no_argument
,
0
,
'q'
},
{
"force"
,
no_argument
,
0
,
'q'
},
{
0
,
0
,
0
,
0
}
{
0
,
0
,
0
,
0
}
};
};
ch
=
getopt_long
(
argc
,
argv
,
"
b
:q"
,
ch
=
getopt_long
(
argc
,
argv
,
"
M
:q"
,
long_options
,
&
option_index
);
long_options
,
&
option_index
);
if
(
ch
==
-
1
)
if
(
ch
==
-
1
)
break
;
break
;
switch
(
ch
)
{
switch
(
ch
)
{
case
'
b
'
:
case
'
M
'
:
board
=
optarg
;
parse_match
(
optarg
)
;
break
;
break
;
case
'q'
:
case
'q'
:
force
=
1
;
force
=
1
;
...
...
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