[Solved]screen /dev/ttyACM0 on STM32L4R9IDISC

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
ndhuy
Posts: 23
Joined: Mon Nov 04, 2019 8:01 am

[Solved]screen /dev/ttyACM0 on STM32L4R9IDISC

Post by ndhuy » Tue Nov 12, 2019 8:24 am

Hi everyone,

I'm Huy. Currently, i am working on a project about writing micropython on the board STM32L4R9IDISC.

Because the board is not supported. Therefore, my team and i had to write 4 files:mpconfigboard.h, mpconfigboard.mk, pins.csv, stm32l4xx_hal_conf.h . we also wrote linker files:stm32l4r9i_af.csv, stm32l4r9xg.ld.

We then "make BOARD=STM32L4R9IDISC" and we met a bunch of errors which were mostly and mainly fixed by "defined STM32L4R9xx" and adjust the name of some pins. We finally made it and successfully "make BOARD=STM32L4R9".

I also successfully flashed the board by STLink-utility.

However, as i inserted "screen /dev/ttyACM0" in the terminal of Ubuntu, a completely black screen appeared. I don't know where to check the error.

Did anyone experience this error and had a way to fix that?

Thank you very much, Huy
Last edited by ndhuy on Thu Dec 05, 2019 1:32 am, edited 1 time in total.

User avatar
jimmo
Posts: 869
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: screen /dev/ttyACM0 on STM32L4R9IDISC

Post by jimmo » Tue Nov 12, 2019 9:16 am

