1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[solved] mimas v2 programming in linux...

Discussion in 'FPGA Boards' started by joefitz, Mar 31, 2015.

  1. joefitz

    joefitz New Member

    Joined:
    Mar 30, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    Hello. I've got a mimas v2 and an elbert v2.
    The elbertv2 works fine with the python loader here: http://svn.numato.cc/svn/numatocc/FPGA/ElbertV2Spartan3ADev/trunk/tools/configuration/python/
    The mimasv2 does not work with the python script. It errors on "Unable to read SPI flash ID".

    I thought the script might be intended for the mimas v1, but I examined the code and see there are no substantial differences between the mimas and elbert python scripts. Both the elbertv2 and mimasv2 work fine with the windows config executable. In fact, both the mimas and the elbert work fine with either config utility - there doesn't seem to be any checks either way - so i can only assume the microcontroller firmware is similar if not identical across the two.

    I connected a logic analyser to the spi flash to watch the process - on the mimas v2 there is not spi flash activity at all, while on the elbert i can see the '0x9f' id code and response. While programmming the mimas v2 in windows, the logic analyser shows the '0x9f' plus the "0x20 0x20 0x15" response on the mimas v2.

    Is there any change necessary to mimasconfig.py to support the v2? Since flashreadid9fh() is the first call that actually expects a response from the board - perhaps it's something as simple as setting the right baud rate? It'd be great to get that info without having to reverse the windows app or sniff usb traffic....


    thanks,
    -joe
     
  2. admin

    admin Administrator Staff Member

    Joined:
    Jan 23, 2015
    Messages:
    169
    Likes Received:
    11
    Trophy Points:
    18
    Hello Joe,

    As you have noticed, Elbert V2, Mimas V1 and Mimas V2 uses the exact same configuration circuit with very minor modifications in the controller firmware. The Elbert V2 Python configuration script should work with Mimas V2 with minor modifications or no modifications at all. I will take a look at the script and see if I can fix it to work with Mimas V2. Will post updates in next couple of days.

    Thanks,
    Tom
    Numato Lab
     
  3. admin

    admin Administrator Staff Member

    Joined:
    Jan 23, 2015
    Messages:
    169
    Likes Received:
    11
    Trophy Points:
    18
  4. joefitz

    joefitz New Member

    Joined:
    Mar 30, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    Thanks for looking into it tom. I figured i should ask before i dive any deeper.
    The mimas v2 script didn't work for me in linux, so i installed python in a windows vm. It worked just fine. so:

    elbert v2: works with python3 linux, python3 windowns, and windows app.
    mimas v2: works with python3 windows and windows app. does NOT work with python3 linux

    This would lead me to think it's a software issue on my linux system, but I've scoured and the devices look identical in linux. there's no difference in the two devices, except the product id (1000 vs 1002). Permissions are the same, running as root makes no difference. I tested on a second linux box (ubuntu 12.04, vs 14.10 i was using previously) with the exact same exact results.

    I'm happy to dig deeper, but it'd be really helpful to know if another mimasv2 has the same issue or if i have a unique hardware/software issue....
     
  5. admin

    admin Administrator Staff Member

    Joined:
    Jan 23, 2015
    Messages:
    169
    Likes Received:
    11
    Trophy Points:
    18
    Both Elbert V2 and Mimas V2 scripts are essentially same in terms of how it works. btw, what is the error/behavior you are seeing while running Mimas V2 script ?
     
  6. joefitz

    joefitz New Member

    Joined:
    Mar 30, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    like this:
    Code:
    -->python3 MimasV2Config.py /dev/ttyACM0 mimasv2topmodulelx9.bin
    ****************************************
    * Numato Lab Mimas V2 Configuration Tool *
    ****************************************
    Unable to read SPI Flash ID
    -->cd ../../../../../ElbertV2Spartan3ADev/trunk/tools/configuration/python/
    -->python3 elbertconfig.py /dev/ttyACM0 elbertv2.bin
    ****************************************
    * Numato Lab Elbert Configuration Tool *
    ****************************************
    Micron M25P16 SPI Flash detected
    Loading file elbertv2.bin...
    Erasing flash sectors...
    Writing to flash 100% complete...
    Verifying flash contents...
    Flash verification successful...
    Booting FPGA...
    Done.
    -->
    Could someone just test a different mimasv2 board in linux so we can know if my board has a unique issue or not?
     
  7. cyrozap

    cyrozap Moderator

    Joined:
    Apr 12, 2015
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    I'm using Arch Linux (64-bit) with Python 3.4.3 and this is what I get when I run the program:

    Code:
    ****************************************
    * Numato Lab Mimas V2 Configuration Tool *
    ****************************************
    Traceback (most recent call last):
      File "MimasV2Config.py", line 531, in <module>
        main()
      File "MimasV2Config.py", line 527, in main
        MimasV2configObj.ConfigureMimasV2(sys.argv[2])
      File "MimasV2Config.py", line 434, in ConfigureMimasV2
        id = self.FlashReadID9Fh()
      File "MimasV2Config.py", line 249, in FlashReadID9Fh
        idTuple = struct.unpack("L", string + b'\x00')
    struct.error: unpack requires a bytes object of length 8
    Printing "string" returns this three-byte string: b' \x15'

    To fix this error, I changed line 249 to be:
    Code:
    idTuple = struct.unpack("L", string + b'\x00' * 5)
     
    Last edited: Apr 12, 2015
  8. joefitz

    joefitz New Member

    Joined:
    Mar 30, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    thanks cryozap!
    Now i know for sure that there is something wrong specifically with my setup.

    b'\x15' in pythonese is a representation of the string 0x15 0x20 0x20, but 0x20 is ascii space. 0x152020 is the correct idcode for the part.

    I think the code assumes "L" is 4 bytes but on your platform it's 8.

    I'm no python expert, but i think the right way to do it is to use I for 4-byte integer instead of L for 8-byte long:
    Code:
    idTuple = struct.unpack("I", string + b'\x00')
    If that doesn't work, then you could put the padding on the other end and your device should work fine with the script. or maybe it already works fine and i'm getting my endienness mixed up
    Code:
    idTuple = struct.unpack("L", b'\x00' * 4 + string + b'\x00')
    edit: ignore this, my endienness was wrong, thanks cryozap

    -joe
     
    Last edited: Apr 12, 2015
  9. cyrozap

    cyrozap Moderator

    Joined:
    Apr 12, 2015
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    That would make sense since an unsigned long on 64-bit platforms is usually 8 bytes. As for the endianness, you were correct in your first solution--struct uses the endianness of the architecture it's running on if none is specified and since x86/x86_64 is little-endian, both your first solution and mine work. However, to accommodate all platforms, endianness should be explicitly defined in all the struct statements.
     
  10. joefitz

    joefitz New Member

    Joined:
    Mar 30, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    Thanks again cryozap. Interesting that ubuntu 64 works fine on that code.
    Now to setup an arch system to test my board before finally placing the blame on the hardware....
     
  11. admin

    admin Administrator Staff Member

    Joined:
    Jan 23, 2015
    Messages:
    169
    Likes Received:
    11
    Trophy Points:
    18
    Sorry again, it took a few extra days to get back with update.

    I finally was able to test the script on a Centos machine. I had to make a minor change in the code to make it work.

    Line 249 was changed from
    Code:
     idTuple = struct.unpack("L", string + b'\x00') 
    to
    Code:
     idTuple = struct.unpack("=L", string + b'\x00') 
    I have committed the updated script to the numato.cc SVN. Here is the screenshot on Centos.

    upload_2015-4-15_11-46-24.png

    Hope this helps.

    Thanks,
    Tom
     
  12. joefitz

    joefitz New Member

    Joined:
    Mar 30, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    Thanks for figuring that out, =L is much more elegant a solution than padding the unpack.

    However, my board does not make it that far. on ubuntu 12.04, 14.10, and arch linux, it takes the branch to line 247 and returns None. My elbert V2 works fine on all those platforms, and my mimasV2 still works fine in windows. Since i've tried several systems, and other mimas v2's work fine with linux, can i exchange my possibly faulty board?

    Thanks!
    -joe
     
  13. admin

    admin Administrator Staff Member

    Joined:
    Jan 23, 2015
    Messages:
    169
    Likes Received:
    11
    Trophy Points:
    18
    Hello Joe, Since the board works fine on Windows, we can not conclude that there is anything wrong with hardware. If it was a hardware problem, it should show up on all platforms the same way.

    Thanks,
    Tom
     
  14. joefitz

    joefitz New Member

    Joined:
    Mar 30, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    Tom,
    The mimasV2 does not work in linux, all 4 varieties i tried. The elbertv2 does. What can i do to isolate the issue? There are no more software variables for me to rule out. Are there any updates or changes to the mcu firmware that might make a difference?

    thanks,
    -joe
     
  15. admin

    admin Administrator Staff Member

    Joined:
    Jan 23, 2015
    Messages:
    169
    Likes Received:
    11
    Trophy Points:
    18
    Can I ask if you are using a VM to host Linux? Some VM software are known to have difficulties with USB CDC.

    I can positively confirm that the hardware is in perfect shape since it does work fine with Windows. There is nothing in hardware or software that depends on the OS to function and hw/fw can not detect if it is connected to Windows or Linux.

    Also please note that the script I have shared is not an official one and is not actively supported by us (I shared it only because you asked for it). So it is expected that you may have to put some amount of work to get it working on your setup. Also kindly understand that I have stated this fact (that the script was not tested on Linux) in my comment on 6th April 2015.

    Thanks,
    Tom
     
  16. joefitz

    joefitz New Member

    Joined:
    Mar 30, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    no VMs, running natively in all scenarios.

    I agree it's odd that it would work in windows but not linux, but i've spent the better part of a decade working on silicon failure analysis, and it is very real for differences in USB stacks between operating systems to cause problems like this - I've see it, in practice, many times.
    If I order a second board, and can show that it works fine and the current one I have does not, would you acknowledge a hardware issue?

    I believe I've already shown i'm willing to put the work into getting it functioning on my system, I'm happy to continue to debug the issue. In order to do that though, I need more information about the PIC micro controller. Any of the following could help me:
    1. Details about the serial protocol to the PIC, and if there is any sort of self-test or other function built into the firmware
    2. your PIC source code, though i understand that it is probably closed-source
    3. binary file so i can restore the original PIC firmware after i flash it with my own test code to identify the issue

    Thanks!!
    -joe
     
  17. cyrozap

    cyrozap Moderator

    Joined:
    Apr 12, 2015
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    @joefitz:

    This will probably sound obvious and you may have already done it, but have you made sure the switch on the Mimas V2 is in the "program" position and not the "UART" position? Whenever I forget to switch it back, I get the same "Unable to read SPI Flash ID" as you, but switching it back fixes that.

    @admin:

    Is there any reason why you're reading the flash ID using native byte ordering and not explicitly stating little-endian? According to the documentation, "=" means native byte order, standard size, no alignment. I suggest changing that to "<" to specify little-endian byte order, standard size, and no alignment for the benefit of naturally big-endian or bi-endian platforms.
     
  18. admin

    admin Administrator Staff Member

    Joined:
    Jan 23, 2015
    Messages:
    169
    Likes Received:
    11
    Trophy Points:
    18
    @cyrozap:
    I'm not sure if endianness is a problem unless Joe is using a big endian machine. Forcing native byte order did work on a bunch of machines here (all are little endian machines). Joe should be able to try this on his machine. Thanks a lot for the suggestions.

    @joefitz:
    We have to get to the bottom of this. I will ship another board tomorrow so you can give a try. Meanwhile, please try changing the "=" to "<" on line 249. just in case if that works. Can you please create a ticket at the Contact Us page. Please make sure to mention the original order number and the latest shipping address if different from the one with the order.

    Thanks,
    Tom
     
  19. Evert Rozendaal

    Evert Rozendaal New Member

    Joined:
    Apr 26, 2015
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    Location:
    Roanoke,VA USA
    I just got my board mimas V2 this Friday and could not get a xilinx licence for windows. I spend about the whole day yesterday to get it one. However I have a version working on ubuntu from few mounths ago. Anyhow I was very happy to find this python script but my luck continues ... The python script does not work on my 32 bits inspiron dell laptop. I am using python 2.7 and was wondering if I need python 3 or higher. The first time ReadData(self, count) gets called it does not seem to read anything.
     
  20. cyrozap

    cyrozap Moderator

    Joined:
    Apr 12, 2015
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    USA
    @Evert Rozendaal:
    Xilinx licenses are not OS-specific. After creating a Xilinx account, you should be able to go to http://www.xilinx.com/getlicense and download the WebPACK license. In fact, if you have a WebPACK license already installed on your Ubuntu system, you should be able to copy that over to your Windows computer and ISE will see it as a valid license. As for the Python script, yes, you need to run it using Python 3. If the script fails to run then, make sure you have the proper permissions on your serial port (read + write).
     

Share This Page