Fix coverity issues for i.MX8

-----BEGIN PGP SIGNATURE-----
 
 iQHDBAABCgAtFiEEiZClFGvhzbUNsmAvKMTY0yrV63cFAlvhbq0PHHNiYWJpY0Bk
 ZW54LmRlAAoJECjE2NMq1et37tAL/2dPOxjQbhNfBKccpv0wGhxL66AykHX+CcMh
 RDTOfa6sVR0LwhtIxCT0RHHiq/RMglZXojTpUCUTB9QZ8UFHn+x01RM5H6MkG8oB
 a5HSD7aGeoutZ0Aqd/NYT/TSFMKNL4dQZaWYaq+nDlOW1rSlHlDJFQLcDcEK0Cz1
 RNOlgbiFT4R+6u2eECL48gHkpYMXBIAAalFMRyyNB8+XUJGeZdFQiAmroWCfXlUz
 MgCS1lMJh43+BuIpTfUr4Ca2FHJurZLouw0+YLFzONpTWn2qkWFGJSow982zayE7
 5tdiCPIgIDts+SVhN6dFojJauhYS032zWJY6siW8jmVSFzax+ib4WOmg0Ip8CAwH
 fd+6cSYMgqiW97HQcS/5f+/YcwC+mJG5kiP7lEMlkyB6Fj4vZ/HrHRaOTkdf1pDB
 S7mvGRWBl3eD8pxioblf9+vOmfVU/XT64SU9KhrCLAXs36U+Dmv2g2VEp4D1eDKc
 9W+8eofp86X3sKkxxPh42ngjV/WhOg==
 =GSUo
 -----END PGP SIGNATURE-----

Merge tag 'u-boot-imx-20181106' of git://git.denx.de/u-boot-imx

Fix coverity issues for i.MX8
This commit is contained in:
Tom Rini 2018-11-06 11:12:00 -05:00
commit dd610e616c
4 changed files with 54 additions and 107 deletions

View File

@ -121,6 +121,7 @@ F: drivers/spi/bcmstb_spi.c
ARM FREESCALE IMX ARM FREESCALE IMX
M: Stefano Babic <sbabic@denx.de> M: Stefano Babic <sbabic@denx.de>
M: Fabio Estevam <fabio.estevam@nxp.com> M: Fabio Estevam <fabio.estevam@nxp.com>
R: NXP Linux Team <linux-imx@nxp.com>
S: Maintained S: Maintained
T: git git://git.denx.de/u-boot-imx.git T: git git://git.denx.de/u-boot-imx.git
F: arch/arm/cpu/arm1136/mx*/ F: arch/arm/cpu/arm1136/mx*/

View File

@ -16,18 +16,14 @@
stdout-path = &lpuart0; stdout-path = &lpuart0;
}; };
regulators { reg_usdhc2_vmmc: regulator-usdhc2-vmmc {
compatible = "simple-bus"; compatible = "regulator-fixed";
regulator-name = "SD1_SPWR";
reg_usdhc2_vmmc: usdhc2-vmmc { regulator-min-microvolt = <3000000>;
compatible = "regulator-fixed"; regulator-max-microvolt = <3000000>;
regulator-name = "SD1_SPWR"; gpio = <&gpio4 19 GPIO_ACTIVE_HIGH>;
regulator-min-microvolt = <3000000>; off-on-delay = <3480>;
regulator-max-microvolt = <3000000>; enable-active-high;
gpio = <&gpio4 19 GPIO_ACTIVE_HIGH>;
off-on-delay = <3480>;
enable-active-high;
};
}; };
}; };

View File

