Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable binascii in microbit_v2 build #5925

Merged
merged 2 commits into from
Jan 25, 2022
Merged

enable binascii in microbit_v2 build #5925

merged 2 commits into from
Jan 25, 2022

Conversation

jerryneedell
Copy link
Collaborator

@jerryneedell jerryneedell commented Jan 25, 2022

ampy and rshell both import ubinascii when reading files from a device.
I modified ampy to import binascii if ubinascii is not avaliable

py$ diff files.py files.py.save 
62,65c62
<             try:
<                 import ubinascii
<             except:
<                 import binascii as ubinascii
---
>             import ubinascii
110c107
<                 try:
---
>                 try:        

This PR enables binascii in the microbit_v2 build so it is possible to use ampy ( and possible rshell with a similar fix)
I have tested this with a microbit_v2 and my modified ampy and it is working

prior to this PR, a "get" failed with

jerryneedell@jerryneedell-ubuntu-macmini:~/projects/microbit_v2$ ampy  get code.py
Traceback (most recent call last):
  File "/home/jerryneedell/.local/bin/ampy", line 8, in <module>
    sys.exit(cli())
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/ampy/cli.py", line 126, in get
    contents = board_files.get(remote_file)
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/ampy/files.py", line 85, in get
    raise ex
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/ampy/files.py", line 77, in get
    out = self._pyboard.exec_(textwrap.dedent(command))
  File "/home/jerryneedell/.local/lib/python3.8/site-packages/ampy/pyboard.py", line 279, in exec_
    raise PyboardError('exception', ret, ret_err)
ampy.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\n  File "<stdin>", line 6, in <module>\r\nImportError: no module named \'binascii\'\r\n')

with binascii enabled

jerryneedell@jerryneedell-ubuntu-macmini:~/projects/microbit_v2$ ampy  get code.py
print("Hello World!")

I plan to submit a PR to ampy to to implement the changes I had to make to use it.

@jerryneedell jerryneedell requested a review from tannewt January 25, 2022 21:17
Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Thanks! One style change, and we'll need to see if it fits.

ports/nrf/boards/microbit_v2/mpconfigboard.mk Outdated Show resolved Hide resolved
Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

👍

@dhalbert dhalbert merged commit 3904421 into adafruit:main Jan 25, 2022
@jerryneedell jerryneedell deleted the jerryn_microbitv2 branch January 25, 2022 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants