コード例 #1
0
def create_device_cert_and_manifest():
    """AWS IoT EduKit MCU hardware device registration script
    Checkes environment is set correctly, generates ECDSA certificates,
    ensures all required python libraries are included, retrieves on-board 
    device certificate using the esp-cryptoauth library and utility, creates 
    an AWS IoT thing using the AWS CLI and Microchip Trust Platform Design Suite.
    """
    app_binary = 'sample_bins/secure_cert_mfg.bin'
    args = manifest_args(env.get("UPLOAD_PORT"))

    args.signer_cert = os.path.join(dest_folder, "signer_cert.crt")
    args.signer_privkey = os.path.join(dest_folder, "signer_key.pem")
    args.print_atecc608_type = False

    check_environment()
    generate_signer_certificate()

    esp = esptool.ESP32ROM(args.port, baud=115200)
    esp_hs.serial.load_app_stub(app_binary, esp)
    init_mfg = esp_hs.serial.cmd_interpreter()

    retval = init_mfg.wait_for_init(esp._port)
    if retval is not True:
        print("CMD prompt timed out.")
        exit(0)

    retval = init_mfg.exec_cmd(
        esp._port, "init {0} {1}".format(atecc608_i2c_sda_pin,
                                         atecc608_i2c_scl_pin))
    esp_hs.serial.esp_cmd_check_ok(
        retval, "init {0} {1}".format(atecc608_i2c_sda_pin,
                                      atecc608_i2c_scl_pin))
    os.makedirs(temp_folder, exist_ok=True)
    esp_hs.generate_manifest_file(esp, args, init_mfg)
コード例 #2
0
def main():
    """AWS IoT EduKit MCU hardware device registration script
    Checkes environment is set correctly, generates ECDSA certificates,
    ensures all required python libraries are included, retrieves on-board 
    device certificate using the esp-cryptoauth library and utility, creates 
    an AWS IoT thing using the AWS CLI and Microchip Trust Platform Design Suite.
    """
    app_binary = 'sample_bins/secure_cert_mfg.bin'
    parser = argparse.ArgumentParser(
        description='''Provision the Core2 for AWS IoT EduKit with 
        device_certificate and signer_certificate required for TLS authentication'''
    )

    parser.add_argument(
        "--port",
        '-p',
        dest='port',
        metavar='[port]',
        required=True,
        help='Serial comm port of the Core2 for AWS IoT EduKit device')

    args = parser.parse_args()

    args.signer_cert = "output_files/signer_cert.crt"
    args.signer_privkey = "output_files/signer_key.pem"
    args.print_atecc608_type = False
    check_environment()

    generate_signer_certificate()

    esp = esptool.ESP32ROM(args.port, baud=115200)
    esp_hs.serial.load_app_stub(app_binary, esp)
    init_mfg = esp_hs.serial.cmd_interpreter()

    retval = init_mfg.wait_for_init(esp._port)
    if retval is not True:
        print("CMD prompt timed out.")
        exit(0)

    retval = init_mfg.exec_cmd(
        esp._port, "init {0} {1}".format(atecc608_i2c_sda_pin,
                                         atecc608_i2c_scl_pin))
    esp_hs.serial.esp_cmd_check_ok(
        retval, "init {0} {1}".format(atecc608_i2c_sda_pin,
                                      atecc608_i2c_scl_pin))
    esp_hs.generate_manifest_file(esp, args, init_mfg)
    upload_manifest()