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.

Printing register base addresses & register contents

Dear Ti E2e Community,

As I don't have hardware debuggers with me, I need to print the register base addresses & register contents in uboot & kernel source codes using printf's & printks, as am new to this Ti SDK 7 platform, 

could anybody please show me how this prints can be done to obtain register base addresses & register contents for example you can show me for i2c0 

As am trying this from many days am unable to succeed further

Kindly do the needful as early as possible

Many Thanks in advance

  • Srini,

    In u-boot, you can use md and mw commands to read and write the device registers. Example:

    u-boot#md
    md - memory display

    Usage:
    md [.b, .w, .l] address [# of objects]
    u-boot#mw
    mw - memory write (fill)

    Usage:
    mw [.b, .w, .l] address value [count]

    u-boot#md 0x4818155C 1
    4818155c: 00030100    ....
    u-boot#mw 0x4818155C 0x2
    u-boot#md 0x4818155C 1
    4818155c: 00000002    ....

    You can also read/write register inside the u-boot (not after loading it) using the  __raw_readl() and __raw_writel() functions. Examples:

    __raw_readl(CONTROL_STATUS)

    __raw_writel(reload, base + 0x2C);

    You can print the I2C0 I2C_BUF register like below:

    printf("I2C0.I2C_BUF = %x\n",__raw_readl(0x48028094)); //I2C0 base addr is 0x48028000, I2C_BUF offset is 0x94

    BR
    Pavel

    BR
    Pavel

  • In linux kernel, you should use the printk function, instead of printf.

    Also, you should translate the physical address to virtual, then you can read/write:

    static void __iomem *base;
        
    base = ioremap(0x48028000, SZ_4K);
        
    printk("I2C0.I2C_BUF = %x\n",__raw_readl(base+0x94));

    In user space (after linux kernel boot up), you can use the devmem2 tool:

    evm:~# devmem2

    Usage:    devmem2 { address } [ type [ data ] ]
        address : memory address to act upon
        type    : access operation type : [b]yte, [h]alfword, [w]ord
        data    : data to be written

    BR
    Pavel

  • Dear Ti  E2E community,

    Could you please let me know how the register base address & offset can be printed using printk, the above gives only the suggestions of printing the register contents, Am trying to print the register base address

    For example: could you please let me know how usb_ctrl1 register base address can be printed using printk in driver code for example I need to print the address of  (usb_ctrl->phy_reg + reg) in phy-am335x-control.c

    Could you please kindly do the needful in how to print the register base address using printk in kernel driver code

    Kindly do the needful as early as possible

    Awaiting for your replies

    Many Thanks in advance

  • Srini,

    I would recommend you to open new e2e thread regarding your new question.

    BR
    Pavel
  • Dear Pavel

    as you recommended I have created new thread

    e2e.ti.com/.../431039

    Could you please provide any inputs w.r.t the above query

    Kindly do the needful as early as possible

    Awaiting for your replies

    Many Thanks in advance