-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from fayalalebrun/dtb
Pi Zero Compatibility; DTB parser
- Loading branch information
Showing
32 changed files
with
2,099 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
((nil . ((eval . (let ((root (projectile-project-root))) | ||
(let ((command (concat "arm-none-eabi-gdb -i=mi -ex \"target remote localhost:1234\" -ex \"symbol-file " root "src/kernel/build/kernel.sym\""))) | ||
(setq-local gud-gud-gdb-command-name command) | ||
(setq-local gud-gdb-command-name command) | ||
(set (make-local-variable 'compile-command) | ||
(concat "cd " (concat root "src") " && make test")) | ||
(use-local-map (copy-keymap (current-local-map))) | ||
(local-set-key [f5] 'compile) | ||
(local-set-key [f6] 'co/gdb) | ||
(let ((command (concat "arm-none-eabi-gdb -i=mi -ex \"target remote localhost:1234\" -ex \"symbol-file " root "src/kernel/build/kernel.sym\""))) | ||
(setq-local gud-gud-gdb-command-name command) | ||
(setq-local gud-gdb-command-name command) | ||
(set (make-local-variable 'compile-command) | ||
(concat "cd " (concat root "src") " && make test")) | ||
(let ((map (make-sparse-keymap))) | ||
|
||
(set-keymap-parent map (current-local-map)) | ||
(use-local-map map) | ||
(local-set-key [f5] 'compile) | ||
(local-set-key [f6] 'co/gdb) | ||
|
||
(defun co/gdb () | ||
(interactive) | ||
(async-shell-command (concat "cd " | ||
(concat (projectile-project-root) "src") | ||
" && " | ||
"make debug") nil 0) | ||
(gdb gud-gdb-command-name)))))))) | ||
(defun co/gdb () | ||
(interactive) | ||
(async-shell-command (concat "cd " | ||
(concat (projectile-project-root) "src") | ||
" && " | ||
"make debug") nil 0) | ||
(gdb gud-gdb-command-name))))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Device Tree Files for QEMU | ||
|
||
In this directory, there are a number of DTB files we use when running the kernel in QEMU. | ||
|
||
## What is a DTB file? | ||
In an ARM board, most peripherals are use via memory-mapped IO, which means there is no standard way to poll what kind of peripherals are present in the system and where in memory to find them. Additionally, there is no way to find out how much memory is present in the system. A Device Tree is the standardized way in which the bootloader communicates to the kernel how the system looks like, including the type of cpu, the amount of memory available, what peripherals can be found and any other details we need to for our kernel to interact with the current board correctly. | ||
|
||
A **DTS** file is the human-readable representation of a device tree, while a **DTB** is a binary version, more suitable for parsing, and usually what you feed into the OS. | ||
|
||
## How does the kernel obtain the DTB file? | ||
One of the responsibilities of a board's bootloader is to load the board's DTB file and pass it to the kernel. Thus on kernel startup, we can expect a pointer to the DTB to be in the `r2` register. | ||
|
||
In QEMU however, there is no provision made for a DTB to be passed to our program. Thus we must work around it, and build the DTB into the kernel, and use this built-in DTB instead. | ||
|
||
## Why use a dumped DTB file? | ||
Certain bootloaders make changes to the board's standard DTB file before passing it to the kernel. For example, the Raspberry Pi Zero's default DTB does not have the memory property filled in. Thus, if we weren't using a dumped DTB, we would not be getting the correct memory value. | ||
|
||
## Further Reading | ||
https://devicetree-specification.readthedocs.io/en/v0.3/ | ||
https://devicetree-specification.readthedocs.io/en/v0.3/flattened-format.html | ||
https://elinux.org/Device_Tree_Usage |
Binary file not shown.
Oops, something went wrong.