1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ベアメタルでAllwinner A10 の UART出力

Posted at

Allwinner A10のUART出力をベアメタルで動かしてみました。

QEMUで動かしてみました。
QEMUの場合は初期化しなくとも、とりあえずデータ出力が確認できるので簡単です。

コード

# include <stddef.h>
# include <stdint.h>

extern void io_halt(void);

# define UART0_THR   ((volatile uint32_t *)(0x01C28000))

void uart_putc(unsigned char c)
{
    *UART0_THR = c;
}

void uart_puts(const char* str)
{
    for (size_t i = 0; str[i] != '\0'; i ++)
        uart_putc((unsigned char)str[i]);
}

void kernel_main(void)
{
    uart_puts("uart01: uart tx\n");
    uart_puts("exit : Ctrl-A x ,monitor : Ctrl-A c\n\n");

    while (1)
        io_halt();
}

UART0_THRに一文字分のデータを書き込めばUART0にデータを出力します。

実行例

QEMUにはAllwinner A10を搭載したcubueboardのエミュレーション機能があります。
オプションでUART0 を 標準出力に割り当てます。

qemu-system-arm -M cubieboard -m 512 -serial mon:stdio -kernel kernel.elf -nographic
uart01: uart tx
exit : Ctrl-A x ,monitor : Ctrl-A c

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?