首页 > 代码库 > X-004 FriendlyARM tiny4412 uboot移植之点亮指路灯
X-004 FriendlyARM tiny4412 uboot移植之点亮指路灯
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
开发环境: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开发板添加相应目录文件,并且可以顺利编译通过生成.bin文件。接下来我们通过点亮tiny4412核心板上的LED灯开始调试u-boot。
1、Tiny4412 LED硬件原理图与exynos4412相关引脚寄存器
从Tiny4412-1412-Schematic.pdf原理图上可以看到板子上的四个LED硬件连接如下图所示:
LED1~LED4分别跟GPM4_0~GPM4_3相接。
exynos4412 GPM4相关的寄存器如下:
现在我们只是想简单的点亮exynos4412 GPM4管脚上的LED灯,需要设置GPM4CON和GPM4DAT寄存器,这两个寄存器的相关描述如下:
2、添加LED灯代码
在arch/arm/cpu/armv7/start.S中添加点亮LED的代码。
diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S index 691e5d3..4496f2f 100755 --- a/arch/arm/cpu/armv7/start.S +++ b/arch/arm/cpu/armv7/start.S @@ -47,6 +47,7 @@ save_boot_params_ret: orr r0, r0, #0xc0 @ disable FIQ and IRQ msr cpsr,r0
+ bl light_led /* * Setup vector: * (OMAP4 spl TEXT_BASE is not 32 byte aligned. @@ -63,6 +64,8 @@ save_boot_params_ret: mcr p15, 0, r0, c12, c0, 0 @Set VBAR #endif
+ + /* the mask ROM code should have PLL and others stable */ #ifndef CONFIG_SKIP_LOWLEVEL_INIT bl cpu_init_cp15 @@ -272,3 +275,18 @@ ENTRY(cpu_init_crit) b lowlevel_init @ go setup pll,mux,memory ENDPROC(cpu_init_crit) #endif + + .globl light_led +light_led: + ldr r0,=0x110002E0 @ set GPM4CON Register + ldr r1,=0x00001111 @ Configurate GPM4_0<A1>GPM4_1<A2>GPM4_2<A2>GPM4_3 output + str r1,[r0] + + ldr r0,=0x110002E4 @ set GPM4DAT Register +@ mov r1,#0xFE @ light All led1 on +@ mov r1,#0xFD @ light All led2 on +@ mov r1,#0xFB @ light All led3 on +@ mov r1,#0xF7 @ light All led4 on + mov r1,#0xF0 @ light All led on + str r1,[r0] + mov pc, lr
|
3、修改board/samsung/tiny4412/tools/mktiny4412spl.c文件,用于生成BL2
diff --git a/board/samsung/tiny4412/tools/mktiny4412spl.c b/board/samsung/tiny4412/tools/mktiny4412spl.c index 3ed20ef..c3a3e29 100755 --- a/board/samsung/tiny4412/tools/mktiny4412spl.c +++ b/board/samsung/tiny4412/tools/mktiny4412spl.c @@ -1,5 +1,6 @@ /* - * Copyright (C) 2011 Samsung Electronics + * 2016 + * Author AP0904225 <ap0904225@qq.com> * * SPDX-License-Identifier: GPL-2.0+ */ @@ -13,11 +14,9 @@ #include <sys/stat.h>
#define BUFSIZE (16*1024) -#define IMG_SIZE (16*1024) -#define SPL_HEADER_SIZE 16 +#define IMG_SIZE ( (14*1024)- 4 ) #define FILE_PERM (S_IRUSR | S_IWUSR | S_IRGRP \ | S_IWGRP | S_IROTH | S_IWOTH) -#define SPL_HEADER "S5PC210 HEADER " /* * Requirement: * IROM code reads first 14K bytes from boot device. @@ -37,7 +36,8 @@ int main(int argc, char **argv) int i, len; unsigned char buffer[BUFSIZE] = {0}; int ifd, ofd; - unsigned int checksum = 0, count; + unsigned int checksum = 0; + unsigned int count = 0;
if (argc != 3) { printf(" %d Wrong number of arguments\n", argc); @@ -52,7 +52,7 @@ int main(int argc, char **argv) }
ofd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, FILE_PERM); - if (ifd < 0) { + if (ofd < 0) { fprintf(stderr, "%s: Can‘t open %s: %s\n", argv[0], argv[2], strerror(errno)); if (ifd) @@ -63,12 +63,9 @@ int main(int argc, char **argv) len = lseek(ifd, 0, SEEK_END); lseek(ifd, 0, SEEK_SET);
- memcpy(&buffer[0], SPL_HEADER, SPL_HEADER_SIZE); - - count = (len < (IMG_SIZE - SPL_HEADER_SIZE)) - ? len : (IMG_SIZE - SPL_HEADER_SIZE); + count = (len < IMG_SIZE )? len : IMG_SIZE; //14K-4
- if (read(ifd, buffer + SPL_HEADER_SIZE, count) != count) { + if (read(ifd, buffer, count) != count) { fprintf(stderr, "%s: Can‘t read %s: %s\n", argv[0], argv[1], strerror(errno));
@@ -80,14 +77,11 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); }
- for (i = 0; i < IMG_SIZE - SPL_HEADER_SIZE; i++) - checksum += buffer[i+16]; - - *(ulong *)buffer ^= 0x1f; - *(ulong *)(buffer+4) ^= checksum; - - for (i = 1; i < SPL_HEADER_SIZE; i++) - buffer[i] ^= buffer[i-1]; + for(i = 0;i < IMG_SIZE;i++) + { + checksum += (unsigned char)(buffer[i]); + } + *(unsigned int*)(buffer+i) = checksum;
if (write(ofd, buffer, BUFSIZE) != BUFSIZE) { fprintf(stderr, "%s: Can‘t write %s: %s\n",
|
4、添加exynos4412 BL1固件E4412_N.bl1.bin
4.1、在board/samsung/tiny4412/目录下添加firmware文件夹
$ mkdir -p board/samsung/tiny4412/firmware |
4.2、拷贝E4412_N.bl1.bin到board/samsung/tiny4412/firmware/目录下
5、u-boot根目录下添加编译脚本文件build-tiny4412.sh
echo "*******clean*********" make distclean
echo "------------config tiny4412------------" make ARCH=arm tiny4412_defconfig
echo "----------------building--------------------" make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
|
6、u-boot根目录下添加SD卡烧写脚本文件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
#################################### # check files
#################################### # fusing images
signed_bl1_position=1 bl2_position=17 uboot_position=49 tzsw_position=705
#<BL1 fusing> echo "---------------------------------------" echo "BL1 fusing" dd iflag=dsync oflag=dsync if=./board/samsung/tiny4412/firmware/E4412_N.bl1.bin of=$1 seek=$signed_bl1_position
#<tiny4412-spl.bin fusing> echo "---------------------------------------" echo "tiny4412-spl.bin fusing" dd iflag=dsync oflag=dsync if=./spl/tiny4412-spl.bin of=$1 seek=$bl2_position
#<u-boot fusing> #echo "---------------------------------------" #echo "u-boot fusing" #dd iflag=dsync oflag=dsync if=${E4412_UBOOT} of=$1 seek=$uboot_position
#<TrustZone S/W fusing> #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 "U-boot image is fused successfully." echo "Eject SD card and insert it again." |
在u-boot根目录下执行build-tiny4412.sh编译完成后,会生成spl/tiny4412-spl.bin,通过SD卡烧写脚本sd_fusing.sh把E4412_N.bl1.bin和tiny4412-spl.bin烧写到相应的位置。把SD卡插到tiny4412开发板的SD卡槽上,选择从SD卡启动,开发板上电后应该可以看到点亮了相应的LED灯。
X-004 FriendlyARM tiny4412 uboot移植之点亮指路灯