add support of mini UART in QEMU

This commit is contained in:
jbltx
2019-11-24 04:22:18 -05:00
parent b1aee91e6e
commit 42dd7f53cc
3 changed files with 28 additions and 21 deletions
+7 -1
View File
@@ -46,7 +46,13 @@ else
QEMU_MACHINE = raspi3
endif
QEMU_FLAGS = -m 256 -M $(QEMU_MACHINE) -serial stdio
QEMU_FLAGS = -m 256 -M $(QEMU_MACHINE)
ifeq ($(USE_MINI_UART),1)
QEMU_FLAGS += -serial null -serial stdio
else
QEMU_FLAGS += -serial stdio
endif
##################
# FILES AND DIRS #
+1 -1
View File
@@ -10,7 +10,7 @@ enum
#elif BCM2711
PERIPHERAL_BASE = 0xFE000000,
#else // BCM2835
PERIPHERAL_BASE = 0x7E000000,
PERIPHERAL_BASE = 0x7E000000, // try with 0x20000000
#endif
// The mailbox base address.
+20 -19
View File
@@ -9,25 +9,6 @@
void uart_init()
{
uint32_t selector;
// Setup the GPIO pin 14 && 15.
selector = mmio_read(GPFSEL1);
selector &= ~(7<<12); // clean gpio14
selector |= 2<<12; // set alt5 for gpio14
selector &= ~(7<<15); // clean gpio15
selector |= 2<<15; // set alt5 for gpio15
mmio_write(GPFSEL1, selector);
// Disable pull up/down for all GPIO pins & delay for 150 cycles.
mmio_write(GPPUD, 0x00000000);
delay(150);
// Disable pull up/down for pin 14,15 & delay for 150 cycles.
mmio_write(GPPUDCLK0, (1 << 14) | (1 << 15));
delay(150);
// Write 0 to GPPUDCLK0 to make it take effect.
mmio_write(GPPUDCLK0, 0x00000000);
//Enable mini uart (this also enables access to it registers)
mmio_write(AUX_ENABLES, 1);
@@ -44,8 +25,28 @@ void uart_init()
//Set RTS line to be always high
mmio_write(AUX_MU_MCR_REG, 0);
// Disable interrupts
mmio_write(AUX_MU_IIR_REG, 0xc6);
//Set baud rate to 115200
mmio_write(AUX_MU_BAUD_REG, 270);
// Setup the GPIO pin 14 && 15.
selector = mmio_read(GPFSEL1);
selector &=~((7<<12)|(7<<15)); // gpio14, gpio15
selector |=(2<<12)|(2<<15); // alt5
mmio_write(GPFSEL1, selector);
// Disable pull up/down for all GPIO pins & delay for 150 cycles.
mmio_write(GPPUD, 0x00000000);
delay(150);
// Disable pull up/down for pin 14,15 & delay for 150 cycles.
mmio_write(GPPUDCLK0, (1 << 14) | (1 << 15));
delay(150);
// Write 0 to GPPUDCLK0 to make it take effect.
mmio_write(GPPUDCLK0, 0x00000000);
//Finally, enable transmitter and receiver
mmio_write(AUX_MU_CNTL_REG, 3);