Arm Linux Atags VS Device Tree

ARM Linux Atags vs Device Tree

A device tree describes everything about the hardware which the kernel uses to select which drivers to load, where all the MMIO interfaces are, etc... at runtime. ATAGs just describes stuff like where to find an initrd and kernel parameters, memory, etc... - everything else about the machine is hard coded into the kernel.

The preferred method now is to use device trees instead of ATAGs. One of the advantages include the fact that adding a new platform doesn't always require adding new code to the kernel.

To answer your second question, if you had read the documentation for booting Linux on the ARM platform, you'd find that the kernel expects the following to be placed in the registers before control is handed over to the kernel:

r0 = 0,
r1 = machine type number discovered in (3) above.
r2 = physical address of tagged list in system RAM, or
physical address of device tree block (dtb) in system RAM

I believe there is (or at least was) an option to load ATAGs from a fixed location instead of the address found in r2. However, the use of ATAGs is now being deprecated and obsolete and new platforms shouldn't be using it.

What are ATAGs for a device that uses Linux Kernel?

ATAGS are ARM tags. They are used to carry information such as memory size from boot code to kernel. Some references (which in turn lead to other references): booting standards, customized ATAG.

This reference arm/Booting explains theory, but does not much tell a user what to do.

On my target I use the following in my U-Boot config: CONFIG_CMDLINE_TAG, CONFIG_SETUP_MEMORY_TAGS, and these in my kernel config: CONFIG_ATAGS=y, CONFIG_USE_OF is not set. Not sure if that is sufficient for you but it gives you clues to search on, good luck.

What is difference between ATAG and cmdline?

ATAG and DeviceTree are two methods to pass parameters to kernel.
Command Line is one of the parameters.

Take LK code(Little Kernel: app/aboot/aboot.c) below as example, in function boot_linux(),
depending on definition of DEVICE_TREE, final_cmdline either passed to kernel via device tree or via atags.

    void boot_linux(void *kernel, unsigned *tags,
const char *cmdline, unsigned machtype,
void *ramdisk, unsigned ramdisk_size)
{
...
#if DEVICE_TREE
dprintf(INFO, "Updating device tree: start\n");

/* Update the Device Tree */
ret = update_device_tree((void *)tags,(const char *)final_cmdline, ramdisk, ramdisk_size);
if(ret)
{
dprintf(CRITICAL, "ERROR: Updating Device Tree Failed \n");
ASSERT(0);
}
dprintf(INFO, "Updating device tree: done\n");
#else
/* Generating the Atags */
generate_atags(tags, final_cmdline, ramdisk, ramdisk_size);
#endif
...
}

ARM R0 register value while moving from U-boot to Kernel

From arch/arm/kernel/head.S

/*
* Kernel startup entry point.
* ---------------------------
*
* This is normally called from the decompressor code. The requirements
* are: MMU = off, D-cache = off, I-cache = dont care, r0 = 0,
* r1 = machine nr, r2 = atags or dtb pointer.

model field of root node in device tree

Searching the Linux source code found me where the model field is used by the Kernel. It is printing the value on the console.

./arch/arm/kernel/devtree.c:236:       
model = of_get_flat_dt_prop(dt_root, "model", NULL);
pr_info("Machine: %s, model: %s\n", mdesc_best->name, model);

In an ARM device tree file, what do the three interrupt values mean

Parsing from the linked websites:

The first number is a flag indicating if the interrupt is an SPI
(shared peripheral interrupt). A nonzero value means it is an SPI.
This impacts offsets added to translate the interrupt number (16 for SPI, 32 for non-SPI).

The second number is the interrupt number.

The third number is the type of interrupt:
0 = Leave it as it was (power-up default or what the bootloader set it to, if it did). 1 = Rising edge. 4 = Level sensitive, active high.



Related Topics



Leave a reply



Submit