Can't create serial port (MacOS) [SOLVED]


#21

I could see it from Windows 10, I was able to flash the new bootloader and load the blink project also. No luck in gentoo yet though.


#22

Ok, I know what’s going on. I updated MacOS on my laptop and it exhibits the same behavior you are seeing. This is new behavior since the update. MacOS is blocking the virtual serial port driver from owning the TinyFPGA BX boot loader.

I have a solution. I can talk to the device directly using pyusb. I’m going to add support into tinyprog to also use pyusb if libusb is installed and working. Stay tuned.

@dugz: This update may also help you as long as you can see the TinyFPGA BX VID:PID in lsusb.

EDIT: This solution has some advantages over using pyserial. If pyusb is reliable, then I can change the boot loader to be a non-standard USB device and have it support Web USB. This means the board could be detected and programmed by a web application if given permission.


#23

Thanks for all your efforts tracking this down!


#24

I have gotten the BX working in gentoo. Firstly make sure you have the kernel driver:

Device Drivers --> USB Support -->
  <M>    USB Modem (CDC ACM) support

Next create a udev rule to assign it to the dialout group

# /etc/udev/rules.d/80-fpga-serial.rules
# Set the group for the device
KERNEL=="ttyACM[0-9]*",GROUP="dialout",MODE="0660"

Finally emerge support utils needed by tinyprog

# emerge sys-apps/init-system-helpers

At this point, you should be able to proceed with the guide.

$ tinyprog -l
    ....
    /dev/ttyACM0: TinyFPGA BX 1.0.0
    UUID: ....
    FPGA: ice40lp8k-cm81

:smiley:


#25

Of course! Here’s some progress on using pyusb and libusb on MacOS:

macbook:programmer lvalenty$ python -m tinyprog -l

    TinyProg CLI
    ------------
    Using device id 1d50:6130
    Please choose a board with the -c or -i option.  Using first board in list.
    Boards with active bootloaders:

        USB 18: TinyFPGA BX 1.0.0
            UUID: 104494e4-59fe-452a-bc14-193264dfeb13
            FPGA: ice40lp8k-cm81

        USB 17: TinyFPGA BX 1.0.0
            UUID: 84afc39e-886f-4919-818f-9b29ea1dc37f
            FPGA: ice40lp8k-cm81

#26

More progress, I should be able to release this later today @hanrahan. I believe it will solve your problem. It seems that all tinyprog functions now work with pyusb if there is no kernel driver attached to the bootloader. If there is a kernel driver attached, then the pyserial backend will work as usual.

I’m able to successfully program the BX on MacOS, but I’m hitting some strange cases. It appears that a driver attaches to the boot loader for a second or so, but is not accessible to the user. I just need a way to make this work while avoiding that corner case in MacOS.

macbook:programmer lvalenty$ python3 -m tinyprog -i 10 -p ~/Downloads/bootloader.bin 

    TinyProg CLI
    ------------
    Using device id 1d50:6130
    Programming USB 6 with /Users/lvalenty/Downloads/bootloader.bin
    Programming at addr 028000
    Waking up SPI flash
    135100 bytes to program
    Erasing: 100%|████████████████████████████| 135k/135k [00:00<00:00, 153kB/s]
    Writing: 100%|████████████████████████████| 135k/135k [00:00<00:00, 184kB/s]
    Reading: 100%|████████████████████████████| 135k/135k [00:00<00:00, 342kB/s]
    Success!

#27

That is great. Let me know if you want me to try it out. I can do it tonight if that would be helpful.


#28

I have a beta release for you to try. Install it with the following pip command:

pip install --upgrade --no-cache-dir tinyprog==1.0.12b1

If you don’t have homebrew, you’ll need to install it:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Once homebrew is installed, you can install libusb:

brew install libusb

Now that’s done, you should be able to see your TinyFPGA BX using tinyprog:

tinyprog -l

See if it needs an update:

tinyprog --update-bootloader

With this fix, you will be able to program the board with tinyprog, but APIO won’t recognize the board. You can build with APIO, but program with tinyprog. I will request that APIO is updated.


Atom, Apio, and TinyFPGA BX tools build error [SOLVED]
Com port does not show up on Win 10 [SOLVED]
#29

If I get a few people to try out this beta testing tinyprog release I’ll be able to make it an official release for everyone.


#30

