This change allows usage of KDB through serial line on Freescale QorIQ systems while system console
is not initialized yet.
Details
- Reviewers
jhibbits
- Build FreeBSD kernel for any QorIQ (for example T2080)2
- Build kernel
- boot kernel
> tftpboot 0x4000000 k0
Using FM1@DTSEC3 device
TFTP from server 192.168.2.23; our IP address is 192.168.2.22
Filename 'k0'.
Load address: 0x4000000
Loading: #############
- ############# ############# ############# ############# ############# ############# ############# ##############
2.7 MiB/s
done
Bytes transferred = 9380324 (8f21e4 hex)
>
- Run kernel
go 0x4001000
- Once kernel hits KDB - ensure that it responds on your input
> go 0x4001000
Starting application at 0x04001000 ...
HELLO FROM t2080 FREEBSD!!
Copyright (c) 1992-2016 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 12.0-CURRENT #40 9d6a66c(master)-dirty: Sun Aug 21 12:15:46 PDT 2016
root@int0dh-home:/usr/obj/powerpc.powerpc/usr/home/int0dh/WORK/freebsd.original/sys/AMIGAX5000 powerpc
gcc version 4.2.1 20070831 patched [FreeBSD]
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
I like this change. Just a couple nits I noted, and move the TLB mapping into this diff, making it conditional on EARLY_PRINTF. As part of that, add a option to the config, via sys/conf/options.powerpc, calling it something like EARLY_UART_BASE, or such. In a conf file, it would be used as follows:
options EARLY_UART_BASE=0xffe11c000ull
sys/powerpc/mpc85xx/platform_mpc85xx.c | ||
---|---|---|
83–84 | These should probably be wrapped by #ifdef EARLY_PRINTF | |
145 | Superfluous blank line here. | |
601–602 | These aren't defined anywhere, only declared. These need to be: early_putc_t early_putc = ... Otherwise it doesn't compile. |
Thank you much for the feedback.
BTW, wouldn't it be better to have something like "early console driver" which could take advantage
of FDT and pick up UART address from there ? It would be desirable to avoid hardcoding of fluid things
ike device address in any place.
I thought about that, but concluded that it's not really possible, for a few reasons:
- It's possible we may need to print something before fdt is available, or, if the fdt itself is having problems that we need to diagnose
- This is typically used for early bringup phases, so doesn't necessarily need to be included in a shipping kernel, so a compile-time option is sufficient.
sys/powerpc/booke/pmap.c | ||
---|---|---|
3419 | One more minor tweak: use a macro instead of a naked constant. It'll be easier to follow down the road to see something like EARLY_UART_VA in all three places instead of the constant. |
Why isn't the normal console getc working? You should be able to get input when cninit is called. This seems to happen before kdb_init is called on powerpc.
Why isn't the normal console getc working? You should be able to get input when cninit is called. This seems to >happen before kdb_init is called on powerpc.
At the moment of cninit() call only gdb_console is in the cons_set, which is quite useless in terms of UART input/output, basically it does nothing more
but puts the flow into some memory buffer. After cninit() is called, gdb_console gets
chosen and it just ignores any output flow (and input flow too). After UART
driver gets up and running it starts taking care on it. May be there is a sense to never zero early_getc and early_putc in cninit(), but do so in appropriate console driver instead.
After thinking it over for the last week or so, I think it's best to make early_getc a weak symbol (extern __weak ....), and check for symbol existence in the two places in kern_cons.c. This allows existing EARLY_PRINTF implementations to continue to work without modification.