Page MenuHomeFreeBSD

early KDB access on QorIQ
Needs RevisionPublic

Authored by int0dster_gmail.com on Aug 23 2016, 2:58 AM.
Referenced Files
Unknown Object (File)
Mar 15 2024, 10:09 PM
Unknown Object (File)
Dec 20 2023, 12:50 AM
Unknown Object (File)
Nov 9 2023, 1:10 AM
Unknown Object (File)
Nov 8 2023, 12:28 PM
Unknown Object (File)
Nov 6 2023, 12:12 PM
Unknown Object (File)
Oct 19 2023, 9:18 PM
Unknown Object (File)
Oct 19 2023, 9:17 PM
Unknown Object (File)
Oct 19 2023, 4:32 AM

Details

Reviewers
jhibbits
Summary

This change allows usage of KDB through serial line on Freescale QorIQ systems while system console
is not initialized yet.

Test Plan
  1. Build FreeBSD kernel for any QorIQ (for example T2080)2
  2. Build kernel
  1. 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: #############

  1. ############# ############# ############# ############# ############# ############# ############# ##############
	 2.7 MiB/s

done
Bytes transferred = 9380324 (8f21e4 hex)

>

  1. Run kernel

go 0x4001000

  1. 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]

WARNING: WITNESS option enabled, expect reduced performance. VT: init without driver. cpu0: Freescale e6500 core revision 0.0, 1533.33 MHz cpu0: Features dc008000<PPC32,PPC64,ALTIVEC,FPU,MMU,BOOKE> cpu0: HID0 80800000<EMCP,DOZE> real memory = 2124398592 (2025 MB) available KVA = 996249599 (950 MB) Physical memory chunk(s): 0x001600000 - 0x07dc1efff, 2086793216 bytes (509471 pages) avail memory = 2075365376 (1979 MB) panic: lock "bufwait" 0xdff81050 already initialized cpuid = 0 KDB: stack backtrace: 0xc2608940: at kdb_backtrace+0x5c 0xc2608960: at vpanic+0x1d4 0xc26089d0: at kassert_panic+0xd4 0xc2608a30: at lock_init+0x70 0xc2608a70: at lockinit+0xf0 0xc2608aa0: at vm_pager_bufferinit+0xe0 0xc2608ae0: at ptrace_set_pc+0x19c 0xc2608b00: at mi_startup+0x184 0xc2608b50: at __start+0x1b8 KDB: enter: panic [ thread pid 0 tid 0 ] Stopped at kdb_enter+0x70: addi r0, r0, 0x0 db> db> db> ? ? db> p c02f03f8 db> help alltrace b break bt c call capture continue countfreebufs d delete dhwatch dump dwatch em_dump_queue em_reset_dev examine findstack gdb halt hwatch kill kldstat match next p panic print ps reboot reset run s script scripts search set show step t

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

int0dster_gmail.com retitled this revision from to early KDB access on QorIQ.
int0dster_gmail.com updated this object.
int0dster_gmail.com edited the test plan for this revision. (Show Details)
int0dster_gmail.com set the repository for this revision to rS FreeBSD src repository - subversion.
int0dster_gmail.com added a project: PowerPC.

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 = ...
early_getc_t early_getc = ...

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.

Ok, then go with configuration option. I will submit second revision of the patch

int0dster_gmail.com edited edge metadata.

Address reviewer comments

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.

jhibbits edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Aug 26 2016, 11:23 AM

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.

jhibbits requested changes to this revision.Sep 8 2016, 2:00 PM
jhibbits edited edge metadata.

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.

This revision now requires changes to proceed.Sep 8 2016, 2:00 PM