Spark Logic

Failed to reconnect serial monitor after uploading on macOS

hanyazou Fri May 05, 2017 3:16 am

Hello there.

This is my first post at this forum. I read some posts related to USB and USB serial on Mac OS. But I can’t find the solution of my problem.

I addressed and solve the problem by myself fotunately. But I’m not sure this is proper fix. So I post here to share my patch and hear your thoughts.

Environment:
OS: Mac OS X 10.12.4
Arduino IDE: 1.8.2
Board: SushiBits One STM32F103CB (https://www.tindie.com/products/maxtch/ … pment-kits)

Error:
I’ve had a error after uploading. The IDE failed to re-connect serial monitor.

/Applications/Arduino-1.8.2.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino-1.8.2.app/Contents/Java/hardware -hardware /Users/hanyazou/Library/Arduino15/packages -hardware /Users/hanyazou/Documents/Arduino/hardware -tools /Applications/Arduino-1.8.2.app/Contents/Java/tools-builder -tools /Applications/Arduino-1.8.2.app/Contents/Java/hardware/tools/avr -tools /Users/hanyazou/Library/Arduino15/packages -built-in-libraries /Applications/Arduino-1.8.2.app/Contents/Java/libraries -libraries /Users/hanyazou/Documents/Arduino/libraries -fqbn=Arduino_STM32-hanyazou:STM32F1:sushibitsone_f103c:upload_method=DFUUploadMethod -vid-pid=0X1EAF_0X0004 -ide-version=10802 -build-path /var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264 -warnings=none -build-cache /var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_cache_770802 -prefs=build.warn_data_percentage=75 -verbose /Users/hanyazou/github/MyArduinoScratchPad/Blink/Blink.ino
/Applications/Arduino-1.8.2.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino-1.8.2.app/Contents/Java/hardware -hardware /Users/hanyazou/Library/Arduino15/packages -hardware /Users/hanyazou/Documents/Arduino/hardware -tools /Applications/Arduino-1.8.2.app/Contents/Java/tools-builder -tools /Applications/Arduino-1.8.2.app/Contents/Java/hardware/tools/avr -tools /Users/hanyazou/Library/Arduino15/packages -built-in-libraries /Applications/Arduino-1.8.2.app/Contents/Java/libraries -libraries /Users/hanyazou/Documents/Arduino/libraries -fqbn=Arduino_STM32-hanyazou:STM32F1:sushibitsone_f103c:upload_method=DFUUploadMethod -vid-pid=0X1EAF_0X0004 -ide-version=10802 -build-path /var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264 -warnings=none -build-cache /var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_cache_770802 -prefs=build.warn_data_percentage=75 -verbose /Users/hanyazou/github/MyArduinoScratchPad/Blink/Blink.ino
Using board 'sushibitsone_f103c' from platform in folder: /Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1
Using core 'maple' from platform in folder: /Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1
Detecting libraries used...
"/Users/hanyazou/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_sushibitsone_f103c -DVECT_TAB_ADDR=0x8002000 -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10802 -DARDUINO_SUSHIBITSONE_F103C -DARDUINO_ARCH_STM32F1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103CB -mthumb -march=armv7-m -D__STM32F1__ -DMCU_STM32F103CB -mthumb -march=armv7-m -D__STM32F1__ "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple/include" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple/stm32f1/include" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple/usb/stm32f1" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple/usb/usb_lib" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/cores/maple" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/variants/sushibitsone_f103c" "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/sketch/Blink.ino.cpp" -o "/dev/null"
Generating function prototypes...
"/Users/hanyazou/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_sushibitsone_f103c -DVECT_TAB_ADDR=0x8002000 -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10802 -DARDUINO_SUSHIBITSONE_F103C -DARDUINO_ARCH_STM32F1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103CB -mthumb -march=armv7-m -D__STM32F1__ -DMCU_STM32F103CB -mthumb -march=armv7-m -D__STM32F1__ "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple/include" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple/stm32f1/include" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple/usb/stm32f1" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple/usb/usb_lib" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/cores/maple" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/variants/sushibitsone_f103c" "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/sketch/Blink.ino.cpp" -o "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/preproc/ctags_target_for_gcc_minus_e.cpp"
"/Applications/Arduino-1.8.2.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/preproc/ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"/Users/hanyazou/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_sushibitsone_f103c -DVECT_TAB_ADDR=0x8002000 -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10802 -DARDUINO_SUSHIBITSONE_F103C -DARDUINO_ARCH_STM32F1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103CB -mthumb -march=armv7-m -D__STM32F1__ -DMCU_STM32F103CB -mthumb -march=armv7-m -D__STM32F1__ "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple/include" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple/stm32f1/include" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple/usb/stm32f1" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/system/libmaple/usb/usb_lib" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/cores/maple" "-I/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/variants/sushibitsone_f103c" "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/sketch/Blink.ino.cpp" -o "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/sketch/Blink.ino.cpp.o"
Compiling libraries...
Compiling core...
Using previously compiled file: /var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/core/wirish/start.S.o
Using previously compiled file: /var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/core/wirish/start_c.c.o
Using previously compiled file: /var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/core/wirish/syscalls.c.o
Using previously compiled file: /var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/core/board.cpp.o
Using previously compiled file: /var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/core/wirish/boards.cpp.o
Using previously compiled file: /var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/core/wirish/boards_setup.cpp.o
Using precompiled core
Linking everything together...
"/Users/hanyazou/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -Os -Wl,--gc-sections -mcpu=cortex-m3 "-T/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/variants/sushibitsone_f103c/ld/bootloader_20.ld" "-Wl,-Map,/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/Blink.ino.map" "-L/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/STM32F1/variants/sushibitsone_f103c/ld" -o "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/Blink.ino.elf" "-L/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264" -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/sketch/Blink.ino.cpp.o" "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/core/wirish/start.S.o" "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/core/wirish/start_c.c.o" "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/core/wirish/syscalls.c.o" "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/core/board.cpp.o" "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/core/wirish/boards.cpp.o" "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/core/wirish/boards_setup.cpp.o" "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/../arduino_cache_770802/core/core_Arduino_STM32-hanyazou_STM32F1_sushibitsone_f103c_upload_method_DFUUploadMethod_b8b0acbbc794d5ed9ab449fd87ac250d.a" -Wl,--end-group
"/Users/hanyazou/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-objcopy" -O binary "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/Blink.ino.elf" "/var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/Blink.ino.bin"
Sketch uses 13052 bytes (9%) of program storage space. Maximum is 131072 bytes.
Global variables use 2816 bytes of dynamic memory.
/Users/hanyazou/Documents/Arduino/hardware/Arduino_STM32-hanyazou/tools/macosx/maple_upload cu.usbmodem143411 2 1EAF:0003 /var/folders/b1/159gqtss0vn9gjsspxhl_6840000gn/T/arduino_build_207264/Blink.ino.bin
dfu-util 0.8
dfu-util: Invalid DFU suffix signature

dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Deducing device DFU version from functional descriptor length
Opening DFU capable USB device...
ID 1eaf:0003
Run-time device DFU version 0110
Claiming USB DFU Interface...
Setting Alternate Setting #2 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 1024
Copying data from PC to DFU device

Download [ ] 0% 0 bytes
Download [= ] 7% 1024 bytes
Download [=== ] 14% 2048 bytes
Download [===== ] 21% 3072 bytes
Download [======= ] 29% 4096 bytes
Download [========= ] 36% 5120 bytes
Download [========== ] 43% 6144 bytes
Download [============ ] 50% 7168 bytes
Download [============== ] 58% 8192 bytes
Download [================ ] 65% 9216 bytes
Download [================== ] 72% 10240 bytes
Download [==================== ] 80% 11264 bytesdfu-util: can't detach
processing.app.SerialException: Error opening serial port '/dev/cu.usbmodem143411'.
at processing.app.Serial.<init>(Serial.java:141)
at processing.app.Serial.<init>(Serial.java:78)
at processing.app.SerialMonitor$3.<init>(SerialMonitor.java:95)
at processing.app.SerialMonitor.open(SerialMonitor.java:95)
at processing.app.AbstractMonitor.resume(AbstractMonitor.java:110)
at processing.app.Editor.resumeOrCloseSerialMonitor(Editor.java:2207)
at processing.app.Editor.access$2200(Editor.java:78)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2173)
at java.lang.Thread.run(Thread.java:745)
Caused by: jssc.SerialPortException: Port name - /dev/cu.usbmodem143411; Method name - openPort(); Exception type - Port not found.
at jssc.SerialPort.openPort(SerialPort.java:167)
at processing.app.Serial.<init>(Serial.java:130)
... 8 more
Error opening serial port '/dev/cu.usbmodem143411'.

