[SOLVED]Irregular flash error


#1

Hi,

I tried flashing the example picosoc project from https://github.com/tinyfpga/TinyFPGA-BX/ but firmware flashing is failing irregularly.

tinyprog -p hardware.bin -u firmware.bin

    TinyProg CLI
    ------------
    Using device id 1d50:6130
    Only one board with active bootloader, using it.
    Programming /dev/ttyACM0 with hardware.bin
    Programming at addr 028000
    Waking up SPI flash
    135100 bytes to program
    Programming and Verifying:  30%|███       | 41.0k/135k [00:02<00:04, 19.6kB/s]
Traceback (most recent call last):
  File "/home/aj/.local/bin/tinyprog", line 11, in <module>
    sys.exit(main())
  File "/home/aj/.local/lib/python2.7/site-packages/tinyprog/__main__.py", line 348, in main
    if not fpga.program_bitstream(addr, bitstream):
  File "/home/aj/.local/lib/python2.7/site-packages/tinyprog/__init__.py", line 460, in program_bitstream
    return self.program_sectors(addr, bitstream)
  File "/home/aj/.local/lib/python2.7/site-packages/tinyprog/__init__.py", line 402, in program_sectors
    self.erase(current_addr, sector_size, disable_progress=True)
  File "/home/aj/.local/lib/python2.7/site-packages/tinyprog/__init__.py", line 353, in erase
    self._erase(addr, erase_length)
  File "/home/aj/.local/lib/python2.7/site-packages/tinyprog/__init__.py", line 307, in _erase
    self.wait_while_busy()
  File "/home/aj/.local/lib/python2.7/site-packages/tinyprog/__init__.py", line 296, in wait_while_busy
    while to_int(self.read_sts()) & 1:
  File "/home/aj/.local/lib/python2.7/site-packages/tinyprog/__init__.py", line 27, in to_int
    return int(value)
ValueError: invalid literal for int() with base 10: ''
make: *** [Makefile:3: upload] Error 1

Sometimes it fails earlier, sometimes later. I tried with a different cable, but the issue persists! Any pointers?


#2

Make sure modem manager is disabled…what OS are you running?


#3

Thank you for the respose @lukevalenty

mmcli -L says there are no modems connected. I am on Ubuntu 18.10. Besides, I have the following udev rule active:

# Disable ModemManager for BlackIce
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", ENV{ID_MM_DEVICE_IGNORE}="1"
# Disable ModemManager for TinyFPGA B2
ATTRS{idVendor}=="1209", ATTRS{idProduct}=="2100", ENV{ID_MM_DEVICE_IGNORE}="1"
# Disable ModemManager for TinyFPGA BX
ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="6130", ENV{ID_MM_DEVICE_IGNORE}="1"

Do I need any other changes?


#4
aj@ubaura:~$ inotifywait -m /dev/ttyACM0
Setting up watches.
Watches established.
/dev/ttyACM0 MODIFY 
/dev/ttyACM0 MODIFY 
/dev/ttyACM0 MODIFY 
/dev/ttyACM0 MODIFY 
/dev/ttyACM0 MODIFY 
/dev/ttyACM0 MODIFY 
/dev/ttyACM0 CLOSE_WRITE,CLOSE 
/dev/ttyACM0 OPEN 
/dev/ttyACM0 MODIFY 
/dev/ttyACM0 CLOSE_WRITE,CLOSE 
/dev/ttyACM0 ATTRIB 
/dev/ttyACM0 DELETE_SELF

I have this in my dmesg:

[13841.288683] cdc_acm 3-2:1.0: ttyACM0: USB ACM device
[13852.870852] usb 3-2: USB disconnect, device number 22
[13852.870971] cdc_acm 3-2:1.0: failed to set dtr/rts

How can I figure who is trying to set dtr/rts ? This happened just after plugging in the device, and I did not try to program it. I have to tinyprog -l multiple times to get it to read actual information about the device connected.


#5

I tried auditctl: sudo auditctl -w /dev/ttyACM0 -p warx and it says:

aj@ubaura:~$ sudo ausearch -f /dev/ttyACM0  | more
----
time->Wed Feb 27 13:10:17 2019
type=CONFIG_CHANGE msg=audit(1551253217.970:24): auid=4294967295 ses=4294967295 op=updated_rules path="/dev/ttyACM0" key=(null) list=4 r
es=1
----
time->Wed Feb 27 13:10:18 2019
type=PROCTITLE msg=audit(1551253218.498:25): proctitle="/lib/systemd/systemd-udevd"
type=PATH msg=audit(1551253218.498:25): item=0 name="/dev/ttyACM0" inode=633 dev=00:06 mode=020600 ouid=0 ogid=0 rdev=a6:00 nametype=NOR
MAL cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1551253218.498:25): cwd="/"
type=SYSCALL msg=audit(1551253218.498:25): arch=c000003e syscall=90 success=yes exit=0 a0=55a0469e2230 a1=21b0 a2=30 a3=5a0 items=1 ppid
=384 pid=3612 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="systemd-udevd" exe
="/lib/systemd/systemd-udevd" subj==unconfined key=(null)
----
time->Wed Feb 27 13:10:18 2019
type=PROCTITLE msg=audit(1551253218.498:26): proctitle="/lib/systemd/systemd-udevd"
type=PATH msg=audit(1551253218.498:26): item=0 name="/dev/ttyACM0" inode=633 dev=00:06 mode=020660 ouid=0 ogid=0 rdev=a6:00 nametype=NOR
MAL cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1551253218.498:26): cwd="/"
type=SYSCALL msg=audit(1551253218.498:26): arch=c000003e syscall=92 success=yes exit=0 a0=55a0469e2230 a1=0 a2=14 a3=5a0 items=1 ppid=38
4 pid=3612 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="systemd-udevd" exe="/
lib/systemd/systemd-udevd" subj==unconfined key=(null)
----
time->Wed Feb 27 13:10:29 2019
type=CONFIG_CHANGE msg=audit(1551253229.183:41): auid=4294967295 ses=4294967295 op=updated_rules path="/dev/ttyACM0" key=(null) list=4 r
es=1

So looks like systemd-udevd is doing something, but I do not recognize what its trying to do.


#6

Hi,

the answer is 99% of the time the modem manager and sometimes the ups daemon. Plug in de device and run lsof /dev/ttyACM0

This modem manager has had this problem for years (it tries to probe random serial devices to discover modems) doing that it also toggles the dtr lines. Other devices like arduino’s or the beaglebone have been bitten by it.


#7

@keesj Yeap modemmanager was the culprit. I removed it and I can flash with no issues! Thank you so much!