Exemple #1
0
    def create_instance(self, dev_path, what_chip):
        "in :                    \
           dev_path:string"

        protocol_type = dfu_common.get_protocol_type_support(
            self.rpc_client_node)["swd"]
        arch_type = dfu_common.get_chip_arch_type_support(
            self.rpc_client_node)["psoc4"]
        chip_type = dfu_common.get_chip_type_support(self.rpc_client_node,
                                                     arch_type)[what_chip]
        logger.info(dfu_common.get_protocol_type_support(self.rpc_client_node))
        logger.info(dfu_common.get_chip_arch_type_support(
            self.rpc_client_node))
        logger.info(
            dfu_common.get_chip_type_support(self.rpc_client_node, arch_type))

        params = {}
        params["driver_name"] = dev_path
        params["protocol_type"] = protocol_type
        params["chip_arch_type"] = arch_type
        params["chip_type"] = chip_type

        response = self.rpc_client_node.call("DfuProgInstanceCreate", **params)
        logger.info(response)
        if response["state"] < 0:
            #             logger.info(response["return"])
            return dfu_common.get_error_return_state(response)
        return dfu_common.get_correct_return_state(response)
Exemple #2
0
    def create_target(self,dev_path,what_chip,frequency_hz):
        ret_str = "\r\n------------------------------------\r\n"
        ret_str += "Operating "
        #traverse
        #if rpc server support the chip type
        arch_type = dfu_common.get_chip_arch_type_support(self.dfu_rpc_node)
        for arch_keys in arch_type.keys():
            chip_type = dfu_common.get_chip_type_support(self.dfu_rpc_node,arch_type[arch_keys]) 
            if what_chip in chip_type.keys():
                if arch_keys == "stm32":
                    self.prog_instance = Stm32Prog(self.dfu_rpc_node)
                elif arch_keys == "cortexm":
                     self.prog_instance = CortexMProg(self.dfu_rpc_node)
                elif arch_keys == "psoc4":
                    self.prog_instance = Psoc4Prog(self.dfu_rpc_node)
                elif arch_keys == "nrf5xble":
                    self.prog_instance = Nrf5XProg(self.dfu_rpc_node)
                elif arch_keys == "spiflash":
                    self.arch_type = "spiflash"
                    self.prog_instance = SpiFlash(self.dfu_rpc_node)
                elif arch_keys == "otp":
                    self.arch_type = "otp"
                    self.prog_instance = OtpProg(self.dfu_rpc_node)
                break
        #if other instance support the chip type
        if self.prog_instance == None:
            logger.warning("create other instance")
            if what_chip == "hearst":
                self.prog_instance = HearstProg(self.dfu_rpc_node)
                arch_keys = "cortexm"
                self.arch_type = "cortexm"
            else:
                ret_str += "error ,do not support this device ."
                return False,ret_str
            ret_str += arch_keys+":"+what_chip+"........\r\n"

        #create instance
        ret_str += "create target.....\r\n"
        ret = self.prog_instance.create_instance(dev_path,what_chip)#[0] true/false,[1] type,[2] return
        # ret_str += _return_to_str(ret)
        if ret[0] == False:
            self.destroy_target()
            return False,ret_str

        #instance initial
        ret = self.prog_instance.instance_initial(frequency_hz)
        ret_str += _return_to_str(ret)
        if ret[0] == False:
            self.destroy_target()
            return False,ret_str

        return True,ret_str
Exemple #3
0
 def list_support_target(self):
     support_chip = ""
     
     #from the rpc server get support
     arch_type = dfu_common.get_chip_arch_type_support(self.dfu_rpc_node)
     for arch_keys in arch_type.keys():
         support_chip += arch_keys+":"
         chip_type = dfu_common.get_chip_type_support(self.dfu_rpc_node,arch_type[arch_keys])
         for chip_keys in chip_type.keys():
             support_chip += chip_keys+" "
         pass
     #from the python layer get support
     support_chip += HearstProg.chip_type_name()
     support_chip += "\r\n"
     #print(support_chip)
     return True,support_chip
Exemple #4
0
 def distinguish_chip_architecture(self,what_chip,arch_type):
     arch_type = dfu_common.get_chip_arch_type_support(self.dfu_rpc_node)
     #if rpc server support the chip type
     for arch_keys in arch_type.keys():
         chip_type = dfu_common.get_chip_type_support(self.dfu_rpc_node,arch_type[arch_keys]) 
         if what_chip in chip_type.keys():
             if arch_keys == arch_type:
                 return True
             else:
                 return False
     #if other instance support the chip type
     arch_keys = None
     if what_chip == "hearst":
         self.prog_instance = HearstProg(self.dfu_rpc_node)
         arch_keys = "cortexm"
         if arch_keys == arch_type:
             return True
         else:
             return False
     return False