Download [===================== ] 87% 12288 bytes
Download [======================= ] 94% 13052 bytes
Download [=========================] 100% 13052 bytes
Download done.
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode

Replies

RogerClark Thu May 25, 2017 10:42 am

I’ve updated all the Maple upload scripts with @danieleff’s suggested fix

I’m not sure if it will cause problems for Rick if he is not using the Arduino Serial Terminal, but the worst case should just be a short delay (timeout)

hanyazou Thu May 25, 2017 12:18 pm

Sorry for late reply. I get back home now.
But my mac and blue-pill requires this change.

echo -n Waiting for ${dummy_port_fullpath} serial...

COUNTER=0
while [ ! -c ${dummy_port_fullpath} ] && ((COUNTER++ < 40)); do
sleep 0.1
done

+ sleep 0.3
echo Done

danieleff Thu May 25, 2017 1:52 pm

Can you check changing -c to -r?

hanyazou Thu May 25, 2017 2:09 pm

No. It fails also if it lacks ‘sleep 0.3’

COUNTER=0
while [ ! -r ${dummy_port_fullpath} ] && ((COUNTER++ < 40)); do
sleep 0.1
done
#sleep 0.3

RogerClark Thu May 25, 2017 9:28 pm

I wonder if this is all Macs or just one specific model.

If its all Macs the additional sleep could be added to the Mac script, but 0.3 may not be enough for slow machines.

What CPU speed etc is your Mac, and what version of OSX are you using.

I have an old machine running Yosemite that I can test with, but I dont have time at the moment

hanyazou Fri May 26, 2017 12:14 pm

My mac is iMac late 2012 3.4GHz Intel Core i7 and OS version is Mac OSX 10.12.4.

This works well on my Mac.

echo -n wait for ${dummy_port_fullpath}...
COUNTER=0
while ! dd if=${dummy_port_fullpath} of=/dev/null count=0 > /dev/null 2>&1 && ((COUNTER++ < 40)); do
sleep 0.1
done
echo done.

ag123 Fri May 26, 2017 8:20 pm

i’m not too sure if /usr/bin/test or /bin/test exists on macos, but i’d guess
[ ! -r ${dummy_port_fullpath} ]

RogerClark Fri May 26, 2017 9:35 pm

hanyazou wrote:My mac is iMac late 2012 3.4GHz Intel Core i7 and OS version is Mac OSX 10.12.4.

This works well on my Mac.

echo -n wait for ${dummy_port_fullpath}...
COUNTER=0
while ! dd if=${dummy_port_fullpath} of=/dev/null count=0 > /dev/null 2>&1 && ((COUNTER++ < 40)); do
sleep 0.1
done
echo done.

Sign in to reply