I have this system which is accessed by a serial Debug Port. I want to disable all of the output, that was made during the U-Boot boot. Therefore there is the
setenv silent 1
parameter, which i put into the BOOTCMD string like:
#define CONFIG_BOOTCOMMAND " setenv silent 1;" \
"bootm "
and there is the
#define CONFIG_SILENT_CONSOLE
command, neither one is working (the lines printed out are still the same and the boot time didn't change). Does somebody see the error ?
For my target, U-Boot baseline 2013.10, silent environment variable works at kernel boot time, but it needed more defines:
#define CONFIG_SILENT_CONSOLE
#define CONFIG_SYS_DEVICE_NULLDEV
#define CONFIG_SILENT_CONSOLE_UPDATE_ON_SET
That also killed kernel serial console after successful boot, until I added
#define CONFIG_SILENT_U_BOOT_ONLY
Refer to README.silent for more info.
U-Boot is doing exactly what it should (silencing the output) with the following command:
#define CONFIG_EXTRA_ENV_SETTINGS \
"silent=1\0" \
see also
Related
I'm testing simple MPI programs locally on my Ubuntu Focal server (Open MPI 4.0.3). However whatever I run with mpirun it produces an annoying message No protocol specified. The problem appears to be related to the fact that mpirun is trying to connect to the X server. How can I disable this behavior so I can use mpirun without a X server ready? I primarily work over SSH (text-only, with tmux).
An example of what I'm doing:
ubuntu#iBug-Server:~$ cat test.c
#include <mpi.h>
int main(int argc, char **argv) {
MPI_Init(&argc, &argv);
// This is a stub program
MPI_Finalize();
return 0;
}
ubuntu#iBug-Server:~$ mpicc test.c
ubuntu#iBug-Server:~$ mpirun -np 2 a.out
No protocol specified
ubuntu#iBug-Server:~$
Update 1: It appears to be related to LightDM and Xorg. The unwanted message goes away after systemctl stop lightdm. Alternatively, running Open MPI in a graphical terminal (connected via VNC or RDP (xrdp), both work) also eliminates the message, as strace shows that the connection to the X server is successful.
I'm using .NET Core on an embedded Linux platform with good success so far. I just ran into a problem with trying to open a tty device in raw (noncanonical mode) though. If I was using regular C or C++ I would call cfmakeraw() after opening the device, but how do I do that from a .NET Core app?
The device I need to work with is a CDC ACM function driver for the USB client connector, i.e. it's a virtual COM port. It appears in my system as /dev/ttyGS0. I can open the device and then read from it and write to it using this code:
FileStream vcom = new FileStream("/dev/ttyGS0", FileMode.Open);
Because the tty device opens in canonical mode by default I don't receive any characters until the user sends the carriage return character at the end of the line of text. I need to receive each character as it is sent, rather than waiting untill the carriage return is sent, i.e. I need to use raw mode for the tty device.
The code below does not work because .NET Core does not realize that this device is a virtual serial port, so it throws an exception when I try to open it this way. When I open the real UART devices using SerialPort then they do behave in raw mode as expected.
SerialPort serialPort = new SerialPort("/dev/ttyGS0);
Since you have a terminal device, you could try to alter its termios configuration prior to actually using it.
Try issuing the shell command stty -F /dev/ttyGS0 raw before you run your program.
The raw setting will make the following termios changes (according to the stty man page) for noncanonical mode:
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixany -ixoff -imaxbel
-opost
-icanon -isig -xcase -iuclc
min 1 time 0
Note that no c_cflag attributes (e.g. baudrate, parity, character size) nor echo attributes (as you already know) are changed by the raw setting.
For comparison the libc cfmakeraw() routine that you mention makes the following termios settings:
t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
t->c_oflag &= ~OPOST;
t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
t->c_cflag &= ~(CSIZE|PARENB);
t->c_cflag |= CS8;
t->c_cc[VMIN] = 1; /* read returns when one char is available. */
t->c_cc[VTIME] = 0;
You can use stty -F /dev/ttyGS0 sane to restore the terminal to a default termios configuration.
I want to compile and transfer an Arduino program by myself on a Leonardo board.
Everything works great with the Arduino official IDE. I have enabled verbose mode for compiling and bytecode transfer.
I can see each command line.
I want to understand each line.
Everything is good except last step: transfer with AVRDUDE. If I type exactly the same command, I get an error:
.avrdude: butterfly_recv(): programmer is not responding
This error is not present if I upload code with the Arduino IDE.
I can see a difference - the Arduino IDE displays this line before the AVRDUDE call:
Forcing reset using 1200 bps open/close on port /dev/cu.usbmodem1431
How can I make this reset by command line?
I had the same issue on macOS, and I came up with the following Bash script:
# Find the Arduino port
ARDUINO_UPLOAD_PORT="$(find /dev/cu.usbmodem* | head -n 1)"
# Reset the Arduino
stty -f "${ARDUINO_UPLOAD_PORT}" 1200
# Wait for it...
while :; do
sleep 0.5
[ -c "${ARDUINO_UPLOAD_PORT}" ] && break
done
# ...upload!
avrdude "${OPTIONS[#]}"
The while loop is the trick! It's going to proceed as soon as the Arduino port is back online.
This is part of a Makefile I wrote for the project Sesame.
For uploading from Windows, I made a bat file wrapper for AVRDUDE.
It identifies the Leonardo COM port with WMI, resets this COM port to 1200 baud with the MODE command, identifies the bootloader COM port and invokes AVRDUDE.
The firmware is supposed to be placed in firmware.hex, but it can be changed to be supplied from the command line.
Code is in a GitHub repository, Arduino Leonardo Uploader
Or below:
#echo off
setlocal
for /f "tokens=1* delims==" %%I in ('wmic path win32_pnpentity get caption /format:list ^| find "SparkFun Pro Micro"') do (
call :resetCOM "%%~J"
)
:continue
:: wmic /format:list strips trailing spaces (at least for path win32_pnpentity)
for /f "tokens=1* delims==" %%I in ('wmic path win32_pnpentity get caption /format:list ^| find "Arduino Leonardo bootloader"') do (
call :setCOM "%%~J"
)
:: end main batch
goto :EOF
:resetCOM <WMIC_output_line>
:: sets _COM#=line
setlocal
set "str=%~1"
set "num=%str:*(COM=%"
set "num=%num:)=%"
set port=COM%num%
echo %port%
mode %port%: BAUD=1200 parity=N data=8 stop=1
goto :continue
:setCOM <WMIC_output_line>
:: sets _COM#=line
setlocal
set "str=%~1"
set "num=%str:*(COM=%"
set "num=%num:)=%"
set port=COM%num%
echo %port%
goto :flash
:flash
avrdude -v -C./avrdude.conf -patmega32u4 -cavr109 -P%port% -b57600 -D -V -Uflash:w:./firmware.hex:i
I had the same problem. I've tried opening and closing the ACM0 port with a Python script at 1200 baud, as someone already mentioned. It didn't work for me. Then I have received half-advice to try toggling RTS/DTS and that will make autoreset. So in the end I found the solution (at least for me) on Linux Mint 18.2 (Sonya):
#! /usr/bin/python
import sys
import serial
com = serial.Serial(sys.argv[1], 1200)
com.dtr=False
com.close()
python ./reset.py "/dev/ttyACM0"
dmesg shows me:
[21850.047120] cdc_acm 1-1:1.0: ttyACM0: USB ACM device
[22093.700327] usb 1-1: USB disconnect, device number 53
[22094.034133] usb 1-1: new full-speed USB device number 54 using xhci_hcd
[22094.175377] usb 1-1: New USB device found, idVendor=2341, idProduct=0036
[22094.175381] usb 1-1: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[22094.175384] usb 1-1: Product: Arduino Leonardo
[22094.175387] usb 1-1: Manufacturer: Arduino LLC
[22094.175964] cdc_acm 1-1:1.0: ttyACM0: USB ACM device
On Windows, in a command prompt, the same solution, slightly different batch file:
It determines the bootloader COM port as well. Note that just only the Leonardo to be flashed should be connected!
#echo off
echo Upgrade procedure starting.
if %1.==. goto error
set hexfile=%1
set comportA=NONE
set comportB=NONE
if not exist %hexfile% goto error
for /f "usebackq" %%B in (`wmic path Win32_SerialPort Where "Caption LIKE '%%Leonardo%%'" Get DeviceID ^| FIND "COM"`) do set comportA=%%B
if %comportA%==NONE goto nodevice
echo COM port for Arduino device is detected as %comportA%.
echo Reset Arduino into bootloader
mode %comportA%: baud=12 > nul
timeout 2 > nul
for /f "usebackq" %%B in (`wmic path Win32_SerialPort Where "Caption LIKE '%%Leonardo%%'" Get DeviceID ^| FIND "COM"`) do set comportB=%%B
if %comportB%==NONE goto nobldevice
echo COM port for Arduino bootloader device is detected as %comportB%.
echo.
echo Starting AVR Downloader/UploaDEr.....
avrdude -pm32u4 -cavr109 -D -P%comportB% -b57600 -Uflash:w:%hexfile%
goto upgradedone
:nodevice
echo No matching module found, you should connect the module you want to upgrade.
goto end
:nobldevice
echo Reset into bootloader failed, please try again...
goto end
:error
Echo Missing parameter or file, you should provide the full filename of an existing .hex file you want to use.
goto end
:upgradedone
echo.
echo Upgrade done!
:end
I use this for Nano-every:
I think the essential elements are:
configure appropriate com port at 1200 baud with DTR = ON
Turn DTR off.
Flash device with correct version of avrdude and avrdude.config. My version came with the installation of my Nano-every device.
For other boards, it might be different. Lines 1, 2 reset the port and I think this is independent of the board, but change the port number!
c:\windows\system32\mode.com com6: baud=1200 dtr=on
c:\windows\system32\mode.com com6: dtr=off
C:\Users\Ludo\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\Ludo\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega4809 -cjtag2updi -PCOM6 -b115200 -e -D -Uflash:w:C:\Users\Ludo\AppData\Local\Temp\arduino_build_385557/sketch_dec11a.ino.hex:i -Ufuse2:w:0x01:m -Ufuse5:w:0xC9:m -Ufuse8:w:0x00:m {upload.extra_files}
Well, you pretty much wrote the answer yourself.
You need to open a serial connection at 1200 baud to the Arduino and then close the connection. The Arduino will then boot into SAM-BA, and reset itself, and is now ready for a new program.
I had the same problem with arduino leonardo.
I want to share my solution for people wanting to solve this problem using Qt.
Here is solution ready to be copy and paste, also taking care of timeout:
#include <QtCore/QString>
#include <QtCore/QDebug>
#include <QtCore/QThread>
#include <QtCore/QElapsedTimer>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
bool forceResetComPort(const QString& portName)
{
QSerialPort serial;
serial.setPortName(portName);
serial.setBaudRate(1200);
qDebug() << "Forcing reset using 1200bps open/close on port ") << portName;
if(!serial.open(QIODevice::ReadWrite))
return false;
// This seems optional
serial.setDataTerminalReady(false);
qDebug() << "Waiting for the new upload port...";
QElapsedTimer timeoutWatcher;
qint64 timeoutMs = 10000;
bool isPortPresent = true;
const auto fetchIsPortPresent = [&]() -> bool
{
const auto ports = QSerialPortInfo::availablePorts();
for(const auto& info : ports)
{
if(info.portName() == serial.portName())
return true;
}
return false;
};
timeoutWatcher.start();
// Wait for port to disconnect
while(isPortPresent && !timeoutWatcher.hasExpired(timeoutMs))
{
isPortPresent = fetchIsPortPresent();
if(isPortPresent)
QThread::msleep(1);
}
serial.close();
// Wait for port to reconnect
while(!isPortPresent && !timeoutWatcher.hasExpired(timeoutMs))
{
isPortPresent = fetchIsPortPresent();
if(!isPortPresent)
QThread::msleep(1);
}
return !timeoutWatcher.hasExpired(timeoutMs);
}
It is all about timing. I really needed to wait for the serial port to disconnect to close serial.
Closing too fast didn't have any effect.
Closing too slow, the usb serial was reconnecting but with a different port name. (For example /dev/ttyACM0 to /dev/ttyACM1).
It's important to wait for the port to reconnect in my case because I call avrdude in QProcess after.
Here is dmesg:
[ 8566.623621] cdc_acm 1-8:1.0: failed to set dtr/rts
[ 8566.979697] usb 1-8: new full-speed USB device number 21 using xhci_hcd
[ 8567.133193] usb 1-8: New USB device found, idVendor=2341, idProduct=0036, bcdDevice= 0.01
[ 8567.133197] usb 1-8: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[ 8567.133199] usb 1-8: Product: Arduino Leonardo
[ 8567.133200] usb 1-8: Manufacturer: Arduino LLC
[ 8567.134820] cdc_acm 1-8:1.0: ttyACM0: USB ACM device
(Wow it took me a while to post this question because of the formatting problem coming from special characters..)
I'm trying to bring up virtual terminal on our embedded system's LCD usnig USB keyboard which is also connected to the system. I have UART connection to my PC so I've been using UART for console till now but I want to switch to framebuffer console on LCD during the boot at some point..
The USB host controller seems to work fine because I've seen USB memory is attached, read and written ok. And when I connect a keyboard and print the events at keyboard_event function, it prints events that seem normal and corresponding to my action(type of key, press or release..)
I have a feeling that it's a configuration problem. In init/main.c, there is
run_init_process(ramdisk_execute_command);
(In my case, ramdisk_execute_command = "/sbin/init")
And this immediately calls
kernel_execve(init_filename, argv_init, envp_init);
// above, init_filename and argv_init are "/sbin/init" same.
I expect busybox to run after this.. (ramdisk had been installed before by a bootloader-like part) but I cannot see any prints on the LCD after this point. But I can see printks on the LCD until just before calling kernel_execve above. I'm using linux 3.3.
I understand I have to open a frame buffer console on LCD and connect it to a tty but I don't know how. Below are printed the current releavant settings.
(In serial UART connection case, linux boots ok up to the final busybox shell prompt printing things in busybox initialization after kernel_execve call. and #cat /proc/fb0 returns 0 for your info. Only LCD/framebuffer console mode stops after kernel_execve.)
#### arch/sparc/boot/ourprocessor/prom_stage.c : #####
// "console=ttyS,mmio,0xff003000,115200n8 " <== serial port case
"console=tty " <= frame buffer console case (below line too)
"fbcon=font:SUN8x16,map:0000 " <= Is this boot argment correct?..
#### sbin/init: #####
#!/bin/busybox sh
export LD_LIBRARY_PATH=/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/nand/lib
exec /bin/busybox init
### rcS #####
mknod /dev/tty0 c 4 0 <== Do I need to explicitly make tty0 and tty1 like this?
mknod /dev/tty1 c 4 1
mknod /dev/tty2 c 4 2
mknod /dev/tty3 c 4 3
mknod /dev/tty4 c 4 4
### .config #####
CONFIG_FRAMEBUFFER_CONSOLE=y <= LCD/framebuffer console case. Otherwise none.
CONFIG_FONT_SUN8x16=y
CONFIG_LOGO=y
By the way, I'm not using /etc/inittab.(so use default init). The busybox init/init.c code says if there isn't the inittab file and console is not the serial port, it runs
tty2::askfirst:/bin/sh
tty3::askfirst:/bin/sh
tty4::askfirst:/bin/sh
(starting shell on tty 2, 3 and 4) then How do make tty2's shell appear on the LCD/framebuffer/framebuffer console? It's confusing and books are not so kind..
Any hint would be deeply appreciated.
This question was solved months ago and I forgot to answer to this question myself.
Adding CONFIG_FRAMEBUFFEr and CONFIG_FBCONSOLE and setting console=ttyS,.. was all that is necessary. In my case, I had another bug in DMA that was causing the frambe buffer console's text not appear on the LCD. So I can use 3 virtual consoles on the LCD (switch using Alt-F2, Alt-F3, .. ) by default. Long storyg short, console is a console(on serial port), and we have 3 (by default busybox setting) virtual console on the LCD.
Is it possible to pipe serial console output to a file or a buffer or some virtual or pseudo device (in /dev)?
The Kernel command line has in startup at this point "console=null,115200".
(Normally it has "console=ttyS0,115200" - my requirement is: if "console=null,115200", should the output go to some other place than ttyS0, e.g. a virtual or pseudo device or to a file/buffer)
Maybe somebody know if there is good solution available?
Thanks a lot in advance!
There are two ways that I am aware of :-
First way :-
get ttylog from sourceforge :-
http://sourceforge.net/projects/ttylog/files/latest/download
Fire the below command:-
nohup ttylog -b 115200 -d /dev/ttyS0 > log.txt
this will then show you the PID of the process that is running, you now need to disown that PID so it doesn't get killed when you log out. Note that 115200 is the serial port speed/baud rate you configured grub for on the box you are monitoring.
Second way :-
Setup a serial console from system under test to some other linux/windows box. In case of linux install minicom and set minicom to listen on the serial port define in grub of system under test. Save that as dfl. You are good to go for more info :-
https://www.kernel.org/doc/Documentation/serial-console.txt