IMX6D, Linux kernel memory setup

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IMX6D, Linux kernel memory setup

3,579 Views
egorrumjantsev
Contributor III

Hello.

We develop custom board based on IMX6D + 2 LPDDR2 chips. Design based on Sabre board.

I bring up U-Boot from Freescale's Yocto BSP and looks like memory chips is working fine.

Next step was porting kernel to our board. But in that step i stuck on memory init during booting kernel.

I wrote my version of Device Tree files for our board and described memory as:

 memory {
                linux,usable-memory = <0x80000000 0x20000000>,
                                              <0x10000000 0x20000000>;
        };

But looks like kernel see only 1 chip ( base 0x80000000 - mem controller 0 ) and skip second chip (0x10000000 - mem controller 1).

 The problem is the following:

During boot process i can see

Ignoring memory block 0x10000000 - 0x30000000 message, so second chip with address 0x10000000 is skipped. I started to debug init process to see how to fix this problem.

So looks like 0x10000000 is less than 0x80000000 and kernel thinks that the lowest address of memory 0x80000000, so it ignore second memory chip:

early_init_dt_add_memory_arch(): PHYS_OFFSET: 0x80000000
early_init_dt_add_memory_arch(): PHYS_OFFSET: 0x80000000

previously i could set lower address in memory using defines, but now in kernel version 4.1.52 from Freescale's repo looks like this value is dynamic and runtime calculated.

Could some one advise how correctly describe memory chips. May be i have to set some of setting in U-Boot in ATAG's array?

Thanks,

Labels (3)
0 Kudos
13 Replies

3,055 Views
egorrumjantsev
Contributor III

Hi, Igor

Thank you for your answer.

I did see this messages. I even have tried to switch memory in interleaved mode in U-Boot. And U-Boot again was working. I used memory fill command to test writing from memory 0x30000000 ( it is more than 0x20000000 - capaciti of one chip ). And memory displaying showed that data which was written looks correct. But...

When i run the kernel it stop booting after decompressor without any messages.

After i have set bootargs with mem helper like mem=1G@0x10000000

and i saw that output was:

=> bootz 0x12000000 - 0x18000000
## Flattened Device Tree blob at 18000000
   Booting using the fdt blob at 0x18000000
   Using Device Tree in place at 18000000, end 1800b78f

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

arm_add_memory(): mem start: 0x10000000 size: 40000000

.....after that kernel stuck.

In fixed mapping mode kernel booted to rootfs, but missed one memory chip. It is sad that Freescale does not have ready to use settings for LPDDR2 (as i think lots of people use this type of memory).

WBR,

0 Kudos

3,055 Views
igorpadykov
NXP Employee
NXP Employee

could you try linux from nxp official source.codeaurora.org/external/imx repository

