How to know physical memory address range

Hi,

I have a sample with 1GB RAM. I want to know its physical memory address range. I checked memory node of device tree. Does it mean the address range is 0x0--0x3f ff ff ff?

root@OpenWRT:/sys/firmware/devicetree/base/memory# hexdump -C reg 
00000000  00 00 00 00 40 00 00 00  00 00 00 00 40 00 00 00  |....@.......@...|
00000010

If so, it seems not make sense. According to its dts file [1], node "reserved-memory" shows the physical memory address from 0x40000000. How do I understand this? Thank you!

reserved-memory {
	#ifdef __IPQ_MEM_PROFILE_256_MB__
......
......
#else

/*                 512MB/1GB Profiles
	 * +==========+==============+=========================+
	 * |          |              |                         |
	 * |  Region  | Start Offset |          Size           |
	 * |          |              |                         |
	 * +----------+--------------+-------------------------+
	 * |    NSS   |  0x40000000  |          16MB           |
	 * +----------+--------------+-------------------------+
	 * |   Linux  |  0x41000000  | Depends on total memory |
	 * +----------+--------------+-------------------------+
	 * |   uboot  |  0x4A600000  |           4MB           |
	 * +----------+--------------+-------------------------+
	 * |    SBL   |  0x4AA00000  |           1MB           |
	 * +----------+--------------+-------------------------+
	 * |   smem   |  0x4AB00000  |           1MB           |
	 * +----------+--------------+-------------------------+
	 * |    TZ    |  0x4AC00000  |           4MB           |
	 * +----------+--------------+-------------------------+
	 * |    Q6    |              |                         |
	 * |   code/  |  0x4B000000  |          20MB           |
	 * |   data   |              |                         |
	 * +----------+--------------+-------------------------+
	 * |  IPQ5018 |              |                         |
	 * |   data   |  0x4C400000  |          14MB           |
	 * +----------+--------------+-------------------------+
	 * |  IPQ5018 |              |                         |
	 * |  M3 Dump |  0x4D200000  |           1MB           |
	 * +----------+--------------+-------------------------+
	 * |  IPQ5018 |              |                         |
	 * |   QDSS   |  0x4D300000  |           1MB           |
	 * +----------+--------------+-------------------------+
	 * |  IPQ5018 |              |                         |
	 * |  Caldb   |  0x4D400000  |           2MB           |
	 * +----------+--------------+-------------------------+
	 * | QCN6122_1|              |                         |
	 * |   data   |  0x4D600000  |          16MB           |
	 * +----------+--------------+-------------------------+
	 * | QCN6122_1|              |                         |
	 * |  M3 Dump |  0x4E600000  |           1MB           |
	 * +----------+--------------+-------------------------+
	 * | QCN6122_1|              |                         |
	 * |   QDSS   |  0x4E700000  |           1MB           |
	 * +----------+--------------+-------------------------+
	 * | QCN6122_1|              |                         |
	 * |  Caldb   |  0x4E800000  |           5MB           |
	 * +----------+--------------+-------------------------+
	 * | QCN6122_2|              |                         |
	 * |   data   |  0x4ED00000  |          16MB           |
	 * +----------+--------------+-------------------------+
	 * | QCN6122_2|              |                         |
	 * |  M3 Dump |  0x4FD00000  |           1MB           |
	 * +----------+--------------+-------------------------+
	 * | QCN6122_2|              |                         |
	 * |   QDSS   |  0x4FE00000  |           1MB           |
	 * +----------+--------------+-------------------------+
	 * | QCN6122_2|              |                         |
	 * |  Caldb   |  0x4FF00000  |           5MB           |
	 * +----------+--------------+-------------------------+
	 * |                                                   |
	 * |            Rest of the memory for Linux           |
	 * |                                                   |
	 * +===================================================+
	 */
		q6_mem_regions: q6_mem_regions@4B000000 {
			no-map;
			reg = <0x0 0x4B000000 0x0 0x5400000>;
		};

		q6_code_data: q6_code_data@4B000000 {
			no-map;
			reg = <0x0 0x4B000000 0x0 01400000>;
		};

[1]https://source.codeaurora.org/quic/qsdk/oss/kernel/linux-msm/tree/arch/arm64/boot/dts/qcom/qcom-ipq5018-mp03.5-c1.dts?h=11.4.0.5

That means that the DRAM is mapped to address 0x40000000, this is pretty common for IPQ807x/60xx/50xx.

So you can access the DRAM like any other memory-mapped IO, just read and write to it.

So do you mean it's VM instead of physical memory? On IPQ806x, it seems that 0x40000000 is also physical memory address. Below output is from my R7800 whose SoC is IPQ806x.

root@OpenWrt:/sys/firmware/devicetree/base/memory# hexdump -C reg 
00000000  40 00 00 00 20 00 00 00                           |@... ...|
00000008

Here is how I translate the output of "hexdump -C reg":

The first 4 bytes is physical start address, the second 4 bytes is the size.

Is this correct? Actually, I don't know why there are the third and fourth 4 bytes on IPQ50xx. Why are they different between IPQ806x and IPQ50xx.

Its physical memory its just that the CPU maps its start at that address.

The format of the DT node depends on #address-cells and #size-cells properties.
For most platforms memory uses value 2 for both, meaning you provide 64 bit values instead of the default 32 bit.
So:
reg = <ADDR_HI_32_BITS ADDR_LO_32_BITS SIZE_HI_32_BITS SIZE_LO_32_BITS>;

Oh, yeah. You are right. I made such stupid mistake that I was not aware of the 64bit address. I used trace32 and confirm the NSS firmware is loaded into the address 0x40000000 on IPQ50xx.

Oh, you got the Lauterbach JTAG?
I am looking into getting it due to working more and more on stuff that is getting hard to debug via printing

Yes, it's very useful for me to study and debug.

Is the price something you can share?

It's from my company. I don't know the price. But I guess it's about at least 6000$ for ARMv8.

Ok, then OpenOCD will be good as well for the start.
Thanks

Would you give me a reminder if you figure out how to use OpenOCD? I may use it when I am OOO. :grinning:Thanks.

Sure, I even got an an interface for it somewhere