Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7766

Bare metal, Assembly language • Re: Raspberry Pi 2 Mini UART

$
0
0
Yeah, ok, had some time to look at this again, and it looks like the firmware on the Raspberry Pi 2 is not leaving the UART configured and enabled when `enable_uart=1` is specified. Doing a full configuration, including setting up the GPIO pins, produces all of my kernel's output even without `enable_uart=1`. It's not clear why `enable_uart=1` works for Linux. It's a little annoying to have to manually do the set up given that the baud rate is dependent on the core frequency, which, as far as I can tell, has to be determined via the VideoCore mailbox interface.

Code:

pub fn init(virt_base: usize) {  unsafe {    assert!(!INITIALIZED);    INITIALIZED = true;    VIRTUAL_BASE = virt_base;  }  reg_put(AUX_ENABLES, 0x1);      // Enable mini UART  reg_put(AUX_MU_CNTL_REG, 0x0);  // Disable Tx/Rx  reg_put(AUX_MU_LCR_REG, 0x3);   // 8 bits, no parity, 1 stop bit  reg_put(AUX_MU_MCR_REG, 0x0);   // RTS is high  reg_put(AUX_MU_IER_REG, 0x0);   // Disable interrupts  reg_put(AUX_MU_BAUD_REG, 270);  // 115200 bps at 250 MHz  reg_put(GPPUPPDN0, 0x0);        // Disable pull-up/down  // Set function Alt5 for GPIO14 and GPIO15.  let mut gpio_func = reg_get(GPFSEL1);  gpio_func = (gpio_func & !(7 << 12)) | (2 << 12);  gpio_func = (gpio_func & !(7 << 15)) | (2 << 15);  reg_put(GPFSEL1, gpio_func);  reg_put(AUX_MU_CNTL_REG, 0x3);  // Enable Tx/Rx}

Statistics: Posted by slakr — Sun May 17, 2026 12:13 am



Viewing all articles
Browse latest Browse all 7766

Latest Images



Latest Images