Skip to content

Update micropython to 1.28 - #7316

Open
mmilata wants to merge 22 commits into
mainfrom
mmilata/micropython-1.28.0
Open

Update micropython to 1.28#7316
mmilata wants to merge 22 commits into
mainfrom
mmilata/micropython-1.28.0

Conversation

@mmilata

@mmilata mmilata commented Jul 16, 2026

Copy link
Copy Markdown
Member

Fixes #2990. Submodule update: trezor/micropython#31.

Major changes

  • hexlify/unhexlify is deprecated, use bytes.hex()/bytes.fromhex() instead.
  • MicroPython now supports t-strings, a generalizations of f-strings. The support is currently turned off to save flash.
  • Some MicroPython modules got u prefix removed from their name to match the CPython name.
  • MicroPython has now internal filesystem mount table (VFS), and due to how we use it frozen emulator can't open files.
  • mp_obj_type_t representation 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 is FullType instead of Type.
  • GC root pointers are now collected at build time in a similar way to qstrings and compressed text.
  • Frozen module size improvements (py: add a mp_raw_code_truncated_t struct to reduce size of frozen code micropython/micropython#13628). Can be further improved by disabling qstr hashing, see below.

Missing

Flash utilization

  • PYOPT=1
  • default MICROPY_QSTR_BYTES_IN_HASH, i.e. 2 for main, 1 for 1.28.0
model KiB main KiB 1.28.0 KiB avail 1.28.0 - main 1.28.0/main
T2B1 1350.8 1311.7 1664 -39.1 -2.9 %
T2T1 1509.5 1467.9 1664 -41.6 -2.8 %
T3B1 1372.0 1333.0 1664 -39.0 -2.8 %
T3T1 1539.5 1499.5 1664 -40.0 -2.6 %
T3W1 2262.5 2220.5 3336 -42.0 -1.9 %

MICROPY_QSTR_BYTES_IN_HASH

We might reclaim another 8KiB of flash by setting MICROPY_QSTR_BYTES_IN_HASH to 0 but it makes dict lookups slightly slower. Qstr hash() 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#12835

Using value 1 (new micropython default) causes UI diffs in share word confirmation and is the reason for 82eaaf9.

  • PYOPT=1
  • main uses 2, default for 1.28.0 is val=1
  • val=0 times from this workflow run
x T2B1 T2T1 T3T1 T3W1
KiB main 1509.5 1539.5 2262.5
KiB val=2 1476.5 1506.0 2229.5
KiB val=1 1467.9 1497.5 2220.5
KiB val=0 1458.8 1488.5 2211.5
cihw uni main 2h41m 3h29m
cihw uni val=0 2h46m 3h32m
cihw btc main 58m 1h15m 1h32m
cihw btc val=0 59m 1h16m 1h33m

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 218 files, which is 68 over the limit of 150.

To get a review, narrow the scope:
• coderabbit review --committed # exclude uncommitted changes
• coderabbit review --dir # limit to a subdirectory
• coderabbit review --base # compare against a closer base

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5c18e558-6a63-4f1e-b847-ca82c5126f33

📥 Commits

Reviewing files that changed from the base of the PR and between e6859ec and 8e17b86.

⛔ Files ignored due to path filters (7)
  • core/mocks/generated/timeq.pyi is excluded by !**/generated/**
  • core/mocks/generated/ubinascii.pyi is excluded by !**/generated/**
  • core/mocks/generated/uio.pyi is excluded by !**/generated/**
  • core/mocks/generated/uos.pyi is excluded by !**/generated/**
  • core/mocks/generated/ustruct.pyi is excluded by !**/generated/**
  • core/mocks/generated/utimeq.pyi is excluded by !**/generated/**
  • core/mocks/generated/vfs.pyi is excluded by !**/generated/**
📒 Files selected for processing (222)
  • core/SConscript.firmware
  • core/SConscript.unix
  • core/embed/projects/firmware/main.c
  • core/embed/projects/firmware/mpconfigport.h
  • core/embed/projects/firmware/mphalport.c
  • core/embed/projects/firmware/nlrthumb.c
  • core/embed/projects/unix/main.c
  • core/embed/projects/unix/mpconfigport.h
  • core/embed/rust/build.rs
  • core/embed/rust/librust.h
  • core/embed/rust/micropython.h
  • core/embed/rust/src/micropython/exception.rs
  • core/embed/rust/src/micropython/macros.rs
  • core/embed/rust/src/micropython/simple_type.rs
  • core/embed/rust/src/micropython/typ.rs
  • core/embed/rust/src/protobuf/obj.rs
  • core/embed/rust/src/thp/micropython.rs
  • core/embed/rust/src/translations/obj.rs
  • core/embed/rust/src/trezorhal/ble/micropython.rs
  • core/embed/rust/src/trezorhal/uzlib.rs
  • core/embed/rust/src/ui/backlight.rs
  • core/embed/rust/src/ui/geometry.rs
  • core/embed/rust/src/ui/layout/base.rs
  • core/embed/rust/src/ui/layout/device_menu_result.rs
  • core/embed/rust/src/ui/layout/obj.rs
  • core/embed/rust/src/ui/layout/result.rs
  • core/embed/rust/src/ui/notification.rs
  • core/embed/sec/image/stm32/boot_image.c
  • core/embed/upymod/bindgen-static.c
  • core/embed/upymod/build.rs
  • core/embed/upymod/modtimeq.c
  • core/embed/upymod/modtrezorapp/modtrezorapp-image.h
  • core/embed/upymod/modtrezorapp/modtrezorapp-task.h
  • core/embed/upymod/modtrezorapp/modtrezorapp.c
  • core/embed/upymod/modtrezorconfig/modtrezorconfig.c
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-aes.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-aesgcm.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bech32.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bip32.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bip340.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-bip39.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake256.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2b.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-blake2s.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-cardano.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-chacha20poly1305.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-crc.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-curve25519.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-ed25519.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-elligator2.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-groestl.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-hmac.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-mcu.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-monero.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-nem.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-nist256p1.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-optiga.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-random.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-ripemd160.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-secp256k1.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha1.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha256.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha3-256.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha3-512.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-sha512.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-shamir.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-slip39.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto-tropic.h
  • core/embed/upymod/modtrezorcrypto/modtrezorcrypto.c
  • core/embed/upymod/modtrezorio/modtrezorio-fatfs.h
  • core/embed/upymod/modtrezorio/modtrezorio-haptic.h
  • core/embed/upymod/modtrezorio/modtrezorio-ipc.h
  • core/embed/upymod/modtrezorio/modtrezorio-pm.h
  • core/embed/upymod/modtrezorio/modtrezorio-poll.h
  • core/embed/upymod/modtrezorio/modtrezorio-rgb_led.h
  • core/embed/upymod/modtrezorio/modtrezorio-sdcard.h
  • core/embed/upymod/modtrezorio/modtrezorio-touch.h
  • core/embed/upymod/modtrezorio/modtrezorio-usb-if.h
  • core/embed/upymod/modtrezorio/modtrezorio-usb.h
  • core/embed/upymod/modtrezorio/modtrezorio.c
  • core/embed/upymod/modtrezorui/modtrezorui-display.h
  • core/embed/upymod/modtrezorui/modtrezorui.c
  • core/embed/upymod/modtrezorutils/modtrezorutils-meminfo.h
  • core/embed/upymod/modtrezorutils/modtrezorutils.c
  • core/embed/upymod/modutime.c
  • core/embed/upymod/mpycross_include/mpconfigport.h
  • core/embed/upymod/trezorobj.h
  • core/mocks/timeq.pyi
  • core/mocks/ubinascii.pyi
  • core/mocks/uio.pyi
  • core/mocks/uos.pyi
  • core/mocks/ustruct.pyi
  • core/mocks/vfs.pyi
  • core/site_scons/site_tools/micropython/__init__.py
  • core/src/apps/bitcoin/sign_tx/layout.py
  • core/src/apps/bitcoin/sign_tx/omni.py
  • core/src/apps/bitcoin/sign_tx/zcash_v4.py
  • core/src/apps/cardano/get_public_key.py
  • core/src/apps/common/cbor.py
  • core/src/apps/common/signverify.py
  • core/src/apps/ethereum/clear_signing.py
  • core/src/apps/ethereum/get_public_key.py
  • core/src/apps/ethereum/helpers.py
  • core/src/apps/ethereum/layout.py
  • core/src/apps/ethereum/sc_constants.py.mako
  • core/src/apps/ethereum/staking.py
  • core/src/apps/management/reboot_to_bootloader.py
  • core/src/apps/management/reset_device/layout.py
  • core/src/apps/misc/sign_identity.py
  • core/src/apps/nostr/sign_event.py
  • core/src/apps/stellar/helpers.py
  • core/src/apps/stellar/layout.py
  • core/src/apps/stellar/operations/layout.py
  • core/src/apps/stellar/sign_tx.py
  • core/src/apps/tron/sc_constants.py
  • core/src/apps/webauthn/credential.py
  • core/src/apps/webauthn/fido2.py
  • core/src/prof/__main__.py
  • core/src/storage/device.py
  • core/src/trezor/crypto/base32.py
  • core/src/trezor/loop.py
  • core/src/trezor/utils.py
  • core/src/trezor/wire/codec/codec_v1.py
  • core/src/trezor/wire/thp/memory_manager.py
  • core/src/trezor/wire/thp/pairing_context.py
  • core/tests/common.py
  • core/tests/ethereum_common.py
  • core/tests/test_apps.bitcoin.address.py
  • core/tests/test_apps.bitcoin.address_grs.py
  • core/tests/test_apps.bitcoin.change_detector.py
  • core/tests/test_apps.bitcoin.ownership_proof.py
  • core/tests/test_apps.bitcoin.segwit.bip143.native_p2wpkh.py
  • core/tests/test_apps.bitcoin.segwit.bip143.p2wpkh_in_p2sh.py
  • core/tests/test_apps.bitcoin.segwit.bip341.p2tr.py
  • core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh.py
  • core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh_grs.py
  • core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh.py
  • core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh_grs.py
  • core/tests/test_apps.bitcoin.sign_tx.writers.py
  • core/tests/test_apps.bitcoin.signtx.fee_threshold.py
  • core/tests/test_apps.bitcoin.signtx.omni.py
  • core/tests/test_apps.bitcoin.signtx.py
  • core/tests/test_apps.bitcoin.signtx_decred.py
  • core/tests/test_apps.bitcoin.signtx_grs.py
  • core/tests/test_apps.bitcoin.txweight.py
  • core/tests/test_apps.bitcoin.zcash.zip243.py
  • core/tests/test_apps.cardano.address.py
  • core/tests/test_apps.cardano.certificate.py
  • core/tests/test_apps.cardano.get_public_key.py
  • core/tests/test_apps.cardano.native_script.py
  • core/tests/test_apps.cardano.seed.py
  • core/tests/test_apps.cardano.utils.py
  • core/tests/test_apps.common.cbor.py
  • core/tests/test_apps.common.payment_request.py
  • core/tests/test_apps.common.seed.py
  • core/tests/test_apps.eos.get_public_key.py
  • core/tests/test_apps.ethereum.clear_signing.py
  • core/tests/test_apps.ethereum.clear_signing_definitions.py
  • core/tests/test_apps.ethereum.helpers.py
  • core/tests/test_apps.ethereum.yielding.py
  • core/tests/test_apps.ethereum.yielding_vaults.py
  • core/tests/test_apps.evolu.check_evolu.py
  • core/tests/test_apps.monero.bulletproof.py
  • core/tests/test_apps.monero.clsag.py
  • core/tests/test_apps.monero.crypto.py
  • core/tests/test_apps.monero.proto.py
  • core/tests/test_apps.nem.address.py
  • core/tests/test_apps.nem.hdnode.py
  • core/tests/test_apps.nem.mosaic_creation.py
  • core/tests/test_apps.nem.mosaic_supply_change.py
  • core/tests/test_apps.nem.multisig.aggregate_modification.py
  • core/tests/test_apps.nem.multisig.py
  • core/tests/test_apps.nem.namespace.py
  • core/tests/test_apps.nem.transfer.py
  • core/tests/test_apps.ripple.address.py
  • core/tests/test_apps.ripple.serializer.py
  • core/tests/test_apps.solana.offchain_message.py
  • core/tests/test_apps.stellar.address.py
  • core/tests/test_apps.stellar.writers.py
  • core/tests/test_apps.tezos.address.py
  • core/tests/test_apps.tezos.encode.py
  • core/tests/test_apps.tron.address.py
  • core/tests/test_apps.webauthn.credential.py
  • core/tests/test_apps.zcash.f4jumble.py
  • core/tests/test_apps.zcash.unified_addresses.py
  • core/tests/test_apps.zcash.zip244.py
  • core/tests/test_trezor.crypto.aes.py
  • core/tests/test_trezor.crypto.aesgcm.py
  • core/tests/test_trezor.crypto.base58.py
  • core/tests/test_trezor.crypto.bech32.py
  • core/tests/test_trezor.crypto.bip32.py
  • core/tests/test_trezor.crypto.bip39.py
  • core/tests/test_trezor.crypto.chacha20poly1305.py
  • core/tests/test_trezor.crypto.crc.py
  • core/tests/test_trezor.crypto.curve.bip340.py
  • core/tests/test_trezor.crypto.curve.curve25519.py
  • core/tests/test_trezor.crypto.curve.ed25519.py
  • core/tests/test_trezor.crypto.curve.nist256p1.py
  • core/tests/test_trezor.crypto.curve.secp256k1.py
  • core/tests/test_trezor.crypto.der.py
  • core/tests/test_trezor.crypto.elligator2.py
  • core/tests/test_trezor.crypto.hashlib.blake256.py
  • core/tests/test_trezor.crypto.hashlib.blake2b.py
  • core/tests/test_trezor.crypto.hashlib.blake2s.py
  • core/tests/test_trezor.crypto.hashlib.groestl512.py
  • core/tests/test_trezor.crypto.hashlib.ripemd160.py
  • core/tests/test_trezor.crypto.hashlib.sha1.py
  • core/tests/test_trezor.crypto.hashlib.sha256.py
  • core/tests/test_trezor.crypto.hashlib.sha3_256.py
  • core/tests/test_trezor.crypto.hashlib.sha3_512.py
  • core/tests/test_trezor.crypto.hashlib.sha512.py
  • core/tests/test_trezor.crypto.hmac.py
  • core/tests/test_trezor.crypto.pbkdf2.py
  • core/tests/test_trezor.crypto.random.py
  • core/tests/test_trezor.crypto.rlp.py
  • core/tests/test_trezor.crypto.slip39.py
  • core/tests/test_trezor.wire.codec.codec_v1.py
  • core/tests/test_trezor.wire.thp.cpace.py
  • pyproject.toml
  • tests/ui_tests/fixtures.json
  • vendor/micropython

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mmilata/micropython-1.28.0

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@trezor-bot trezor-bot Bot added this to Firmware Jul 16, 2026
@github-project-automation github-project-automation Bot moved this to 🔎 Needs review in Firmware Jul 16, 2026
@mmilata mmilata added core Trezor Core firmware. Runs on Trezor Model T and Safe models. micropython Python interpreter and runtime that runs Trezor firmware code Code improvements flash reduction Decrease required size of flash labels Jul 16, 2026
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

en main(all)

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

Comment thread core/tests/test_apps.nem.transfer.py Outdated
"8d07f90fb4bbe7715fa327c926770166a11be2e494a970605f2e12557f66c9b9"
),
bytearray("Good luck!"),
bytes("Good luck!", "utf-8"),

@matejcik matejcik Jul 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not bytes(b"Good luck!") actually just b"Good luck!" ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brain cells ran out

thanks, a350185

@mmilata
mmilata force-pushed the mmilata/micropython-1.28.0 branch 5 times, most recently from 63b5e71 to 8f2db8e Compare July 17, 2026 15:05
@mmilata
mmilata marked this pull request as ready for review July 17, 2026 15:47
@mmilata

mmilata commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

@matejcik can you please review refactor(core/rust): update obj_type! for slots-based mp_obj_type_t (cbe789a)?

@cepetr can you please review refactor(core): micropython-1.28.0 embedded fixups (186c8e0)?

@mmilata
mmilata requested a review from romanz July 17, 2026 15:49
@andrewkozlik
andrewkozlik removed their request for review July 19, 2026 10:01
@obrusvit obrusvit added the blocked Blocked by external force. Third party inputs required. label Jul 22, 2026
@obrusvit

Copy link
Copy Markdown
Contributor

Let's postpone merging until after the Freeze for 26.08.

@romanz romanz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed some commits, will continue tomorrow.

Comment thread core/SConscript.firmware Outdated

dump_value(out, type->parent);
dump_value(out, type->locals_dict);
// XXX 3ac8b5851e5f4dade465d52b91ed2ccc17851263 #7542

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is/was the issue here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The representation of mp_obj_type_t changed. Currently the entirely meminfo is broken, haven't tried to port it yet.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, more binascii-related calls were added meanwhile in main :(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix after rebasing, let's keep this unresolved until then.

Comment thread core/embed/upymod/modtimeq.c Outdated
Comment thread core/embed/upymod/modtimeq.c
Comment thread core/embed/upymod/modtrezorcrypto/modtrezorcrypto-monero.h Outdated
Comment thread core/embed/upymod/build.rs Outdated
Comment thread core/embed/upymod/mpycross_include/mpconfigport.h
Comment thread core/embed/upymod/mpycross_include/mpconfigport.h

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with finishing porting this feature in a separate PR.

@romanz

This comment was marked as outdated.

@matejcik matejcik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

mmilata added 21 commits July 30, 2026 10:14
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]
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]
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]
@mmilata
mmilata force-pushed the mmilata/micropython-1.28.0 branch from 8620d51 to 6318781 Compare July 30, 2026 09:29
Comment thread core/embed/upymod/build.rs
@@ -29,6 +29,9 @@ async def _confirm_word(

# remove duplicates
non_duplicates = list(set(share_words))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:


Is it intended?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")

trezor/trezor-core@34322d5

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I haven't understand this change...

Why do we need to define mp_obj_list_get__extern()?
Is it being called elsewhere?

@mmilata mmilata Jul 31, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
}

@romanz

romanz commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

BTW, meminfo uses >6kB of flash - I am fine with excluding it from default builds:

$ arm-none-eabi-nm -C --size-sort core/build-xtask/artifacts/T3T1/firmware.elf -t dec \ 
  | grep meminfo | awk '{s+=$1} END {print s}'
6208

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked Blocked by external force. Third party inputs required. code Code improvements core Trezor Core firmware. Runs on Trezor Model T and Safe models. flash reduction Decrease required size of flash micropython Python interpreter and runtime that runs Trezor firmware

Projects

Status: 🔎 Needs review

Development

Successfully merging this pull request may close these issues.

Upgrade to micropython 1.28.0

4 participants