Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r 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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
flow3r
flow3r firmware
Merge requests
!83
main: automatically update python files
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
main: automatically update python files
q3k/autoupdate
into
main
Overview
0
Commits
1
Pipelines
2
Changes
1
Merged
q3k
requested to merge
q3k/autoupdate
into
main
1 year ago
Overview
0
Commits
1
Pipelines
2
Changes
1
Expand
0
0
Merge request reports
Compare
main
version 1
b11e80cd
1 year ago
main (base)
and
latest version
latest version
f903e55c
1 commit,
1 year ago
version 1
b11e80cd
1 commit,
1 year ago
1 file
+
53
−
8
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
main/fs.c
+
53
−
8
Options
@@ -6,18 +6,33 @@
#include
"st3m_mode.h"
#include
"st3m_sys_data.h"
#include
"st3m_tar.h"
#include
"st3m_version.h"
#include
"esp_system.h"
#include
"esp_vfs.h"
#include
"esp_vfs_fat.h"
static
const
char
*
TAG
=
"st3m-fs"
;
static
bool
_updating
=
false
;
static
const
char
*
sysflag
=
"/flash/sys/.sys-installed"
;
static
void
_extract_callback
(
const
char
*
path
)
{
char
msg
[
256
];
snprintf
(
msg
,
256
,
"Installing %s..."
,
path
);
// Strip /flash/sys/ from displayed paths...
const
char
*
prefix
=
"/flash/sys/"
;
if
(
strstr
(
path
,
prefix
)
==
path
)
{
path
+=
strlen
(
prefix
);
}
if
(
_updating
)
{
snprintf
(
msg
,
256
,
"Updating %s"
,
path
);
}
else
{
snprintf
(
msg
,
256
,
"Installing %s"
,
path
);
}
size_t
limit
=
30
;
if
(
strlen
(
msg
)
>
limit
)
{
strlcpy
(
msg
+
limit
,
"..."
,
256
-
limit
);
}
st3m_mode_set
(
st3m_mode_kind_starting
,
msg
);
}
@@ -37,10 +52,16 @@ static void _extract_sys_data(void) {
FILE
*
f
=
fopen
(
sysflag
,
"w"
);
assert
(
f
!=
NULL
);
fprintf
(
f
,
"
remove me to reinstall /sys on next startup"
);
fprintf
(
f
,
"
%s"
,
st3m_version
);
fclose
(
f
);
}
typedef
enum
{
sys_state_absent
=
0
,
sys_state_diff_version
=
1
,
sys_state_correct
=
2
,
}
sys_state_t
;
void
flow3r_fs_init
(
void
)
{
st3m_fs_init
();
@@ -50,16 +71,40 @@ void flow3r_fs_init(void) {
return
;
}
bool
have_mpy
=
false
;
sys_state_t
state
=
sys_state_absent
;
char
local_version
[
128
];
struct
stat
st
;
if
(
stat
(
sysflag
,
&
st
)
==
0
)
{
have_mpy
=
S_ISREG
(
st
.
st_mode
);
if
(
stat
(
sysflag
,
&
st
)
==
0
&&
S_ISREG
(
st
.
st_mode
))
{
state
=
sys_state_diff_version
;
FILE
*
f
=
fopen
(
sysflag
,
"r"
);
size_t
len
=
fread
(
local_version
,
1
,
sizeof
(
local_version
)
-
1
,
f
);
fclose
(
f
);
local_version
[
len
]
=
0
;
if
(
strcmp
(
st3m_version
,
local_version
)
==
0
)
{
state
=
sys_state_correct
;
}
}
if
(
!
have_mpy
)
{
if
(
state
==
sys_state_absent
)
{
st3m_mode_set
(
st3m_mode_kind_starting
,
"Installing /flash/sys..."
);
ESP_LOGI
(
TAG
,
"No %s on flash, preparing sys directory..."
,
sysflag
);
_updating
=
false
;
ESP_LOGI
(
TAG
,
"Installing /sys/flash... (st3m version: %s, local version: none)"
,
st3m_version
);
_extract_sys_data
();
st3m_mode_set
(
st3m_mode_kind_starting
,
"Installed, continuing startup..."
);
}
if
(
state
==
sys_state_diff_version
)
{
st3m_mode_set
(
st3m_mode_kind_starting
,
"Updating /flash/sys..."
);
_updating
=
true
;
ESP_LOGI
(
TAG
,
"Updating /sys/flash... (st3m version: %s, local version: %s)"
,
st3m_version
,
local_version
);
_extract_sys_data
();
st3m_mode_set
(
st3m_mode_kind_starting
,
"Updated, continuing startup..."
);
}
esp_err_t
ret
=
st3m_fs_sd_mount
();
Loading