Port-arm archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Enabling KGDB for AM335x
Hi Lloyd,
Thank you for the feedback, I agree that U-Boot is really the correct
place for this. I'll reach out to their community
to see what the best way to handle this is. I suspect they won't want
to change the device tree defaults, but maybe
there's some command or env variable that can be used to solve this.
I've updated my patch below, I added new params to opt_kgdb.h for
users to specify mux register offsets and values.
I set the defaults to uart1. I also added defaults for the KGDB
rate/mode/address parameters.
Best,
James
=================================================================================
diff -r d708c4dcdd7d sys/arch/arm/ti/files.ti
--- a/sys/arch/arm/ti/files.ti Sun Apr 27 23:30:39 2025 +0000
+++ b/sys/arch/arm/ti/files.ti Sun May 25 21:39:29 2025 -0700
@@ -141,4 +141,12 @@
# SOC parameters
defflag opt_soc.h SOC_TI
defflag opt_soc.h SOC_AM33XX: SOC_TI
-defflag opt_soc.h SOC_OMAP3: SOC_TI
+defflag opt_soc.h SOC_OMAP3: SOC_TI
+
+# Pins may need to be muxed early to enable kgdb console. This should
be done by
+# the bootloader, but in case it isn't then use this option
+defflag opt_kgdb.h TI_EARLY_COM_MUX: SOC_TI,KGDB
+defparam opt_kgdb.h TI_EARLY_COM_RXOFF=0x980
+ TI_EARLY_COM_RXVAL=0x30: TI_EARLY_COM_MUX
+defparam opt_kgdb.h TI_EARLY_COM_TXOFF=0x984
+ TI_EARLY_COM_TXVAL=0x0: TI_EARLY_COM_MUX
diff -r d708c4dcdd7d sys/arch/arm/ti/ti_com.c
--- a/sys/arch/arm/ti/ti_com.c Sun Apr 27 23:30:39 2025 +0000
+++ b/sys/arch/arm/ti/ti_com.c Sun May 25 21:39:29 2025 -0700
@@ -30,6 +30,10 @@
__KERNEL_RCSID(1, "$NetBSD: ti_com.c,v 1.12 2023/09/05 02:59:07
gutteridge Exp $");
+#ifdef _KERNEL_OPT
+#include "opt_kgdb.h"
+#endif
+
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/device.h>
@@ -44,6 +48,25 @@
#include <arch/arm/ti/ti_prcm.h>
+#ifdef KGDB
+extern struct bus_space armv7_generic_bs_tag;
+#ifndef KGDB_DEVMODE
+const int comkgdbmode = HUPCL | CS8 | CREAD;
+#else
+const int comkgdbmode = KGDB_DEVMODE;
+#endif
+#ifndef KGDB_DEVADDR
+const int comkgdbaddr = 0x48022000;
+#else
+const int comkgdbaddr = KGDB_DEVADDR;
+#endif
+#ifndef KGDB_DEVRATE
+const int comkgdbrate = 115200;
+#else
+const int comkgdbrate = KGDB_DEVRATE;
+#endif
+#endif
+
static int ti_com_match(device_t, cfdata_t, void *);
static void ti_com_attach(device_t, device_t, void *);
@@ -159,6 +182,21 @@
if (comcnattach1(®s, speed, uart_freq, COM_TYPE_NORMAL, flags))
panic("Cannot initialize ti com console");
+
+#if defined(KGDB)
+#if defined(TI_EARLY_COM_MUX)
+ const bus_addr_t ctrl_mod = 0x44E10000;
+ const bus_space_tag_t arm_bst = &armv7_generic_bs_tag;
+ bus_space_handle_t ctrl_bsh;
+
+ bus_space_map(arm_bst, ctrl_mod, 0x2000, 0, &ctrl_bsh);
+ bus_space_write_4(arm_bst, ctrl_bsh, TI_EARLY_COM_RXOFF,
TI_EARLY_COM_RXVAL);
+ bus_space_write_4(arm_bst, ctrl_bsh, TI_EARLY_COM_TXOFF,
TI_EARLY_COM_TXVAL);
+#endif
+ com_init_regs_stride(®s, bst, dummy_bsh, comkgdbaddr, 2);
+ if (com_kgdb_attach1(®s, comkgdbrate, uart_freq,
COM_TYPE_OMAP, comkgdbmode))
+ panic("Cannot initialize kgdb console");
+#endif
}
static const struct fdt_console ti_com_console = {
On Fri, May 16, 2025 at 1:13 PM Lloyd Parkes
<lloyd%must-have-coffee.gen.nz@localhost> wrote:
>
> Kia ora James,
> I'm no port-arm gatekeeper so I'm not going to answer any of your
> questions about what is right, but I will point out one bit of
> information.
>
> You state in a comment "Need to mux the pins since fdt bus isn't up
> yet". This is only sort-of true.
>
> The NetBSD FDT bus is not ready yet for sure, but U-Boot has already
> initialised the MUX using it's own FDT. You could add uart1
> configuration to the devicetree used by U-Boot and then U-Boot will
> configure the hardware for you. Configuring the hardware so that the
> kernel can boot is one of U-Boot's stated jobs.
>
> The kernel can support both methods with a #ifdef option.
>
> Whether or not you want to put that work into U-Boot is up to you.
>
> Ngā mihi,
> Lloyd
>
Home |
Main Index |
Thread Index |
Old Index