ポーティングについて

おせわになります。いっとうです。

 

APRZA0AとLCD-KIT-B01の組み合わせで、アメリカサイトのBSPv1.3にて動作させようとしています。

buildrootの先のアドバイスのお陰でU-bootは動くようになりましたが、kernelの方が手こずっております。

APRZA0AのBSPはかなり古いため(linux3.8.13)、まずはここにあるboard-rskrza1.cとBSPv1.3(linux3.14)のboard-rskrza1.cの差分を

把握しようとしていますが、前者は446行、後者は2311行とかなり増えていて、何が変わったのか把握出来ず困っています。

まずはlogin画面まで行きたいと思っているのですが、1ヶ月やってみたもののStarting kernel …で止まったままでお手上げになりました。

 

このバージョン間の履歴みたいなものを調べる方法は無いものでしょうか。https://github.com/renesas-rz を見ても、linux3.14以前のデータを見つけることが出来ません。

Parents
  • RZ/A1 に対しては、

    (1) 最初に GENMAI ボードに Linux 3.8 が、
    (2) 
    次いで RSK ボードに Linux 3.8 が、
    (3) 
    その後、RSK ボードに Linux 3.14 が、

    この順序で移植されました。現在、ここ(Japanese community サイトの "サンプルプログラム等")には、(1) が、
    English community サイトの "RZ Forum" の "Files - Linux" には、(3) が、それぞれ登録されています。
    ですから、RZ/A1 Linux BSP に 3.8 と 3.14 の間の履歴は、存在しません。

    また、(1) の board-rskrza1.c と (3) の board-rskrza1.c の差分を調査されているようですが、(1) の board-rskrza1.c は、
    GENMAI ボード用、
    (3) の board-rskrza1.c は RSK ボード用です。(1) の board-rskrza1.c と (3) の board-genmai.c が
    正しい組み合わせです。
    諸般の事情でこのようになっていますが、混乱されたかもしれません。お詫び致します。

    移植については、最初は、RZ/A1 Linux BSP Porting Guide などを参考にして、(3) の BSP を APRZA0A に新規に移植
    するつもりで作業された方が速いかもしれません。"Starting kernel …" で止まってしまうということですから、
    Porting Guide の "12. Kernel: Enable (Early) Low Level Debugging for Linux Booting" の early_printk が役に立つ
    かもしれません。 

  • 返信ありがとうございます。

    XIPが理解出来ていないので、通常のuImageにて動作させようとしています。古いBSPのブートログはこんな感じです。
    U-Boot 2013.04 (Apr 17 2017 - 16:21:18)

    I2C: ready
    DRAM: 32 MiB
    Using default environment

    In: serial
    Out: serial
    Err: serial
    Net: sh_eth
    Hit any key to stop autoboot: 0
    (Re)start USB...
    USB0: scanning bus 0 for devices... 2 USB Device(s) found
    scanning usb for storage devices... 1 Storage Device(s) found
    2808968 bytes read in 2712 ms (1010.7 KiB/s)
    308 bytes read in 72 ms (3.9 KiB/s)
    ## Booting kernel from Legacy Image at 0c100000 ...
    Image Name: Linux-3.8.13-aprza0a-1.0
    Created: 2017-04-17 7:29:45 UTC
    Image Type: ARM Linux Kernel Image (uncompressed)
    Data Size: 2808904 Bytes = 2.7 MiB
    Load Address: 0c008000
    Entry Point: 0c008000
    Verifying Checksum ... OK
    ## Flattened Device Tree blob at 0c000000
    Booting using the fdt blob at 0x0c000000
    Loading Kernel Image ... OK
    OK
    Loading Device Tree to 0def1000, end 0def4133 ... OK

    Starting kernel ...

    console [ttySC4] enabled, bootconsole disabled
    sh-sci.5: ttySC5 at MMIO 0xe8009800 (irq = 243) is a scif
    sh-sci.6: ttySC6 at MMIO 0xe800a000 (irq = 247) is a scif
    sh-sci.7: ttySC7 at MMIO 0xe800a800 (irq = 251) is a scif
    rspi rspi.0: master is unqueued, this is deprecated
    rspi rspi.0: probed
    rspi rspi.1: master is unqueued, this is deprecated
    rspi rspi.1: probed
    rspi rspi.2: master is unqueued, this is deprecated
    rspi rspi.2: probed
    rspi rspi.3: master is unqueued, this is deprecated
    rspi rspi.3: probed
    rspi rspi.4: master is unqueued, this is deprecated
    rspi rspi.4: probed
    Info : OTP bit = 1 (CR1 = 0xff, SR1 = 0x00)
    m25p80 spi5.0: found n25q128a13, expected s25fl512s
    m25p80 spi5.0: n25q128a13 (16384 Kbytes)
    Creating 4 MTD partitions on "m25p80":
    0x000000000000-0x000000080000 : "spibsc0_loader"
    0x000000080000-0x0000000c0000 : "spibsc0_bootenv"
    0x0000000c0000-0x0000004c0000 : "spibsc0_kernel"
    0x0000004c0000-0x000001000000 : "spibsc0_rootfs"
    spibsc spibsc.0: probed
    CAN device driver interface
    libphy: sh_mii: probed
    Base address at 0xe8203000, 00:0c:7b:38:02:22, IRQ 359.
    r8a66597_hcd r8a66597_hcd.0: USB Host Controller
    r8a66597_hcd r8a66597_hcd.0: new USB bus registered, assigned bus number 1
    r8a66597_hcd r8a66597_hcd.0: irq 73, io base 0xe8010000
    usb usb1: default language 0x0409
    usb usb1: udev 1, busnum 1, minor = 0
    usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
    usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
    usb usb1: Product: USB Host Controller
    usb usb1: Manufacturer: Linux 3.8.13-aprza0a-1.0 r8a66597_hcd
    usb usb1: SerialNumber: r8a66597_hcd
    usb usb1: usb_probe_device
    usb usb1: configuration #1 chosen from 1 choice
    usb usb1: adding 1-0:1.0 (config #1, interface 0)
    ・・・以下略

    U-bootをv1.3で作成してカーネルとルートファイルシステムは古いままでも起動は確認できました。
    =>usb start
    =>ext2load usb 0 0x0c100000 /uImage
    =>ext2load usb 0 0x0c000000 /hoge.dtb
    =>bootm 0x0c100000 - 0x0c000000

    printkを組み込む為にmenuconfigを設定し、上記bootに対してPortingGuideのxargsを反映させようとしていますが、mtdblock0の部分はsda1に置き換えてみましたがエラーが出ます。USBメモリにuImage,rootfsを作成しています。シリアルはSC4と読み替えています。

    => set xargs 'console=ttySC4,115200 console=tty0 ignore_loglevel root=/dev/sda1 earlyprintk'
    => bootm 0x0c100000 - 0x0c000000
    Wrong Image Format for bootm command
    ERROR: can't get kernel image!

    この部分、デバイスはどのような指定になるでしょうか。
  • > アドバイス頂いた点を見直して、何かしら表示されるようになりました。

    earlyprintk が有効になったようですから、board ファイルの修正を始めましょう。

    > => bootm 0x0d000000 - 0x0d800000
    > ## Booting kernel from Legacy Image at 0d000000 ...
        (略)
    > Starting kernel ...
    >
    > Booting Linux on physical CPU 0x0
        (略)
    > Kernel command line: console=ttySC4,115200 root=/dev/sda1 rw rootdelay=3 ignore_loglevel earlyprintk=sh-sci.2,115200
        (略)
    > bootconsole [earlycon0] disabled

    bootargs 指定時、起動メッセージがここで途切れてしまうのは、bootargs で指定した
    ttySC4 のドライバが正しく初期化できていないからです。

    「BSP Porting Guide」の「13. Kernel: Editing Your Board File」に従って、
    最初に board ファイル(仮に board-aprza0a.c とします) を作成してください。
    RSKRZA1 ボードは、ttySC2 をコンソールにしていますから、これを ttySC4 に
    変更します。次の2か所を修正します。
    # 行番号は、Github の最新のソースのものです。

    ----
      1159 /* BOARD: To save on RAM usage, we are only declaring the SCIF
      1160           channels we plan on using. Modify if you plan on
      1161           using other channels */
      1162 //R7S72100_SCIF(0, 0xe8007000, gic_iid(221));   /* Not used */
      1163 //R7S72100_SCIF(1, 0xe8007800, gic_iid(225));   /* Not used */
    - 1164 R7S72100_SCIF(2, 0xe8008000, gic_iid(229));
    +      //R7S72100_SCIF(2, 0xe8008000, gic_iid(229));
      1165 //R7S72100_SCIF(3, 0xe8008800, gic_iid(233));   /* Not used */
    - 1166 //R7S72100_SCIF(4, 0xe8009000, gic_iid(237));   /* Not used */
    +      R7S72100_SCIF(4, 0xe8009000, gic_iid(237));     /* Not used */
      1167 //R7S72100_SCIF(5, 0xe8009800, gic_iid(241));   /* Not used */

    ----
      1879 static void __init rskrza1_add_standard_devices(void)
      1880 {
        (略)
      2041
      2042 //      r7s72100_register_scif(0);      /* SCIF ch0 */ /* Not used */
      2043 //      r7s72100_register_scif(1);      /* SCIF ch1 */ /* Not used */
    - 2044         r7s72100_register_scif(2);      /* SCIF ch2 */
    +      //      r7s72100_register_scif(2);      /* SCIF ch2 */
      2045 //      r7s72100_register_scif(3);      /* SCIF ch3 */ /* Not used */
    - 2046 //      r7s72100_register_scif(4);      /* SCIF ch4 */ /* Not used */
    +              r7s72100_register_scif(4);      /* SCIF ch4 */ /* Not used */
      2047 //      r7s72100_register_scif(5);      /* SCIF ch5 */ /* Not used */
      2048 //      r7s72100_register_scif(6);      /* SCIF ch6 */ /* Not used */
      2049 //      r7s72100_register_scif(7);      /* SCIF ch7 */ /* Not used */
      2050
        (略)
      2060 }

    私は、APRZA0A の場合、SCIF のチャネル 4 の信号 TXD4 や RXD4 がどの兼用端子に
    割り当てられているか知りません。兼用端子の設定は、u-boot が行ったものを
    引き継ぐので、上の修正だけで ttySC4 が有効となり、引き続き、起動メッセージが
    表示されるはずですが、board-aprza0a.c の他の場所で、その兼用端子を他の用途に
    使用してしまうと、表示出来なくなります。

    r7s72100_pfc_pin_assign 関数が、兼用端子の設定を行う関数ですから、そうした
    ことが無いようにしてください。また、もし、この時点で、全ての兼用端子の設定を
    見直して正しく修正できるなら、直してください。

  • お世話になります。

    アドバイス頂いた方法で、一旦loginまではたどり着きました。しかし、bootargsを指定するとStarting kernel ...で止まってしまいます。
    また、X関連のバイナリをmenuconfigで指定していなかったので、その辺りを追加したところ、以下エラーでpanicになりました。
    /sbin/init: '/usr/lib/libtirpc.so.3' is not an ELF file
    /sbin/init: can't load library 'libtirpc.so.3'

    まずはlibtirpcのエラーをどうにかする前に、bootargs指定で上手く起動しない件を修正しようとしております。U-bootに問題があると判断して作り直しているのですが、なかなかビルドが通りません。元々動いていたU-bootは、旧aprza0aのU-bootを参考に、rskrza1の殆どの部分をコメントアウトして通していました。
    今はrskrza1のU-bootをそのまま生かす形でaprza0aの設定を反映させようとして頓挫しています。

    旧aprza0aのソースではlowlevel_init.Sでポートの初期化を実行しているように見えますが、rskrza1はlowlevel_init.Sでは実行していないように見えます。

    u-boot-2013.04-apra0a/board/alphaproject/ap_rza_0a/lowlevel_init.S
    /*
    * Copyright (C) 2008-2014 Renesas Solutions Corp.
    * Copyright (C) 2012 Renesas Electronics Europe Ltd.
    * Copyright (C) 2012 Phil Edworthy
    * Copyright (C) 2008 Nobuhiro Iwamatsu
    *
    * Based on board/renesas/rsk7264/lowlevel_init.S
    *
    * This file is released under the terms of GPL v2 and any later version.
    * See the file COPYING in the root directory of the source tree for details.
    */
    #include <config.h>
    #include <version.h>
    #include <asm/arch/rza1-regs.h>
    #include <asm/macro.h>

    .global lowlevel_init

    .text
    .align 2

    lowlevel_init:
    /* PL310 init */
    write32 0x3FFFFF80, 0x00000001

    /* Disable WDT */
    write16 WTCSR, WTCSR_D
    write16 WTCNT, WTCNT_D

    /* Disable Register Bank interrupts */
    /* write16 IBNR, IBNR_D */

    /* Set clocks */
    write16 FRQCR, FRQCR_D
    write16 FRQCR2, FRQCR2_D

    /* Enable all peripherals(Standby Control) */
    write8 STBCR2, STBCR2_D
    write8 STBCR3, STBCR3_D
    write8 STBCR4, STBCR4_D
    write8 STBCR5, STBCR5_D
    write8 STBCR6, STBCR6_D
    write8 STBCR7, STBCR7_D
    write8 STBCR8, STBCR8_D
    write8 STBCR9, STBCR9_D
    write8 STBCR10, STBCR10_D
    write8 STBCR11, STBCR11_D
    write8 STBCR12, STBCR12_D

    /* Port Control Register */

    /* Port0 */
    write16 PIBC0, PIBC0_D

    write16 PMC0, PMC0_S
    write16 PIBC0, PIBC0_S

    /* PORT1 */
    write16 PIBC1, PIBC1_D
    write16 PBDC1, PBDC1_D
    write16 PM1, PM1_D
    write16 PMC1, PMC1_D
    write16 PIPC1, PIPC1_D

    write16 PBDC1, PBDC1_S
    write16 PFC1, PFC1_S
    write16 PFCE1, PFCE1_S
    write16 PFCAE1, PFCAE1_S
    write16 PIPC1, PIPC1_S
    write16 PMC1, PMC1_S
    write16 P1, P1_S
    write16 PM1, PM1_S
    write16 PIBC1, PIBC1_S

    /* PORT2 */
    write16 PIBC2, PIBC2_D
    write16 PBDC2, PBDC2_D
    write16 PM2, PM2_D
    write16 PMC2, PMC2_D
    write16 PIPC2, PIPC2_D

    write16 PBDC2, PBDC2_S
    write16 PFC2, PFC2_S
    write16 PFCE2, PFCE2_S
    write16 PFCAE2, PFCAE2_S
    write16 PIPC2, PIPC2_S
    write16 PMC2, PMC2_S
    write16 P2, P2_S
    write16 PM2, PM2_S
    write16 PIBC2, PIBC2_S

    /* PORT3 */
    write16 PIBC3, PIBC3_D
    write16 PBDC3, PBDC3_D
    write16 PM3, PM3_D
    write16 PMC3, PMC3_D
    write16 PIPC3, PIPC3_D

    write16 PBDC3, PBDC3_S
    write16 PFC3, PFC3_S
    write16 PFCE3, PFCE3_S
    write16 PFCAE3, PFCAE3_S
    write16 PIPC3, PIPC3_S
    write16 PMC3, PMC3_S
    write16 P3, P3_S
    write16 PM3, PM3_S
    write16 PIBC3, PIBC3_S

    /* PORT4 */
    write16 PIBC4, PIBC4_D
    write16 PBDC4, PBDC4_D
    write16 PM4, PM4_D
    write16 PMC4, PMC4_D
    write16 PIPC4, PIPC4_D
    write16 PMC4, PMC4_S
    write16 P4, P4_S
    write16 PM4, PM4_S
    write16 PIBC4, PIBC4_S

    /* PORT5 */
    write16 PIBC5, PIBC5_D
    write16 PBDC5, PBDC5_D
    write16 PM5, PM5_D
    write16 PMC5, PMC5_D
    write16 PIPC5, PIPC5_D

    write16 PBDC5, PBDC5_S
    write16 PFC5, PFC5_S
    write16 PFCE5, PFCE5_S
    write16 PFCAE5, PFCAE5_S
    write16 PIPC5, PIPC5_S
    write16 PMC5, PMC5_S
    write16 P5, P5_S
    write16 PM5, PM5_S
    write16 PIBC5, PIBC5_S

    /* PORT6 */
    write16 PIBC6, PIBC6_D
    write16 PBDC6, PBDC6_D
    write16 PM6, PM6_D
    write16 PMC6, PMC6_D
    write16 PIPC6, PIPC6_D

    write16 PBDC6, PBDC6_S
    write16 PFC6, PFC6_S
    write16 PFCE6, PFCE6_S
    write16 PFCAE6, PFCAE6_S
    write16 PIPC6, PIPC6_S
    write16 PMC6, PMC6_S
    write16 P6, P6_S
    write16 PM6, PM6_S
    write16 PIBC6, PIBC6_S

    /* PORT7 */
    write16 PIBC7, PIBC7_D
    write16 PBDC7, PBDC7_D
    write16 PM7, PM7_D
    write16 PMC7, PMC7_D
    write16 PIPC7, PIPC7_D

    write16 PBDC7, PBDC7_S
    write16 PFC7, PFC7_S
    write16 PFCE7, PFCE7_S
    write16 PFCAE7, PFCAE7_S
    write16 PIPC7, PIPC7_S
    write16 PMC7, PMC7_S
    write16 P7, P7_S
    write16 PM7, PM7_S
    write16 PIBC7, PIBC7_S

    /* PORT8 */
    write16 PIBC8, PIBC8_D
    write16 PBDC8, PBDC8_D
    write16 PM8, PM8_D
    write16 PMC8, PMC8_D
    write16 PIPC8, PIPC8_D

    write16 PBDC8, PBDC8_S
    write16 PFC8, PFC8_S
    write16 PFCE8, PFCE8_S
    write16 PFCAE8, PFCAE8_S
    write16 PIPC8, PIPC8_S
    write16 PMC8, PMC8_S
    write16 P8, P8_S
    write16 PM8, PM8_S
    write16 PIBC8, PIBC8_S

    /* Configure SDRAM (CS3) */
    write32 CS3BCR, CS3BCR_D
    write32 CS3WCR, CS3WCR_D
    write32 SDCR, SDCR_D
    write32 RTCOR, RTCOR_D
    write32 RTCSR, RTCSR_D

    /* wait */
    ldr r3, REPEAT_D
    mov r2, #0
    repeat0:
    add r2, r2, #1
    cmp r2, r3
    ble repeat0
    nop

    /* write16 0x3FFFE440, 0x0000 */
    write16 SDRAM_MODE_CS3, 0x0000

    nop
    /* back to arch calling code */
    mov pc, lr

    .align 4

    .align 2
    SDRAM_MODE_CS3: .long 0x3FFFE440
    REPEAT_D: .long 0x000033F1

    1. r7s72100_pfc_pin_assign 関数でPINの設定をしているとのことですが、U-bootでも設定しているという認識で良いでしょうか。
    2. 旧BSPのU-bootと新BSPのU-bootではPINの設定をしているソースが違うのでしょうか。旧はlowlevel_init.Sで設定し、新はrskrza1.cで設定している?
  • > 1. r7s72100_pfc_pin_assign 関数でPINの設定をしているとのことですが、
    > U-bootでも設定しているという認識で良いでしょうか。

    はい、(新BSPのu-bootでは) pfc_set_gpioやpfc_set_pin_function関数で設定しています。

    > 2. 旧BSPのU-bootと新BSPのU-bootではPINの設定をしているソースが違うのでしょうか。
    > 旧はlowlevel_init.Sで設定し、新はrskrza1.cで設定している?

    はい、旧BSPは、lowlevel_init.Sで1ポートごとに(16端子まとめて)、
    新BSPは、rskrza1.cで1端子ごとに、それぞれ初期化しています。
    移植しやすいように変更したのだと思います。

  • お世話になります。
    U-bootのPIN情報がrskrza1のまま変更していなかった為、見直して変更しました。
    ・NOR,NANDフラッシュが無いこと
    ・SDRAMがCS2でなくCS3であること
    ・QSPIフラッシュが2個パラではなく1個だけ

    #include <common.h>
    #include <asm/io.h>
    #include <asm/processor.h>
    #include <i2c.h>
    #include <rtc.h>
    #include <asm/arch/rza1-regs.h>

    #include <spi.h>
    #include <spi_flash.h>

    /* This function temporary disables the feature of OR-ing the results of
    commands together when using dual spi flash memory. When using single
    flash, it does nothing. */
    void qspi_disable_auto_combine(void);

    //#define DEBUG

    略・・・

    int checkboard(void)
    {
    puts("BOARD: AlphaProject AP-RZA-0A\n");
    return 0;
    }

    int board_init(void)
    {
    gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100);
    return 0;
    }

    int board_early_init_f(void)
    {
    /* This function runs early in the boot process, before u-boot is relocated
    to RAM (hence the '_f' in the function name stands for 'still running from
    flash'). A temporary stack has been set up for us which is why we can
    have this as C code. */

    int i;

    /* When booting from Parallel NOR, some pins need to be bi-directional */
    /* CS0, RD, A1-A15 */
    #if defined(CONFIG_BOOT_MODE0)
    #define NOR_BIDIR 1
    /* TODO: Replace '0' with 'NOR_BIDIR for those pins below */
    #else
    #define NOR_BIDIR 0
    #endif

    rtc_reset(); /* to start rtc */

    /* =========== Pin Setup =========== */
    /* Specific for the RZ/H on the RSK board. Adjust for your board as needed. */
    /* LCD */
    //pfc_set_pin_function(1, 5, ALT4, 0, 0); /* P1_5 = IRQ5 (LCD_IRQ) */ /* NOTE: u-boot doesn't enable interrupts */
    pfc_set_pin_function(3, 0, ALT1, 0, 0); /* P3_0 = LCD0_CLK */
    pfc_set_pin_function(3, 1, ALT1, 0, 0); /* P3_1 = LCD0_TCON0 */
    pfc_set_pin_function(3, 2, ALT1, 0, 0); /* P3_2 = LCD0_TCON1 */
    pfc_set_pin_function(3, 7, ALT1, 0, 0); /* P3_7 = LCD0_TCON6 */
    pfc_set_pin_function(3, 8, ALT1, 0, 0); /* P3_8 = LCD0_DATA0 */
    pfc_set_pin_function(3, 9, ALT1, 0, 0); /* P3_9 = LCD0_DATA1 */
    pfc_set_pin_function(3, 10, ALT1, 0, 0); /* P3_10 = LCD0_DATA2 */
    pfc_set_pin_function(3, 11, ALT1, 0, 0); /* P3_11 = LCD0_DATA3 */
    pfc_set_pin_function(3, 12, ALT1, 0, 0); /* P3_12 = LCD0_DATA4 */
    pfc_set_pin_function(3, 13, ALT1, 0, 0); /* P3_13 = LCD0_DATA5 */
    pfc_set_pin_function(3, 14, ALT1, 0, 0); /* P3_14 = LCD0_DATA6 */
    pfc_set_pin_function(3, 15, ALT1, 0, 0); /* P3_15 = LCD0_DATA7 */
    pfc_set_pin_function(4, 0, ALT1, 0, 0); /* P4_0 = LCD0_DATA8 */
    pfc_set_pin_function(4, 1, ALT1, 0, 0); /* P4_1 = LCD0_DATA9 */
    pfc_set_pin_function(4, 2, ALT1, 0, 0); /* P4_2 = LCD0_DATA10 */
    pfc_set_pin_function(4, 3, ALT1, 0, 0); /* P4_3 = LCD0_DATA11 */
    pfc_set_pin_function(4, 4, ALT1, 0, 0); /* P4_4 = LCD0_DATA12 */
    pfc_set_pin_function(4, 5, ALT1, 0, 0); /* P4_5 = LCD0_DATA13 */
    pfc_set_pin_function(4, 6, ALT1, 0, 0); /* P4_6 = LCD0_DATA14 */
    pfc_set_pin_function(4, 7, ALT1, 0, 0); /* P4_7 = LCD0_DATA15 */
    pfc_set_pin_function(4, 8, ALT1, 0, 0); /* P4_8 = LCD0_DATA16 */
    pfc_set_pin_function(4, 9, ALT1, 0, 0); /* P4_9 = LCD0_DATA17 */

    /* SD */
    //pfc_set_pin_function(1, 4, ALT4, 0, 0); /* P1_4 = IRQ4 (SD_IRQ) */ /* NOTE: u-boot doesn't enable interrupts */
    pfc_set_pin_function(4, 10, ALT3, 0, 0); /* P4_10 = SD_D1_0 */
    pfc_set_pin_function(4, 11, ALT3, 0, 0); /* P4_11 = SD_D0_0 */
    pfc_set_pin_function(4, 12, ALT3, 0, 0); /* P4_12 = SD_CLK_0 */
    pfc_set_pin_function(4, 13, ALT3, 0, 0); /* P4_13 = SD_CMD_0 */
    pfc_set_pin_function(4, 14, ALT3, 0, 0); /* P4_14 = SD_D3_0 */
    pfc_set_pin_function(4, 15, ALT3, 0, 0); /* P4_15 = SD_D2_0 */

    /* Serial Console */
    pfc_set_pin_function(5, 0, ALT5, 0, 0); /* P5_0 = TxD4 */
    pfc_set_pin_function(5, 1, ALT5, 0, 0); /* P5_1 = RxD4 */

    /* QSPI_0 ch0 (booted in 1-bit, need to change to 4-bit) */
    pfc_set_pin_function(9, 2, ALT2, 0, 0); /* P9_2 = SPBCLK_0 */
    pfc_set_pin_function(9, 3, ALT2, 0, 0); /* P9_3 = SPBSSL_0 */
    pfc_set_pin_function(9, 4, ALT2, 0, 1); /* P9_4 = SPBIO00_0 (bi dir) */
    pfc_set_pin_function(9, 5, ALT2, 0, 1); /* P9_5 = SPBIO10_0 (bi dir) */
    pfc_set_pin_function(9, 6, ALT2, 0, 1); /* P9_6 = SPBIO20_0 (bi dir) */
    pfc_set_pin_function(9, 7, ALT2, 0, 1); /* P9_7 = SPBIO30_0 (bi dir) */
    /* Audio */
    //pfc_set_pin_function(1, 2, ALT4, 0, 0); /* P1_2 = IRQ2 (Audio_IRQ) */ /* NOTE: u-boot doesn't enable interrupts */
    pfc_set_pin_function(8, 8, ALT8, 0, 0); /* P8_8 = SSISCK5 */
    pfc_set_pin_function(8, 9, ALT8, 0, 0); /* P8_9 = SSIWSS */
    pfc_set_pin_function(8, 10, ALT8, 0, 0); /* P8_10 = SSITXD5 */
    pfc_set_pin_function(8, 12, ALT8, 0, 0); /* P8_12 = SSISCK4 */
    pfc_set_pin_function(8, 13, ALT8, 0, 0); /* P8_13 = SSIWS4 */
    pfc_set_pin_function(8, 14, ALT8, 0, 0); /* P8_14 = SSIDATA4 */

    /* Wireless */
    //pfc_set_pin_function(1, 3, ALT4, 0, 0); /* P1_3 = IRQ3 (Wireless_IRQ) */ /* NOTE: u-boot doesn't enable interrupts */
    pfc_set_pin_function(2, 12, ALT2, 0, 0); /* P2_12 = RSPCK0 */
    pfc_set_pin_function(2, 13, ALT2, 0, 0); /* P2_13 = SSL00 */
    pfc_set_pin_function(2, 14, ALT2, 0, 0); /* P2_14 = MOSI0 */
    pfc_set_pin_function(2, 15, ALT2, 0, 0); /* P2_15 = MISO0 */

    /* RIIC Ch 3 */
    pfc_set_pin_function(1, 6, ALT1, 0, 1); /* P1_6 = RIIC3SCL (bi dir) */
    pfc_set_pin_function(1, 7, ALT1, 0, 1); /* P1_7 = RIIC3SDA (bi dir) */

    /* Ethernet */
    pfc_set_pin_function(1, 14, ALT4, 0, 0); /* P1_14 = ET_COL */
    pfc_set_pin_function(2, 0, ALT2, 0, 0); /* P2_0 = ET_TXCLK */
    pfc_set_pin_function(2, 1, ALT2, 0, 0); /* P2_1 = ET_TXER */
    pfc_set_pin_function(2, 2, ALT2, 0, 0); /* P2_2 = ET_TXEN */
    pfc_set_pin_function(2, 3, ALT2, 0, 0); /* P2_3 = ET_CRS */
    pfc_set_pin_function(2, 4, ALT2, 0, 0); /* P2_4 = ET_TXD0 */
    pfc_set_pin_function(2, 5, ALT2, 0, 0); /* P2_5 = ET_TXD1 */
    pfc_set_pin_function(2, 6, ALT2, 0, 0); /* P2_6 = ET_TXD2 */
    pfc_set_pin_function(2, 7, ALT2, 0, 0); /* P2_7 = ET_TXD3 */
    pfc_set_pin_function(2, 8, ALT2, 0, 0); /* P2_8 = ET_RXD0 */
    pfc_set_pin_function(2, 9, ALT2, 0, 0); /* P2_9 = ET_RXD1 */
    pfc_set_pin_function(2, 10, ALT2, 0, 0); /* P2_10 = ET_RXD2 */
    pfc_set_pin_function(2, 11, ALT2, 0, 0); /* P2_11 = ET_RXD3 */
    pfc_set_pin_function(3, 3, ALT2, 0, 1); /* P3_3 = ET_MDIO (bi dir) */
    pfc_set_pin_function(3, 4, ALT2, 0, 0); /* P3_4 = ET_RXCLK */
    pfc_set_pin_function(3, 5, ALT2, 0, 0); /* P3_5 = ET_RXER */
    pfc_set_pin_function(3, 6, ALT2, 0, 0); /* P3_6 = ET_RXDV */
    pfc_set_pin_function(5, 9, ALT2, 0, 0); /* P5_9 = ET_MDC */

    /* SDRAM */
    for(i=0;i<=15;i++)
    pfc_set_pin_function(6, i, ALT1, 0, 1); /* P6_0~15 = D0-D15 (bi dir) */
    pfc_set_pin_function(7, 1, ALT1, 0, 0); /* P7_1 = CS3 */
    pfc_set_pin_function(7, 2, ALT1, 0, 0); /* P7_2 = RAS */
    pfc_set_pin_function(7, 3, ALT1, 0, 0); /* P7_3 = CAS */
    pfc_set_pin_function(7, 4, ALT1, 0, 0); /* P7_4 = CKE */
    pfc_set_pin_function(7, 5, ALT1, 0, 0); /* P7_5 = RD/WR */
    pfc_set_pin_function(7, 6, ALT1, 0, 0); /* P7_6 = WE0/DQMLL */
    pfc_set_pin_function(7, 7, ALT1, 0, 0); /* P7_7 = WE1/DQMLU */
    for(i=9;i<=15;i++)
    pfc_set_pin_function(7, i, ALT1, 0, 0); /* P7_9~15: A1-A7 */
    for(i=0;i<=7;i++)
    pfc_set_pin_function(8, i, ALT1, 0, 0); /* P8_0~7 = A8-A15 */

    /* Parallel NOR Flash */
    /* Assumes previous SDRAM setup A1-A23,D0-D15,WE0 */

    /* CAN */
    pfc_set_pin_function(9, 0, ALT2, 0, 0); /* P9_0 = CTX0 */
    pfc_set_pin_function(9, 1, ALT2, 0, 0); /* P9_1 = CRX0 */
    pfc_set_gpio(5, 2, GPIO_OUT); /* P5_2 */

    /* LED 0 */
    pfc_set_gpio(8, 15, GPIO_OUT); /* P8_15 = LED */

    /* SW1 */
    pfc_set_gpio(1, 9, GPIO_IN); /* P1_9 = GPIO_IN */
    /* SW2 */
    pfc_set_gpio(1, 8, GPIO_IN); /* P1_8 = GPIO_IN */
    /* SW3 */
    pfc_set_gpio(1, 11, GPIO_IN); /* P1_11 = GPIO_IN */


    /**********************************************/
    /* Configure NOR Flash Chip Select (CS0, CS1) */
    /**********************************************/
    #define CS0WCR_D 0x00000b40
    #define CS0BCR_D 0x10000C00
    #define CS1WCR_D 0x00000b40
    #define CS1BCR_D 0x10000C00
    *(u32 *)CS0WCR = CS0WCR_D;
    *(u32 *)CS0BCR = CS0BCR_D;
    *(u32 *)CS1WCR = CS1WCR_D;
    *(u32 *)CS1BCR = CS1BCR_D;

    /**********************************************/
    /* Configure SDRAM (CS3) */
    /**********************************************/
    #define CS3BCR_D 0x00004C00 /* Type=SDRAM, 16-bit memory */
    #define CS3WCR_D 0x0000488A /* CAS Latency = 2 */
    #define SDCR_D 0x00000811 /* 13-bit row, 9-bit col, auto-refresh */
    #define RTCOR_D 0xA55A000F
    #define RTCSR_D 0xA55A0018
    *(u32 *)CS3BCR = CS3BCR_D;
    *(u32 *)CS3WCR = CS3WCR_D;
    *(u32 *)SDCR = SDCR_D;
    *(u32 *)RTCOR = RTCOR_D;
    *(u32 *)RTCSR = RTCSR_D;

    /* wait */
    #define REPEAT_D 0x000033F1
    for (i=0;i<REPEAT_D;i++) {
    asm("nop");
    }

    /* The final step is to set the SDRAM Mode Register by written to a
    specific address (the data value is ignored) */
    /* Check the hardware manual (table 8.15) if your settings differ */
    /* Burst Length = 1 (fixed)
    * Burst Type = Sequential (fixed)
    * CAS Latency = 2 or 3 (see table 8.15)
    * Write Burst Mode = [burst read/single write] or [burst read/burst write] (see table 8.15)
    */
    #define SDRAM_MODE_CS2 0x3FFFD040 /* CS3: CAS=2, burst write, 16bit bus */
    #define SDRAM_MODE_CS3 0x3FFFE040 /* CS3: CAS=2, burst write, 16bit bus */
    *(u32 *)SDRAM_MODE_CS2 = 0;
    *(u32 *)SDRAM_MODE_CS3 = 0;

    return 0;
    }

    int board_late_init(void)
    {
    u8 mac[6];
    u8 tmp[1];

    /* Read Mac Address and set*/
    i2c_init(CONFIG_SYS_I2C_SPEED, 0);
    i2c_set_bus_num(CONFIG_SYS_I2C_MODULE);

    /*
    * PORT EXPANDER
    *
    * PX1.0 LED1 O 1 0=ON, 1=OFF
    * PX1.1 LED2 O 1 0=ON, 1=OFF
    * PX1.2 LED3 O 1 0=ON, 1=OFF
    * PX1.3 NOR_A25 O 0 Bit #25 of NOR Flash Addressing
    * PX1.4 PMOD1_RST O 1 Reset for PMOD channel 1
    * PX1.5 PMOD2_RST O 1 Reset for PMOD channel 2
    * PX1.6 SD_CONN_PWR_EN O 0 Enable power supply for external SD card
    * PX1.7 SD_MMC_PWR_EN O 1 Enable power supply for MMC card
    *
    * PX2.0 PX1_EN0 O 0 0=LCD, 1=DV
    * PX2.1 PX1_EN1 O 1 0=General Data, 1=Ethernet
    * PX2.2 TFT_CS O 0 Chip select for TFT
    * PX2.3 PX1_EN3 O 0 0=PWM timer channels, 1=ADC/DAC I/O lines
    * PX2.4 USB_OVR_CURRENT I 1 Signal from USB power controller (over-current)
    * PX2.5 USB_PWR_ENA O 0 Enable power supply for USB channel 0
    * PX2.6 USB_PWR_ENB O 0 Enable power supply for USB channel 1
    * PX2.7 PX1_EN7 O 0 0=A18-A21, 1=SGOUT0-SGOUT4
    */

    /* init PX01(IC34) */
    tmp[0] = 0x00;
    i2c_write(0x20, 3, 1, tmp, 1); /* config */
    tmp[0] = 0x37;
    i2c_write(0x20, 1, 1, tmp, 1); /* output */

    /*init PX02(IC35) */
    tmp[0] = 0x10;
    i2c_write(0x21, 3, 1, tmp, 1); /* config */
    i2c_write(0x21, 3, 1, tmp, 1); /* config */
    tmp[0] = 0x12;
    i2c_write(0x21, 1, 1, tmp, 1); /* output */

    /* Read MAC address */
    i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR,
    CONFIG_SH_ETHER_EEPROM_ADDR,
    CONFIG_SYS_I2C_EEPROM_ADDR_LEN,
    mac, 6);

    if (is_valid_ether_addr(mac))
    eth_setenv_enetaddr("ethaddr", mac);

    #if !defined(CONFIG_BOOT_MODE0)
    printf( "\t\t SPI Flash Memory Map\n"
    "\t\t------------------------------------\n"
    "\t\t Start Size SPI\n");
    printf( "\t\tu-boot: 0x%08X 0x%06X 0\n", 0,CONFIG_ENV_OFFSET);
    printf( "\t\t env: 0x%08X 0x%06X 0\n", CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE);
    printf( "\t\t DT: 0x%08X 0x%06X 0\n", CONFIG_ENV_OFFSET+CONFIG_ENV_SIZE,CONFIG_ENV_SECT_SIZE);
    printf( "\t\tKernel: 0x%08X 0x%06X 0+1 (size*=2)\n",0x100000, 0x280000);
    printf( "\t\trootfs: 0x%08X 0x%06X 0+1 (size*=2)\n",0x400000, 0x2000000-0x400000);
    #endif

    /* Boot uImage in external SDRAM */
    /* Rootfs is a squashfs image in memory mapped QSPI */
    /* => run s_boot */
    setenv("s1", "sf probe 0; sf read 09800000 C0000 8000"); // Read out DT blob
    setenv("s2", "sf probe 0:1; sf read 09000000 100000 500000"); //Copy Kernel to SDRAM
    setenv("s3", "bootm start 0x09000000 - 0x09800000 ; bootm loados ;"\
    "fdt memory 0x08000000 0x02000000"); // Change memory address in DTB
    setenv("s4", "qspi dual"); // Change XIP interface to dual QSPI
    setenv("sargs", "console=ttySC4,115200 console=tty0 ignore_loglevel root=/dev/mtdblock0"); // bootargs
    setenv("s_boot", "run s1 s2 s3 s4; set bootargs ${sargs}; fdt chosen; bootm go"); // run the commands

    /* Boot XIP using internal RAM */
    /* Rootfs is a squashfs image in memory mapped QSPI */
    /* => run x_boot */
    /* Read out DT blob */
    setenv("x1", "sf probe 0; sf read 20500000 C0000 8000");
    /* Change memory address in DTB */
    setenv("x2", "fdt addr 20500000 ; fdt memory 0x20000000 0x00A00000"); /* 10MB RAM */
    /* Change XIP interface to dual QSPI */
    setenv("x3", "qspi dual");
    setenv("xargs", "console=ttySC4,115200 console=tty0 ignore_loglevel root=/dev/mtdblock0"); // bootargs
    setenv("x_boot", "run x1 x2 x3; set bootargs ${xargs}; fdt chosen; bootx 18200000 20500000"); // run the commands

    /* Boot XIP using internal RAM */
    /* Rootfs is a AXFS image in memory mapped QSPI */
    /* => run xa_boot */
    /* Read out DT blob */
    setenv("xa1", "sf probe 0; sf read 20500000 C0000 8000");
    /* Change memory address in DTB */
    setenv("xa2", "fdt addr 20500000 ; fdt memory 0x20000000 0x00A00000"); /* 10MB RAM */
    /* Change XIP interface to dual QSPI */
    setenv("xa3", "qspi dual");
    setenv("xaargs", "console=ttySC4,115200 console=tty0 ignore_loglevel root=/dev/null rootflags=physaddr=0x18800000"); // bootargs
    setenv("xa_boot", "run xa1 xa2 xa3; set bootargs ${xaargs}; fdt chosen; bootx 18200000 20500000"); // run the commands

    /* Boot XIP using external SDRAM RAM */
    /* Rootfs is a AXFS image in memory mapped QSPI */
    /* => run xsa_boot */
    /* Read out DT blob */
    setenv("xsa1", "sf probe 0; sf read 09800000 C0000 8000");
    /* Change memory address in DTB */
    setenv("xsa2", "fdt addr 09800000 ; fdt memory 0x08000000 0x02000000"); /* 32MB SDRAM RAM */
    /* Change XIP interface to dual QSPI */
    setenv("xsa3", "qspi dual");
    setenv("xsaargs", "console=ttySC4,115200 console=tty0 ignore_loglevel root=/dev/null rootflags=physaddr=0x18800000"); // bootargs
    setenv("xsa_boot", "run xsa1 xsa2 xsa3; set bootargs ${xsaargs}; fdt chosen; bootx 18200000 09800000"); // run the commands

    return 0;
    }

    int dram_init(void)
    {
    #if (1 != CONFIG_NR_DRAM_BANKS)
    # error CONFIG_NR_DRAM_BANKS must set 1 in this board.
    #endif
    gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
    gd->bd->bi_dram[0].size = CONFIG_SYS_SDRAM_SIZE;
    gd->ram_size = CONFIG_SYS_SDRAM_SIZE * CONFIG_NR_DRAM_BANKS;

    return 0;
    }

    void reset_cpu(ulong addr)
    {
    }

    void led_set_state(unsigned short value)
    {
    if (value) /* turn LED on */
    gpio_set(7,1,0);
    else /* turn LED off */
    gpio_set(7,1,1);
    }

    u8 button_check_state(u8 sw)
    {
    /* returns: 1 = button up
    0 = button pressed
    */

    if (sw == 1) /* SW 1 */
    return gpio_read(1, 9);
    if (sw == 2) /* SW 2 */
    return gpio_read(1, 8);
    if (sw == 3) /* SW 3 */
    return gpio_read(1, 11);
    return 1;
    }

    /* XIP Kernel boot */
    int do_bootx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
    {
    ulong machid = MACH_TYPE_APRZA0A;
    void (*kernel_entry)(int zero, int arch, uint params);
    ulong r2;
    ulong img_addr;
    char *endp;

    /* need at least two arguments */
    if (argc < 2)
    goto usage;

    img_addr = simple_strtoul(argv[1], &endp, 16);
    kernel_entry = (void (*)(int, int, uint))img_addr;

    #ifdef CONFIG_USB_DEVICE
    udc_disconnect();
    #endif
    cleanup_before_linux();

    r2 = simple_strtoul(argv[2], NULL, 16);

    /* The kernel expects the following when booting:
    * r0 - 0
    * r1 - machine type
    * r2 - boot data (atags/dt) pointer
    *
    * For more info, refer to:
    * www.kernel.org/.../Booting
    */

    printf("Booting Linux...\n");

    kernel_entry(0, machid, r2);

    return 0;

    usage:
    return CMD_RET_USAGE;
    }
    static char bootx_help_text[] =
    "x_addr dt_addr\n - boot XIP kernel in Flash\n"
    "\t x_addr: Address of XIP kernel in Flash\n"
    "\tdt_addr: Address of Device Tree blob image";
    U_BOOT_CMD(
    bootx, CONFIG_SYS_MAXARGS, 1, do_bootx,
    "boot XIP kernel in Flash", bootx_help_text
    );


    #define CMNCR_0 0x3FEFA000 /* Common control register */
    #define DRCR_0 0x3FEFA00C /* Data Read Control Register */
    #define DRCMR_0 0x3FEFA010 /* Data Read Command Setting Register */
    #define DREAR_0 0x3FEFA014 /* Data read extended address setting register */
    #define DRENR_0 0x3FEFA01C /* Data read enable setting register */
    #define DROPR_0 0x3FEFA018 /* Data read option setting register */
    #define DMDMCR_0 0x3FEFA058 /* SPI Mode Dummy Cycle Setting Register */
    #define DRDRENR_0 0x3FEFA05C /* Data Read DDR Enable Register */


    struct read_mode {
    u8 cmd;
    char name[50];
    };
    #define READ_MODES 9
    const struct read_mode modes[READ_MODES] = {
    {0x03, "Read Mode (3-byte Addr) (RZ/A1 reset value)"},
    {0x0C, "Fast Read Mode (4-byte Addr)"},
    {0x6C, "Quad Read Mode (4-byte Addr)"},
    {0xEC, "Quad I/O Read Mode (4-byte Addr)"},
    {0xEE, "Quad I/O DDR Read Mode (4-byte Addr)"},
    {0x0B, "Fast Read Mode (3-byte Addr)"},
    {0x6B, "Quad Read Mode (3-byte Addr)"},
    {0xEB, "Quad I/O Read Mode (3-byte Addr)"},
    {0xED, "Quad I/O DDR Read Mode (3-byte Addr)"},
    };

    /* If you are using a SPI Flash device that does not have 4-byte address
    commands (Flash size <= 16MB), then change the #if 0 to #if 1 */
    #if 0
    #define ADDRESS_BYTE_SIZE 3 /* Addresses are 3-bytes (A0-A23) */
    #define FAST_READ 0x0B /* Fast Read Mode (1-bit cmd, 1-bit addr, 1-bit data, 3-bytes of address) */
    #define QUAD_READ 0x6B /* Quad Read Mode (1-bit cmd, 1-bit addr, 4-bit data, 3-bytes of address) */
    #define QUAD_IO_READ 0xEB /* Quad I/O Read Mode (1-bit cmd, 4-bit addr, 4-bit data, 3-bytes of address) */
    #define QUAD_IO_DDR_READ 0xED /* Quad I/O DDR Read Mode (1-bit cmd, 1-bit addr, 4-bit data, 3-bytes of address) */
    #else
    #define ADDRESS_BYTE_SIZE 4 /* Addresses are 4-bytes (A0-A31) */
    #define FAST_READ 0x0C /* Fast Read Mode (1-bit cmd, 1-bit addr, 1-bit data, 4-bytes of address) */
    #define QUAD_READ 0x6C /* Quad Read Mode (1-bit cmd, 1-bit addr, 4-bit data, 4-bytes of address) */
    #define QUAD_IO_READ 0xEC /* Quad I/O Read Mode (1-bit cmd, 4-bit addr, 4-bit data, 4-bytes of address) */
    #define QUAD_IO_DDR_READ 0xEE /* Quad I/O DDR Read Mode (1-bit cmd, 1-bit addr, 4-bit data, 4-bytes of address) */
    #endif

    /* These should be filled out for each device */
    u32 g_FAST_RD_DMY; /* Fast Read Mode */
    u32 g_QUAD_RD_DMY; /* Quad Read Mode */
    u32 g_QUAD_IO_RD_DMY; /* Quad I/O Read Mode */
    u32 g_QUAD_IO_DDR_RD_DMY; /* Quad I/O DDR Read Mode */
    u32 g_QUAD_IO_RD_OPT; /* Addtional option or 'mode' settings */


    /* Dummy cycles are need for the quad mode FAST_READ commands,
    but they get applied to ever type of FAST_READ command.
    Since the "sf" commands in u-boot know nothing about dummy
    cycles, we need to shut them off if we see a "sf probe" */
    int remove_dummy_micron(struct spi_flash *sf)
    {
    int ret;
    u8 cmd;
    u8 cfg_reg;

    #ifdef DEBUG
    /* Read VOLATILE Configuration register (85h) */
    ret = spi_flash_cmd(sf->spi, 0x85, &cfg_reg, 1);
    printf("%s: Initial Volatile Configuration register = %02X\n", __func__, cfg_reg);
    #endif

    /* Send Write Enable (06h) */
    ret = spi_flash_cmd(sf->spi, 0x06, NULL, 0);

    /* Set Volatile Configuration Register to default value */
    /* Send WRITE VOLATILE CONFIGURATION REGISTER (81h) */
    cmd = 0x81;
    cfg_reg = 0xFB;
    ret |= spi_flash_cmd_write(sf->spi, &cmd, 1, &cfg_reg, 1);

    #ifdef DEBUG
    /* Read Volatile Configuration register (85h) */
    ret = spi_flash_cmd(sf->spi, 0x85, &cfg_reg, 1);
    printf("%s: New Volatile Configuration register = %02X\n", __func__, cfg_reg);
    #endif

    return ret;
    }

    /* This function is called when "sf probe" is issued, meaning that
    the user wants to access the deivce in normal single wire SPI mode.
    Since some SPI devices have to have special setups to enable QSPI mode
    or DDR QSPI mode, this function is used to reset those settings
    back to normal single wire FAST_READ mode. */
    int qspi_reset_device(struct spi_flash *sf)
    {
    int ret = 0;

    if( !strcmp(sf->name, "S25FL512S_256K") ) {
    /* Don't really need to do anything */
    }
    else if( !strcmp(sf->name, "MX25L12805") ) {
    /* Macronix and Windbond are similar to Spansion */
    /* Don't really need to do anything */
    }
    else if( !strcmp(sf->name, "N25Q512") ) {
    ret = remove_dummy_micron(sf);
    }
    else {
    printf("\tWARNING: SPI Flash needs to be added to function %s() sf->name=%s\n",__func__, sf->name);
    return 1;
    }
    return ret;
    }


    後はttyS2を全てttyS4に変更、machidをMACH_ZTYPE_APRZA0Aに変更、
    Macronix MX25L12845、Spansion S25FL512S、Micron N25Q512Aの関数をコメントアウト、
    remove_dummy_micron,qspi_reset_device,do_qspi,qspi_help_textをコメントアウトしました。

    結果としてU-bootは何も表示されなくなってしまいました。
    U-bootが全く動かなくなって、手も足もでなくなっています。

    業務で何とかXまで起動させて本デバイスで開発をと思っていたのですが、2ヶ月ではbootまで
    辿り着けず、無念でなりません・・・
  • > 結果としてU-bootは何も表示されなくなってしまいました。
    > U-bootが全く動かなくなって、手も足もでなくなっています。

    最初に申し上げた通り、「移植については、最初は、RZ/A1 Linux BSP Porting Guide などを参考にして、
    (3) の BSP を APRZA0A に新規に移植するつもりで作業された方が速いかもしれません。」です。

    まず最初に、(u-boot のプロンプトが出るまでは無理でも) シリアルコンソールに何か出るようにしましょう。
    rskrza1.c 相当のファイルのシリアルコンソールの兼用端子設定は、出来ているようですから、後は、

    include/configs/rskrza1.h 相当のファイル

    の修正が出来ていないのでしょう。BSP Porting Guide の

    「6. u-boot: Serial Console Port Select」

    を読んで修正してください。

    なお、上のコードを少し見ただけですが、これ以前のいっとうさんの書き込みを参照すると、

    > 旧:at24 0-0050: 128 byte 24c01 EEPROM, writable, 1 bytes/write
    > 新:at24 3-0050: 2048 byte at24 EEPROM, writable, 16 bytes/write

    となっていますから、AP-RZA-0A で使用している I2C のチャネルは、0だと推測するのですが、
    上のコードでは、チャネル3の兼用端子を初期化しています。間違えていませんか? また、

    > m25p80 spi5.0: found n25q128a13, expected s25fl512s
    > m25p80 spi5.0: n25q128a13 (16384 Kbytes)

    となっていますから、シリフラは、N25Q128A13 だと推測するのですが、上のコードでは、

    > Micron N25Q512Aの関数をコメントアウト、

    していますが、これも、BSP Porting Guide の

    「8.1 Add Support for your SPI Flash」

    を参照して、適切に修正してください。それ以外に、(以降、原文の誤りを訂正)

    1. 上のコードで、一部の兼用端子が被っている
    2. クロックの設定が修正されていない(main clock、RTC clock)

    などの問題が散見/推測されます。Alpha Project さんが移植された u-boot や Linux kernel の
    ソースコードと RZ/A1 Linux BSP Porting Guide を参照して、適切に修正してください。

  • お世話になります。
    なんとかU-bootの起動までは復帰することが出来ました。
    LowLevelDebugも有効になって、Starting kernel以降に以下が表示されるようになりました。

    I2C: ready
    DRAM: 10 MiB
    Using default environment

    In: serial
    Out: serial
    Err: serial
    Net: sh_eth
    => usb start
    (Re)start USB...
    USB0: scanning bus 0 for devices... 2 USB Device(s) found
    scanning usb for storage devices... 1 Storage Device(s) found
    => ext2load usb 0 0x0d000000 /uImage
    2637472 bytes read in 2258 ms (1.1 MiB/s)
    => ext2load usb 0 0x0d800000 /r7s72100-aprza0a.dtb
    7633 bytes read in 75 ms (98.6 KiB/s)
    => set bootargs ‘console=ttySC4,115200 console=tty0 ignore_loglevel root=/dev/sda1 rootwait earlyprintk’
    => bootm 0x0d000000 - 0x0d800000
    ## Booting kernel from Legacy Image at 0d000000 ...
    Image Name: Linux-3.14.79-ltsi+
    Created: 2017-07-03 0:45:11 UTC
    Image Type: ARM Linux Kernel Image (uncompressed)
    Data Size: 2637408 Bytes = 2.5 MiB
    Load Address: 08008000
    Entry Point: 08008000
    Verifying Checksum ... OK
    ## Flattened Device Tree blob at 0d800000
    Booting using the fdt blob at 0xd800000
    Loading Kernel Image ... OK
    Loading Device Tree to 208e7000, end 208ebdd0 ... OK

    Starting kernel ...

    data abort
    pc : [<0800800c>] lr : [<2096e860>]
    sp : 208edcf0 ip : 0000000c fp : 00000000
    r10: 208ef224 r9 : 208edf08 r8 : 00000000
    r7 : 00000000 r6 : 08008000 r5 : 209a61fc r4 : 00000000
    r3 : 00001dd1 r2 : 208e7000 r1 : 00000dd1 r0 : 00000dd1
    Flags: nZCv IRQs off FIQs off Mode SVC_32
    Resetting CPU ...

    resetting ...


    pcが0x0800800cということで、起動早々にこけているということでしょうか。
  • > pcが0x0800800cということで、起動早々にこけているということでしょうか。

    メッセージを見る限り、u-boot が Linux を起動した直後(未だ Linux が例外を処理する準備が出来る前) に例外を
    起こし、u-boot の例外ルーチンが呼び出されているように見えます。

    以前のカーネルは、どうされたのですか?

  • お世話になります。

    先の実行結果ですが、カーネルとデバイスファイルのアドレスが逆になっていました。

    旧BSPで動作したkernelとユーザランドは有りますので、現行U-bootを使って起動させようとしたところ、
    ロードするアドレスが0c000000-0x0c8000000の場合、0d000000-0d800000の場合共に、starting kernelで
    止まってしまいます。

    => usb start
    (Re)start USB...
    USB0: scanning bus 0 for devices... 2 USB Device(s) found
    scanning usb for storage devices... 1 Storage Device(s) found
    => ext2load usb 0 0x0d000000 /uImage
    2827952 bytes read in 2392 ms (1.1 MiB/s)
    => ext2load usb 0 0x0d800000 /rza1-aprza0a.dtb
    308 bytes read in 58 ms (4.9 KiB/s)
    => set bootargs 'console=ttySC4,115200 console=tty0 ignore_loglevel root=/dev/sda1 rootwait earlyprintk'
    => bootm 0x0d000000 - 0x0d800000
    ## Booting kernel from Legacy Image at 0d000000 ...
    Image Name: Linux-3.8.13-aprza0a-1.0
    Created: 2017-06-05 8:37:48 UTC
    Image Type: ARM Linux Kernel Image (uncompressed)
    Data Size: 2827888 Bytes = 2.7 MiB
    Load Address: 0c008000
    Entry Point: 0c008000
    Verifying Checksum ... OK
    ## Flattened Device Tree blob at 0d800000
    Booting using the fdt blob at 0xd800000
    Loading Kernel Image ... OK
    Loading Device Tree to 208e9000, end 208ec133 ... OK

    Starting kernel ...

    => usb start
    (Re)start USB...
    USB0: scanning bus 0 for devices... 2 USB Device(s) found
    scanning usb for storage devices... 1 Storage Device(s) found
    => ext2load usb 0 0x0c000000 /uImage
    2827952 bytes read in 2392 ms (1.1 MiB/s)
    => ext2load usb 0 0x0c800000 /rza1-aprza0a.dtb
    308 bytes read in 58 ms (4.9 KiB/s)
    => set bootargs 'console=ttySC4,115200 console=tty0 ignore_loglevel root=/dev/sda1 rootwait earlyprintk'
    => bootm 0x0c000000 - 0x0c800000
    ## Booting kernel from Legacy Image at 0c000000 ...
    Image Name: Linux-3.8.13-aprza0a-1.0
    Created: 2017-06-05 8:37:48 UTC
    Image Type: ARM Linux Kernel Image (uncompressed)
    Data Size: 2827888 Bytes = 2.7 MiB
    Load Address: 0c008000
    Entry Point: 0c008000
    Verifying Checksum ... OK
    ## Flattened Device Tree blob at 0c800000
    Booting using the fdt blob at 0xc800000
    Loading Kernel Image ... OK
    Loading Device Tree to 208e9000, end 208ec133 ... OK

    Starting kernel ...

    これはU-bootのPIN初期設定が上手く出来ていないということでしょうか。
  • > 先の実行結果ですが、カーネルとデバイスファイルのアドレスが逆になっていました。

    新旧の実行結果を比較して、古いカーネルと間違ったデバイスツリーをロードして実行した、と理解しました。

    > 旧BSPで動作したkernelとユーザランドは有りますので、現行U-bootを使って起動させようとしたところ、
    > ロードするアドレスが0c000000-0x0c8000000の場合、0d000000-0d800000の場合共に、starting kernelで
    > 止まってしまいます。

    ロードするアドレスが 0x0c000000-0x0c800000 の場合は、以前にご説明した通り、カーネルをロードした領域と
    カーネルの実行領域が、一部、オーバラップしますから、正常に動作しません。

    ロードするアドレスが 0x0d000000-0x0d800000 の場合は、bootargs に earlyprintk が指定されていますから、
    通常、何らかの表示があります。以前にご説明した通り、まず、earlyprintk を有効にしてみてください。

    > これはU-bootのPIN初期設定が上手く出来ていないということでしょうか。

    ご質問が解りません。
    u-boot の端子設定が (完璧ではないにせよ、それなりに)出来ているから、上のように u-boot が動いているの
    だと思いますが...

     

  • お世話になります。
    説明不足で申し訳有りません。

    旧U-bootと旧kernel→動作OK
    新U-bootと新kernrl→動作NG(earlyprintk有り)
    新U-bootと旧kernel→動作NG
    以上の結果と、アドバイス頂いた、
    > メッセージを見る限り、u-boot が Linux を起動した直後(未だ Linux が例外を処理する準備が出来る前) に例外を
    > 起こし、u-boot の例外ルーチンが呼び出されているように見えます。
    から、新U-bootがおかしいと考えました。
    旧BSPで.configを見るとerarlyprintkが有効になっていて、その上で何も表示されないと思っていたのですが、
    再度ビルドして以下を試してみます。
    旧U-bootと旧kernel(earlyprintk有り)
    新U-bootと旧kernel(earlyprintk有り)
