OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:19 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: [SOLVED] BCM2835 MMU setup
PostPosted: Wed Jun 07, 2017 8:43 am 
Offline

Joined: Thu Nov 10, 2016 4:00 pm
Posts: 12
Hi guys,

I'm working with a Raspberry Pi Zero (BCM2835) and are currently trying to setup the MMU.
I have tried working with the MMU on a Odroid-C1 with great success.
However, that was a newer architecture (v7 vs v6) and I cannot copy my work entirely from there.
I would appreciate if I could get some help from someone who has worked with the Pi Zero.
Here is my current setup, which halts the system (an exception I assume). It works with the simple 1 MB section mapping:

First, I set the TLB address to 0x10000, where I have 4KB available for the table.
Code:
MCR P15, 0, R0, C2, C0, 0


Next, I map the entire table PA = VA as sections with full privileged access and strong order.
Thus, the table content looks like this:
Code:
00000410
00100410
00200410
00300410
00400410
00500410
...


Next, I enable the MMU with the following procedure:
Code:
# Invalidate cache, tlb and DSB.
MOV R0, #0
MCR P15, 0, R0, C7, C7, 0
MCR P15, 0, R0, C8, C7, 0
MCR P15, 0, R0, C7, C10, 4

# Set domain access.
MOV R0, #0xFFFFFFFF
MCR P15, 0, R0, C3, C0, 0

# Setup MMU.
MRC P15, 0, R0, C1, C0, 0

# Enable MMU.
ORR R0, R0, #0x1

# Disable caching.
BIC R0, R0, #(1 << 2)
BIC R0, R0, #(1 << 12)

# Enables subpage.
ORR R0, R0, #(1 << 23)

# Enables TEX-mapping.
ORR R0, R0, #(1 << 28)

MCR P15, 0, R0, C1, C0, 0 <-- This is where it dies.


I know it dies right after. I have tried to turn off the led on the board right after saving the register but it never runs.
If anyone has suggestions to make it work, I would be very happy as I can move on with my little kernel :)

Best regards,
Simon


Last edited by SimonHA on Sat Jun 10, 2017 2:58 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: BCM2835 MMU setup
PostPosted: Wed Jun 07, 2017 1:07 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 21, 2011 9:47 pm
Posts: 286
Location: Tustin, CA USA
I recently completed the set up for the MMU for my rpi2b which has the same BCM2835 SoC but a different CPU. I am not sure how helpful this will be and I have not had the opportunity to research the differences. Also, disclaimer: I have coded the setup and tested to the best of my ability without actually having enabled the setup yet (I'm focused on the loader for now).

I offer up my code for you to review if it provides any benefit. Some places to look are:
https://github.com/eryjus/century/blob/master/README.md -- which contains the rpi2b VMM address space
https://github.com/eryjus/century/blob/ ... pi2b/mmu.c

_________________
Adam

The name is fitting: Century Hobby OS -- At this rate, it's gonna take me that long!
Read about my mistakes and missteps with this iteration: Journal

"Sometimes things just don't make sense until you figure them out." -- Phil Stahlheber


Top
 Profile  
 
 Post subject: Re: BCM2835 MMU setup
PostPosted: Wed Jun 07, 2017 7:23 pm 
Offline
Member
Member

Joined: Sat Jul 02, 2016 7:02 am
Posts: 207
When mapping sections, an entry such as '00000410' is invalid and generates translation fault (the 2 LSBs are 00).


Top
 Profile  
 
 Post subject: Re: BCM2835 MMU setup
PostPosted: Thu Jun 08, 2017 8:27 am 
Offline

Joined: Thu Nov 10, 2016 4:00 pm
Posts: 12
Thank you for your help. I had a typo where I translated binary 10 into hex 0x10.
Now it works! :D


Top
 Profile  
 
 Post subject: Re: BCM2835 MMU setup
PostPosted: Thu Jun 08, 2017 11:53 am 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 640
Location: Ukraine, Bachmut
I'm just curious, why you chose the least capable board from the range? you end up messing with a fairly out dated architecture version, nobody else is using armv6 now.

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
 Post subject: Re: BCM2835 MMU setup
PostPosted: Fri Jun 09, 2017 2:14 am 
Offline

Joined: Thu Nov 10, 2016 4:00 pm
Posts: 12
Hi zaval,

I understand your point of view and your arguments a definitely correct!
The kernel is just a hobby project but I hope I can use it to have a light weight kernel for my hardware projects,
where I need a microcontroller with a bit more power than normally.
The Pi Zero is very cheap and compact for my design needs.
A few years ago I did work with an Odroid C1 and managed to make a kernel with multi-processor support and
the support to write simple multi-threaded C-libraries. However, this was part of a technology project course.
Now I want to make my little kernel called MinOS with focus on I/O for hardware projects with better design and code.

Best regards,
Simon


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: rdos and 81 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group