@ -1,81 +0,0 @@
U-Boot for the NXP i.MX8MQ EVK board
Quick Start
===========
- Build U-Boot
- Build the ARM Trusted firmware binary
- Get DDR firmware and mkimage tool
- Generate flash.bin using imx-mkimage
- Flash the binary into the SD card
- Boot
Build U-Boot
============
$ make mx8mq_evk_defconfig
$ make
Get and Build the ARM Trusted firmware
======================================
$ git clone https://source.codeaurora.org/external/imx/imx-atf
$ cd imx-atf/
$ git checkout origin/imx_4.9.51_imx8m_beta
$ make PLAT=imx8mq bl31
Get the DDR firmware and mkimage tool
==============================
$ wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-7.2.bin
$ chmod +x firmware-imx-7.2.bin
$ ./firmware-imx-7.2.bin
Download the imx-mkimage tool:
$ git clone https://source.codeaurora.org/external/imx/imx-mkimage/
$ cd imx-mkimage/
$ git checkout origin/imx_4.9.51_imx8m_beta
Generate flash.bin using imx-mkimage
====================================
Copy the following binaries to imx-mkimage/iMX8M folder:
$ cp imx-atf/build/imx8mq/release/bl31.bin imx-mkimage/iMX8M/
$ cp u-boot/u-boot-nodtb.bin imx-mkimage/iMX8M/
$ cp u-boot/spl/u-boot-spl.bin imx-mkimage/iMX8M/
$ cp u-boot/arch/arm/dts/fsl-imx8mq-evk.dtb imx-mkimage/iMX8M/
Copy the following firmwares to imx-mkimage/iMX8 folder :
$ cp firmware-imx-7.2/firmware/ddr/synopsys/lpddr4_pmu_train_1d_dmem.bin imx-mkimage/iMX8M/
$ cp firmware-imx-7.2/firmware/ddr/synopsys/lpddr4_pmu_train_1d_imem.bin imx-mkimage/iMX8M/
$ cp firmware-imx-7.2/firmware/ddr/synopsys/lpddr4_pmu_train_2d_dmem.bin imx-mkimage/iMX8M/
$ cp firmware-imx-7.2/firmware/ddr/synopsys/lpddr4_pmu_train_2d_imem.bin imx-mkimage/iMX8M/
If you want to run with HDMI, copy signed_hdmi_imx8m.bin to imx-mkimage/iMX8M.
Before generating the flash.bin, transfer the mkimage generated by U-Boot to iMX8M folder:
$ cp u-boot/tools/mkimage imx-mkimage/iMX8M/
$ mv imx-mkimage/iMX8M/mkimage imx-mkimage/iMX8M/mkimage_uboot
$ cd imx-mkimage/
$ make SOC=iMX8M flash_spl_uboot
Or for using HDMI:
$ make SOC=iMX8M flash_hdmi_spl_uboot
Flash the binary into the SD card
=================================
Burn the flash.bin binary to SD card offset 33KB:
$ sudo dd if=iMX8M/flash.bin of=/dev/sd[x] bs=1024 seek=33
Boot
====
Set Boot switch SW801: 1100 and Bmode: 10 to boot from Micro SD.

View File

