Kernel Configuration for SAM9G45 using second DRAM bank

Discussion around AT91RM9200 and SAM9 Series Products.

Moderator: nferre

jay214128
Posts: 7
Joined: Fri Jan 23, 2015 3:29 am

Kernel Configuration for SAM9G45 using second DRAM bank

Tue Aug 01, 2017 7:50 pm

I have a legacy platform based on the SAM9G45 running linux 3.2.y that uses both banks of DRAM of 128MB each. In the 3.2 kernel, I selected:

Code: Select all

ARCH_SPARSEMEM_ENABLE
ARCH_SELECT_MEMORY_MODEL
NEED_MACH_MEMORY_H

and modified the __phys_to_virt() and __virt_to_phys() macros (arch/arm/mach-at91/include/mach/memory.h) to perform the desired mappings: physical 0x70000000 -> virtual 0xC0000000 and physical 0x20000000 -> virtual 0xC7000000.

I am trying to accomplish the same thing with the 4.4.68 kernel, however I am running into a kernel configuration circular dependency problem.

ARCH_SPARSEMEM_ENABLE depends on NEED_MACH_MEMORY_H
NEED_MACH_MEMORY_H fails because ARCH_MULTIPLATFORM is selected.
ARCH_MULTIPLATFORM is selected by default when MMU is selected, which I also need.

I attempted to define my own platform configuration to remove ARCH_MULTIPLATFORM, but failed. I need ARCH_AT91 and ARCH_AT91SAM9, but they require ARCH_MULTI_V5, which requires ARCH_MULTIPLATFORM.

Is there a way to use ARCH_SPARSEMEM_ENABLE and NEED_MACH_MEMORY_H on an SAM9G45 with the 4.4 kernel?
blue_z
Location: USA
Posts: 1505
Joined: Thu Apr 19, 2007 10:15 pm

Re: Kernel Configuration for SAM9G45 using second DRAM bank

Wed Aug 02, 2017 11:08 pm

jay214128 wrote:ARCH_SPARSEMEM_ENABLE depends on NEED_MACH_MEMORY_H
Please clarify. I see no such dependency in the Kconfig file.
jay214128 wrote: NEED_MACH_MEMORY_H fails because ARCH_MULTIPLATFORM is selected.
How does a configuration variable "fail"?

Regards
jay214128
Posts: 7
Joined: Fri Jan 23, 2015 3:29 am

Re: Kernel Configuration for SAM9G45 using second DRAM bank

Fri Aug 04, 2017 8:58 pm

Compilation fails when ARCH_SPARSEMEM_ENABLE is configured and NEED_MACH_MEMORY_H is not

Code: Select all

  CC      arch/arm/kernel/asm-offsets.s
In file included from include/linux/page-flags-layout.h:25:0,
                 from include/linux/mm_types.h:14,
                 from include/linux/sched.h:27,
                 from arch/arm/kernel/asm-offsets.c:14:
./arch/arm/include/asm/sparsemem.h:21:2: error: #error Sparsemem is not supported on this platform
 #error Sparsemem is not supported on this platform
  ^
NEED_MACH_MEMORY_H does not compile when ARCH_MULTIPLATFORM is configured. I have patched arch/arm/Makefile to get passed this.

Code: Select all

Index: arch/arm/Makefile
===================================================================
--- arch/arm/Makefile	(revision 4657)
+++ arch/arm/Makefile	(working copy)
@@ -263,10 +263,17 @@ ifeq ($(KBUILD_SRC),)
 KBUILD_CPPFLAGS += $(patsubst %,-I%include,$(machdirs) $(platdirs))
 else
 KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs) $(platdirs))
 endif
 endif
+ifeq ($(CONFIG_NEED_MACH_MEMORY_H),y)
+ifeq ($(KBUILD_SRC),)
+KBUILD_CPPFLAGS += $(patsubst %,-I%include,$(machdirs))
+else
+KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
+endif
+endif
 
 export	TEXT_OFFSET GZFLAGS MMUEXT
 
 # Do we have FASTFPE?
 FASTFPE		:=arch/arm/fastfpe
But then compilation fails with

Code: Select all

  CC      arch/arm/kernel/setup.o
In file included from ./arch/arm/include/asm/memory.h:17:0,
                 from ./arch/arm/include/asm/delay.h:9,
                 from include/linux/delay.h:14,
                 from arch/arm/kernel/setup.c:14:
arch/arm/kernel/setup.c: In function 'arm_add_memory':
./arch/arm/include/asm/memory.h:135:29: error: 'CONFIG_PHYS_OFFSETUL' undeclared (first use in this function)
 #define PLAT_PHYS_OFFSET UL(CONFIG_PHYS_OFFSET)
                             ^
I finally tracked this down to a change from 3.2.y to 4.4.y kernels. In 3.2, it was PHYS_OFFSET, in 4.4, it is CONFIG_PHYS_OFFSET. I changed this in my memory.h header, along with the missing prototype declarations for __pv_phys_pfn_offset and __pv_offset. The code now compiles. The next thing I need to get working is early_init_dt_add_memory_arch().
blue_z
Location: USA
Posts: 1505
Joined: Thu Apr 19, 2007 10:15 pm

Re: Kernel Configuration for SAM9G45 using second DRAM bank

Sat Aug 05, 2017 2:18 am

jay214128 wrote:I finally tracked this down to a change from 3.2.y to 4.4.y kernels.
Actually there are a lot changes between 3.2 and 4.4 that require major revision to "your modifications" (that are probably copied without attribution) for using two memory banks.
Since Linux kernel version 4.1, the mach-at91 is fully committed to supporting Device Tree and configuring kernels to run on more than one SoC.
Version 4.0 was the last version that permitted individual specification of an AT91 SoC. Since that version the makefile include paths, mach header files, and linker scripts have evolved.

IMO the sensible method of enabling SPARSEMEM is to restore the concept of specifying a kernel for a single AT91 SoC, i.e. do not try to hack around ARCH_MULTIPLATFORM and ARCH_MULTI_V5.

Regards

Return to “SAM9 ARM9 MPU”

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 3 guests