Linux serial_posix vs. Windows serial_w32

Post here first, or if you can't find a relevant section!
simpleboy
Posts: 19
Joined: Wed Apr 27, 2022 9:01 am
Answers: 1

Re: Linux serial_posix vs. Windows serial_w32

Post by simpleboy »

ag123 wrote: Wed May 25, 2022 5:03 am you did not compile with USB (CDC) Serial selected.
USB Serial from your board did not appear in dmesg

you can actually disconnect the FTDI dongle and just connect your stm32 board to usb.
a USB Serial connection should appear in dmesg
My only option is to compile using FTDI dongle. I'm using a custom board which only has RX and TX terminal. Do you think this might be the issue?
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Linux serial_posix vs. Windows serial_w32

Post by ag123 »

simpleboy wrote: Wed May 25, 2022 7:00 am
ag123 wrote: Wed May 25, 2022 5:03 am you did not compile with USB (CDC) Serial selected.
USB Serial from your board did not appear in dmesg

you can actually disconnect the FTDI dongle and just connect your stm32 board to usb.
a USB Serial connection should appear in dmesg
My only option is to compile using FTDI dongle. I'm using a custom board which only has RX and TX terminal. Do you think this might be the issue?
yes, USB (CDC) Serial is for the on-chip usb (pins pa11, pa12). If you want to use a separate FTDI dongle, then u'd need to use UART for your serial.

based on your dmesg output you posted earlier, the device seemed to be at /dev/ttyUSB0
you can try to connect to it using a serial terminal utility, e.g. https://www.putty.org/
simpleboy
Posts: 19
Joined: Wed Apr 27, 2022 9:01 am
Answers: 1

Re: Linux serial_posix vs. Windows serial_w32

Post by simpleboy »

ag123 wrote: Wed May 25, 2022 7:10 am
simpleboy wrote: Wed May 25, 2022 7:00 am
ag123 wrote: Wed May 25, 2022 5:03 am you did not compile with USB (CDC) Serial selected.
USB Serial from your board did not appear in dmesg

you can actually disconnect the FTDI dongle and just connect your stm32 board to usb.
a USB Serial connection should appear in dmesg
My only option is to compile using FTDI dongle. I'm using a custom board which only has RX and TX terminal. Do you think this might be the issue?
yes, USB (CDC) Serial is for the on-chip usb (pins pa11, pa12). If you want to use a separate FTDI dongle, then u'd need to use UART for your serial.

based on your dmesg output you posted earlier, the device seemed to be at /dev/ttyUSB0
you can try to connect to it using a serial terminal utility, e.g. https://www.putty.org/
When I install putty this message comes up:

Code: Select all

'configure' was unable to find any version of the GTK libraries on
your system. Therefore, PuTTY itself and the other GUI utilities will
not be built by the generated Makefile: only the command-line tools
such as puttygen, plink and psftp will be built.
simpleboy
Posts: 19
Joined: Wed Apr 27, 2022 9:01 am
Answers: 1

Re: Linux serial_posix vs. Windows serial_w32

Post by simpleboy »

On a side note, I notice this. I have script file named "serial_upload" in STM32Tools folder.

It's content is this: (LINUX)

Code: Select all

#!/bin/bash
$(dirname $0)/stm32flash/stm32flash -g 0x8000000 -b 115200 -e 1000 -w "$4" /dev/"$1"

While on the same file "serial_upload.bat" in my Windows version,

The content is this: (WINDOWS)

Code: Select all

@echo off
rem: Note %~dp0 get path of this batch file
rem: Need to change drive if My Documents is on a drive other than C:
set driverLetter=%~dp0
set driverLetter=%driverLetter:~0,2%
%driverLetter%
cd %~dp0
rem: the two line below are needed to fix path issues with incorrect slashes before the bin file name
set str=%4
set str=%str:/=\%
stm32flash\stm32flash.exe -g 0x8000000 -b 115200 -e 1000 -w %str% %1
The windows version works fine while on my Linux the program freeze.

Can you tell the difference?
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Linux serial_posix vs. Windows serial_w32

Post by ag123 »

install putty from your distribution source
e.g. for debian based distributions (e.g. ubuntu)

apt-cache search putty

one of the entry should be
putty - Telnet/SSH client for X

apt-get install putty

you would likely need to add a sudo in front of that

that /dev/$1 you can try patching it to your actual usb serial dev that shows up in your dmesg

