android移植(一)-s3c2416内核的移植

板子helper2416    芯片是三星的s3c2416  arm平台   本机系统: opensuse 

以下只是记录曾经的瞎搞过程,可能有些乱。 要在板子上运行andoid首先得有一个支持android的内核

下载内核

$ git clone https://android.googlesource.com/kernel/samsung.git
$ ls -a
.  ..  .git


$ git branch -r
origin/HEAD -> origin/master
origin/android-samsung-2.6.35-gingerbread
origin/android-samsung-3.0-ics-mr1
origin/master


$ git checkout origin/android-samsung-3.0-ics-mr1
hecking out files: 100% (37465/37465), done.
Previous HEAD position was eef8e7b... empty commit
HEAD is now at 6656123... ARM: s5pv210: herring: don't disable prox sensor during suspend


$ ls
arch     CREDITS        drivers   include  Kbuild   lib          mm      REPORTING-BUGS  security  usr
block    crypto         firmware  init     Kconfig  MAINTAINERS  net     samples         sound     virt
COPYING  Documentation  fs        ipc      kernel   Makefile     README  scripts         tools


上面版本为 3.0.8


由help2416的内核与同版本的内核比较,生成patch,然后把patch打到下载的android 内核上,冲突的手动解决
编译通过后,启动出现
Memory policy: ECC disabled, Data cache writeback
<4>BUG: not creating mapping for 0x56000000 at 0x03000000 in user region


Linux内核访问外设I/O内存资源的方式有两种:动态映射(ioremap)和静态映射(map_desc)
static void __init create_mapping(struct map_desc *md)
{
    unsigned long addr, length, end;
    phys_addr_t phys;
    const struct mem_type *type;
    pgd_t *pgd;


    if (md->virtual != vectors_base() && md->virtual < TASK_SIZE) { //0x03000000这个是virtual找到对应这个就能知道哪里错
        printk(KERN_WARNING "BUG: not creating mapping for 0x%08llx"
               " at 0x%08lx in user region\n",
               (long long)__pfn_to_phys((u64)md->pfn), md->virtual);
        return;
    }
.................
}


arch/arm/mach-s3c2416/s3c2416.c
static struct map_desc s3c2416_iodesc[] __initdata = {
    IODESC_ENT(WATCHDOG),
    IODESC_ENT(CLKPWR),
    IODESC_ENT(TIMER),
};
iotable_init(s3c2416_iodesc, ARRAY_SIZE(s3c2416_iodesc));


struct map_desc {
    unsigned long virtual; ////0x03000000
    unsigned long pfn;  //0x56000000 这两个值是出错值
    unsigned long length;
    unsigned int type;
};


#define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C24XX_PA_##x), S3C24XX_SZ_##x, MT_DEVICE }


由代码可知,可能是S3C24XX_VA_WATCHDOG/CLKPWR/TIMER 中的一个或几个值不对 或者是S3C24XX_PA_xx中某个不对


另外还有一处可能是出错处
arm/mach-s3c2416/mach-smdk2416.c
static void __init smdk2416_map_io(void)
{
    s3c24xx_init_io(smdk2416_iodesc, ARRAY_SIZE(smdk2416_iodesc)); //这个函数里处理了smdk2416_iodesc还处理了s3c_iodesc
}


static struct map_desc s3c_iodesc[] __initdata = {
    IODESC_ENT(GPIO),
    IODESC_ENT(IRQ),
    IODESC_ENT(MEMCTRL),
    IODESC_ENT(UART)
};


调试发现,出错出为GPIO处
#define S3C2410_PA_GPIO    (0x56000000)
#define S3C24XX_VA_GPIO    ((S3C24XX_PA_GPIO - S3C24XX_PA_UART) + S3C24XX_VA_UART)
#define S3C24XX_SZ_GPIO    SZ_1M


S3C24XX_VA_GPIO = (0x56000000 - 0x50000000) + (0xFC000000 + 0x01000000)  = 0x03000000
解决方法
arch/arm/plat-samsung/include/plat/map-base.h
#define S3C_ADDR_BASE   (0xFC000000)
改成
#define S3C_ADDR_BASE   0xF6000000