It doesn’t work for me. I’m running macOS 10.13.6 on a 2016 13" MacBook Pro. In case it makes any difference, the TinyFPGA BX is connected using a USB-C to micro-B cable from Monoprice. libusb 1.0.22 was installed by Homebrew.

tinyprog -l does not show any devices. I did try to push the button on the board.

A 1d60:6130 device appears when I list USB devices in System Information. When I check for cu.* devices in /dev, there are ones for Bluetooth, MALS and SOC. I have no idea what MALS and SOC are but they remain there after I unplug the BX board.

Is there a particular kext I should unload?


#31

This is with the beta tinyprog (1.0.12b1)?


#32

Yes.

(May I suggest adding an argument to display the version number, so I can be 110% sure? But yes.)


#33

Very interesting. Is there any error message or Python traceback printed out? If not, I’ll have to instrument the code with more debug logging to figure out what’s going on.

Run “tinyprog —help” and send me the output. Also run “tinyprog -m —libusb” and send me the output.


#34

Yeah. It works!

I need to explicitly say

tinyprog --libusb -l

#35

This is weird: without apparently changing anything (I don’t think my Mac even went to sleep and the board was plugged in the whole time), it just worked.

(fpga) Guans-MacBook-Pro:~ guan$ tinyprog --libusb -m
[
  {
    "boardmeta": {
      "name": "TinyFPGA BX",
      "fpga": "ice40lp8k-cm81",
      "hver": "1.0.0",
      "uuid": "968ae964-4333-4b12-9a4d-4cb1464c1004"
    },
    "bootmeta": {
      "bootloader": "TinyFPGA USB Bootloader",
      "bver": "1.0.1",
      "update": "https://tinyfpga.com/update/tinyfpga-bx",
      "addrmap": {
        "bootloader": "0x000a0-0x28000",
        "userimage": "0x28000-0x50000",
        "userdata": "0x50000-0x100000"
      }
    },
    "port": "USB 20.7"
  }
> ]

Plain old tinyprog -m also works.


#36

On my MacOS machine, I noticed the OS doing some wierd things with the bootloader device. It appears to first attach a driver, do something, then detach. This process could take several seconds or more.

Going forward, I’m thinking about moving away from the serial device class and advertising the device as a HID device instead. This will give me complete control over the device, however it requires libusb and some other backends to be available on each OS. This move would make the experience smoother on MacOS and Linux. It would also open the door for programming the device directly from a web browser.


#37

I am having problems on MacOS with this too.

The USB device info under profiler sometimes shows:

    Communication Device:

      Product ID: 0x6130
      Vendor ID: 0x1d50
      Speed: Up to 12 Mb/sec
      Location ID: 0x1d100000
      Current Available (mA): 1000
      Extra Operating Current (mA): 0

OR

    Communication Device:

      Product ID: 0x6130
      Vendor ID: 0x1d50
      Version: 0.00
      Location ID: 0x1a200000

OR is sometimes missing.

I have tried using tinyprog 1.0.12b1, but the MacOS usb device issue probably doesn’t give it a chance.

I can’t update the bootloader since tinyprog can’t see the board. Would updating the bootloader using another host OS help?


#38

It looks like your board has the latest bootloader, updating it won’t help.

Did you install libusb? Try plugging in the board, waiting 10 seconds, and running tinyprog -l --libusb. Post the output of that command here.


#39

I do have libusb installed via brew, and I’m getting:

$ tinyprog -l --libusb

TinyProg CLI
------------
Using device id 1d50:6130
No port was specified and no active bootloaders found.
Activate bootloader by pressing the reset button.

and:

$ system_profiler SPUSBDataType
USB:

USB Bus:

  Host Controller Driver: AppleUSBUHCIPCI
  PCI Device ID: 0x2830 
  PCI Revision ID: 0x0003 
  PCI Vendor ID: 0x8086 

    Communication Device:

      Product ID: 0x6130
      Vendor ID: 0x1d50
      Version: 0.00
      Speed: Up to 12 Mb/sec
      Location ID: 0x1d100000 / 2
      Current Available (mA): 1000
      Current Required (mA): 100
      Extra Operating Current (mA): 0

I found a different cable that seems to work better, but tinyprog still doesn’t see it.


#40

Ok, thanks for the info, this is helpful. I’ll have another beta you can try later today.