@ -301,6 +301,7 @@ static void copy_file_aligned(int ifd, const char *datafile, int offset,
unsigned char *ptr; unsigned char *ptr;
uint8_t zeros[0x4000]; uint8_t zeros[0x4000];
int size; int size;
int ret;
if (align > 0x4000) { if (align > 0x4000) {
fprintf(stderr, "Wrong alignment requested %d\n", align); fprintf(stderr, "Wrong alignment requested %d\n", align);
@ -333,7 +334,13 @@ static void copy_file_aligned(int ifd, const char *datafile, int offset,
} }
size = sbuf.st_size; size = sbuf.st_size;
lseek(ifd, offset, SEEK_SET); ret = lseek(ifd, offset, SEEK_SET);
if (ret < 0) {
fprintf(stderr, "%s: lseek error %s\n",
__func__, strerror(errno));
exit(EXIT_FAILURE);
}
if (write(ifd, ptr, size) != size) { if (write(ifd, ptr, size) != size) {
fprintf(stderr, "Write error %s\n", strerror(errno)); fprintf(stderr, "Write error %s\n", strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -359,7 +366,7 @@ static void copy_file (int ifd, const char *datafile, int pad, int offset)
int tail; int tail;
int zero = 0; int zero = 0;
uint8_t zeros[4096]; uint8_t zeros[4096];
int size; int size, ret;
memset(zeros, 0, sizeof(zeros)); memset(zeros, 0, sizeof(zeros));
@ -387,7 +394,13 @@ static void copy_file (int ifd, const char *datafile, int pad, int offset)
} }
size = sbuf.st_size; size = sbuf.st_size;
lseek(ifd, offset, SEEK_SET); ret = lseek(ifd, offset, SEEK_SET);
if (ret < 0) {
fprintf(stderr, "%s: lseek error %s\n",
__func__, strerror(errno));
exit(EXIT_FAILURE);
}
if (write(ifd, ptr, size) != size) { if (write(ifd, ptr, size) != size) {
fprintf(stderr, "Write error %s\n", fprintf(stderr, "Write error %s\n",
strerror(errno)); strerror(errno));
@ -653,8 +666,10 @@ static int get_container_image_start_pos(image_t *image_stack, uint32_t align)
} }
ret = fread(&header, sizeof(header), 1, fd); ret = fread(&header, sizeof(header), 1, fd);
if (ret != 1) if (ret != 1) {
printf("Failure Read header %d\n", ret); printf("Failure Read header %d\n", ret);
exit(EXIT_FAILURE);
}
fclose(fd); fclose(fd);
@ -762,6 +777,7 @@ static int build_container(soc_type_t soc, uint32_t sector_size,
char *tmp_filename = NULL; char *tmp_filename = NULL;
uint32_t size = 0; uint32_t size = 0;
uint32_t file_padding = 0; uint32_t file_padding = 0;
int ret;
int container = -1; int container = -1;
int cont_img_count = 0; /* indexes to arrange the container */ int cont_img_count = 0; /* indexes to arrange the container */
@ -796,6 +812,10 @@ static int build_container(soc_type_t soc, uint32_t sector_size,
case SCFW: case SCFW:
case DATA: case DATA:
case MSG_BLOCK: case MSG_BLOCK:
if (container < 0) {
fprintf(stderr, "No container found\n");
exit(EXIT_FAILURE);
}
check_file(&sbuf, img_sp->filename); check_file(&sbuf, img_sp->filename);
tmp_filename = img_sp->filename; tmp_filename = img_sp->filename;
set_image_array_entry(&imx_header.fhdr[container], set_image_array_entry(&imx_header.fhdr[container],
@ -809,6 +829,10 @@ static int build_container(soc_type_t soc, uint32_t sector_size,
break; break;
case SECO: case SECO:
if (container < 0) {
fprintf(stderr, "No container found\n");
exit(EXIT_FAILURE);
}
check_file(&sbuf, img_sp->filename); check_file(&sbuf, img_sp->filename);
tmp_filename = img_sp->filename; tmp_filename = img_sp->filename;
set_image_array_entry(&imx_header.fhdr[container], set_image_array_entry(&imx_header.fhdr[container],
@ -883,19 +907,26 @@ static int build_container(soc_type_t soc, uint32_t sector_size,
} while (img_sp->option != NO_IMG); } while (img_sp->option != NO_IMG);
/* Add padding or skip appended container */ /* Add padding or skip appended container */
lseek(ofd, file_padding, SEEK_SET); ret = lseek(ofd, file_padding, SEEK_SET);
if (ret < 0) {
/* Note: Image offset are not contained in the image */ fprintf(stderr, "%s: lseek error %s\n",
tmp = flatten_container_header(&imx_header, container + 1, &size, __func__, strerror(errno));
file_padding);
/* Write image header */
if (write(ofd, tmp, size) != size) {
fprintf(stderr, "error writing image hdr\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* Clean-up memory used by the headers */ if (container >= 0) {
free(tmp); /* Note: Image offset are not contained in the image */
tmp = flatten_container_header(&imx_header, container + 1,
&size, file_padding);
/* Write image header */
if (write(ofd, tmp, size) != size) {
fprintf(stderr, "error writing image hdr\n");
exit(EXIT_FAILURE);
}
/* Clean-up memory used by the headers */
free(tmp);
}
/* /*
* step through the image stack again this time copying * step through the image stack again this time copying