Re: BeagleBone Black doesn't boot without serial console (10.0 release)

Manuel Bouyer <[email protected]>
Newsgroups gmane.os.netbsd.ports.arm
Message-ID <[email protected]>
On Sun, Oct 13, 2024 at 04:01:22PM +0200, Dr. Nicola Mingotti wrote:
> 
> 
> 
> On Fri-11-Oct-2024 14:36, Manuel Bouyer wrote:
> >  From the schematic here:
> > https://github.com/beagleboard/BeagleBone-Black/blob/master/BBB_SCH.pdf
> > 
> > there is a pulldown resitor on UART0_RX input. This means that without
> > a (powered up) USB/serial adapter, UART0_RX sees a logical 0 which
> > is most probably interpreted as a BREAK by the AM335x UART, and causes
> > the kernel to enter DDB.
> > 
> > The solution is to either rebuild a kernel without DDB, or tie UART0_RX to
> > a +3.3V pin.
> > Or patch the kernel sources like this:
> > 
> > Index: com.c
> > ===================================================================
> > RCS file: /cvsroot/src/sys/dev/ic/com.c,v
> > retrieving revision 1.382
> > diff -u -p -u -r1.382 com.c
> > --- com.c	9 Dec 2022 00:35:58 -0000	1.382
> > +++ com.c	11 Oct 2024 12:33:45 -0000
> > @@ -2647,7 +2647,8 @@ comcnattach1(struct com_regs *regsp, int
> >   	cn_tab = &comcons;
> >   	cn_init_magic(&com_cnm_state);
> > -	cn_set_magic("\047\001"); /* default magic is BREAK */
> > +	// cn_set_magic("\047\001"); /* default magic is BREAK */
> > +	cn_set_magic("+++++");
> >   	comcons_info.frequency = frequency;
> >   	comcons_info.type = type;
> > @@ -2734,7 +2735,8 @@ com_kgdb_attach1(struct com_regs *regsp,
> >   		 * expects this to be initialized
> >   		 */
> >   		cn_init_magic(&com_cnm_state);
> > -		cn_set_magic("\047\001");
> > +		// cn_set_magic("\047\001");
> > +		cn_set_magic("+++++");
> >   	}
> >   	kgdb_attach(com_kgdb_getc, com_kgdb_putc, NULL);
> > 
> 
> Manuel, your proposed solution has been tested working.
> 
> This means i can plug and unplag the UART in J1 on BBB without entering
> the debugger, the active ssh connection remains alive, and from the
> other side of the "serial" (my computer) everything works after the
> plug-unplug,
> it still can type commands.
> 
> As far (or as little) as i can understand, when i connect the UART to J1
> by default "a signal" i generated which is the same signal that opens the
> debugger.
> 
> With your change the signal generated is different so the debugger does not
> pop up.

Not exactly; the generated signal (a BREAK) is still the same, but
it doens't cause the kernel to enter the debugger any more.
The signal to enter the debugger is now "+++++" (5 plus signs in a row).

> 
> Ok, this works, but it would be very inconvenient for me or anybody else
> to patch the kernel for BBB every time we need to prepare a new device.
> I would be also very annoying to maintain on upgrades etc.
> 
> Would it be any bad to change this line in the main kernel ?
> 
> I don't see the need to call the debugger when a com is connected, but
> I know nothing of kernel debugging/programming so this may be useful to
> somebody else.

Actually it's very convenient to be able to enter DDB from the
console when working on kernel, even when helping a user which doesn't
know how to use the debugger.

As noted by martin, rebuilding a kernel with
options CNMAGIC="\"+++++\""
in the config file should have the same effect.

What should the CNMAGIC default be ? Maybe it's time to change it, because
some hardware sends spurious BREAK (when disconnecting a USB/serial
adapter for example) and because some hardware cannot send a BREAK on demand
(e.g. Dell's idrac). But this is something that should be discussed first.

-- 
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.