minosproject / minos

Flexible Virtualization Solution for Embedded System
http://minosproject.org
GNU General Public License v2.0
247 stars 92 forks source link

Unable to get hypervisor console in Raspberry Pi 3B #13

Closed aananthcn closed 3 years ago

aananthcn commented 4 years ago

I followed the minos-hypervisor build instructions for Raspberry Pi 3B. I also followed the patches referred in https://github.com/minosproject/minos/issues/12.

I could not get the hypervisor console by pressing Ctrl + d. But if I leave the system idle for about 2 hours, I get this console. Let me know what additional information you need.

aananthcn commented 4 years ago

Additional information: After 2 hours, when I get the hypervisor console prompt, I am able to attach to the guest by using tty attach vm0 command. But some of the commands such as ps, top, free doesn't generate outputs.

minos # tty attach vm0
Attach tty: vm0 press any key to active the console
minos # 

^C
pi@raspberrypi:~$ ps
^C
pi@raspberrypi:~$ ls /dev/
autofs           initctl             ram12   tty19  tty48      vcs1
block            input               ram13   tty2   tty49      vcs2
...
pi@raspberrypi:~$ ls
Bookshelf  Documents  minos  Pictures  Templates
Desktop    Downloads  Music  Public    Videos
pi@raspberrypi:~$ echo "Hi Aananth"
Hi Aananth
pi@raspberrypi:~$ top
^C
pi@raspberrypi:~$ free
^C
pi@raspberrypi:~$
lemin9538 commented 4 years ago

I see so many ^C, have you type Ctrl-C ?

you mean you can not get the hypervisor console after system boot without waiting for system idle ?

aananthcn commented 4 years ago

Yes, for those few commands, I have to press Ctrl + c to get back to the command prompt. Otherwise, the system freezes for those commands. Please note that the commands top, ps and free worked "as expected" before the system went to idle.

Yes for the 2nd question too. Unless the system goes to idle, I did not get the hypervisor control even after pressing Ctrl + d.

lemin9538 commented 4 years ago

Could you help to fix this issue?

RP4 can works good, the Uart controller in rpi3b is same as RPI4. Currently I have no RPI3B board can use.

aananthcn commented 4 years ago

Yes I think, but help me how to proceed :-), Ctrl + d seems to be picked up by the Linux guest as 'logout' event. Are there any specific patch you added in RPi4 to pick up this event to switch console?

lemin9538 commented 4 years ago

No specific patch for rpi4. The event handler code is in hypervisor under app/eh/shell. C

aananthcn commented 4 years ago

Sorry for the delay. In the code snippet below (drivers/serial/serial_bcm283x_mu.c), I don't see prints from line number 65 at all.

 58 char bcm283x_mu_getc(void)
 59 {
 60         pr_notice("Debug-Aananth ~ %s() : %d\n", __func__, __LINE__);
 61         if (!(ioread32(serial_base + AUX_MU_LSR) &
 62                                 BCM283X_MU_LSR_RX_READY))
 63                 return 0;
 64         
 65         pr_notice("Debug-Aananth ~ %s() : %d\n", __func__, __LINE__);
 66         return ioread32(serial_base + AUX_MU_IO);
 67 }

This means, the function call console_getc() (apps/esh/shell.c) always gets 0 as return value and the for {} loop in shell_task() breaks at line 92. What could be the cause for ioread32() call in serial_bcm283x_mu.c:61 failing?

 88         while (1) {
 89                 for (; ;) {
 90                         ch = console_getc();
 91                         if (ch <= 0) 
 92                                 break;
~~~~~~~~~~~~~~~~~~~~~~~~
110                 }
111 
112                 msleep(10);
113         }
aananthcn commented 4 years ago

Is the address specified in the definition (shown below) in include/config/config.h correct? #define CONFIG_UART_BASE 0x3f215040

In BCM2835 ARM Peripherals manual from Broadcom in page 8, I could see that the UART1 (the debug uart) base address as: 0x7E21 5040

aananthcn commented 4 years ago

Is the address specified in the definition (shown below) in include/config/config.h correct? #define CONFIG_UART_BASE 0x3f215040

In BCM2835 ARM Peripherals manual from Broadcom in page 8, I could see that the UART1 (the debug uart) base address as: 0x7E21 5040

The address seems to be not a problem (I am not sure). But I suspect 2 other areas:

  1. Receive interrupts flag is not set. I could see commented code in bcm283x_mu_init() function, which may be the reason why the bcm283x_mu_getc() always returns 0.
  2. The shell.c::shell_task() expects a tty=vm0 as boot argument, which I didn't had it before in u-boot. If this bootarg is not added, then open_tty() is never called.

I am still analysing the code and user manual of RPi3 chip.

lemin9538 commented 4 years ago

👍🏻 the address is on. Now we are using polling mode, do not use interrupt.

aananthcn commented 4 years ago

Some updates:

1) If I delete the environment variable bootargs in u-boot and start, then I get Press any key to stop vm startup: prompt.

2) If I set bootargs="console=serial0,115200 console=tty1 tty=vm0", then I don't get any boot prompt! It directly goes to VM0 console (i.e, Linux guest).

New suspect: 'console=ttyS0"

lemin9538 commented 4 years ago

New suspect: 'console=ttyS0"

I think this is the point, We need use hvc0 not ttyS0. If use ttyS0 the VM0 will also read/write the uart. You can try remove the uart info in the DTS.

aananthcn commented 4 years ago

Hi LeMin, I replaced 'console=ttyS0' with 'console=hvc0', I could see the switch to hypervisor console happen if I press Ctrl+d. Also attach to VM0 console happens when I type "tty attach vm0" command from minos hypervisor console. But the guest console is not responsive to my inputs. The problem still persists.

aananthcn commented 4 years ago

Update: If I set 'console=hvc0' polling of input via console is not happening. If I set 'console=ttyS0' in bootargs, then polling of input is happening. That explains why the console is not responding with hvc0. Will deep dive further when I find time.

lemin9538 commented 4 years ago

Good job👍

aananthcn commented 4 years ago

Update: suspecting that if I need s390-tools installed on my Linux guest to make the HVC0 to work with minos. I cross-compiled s390-tools/iucvterm and tried running icuvtty binary so that icuvtty could connect to the login program to minos, but I got error shown below: iucvtty: The AF_IUCV address family is not available: Address family not supported by protocol

The above error means 2 things to me: 1) Linux kernel is not configured to support AF_IUCV sockets. 2) Point 1) indirectly means the approach I am taking to solve the non-responding terminal could be incorrect.

icutty-connection

aananthcn commented 4 years ago
  │ Symbol: HVC_CONSOLE [=n]                                                          │
  │ Type  : bool                                                                      │
  │ Prompt: pSeries Hypervisor Virtual Console support                                │
  │   Location:                                                                       │
  │     -> Device Drivers                                                             │
  │ (1)   -> Character devices                                                        │
  │   Defined at drivers/tty/hvc/Kconfig:14                                           │
  │   Depends on: TTY [=y] && PPC_PSERIES                                             │
  │   Selects: HVC_DRIVER [=y] && HVC_IRQ [=y]                                        │

Is HVC_CONSOLE=n (see above) is correct?

lemin9538 commented 4 years ago

pSeries Hypervisor

yes it should be N, it is for pSeries Hypervisor