Wednesday, July 7, 2010

Porting Linux kernel on ARM from scratch

Create new directory mach-PuppyBeagle  under arch/arm.
Create include/mach/ folder under PuppyBeagle

 Following header files created under this directory:
  • hardware.h -Nothing added yet
  • io.h -
    • Following lines copied and added from other mach directory
    • #define IO_SPACE_LIMIT 0xffffffff

      /*
       * We don't actually have real ISA nor PCI buses, but there is so many
       * drivers out there that might just work if we fake them...
       */
      #define __io(a)        __typesafe_io(a)
      #define __mem_pci(a)    (a)
  • irqs.h -
    • /*TODO: Temporary declaration, to be corrected*/
      #define NR_IRQS        96
  • memory.h -
    • #define PHYS_OFFSET    0x80000000
  • system.h -
    • void arch_reset(char mode, const char *cmd);
      void arch_idle(void);
  • timex.h -
    • #define CLOCK_TICK_RATE        32768 (Copied from other mach directory)
  • uncompress.h -
    • Added UART3 physical addr pointer to get decompress message from early compressed kernel
    • #define UART3_TX_REG    0x49020000

      inline void arch_decomp_setup(void)
      {
      }

      inline void putc (char c)
      {
          u32 *reg_uart_tx = (u32 *)UART3_TX_REG;
          *reg_uart_tx = c;
      }

      inline void flush (void)
      {
      }
  • vmalloc.h -
    • #define VMALLOC_END    0xFF000000  (Copied from other mach directory)

 You also need to add a assembly file under this same include/mach directory:
  • entry-macro.S -
    • (Copied from other mach directory)
    •     .macro    get_irqnr_preamble , base, tmp
          .endm

          .macro  arch_ret_to_user, tmp1, tmp2
          .endm

          .macro    get_irqnr_and_base, irqnr, irqstat, base, tmp
          .endm

          .macro    disable_fiq
          .endm
Create a Kconfig file under mach-PuppyBeagle directory to provide additional configuration options while preparing for building the image (to get options under menuconfig)

You need to add a  Makefile for any source files to be compiled under this directory.
You also need to add an additional file named Makefile.boot  to include zreladdr value.

Add a new entry in arch/arm/KConfig for PuppyBeagle:

config ARCH_PUPPYBEAGLE
    bool "Puppy Beagle"
    select GENERIC_GPIO
    select HAVE_CLK
    select CPU_V7
    help
      Puppy Beagle series based systems

Also add


source "arch/arm/mach-puppybeagle/Kconfig"

to source additional configuration file from above PATH

No comments:

Post a Comment