Exemplo n.º 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)["nrf5xble"]
        chip_type = dfu_common.get_chip_type_support(self.rpc_client_node,
                                                     arch_type)[what_chip]

        print(dfu_common.get_protocol_type_support(self.rpc_client_node))
        print(dfu_common.get_chip_arch_type_support(self.rpc_client_node))
        print(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)
Exemplo n.º 2
0
    def create_target(self, dev_path, what_chip, frequency_hz, sub_type=None):
        ret_str = "\r\n------------------------------------\r\n"
        ret_str += "Operating "
        #traverse
        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.target_address = 0x08000000
                    self.prog_instance = Stm32Prog(self.dfu_rpc_node)
                    # self.prog_instance = Stm32L4xxProg(self.dfu_rpc_node)
                elif arch_keys == "cortexm":
                    self.target_address = 0x00000000
                    if sub_type == "hearst":
                        self.prog_instance = HearstProg(self.dfu_rpc_node)
                    else:
                        self.prog_instance = CortexMProg(self.dfu_rpc_node)

                elif arch_keys == "psoc4":
                    self.target_address = 0x00000000
                    self.prog_instance = Psoc4Prog(self.dfu_rpc_node)
                elif arch_keys == "nrf5xble":
                    self.target_address = 0x00000000
                    self.prog_instance = Nrf5XProg(self.dfu_rpc_node)
                elif arch_keys == "spiflash":
                    self.arch_type = "spiflash"
                    self.target_address = 0x00000000
                    self.prog_instance = SpiFlash(self.dfu_rpc_node)
                else:
                    ret_str += "error ,do not support this device ."
                    return False, ret_str
                ret_str += arch_keys + ":" + what_chip + "........\r\n"
                break
        if what_chip not in chip_type.keys():
            ret_str += "error ,do not support this device .\r\n"
            return False, ret_str

        #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
Exemplo n.º 3
0
 def list_support_target(self):
     support_chip_architecture = ""
     arch_type = dfu_common.get_chip_arch_type_support(self.dfu_rpc_node)
     for arch_keys in arch_type.keys():
         support_chip_architecture += 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_architecture += chip_keys + " "
         support_chip_architecture += "\r\n"
         pass
     #pring(support_chip_architecture)
     return True, support_chip_architecture
Exemplo n.º 4
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
Exemplo n.º 5
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