Yocto: u-boot-fw-utils package

Hi,

I'm having some troubles adding the u-boot-fw-utils package to our image build. Right now I'm using the SC589 Mini evaluation board.

First I just tried to add 'u-boot-fw-utils' to IMAGE_INSTALL but this gave 'Can't find default configuration "arch/../configs/sc589-mini_defconfig"!'

Makes sense, since the recipe sources/poky/meta/recipes-bsp/u-boot/u-boot-fw-utils_2018.07.bb points directly to git.denx.de/u-boot.git, while we should be using ADI https://github.com/analogdevicesinc/u-boot-sharc repo. 

I've been trying to edit the u-boot-fw-utils_2018.07.bb recipe with no luck. Since u-boot-fw-utils_2018.07 is based on U-boot 2018 and the ADI repo seems to be forked from U-boot 2015 (correct?) I started from an older recipe: http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-bsp/u-boot/u-boot-fw-utils_2015.01.bb .

I changed the SRCREV, SRC_URI with the ADI U-boot repo + it seems I needed to update EXTRA_OEMAKE_class-target and EXTRA_OEMAKE_class-cross to the 2018 version to avoid an  "/bin/sh: 1: cc: not found" error but then I get a lot of 'unknown type' errors. See attached snippet.

Can we get some support for this issue? I was planning on using 2 kernels and filesystems: 1 'normal OS' on SD-card and 1 'recover OS' in SPI flash but I need a way to signal to U-boot when to / when not to switch to the recover OS.

Thanks!

