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
Nikolay Amiantov
firmware
Commits
addcc9f6
Commit
addcc9f6
authored
5 years ago
by
Nikolay Amiantov
Browse files
Options
Downloads
Patches
Plain Diff
Implement reboot-to-bootloader call
Use a special file at filesystem root for that.
parent
795d965c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
bootloader/main.c
+18
-2
18 additions, 2 deletions
bootloader/main.c
epicardium/epicardium.h
+1
-1
1 addition, 1 deletion
epicardium/epicardium.h
epicardium/modules/lifecycle.c
+7
-1
7 additions, 1 deletion
epicardium/modules/lifecycle.c
pycardium/modules/os.c
+8
-3
8 additions, 3 deletions
pycardium/modules/os.c
with
34 additions
and
7 deletions
bootloader/main.c
+
18
−
2
View file @
addcc9f6
...
...
@@ -28,6 +28,10 @@
#define PARTITION_START (0x10000000 + 64 * 1024)
#define PARTITION_END (0x10000000 + 1024 * 1024 - 1)
#define MSC_MAGIC 0x6E697807
/* TODO: Make this address part of the linker script */
void
*
API_CALL_MEM
=
(
void
*
)
0x20080000
;
DIR
dir
;
FATFS
FatFs
;
...
...
@@ -68,6 +72,18 @@ int mount(void)
return
0
;
}
int
get_msc_flag
(
void
)
{
// We use the API call memory to store a magic value there.
uint32_t
*
flag
=
(
uint32_t
*
)
API_CALL_MEM
;
if
(
*
flag
==
MSC_MAGIC
)
{
*
flag
=
0
;
return
1
;
}
else
{
return
0
;
}
}
int
check_integrity
(
void
)
{
FIL
file
;
...
...
@@ -242,8 +258,8 @@ int main(void)
bootloader_display_init
();
// If the button is pressed, we go into MSC mode.
if
(
PB_Get
(
3
))
{
// If the button is pressed
or a flag in memory is detected
, we go into MSC mode.
if
(
PB_Get
(
3
)
||
get_msc_flag
()
)
{
msc
();
}
...
...
This diff is collapsed.
Click to expand it.
epicardium/epicardium.h
+
1
−
1
View file @
addcc9f6
...
...
@@ -242,7 +242,7 @@ API(API_SYSTEM_EXEC, int __epic_exec(char *name));
/**
* Reset/Restart card10
*/
API
(
API_SYSTEM_RESET
,
void
epic_system_reset
(
void
));
API
(
API_SYSTEM_RESET
,
void
epic_system_reset
(
int
to_bootloader
));
/**
* PMIC API
...
...
This diff is collapsed.
Click to expand it.
epicardium/modules/lifecycle.c
+
7
−
1
View file @
addcc9f6
...
...
@@ -17,6 +17,8 @@
#define PYCARDIUM_IVT (void *)0x10080000
#define BLOCK_WAIT pdMS_TO_TICKS(1000)
#define MSC_MAGIC 0x6E697807
/*
* Loading an empty filename into Pycardium will drop straight into the
* interpreter. This define is used to make it more clear when we intend
...
...
@@ -282,8 +284,12 @@ static void load_menu(bool reset)
/*
* Restart the firmware
*/
void
epic_system_reset
(
void
)
void
epic_system_reset
(
int
to_bootloader
)
{
// Set a flag for the bootloader.
uint32_t
*
flag
=
(
uint32_t
*
)
API_CALL_MEM
;
*
flag
=
to_bootloader
?
MSC_MAGIC
:
0
;
card10_reset
();
}
...
...
This diff is collapsed.
Click to expand it.
pycardium/modules/os.c
+
8
−
3
View file @
addcc9f6
...
...
@@ -77,14 +77,19 @@ static mp_obj_t mp_os_exec(mp_obj_t name_in)
}
static
MP_DEFINE_CONST_FUN_OBJ_1
(
exec_obj
,
mp_os_exec
);
static
mp_obj_t
mp_os_reset
(
void
)
static
mp_obj_t
mp_os_reset
(
size_t
n_args
,
const
mp_obj_t
*
args
)
{
epic_system_reset
();
int
bootloader_mode
=
0
;
if
(
n_args
==
1
)
{
bootloader_mode
=
mp_obj_get_int
(
args
[
0
]);
}
epic_system_reset
(
bootloader_mode
);
/* unreachable */
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_
0
(
reset_obj
,
mp_os_reset
);
static
MP_DEFINE_CONST_FUN_OBJ_
VAR_BETWEEN
(
reset_obj
,
0
,
1
,
mp_os_reset
);
static
mp_obj_t
mp_os_listdir
(
mp_obj_t
py_path
)
{
...
...
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