diff --git a/extmod/modtrezorconfig/norcow_config.h b/extmod/modtrezorconfig/norcow_config.h index dd08076802..74e19ffc45 100644 --- a/extmod/modtrezorconfig/norcow_config.h +++ b/extmod/modtrezorconfig/norcow_config.h @@ -2,9 +2,3 @@ #define NORCOW_UNIX 1 #define NORCOW_FILE "/var/tmp/trezor.config" #endif - -#ifdef STM32_HAL_H -// TODO: switch to native implementation when finished -#define NORCOW_UNIX 1 -#define NORCOW_FILE "/sd/trezor.config" -#endif diff --git a/src/trezor/config.py b/src/trezor/config.py index 471f64435e..1db7ad0593 100644 --- a/src/trezor/config.py +++ b/src/trezor/config.py @@ -1,6 +1,10 @@ -from TrezorConfig import Config - -_config = Config() +import sys +if sys.platform in ['trezor', 'pyboard']: # stmhal + from config_mock import Config + _config = Config('/sd/trezor.config') +else: + from TrezorConfig import Config + _config = Config() def get(app, key, default=None): v = _config.get(app, key) diff --git a/src/trezor/config_mock.py b/src/trezor/config_mock.py new file mode 100644 index 0000000000..06b32891c7 --- /dev/null +++ b/src/trezor/config_mock.py @@ -0,0 +1,37 @@ +# mock implementation using binary file + +import ustruct + +def Config(): + + def __init__(self, filename): + self._data = {} + self._file = filename + try: + with open(self._file, 'rb') as f: + while True: + d = f.read(4) + if len(d) != 4: + break + k, l = ustruct.unpack('