Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
6a11048a
Commit
6a11048a
authored
8 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py/persistentcode: Bump .mpy version due to change in bytecode.
parent
c2644147
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/persistentcode.c
+8
-5
8 additions, 5 deletions
py/persistentcode.c
tools/mpy-tool.py
+3
-2
3 additions, 2 deletions
tools/mpy-tool.py
with
11 additions
and
7 deletions
py/persistentcode.c
+
8
−
5
View file @
6a11048a
...
...
@@ -38,6 +38,9 @@
#include
"py/smallint.h"
// The current version of .mpy files
#define MPY_VERSION (1)
// The feature flags byte encodes the compile-time config options that
// affect the generate bytecode.
#define MPY_FEATURE_FLAGS ( \
...
...
@@ -209,10 +212,10 @@ STATIC mp_raw_code_t *load_raw_code(mp_reader_t *reader) {
mp_raw_code_t
*
mp_raw_code_load
(
mp_reader_t
*
reader
)
{
byte
header
[
4
];
read_bytes
(
reader
,
header
,
sizeof
(
header
));
if
(
strncmp
((
char
*
)
header
,
"M
\x00
"
,
2
)
!=
0
)
{
mp_raise_ValueError
(
"invalid .mpy file"
);
}
if
(
header
[
2
]
!=
MPY_FEATURE_FLAGS
||
header
[
3
]
>
mp_small_int_bits
())
{
if
(
header
[
0
]
!=
'M'
||
header
[
1
]
!=
MPY_VERSION
||
header
[
2
]
!=
MPY_FEATURE_FLAGS
||
header
[
3
]
>
mp_small_int_bits
())
{
mp_raise_ValueError
(
"incompatible .mpy file"
);
}
mp_raw_code_t
*
rc
=
load_raw_code
(
reader
);
...
...
@@ -359,7 +362,7 @@ void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print) {
// byte version
// byte feature flags
// byte number of bits in a small int
byte
header
[
4
]
=
{
'M'
,
0
,
MPY_FEATURE_FLAGS_DYNAMIC
,
byte
header
[
4
]
=
{
'M'
,
MPY_VERSION
,
MPY_FEATURE_FLAGS_DYNAMIC
,
#if MICROPY_DYNAMIC_COMPILER
mp_dynamic_compiler
.
small_int_bits
,
#else
...
...
This diff is collapsed.
Click to expand it.
tools/mpy-tool.py
+
3
−
2
View file @
6a11048a
...
...
@@ -57,6 +57,7 @@ class FreezeError(Exception):
return
'
error while freezing %s: %s
'
%
(
self
.
rawcode
.
source_file
,
self
.
msg
)
class
Config
:
MPY_VERSION
=
1
MICROPY_LONGINT_IMPL_NONE
=
0
MICROPY_LONGINT_IMPL_LONGLONG
=
1
MICROPY_LONGINT_IMPL_MPZ
=
2
...
...
@@ -438,8 +439,8 @@ def read_mpy(filename):
header
=
bytes_cons
(
f
.
read
(
4
))
if
header
[
0
]
!=
ord
(
'
M
'
):
raise
Exception
(
'
not a valid .mpy file
'
)
if
header
[
1
]
!=
0
:
raise
Exception
(
'
incompatible version
'
)
if
header
[
1
]
!=
config
.
MPY_VERSION
:
raise
Exception
(
'
incompatible
.mpy
version
'
)
feature_flags
=
header
[
2
]
config
.
MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
=
(
feature_flags
&
1
)
!=
0
config
.
MICROPY_PY_BUILTINS_STR_UNICODE
=
(
feature_flags
&
2
)
!=
0
...
...
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