Zondax / ledger-oasis

Oasis app for Ledger Nano S and X
Apache License 2.0
3 stars 6 forks source link

Installation on Nano X using installer_s.sh fails #140

Closed valentinbud closed 3 years ago

valentinbud commented 3 years ago

Hello everyone 👋.

I am trying to install the latest v2.3.1 version on a Ledger Nano X from a MacBook.

I have downloaded installer_s.sh from v2.3.1 release page .

I have ran the following

pip3 install ledgerblue

~/Downloads/installer_s.sh load

Generated random root public key : b'046252bed8f7a74f0041a8870a93ed562a13942122dc3dc92d2106feffe11b9e469b70a290dd38c70bbe170e86a73cf05d936b1755869d96644f8a415230a5b3d2'
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.9/site-packages/ledgerblue/loadApp.py", line 204, in <module>
    secret = getDeployedSecretV2(dongle, bytearray.fromhex(args.rootPrivateKey), args.targetId)
  File "/usr/local/lib/python3.9/site-packages/ledgerblue/deployed.py", line 91, in getDeployedSecretV2
    dongle.exchange(apdu)
  File "/usr/local/lib/python3.9/site-packages/ledgerblue/comm.py", line 145, in exchange
    raise CommException("Invalid status %04x (%s)" % (sw, possibleCause), sw, response)
ledgerblue.commException.CommException: Exception : Invalid status 6484 (Are you using the correct targetId?)

The device has an older version of the app already installed, v1.8.2. The firmware is at 1.3.0, latest, as reported by Ledger Live. Development mode is enabled.

The error sounded like the installer doesn't have the correct targetId value setup.

I have found here the following snippet of code to check the id of the device

Python 3.9.7 (default, Sep  3 2021, 12:45:31)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.27.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import binascii
   ...: from ledgerblue.comm import getDongle
   ...: dongle = getDongle(True)
   ...: a = dongle.exchange(bytearray([0xe0, 0x01, 0x00, 0x00, 0x00]))
   ...: print('targetID: 0x' + binascii.hexlify(bytes(a[:4])).decode('ascii'))
HID => e001000000
HID <= 3300000405312e332e30042e00000004322e31329000
targetID: 0x33000004

In [2]: quit 

I have updated the installer_s.sh file with the above targetId value

- LOAD_PARAMS="--tlv --targetId 0x31100004 --targetVersion=2.0.0 --delete --fileName bin/app.hex --appName Oasis --appVersion 2.3.1 --dataSize 8256 --icon 0100000000ffffff00ffffffffffff5ffcaffbaff5d7ebd7ebd7ebd7ebaff5dff53ffaffffffffffff "
+ LOAD_PARAMS="--tlv --targetId 0x33000004 --targetVersion=2.0.0 --delete --fileName bin/app.hex --appName Oasis --appVersion 2.3.1 --dataSize 8256 --icon 0100000000ffffff00ffffffffffff5ffcaffbaff5d7ebd7ebd7ebd7ebaff5dff53ffaffffffffffff "

- DELETE_PARAMS="--targetId 0x31100004 --appName Oasis "
+ DELETE_PARAMS="--targetId 0x33000004 --appName Oasis "

Running the installer again the error changed.

~/Downloads/installer_s.sh load                                                                                                                                    
Generated random root public key : b'04c1c8e49a54e6fee316f42a2b7ae87a2979e6c89ee84c8c7747da62a4af83855d941a26458615dc42b242d48ca025376410107f7ac41f19b7907994a9fefe9a8c'
Using test master key b'04c1c8e49a54e6fee316f42a2b7ae87a2979e6c89ee84c8c7747da62a4af83855d941a26458615dc42b242d48ca025376410107f7ac41f19b7907994a9fefe9a8c'
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.9/site-packages/ledgerblue/loadApp.py", line 204, in <module>
    secret = getDeployedSecretV2(dongle, bytearray.fromhex(args.rootPrivateKey), args.targetId)
  File "/usr/local/lib/python3.9/site-packages/ledgerblue/deployed.py", line 115, in getDeployedSecretV2
    dongle.exchange(apdu)
  File "/usr/local/lib/python3.9/site-packages/ledgerblue/comm.py", line 145, in exchange
    raise CommException("Invalid status %04x (%s)" % (sw, possibleCause), sw, response)
ledgerblue.commException.CommException: Exception : Invalid status 69d5 (Unknown reason)

Am I missing something? What can I do to have the v2.3.1 app installed? Thank you.

jleni commented 3 years ago

Nano X devices are locked and do now allow sideloading. You can only use unreleased firmware in Nano S device and definitely it is only recommended for testing/development purposes.

valentinbud commented 3 years ago

Thank you @jleni for clearing this up for me. I'll wait for the v2.3.1 PR to get merged then.