def program_new_pcb(fx3_firmware, VID, PID, di_file, fx3_prom_term='FX3_PROM'):
    """
        This function does not require an open device.  It looks
        for the 1st unprogrammed pcb (by using the default Cypress
        Vendor ID/Product ID and attempts to load the fx3 firmware
        files specified.

        :param fx3_firmware: The fx3 firmare ihx file. 
        :param vendor id of firmware being loaded.
        :param product id of firmware being loaded.
        :param path to di file implemented by firmware.
    """
    dev=nitro.USBDevice(0x04b4,0x00f3)
    dev.open(0,True)
    program_fx3(dev,fx3_firmware)
    time.sleep(1)

    # 
    while nitro.USBDevice.get_device_count(VID, PID) < 1:
        time.sleep(1)

    dev=nitro.USBDevice(VID, PID)
    dev.open()
    dev.set_di( nitro.load_di ( di_file ) )
    program_fx3_prom(dev, fx3_firmware, fx3_prom_term)
    dev.close()
def program_new_pcb(fx2_firmware, VID, PID, di_file, fx2_prom_term='FX2_PROM'):
    """
        This function does not require an open device.  It looks
        for the 1st unprogrammed pcb (by using the default Cypress
        Vendor ID/Product ID and attempts to load the fx2 firmware
        files specified.

        :param fx2_firmware: The fx2 firmare ihx file. 
        :param vendor id of firmware being loaded.
        :param product id of firmware being loaded.
        :param path to di file implemented by firmware.
    """
    dev=nitro.USBDevice(0x04b4,0x8613)
    dev.open(0,True)
    program_fx2(dev,fx2_firmware)
    time.sleep(1)

    # 
    while nitro.USBDevice.get_device_count(VID, PID) < 1:
        time.sleep(1)

    dev=nitro.USBDevice(VID, PID)
    dev.open()
    dev.set_di( nitro.load_di ( di_file ) )
    program_fx2_prom(dev,fx2_firmware, fx2_prom_term)
    dev.close()
Example #3
0
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#

import nitro
from nitro import DeviceInterface, Terminal, Register, SubReg

prom_di = nitro.load_di ( "Microchip/M24XX/M24XX.xml" )
fx3_prom_term = prom_di['M24XX'].clone()
fx3_prom_term.name = 'FX3_PROM'
fx3_prom_term.addr = 0x50
fx3_prom_term.add_child ( 
    Register ( 
        name='serialnum',
        addr=0x20000-16, # place serial number at last 16 bytes of eeprom (stored as unicode (16 bit) on prom for device descriptor compat.
        comment="Location of serial number stored on eeprom.",
        mode="write",
        width=16, # unicode characters 
        array=8) ) # 8 characters (str type not implemented yet)


di=DeviceInterface(
    name="fx3",
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#

import nitro
from nitro import DeviceInterface, Terminal, Register, SubReg

prom_di = nitro.load_di("Microchip/M24XX/M24XX.xml")
fx2_prom_term = prom_di['M24XX'].clone()
fx2_prom_term.name = 'FX2_PROM'
fx2_prom_term.add_child(
    Register(
        name='serialnum',
        addr=0x10000 -
        16,  # place serial number at last 16 bytes of eeprom (stored as unicode (16 bit) on prom for device descriptor compat.
        comment="Location of serial number stored on eeprom.",
        mode="write",
        width=16,  # unicode characters 
        array=8))  # 8 characters (str type not implemented yet)

di = DeviceInterface(
    name="Cy7C68013",
    terminal_list=[
                         type='trigger',
                         mode='write',
                         width=1,
                         comment="Resets the dram memory controller block (MCB).",
                         ),
                Register(name='mode',
                         type='int',
                         mode='write',
                         subregs=[SubReg(name='selfrefresh',init=0,width=1,comment='Puts dram controller in self refresh mode. See Xilinx UG388 MCB User Guide for more information'),
                                  ],
                         comment='Mode Register',
                         ),
                ]),

        ],
    )

# load the baseline UXN1212 terminals
import nitro
di=nitro.load_di("Cypress/CY7C68013/CY7C68013.xml", di)
di = nitro.load_di("Xilinx/Spartan/Spartan.xml", di)
di["FX2_SFR"]["IOA"]["A0"].name = "init_b"
di["FX2_SFR"]["IOA"]["A1"].name = "done"
di["FX2_SFR"]["IOA"]["A3"].name = "prog_b"
# load the FPGA prom terminals
di = nitro.load_di("Numonyx/M25P/M25P.xml", di)
di["DATA"].name = "FPGA_PROM"
di["CTRL"].name = "FPGA_PROM_CTRL"


def init_dev(dev, di_file="Cypress/fx3/fx3.xml"):
    """Initializes the device with the di files."""

    di = nitro.load_di(di_file)
    dev.set_di(di)
 def __init__(self, filename, di):
     self.fd = open(filename,"rb")
     if type(di)==types.StringType:
         di=nitro.load_di(di)
     self.di = di
                Register(name='mcb_reset',
                         type='trigger',
                         mode='write',
                         width=1,
                         comment="Resets the dram memory controller block (MCB).",
                         ),
                Register(name='mode',
                         type='int',
                         mode='write',
                         subregs=[SubReg(name='selfrefresh',init=0,width=1,comment='Puts dram controller in self refresh mode. See Xilinx UG388 MCB User Guide for more information'),
                                  ],
                         comment='Mode Register',
                         ),
                ]),

        ],
    )

di = nitro.load_di ( "Cypress/fx3/fx3.xml", di )
di = nitro.load_di("Xilinx/Spartan/Spartan.xml", di)
# parallel programming not supported on fx3
del di['PROGRAM_FPGA']

# add M25P terminals in
di = nitro.load_di ( "Numonyx/M25P/M25P.xml", di )
di['DATA'].name = 'FPGA_PROM_DATA'
di['CTRL'].name = 'FPGA_PROM_CTRL'



def init_dev(dev, di_file="Cypress/CY7C68013/CY7C68013.xml"):
    """Initializes the device with the di files."""

    di = nitro.load_di(di_file)
    dev.set_di(di)