(SCM  "imx6dqscm*)

Best regards
igor

0 Kudos

3,056 Views
egorrumjantsev
Contributor III

Igor, i use U-Boot and kernel from Freescale's Yocto repo. Isn't it official?

git://github.com/Freescale/linux-fslc.git

0 Kudos

3,056 Views
igorpadykov
NXP Employee
NXP Employee

> i use U-Boot and kernel from Freescale's Yocto repo. Isn't it official?

>git://github.com/Freescale/linux-fslc.git

no.

Official (and supported by nxp) is Code Aurora git repositories 

linux-fslc is community linux not supported by nxp. More detailed description:

difference between Yocto Community BSP and Freescale BSP Release 


Best regards
igor

0 Kudos

3,056 Views
egorrumjantsev
Contributor III

Official kernel run but with same situation - in fixed mapping mode it skip second chip.

Booting Linux on physical CPU 0x0
Linux version 4.1.15-00158-g30278abfe097-dirty (shadow@rumjantsev.xxxx.ru) (gcc version 4.9.2 20140904 (prerelease) (crosstool-NG linaro-1.1
3.1-4.9-2014.09 - Linaro GCC 4.9-2014.09) ) #1 SMP PREEMPT Fri Aug 23 12:34:52 YEKT 2019
CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: Freescale i.MX6 Dual Device
Ignoring memory block 0x10000000 - 0x50000000
Ignoring memory below PHYS_OFFSET: 0x10000000-0x30000000
Reserved memory: created CMA memory pool at 0x8c000000, size 320 MiB

So it runs but same issues like from Yocto repo. Sadly....

0 Kudos

3,056 Views
igorpadykov
NXP Employee
NXP Employee

there are ready to use settings for LPDDR2  SCM board SCM-i.MX6D: Single-Chip Module  :

there are examples:

    memory: memory {
        linux,usable-memory = <0x10000000 0x20000000
                       0x80000000 0x20000000>;
    };

imx6dqscm-1gb-evb-fix-ldo.dts\dts\boot\arm\arch - linux-imx - i.MX Linux kernel 

mx6dqscm\freescale\board - uboot-imx - i.MX U-Boot 

imx6dqscm-1gb-interleave-android.dtsi\dts\boot\arm\arch - linux-imx - i.MX Linux kernel 

0 Kudos

3,057 Views
egorrumjantsev
Contributor III

Ok. I moved a little.

If i would change PAGE_OFFSET to 0x10000000 both kernels is start booting

Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0x0
Linux version 4.1.52-03834-ge80a1733ac87-dirty (shadow@rumjantsev.xxxx.ru) (gcc version 4.9.2 20140904 (prerelease) (crosstool-NG linaro-1.1
3.1-4.9-2014.09 - Linaro GCC 4.9-2014.09) ) #20 SMP PREEMPT Mon Aug 26 14:57:32 YEKT 2019
CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: Freescale i.MX6 Dual Device
early_init_dt_add_memory_arch(): PHYS_OFFSET: 0x10000000
early_init_dt_add_memory_arch(): PHYS_OFFSET: 0x10000000
Reserved memory: created CMA memory pool at 0x8c000000, size 320 MiB
Reserved memory: initialized node linux,cma, compatible id shared-dma-pool
arm_memblock_init(): Leave
Memory policy: Data cache writealloc
On node 0 totalpages: 262144
free_area_init_node: node 0, pgdat 10bc3cc0, node_mem_map 8ad57000
  Normal zone: 4608 pages used for memmap
  Normal zone: 0 pages reserved
  Normal zone: 262144 pages, LIFO batch:31
PERCPU: Embedded 13 pages/cpu @8ad19000 s20992 r8192 d24064 u53248
pcpu-alloc: s20992 r8192 d24064 u53248 alloc=13*4096
pcpu-alloc: [0] 0 [0] 1
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 257536
Kernel command line: console=ttymxc1,115200n8 root=/dev/mmcblk2p0 debug
PID hash table entries: 4096 (order: 2, 16384 bytes)
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Memory: 698484K/1048576K available (8280K kernel code, 549K rwdata, 2684K rodata, 520K init, 417K bss, 22412K reserved, 327680K cma-reserved, 0K  highmem)

Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xa0800000 - 0xff000000   (1512 MB)
    lowmem  : 0x10000000 - 0xa0000000   (2304 MB)
    pkmap   : 0x0fe00000 - 0x10000000   (   2 MB)
    modules : 0x0f000000 - 0x0fe00000   (  14 MB)
      .text : 0x10008000 - 0x10abd3c4   (10965 kB)
      .init : 0x10abe000 - 0x10b40000   ( 520 kB)
      .data : 0x10b40000 - 0x10bc9654   ( 550 kB)
       .bss : 0x10bcc000 - 0x10c34660   ( 418 kB)

.....but both kernels stop on eMMC

Galcore version 5.0.11.41671
mmc2: MAN_BKOPS_EN bit is not set
mmc2: new DDR MMC card at address 0001
mmcblk2: mmc2:0001 R1J55A 7.28 GiB
mmcblk2boot0: mmc2:0001 R1J55A partition 1 2.00 MiB
mmcblk2boot1: mmc2:0001 R1J55A partition 2 2.00 MiB
mmcblk2rpmb: mmc2:0001 R1J55A partition 3 128 KiB

..................

again in one chip mode booting continue next...

0 Kudos

3,057 Views
igorpadykov
NXP Employee
NXP Employee

Hi Egor

NXP has special service for helping with custom configurations:

NXP Professional Services | NXP 

Best regards
igor

0 Kudos

3,057 Views
egorrumjantsev
Contributor III

Thank you for your recommendations, Igor.

In result i did run Yocto's kernel in interleaved mode.

0 Kudos

3,057 Views
egorrumjantsev
Contributor III

Hi, Igor.

Unfortunatelly this settings did not work.

I have added additional debug in assembler code in head-common.S. In function lookup_processor_type which is set adresses of virtual and physical memory.

Also i have changed PAGE_OFFSET from 0x80000000 to 0x10000000

=> bootz 0x12000000 - 0x18000000
## Flattened Device Tree blob at 18000000
   Booting using the fdt blob at 0x18000000
   Using Device Tree in place at 18000000, end 1800b797

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

Value: 0x0000000c.

Value: 0x10009690.

Value: 0x10009690.

Value: 0x10779620.

Value: 0x1077985c.

Value: 0x00000000.

Value: 0x10779620.

Value: 0x1077985c.

__lookup_processor_type:
        mov r0, r3
        bl __myprintf
        adr     r3, __lookup_processor_type_data
        mov r0, r3
        bl __myprintf
        ldmia   r3, {r4 - r6}
        mov r0, r4
        bl __myprintf
        mov r0, r5
        bl __myprintf
        mov r0, r6
        bl __myprintf
        sub     r3, r3, r4                      @ get offset between virt&phys
        mov r0, r3
        bl __myprintf
        add     r5, r5, r3                      @ convert virt addresses to
        mov r0, r5
        bl __myprintf
        add     r6, r6, r3                      @ physical address space
        mov r0, r6
        bl __myprintf
1:      ldmia   r5, {r3, r4}                    @ value, mask
        and     r4, r4, r9                      @ mask wanted bits
        teq     r3, r4
        beq     2f
        add     r5, r5, #PROC_INFO_SZ           @ sizeof(proc_info_list)
        cmp     r5, r6
        blo     1b
        mov     r5, #0                          @ unknown processor
2:      ret     lr
ENDPROC(__lookup_processor_type)

So debug looks correctly, but kernel not booting. It boots if i run it from 0x80000000. I will continue debug assembler and sturtup C code, will try to find where is the problem.

WBR,

0 Kudos

3,057 Views
egorrumjantsev
Contributor III

Igor, could you tell if gcc version is important for compilation of kernel (i remembered the case 3-4 years ago when i used gcc 4.7 and kernel did not work, but with gcc 4.8 kernel run correctly)?

Could you recomment which gcc i have to use?

WBR,

0 Kudos

3,057 Views
egorrumjantsev
Contributor III

Igor, I have tried your suggested kernel. Actually it did not run in both cases - if i set up memory as 2 different address spaces and if i set up as interleaved memory spaces.

Ok, i will try to dig this kernel, will see if i will find solution.

WBR,

0 Kudos

3,057 Views
igorpadykov
NXP Employee
NXP Employee

Hi Egor

for lpddr2 usage below links may be helpful:

How to modify Bootloader and kernel to support LPDDR2? 

Problems configuring 2-Channel LPDDR2 on i.MX6Q 

Single Chip System Modules (SCM) "imx6dqscm*" dts examples in
dts\boot\arm\arch - linux-imx - i.MX Linux kernel 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos