Bug 251616

Summary: devel/msp430-debug-stack: devd file creates broken symlink
Product: Ports & Packages Reporter: Kevin Zheng <kevinz5000>
Component: Individual Port(s)Assignee: Lev A. Serebryakov <lev>
Status: New ---    
Severity: Affects Only Me CC: darius, tingox+freebsd
Priority: --- Flags: bugzilla: maintainer-feedback? (lev)
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Fixed devd file none

Description Kevin Zheng 2020-12-05 20:02:01 UTC
The current devd config that symlinks mspfet is broken:

Output from `devd -d`:

Processing attach event                                                                                                          
Testing device-name=umodem0 against ^ed50$, invert=0                                                                             
Testing device-name=umodem0 against ^ubt[0-9]+$, invert=0                                                                        
Testing device-name=umodem0 against ^ukbd0$, invert=0                                                                            
Testing device-name=umodem0 against ^umodem[0-9]+$, invert=0                                                                     
Testing vendor=0x2047 against ^0x2047$, invert=0                                                                                 
Testing product=0x0013 against ^0x001(0|3|4)$, invert=0                                                                          
Testing interface=0 against ^0$, invert=0                                                                                        
Executing 'cd /dev; p=$'0x0013'; dn=$'umodem0';                 un=$(sysctl -n dev.umodem.${dn#umodem}.ttynam                    e);        chmod 666 cua$''; ln -sf cua$'' mspfet${p#0x}'                                                                        
chmod: cua: No such file or directory

I'm currently investigating a fix.
Comment 1 Torfinn Ingolfsen 2023-05-18 20:51:02 UTC
Problem still exists. Tested on FreeBSD 13.1-release-p7. Output from `devd -d`:
Testing device-name=umodem0 against ^ed50$, invert=0
Testing device-name=umodem0 against ^ubt[0-9]+$, invert=0
Testing device-name=umodem0 against ^ukbd0$, invert=0
Testing device-name=umodem0 against ^umodem[0-9]+$, invert=0
Testing vendor=0x2047 against ^0x2047$, invert=0
Testing product=0x0013 against ^0x001(0|3|4)$, invert=0
Testing interface=0 against ^0$, invert=0
Executing 'cd /dev; p=$'0x0013'; dn=$'umodem0';			un=$(sysctl -n dev.umodem.${dn#umodem}.ttyname);	chmod 666 cua$''; ln -sf cua$'' mspfet${p#0x}'
chmod: cua: No such file or directory
Popping table
Comment 2 Kevin Zheng 2023-05-18 20:52:56 UTC
You can work around this by selecting the correct cuaUX port yourself and pass that argument to mspdebug.
Comment 3 Torfinn Ingolfsen 2023-05-18 22:25:13 UTC
specifying a port for mspdebug doesn't work here:

tingo@kg-core1:~/personal/projects/2023/rust/embedded/msp430/msp430-test-f5529 $ ls -l /dev/cuaU0 /dev/mspfet*
crw-rw----  1 uucp  dialer  0x1d9 May 19 00:19 /dev/cuaU0
lrwxr-xr-x  1 root  wheel      10 May 18 23:31 /dev/mspfet0013 -> /dev/cuaU0
tingo@kg-core1:~/personal/projects/2023/rust/embedded/msp430/msp430-test-f5529 $ groups
tingo wheel operator video dialer webcamd

tingo@kg-core1:~/personal/projects/2023/rust/embedded/msp430/msp430-test-f5529 $ mspdebug -C mspdebug.cfg -d /dev/cuaU0 tilib
MSPDebug version 0.25 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2017 Daniel Beer <dlbeer@gmail.com>
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chip info database from MSP430.dll v3.15.0.1 Copyright (C) 2013 TI, Inc.

Using new (SLAC460L+) API
MSP430_Initialize: /dev/cuaU0
tilib: MSP430_Initialize: Could not find MSP-FET430UIF on specified COM port (error = 57)
tilib: device initialization failed

but it works with a correctly linked /dev/mspfet*

tingo@kg-core1:~/personal/projects/2023/rust/embedded/msp430/msp430-test-f5529 $ mspdebug -C mspdebug.cfg tilib
MSPDebug version 0.25 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2017 Daniel Beer <dlbeer@gmail.com>
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chip info database from MSP430.dll v3.15.0.1 Copyright (C) 2013 TI, Inc.

Using new (SLAC460L+) API
MSP430_GetNumberOfUsbIfs
MSP430_GetNameOfUsbIf
Found FET: mspfet0013
MSP430_Initialize: mspfet0013
Firmware version is 31501001
MSP430_VCC: 3000 mV
MSP430_OpenDevice
MSP430_GetFoundDevice
Device: MSP430F5529 (id = 0x002f)
8 breakpoints available
MSP430_EEM_Init
Chip ID data:
  ver_id:         2955
  ver_sub_id:     0000
  revision:       17
  fab:            55
  self:           5555
  config:         12
  fuses:          55
Device: MSP430F5529
Bound to port 2000. Now waiting for connection...
Comment 4 Daniel O'Connor 2023-06-08 05:09:31 UTC
Created attachment 242679 [details]
Fixed devd file
Comment 5 Daniel O'Connor 2023-06-08 05:10:01 UTC
The attached devd file works for me (simply replacing $un with ${un})
Comment 6 Torfinn Ingolfsen 2023-07-05 16:11:30 UTC
I can confirm that the fix (changing '$un' to '${un}' in the devd file) works.