This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM437x UART debug console change in U-boot

Hi All,

I am working on AM437x SOC and I am trying to change UART debug console from default port UART0 to UART5 in out custom board.

I would like to confirm my changes in the u-boot source for my custom board to make use of UART5 as debug console. The below are the changes I have done in my u-boot source to use UART5 as debug console.

Kindly please have a look and let me know is these changes are fine, or need to do any extra changes in the u-boot source for UART5 port.

1. Pin MUX configuration for UART5.

Added the below changes in the following file "board/ti/am43xx/mux.c"  to support UART5 Pinx MUX configuration.

static struct module_pin_mux uart5_pin_mux[] = {
{OFFSET(mii1_col), (MODE(3) | PULLUP_EN | RXACTIVE | SLEWCTRL)},
{OFFSET(rmii1_refclk), (MODE(3) | PULLUDDIS | PULLUP_EN | SLEWCTRL)},
{-1},
}; 

Added function call to configure pin mux for UART5. 

void enable_uart5_pin_mux(void)
{
 configure_module_pin_mux(uart5_pin_mux);
}

2. Edited the file "board/ti/am43xx/board.c" to add required changes for UART5 pin mux.

void set_uart_mux_conf(void)
{
 //enable_uart0_pin_mux();
 enable_uart5_pin_mux();     /*added for UART5 */
}

3. Changes in file "board/ti/am43xx/board.h"

Added prototype declaration for function "enable_uart5_pin_mux()" 

void enable_uart5_pin_mux(void);

4. Added uart clock for UART5 in the file "arch/arm/cpu/armv7/am33xx/clock_am43xx.c"

in the function: "setup_clocks_for_console(void), edited the below lines to add support for UART5.

/* Enable UART5 */
 clrsetbits_le32(&cmper->uart5clkctrl,
 MODULE_CLKCTRL_MODULEMODE_MASK,
 MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<
 MODULE_CLKCTRL_MODULEMODE_SHIFT);

 while ((idlest == MODULE_CLKCTRL_IDLEST_DISABLED) ||
 (idlest == MODULE_CLKCTRL_IDLEST_TRANSITIONING)) {
 clkctrl = readl(&cmper->uart5clkctrl);
 idlest = (clkctrl & MODULE_CLKCTRL_IDLEST_MASK) >>
 MODULE_CLKCTRL_IDLEST_SHIFT;
 }

5. Added uart clock reset support for UART5 in the file "arch/arm/cpu/armv7/am33xx/board.c"

/*Added UART base address macro in the same file*/

#define UART5_BASE_ADD 0x481AA000

