Update micropython to 1.28 - #7316
Conversation
|
Important Review skippedToo many files! This PR contains 218 files, which is 68 over the limit of 150. To get a review, narrow the scope: Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (7)
📒 Files selected for processing (222)
You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| model | device_test | click_test | persistence_test |
|---|---|---|---|
| T2T1 | test(all) main(all) ![]() |
test(all) main(all) ![]() |
test(all) main(all) ![]() |
| T3B1 | test(all) main(all) ![]() |
test(all) main(all) ![]() |
test(all) main(all) ![]() |
| T3T1 | test(all) main(all) ![]() |
test(all) main(all) ![]() |
test(all) main(all) ![]() |
| T3W1 | test(all) main(all) ![]() |
test(all) main(all) ![]() |
test(all) main(all) ![]() |
Latest CI run: 30587619974
| "8d07f90fb4bbe7715fa327c926770166a11be2e494a970605f2e12557f66c9b9" | ||
| ), | ||
| bytearray("Good luck!"), | ||
| bytes("Good luck!", "utf-8"), |
There was a problem hiding this comment.
why not actually just bytes(b"Good luck!")b"Good luck!" ?
63b5e71 to
8f2db8e
Compare
|
Let's postpone merging until after the Freeze for |
romanz
left a comment
There was a problem hiding this comment.
Reviewed some commits, will continue tomorrow.
|
|
||
| dump_value(out, type->parent); | ||
| dump_value(out, type->locals_dict); | ||
| // XXX 3ac8b5851e5f4dade465d52b91ed2ccc17851263 #7542 |
There was a problem hiding this comment.
What is/was the issue here?
There was a problem hiding this comment.
The representation of mp_obj_type_t changed. Currently the entirely meminfo is broken, haven't tried to port it yet.
There was a problem hiding this comment.
Unfortunately, more binascii-related calls were added meanwhile in main :(
There was a problem hiding this comment.
Will fix after rebasing, let's keep this unresolved until then.
There was a problem hiding this comment.
I'm fine with finishing porting this feature in a separate PR.
This comment was marked as outdated.
This comment was marked as outdated.
matejcik
left a comment
There was a problem hiding this comment.
FullType related changes LGTM
for the record i'll be adding #!feature(const_traits) anyway for qstrs so we can leverage it for types too. but there are gonna be subsequent PRs for that
Relevant micropython commits: 28aaab95909aab092cc8c16188fec157142f18a9 py/objstr: Add hex/fromhex to bytes/memoryview/bytearray. [no changelog]
It is no longer part of micropython. Relevant micropython commits: a1fbb1980cf90cc58186eac9cc405a97ebd41e64 extmod/modtimeq: Remove timeq module. [no changelog]
E.g. uos was renamed to os, uerrno to errno. Relevant micropython commits: 45ac651d1a2801bccbdc32fddaa9b029ed4ce879 all: Rename *umodule*.c to remove the "u" prefix. f5f9edf6457624bf32e71b0c2fdcfbfa5d5753a6 all: Rename UMODULE to MODULE in preprocessor/Makefile vars. [no changelog]
Relevant micropython commits: 995555300181b3385855f5a4ffb629441553d3ea extmod/modutime: Provide a generic time module. df05caea6c6437a8b4756ec502a5e6210f4b6256 shared/timeutils: Standardize supported date range on all platforms. [no changelog]
Relevant micropython commits: 289b2dd87960a4cdf019013cecd489f0d0cabc26 py/objstr: Add new mp_obj_new_str_from_cstr() helper function. [no changelog]
The str variant now also does UTF-8 validation which can be removed to improve performance where justified. Relevant micropython commits: 0b9ee86133a2a0524691c6cdac209dbfcb3bf116 py: Add mp_obj_new_str_from_vstr, and use it where relevant. 88864587f5af292d7f86aceb6bf40e8331e9a8d6 py/objstr: Always ensure mp_obj_str_from_vstr is unicode-safe. [no changelog]
Relevant micropython commits: 971617196644775905fd821c39c6a7771b63dbaf py/misc: Remove m_new_obj[_var]_with_finaliser macros. [no changelog]
Relevant micropython commits: 3ac8b5851e5f4dade465d52b91ed2ccc17851263 py/obj: Add slot-index mp_obj_type_t representation. cb0ffdd2bf25dcac3c230bdc1168d492aabaf573 py/obj: Remove basic mp_obj_type_t sparse representation. [no changelog]
Relevant micropython commits: 3ac8b5851e5f4dade465d52b91ed2ccc17851263 py/obj: Add slot-index mp_obj_type_t representation. cb0ffdd2bf25dcac3c230bdc1168d492aabaf573 py/obj: Remove basic mp_obj_type_t sparse representation. [no changelog]
…unctions [no changelog]
Relevant micropython changes: c2b8e6e5d685ce0ef7cd7186f326cac8a39eb2a3 lib/uzlib: Clean up tinf -> uzlib rename. e6c290c3d145de81e23f406c84359860c4d6e632 lib/uzlib: Add a source_read_data var to pass to source_read_cb. Needs trezor-specific patch. [no changelog]
Relevant micropython changes: decf8e6a8bb940d5829ca3296790631fcece7b21 all: Remove the "STATIC" macro and just use "static" instead. [no changelog]
The file is now be quite similar to the upstream one to make future updates easier. Notable differences include: - entry point is `coreapp_emu()` instead of `main()` - different command line handling that loads `main` if no module or command is provided - no filesystem access for frozen emulator to prevent it from loading live modules - no default sys.path [no changelog]
Relevant micropython commits: b2e82402688b53829f37475583231b067b9faea7 py/mkrules.mk: Keep all build artefacts inside $(BUILD) directory. 47c84286e8c8d9873e99f12711a683ecd6b9ca62 all: Fix paths to mpy-cross and micropython binaries. [no changelog]
Relevant micropython commits: fc3d7ae11be11a7f05709ebfd439061fce9ee555 py/make_root_pointers: Add MP_REGISTER_ROOT_POINTER parser/generator. 7e4b205cb00013b272e4cf9fac128866bf0e1f21 py/mpstate: Drop MICROPY_PORT_ROOT_POINTERS from mp_state_vm_t. [no changelog]
[no changelog]
Relevant micropython commits: 908ab1ceca15ee6fd0ef82ca4cba770a3ec41894 py/objint: Fix int.to_bytes() buffer size checks. 86f2c285eb222f30c24df187ac66d3e0c80caf61 py: Add new cstack API for stack checking, with limit margin macro. c046b23ea29e0183c899a8dbe1da3bed3440a255 shared/runtime/pyexec: Don't allow Ctrl+C to interrupt frozen boot code. 3bca93b2d00dec37b3770c3e4fac15f07e0b9f15 ports: Fix sys.stdout.buffer.write() return value. 2c8dab7ab4ec0884c6428afc613d9dcc322d8c6d py/objarray: Detect bytearray(str) without an encoding. [no changelog]
Relevant micropython commits: 2c828a88153dfdbd767fc0d8f2124cfbefdcbc81 unix: Update port to use the new event functions. 2757acf6ed1fe165e4d8aa72ba8090fb9bc60c31 py/nlr: Implement jump callbacks. 3446d440f661cf3c052c08e5c6879b1e59a478bb shared/runtime/gchelper: Drop cpu directive from ARM asm helpers. [no changelog]
8620d51 to
6318781
Compare
[no changelog]
| @@ -29,6 +29,9 @@ async def _confirm_word( | |||
|
|
|||
| # remove duplicates | |||
| non_duplicates = list(set(share_words)) | |||
There was a problem hiding this comment.
nit: maybe always use sorted()?
non_duplicates = sorted(set(share_words))| *top = (*top)->prev; | ||
| } | ||
|
|
||
| void nlr_push_jump_callback(nlr_jump_callback_node_t *node, nlr_jump_callback_fun_t fun) { |
There was a problem hiding this comment.
It seems to be vendored from here:
https://github.com/micropython/micropython/blob/e0e9fbb17ed6fd06bb76e266ae554784c9c80804/py/nlr.c#L53-L67
We use this file on emulator, but not on firmware:
trezor-firmware/core/embed/upymod/build.rs
Line 246 in 8e17b86
Is it intended?
There was a problem hiding this comment.
I think the reason we have our own copy of nlrthumb.c is the stack protector, otherwise the logic appears identical.
#pragma GCC optimize("no-stack-protector")
I suppose we can use a compiler attribute in build.rs together with the micropython version if that's preferable?
|
|
||
| // Static wrappers | ||
|
|
||
| void mp_obj_list_get__extern(mp_obj_t self_in, size_t *len, mp_obj_t **items) { |
There was a problem hiding this comment.
Sorry, I haven't understand this change...
Why do we need to define mp_obj_list_get__extern()?
Is it being called elsewhere?
There was a problem hiding this comment.
It's because mp_obj_list_get is header-only static inline function, after we compile micropython it's invisible from the outside and rust code cannot link to it. These wrappers are not static and can be used through the rust bindings generated in micropython.rs:
unsafe extern "C" {
#[link_name = "mp_obj_list_get__extern"]
pub fn mp_obj_list_get(self_in: mp_obj_t, len: *mut usize, items: *mut *mut mp_obj_t);
}|
BTW, |




































Fixes #2990. Submodule update: trezor/micropython#31.
Major changes
hexlify/unhexlifyis deprecated, usebytes.hex()/bytes.fromhex()instead.uprefix removed from their name to match the CPython name.mp_obj_type_trepresentation changed, this also prompted some changes on Rust side. As that struct now has variable size, whenever we construct a new type object, the return type isFullTypeinstead ofType.Missing
Flash utilization
PYOPT=1MICROPY_QSTR_BYTES_IN_HASH, i.e. 2 formain, 1 for 1.28.0main1.28.0-main1.28.0/mainMICROPY_QSTR_BYTES_IN_HASH
We might reclaim another 8KiB of flash by setting
MICROPY_QSTR_BYTES_IN_HASHto0but it makes dict lookups slightly slower. Qstrhash()values are precomputed during freezing, the setting determines size of each hash or can be 0 to disable precomputation. We have about 5000 qstrings, not quite sure how this becomes 8KiB. Micropython PR: micropython/micropython#12835Using value
1(new micropython default) causes UI diffs in share word confirmation and is the reason for 82eaaf9.PYOPT=1mainuses2, default for 1.28.0 is val=10times from this workflow runmain210main0main0