# Linux Kernel Module Cheat

### 9.4. Device tree emulator generation

Since emulators know everything about the hardware, they can automatically generate device trees for us, which is very convenient.

This is the case for both QEMU and gem5.

For example, if we increase the number of cores to 2:

    ./run --arch aarch64 --cpus 2

QEMU automatically adds a second CPU to the DTB!

                    cpu@0 {
                    cpu@1 {

The action seems to be happening at: `hw/arm/virt.c`.

You can dump the DTB QEMU generated with:

    ./run --arch aarch64 -- -machine dumpdtb=dtb.dtb

as mentioned at: https://lists.gnu.org/archive/html/qemu-discuss/2017-02/msg00051.html

gem5 fs_bigLITTLE 2a9573f5942b5416fb0570cf5cb6cdecba733392 can also generate its own DTB.

gem5 can generate DTBs on ARM with `--generate-dtb`. The generated DTB is placed in the m5out directory named as `system.dtb`.