• X-008 FriendlyARM tiny4412 uboot移植之copy u-boot到DDR内存


     

    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 

    开发环境:win7 64 + VMware12 + Ubuntu14.04 64

    工具链:linaro提供的gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi

    要移植的u-boot版本:u-boot-2016-11

    Tiny4412开发板硬件版本为

        底板:  Tiny4412/Super4412SDK 1506

           核心板:Tiny4412 - 1412

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 

     

    在上一节中我们已经把tiny4412开发板上片外的DDR内存初始化完成。接下来是把完整的u-boot.binSD卡上拷贝到DDR内存,并跳转到DDR内存中去执行u-boot

     

    1Exynos4412代码拷贝函数(DEVICE COPY FUNCTIONS)

       Android_Exynos4412_iROM_Secure_Booting_Guide_Ver.1.00.00.pdf》的第21页描述了exynos4412芯片的块拷贝函数。这些内置的函数支持从启动设备拷贝数据到内存。

    clip_image002

     

     

    特别要注意,使用这些函数是对启动设备的时钟有要求,如果时钟不对,这些函数可能无法正常工作:

    clip_image004

    SD卡和eMMC卡的工作频率是20MHz。因此在设置系统时钟的时候,要把启动设备(SD卡、eMMC卡)的时钟设置为20MHz

           从《Tiny4412-1412-Schematic.pdf》和《Tiny4412SDK-1506-Schematic.pdf》原理图上,我们可以知道tiny4412SD卡是接在exynos4412芯片的Xmmc2口。

    clip_image006

    重新设置mmc2的时钟频率为20MHz,相应的代码修改如下:

    diff --git a/arch/arm/mach-exynos/clock_init_exynos4412.c b/arch/arm/mach-exynos/clock_init_exynos4412.c

    index cd70185..4617c8c 100644

    --- a/arch/arm/mach-exynos/clock_init_exynos4412.c

    +++ b/arch/arm/mach-exynos/clock_init_exynos4412.c

    @@ -298,9 +298,9 @@ void system_clock_init(void)

                     * DOUTmmc3 = MOUTmmc3 / (ratio + 1) = 100 (7)

                     * sclk_mmc3 = DOUTmmc3 / (ratio + 1) = 50 (1)

                     * DOUTmmc2 = MOUTmmc2 / (ratio + 1) = 100 (7)

    -                * sclk_mmc2 = DOUTmmc2 / (ratio + 1) = 50 (1)

    +                * sclk_mmc2 = DOUTmmc2 / (ratio + 1) = 20 (4)

                    */

    -       set = MMC2_RATIO(7) | MMC2_PRE_RATIO(1) | MMC3_RATIO(7) |

    +       set = MMC2_RATIO(7) | MMC2_PRE_RATIO(4) | MMC3_RATIO(7) |

                              MMC3_PRE_RATIO(1);

     

            clrsetbits_le32(&clk->div_fsys2, clr, set);

     

     

     

    2、设置SD卡上存放代码的位置

       相应的设置参考Android_Exynos4412_iROM_Secure_Booting_Guide_Ver.1.00.00.pdf》的第24页描述.

    clip_image008

    对于tiny4412开发板,SD卡上存放代码的位置设置如下:

    / *    SD/MMC(1 Block = 512B) layout:

     *    +------------------------------------------------------------------------------------------------------------------------------------+

    *    |          |                  |                   |                     |                    |

     *    |   512B   |   8K(bl1)         |   16k(bl2/spl)      |   16k(ENV)         |  512k(u-boot)        |

     *    |          |                   |                   |                    |                     |

    *    <- Block0  ->-<- Block1~Block16 ->-<- Block17~Block48 ->-<- Block49~Block80 ->-<- Block81~Block1073 ->

    */

    相应的代码修改如下:

    diff --git a/arch/arm/mach-exynos/lowlevel_init.c b/arch/arm/mach-exynos/lowlevel_init.c

    index 361727d..6a05fda 100644

    --- a/arch/arm/mach-exynos/lowlevel_init.c

    +++ b/arch/arm/mach-exynos/lowlevel_init.c

    @@ -229,7 +229,10 @@ int do_lowlevel_init(void)

     #endif

     #endif

                    mem_ctrl_init(actions & DO_MEM_RESET);

    +

    +#ifndef TINY4412

                    tzpc_init();

    +#endif

            }

     

            return actions & DO_WAKEUP;

    diff --git a/include/configs/tiny4412.h b/include/configs/tiny4412.h

    index 281838d..3a02f9e 100644

    --- a/include/configs/tiny4412.h

    +++ b/include/configs/tiny4412.h

    @@ -102,17 +102,33 @@

     #define CONFIG_SYS_MMC_ENV_DEV         0

     #define CONFIG_ENV_SIZE                        (16 << 10)      /* 16 KB */

     #define RESERVE_BLOCK_SIZE             (512)

    -#define BL1_SIZE                       (16 << 10) /*16 K reserved for BL1*/

    -#define CONFIG_ENV_OFFSET              (RESERVE_BLOCK_SIZE + BL1_SIZE)

    +#define BL1_SIZE                       (8 << 10) /* 8K reserved for BL1*/

    +#define BL2_SIZE                       (16 << 10) /*16 K reserved for BL2/SPL*/

    +#define CONFIG_ENV_OFFSET              (RESERVE_BLOCK_SIZE + BL1_SIZE + BL2_SIZE)

     

     #define CONFIG_SPL_LDSCRIPT    "board/samsung/common/exynos-uboot-spl.lds"

     #define CONFIG_SPL_MAX_FOOTPRINT       (14 * 1024)

     

     #define CONFIG_SYS_INIT_SP_ADDR                0x02040000

     

    -/* U-Boot copy size from boot Media to DRAM.*/

    +/* U-Boot copy size from SD/MMC to DRAM.*/

     #define COPY_BL2_SIZE          0x80000

     #define BL2_START_OFFSET       ((CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)/512)

    -#define BL2_SIZE_BLOC_COUNT    (COPY_BL2_SIZE/512)

    +#define BL2_SIZE_BLOC_COUNT    (COPY_BL2_SIZE/512)  /* u-boot size is 512K */

    +

    +/*

    + *    SD/MMC(1 Block = 512B) layout:

    + *    +------------+-------------------------------------------------------------------------------------------------+

    + *    |                                                                                    |

    + *    |            |                      |                      |                         |                        |

    + *    |   512B     |   8K(bl1)           |   16k(bl2/spl)      |   16k(ENV)             |  512k(u-boot)         |

    + *    |            |                      |                       |                        |                        |

    + *    |                                                                                    |

    + *    <- Block0  ->-<- Block1~Block16 ->-<- Block17~Block48 ->-<- Block49~Block80 ->-<- Block81~Block1073 ->----------+

    + *

    + *

    + */

    +

    +

     

     #endif /* __CONFIG_H */

     

     

    3、修改sd_fuse/sd_fusing.sh,烧写BL2u-boot.binSD卡中

        sd_fuse/sd_fusing.sh脚本修改为如下:

    #

    # Copyright (C) 2011 Samsung Electronics Co., Ltd.

    #              http://www.samsung.com/

    #

    # This program is free software; you can redistribute it and/or modify

    # it under the terms of the GNU General Public License version 2 as

    # published by the Free Software Foundation.

    #

    ####################################

     

    if [ -z $1 ]

    then

        echo "usage: ./sd_fusing.sh <SD Reader's device file>"

        exit 0

    fi

     

    if [ -b $1 ]

    then

        echo "$1 reader is identified."

    else

        echo "$1 is NOT identified."

        exit 0

    fi

     

    ####################################

    #<verify device>

     

    BDEV_NAME=`basename $1`

    BDEV_SIZE=`cat /sys/block/${BDEV_NAME}/size`

     

    if [ ${BDEV_SIZE} -le 0 ]; then

        echo "Error: NO media found in card reader."

        exit 1

    fi

     

    if [ ${BDEV_SIZE} -gt 32000000 ]; then

        echo "Error: Block device size (${BDEV_SIZE}) is too large"

        exit 1

    fi

     

     

    ####################################

    # fusing images

     

    #E4412_UBOOT = ../u-boot.bin

     

    signed_bl1_position=1

    bl2_position=17

    uboot_position=81

    tzsw_position=705

     

    #<BL1 fusing>

    echo " "

    echo "---------------------------------------"

    echo "BL1 fusing"

    #dd iflag=dsync oflag=dsync if=./E4412_N.bl1.bin of=$1 seek=$signed_bl1_position

     

    #<BL2 fusing>

    echo " "

    echo "---------------------------------------"

    echo "BL2 fusing"

    dd iflag=dsync oflag=dsync if=../spl/tiny4412-spl.bin of=$1 seek=$bl2_position

     

    #<u-boot fusing>

    echo " "

    echo "---------------------------------------"

    echo "u-boot fusing"

    dd iflag=dsync oflag=dsync if=../u-boot.bin of=$1 seek=$uboot_position

     

    #<TrustZone S/W fusing>

    #echo " "

    #echo "---------------------------------------"

    #echo "TrustZone S/W fusing"

    #dd iflag=dsync oflag=dsync if=./E4412_tzsw.bin of=$1 seek=$tzsw_position

     

    #<flush to disk>

    sync

     

    ####################################

    #<Message Display>

    echo " "

    echo "---------------------------------------"

    echo "U-boot image is fused successfully."

    echo "Eject SD card and insert it to tiny4412 board ."

    编译u-boot,并把相应的BL2u-boot.bin文件烧写到SD卡,设置tiny4412开发板从SD卡启动,启动后,可以看到串口输出如下信息:

    clip_image009

    到这里,我们就完成了把u-boot.binSD卡拷贝到DDR内存中并在内存中执行u-boot

        u-boot可以在DDR内存执行后,我们转向使用printf函数来打印调试信息。因此可以把SPL阶段的调试串口关闭了:

    diff --git a/configs/tiny4412_defconfig b/configs/tiny4412_defconfig

    index 19d0dda..0f4f2b1 100644

    --- a/configs/tiny4412_defconfig

    +++ b/configs/tiny4412_defconfig

    @@ -26,12 +26,12 @@ CONFIG_OF_CONTROL=y

     #

     #DEBUG UART

     #

    -CONFIG_DEBUG_UART=y

    -CONFIG_SPL_SERIAL_SUPPORT=y

    -CONFIG_SPL_GPIO_SUPPORT=y

    -CONFIG_DEBUG_UART_S5P=y

    -CONFIG_DEBUG_UART_BASE=0x13800000

    -CONFIG_DEBUG_UART_CLOCK=100000000

    +#CONFIG_DEBUG_UART=y

    +#CONFIG_SPL_SERIAL_SUPPORT=y

    +#CONFIG_SPL_GPIO_SUPPORT=y

    +#CONFIG_DEBUG_UART_S5P=y

    +#CONFIG_DEBUG_UART_BASE=0x13800000

    +#CONFIG_DEBUG_UART_CLOCK=100000000

     

     #

     #NOTE:do not delete this:

     

     

    参考

    1、《Exynos 4412 SCP_Users Manual_Ver.0.10.00_Preliminary.pdf

    2tiny210(s5pv210)从存储设备加载代码到DDR http://blog.csdn.net/ooonebook/article/details/52965362

    3uboot_tiny4412-20130729

     

     

  • 相关阅读:
    SSH学习-struts2整合spring报错'Could not open ServletContext resource [/WEB-INF/applicationContext.xml]'
    YAML学习
    配置composer代理
    Windows下配置PHPUnit(pear已弃用,使用phpunit.phar)
    算法-第四版-练习1.3.9解答
    算法-第四版-练习1.3.10解答
    算法-第四版-练习1.3.11解答
    算法-第四版-练习1.3.12解答
    算法-第四版-练习1.3.13解答
    算法-第四版-练习1.3.14解答
  • 原文地址:https://www.cnblogs.com/LoTGu/p/6139209.html
Copyright © 2020-2023  润新知