diff --git a/srcpkgs/odroid-u2-uboot/files/mkbl2.c b/srcpkgs/odroid-u2-uboot/files/mkbl2.c new file mode 100644 index 00000000000..351e8f6dc09 --- /dev/null +++ b/srcpkgs/odroid-u2-uboot/files/mkbl2.c @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2010 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. + */ + +#include +#include +#include + +int main (int argc, char *argv[]) +{ + FILE *fp; + unsigned char src; + char *Buf, *a; + int BufLen; + int nbytes, fileLen; + unsigned int checksum = 0; + int i; + + if (argc != 4) + { + printf("Usage: mkbl1 \n"); + return -1; + } + + BufLen = atoi(argv[3]); + Buf = (char *)malloc(BufLen); + memset(Buf, 0x00, BufLen); + + fp = fopen(argv[1], "rb"); + if( fp == NULL) + { + printf("source file open error\n"); + free(Buf); + return -1; + } + + fseek(fp, 0L, SEEK_END); + fileLen = ftell(fp); + fseek(fp, 0L, SEEK_SET); + + if ( BufLen > fileLen ) + { + printf("Usage: unsupported size\n"); + free(Buf); + fclose(fp); + return -1; + } + + nbytes = fread(Buf, 1, BufLen, fp); + + if ( nbytes != BufLen ) + { + printf("source file read error\n"); + free(Buf); + fclose(fp); + return -1; + } + + fclose(fp); + + for(i = 0;i < (14 * 1024) - 4;i++) + { + checksum += (unsigned char)(Buf[i]); + } + *(unsigned int*)(Buf+i) = checksum; + + fp = fopen(argv[2], "wb"); + if (fp == NULL) + { + printf("destination file open error\n"); + free(Buf); + return -1; + } + + a = Buf; + nbytes = fwrite( a, 1, BufLen, fp); + + if ( nbytes != BufLen ) + { + printf("destination file write error\n"); + free(Buf); + fclose(fp); + return -1; + } + + free(Buf); + fclose(fp); + + return 0; +} diff --git a/srcpkgs/odroid-u2-uboot/template b/srcpkgs/odroid-u2-uboot/template index bab3e959dfe..e15a4aea2a3 100644 --- a/srcpkgs/odroid-u2-uboot/template +++ b/srcpkgs/odroid-u2-uboot/template @@ -2,7 +2,7 @@ _githash=89f2ab95e7304fe02e5267f1282fbc178550d528 pkgname=odroid-u2-uboot version=v2010.12 -revision=1 +revision=2 wrksrc="u-boot-${_githash}" hostmakedepends="uboot-mkimage" short_desc="Odroid U2 U-Boot files for SD booting" @@ -23,6 +23,8 @@ do_configure() { } do_build() { + ${BUILD_CC} ${BUILD_CFLAGS} -o mkbl2 ${FILESDIR}/mkbl2.c + unset CFLAGS CXXFLAGS LDFLAGS if [ "$CROSS_BUILD" ]; then