Hi all,
I’m trying to get back into some embedded development using RTEMS after a number of years away and have resurrected an old project using the Beaglebone black as a starting point.
I have built the latest RTEMS and have some test applications running on the board ok, but today I was trying to build a basic UI task and try as I might I can’t read input from the console.
I’m using the following code in the Init task:
char buf[80] = "";
char *cmd, *sval, *rval;
printf("cmd: ");
rval = fgets(buf, 80, stdin);
if (rval == NULL) {
printf("fgets returned NULL\n");
} else {
printf("fgets returned %s\n", rval);
}
printf("buf = %s\n", buf);
cmd = strtok(buf, " \t\n");
printf("cmd = %s\n", cmd);
which outputs:
Starting kernel ...
RTEMS Beagleboard: am335x-based
ARM Debug: 0x4b141000
Starting Motor Testing
cmd: fgets returned NULL
buf =
cmd = (null)
I know the hardware connections are fine as I can use the Linux console ok.
Am I doing something stupid, or is the console driver for this BSP not working as expected?
Many thanks for any advice you can provide!
Cheers,
James
I just wanted to follow up this post to mention you posted on discord you found the BBB’s console driver does not support termios
and this was the reason the code does not work.
Hi Chris,
Thanks for following up. Yes I have done further investigation and discovered that the Beaglebone black BSP console driver doesn’t accept input in interrupt mode. I rebuilt the BSP in polled mode and that does work.
Ideally I’m after a version that works correctly in interrupt mode, so I’m currently investigating writing a new termios compatible version of the console driver to replace the current legacy driver.
I’ve been looking at the raspberrypi and stm32h7 BSPs to see how they do it, but if anyone has any other suggestions they’d be most welcome.
Cheers,
James
Could you please raise an issue for this?
Thanks
Hi Chris,
No problem, I’ll raise an issue for this later today.
Cheers,
James
I’ve raised the issue here:
I couldn’t add a arch or bsp label to the issue for some reason - maybe a permissions thing?
I’ve been investigating trying to write a termios console driver for the beaglebone bsp per the documentation:
In order to trying and fill in some of the gaps I’ve been looking at the raspberrypi and riscv bsps which both implement this type of driver and use the ns16550 low level driver which is what I’m trying to use for the beaglebone.
I can’t figure out what actually calls the console_initialize function. Can someone explain this to me please?
Also, I note that both the raspberrypi and riscv BSP console-config.c files have something like this at the bottom:
RTEMS_SYSINIT_ITEM(
uart_probe,
RTEMS_SYSINIT_BSP_START,
RTEMS_SYSINIT_ORDER_LAST_BUT_5
);
This appears to add the function to configure the console hardware into the startup process, but the uart_probe function is also called inside console_initialize. Why is this additional RTEMS_SYSINIT_ITEM necessary and doesn’t this mean the uart_probe function will get called twice?
I’ve scoured the internet and the RTEMS documentation and can’t find the answers to these questions. I clearly don’t understand the RTEMS initialisation process well enough but I would really appreciate it if someone could shed some light on this for me!
Cheers,
James