The console has nothing to do with input, only with output
Model
Both the serial port and LCD can be used as output, so it can be used as a console
Output without console mechanism: Serial port
Just use serial_puts to print information to the serial port
Output without console mechanism: lcd
Just use lcd_puts to print information to the LCD
console
Register serial_puts and lcd_puts to the console mechanism
Call console_puts provided by console to print information
Whether to print to the serial port or LCD depends on the configuration of the console.
How does U-boot handle this?
Before board_init_f->console_init_f
gd->have_console is 0
The serial port is also initialized
No output can be done at this time (printf is usually called for output). The information output by printf is in memory.
After board_init_f->console_init_f, before board_init_r->console_init_r
gd->have_console is now 1
gd->flags & GD_FLG_DEVINIT == 0
The serial port has been initialized
The information previously output in the memory has been printed to the serial port
At this time, the information output by printf is on the serial port, and serial_puts is called.
After board_init_r->console_init_r
gd->have_console is now 1
gd->flags & GD_FLG_DEVINIT == 1
The serial port has been initialized and registered (init_sequence_r->stdio_add_devices->drv_system_init->stdio_register) to the console system
The lcd has been initialized and registered (init_sequence_r->stdio_add_devices->drv_lcd_init->stdio_register) to the console system
At this time, the output can be output (the output usually calls printf)
At this time, the information output by printf may be output to the LCD or serial port according to the settings, and console_puts is called
console_puts then calls serial_puts or lcd_puts
Details stage
stdio_register
In fact, it is to mount the struct stdio_dev structure to the end of the global variable static struct stdio_dev devs;
console_init_r
console_init_r has two implementations depending on whether SYS_CONSOLE_IS_IN_ENV is defined
SYS_CONSOLE_IS_IN_ENV // Y if CONSOLE_MUX is Y
This allows multiple input/output devices to be set up at boot time.
For example, if stdout is set to "serial,video" then output will be sent to both the serial and video devices at boot time.
Environment variables can be updated after boot to change input/output devices.
CONSOLE_MUX // VIDEO/DM_VIDEO/LCD is Y, then Y
This allows the use of multiple devices per console "file".
For example, stdout can be set to go to both serial and video.
Similarly, stdin can be set to come from both serial and keyboard.
Input can be provided from any source.
Console multiplexing adds a small amount of size to U-Boot.
Changes to the environment variables stdout, stdin, and stderr take effect immediately.
console_init_r SYS_CONSOLE_IS_IN_ENV when defined
// Problem: outputdev is found, but how to use outputdev in printf
console_init_r
stdinname = env_get("stdin");
stdoutname = env_get("stdout");
// stdoutname can be lcd,serial0@7F005000
// can be lcd
// can be serial0@7F005000
// If there is a comma (,) it means there are two stdout devices
stderrname = env_get("stderr");
iomux_err = iomux_doenv(stdin, stdinname);
iomux_err += iomux_doenv(stdout, stdoutname);
for_each_consoledevice
console_devices[console] = (struct stdio_dev **)realloc(console_devices[console], cs_idx * sizeof(struct stdio_dev *));
memcpy(console_devices[console], cons_set, cs_idx * sizeof(struct stdio_dev *));
cd_count[console] = cs_idx;
iomux_err += iomux_doenv(stderr, stderrname);
stdio_print_current_devices
gd->flags |= GD_FLG_DEVINIT;
print_pre_console_buffer(flushpoint);
console_init_r SYS_CONSOLE_IS_IN_ENV is not defined
consumer
console_puts
for (i = 0; i < cd_count[file]; i++)
dev = console_devices[file][i];
dev->puts(dev, s);
Console Settings
Correct Setup
Set the environment variables in the u-boot environment to output on the LCD
Only LCD output // When set like this, the serial port also has output, because the program has been modified 8c24d5adfbc43826246716e41f964f0467c1cfd6
// BUG at this time: some miscellaneous data (promot data) will come out on the serial port
env set stdout lcd
s
Only serial output
// No problems at this time
env set stdout serial0@7F005000
s
Both output // When set like this, the serial port prints twice because the program has been modified 8c24d5adfbc43826246716e41f964f0467c1cfd6
// The timing is not satisfied at this time (because the LCD needs to be written immediately after getc from the serial port, and the next character cannot be getc from the serial port at this time)
env set stdout "lcd,serial0@7F005000" // Every time printf/puts is executed, output from lcd first
env set stdout "serial0@7F005000,lcd" // Every time printf/puts is executed, output from serial first
s
Wrong settings
env set stdout bbb
## Error inserting "stdout" variable, errno=22
bbb is not a stdout device and cannot be set like this
env set stdout parsing
It must be something like iomux_doenv
//TODO
Previous article:OK6410A development board (eight) 4 linux-5.11 OK6410A peripheral driver
Next article:OK6410A development board (eight) 2 linux-5.11 OK6410A linux development environment construction
Recommended ReadingLatest update time:2024-11-15 01:55
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Power supply quality resource sharing, free points download this week
- [NXP Rapid IoT Review] + Mobile Synchronizer 6
- Solution to the problem that the TI 280049 LaunchPad emulator cannot connect
- Voiceprint collection system based on Pingtouge RVB2601
- How to improve the execution efficiency of microcontroller programs?
- Latest interpretation: What is Wi-Fi 7?
- 【GD32L233C-START Review】17. Completed work: Indoor environment monitoring equipment
- [Atria AT32WB415 Series Bluetooth BLE 5.0 MCU] Part 3: Lightble Control OLED Display
- Car sunlight sensor, urgent help
- Communication Principles_matlab.pdf