tools/env/fw_env.c:55:2: error: unknown type name 'uint8_t'
|   uint8_t mtd_type;  /* type of the MTD device */
|   ^~~~~~~
| tools/env/fw_env.c:80:2: error: unknown type name 'uint32_t'
|   uint32_t crc; /* CRC32 over data bytes    */
|   ^~~~~~~~
| tools/env/fw_env.c:85:2: error: unknown type name 'uint32_t'
|   uint32_t crc; /* CRC32 over data bytes    */
|   ^~~~~~~~
| tools/env/fw_env.c:98:2: error: unknown type name 'uint32_t'
|   uint32_t  *crc;
|   ^~~~~~~~
| tools/env/fw_env.c:110:8: error: unknown type name 'uint8_t'
|  static uint8_t aes_key[AES_KEY_LENGTH] = { 0 };
|         ^~~~~~~
| tools/env/fw_env.c: In function 'getenvsize':
| tools/env/fw_env.c:131:34: error: 'uint32_t' undeclared (first use in this function); did you mean 'u_int32_t'?
|   ulong rc = CUR_ENVSIZE - sizeof(uint32_t);
|                                   ^~~~~~~~
|                                   u_int32_t
| tools/env/fw_env.c:131:34: note: each undeclared identifier is reported only once for each function it appears in
| tools/env/fw_env.c: In function 'fw_env_close':
| tools/env/fw_env.c:341:31: error: 'uint8_t' undeclared (first use in this function); did you mean 'u_int8_t'?
|   *environment.crc = crc32(0, (uint8_t *) environment.data, ENV_SIZE);
|                                ^~~~~~~
|                                u_int8_t
| tools/env/fw_env.c:341:40: error: expected expression before ')' token
|   *environment.crc = crc32(0, (uint8_t *) environment.data, ENV_SIZE);
|                                         ^
| tools/env/fw_env.c:341:21: error: too few arguments to function 'crc32'
|   *environment.crc = crc32(0, (uint8_t *) environment.data, ENV_SIZE);
|                      ^~~~~
| In file included from tools/env/fw_env.c:35:0:
| tools/env/fw_env.h:55:23: note: declared here
|  extern unsigned long  crc32  (unsigned long, const unsigned char *, unsigned);
|                        ^~~~~
| tools/env/fw_env.c: At top level:
| tools/env/fw_env.c:679:37: error: unknown type name 'uint8_t'; did you mean 'u_int8_t'?
|  static int flash_bad_block (int fd, uint8_t mtd_type, loff_t *blockstart)
|                                      ^~~~~~~
|                                      u_int8_t
| tools/env/fw_env.c:707:21: error: unknown type name 'uint8_t'; did you mean 'u_int8_t'?
|        off_t offset, uint8_t mtd_type)
|                      ^~~~~~~
|                      u_int8_t
| tools/env/fw_env.c:796:22: error: unknown type name 'uint8_t'; did you mean 'u_int8_t'?
|         off_t offset, uint8_t mtd_type)
|                       ^~~~~~~
|                       u_int8_t
| tools/env/fw_env.c: In function 'env_aes_cbc_crypt':
| tools/env/fw_env.c:993:2: error: unknown type name 'uint8_t'; did you mean 'u_int8_t'?
|   uint8_t *data = (uint8_t *)payload;
|   ^~~~~~~
|   u_int8_t
| tools/env/fw_env.c:993:19: error: 'uint8_t' undeclared (first use in this function); did you mean 'u_int8_t'?
|   uint8_t *data = (uint8_t *)payload;
|                    ^~~~~~~
|                    u_int8_t
| tools/env/fw_env.c:993:28: error: expected expression before ')' token
|   uint8_t *data = (uint8_t *)payload;
|                             ^
| tools/env/fw_env.c:995:10: error: expected ';' before 'key_exp'
|   uint8_t key_exp[AES_EXPAND_KEY_LENGTH];
|           ^~~~~~~
| tools/env/fw_env.c:996:2: error: unknown type name 'uint32_t'; did you mean 'u_int32_t'?
|   uint32_t aes_blocks;
|   ^~~~~~~~
|   u_int32_t
| tools/env/fw_env.c:999:26: error: 'key_exp' undeclared (first use in this function); did you mean 'key_t'?
|   aes_expand_key(aes_key, key_exp);
|                           ^~~~~~~
|                           key_t
| tools/env/fw_env.c:999:17: warning: passing argument 1 of 'aes_expand_key' from incompatible pointer type [-Wincompatible-pointer-types]
|   aes_expand_key(aes_key, key_exp);
|                  ^~~~~~~
| In file included from tools/env/fw_env.c:37:0:
| include/aes.h:43:6: note: expected 'u8 * {aka unsigned char *}' but argument is of type 'int *'
|  void aes_expand_key(u8 *key, u8 *expkey);
|       ^~~~~~~~~~~~~~
| tools/env/fw_env.c:1005:35: warning: passing argument 2 of 'aes_cbc_encrypt_blocks' from incompatible pointer type [-Wincompatible-pointer-types]
|    aes_cbc_encrypt_blocks(key_exp, data, data, aes_blocks);
|                                    ^~~~
| In file included from tools/env/fw_env.c:37:0:
| include/aes.h:82:6: note: expected 'u8 * {aka unsigned char *}' but argument is of type 'int *'
|  void aes_cbc_encrypt_blocks(u8 *key_exp, u8 *src, u8 *dst, u32 num_aes_blocks);
|       ^~~~~~~~~~~~~~~~~~~~~~
| tools/env/fw_env.c:1005:41: warning: passing argument 3 of 'aes_cbc_encrypt_blocks' from incompatible pointer type [-Wincompatible-pointer-types]
|    aes_cbc_encrypt_blocks(key_exp, data, data, aes_blocks);
|                                          ^~~~
| In file included from tools/env/fw_env.c:37:0:
| include/aes.h:82:6: note: expected 'u8 * {aka unsigned char *}' but argument is of type 'int *'
|  void aes_cbc_encrypt_blocks(u8 *key_exp, u8 *src, u8 *dst, u32 num_aes_blocks);
|       ^~~~~~~~~~~~~~~~~~~~~~
| tools/env/fw_env.c:1007:35: warning: passing argument 2 of 'aes_cbc_decrypt_blocks' from incompatible pointer type [-Wincompatible-pointer-types]
|    aes_cbc_decrypt_blocks(key_exp, data, data, aes_blocks);
|                                    ^~~~
| In file included from tools/env/fw_env.c:37:0:
| include/aes.h:92:6: note: expected 'u8 * {aka unsigned char *}' but argument is of type 'int *'
|  void aes_cbc_decrypt_blocks(u8 *key_exp, u8 *src, u8 *dst, u32 num_aes_blocks);
|       ^~~~~~~~~~~~~~~~~~~~~~
| tools/env/fw_env.c:1007:41: warning: passing argument 3 of 'aes_cbc_decrypt_blocks' from incompatible pointer type [-Wincompatible-pointer-types]
|    aes_cbc_decrypt_blocks(key_exp, data, data, aes_blocks);
|                                          ^~~~
| In file included from tools/env/fw_env.c:37:0:
| include/aes.h:92:6: note: expected 'u8 * {aka unsigned char *}' but argument is of type 'int *'
|  void aes_cbc_decrypt_blocks(u8 *key_exp, u8 *src, u8 *dst, u32 num_aes_blocks);
|       ^~~~~~~~~~~~~~~~~~~~~~
| tools/env/fw_env.c: In function 'flash_write':
| tools/env/fw_env.c:1036:7: warning: implicit declaration of function 'flash_write_buf'; did you mean 'flash_write'? [-Wimplicit-function-declaration]
|   rc = flash_write_buf(dev_target, fd_target, environment.image,
|        ^~~~~~~~~~~~~~~
|        flash_write
| tools/env/fw_env.c: In function 'flash_read':
| tools/env/fw_env.c:1092:7: warning: implicit declaration of function 'flash_read_buf'; did you mean 'flash_read'? [-Wimplicit-function-declaration]
|   rc = flash_read_buf(dev_current, fd, environment.image, CUR_ENVSIZE,
|        ^~~~~~~~~~~~~~
|        flash_read
| tools/env/fw_env.c: In function 'fw_env_open':
| tools/env/fw_env.c:1225:20: error: 'uint8_t' undeclared (first use in this function); did you mean 'u_int8_t'?
|   crc0 = crc32 (0, (uint8_t *) environment.data, ENV_SIZE);
|                     ^~~~~~~
|                     u_int8_t
| tools/env/fw_env.c:1225:29: error: expected expression before ')' token
|   crc0 = crc32 (0, (uint8_t *) environment.data, ENV_SIZE);
|                              ^
| tools/env/fw_env.c:1225:9: error: too few arguments to function 'crc32'
|   crc0 = crc32 (0, (uint8_t *) environment.data, ENV_SIZE);
|          ^~~~~
| In file included from tools/env/fw_env.c:35:0:
| tools/env/fw_env.h:55:23: note: declared here
|  extern unsigned long  crc32  (unsigned long, const unsigned char *, unsigned);
|                        ^~~~~
| tools/env/fw_env.c:1282:30: error: expected expression before ')' token
|    crc1 = crc32 (0, (uint8_t *) redundant->data, ENV_SIZE);
|                               ^
| tools/env/fw_env.c:1282:10: error: too few arguments to function 'crc32'
|    crc1 = crc32 (0, (uint8_t *) redundant->data, ENV_SIZE);
|           ^~~~~
| In file included from tools/env/fw_env.c:35:0:
| tools/env/fw_env.h:55:23: note: declared here
|  extern unsigned long  crc32  (unsigned long, const unsigned char *, unsigned);

  • +1
    •  Analog Employees 
    on Oct 19, 2020 8:03 AM 3 months ago

    Hi @StijnVM,

    Sorry for the late response, we only have a workaround to build the fw_printenv/fw_setenv utils in Linux without YOCTO that is to Cross compile with the arm-linux-gnueabi- toolchain within U-boot source code, just enter into the u-boot source code and then run the command "make sc589-mini_defconfig and make CROSS_COMPILE=arm-linux-gnueabi- env", the fw_printenv would be generated in tools/env directory and then copy them to filesystem manully, But for your building error in Yocto, we are also in investigation now. Seems the YOCTO use the HOST gcc toolchain but did not recognize the cross-compile toolchain.

    Note that we should change the /etc/fw_env.config file to read parameter from " /dev/mtd0  0x10000   0x2000   0x10000". The ENV_OFFSET in our ADI is 0x10000, the ENV_SIZE is 0x2000.

    Thanks.

  • Hi, have you made any progress on the building error in Yocto?

    I have been able to build the utils after a couple of steps. For future reference for myself and maybe useful to others: 

    • fw_env.c needs to be patched it seems, regarding the unknown type errors I was seeing above
      https://gitlab.denx.de/u-boot/u-boot/-/commit/69bf2d2fafe64349be3c3ef1256e3c68f812bb25
       

    • You suggested the arm-linux-gnueabi-gcc toolchain, but this didn't work for me. I installed gcc-arm-linux-gnueabi package for this. readelf -l fw_printenv shows:
      [Requesting program interpreter: /lib/ld-linux.so.3]
      But ld-linux.so isn't present in my fs. And couldn't get it to statically link for some reason.. What did work was using the Yocto SDK toolchain I generated instead, but only by setting CC in the env makefile to 
      CC=arm-poky-linux-gnueabi-gcc -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi
    • The ISSI nor-flash(the 512 version) of the MINI board isn't defined in the kernel so had to create a patch to add it to spi-nor.c for the /dev/mtd0 partition to show up

    This works, but it would be nice if we could use Yocto to build this. 

    I tried building again by adding the u-boot-fw-utils package but now got stuck on an error and didn't pusue.

    ERROR: u-boot-fw-utils-2018.07-r0 do_package: Function failed: split_and_strip_files