Reply
  • お世話になります。
    説明不足で申し訳有りません。

    旧U-bootと旧kernel→動作OK
    新U-bootと新kernrl→動作NG(earlyprintk有り)
    新U-bootと旧kernel→動作NG
    以上の結果と、アドバイス頂いた、
    > メッセージを見る限り、u-boot が Linux を起動した直後(未だ Linux が例外を処理する準備が出来る前) に例外を
    > 起こし、u-boot の例外ルーチンが呼び出されているように見えます。
    から、新U-bootがおかしいと考えました。
    旧BSPで.configを見るとerarlyprintkが有効になっていて、その上で何も表示されないと思っていたのですが、
    再度ビルドして以下を試してみます。
    旧U-bootと旧kernel(earlyprintk有り)
    新U-bootと旧kernel(earlyprintk有り)
Children
  • お世話になります。
    旧U-bootと旧kernel(earlyprintk有り)は動き、新U-bootと旧kernel(earlyprintk有り)はStarting kernelで止まって
    何も表示されませんでした。printkが効いていないのかと旧+旧のブートログをearlyprintk無しの時のログと
    比較してみましたが、情報量が増えているのでprintkは効いているように見えます。
    旧旧<earlyprintk無し>
    Starting kernel …

    console [ttySC4] enabled, bootconsole disabled
    sh-sci.5: ttySC5 at MMIO 0xe8009800 (irq = 243) is a scif
    sh-sci.6: ttySC6 at MMIO 0xe800a000 (irq = 247) is a scif
    sh-sci.7: ttySC7 at MMIO 0xe800a800 (irq = 251) is a scif
    rspi rspi.0: master is unqueued, this is deprecated
    rspi rspi.0: probed
    rspi rspi.1: master is unqueued, this is deprecated
    rspi rspi.1: probed
    rspi rspi.2: master is unqueued, this is deprecated
    rspi rspi.2: probed
    rspi rspi.3: master is unqueued, this is deprecated
    rspi rspi.3: probed
    rspi rspi.4: master is unqueued, this is deprecated
    rspi rspi.4: probed
    Info : OTP bit = 1 (CR1 = 0xff, SR1 = 0x00)

    旧旧<earlyprintk有り>
    Starting kernel ...

    Booting Linux on physical CPU 0x0
    Linux version 3.8.13-aprza0a-1.0 (ampere@ampere-Ubuntu12) (gcc version 4.7.3 20130102 (prerelease) (crosstool-NG linaro-1.13.1-4.7-2013.01-20130125 - Linaro GCC 2013.01) ) #13 PREEMPT Tue Jul 4 14:49:30 JST 2017
    CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c53c7d
    CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
    Machine: aprza0a, model: APRZA0A
    debug: ignoring loglevel setting.
    Memory policy: ECC disabled, Data cache writeback
    On node 0 totalpages: 8192
    free_area_init_node: node 0, pgdat c0553e2c, node_mem_map c0582000
    Normal zone: 64 pages used for memmap
    Normal zone: 0 pages reserved
    Normal zone: 8128 pages, LIFO batch:0
    bootconsole [early_ttySC4] enabled
    pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
    pcpu-alloc: [0] 0
    Built 1 zonelists in Zone order, mobility grouping on. Total pages: 8128
    Kernel command line: console=ttySC4,115200 root=/dev/sda1 rw rootdelay=3 ignore_loglevel earlyprintk=sh-sci.4,115200
    PID hash table entries: 128 (order: -3, 512 bytes)
    Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
    Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
    __ex_table already sorted, skipping sort
    Memory: 32MB = 32MB total
    Memory: 26780k/26780k available, 5988k reserved, 0K highmem
    Virtual kernel memory layout:
    vector : 0xffff0000 - 0xffff1000 ( 4 kB)
    fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
    vmalloc : 0xc2800000 - 0xff000000 ( 968 MB)
    lowmem : 0xc0000000 - 0xc2000000 ( 32 MB)
    pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
    modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
    .text : 0xc0008000 - 0xc05033a0 (5101 kB)
    .init : 0xc0504000 - 0xc0526324 ( 137 kB)
    .data : 0xc0528000 - 0xc0554960 ( 179 kB)
    .bss : 0xc0554960 - 0xc0581648 ( 180 kB)

    U-bootに問題が有ると考えたのですが、間違っているでしょうか。
  • > 旧U-bootと旧kernel(earlyprintk有り)は動き、新U-bootと旧kernel(earlyprintk有り)はStarting kernelで止まって
    > 何も表示されませんでした。
          (中略)
    > U-bootに問題が有ると考えたのですが、間違っているでしょうか。

    新旧が自由に入れ替えて組み合わせられる前提での経験則のようですが、前提が正しいことを確認しましたか?
    u-boot とカーネルの間にもインタフェースがあります。単にジャンプすれば良いという訳ではありません。

    確認ですが、いっとうさんは、3.14 のカーネルを最初にコンフィギュレーションする際、3.8 のカーネルの
    コンフィギュレーションファイルを使用しませんでしたか?

    また、7/3のいっとうさんの書き込みですが、

    > なんとかU-bootの起動までは復帰することが出来ました。
    > LowLevelDebugも有効になって、Starting kernel以降に以下が表示されるようになりました。

    > I2C: ready
    > DRAM: 10 MiB
    > Using default environment
        (中略)
    > r7 : 00000000 r6 : 08008000 r5 : 209a61fc r4 : 00000000
    > r3 : 00001dd1 r2 : 208e7000 r1 : 00000dd1 r0 : 00000dd1
    > Flags: nZCv IRQs off FIQs off Mode SVC_32
    > Resetting CPU ...

    > resetting ...

    Starting kernel 以降に表示されているメッセージは、全て u-boot のコードが出しています。
    ですから、earlyprintk が有効になっているかは不明です。

    同じ日の私の書き込みで

    > 以前のカーネルは、どうされたのですか?

    これは、5/22 のいっとうさんの書き込みに出てくる 3.14 のカーネルです。
    途中で "bootconsole [earlycon0] disabled" と表示してそのままになるようですが
    それでOKです(その後、UART の端子設定を見直しているなら更にOK)。
    そのカーネルと新 u-boot を組み合わせて実行したログを見せてください。ログには、
    u-boot での操作も含めたフルのログをください。

  • いっとうです。時間が随分経ってしまい、申し訳有りません。

    何ヶ月か格闘していたのですが、もうソースの何処を改変したか分からなくなってしまい、
    改めてgitからBSPの作成を再開しました。
    過去のここのアドバイスを見ながらU-bootから作り直しをしました。U-bootはプロンプト
    が返ってきましたが、bootmでWrong Image Format for bootm commandが出てしまいます。
    以下は作ったU-bootとアルファさんの旧カーネルでの動作です(U-bootは使い回し出来ない点
    は承知しております。)

    U-Boot 2015.01-00077-g8680056-dirty (Dec 01 2017 - 15:27:30)

    I2C: ready
    DRAM: 10 MiB
    Using default environment

    In: serial
    Out: serial
    Err: serial
    SPI Flash Memory Map
    ------------------------------------
    Start Size SPI
    u-boot: 0x00000000 0x080000 0
    env: 0x00080000 0x040000 0
    DT: 0x000C0000 0x040000 0
    Kernel: 0x00100000 0x280000 0+1 (size*=2)
    rootfs: 0x00400000 0x1C00000 0+1 (size*=2)
    Net: sh_eth
    >> usb start
    (Re)start USB...
    USB0: scanning bus 0 for devices... 2 USB Device(s) found
    scanning usb for storage devices... 1 Storage Device(s) found
    => ext2load usb 0 0x0d000000 /uImage
    2827952 bytes read in 2392 ms (1.1 MiB/s)
    >>ext2load usb 0 0x0d800000 /rza1-aprza0a.dtb
    308 bytes read in 57 ms (4.9 KiB/s)
    => set bootargs ‘console=ttySC4,115200 console=tty0
    =>
    => bootm 0x0d000000 - 0x0d800000
    Wrong Image Format for bootm command
    ERROR: can't get kernel image!
    =>
    Wrong Image Format for bootm command
    ERROR: can't get kernel image!
    =>

    自分で作ったカーネル、アルファさんの旧カーネルでbootmを試しましたがどちらもWrong
    Imageで止まってしまいます。

    U-bootの問題と認識したのですが、formatを左右するような部分をboardファイルから見つけ出す
    ことが出来ず試行錯誤しております。

    今まで色々とアドバイス頂いたことが咀嚼出来ず申し訳有りませんが、何か「ここを見直したら」
    等有りましたら教えて頂けないでしょうか。
  • お世話になります。
    再度過去のアドバイスを確認して、問題はU-bootでは無くKernelにあると認識しました。
    boardファイルを追いかけます。
  • お世話になります。いっとうです。

    どうしてもエラーから抜け出せません。
    => usb start
    (Re)start USB...
    USB0: scanning bus 0 for devices... 2 USB Device(s) found
    scanning usb for storage devices... 1 Storage Device(s) found
    => ext2load usb 0 0x0d000000 /uImage
    2637008 bytes read in 2258 ms (1.1 MiB/s)
    => ext2load usb 0 0x0d800000 /r7s72100-aprza0a.dtb
    7633 bytes read in 76 ms (97.7 KiB/s)
    => set bootargs 'console=ttySC4,115200 console=tty0 ignore_loglevel root=/dev/sda1 rootwait earlyprintk'
    =>
    => bootm 0x0d000000 - 0x0d800000
    Wrong Image Format for bootm command
    ERROR: can't get kernel image!
    =>
    Wrong Image Format for bootm command
    ERROR: can't get kernel image!

    以前に教えて頂いた.configの内容チェックは以下の通りです。
    $grep -e CONFIG_DEBUG_LL -e CONFIG_EARLY_PRINTK -e CONFIG_DEBUG_R7S72100_SCIF .config
    CONFIG_DEBUG_LL=y
    CONFIG_DEBUG_R7S72100_SCIF4=y
    # CONFIG_DEBUG_LL_UART_NONE is not set
    # CONFIG_DEBUG_LL_UART_8250 is not set
    # CONFIG_DEBUG_LL_UART_PL01X is not set
    CONFIG_DEBUG_LL_INCLUDE="debug/renesas-scif.S"
    CONFIG_EARLY_PRINTK=y

    $grep -R "CONFIG_DEBUG_R7S72100_SCIF" .
    ./.config:CONFIG_DEBUG_R7S72100_SCIF4=y
    ./include/config/auto.conf:CONFIG_DEBUG_R7S72100_SCIF4=y
    ./include/generated/autoconf.h:#define CONFIG_DEBUG_R7S72100_SCIF4 1

    $make menuconfig
    $make uImage LOADADDR=0x08008000
    $make dtbs

    上記設定で何かおかしいところは有るでしょうか。
  • いっとうさん

    アルファプロジェクトの APRZA0A のマニュアルを見る限り、外付け SDRAM は 0x0C000000~0x0DFFFFFF に
    32MB 実装されているようです。であれば、少なくとも、

    $ make menuconfig
    $ make uImage LOADADDR=0x08008000
    $ make dtbs

    指定しているアドレスがおかしいと思いませんか?

  • お世話になります。

    LOADADDRを理解出来ておりませんでした。申し訳有りません。
    uImageを0c008000で
    $ make uImage LOADADDR=0x0c008000
    Image Name: Linux-3.14.79-ltsi+
    Created: Mon Dec 4 20:32:25 2017
    Image Type: ARM Linux Kernel Image (uncompressed)
    Data Size: 2636944 Bytes = 2575.14 kB = 2.51 MB
    Load Address: 0c008000
    Entry Point: 0c008000
    Image arch/arm/boot/uImage is ready
    $ make dtbs

    -----------------------------------------------------------------------------------------
    => usb start
    (Re)start USB...
    USB0: scanning bus 0 for devices... 2 USB Device(s) found
    scanning usb for storage devices... 1 Storage Device(s) found
    => ext2load usb 0 0x0d000000 /uImage
    2637008 bytes read in 2258 ms (1.1 MiB/s)
    => ext2load usb 0 0x0d800000 /r7s72100-aprza0a.dtb
    7633 bytes read in 76 ms (97.7 KiB/s)
    => set bootargs 'console=ttySC4,115200 console=tty0 ignore_loglevel root=/dev/sda1 rootwait earlyprintk'
    =>
    => bootm 0x0d000000 - 0x0d800000
    Wrong Image Format for bootm command
    ERROR: can't get kernel image!
    =>
    Wrong Image Format for bootm command
    ERROR: can't get kernel image!

    SCIF4はP5_0,P5_1にアサインしています。U-bootでは指定していますが、kernelの方はP5_0,P5_1を
    どこにも使っておりません。kernelの方でSCIFのpin_assignは元のrskrza1でも記載されていなかった
    為、kernelでは以下の指定だけです。
    829 //R7S72100_SCIF(2, 0xe8008000, gic_iid(229));
    830 //R7S72100_SCIF(3, 0xe8008800, gic_iid(233)); /* Not used */
    831 R7S72100_SCIF(4, 0xe8009000, gic_iid(237)); /* Not used */
    832 //R7S72100_SCIF(5, 0xe8009800, gic_iid(241)); /* Not used */

    1707 // r7s72100_register_scif(0); /* SCIF ch0 */ /* Not used */
    1708 // r7s72100_register_scif(1); /* SCIF ch1 */ /* Not used */
    1709 // r7s72100_register_scif(2); /* SCIF ch2 */
    1710 // r7s72100_register_scif(3); /* SCIF ch3 */ /* Not used */
    1711 r7s72100_register_scif(4); /* SCIF ch4 */ /* Not used */
    1712 // r7s72100_register_scif(5); /* SCIF ch5 */ /* Not used */
    1713 // r7s72100_register_scif(6); /* SCIF ch6 */ /* Not used */
    1714 // r7s72100_register_scif(7); /* SCIF ch7 */ /* Not used */

    明日改めてU-bootも見直してみます。
  • いっとうさん
    はじめまして。Hiroです。
    当方も昨年度末、苦戦しましたのでお察しします。

    >$ make uImage LOADADDR=0x0c008000
    で、uImageを0x0c008000に読み込んでいるのに、
    >=> bootm 0x0d000000 - 0x0d800000
    では、0x0d000000からuImageを読み込もうとしていませんか。
    setenvを見直されてはいかがでしょうか。

    1年近く前の知識を絞り出していますので、とんちんかんな回答でしたら申し訳ありません。
  • お世話になります。いっとうです。

    アドバイスありがとうございます。

    LOADADDRとext2loadの処理がはっきりと分かっていないのですが、LOADADDRにて一旦RAM等にロードした後、起動の為にext2loadに再配置して、再配置したところから起動するのかなと想像しております。
    試しにext2loadをLOADADDRと同じにして実行してみました。やはり、WrongImageFormatと出て
    先に進めません。

    U-Boot 2015.01-00077-g8680056-dirty (Dec 05 2017 - 15:41:31)

    I2C: ready
    DRAM: 10 MiB
    Using default environment

    In: serial
    Out: serial
    Err: serial
    SPI Flash Memory Map
    ------------------------------------
    Start Size SPI
    u-boot: 0x00000000 0x080000 0
    env: 0x00080000 0x040000 0
    DT: 0x000C0000 0x040000 0
    Kernel: 0x00100000 0x280000 0+1 (size*=2)
    rootfs: 0x00400000 0x1C00000 0+1 (size*=2)
    Net: sh_eth
    => usb start
    (Re)start USB...
    USB0: scanning bus 0 for devices... 2 USB Device(s) found
    scanning usb for storage devices... 1 Storage Device(s) found
    => ext2load usb 0 0x0c008000 /uImage
    2637008 bytes read in 2258 ms (1.1 MiB/s)
    => ext2load usb 0 0x0d800000 /r7s72100-aprza0a.dtb
    7633 bytes read in 76 ms (97.7 KiB/s)
    => set bootargs ‘console=ttySC4,115200 console=tty0 ignore_loglevel root=/dev/sda1 rootwait earlyprintk
    =>
    => bootm 0x0c008000 - 0x0d800000
    Wrong Image Format for bootm command
    ERROR: can't get kernel image!
    =>
    Wrong Image Format for bootm command
    ERROR: can't get kernel image!

    SDRAMの初期化に失敗しているのでは?とU-bootを見直しているのですが、今のところ原因が
    見つかっていません。

    PINの初期化を再度見直してみます。何とか切り分けしたいのですが、このエラーメッセージで
    検索しても情報が得られない状況です。

    お客がRZA1を気に入っておられるので、何とかして使えるようにしたいのですが、半年
    くらい前進しなくてとても焦っています。。
  • uImage は、mkimage コマンドを使って、

    (a) 単純なメモリイメージのカーネル Image から、
    (b) Image を Z/BZ2 圧縮したカーネル zImage/bzImage から、
    (c) (b) の先頭に自己解凍用のルーチンを付加して、

    などの方法で作成され、LOADADDR は、無圧縮の(解凍された)カーネルの
    最終ロードアドレス (及び、エントリポイント) を指定します。
    # ですから、修正した LOADADDR は、正しいだろうと思います。

    2つ上の、いっとうさんの書き込みだと、

    $ make uImage LOADADDR=0x0c008000
    Image Name: Linux-3.14.79-ltsi+
    Created: Mon Dec 4 20:32:25 2017
    Image Type: ARM Linux Kernel Image (uncompressed)
    Data Size: 2636944 Bytes = 2575.14 kB = 2.51 MB
    Load Address: 0c008000
    Entry Point: 0c008000
    Image arch/arm/boot/uImage is ready

    と、uImage のサイズが 2.6MB 程度しかなので、多分、(b) か (c)、また、
    無圧縮(uncompressed) と表示されていますから、多分、(c) だろうと推測
    出来ます(RZ/A1 Linux BSP は、その形式で作成しますし)。

    ですから、

    => ext2load usb 0 0x0d000000 /uImage
    2637008 bytes read in 2258 ms (1.1 MiB/s)
    => ext2load usb 0 0x0d800000 /r7s72100-aprza0a.dtb
    7633 bytes read in 76 ms (97.7 KiB/s)
    => set bootargs 'console=ttySC4,115200 console=tty0 ignore_loglevel root=/dev/sda1 rootwait earlyprintk'
    =>
    => bootm 0x0d000000 - 0x0d800000
    Wrong Image Format for bootm command
    ERROR: can't get kernel image!

    は、本来であれば、

    自己解凍形式の uImage を 0x0d000000 にロード、DTB を 0x0d800000 にロード、
    その後、bootm で uImage の実行を開始すると、uImage 自身が圧縮を解凍しつつ、
    カーネルを最終ロードアドレスの LOADADDR に配置し直してから、エントリ
    ポイント LOADADDR にジャンプすることでカーネルの実行が始まる、

    のですが、実際には、

    自己解凍形式の uImage を 0x0d000000 にロード、DTB を 0x0d800000 にロード、
    その後、bootm がロードした uImage の先頭に付いているヘッダ情報を確認し、
    不正あるいは未サポート、と判断して「Wrong Image Format for bootm command」
    を表示しています。

    当該のメッセージは、common/bootm.c の boot_get_kernel が出力しており、
    u-boot で、CONFIG_IMAGE_FORMAT_LEGACY が未定義なコンフィギュレーションを
    するか、mkimage が不正な(u-boot が未サポートの)ファイルを作成すれば出力
    されますが、実際の所、考えにくいです。

    現状、u-boot は、内蔵 RAM で実行されますし、USB は、端子固定ですから、
    UART(SCIF) の初期化や設定を間違えない限り、何もしなくても、普通は動作しますが、
    ボードを正しく初期化出来ているとは限りません。

    以前にも申し上げましたが、
    > 出力されたエラーメッセージを素直に解釈すると、uImage が正しく作れていない、
    > (RZ/A1 の BSC が正しく初期化出来ていない、何かの領域とオーバラップしている、
    > などの理由で) USB からのロード後に壊れた/壊された、と思われますが、

    u-boot がボード(特に BSC)を正しく初期化出来ているか、確認してください。