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

Clean up tinyprog for releasing #36

Merged
merged 12 commits into from
Jan 17, 2019
Merged

Clean up tinyprog for releasing #36

merged 12 commits into from
Jan 17, 2019

Conversation

mithro
Copy link
Collaborator

@mithro mithro commented Jan 17, 2019

  • Use travis to test tinyprog under support Python versions.
  • Generate the version information from git and upload dev versions to PyPi.
  • Make tinyprog pep8 clean.
  • Adds a --version command line argument.

@mithro
Copy link
Collaborator Author

mithro commented Jan 17, 2019

@ewenmcneill - Please take a look.

@mithro mithro force-pushed the master branch 10 times, most recently from 96cf89f to 506b087 Compare January 17, 2019 07:05
Copy link
Contributor

@ewenmcneill ewenmcneill left a comment

Choose a reason for hiding this comment

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

Other than the comments mentioned, it looks basically okay to me. There's a bunch of code churn but most of it seems to be caused by intentional reformatting. With the TypeError correction, and the formatting string fixups, I'm able to run successfully.

The addition of a --version seems very helpful (although I've not installed your pull request version in a way that works properly for me).

Ewen

(tinyfpga) ewen@parthenon:/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer$ PYTHONPATH=. python3 /src/fpga/litex-buildenv/build/conda/bin/tinyprog --program-image /src/fpga/litex-buildenv/build/tinyfpga_bx_base_lm32.minimal//image-gateware+bios+micropython.bin

    TinyProg CLI
    ------------
    Using device id 1d50:6130
    Only one board with active bootloader, using it.

    Programming /dev/ttyACM0 with /src/fpga/litex-buildenv/build/tinyfpga_bx_base_lm32.minimal//image-gateware+bios+micropython.bin
    Programming at addr 028000
    Waking up SPI flash
    442884 bytes to program
    Programming and Verifying: 100%|█████████| 443k/443k [00:10<00:00, 40.6kB/s]
    Success!

(tinyfpga) ewen@parthenon:/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer$

programmer/tinyprog/__init__.py Show resolved Hide resolved
programmer/tinyprog/__main__.py Show resolved Hide resolved
programmer/tinyprog/__main__.py Show resolved Hide resolved
programmer/tinyprog/__main__.py Show resolved Hide resolved
def boot(self):
try:
self.ser.write(b"\x00")
self.ser.flush()
except:
except Exception:
Copy link
Contributor

Choose a reason for hiding this comment

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

@mithro is writeTimeoutError an exception? I'm both unclear whether that's true, and also on one run I did have programming bail out due to a writeTimeoutError which I hadn't seen happen before.

Ewen


(tinyfpga) ewen@parthenon:/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer$ PYTHONPATH=. python3 /src/fpga/litex-buildenv/build/conda/bin/tinyprog --program-image /src/fpga/litex-buildenv/build/tinyfpga_bx_base_lm32.minimal//image-gateware+bios+micropython.bin

    TinyProg CLI
    ------------
    Using device id 1d50:6130
    Only one board with active bootloader, using it.

    Programming /dev/ttyACM0 with /src/fpga/litex-buildenv/build/tinyfpga_bx_base_lm32.minimal//image-gateware+bios+micropython.bin
    Programming at addr 028000
    Waking up SPI flash
    442884 bytes to program
    Programming and Verifying:   1%|        | 5.63k/443k [00:01<01:31, 4.80kB/s]
Traceback (most recent call last):
  File "/src/fpga/litex-buildenv/build/conda/bin/tinyprog", line 11, in <module>
    sys.exit(main())
  File "/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer/tinyprog/__main__.py", line 455, in main
    if not fpga.program_bitstream(addr, bitstream):
  File "/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer/tinyprog/__init__.py", line 497, in program_bitstream
    return self.program_sectors(addr, bitstream)
  File "/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer/tinyprog/__init__.py", line 441, in program_sectors
    max_length=256)
  File "/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer/tinyprog/__init__.py", line 403, in write
    self._write(addr, write_data)
  File "/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer/tinyprog/__init__.py", line 389, in _write
    self.wait_while_busy()
  File "/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer/tinyprog/__init__.py", line 319, in wait_while_busy
    while to_int(self.read_sts()) & 1:
  File "/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer/tinyprog/__init__.py", line 276, in read_sts
    return self.cmd(0x05, read_len=1)
  File "/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer/tinyprog/__init__.py", line 262, in cmd
    self.ser.write(bytearray(cmd_write_string))
  File "/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer/tinyprog/__init__.py", line 94, in write
    self.ser.write(data)
  File "/src/tinyfpga/tools/lib/python3.5/site-packages/serial/serialposix.py", line 579, in write
    raise writeTimeoutError
serial.serialutil.SerialTimeoutException: Write timeout
(tinyfpga) ewen@parthenon:/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer$ 

Copy link
Contributor

Choose a reason for hiding this comment

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

I can find:

https://chromium.googlesource.com/experimental/chromium/src/+/84aa73c4dd94ac0089a164a7f8e8b1571c7a5eb9/tools/telemetry/third_party/pyserial/serial/serialutil.py#108

which suggests writeTimeoutError is a SerialTimeoutException:

https://chromium.googlesource.com/experimental/chromium/src/+/84aa73c4dd94ac0089a164a7f8e8b1571c7a5eb9/tools/telemetry/third_party/pyserial/serial/serialutil.py#104

which seems to be a SerialError:

https://chromium.googlesource.com/experimental/chromium/src/+/84aa73c4dd94ac0089a164a7f8e8b1571c7a5eb9/tools/telemetry/third_party/pyserial/serial/serialutil.py#100

which seems to be an IOError. Which I think should be an Exception? So I'm a bit unclear what's going on here.

But if it's only writeTimeoutError that's expected, maybe it'd make sense to be more specific? except Exception doesn't seem much more useful than except: pass....

Ewen

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We concluded this was a different path triggering this exception.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(We should probably also be only catching writeTimeoutError here too as you mention.)

@mithro mithro merged commit 19073dd into tinyfpga:master Jan 17, 2019
@ewenmcneill
Copy link
Contributor

@mithro, FTR, the version now in master, with cleanups we went through in person seems to work okay. So I think we just treat it as "merged by having same commits added to master".

Ewen

(tinyfpga) ewen@parthenon:/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer$ PYTHONPATH=. python3 /src/fpga/litex-buildenv/build/conda/bin/tinyprog --program-image /src/fpga/litex-buildenv/build/tinyfpga_bx_base_lm32.minimal//image-gateware+bios+micropython.bin

    TinyProg CLI
    ------------
    Using device id 1d50:6130
    Only one board with active bootloader, using it.

    Programming /dev/ttyACM0 with /src/fpga/litex-buildenv/build/tinyfpga_bx_base_lm32.minimal//image-gateware+bios+micropython.bin
    Programming at addr 028000
    Waking up SPI flash
    442884 bytes to program
    Programming and Verifying: 100%|█████████| 443k/443k [00:10<00:00, 40.6kB/s]
    Success!

(tinyfpga) ewen@parthenon:/src/tinyfpga/packages/TinyFPGA-Bootloader/programmer$

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