static void uart_soft_reset(void)
{
struct uart_sys *uart_base = (struct uart_sys *)UART5_BASE_ADD;
u32 regval;

regval = readl(&uart_base->uartsyscfg);
regval |= UART_RESET;
writel(regval, &uart_base->uartsyscfg);
while ((readl(&uart_base->uartsyssts) &
UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK)
 ;

 /* Disable smart idle */
 regval = readl(&uart_base->uartsyscfg);
 regval |= UART_SMART_IDLE_EN;
 writel(regval, &uart_base->uartsyscfg);
}

6. Edited make file of the following path "board/ti/am43xx/Makefile" to generate mux obj file to link.

ifeq ($(CONFIG_SKIP_LOWLEVEL_INIT),)
obj-y := mux.o
endif
obj-y := mux.o

obj-y += board.o

7. Added UART5 base address and port configuration in the "include/configs/am43xx_evm.h" file as shown below.

#define CONFIG_SYS_NS16550_COM6 0x481aa000 /* Base custom board has UART5 */

Replaced the boot-args parameter ""console=ttyO0,115200n8\0" \" to ""console=ttyO5,115200n8\0" \ " to support UART5 console.

I appreciate your support on this.

Thanks & Regards

Ch. Siva

  • Hi,

    This should be enough.

    Best Regards,
    Yordan
  • Hi Yordan,
    Thank you for your time to verify it.
    I will test on our custom board with these changes and update you.

    Thanks & Regards
    Ch. Siva
  • You also need to update /etc/inittab in the file system. Usually u-boot is updated as well.
  • Hi Brad,

    Thanks for your comment.

    With my above mentioned u-boot source changes UART5 debug console working and I am able to see my SPL boot log.

    I will update in the /etc/inittab of the file system to reflect the debug console change to display kernel image boot process and to get access of console.

    Thanks & Regards
    Ch. Siva
  • Which Processor SDK are you using?

  • Hi Brad,

    I am using the AM437X processor SDK.

    Thanks & Regards
    Ch. Siva
  • Hi Brad,

    I am using the u-boot version "u-boot-2016.05+gitAUTOINC+b4e185a8c3-gb4e185a8c3".

    Thanks & Regards
    Ch. Siva

  • That comes from Processor SDK 3.00.00.04.  That's what I was trying to get you to tell me...  I went through nearly this exact same exercise recently on AM335x EVM and Processor SD 2.00.02.11.  Here are the changes I made to change from UART0 to UART1:

    diff --git a/configs/am335x_boneblack_chipsee_defconfig b/configs/am335x_boneblack_chipsee_defconfig
    new file mode 100644
    index 0000000..09544ea
    --- /dev/null
    +++ b/configs/am335x_boneblack_chipsee_defconfig
    @@ -0,0 +1,11 @@
    +CONFIG_ARM=y
    +CONFIG_TARGET_AM335X_EVM=y
    +CONFIG_SPL=y
    +CONFIG_SPL_STACK_R=y
    +CONFIG_SPL_STACK_R_ADDR=0x82000000
    +CONFIG_SYS_EXTRA_OPTIONS="EMMC_BOOT"
    +# CONFIG_CMD_IMLS is not set
    +# CONFIG_CMD_FLASH is not set
    +# CONFIG_CMD_SETEXPR is not set
    +CONFIG_SPI_FLASH=y
    +CONFIG_CONS_INDEX=2

    FYI, that config file is one that I created based off the original AM335x EVM config.  The CONS_INDEX line is the key one there...  And I needed to change the bootargs too:

    diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
    index 840123b..7aadbd5 100644
    --- a/include/configs/am335x_evm.h
    +++ b/include/configs/am335x_evm.h
    @@ -76,7 +76,7 @@
            "bootdir=/boot\0" \
            "bootfile=zImage\0" \
            "fdtfile=undefined\0" \
    -       "console=ttyO0,115200n8\0" \
    +       "console=ttyO1,115200n8\0" \
            "partitions=" \
                    "uuid_disk=${uuid_gpt_disk};" \
                    "name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}\0" \

    I believe this same thing should work for you too.

  • Hi Brad Griffs,

    I am trying to change the UART debug console from default UART0 to UART3 in u-boot on boneblack based customised board.


    SPL and LINUX kernel console messages are coming but u-boot console messages are missing
    how to overcome this problem, what are all changes required in u-boot ??

    Thanks and Regards,
    Ravikiran
  • If it works for SPL, I don't see why it wouldn't work for u-boot since it's the same code base! Are you positive that your u-boot.img has been properly updated on the target?
  • Hi Brad Griffis,

    I am properly updating the u-boot.img on board.

    I am getting Boot-log like this.

    U-Boot SPL 2016.05-00118-gabc6b2a-dirty (Jan 24 2017 - 10:22:53)
    Magiuc : 3996341674
    Name : A335BNLT
    Trying to boot from MMC1
    reading args
    spl_load_image_fat_os: error reading image args, err - -1
    reading u-boot.img
    reading u-boot.img
    reading u-boot.img
    reading u-boot.img
    *********69-------spl_board_prepare_for_boot********
    [ 0.000000] Booting Linux on physical CPU 0x0
    [ 0.000000] Linux version 3.12.10-g11c7460 (mistral@CPU349) (gcc version 4.8.4 (Ubuntu/Linaro 4.8.4-2u6
    [ 0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c53c7d
    [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
    [ 0.000000] Machine: Generic AM33XX (Flattened Device Tree), model: TI AM335x BeagleBone
    [ 0.000000] cma: CMA: reserved 24 MiB at 9e000000
    [ 0.000000] Memory policy: ECC disabled, Data cache writeback
    [ 0.000000] CPU: All CPU(s) started in SVC mode.
    [ 0.000000] AM335X ES2.1 (neon )
    [ 0.000000] PERCPU: Embedded 8 pages/cpu @c0c56000 s9024 r8192 d15552 u32768
    [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 129280
    [ 0.000000] Kernel command line: console=ttyO3,115200n8 root=PARTUUID=00000000-02 rw rootfstype=ext4 rt
    [ 0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
    [ 0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
    [ 0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
    [ 0.000000] Memory: 483488K/521216K available (5506K kernel code, 563K rwdata, 1744K rodata, 376K init)
    [ 0.000000] Virtual kernel memory layout:
    [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
    [ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
    [ 0.000000] vmalloc : 0xe0800000 - 0xff000000 ( 488 MB)
    [ 0.000000] lowmem : 0xc0000000 - 0xe0000000 ( 512 MB)
    [ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
    [ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
    [ 0.000000] .text : 0xc0008000 - 0xc071cfdc (7252 kB)
    [ 0.000000] .init : 0xc071d000 - 0xc077b340 ( 377 kB)
    [ 0.000000] .data : 0xc077c000 - 0xc0808e00 ( 564 kB)
    [ 0.000000] .bss : 0xc0808e08 - 0xc08421dc ( 229 kB)
    [ 0.000000] Hierarchical RCU implementation.
    [ 0.000000] RCU restricting CPUs from NR_CPUS=2 to nr_cpu_ids=1.
    [ 0.000000] NR_IRQS:16 nr_irqs:16 16


    Thanks and Regards,
    Ravikiran
  • The best guess that comes to mind is that perhaps you have some code remnants leftover from the TI EVM that are reconfiguring the pinmux for your UART during u-boot, but that they get set back to the proper mode by the kernel. Perhaps look carefully at what's happening in the enable_board_pin_mux() function.
  • Hi Brad,
    reconfiguring the pinmux for your UART during u-boot these pin mux functions in which file located ??
    I am using ti-SDK version 3 , board is customised boneblack board.


    Thanks and Regards,
    Ravikiran
  • Ravikiran J J said:
    Hi Brad,
    reconfiguring the pinmux for your UART during u-boot these pin mux functions in which file located ??
    I am using ti-SDK version 3 , board is customised boneblack board.


    Thanks and Regards,
    Ravikiran

    I gave you the function name, enable_board_pin_mux().  To find the file I just ran the command "grep -R enable_board_pin_mux *" from the u-boot root directory.

    The one you need is board/ti/am335x/mux.c.