note also that we are assuming that you are using the 'official' stm core.
https://github.com/stm32duino/Arduino_Core_STM32
https://github.com/stm32duino/wiki/wiki

you should mention more things to avoid others guessing.
mention the core that you are using and importantly, mention the chip e.g. stm32fxxyy that you are using

that stm32flash seemed to be a 3rd party / open sourced utility bundled. it apparently is setup to program the mcu over uart i.e. with your FTDI dongle
simpleboy
Posts: 19
Joined: Wed Apr 27, 2022 9:01 am
Answers: 1

Re: Linux serial_posix vs. Windows serial_w32

Post by simpleboy »

The problem still occurs on Putty and I also patch it directly to dev/ttyUSB0, still the same.

I'm using an old verion of STM32Core 1.5.0, it has the built-in stm32flash

Image

I'm currently using ACSIP S76S LoRA chip containing an STMicro STM32L073RZ MCU

my Device ID is: (STM32L07xxx/08xxx)
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Linux serial_posix vs. Windows serial_w32

Post by ag123 »

copy out that tools folder, that you found, that stm32flash utility and script can still be used for manual firmware install.

install your core base on this
https://github.com/stm32duino/wiki/wiki/Getting-Started
this is the 'official' stm32duino core.

you would need to select your board (it won't be there), so u'd need to select your *chip*, you may need to make a new variant.
you would also need to know the external crystal (HSE) frequency - i.e. check your schematics.
it is possible to use your board with the same chip (selecting a predefined board), if there is an existing board that is configured to use the same HSE frequency. Otherwise, it means making a new variant, and u'd need to define your
void SystemClock_Config(void) that setup the HSE for your on board crystal frequency.
if you aren't particular about using an external crystal, you may be able to use a 'generic' variant that matches your chip.
external crystals is mainly for usb, which needs to be at 48 Mhz exact. If it drift, usb may fail.

note also that the 'official' stm32duino core uses
https://www.st.com/en/development-tools ... eprog.html
which is a separate install.
In Linux, I made do with various public domain or open sourced utilities to install my firmware, e.g. that stm32flash
but this needs to be done manually and u'd need to know how to use it if you use your own tools.
In the Arduino IDE, the binary can normally be generated using Tools > export compiled binary, and the binary should be left in your project folder.
Manual install is just an extra step on the command line, I find that it is ok and you use your own commands so there is less of a 'black box' when you try to install the binary. I prefer this as well, as I normally reinstall my binaries manually from the command line, and I won't need Arduino IDE for that.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Linux serial_posix vs. Windows serial_w32

Post by fpiSTM »

I don't think it is link to upload tools. You can simply try to flash the windows generated binary using the command line on Linux.
and vice versa.
My guess is the USB implementation done on Linux wit 1.5.0 has probably an issue.
Since core version 1.5.0 there is a lot of work, I would suggest to port your "firmware" on the latest version or a least 1.9.0.
simpleboy
Posts: 19
Joined: Wed Apr 27, 2022 9:01 am
Answers: 1

Re: Linux serial_posix vs. Windows serial_w32

Post by simpleboy »

I follow your suggestion to use the official and updated Arduino STM32cores. I also make my own variant. I editted the boards.txt to have it on my board menu. I receive this error. I wonder how to fix it. Thanks in advance.

Image
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Linux serial_posix vs. Windows serial_w32

Post by ag123 »

While you make the variant
there are quite a few dependencies
I'd suggest take a look at how others did it with the custom boards
here is an entry in boards.txt for Piconomix PX-HER0 board
https://github.com/stm32duino/Arduino_C ... .txt#L4184
their specific variant files are found here
https://github.com/stm32duino/Arduino_C ... 083R(B-Z)T
in particular
variant_PX_HER0.cpp
variant_PX_HER0.h
PeripheralPins_PX_HER0.c

In particular, void SystemClock_Config(void) in your variant.cpp file needs to be properly defined if you are using HSE.
You could use codes from existing variants as an example.
The important thing about system clock config is to configure the PLL multipliers (M,N,P,Q) so that the mcu runs at the correct system clock speeds according to the spec for your HSE crystal frequency
here is a python script which can be used to explore the PLL configs.
viewtopic.php?f=41&t=78

review the notes in the wiki as well
https://github.com/stm32duino/wiki/wiki ... 28board%29
Last edited by ag123 on Mon May 30, 2022 7:04 am, edited 1 time in total.
Post Reply

Return to “General discussion”