atk source device program

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

atk source device program

551 次查看
wangliang
Contributor I

Hello

I am using imx257

I want to add support for programming the spi flash m25p64 for imx257 .

I use the device program of atk source . I use the cygwin to compile it .

but ,I have no way to debug it ,then I add the following code in channel.c ,

I want to print something using uart5

void serial_setbrg(void)

{

  //u32 clk = 33250000;

  u32 clk = 49875000;

  __REG(UART5_PHYS + UFCR) = 4 << 7; /* divide input clock by 2 */

  __REG(UART5_PHYS + UBIR) = 0xf;

  __REG(UART5_PHYS + UBMR) = clk / (2 * 115200);

}

void serial_putc(const char c)

{

  __REG(UART5_PHYS + UTXD) = c;

  /* wait for transmitter to be ready */

  while (!(__REG(UART5_PHYS + UTS) & UTS_TXEMPTY))

  ;

  /* If \n, also do \r */

  if (c == '\n')

  serial_putc('\r');

}

void serial_puts(const char *s)

{

  while (*s)

  serial_putc(*s++);

}

static int serial_init(void)

{

  __writel(0x3, IOMUXC_BASE_ADDR + 0x060);//uart5_txd mux

  __writel(0x3, IOMUXC_BASE_ADDR + 0x064);//uart5_rxd mux

  __writel(0x80, IOMUXC_BASE_ADDR + 0x274);//uart5 RXD pad ctl

  __writel(0x80, IOMUXC_BASE_ADDR + 0x270);//uart5 TXD pad ctl

  __REG(UART5_PHYS + UCR1) = 0x0;

  __REG(UART5_PHYS + UCR2) = 0x0;

  while (!(__REG(UART5_PHYS + UCR2) & UCR2_SRST))

  ;

  __REG(UART5_PHYS + UCR3) = 0x0704;

  __REG(UART5_PHYS + UCR4) = 0x8000;

  __REG(UART5_PHYS + UESC) = 0x002b;

  __REG(UART5_PHYS + UTIM) = 0x0;

  __REG(UART5_PHYS + UTS) = 0x0;

  serial_setbrg();

  __REG(UART5_PHYS + UCR2) = UCR2_WS | UCR2_IRTS | UCR2_RXEN |

  UCR2_TXEN | UCR2_SRST;

  __REG(UART5_PHYS + UCR1) = UCR1_UARTEN;

  return 0;

}

I add the serail init in

atk_channel_init() function in channel.c  like this:

case CHAN_UART:

  /* service watchdog */

  watchdog_service();

  serial_init();

  serial_puts("uart5 inited\n");

When I use the atk tool with my mx25_spi.bin using uart1.

The atk tool show ram kernel downloading fine,but it can not print the ("uart5 inited\n");

But when I add this code to the uboot,it work fine ,uart1 and uart5 can work at same time.

What is wrong?When the boot rom jump to mx25_spi.bin ,why uart5 can not work?

0 项奖励
回复
1 回复

475 次查看
igorpadykov
NXP Employee
NXP Employee

Hi wang

reason may be clock gating in Clock Gating Control Register 2 (CGCR2).

Also one can attach jtag and check register contents, output uart data with jtag.

Best regards

igor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复