另外启动时发现,打印信息都会打两次
比如
<6>usbcore: registered new interface driver usbfs
usbcore: registered new interface driver usbfs


查看printk源码
在vprintk中多了以下代码
#ifdef  CONFIG_DEBUG_LL
    printascii(printk_buf);
#endif


menuconfig中下面选项不配置
[ ] Kernel low-level debugging functions


=======================================================================================
kernel运行声卡驱动出问题
Error: Driver 'samsung-audio' is already registered, aborting...
ALSA device list:
  No soundcards found.


搜索发现有两处driver的  name都是"samsung-audio",而且这两个driver都编译进内核,导致冲突
sound/soc/samsung/dma.c
sound/soc/samsung/s3c-dma-wrapper.c


sound/soc/samsung/Makefile
snd-soc-s3c24xx-objs := dma.o s3c-dma-wrapper.o 
改成snd-soc-s3c24xx-objs := dma.o


此时还是无法识别声卡
sound/soc/samsung/dma.c


#ifndef CONFIG_S5P_INTERNAL_DMA  //这行去掉


static int __devinit samsung_asoc_platform_probe(struct platform_device *pdev)
{
    return snd_soc_register_platform(&pdev->dev, &samsung_asoc_platform);
}
.......
#endif //这行去掉


sound/soc/codecs/wm8753.c
static struct i2c_driver wm8753_i2c_driver = {
    .driver = {
        .name = "wm8753-codec", //注意这里与3.2.11不同
        .owner = THIS_MODULE,
.........
}


/sound/soc/samsung/smdk2416_wm8753.c
static struct snd_soc_dai_link smdk6400_dai[] = {
{ /* Hifi Playback - for similatious use with voice below */
    .name = "WM8753",
    .stream_name = "WM8753 HiFi",
    //.cpu_dai = &s3c_i2s_dai,
    //.codec_dai = &wm8753_dai[WM8753_DAI_HIFI],
    .platform_name = "samsung-audio",
    .cpu_dai_name = "s3c24xx-iis",
    .codec_dai_name = "wm8753-hifi",
    .codec_name = "wm8753-codec.0-001a", //"wm8753.0-001a", //相应改这里
    .init = smdk6400_wm8753_init,
    .ops = &smdk6400_hifi_ops,
},
};


再编译运行kernel打印出错
clk_get: could not find clock iis for dev 0xc03e9f38 (s3c24xx-iis)


arch/arm/plat-s3c24xx/s3c2443-clock.c
static struct clk init_clocks_off[] = {
    //加上
    {
        .name       = "iis", //这个是针对s3c24xx-iis的
        .id     = -1,
        .parent     = &clk_p,
        .enable     = s3c2443_clkcon_enable_p,
        .ctrlbit    = S3C2443_PCLKCON_IIS,
    }, {
        .name       = "hsspi", //这个是spi的,跟上面的错误无关,随便加的
        .id     = -1,
        .parent     = &clk_p,
        .enable     = s3c2443_clkcon_enable_p,
        .ctrlbit    = S3C2443_PCLKCON_HSSPI,
    },
}


arch/arm/mach-s3c2410/include/mach/regs-s3c2443-clock.h
加上
#define S3C2443_PCLKCON_HSSPI       (1<<6)


选中Android内核必须选项
Kernel Features  ---> [*] Use the ARM EABI to compile the kernel
Device Drivers ---> [*] Staging drivers  --->       Android  --->  
[*] Android Drivers
[*]   Android Binder IPC Driver
<*>   Android log driver
[*]   Android RAM buffer console
[*]     Enable verbose console messages on Android RAM console (NEW)
[*]     Android RAM Console Enable error correction  --->
[ ]     Start Android RAM console early (NEW)
[*]   Timed output class driver (NEW)
<*>     Android timed gpio driver
[*]   Android Low Memory Killer


-> General setup--> [ ] Configure standard kernel features (expert users)  --->
-> General setup-->[*]Enable the Anonymous Shared Memory Subsystem
-> System Type-->[*]Support Thumb user binaries
   作者:帅得不敢出门   c++哈哈堂群:31843264  转载请保留此信息

你可能感兴趣的:(android移植(一)-s3c2416内核的移植)