简体   繁体   中英

How to use assembly to write a console(or just like printf() function) in uboot before set up C environment?

I try to use assembly to write a console in uboot flow before setting up c environment. I referenced the chip vendor's UART firmware driver to translate to assembly in the beginning of uboot flow(in reset). Question 1: Does the SOC mmio address work in the begging of uboot?ex: #define UART_BASE 0x11000000 in SOC spec, can I use this address to control uart? 2. where are those assembly codes running if using nand to boot? Nand SPL UBOOT to ram is not at begging...

(those address are from SOC vendor SPEC)

_UART_Init_and_write_a_char:


mov r11, #0x00
ldr r12, =0xf1012004
str r11, [r12]


mov r11, #0x80
ldr r12, =0xf101200c
str r11, [r12]


mov r11, #0x87
ldr r12, =0xf1012000
str r11, [r12]


mov r11, #0x0
ldr r12, =0xf1012004
str r11, [r12]


mov r11, #0x3
ldr r12, =0xf101200c
str r11, [r12]



mov r11, #0x7
ldr r12, =0xf1012008
str r11, [r12]

MMIO is (hardware) memory-mapped I/O, so it already works. However, prior than being able of writing characters, you will likely need to properly configure the registers for UART. These typically include UART settings like eg baudrate, flow control, etc. You can refer to the chip reference manual to know values and addresses.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM