I am currently using uboot to boot linux kernel. I have not mentioned ttyS0 or anything in the console parameter. I get to see the output only when there is not console parameter while if I specify the console parameter the log stops after "Starting Kernel...". So I was trying to find if the linux kernel uses the u-boot serial driver to print and get characters. But when I make a small change or add a print statement in the driver I can see that change till the u-boot command line while I cannot see these when Linux is started. I am wondering which driver is being used to print data and get data from the console.
Edit(1) : After some working with the TTY Driver I am now getting print statements on console. See log below :
[ 0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x84000000
[ 0.000000] Linux version 5.5.0-rc1-00032-g264b43306b8c-dirty (venkatakrishnan#venkatakrishnan-ubuntu) (gcc version 10.2.0 (GCC)) #22 Tue Jul 27 15:02:20 IST 2021
[ 0.000000] initrd not found or empty - disabling initrd
[ 0.000000] Zone ranges:
[ 0.000000] DMA32 [mem 0x0000000084000000-0x000000008fffffff]
[ 0.000000] Normal empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000084000000-0x000000008fffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000084000000-0x000000008fffffff]
[ 0.000000] software IO TLB: mapped [mem 0x8bd5b000-0x8fd5b000] (64MB)
[ 0.000000] elf_hwcap is 0x1105
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 48480
[ 0.000000] Kernel command line: console=ttySHAKTI0,19200n8 earlycon root=/dev/mmcblk1p1 rw rootfs=ext4 noinitrd selinux=0
[ 0.000000] Dentry cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[ 0.000000] Sorting __ex_table...
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 112684K/196608K available (3868K kernel code, 199K rwdata, 702K rodata, 9856K init, 233K bss, 83924K reserved, 0K cma-reserved)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
[ 0.000000] plic: mapped 29 interrupts with 1 handlers for 2 contexts.
[ 0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0]
[ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1ef4687b1, max_idle_ns: 112843571739654 ns
[ 0.001342] sched_clock: 64 bits at 32kHz, resolution 30517ns, wraps every 70368744171142ns
[ 0.011474] Calibrating delay loop (skipped), value calculated using timer frequency.. 0.06 BogoMIPS (lpj=131)
[ 0.016326] pid_max: default: 32768 minimum: 301
[ 0.077301] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.082397] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.482940] devtmpfs: initialized
[ 1.069976] random: get_random_bytes called from setup_net+0x54/0x1dc with crng_init=0
[ 1.123840] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[ 1.129333] futex hash table entries: 256 (order: 0, 6144 bytes, linear)
[ 1.213317] NET: Registered protocol family 16
[ 1.639770] Shakti UART Probing started...
[ 1.669952] 11300.uart: ttySHAKTI0 at MMIO 0x11300 (irq = 0, base_baud = 0) is a Shakti UART 0
[ 234.333038] printk: console [ttySHAKTI0] enabled
[ 235.845855] clocksource: Switched to clocksource riscv_clocksource
[ 236.541534] NET: Registered protocol family 2
[ 236.840209] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[ 237.152709] TCP established hash table entries: 2048 (order: 2, 16384 bytes, linear)
[ 237.442626] TCP bind hash table entries: 2048 (order: 2, 16384 bytes, linear)
[ 237.703186] TCP: Hash tables configured (established 2048 bind 2048)
[ 237.953887] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 238.188140] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 238.492340] NET: Registered protocol family 1
[ 268.344238] workingset: timestamp_bits=62 max_order=15 bucket_order=0
[ 281.773803] ntfs: driver 2.1.32 [Flags: R/W DEBUG].
[ 282.271209] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
[ 282.536315] io scheduler mq-deadline registered
[ 282.675445] io scheduler kyber registered
[ 282.983062] io scheduler bfq registered
[ 304.778137] Error: Driver 'shakti-uart' is already registered, aborting...
[ 305.379852] shakti_spi 20100.spi: Shakti SPI Driver initialized
[ 306.020507] libphy: Fixed MDIO Bus: probed
[ 306.185424] xilinx_emaclite 44000.ethernet: Device Tree Probing
[ 306.439025] libphy: Xilinx Emaclite MDIO: probed
[ 306.686065] xilinx_emaclite 44000.ethernet: MAC address is now 00:0a:35:00:00:00
[ 307.191101] xilinx_emaclite 44000.ethernet: Xilinx EmacLite at 0x00044000 mapped to 0x04010000, irq=29
[ 307.796661] mmc_spi spi0.0: SD/MMC host mmc0, no DMA, no WP, no poweroff, cd polling
[ 308.229644] NET: Registered protocol family 17
[ 311.828765] Freeing unused kernel memory: 9856K
[ 311.968719] This architecture does not have kernel memory protection.
[ 312.218292] Run /init as init process
[ 313.042419] mmc0: host does not support reading read-only switch, assuming write-enable
[ 313.339843] mmc0: new SDHC card on SPI
[ 314.152679] mmcblk0: mmc0:0000 SS08G 7.40 GiB
[ 315.783752] mmcblk0: p1
I am still wondering that I am not able to see the login prompt and I can see this console being used as log console where the printk statements are only printed(similar to dmesg command). Also for input do we need to register interrupts and use that to being data in or is there any polling method possible?
I get to see the output only when there is not console parameter while if I specify the console parameter the log stops after "Starting Kernel...".
That implies that
a. when you do specify a console, that device or its driver is not functioning as expected.
and
b. when you do not specify a console, the kernel is defaulting to a serial terminal that it found capable of
acting as a system console.
As documented in Documentation/admin-guide/serial-console.rst:
If no console device is specified [in the command line], the first device found capable
of acting as a system console will be used.
...
So if you don't have a VGA card in your system the first serial port will automatically
become the console.
So I was trying to find if the linux kernel uses the u-boot serial driver to print and get characters.
As already mentioned, the Linux kernel will not execute code outside its own image.
However there is the "low-level kernel debugging" feature (CONFIG_DEBUG_LL and its friends) (that may be architecture dependent) that will utilize a UART already initialized by the bootloader. This feature requires the hardcoding of device addresses so that the kernel is immediately capable of displaying text messages without having to perform any device initialization.
The EARLYPRINTK feature depends on this pre-initialized serial port.
I am wondering which driver is being used to print data and get data from the console.
Displaying kernel messages is a separate functionality from "get data from the console".
The kernel console is essentially an ouput-only device. For example on a PC, Linux can use the VGA display adapter as the console; a display adapter has no input capability. The console is merely a device for the kernel to display its messages.
The console=... kernel parameter does not setup/configure an interactive terminal. A kernel console on UART typically does not even have input capability. The struct console does allow a read function (for input), but drivers/tty/serial/ drivers don't implement it.
The capability to login on a serial terminal is provided by using the getty command (in userspace); study Documentation/admin-guide/serial-console.rst.
As an experiment, I booted a Linux ARM SBC, but edited the bootargs variable so that there was no console=ttyS0... parameter in the command line.
Kernel boot messages were displayed anyway over the serial link, there was a printk: console [tty0] enabled message, and after the UART driver was initialized, the message printk: console [ttyS0] enabled was displayed.
Booting Linux on physical CPU 0x0
Linux version 5.4.81-linux4sam-2020.10 (oe-user#oe-host) (gcc version 9.3.0 (GCC)) #1 Thu Jan 14 12:54:56 UTC 2021
...
Kernel command line: root=/dev/mmcblk0p1 rw rootfstype=ext4 rootwait atmel.pm_modes=standby,ulp1
...
Switching to timer-based delay loop, resolution 96ns
Console: colour dummy device 80x30
printk: console [tty0] enabled
Calibrating delay loop (skipped), value calculated using timer frequency.. 20.75 BogoMIPS (lpj=103750)
...
atmel_usart_serial.0.auto: ttyS0 at MMIO 0xf8020000 (irq = 35, base_baud = 5187500) is a ATMEL_SERIAL
printk: console [ttyS0] enabled
...
So this kernel defaults to using the first serial terminal for the console as documented: "If no console device is specified, ... the first serial port will automatically become the console."
Your boot log has the following
[ 0.000000] Linux version 5.5.0-rc1-00032-g264b43306b8c-dirty (venkatakrishnan#venkatakrishnan-ubuntu) (gcc version 10.2.0 (GCC)) #22 Tue Jul 27 15:02:20 IST 2021
...
[ 0.000000] Kernel command line: console=ttySHAKTI0,19200n8 earlycon root=/dev/mmcblk1p1 rw rootfs=ext4 noinitrd selinux=0
...
[ 1.639770] Shakti UART Probing started...
[ 1.669952] 11300.uart: ttySHAKTI0 at MMIO 0x11300 (irq = 0, base_baud = 0) is a Shakti UART 0
[ 234.333038] printk: console [ttySHAKTI0] enabled
So it appears that the specification of console=ttySHAKTI0... was effective, since the kernel reports that the console is enabled for /dev/ttySHAKTI0.
The specification of earlycon in the command line seems to be ineffective, since that typically generates an appropriate message, and there is not any such message.
If you expect to login using /dev/ttySHAKTI0, then that would depend on a fully-functioning serial terminal driver (i.e. a UART driver that supports termios functions), and a proper /etc/inittab entry that (repeatedly) executes (or respawns) getty (or a variant) on that terminal device.
For example my Linux ARM SBC has:
S0:12345:respawn:/bin/start_getty 115200 ttyS0 vt102
where start_getty is a script used to automatically set up the serial terminal(s) for login on startup.
This login specification is independent of the console=... kernel parameter. But convention is to use the same device for both duties, which can cause confusion as to what a "console" is.
Goal: emulate the "sabrelite : Freescale i.MX6 Quad SABRE Lite Board (Cortex A9)" that Qemu specifically supports (doing 'qemu-system-arm -M ?' it shows up).
Qemu ver: 2.10.1 (host: fedora-27).
I have successfully cross-compiled and built a 4.1.46 Linux kernel (used the imx_v6_v7_defconfig config file) as well as a simple "skeleton" root filesystem (busybox-based). (FYI, I have a similar working setup for the ARM Cortex-A9 Versatile Express platform - I do this using my own home-spun embedded Linux system called SEALS).
Looking at the U-Boot config file used by similar boards, I figured to use 'root=/dev/mmcblk0p0' as the root= param for the kernel.
So, to try it out I then run qemu as follows (pl scroll horizontally as well to see):
qemu-system-arm -m 512 -M sabrelite -kernel zImage -drive file=rfs.img,format=raw -append "console=ttymxc0 rootfstype=ext4 root=/dev/mmcblk0p0 rw rootwait init=/sbin/init " -nographic -dtb imx6dl-sabresd.dtb
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 4.1.46 (kai#klaptop) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29) ) #2 SMP Mon Nov 27 17:16:22 IST 2017
[ 0.000000] CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c5387d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[ 0.000000] Machine model: Freescale i.MX6 DualLite SABRE Smart Device Board
[ 0.000000] cma: Reserved 16 MiB at 0x2f000000
[...]
So it starts to boot up just fine. But then:
[...]
[ 2.210965] /soc/aips-bus#02100000/usdhc#02194000: voltage-ranges unspecified
[ 2.211796] sdhci-esdhc-imx 2194000.usdhc: Got CD GPIO
[ 2.212199] sdhci-esdhc-imx 2194000.usdhc: Got WP GPIO
[ 2.214392] sdhci-esdhc-imx 2194000.usdhc: could not get ultra high speed state, work on normal mode
[ 2.218084] sdhci-esdhc-imx 2194000.usdhc: No vmmc regulator found
[ 2.218367] sdhci-esdhc-imx 2194000.usdhc: No vqmmc regulator found
[ 2.265431] mmc0: SDHCI controller on 2194000.usdhc [2194000.usdhc] using ADMA
[ 2.267300] mmc0: mmc_rescan_try_freq: trying to init card at 400000 Hz
[ 2.281912] /soc/aips-bus#02100000/usdhc#02198000: voltage-ranges unspecified
[ 2.282956] sdhci-esdhc-imx 2198000.usdhc: Got CD GPIO
[ 2.283703] sdhci-esdhc-imx 2198000.usdhc: Got WP GPIO
[ 2.284044] sdhci-esdhc-imx 2198000.usdhc: could not get ultra high speed state, work on normal mode
[ 2.284892] sdhci-esdhc-imx 2198000.usdhc: No vmmc regulator found
[ 2.285167] sdhci-esdhc-imx 2198000.usdhc: No vqmmc regulator found
[ 2.298029] mmc0: mmc_rescan_try_freq: trying to init card at 300000 Hz
[ 2.337904] mmc1: SDHCI controller on 2198000.usdhc [2198000.usdhc] using ADMA
[ 2.357051] /soc/aips-bus#02100000/usdhc#0219c000: voltage-ranges unspecified
[ 2.358313] sdhci-esdhc-imx 219c000.usdhc: No vmmc regulator found
[ 2.358642] sdhci-esdhc-imx 219c000.usdhc: No vqmmc regulator found
[ 2.368204] mmc0: mmc_rescan_try_freq: trying to init card at 200000 Hz
[ 2.414722] mmc2: SDHCI controller on 219c000.usdhc [219c000.usdhc] using ADMA
[ 2.440456] mmc0: mmc_rescan_try_freq: trying to init card at 100000 Hz
[...]
[ 2.986441] No soundcards found.
[ 3.007698] Waiting for root device /dev/mmcblk0p0...
Keeps waiting forever here ...
I understand that, on an actual physical board, one would have to "format" or partition the MMC (or SD) card, and have u-boot load up the kernel and rootfs into RAM. But am currently interested in getting the IMX6 working on Qemu...
So, my actual question: how can I get the root filesystem mounted and operational on Qemu?
Any help appreciated! TIA,
There are two problems here. Firstly, your command line isn't actually creating an SD card: the -drive option creates a drive object but doesn't try to plug it in anywhere (because the sabrelite board doesn't define a "default kind of block drive"). To actually plug in the drive to an emulated sd card you need
-drive file=yourfile.img,format=raw,id=mycard -device sd-card,drive=mycard
Secondly, there are bugs in QEMU's current imx6 sd controller emulation, because if you do that then the guest kernel continuously prints
[ 28.971663] mmc1: Timeout waiting for hardware interrupt.
[ 28.973619] mmc1: error -110 whilst initialising SD card
...so it has found the emulated card but isn't getting an interrupt it expects.
These can be fixed by a patch currently on the qemu-devel mailing lists and going through code review: http://patchwork.ozlabs.org/patch/834805/ plus a simple change to hw/arm/fsl-imx6.c to make it create TYPE_IMX_USDHC devices rather than TYPE_SYSBUS_SDHCI. (Basically the imx6's SD controller isn't a completely standard compatible sdhci controller but what we were creating in the QEMU model was the plain variety.)
If you do all that then you can boot a kernel that can see the mmc card:
[ 8.878283] mmc1: new SD card at address 4567
[ 8.910566] mmcblk0: mmc1:4567 QEMU! 256 MiB
With a little luck we'll be able to have this fixed in the 2.12 release of QEMU, which will be out in some time in spring 2018.
Edit as of 9 Mar 2018 -- the relevant fixes are now in QEMU master (commits fd1e5c81796, df2a5cf4c8) and will be in 2.12.
I am booting a pre-built FIT image from a vendor's SDK (NXP SDK2.0) on an ARM reference platform (ls1046ardb). This .itb image contains 'kernel#1', 'fdt#1', and 'ramdisk#1'.
During boot I see a CRC check failure on the FDT. Is this failure common and expected? Although it's always possible, I wouldn't expect a vendor's pre-built images to be corrupted.
[ 3.600660] fsl_generic: FSL DPAA Generic Ethernet driver
[ 3.606246] rtc-pcf2127 1-0051: pcf2127_get_datetime: read error
[ 3.612256] rtc-pcf2127 1-0051: hctosys: unable to read the hardware clock
[ 3.619213] fdt: not creating '/sys/firmware/fdt': CRC check failed
[ 3.625868] RAMDISK: gzip image found at block 0
[ 4.508215] VFS: Mounted root (ext2 filesystem) readonly on device 1:0.
[ 4.514883] devtmpfs: mounted
The boot command (from u-boot) is,
kernel_load=0xa0000000
ext2load mmc 0 $kernel_load kernel.itb
bootm $kernel_load
Any help would be appreciated. I don't see many references to this type of error on the net.
I've a device on which I've a 3.10 linux kernel booting up to a busybox shell (initramfs)
When I extracted the busybox filesystem image on the SD card and when modified the root from root=/dev/ram to /dev/mmcblck0p1, it still boots up to the shell
So the busybox works fine but if I try to use any other FS the kernel would crash...
While I try to generate a rootfs using debootstrap (https://help.ubuntu.com/community/DebootstrapChroot) and have the new rootfs extracted on the SD card. I get an error saying "Failed to execute /sbin/init"
I did check if the file is present and also checked the permissions and it looks good to me.
What could be the problem?
W.R.T rootfs I'm particularly new. I was assuming that any FS on the SD card could be mounted but looks like its not the case. I'm guessing that whatever the /sbin/init will be doing is device dependent?
What I am trying to do? --->
I need to make a rootfs with a few packages and libraries (gcc python etc..) What would a normal approach? I've even tried buildroot but I couldn't get gcc on target. Is it not possible to have gcc in /bin/ within buildroot?
-- UPDATE --
I'm formatting the SD card to ext4 format and following is the output of fdisk
Disk /dev/sdb1: 7945 MB, 7945588224 bytes
255 heads, 63 sectors/track, 965 cylinders, total 15518727 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc2aa4908
Device Boot Start End Blocks Id System
And following are the kernel logs while I have a filesystem on the SD card. The memory card driver works fine I've verified that. If I have a busybox filesystem on the SD card, everything works fine. When I'm using any other file systems I get the following...
6EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
6VFS: Mounted root (ext4 filesystem) on device 179:1.
6Freeing unused kernel memory: 84K (c0f00000 - c0f15000)
3request_module: runaway loop modprobe binfmt-464c
4kworker/u2:4 (145) used greatest stack depth: 6132 bytes left
3Failed to execute /sbin/init. Attempting defaults...
3request_module: runaway loop modprobe binfmt-464c
3request_module: runaway loop modprobe binfmt-464c
0Kernel panic - not syncing: No init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
When checked, there is /sbin/init with the appropriate permissions that too!
Consider this error: "request_module: runaway loop modprobe binfmt-464c"
In all probability you're trying to use 64b binaries (/sbin/init and the rest) with 32b only kernel. Either recompile your kernel to support 64b or install a 32b user space onto your sd card.
Other things to check:
Confirm that elf support is indeed enabled in your kernel (it normally is, but it is possible to disable it).
Google that error and see what sort of problems people were having with it.
I want to suspend and resume my Beagleboard C4.
I checked out the latest Angstrom kernel using,
git clone git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6.git linux-omap-2.6
But the kernel is not booting properly. It is stuck at
[ 4.755645] EXT3-fs (mmcblk0p2): recovery complete
[ 4.991027] EXT3-fs (mmcblk0p2): mounted filesystem with ordered data mode
[ 4.999023] VFS: Mounted root (ext3 filesystem) readonly on device 179:2.
[ 5.006652] Freeing init memory: 304K
[ 6.316253] EXT3-fs (mmcblk0p2): using internal journal
Has anyone resolved this issue?
I compiled the kernel directly on the beagleboard. Same result.
I compiled the kernel using toolchain. Same result.
Is it something related to the u-boot/File system?