My approach would probably be to try and use the st-link debugger (using whatever tools you're familiar with -- I use openocd and gdb) to figure out what the code is doing and why it's not working.

You probably want to enable -Og and -g in CFLAGS (look in stm32/Makefile).

It might be something simple like the UART and REPL configuration... is the ttyACM0 device the st-link VCP or is the USB connected to the L4R9?

And just to be sure (because I've fallen for this) is is definitely the right baud rate and have to tried pressing return to get the prompt to print out again?

ndhuy
Posts: 23
Joined: Mon Nov 04, 2019 8:01 am

Re: screen /dev/ttyACM0 on STM32L4R9IDISC

Post by ndhuy » Tue Nov 12, 2019 9:28 am

Hi Jimmo,

About the first one, i will give it a try.

Could you please be more specific about the second and the third one?

And the fourth, i set the baud rate in the file i wrote is 115200. How can i know is that the right one or another one is correct?

Thank you, Huy

chrismas9
Posts: 124
Joined: Wed Jun 25, 2014 10:07 am

Re: screen /dev/ttyACM0 on STM32L4R9IDISC

Post by chrismas9 » Tue Nov 12, 2019 10:08 pm

Have you enabled USB? If so short BOOT0 to 3V3 and plug USB into PC. Use the USB OTG-FS port with power to the STlink port. The board should appear as STM32 in DFU mode (or something similar, not sure how it appears in Linux). Thus will verify your USB. If USB is enabled your REPL will be on USB virtual COM port and you will need two USB cables - one for STlink and power and one for REPL.

If not using USB then you need to specify a REPL serial port in mpconfigboard.h that is either connected to the STlink COM port or a direct serial link to host.

Post your mpconfigboard.h here.

User avatar
jimmo
Posts: 869
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: screen /dev/ttyACM0 on STM32L4R9IDISC

Post by jimmo » Tue Nov 12, 2019 10:54 pm

ndhuy wrote:
Tue Nov 12, 2019 9:28 am
Could you please be more specific about the second and the third one?
2. If you're using the debugger, you need symbols and it helps to not use full optimisation (otherwise the code that's running looks nothing like your original code). So those two flags (-g enabled debug symbols, -Og enables "debugging-safe optimisations).
Look in stm32/Makefile for the comment "# Debugging/Optimization". i.e. "make DEBUG=1 BOARD=FOO". I'd recommend using -Og instead of its -O0.

3. I mean, how are you connceted by USB. Is it via the st-link interface on the board, or directly to the STM32L4 chip?
ndhuy wrote:
Tue Nov 12, 2019 9:28 am
And the fourth, i set the baud rate in the file i wrote is 115200. How can i know is that the right one or another one is correct?
So if you're using 115200 in the config, then you also need to connect to it with that. So "screen /dev/port 115200".

ndhuy
Posts: 23
Joined: Mon Nov 04, 2019 8:01 am

Re: screen /dev/ttyACM0 on STM32L4R9IDISC

Post by ndhuy » Wed Nov 13, 2019 2:39 am

chrismas9 wrote:
Tue Nov 12, 2019 10:08 pm
Have you enabled USB? If so short BOOT0 to 3V3 and plug USB into PC. Use the USB OTG-FS port with power to the STlink port. The board should appear as STM32 in DFU mode (or something similar, not sure how it appears in Linux). Thus will verify your USB. If USB is enabled your REPL will be on USB virtual COM port and you will need two USB cables - one for STlink and power and one for REPL.

If not using USB then you need to specify a REPL serial port in mpconfigboard.h that is either connected to the STlink COM port or a direct serial link to host.

Post your mpconfigboard.h here.
Hi Chrismas9,

Thanks for your reply

Well, i suppose that the board is connected to my laptop. As i checked Device Manager/Ports and Device Manager/Universal Serial Bus, they both showed the sign of the board being connected to the laptop. I used STM32 ST-LINK Utility to connect ("connect under reset" mode in Target/Setting as i first tried to connect the board via ST-LINK Utility) and further i could flash the board. SO i guess the problem of connection is not the case here.

Also, because i did not set up dual bootloader ubuntu but i use parallel OS via virtual machine VMWare. Thus everytime i plug the microUSB cable to my laptop, in the VMWare, it asks me whether i want to connect to the host (Window) or the virtual machine (VMWare/Ubuntu).

The below is the mpconfigboard.h (sorry i could not attach the .h file in this so i have to use Snipping Tool). I wrote this file based on the structure of the mpconfigboard.h of STM32L496 as i found some similarity between 2 boards. But the pins and other content, i relied mainly on the datasheet of STM32L4R9I Disco.
Attachments
Screen Shot 2019-11-13 at 9.38.13 AM.png
Screen Shot 2019-11-13 at 9.38.13 AM.png (248.02 KiB) Viewed 334 times
Last edited by ndhuy on Wed Nov 13, 2019 3:32 am, edited 1 time in total.

ndhuy
Posts: 23
Joined: Mon Nov 04, 2019 8:01 am

Re: screen /dev/ttyACM0 on STM32L4R9IDISC

Post by ndhuy » Wed Nov 13, 2019 3:32 am

jimmo wrote:
Tue Nov 12, 2019 10:54 pm
ndhuy wrote:
Tue Nov 12, 2019 9:28 am
Could you please be more specific about the second and the third one?
2. If you're using the debugger, you need symbols and it helps to not use full optimisation (otherwise the code that's running looks nothing like your original code). So those two flags (-g enabled debug symbols, -Og enables "debugging-safe optimisations).
Look in stm32/Makefile for the comment "# Debugging/Optimization". i.e. "make DEBUG=1 BOARD=FOO". I'd recommend using -Og instead of its -O0.

3. I mean, how are you connceted by USB. Is it via the st-link interface on the board, or directly to the STM32L4 chip?
ndhuy wrote:
Tue Nov 12, 2019 9:28 am
And the fourth, i set the baud rate in the file i wrote is 115200. How can i know is that the right one or another one is correct?
So if you're using 115200 in the config, then you also need to connect to it with that. So "screen /dev/port 115200".

Hi Jimmo,

Thanks for your reply

I guess to perform the 2, I have to have the ST-Link Debugger, which is a in-circuit debugger - a device as i did some researches. It might take several days for shipping. But there is something different: when i accessed stm32/Makefile, at the section # Debugging/Optimization, the code are:
ifeq ($(DEBUG), 1)
CFLAGS += -g -DPENDSV_DEBUG
COPT = -O0
else
COPT += -Os -DNDEBUG
endif
Nowhere i could find something similar to your "make DEBUG=1 BOARD=FOO".

About the 3, I use the microUSB cable to connect the board (via USB STLINK port embedded on the board) with my laptop. There are 2 microUSB port on this board: USB STLink (the one i use to connect the board) and OTG-FS. As i used Device Manager to check the connection, the board was connected to the laptop. First I used STLink - Utility to flash the board. Every time i plug the microUSB to my laptop, there is a window appearing in VMWare (an application i use to run virtual machine) to ask me whether i want to connect the board with the host (Window) or the virtual machine (Ubuntu).


I tried to type in screen /dev/ttyACM0 115200 but there is still nothing appear. I do notice that when i plugged the STM32F4DISC in my laptop, there were 4 files: boot.py, main.py, pybcdc.inf, README.txt. However, when i connected STM32L4R9IDISC, there were only 2 files: DETAILS.TXT, MBED.HTM. I don't know why this happened and i guess probably this is one of the reasons why i could not write uPython on the board.
Last edited by ndhuy on Wed Nov 13, 2019 3:44 am, edited 1 time in total.

User avatar
jimmo
Posts: 869
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: screen /dev/ttyACM0 on STM32L4R9IDISC

Post by jimmo » Wed Nov 13, 2019 3:40 am

ndhuy wrote:
Wed Nov 13, 2019 3:32 am
I guess to perform the 2, I have to have the ST-Link Debugger, which is a in-circuit debugger - a device as i did some researches. It might take several days for shipping.
You already have one, it's built into your board! i.e. it's the ST Link you're already using to program and access the UART.
ndhuy wrote:
Wed Nov 13, 2019 3:32 am
I tried to type in screen /dev/ttyACM0 115200 but there is still nothing appear. I do notice that when i plugged the STM32F4DISC in my laptop, there were 4 files: boot.py, main.py, pybcdc.inf, README.txt. However, when i connected STM32L4R9IDISC, there were only 2 files: DETAILS.TXT, MBED.HTM. I don't know why this happened and i guess probably this is one of the reasons why i could not write uPython on the board.
On the F4 board, you're seeing the MicroPython USB device (on the F4 chip itself).

On the L4 board, you're seeing the ST-link's USB device (i.e. you're plugged into the st-link on the board). Try using the other USB port (which should connect to the L4)

ndhuy
Posts: 23
Joined: Mon Nov 04, 2019 8:01 am

Re: screen /dev/ttyACM0 on STM32L4R9IDISC

Post by ndhuy » Wed Nov 13, 2019 7:46 am

jimmo wrote:
Wed Nov 13, 2019 3:40 am
ndhuy wrote:
Wed Nov 13, 2019 3:32 am
I guess to perform the 2, I have to have the ST-Link Debugger, which is a in-circuit debugger - a device as i did some researches. It might take several days for shipping.
You already have one, it's built into your board! i.e. it's the ST Link you're already using to program and access the UART.
ndhuy wrote:
Wed Nov 13, 2019 3:32 am
I tried to type in screen /dev/ttyACM0 115200 but there is still nothing appear. I do notice that when i plugged the STM32F4DISC in my laptop, there were 4 files: boot.py, main.py, pybcdc.inf, README.txt. However, when i connected STM32L4R9IDISC, there were only 2 files: DETAILS.TXT, MBED.HTM. I don't know why this happened and i guess probably this is one of the reasons why i could not write uPython on the board.
On the F4 board, you're seeing the MicroPython USB device (on the F4 chip itself).

On the L4 board, you're seeing the ST-link's USB device (i.e. you're plugged into the st-link on the board). Try using the other USB port (which should connect to the L4)
Hi Jimmo,

Sorry for interrupting your instruction.

I did notice that when i connected VMWare/Ubuntu to F4 board, everytime i press reset, the Ubuntu did respond to the pressing (it asks me again whether i want to connect to Ubuntu or Window). But when i connected the L4 board and press reset button, it did not respond the same. Maybe the connection is not there between L4 and Ubuntu.

User avatar
Roberthh
Posts: 1729
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: screen /dev/ttyACM0 on STM32L4R9IDISC

Post by Roberthh » Wed Nov 13, 2019 9:14 am

The support of USB devices by virtual machines is a different sad story. I consider it as simply unreliable. If it work - fine. If not, i cannot deduct anything from that.

Post Reply