rhythm16 / rpi4-bare-metal Goto Github PK
View Code? Open in Web Editor NEWan operating system for the Raspberry Pi 4B in the making
an operating system for the Raspberry Pi 4B in the making
Line 97 in cbea79d
The baudrate setting of the PL011 UART was copied from the exercise solutions, I don't know how it's calculated and is surprised that the value also works for the RPI4.
The hint is in this file:
for calculation hint see PrimeCell ® UART (PL011) Technical Reference Manual
Said reference manual is here: https://developer.arm.com/documentation/ddi0183/g/; section 3.3.6 example 3-1 contains an example for how to calculate the baudrate setting (the formulas in section 3.3.4 and 3.3.6 are pretty obscure):
If the required baud rate is 230400 and
UARTCLK
= 4MHz then:
Baud Rate Divisor = (4×10^6)/(16×230400) = 1.085
This meansBRDI
= 1 andBRDF
= 0.085.
Therefore, fractional part, m = integer((0.085×64)+0.5) = 5
Generated baud rate divider = 1+5/64 = 1.078
Generated baud rate = (4×10^6)/(16×1.078) = 231911
Error = (231911-230400)/230400 × 100 = 0.656%
The maximum error using a 6-bit UARTFBRD Register = 1/64×100 = 1.56%. This occurs when m = 1, and the error is cumulative over 64 clock ticks.
There's also table 3-8 with "typical bit rates and their corresponding divisors when UARTCLK is 7.3728MHz" and table 3-9 with "required bit rates and their corresponding integer and fractional divisor values and generated bit rates when UARTCLK is 4MHz".
As both the RPi3 and the RPi4 have a PL011 UART, these calculations work for both models.
(this is a bit like a detective following clues...)
Hey nice work, I'm trying to get this working as well so I can startup the MMU on rpi4, it doesn't seem to startup for me though.
I tried downloading the firmware from today and from ~6 months ago but neither will boot up for me.
I'm able to get the MMU working on the rpi 3 but not the 4, so was hoping to be able to boot this up and use some of your code.
Line 91 in cbea79d
Low level devel said the RPI4's system clock frequency is 500MHz, this is correct in my testing, but I can't find this anywhere, in fact the bcm2711 (the soc on the PI4) peripheral datasheet actually says the system clock frequency is 250MHz on page 10.
The document on overclocking contains the default frequencies:
This table gives the default values for the options on various Raspberry Pi Models, all frequencies are stated in MHz
...
core_freq... Pi4... 500
(yeah, the documentation is all over the place)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.