Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marek
firmware
Commits
352b5a97
Verified
Commit
352b5a97
authored
5 years ago
by
rahix
Browse files
Options
Downloads
Patches
Plain Diff
chore(bootloader): Move all display code into main()
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
384fcfb1
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
bootloader/main.c
+24
-16
24 additions, 16 deletions
bootloader/main.c
with
24 additions
and
16 deletions
bootloader/main.c
+
24
−
16
View file @
352b5a97
...
...
@@ -20,6 +20,7 @@
#include
<stddef.h>
#include
<stdio.h>
#include
<string.h>
#include
<errno.h>
#define GPIO_PORT_IN PORT_1
#define GPIO_PIN_IN PIN_6
...
...
@@ -30,25 +31,25 @@
DIR
dir
;
FATFS
FatFs
;
bool
mount
(
void
)
int
mount
(
void
)
{
FRESULT
res
;
res
=
f_mount
(
&
FatFs
,
"/"
,
0
);
if
(
res
!=
FR_OK
)
{
printf
(
"f_mount error %d
\n
"
,
res
);
return
false
;
return
-
1
;
}
res
=
f_opendir
(
&
dir
,
"0:"
);
if
(
res
!=
FR_OK
)
{
printf
(
"f_opendir error %d
\n
"
,
res
);
return
false
;
return
-
1
;
}
return
true
;
return
0
;
}
bool
check_integrity
(
void
)
int
check_integrity
(
void
)
{
FIL
file
;
UINT
readbytes
;
...
...
@@ -58,9 +59,8 @@ bool check_integrity(void)
res
=
f_open
(
&
file
,
filename
,
FA_OPEN_EXISTING
|
FA_READ
);
if
(
res
!=
FR_OK
)
{
bootloader_display_line
(
2
,
"card10.bin not found"
,
0xffff
);
printf
(
"f_open error %d
\n
"
,
res
);
return
false
;
return
-
ENOENT
;
}
uint16_t
crcval
=
0
;
...
...
@@ -76,13 +76,12 @@ bool check_integrity(void)
f_close
(
&
file
);
if
(
crcval
==
0
)
{
return
true
;
}
else
{
bootloader_display_line
(
2
,
"Integrity check failed"
,
0xffff
);
if
(
crcval
!=
0
)
{
printf
(
"CRC check failed. Final CRC: %d
\n
"
,
crcval
);
return
false
;
return
-
EINVAL
;
}
return
0
;
}
bool
is_update_needed
(
void
)
...
...
@@ -221,8 +220,19 @@ int main(void)
;
}
if
(
mount
())
{
if
(
check_integrity
())
{
if
(
mount
()
==
0
)
{
int
res
=
check_integrity
();
if
(
res
==
-
ENOENT
)
{
printf
(
"card10.bin not found!
\n
"
);
bootloader_display_line
(
2
,
"card10.bin not found"
,
0xffff
);
}
else
if
(
res
==
-
EINVAL
)
{
printf
(
"card10.bin CRC is invalid!
\n
"
);
bootloader_display_line
(
2
,
"Integrity check failed"
,
0xffff
);
}
else
if
(
res
==
0
)
{
printf
(
"Found valid application image
\n
"
);
if
(
is_update_needed
())
{
printf
(
"Trying to update firmware from external flash
\n
"
);
...
...
@@ -234,8 +244,6 @@ int main(void)
}
else
{
printf
(
"No update needed
\n
"
);
}
}
else
{
printf
(
"Integrity check failed
\n
"
);
}
}
else
{
bootloader_display_line
(
...
...
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