From nobody Sat Oct 26 23:51:26 2024 X-Original-To: hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Xbbz51MwLz5bKPX for ; Sat, 26 Oct 2024 23:51:45 +0000 (UTC) (envelope-from tomek@cedro.info) Received: from mail-yb1-xb2c.google.com (mail-yb1-xb2c.google.com [IPv6:2607:f8b0:4864:20::b2c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xbbz42gJyz4fZ4 for ; Sat, 26 Oct 2024 23:51:44 +0000 (UTC) (envelope-from tomek@cedro.info) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=cedro.info header.s=google header.b=THpSA6RS; spf=none (mx1.freebsd.org: domain of tomek@cedro.info has no SPF policy when checking 2607:f8b0:4864:20::b2c) smtp.mailfrom=tomek@cedro.info; dmarc=none Received: by mail-yb1-xb2c.google.com with SMTP id 3f1490d57ef6-e28fa2807eeso3158355276.1 for ; Sat, 26 Oct 2024 16:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cedro.info; s=google; t=1729986703; x=1730591503; darn=freebsd.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=5JBVEUB7ezrRkrqc/ou7YoDjxKt7e8SoLjqq/8ygIlU=; b=THpSA6RSvmUr88hAkwztkL1iBoPa6v+j8g5b7wXgsZ1SAinZzefqby8OWLjrzKL1Lg EGHVaAjOXuvmiufdVqSEvDJqbd5VzcSX9711mVUIf0RTKcSvt63GDjFc1COgm3lD/lV0 pph8dgTjcWY83hbEHBX8ksmWMSCkwSley6qw2Sxi3EQKn8N4AVBwS8AhXP8VjVrLUOpZ HKA7ihv4RkgT7kysV6F/zgaixfyFIhyZ5gdA7h6YSYdZzxL+b5//EakzhuNDj5cdp61D WgazwLhNH0uEoK4xtaIJ0h5AJImCgAv8jv/bz5/Q2fXmguYJbmKUjVH6fo340+iEweN/ 2DQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729986703; x=1730591503; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5JBVEUB7ezrRkrqc/ou7YoDjxKt7e8SoLjqq/8ygIlU=; b=lPz3GOTjUngWYVFwG9H2lAGdPm821dLq0EABfqBCOHLThRbX85HQIvzLJkcdWmJD8s qLPbAdakspAMbTXpvYSyVKr2lnncsTblC7es127qy5G4f7NO9Be1grfDI0V99ybW96kk beacFAagsBG3sf1SfIp5FcUz56bE2D9/lmCsd+rBtJOY4SfQ8PR7WJWqcCrZyLHgIIbE FI2a/884K5wqy4gHqUTNugjidy8aAM4rry401zLBoH+V2UKqbWozmKIf57Vi1TppVGKW +IjBqCUX0yyQTM9q1JKpAKlUnbGbyFbzPnd7zTGPsBdFfAVuOCEZdEAygqtc7wv17PE2 J6QA== X-Gm-Message-State: AOJu0Yw5BwDhgYClpVQa1wan1e0p1RDHRnAkwLtW5p0XmiJceYsJVfT9 x/3eFs/pzVMiuWcDCxXuwVHt6XRtfnqE+fXOSBgvvSiU4MTHE1EVqTwaIZQ/nRdQG6XSqy3q268 = X-Google-Smtp-Source: AGHT+IGbZYSAYCdCvF9hGtO2FmaW75LV9wkwMK24sfzRxCwUyGDkg4w4OKqBP1ZIJ6xFU7B9FSNFMQ== X-Received: by 2002:a05:6902:2410:b0:e2b:b74c:4783 with SMTP id 3f1490d57ef6-e3087a5c571mr2702678276.18.1729986702918; Sat, 26 Oct 2024 16:51:42 -0700 (PDT) Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com. [209.85.128.174]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e3079d82cd8sm785917276.23.2024.10.26.16.51.40 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 26 Oct 2024 16:51:41 -0700 (PDT) Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-6e9ed5e57a7so3123787b3.1 for ; Sat, 26 Oct 2024 16:51:40 -0700 (PDT) X-Received: by 2002:a05:690c:61c8:b0:6dd:bcce:7cd7 with SMTP id 00721157ae682-6e9d8aff19emr37940077b3.42.1729986700271; Sat, 26 Oct 2024 16:51:40 -0700 (PDT) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 References: <202410210954.49L9s9sD076618@critter.freebsd.dk> <203ADA8C-A4ED-4849-B89D-6D18664D67D0@webweaving.org> <202410221118.49MBIRSj009090@critter.freebsd.dk> <202410221847.49MIlXEs014246@critter.freebsd.dk> <202410221907.49MJ7BZl014476@critter.freebsd.dk> In-Reply-To: From: Tomek CEDRO Date: Sun, 27 Oct 2024 01:51:26 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: pyserial.tools.list_port improvement for FreeBSD To: Poul-Henning Kamp Cc: hackers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Spamd-Result: default: False [-3.30 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[cedro.info:s=google]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_SPF_NA(0.00)[no SPF record]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; MIME_TRACE(0.00)[0:+]; MISSING_XM_UA(0.00)[]; TO_DN_SOME(0.00)[]; DMARC_NA(0.00)[cedro.info]; RCPT_COUNT_TWO(0.00)[2]; MLMMJ_DEST(0.00)[hackers@freebsd.org]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::b2c:from]; TO_MATCH_ENVRCPT_SOME(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[hackers@freebsd.org]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[cedro.info:+] X-Rspamd-Queue-Id: 4Xbbz42gJyz4fZ4 X-Spamd-Bar: --- By the way, most of develkits use USB-TO-UART chip that have unusable serial number because with many boards having the same VID:PID and serial number it is not possible to distinguish them o_O It would be nice to add chip customization to pyserial :-) I found two kinda broken old utilities to update CP2102 USB-TO-UART chips that may serve as reference point :-) C: https://github.com/DiUS/cp210x-cfg Python: https://github.com/cederom/cp210x-program The first one uses LibUSB 1.0. After minor tweaks on FreeBSD I made it to compile, work, and burn the new serial.. maybe I will create a Port for this nice utility :-) From what I read this is one time only operation but that is okay I will add random stuff :-) % ./cp210x-cfg ID 10c4:ea60 @ bus 000, dev 007: CP2102 USB to UART Bridge Controller Model: CP2102 Vendor ID: 10c4 Product ID: ea60 Name: CP2102 USB to UART Bridge Controller Serial: 0001 % dd if=/dev/random count=1M | md5 1048576+0 records in 1048576+0 records out 76f24aad88225fedf7260bb4f54c525d 536870912 bytes transferred in 3.788303 secs (141718053 bytes/sec) % ./cp210x-cfg -h Syntax: cp210x-cfg [-h ] | [-m vid:pid] [-d bus:dev] [ -l | [-V vid] [-P pid] [-F flush] [-M mode] [-N name] [-S serial]] -h This help -m vid:pid Find and use first device with vid:pid -d bus:dev Find and use device at bus:dev -l List all CP210x devices connected -V vid Program the given Vendor ID -P pid Program the given Product ID -F flush Program the given buffer flush bitmap (CP2105 only) -M mode Program the given SCI/ECI mode (CP2105 only) -N name Program the given product name string -S serial Program the given serial string Unless the -d option is used, the first found CP210x device is used. If no programming options are used, the current values are printed. % ./cp210x-cfg -S 76f24aad88225fedf7260bb4f54c525d ID 10c4:ea60 @ bus 000, dev 007: CP2102 USB to UART Bridge Controller Model: CP2102 Vendor ID: 10c4 Product ID: ea60 Name: CP2102 USB to UART Bridge Controller Serial: 76f24aad88225fedf7260bb4f54c525d % ./cp210x-cfg ID 10c4:ea60 @ bus 000, dev 007: CP2102 USB to UART Bridge Controller Model: CP2102 Vendor ID: 10c4 Product ID: ea60 Name: CP2102 USB to UART Bridge Controller Serial: 76f24aad88225fedf7260bb4f54c525d I would not be myself not to try write serial again knowing it it supposedly one time only operation :-) % ./cp210x-cfg -S CeDeROM76f24aad88225fedf7260bb4f54c525d ID 10c4:ea60 @ bus 000, dev 007: CP2102 USB to UART Bridge Controller Model: CP2102 Vendor ID: 10c4 Product ID: ea60 Name: CP2102 USB to UART Bridge Controller Serial: CeDeROM76f24aad88225fedf7260bb4f54c525d % ./cp210x-cfg ID 10c4:ea60 @ bus 000, dev 007: CP2102 USB to UART Bridge Controller Model: CP2102 Vendor ID: 10c4 Product ID: ea60 Name: CP2102 USB to UART Bridge Controller Serial: CeDeROM76f24aad88225fedf7260bb4f54c525d % ./cp210x-cfg -S ESP32DEVKITC-CDR-76f24aad88225fedf7260bb4f54c525d ID 10c4:ea60 @ bus 000, dev 007: CP2102 USB to UART Bridge Controller Model: CP2102 Vendor ID: 10c4 Product ID: ea60 Name: CP2102 USB to UART Bridge Controller Serial: ESP32DEVKITC-CDR-76f24aad88225fedf7260bb4f54c525d % ./cp210x-cfg ID 10c4:ea60 @ bus 000, dev 007: CP2102 USB to UART Bridge Controller Model: CP2102 Vendor ID: 10c4 Product ID: ea60 Name: CP2102 USB to UART Bridge Controller Serial: ESP32DEVKITC-CDR-76f24aad88225fedf7260bb4f54c525d Very cool, looks like this chip has Flash not the OTP and we can assign whatever serial string we want :-) Have a good weekend folks :-) -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info