Request help troubleshoot cross compilation problem

Continuing the discussion from Request help troubleshoot cross compilation problem:

Hi,

I use this sabrelite-gadget snap (https://github.com/ogra1/sabrelite-gadget) as a reference to create a gadget snap for imx6 pico board. However, after running snapcraft, it built *amd_64.snap. When I did ‘snapcraft --target-arch=armhf’ (or =arm), I got

Sorry, an error occurred in Snapcraft:
Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 9, in <module>
    load_entry_point('snapcraft==2.43.1', 'console_scripts', 'snapcraft')()
....
 File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/_plugin_loader.py", line 79, in load_plugin
    plugin.enable_cross_compilation()
  File "/usr/lib/python3/dist-packages/snapcraft/_baseplugin.py", line 188, in enable_cross_compilation
    "to a different target architecture".format(self.name)
NotImplementedError: The plugin used by 'uboot' does not support cross-compiling to a different target architecture

Here’s my yaml:

parts:
  uboot:
    plugin: make
    source: ./source
    artifacts: [u-boot.imx]
    prepare: |
      make mx6_iwg15s_pico_defconfig
    build: |
      if [ "$(arch)" = "x86_64" ]; then
        CROSS_COMPILE=arm-linux-gnueabi- make
      else
        make
      fi
    install: |
      cp u-boot.imx $SNAPCRAFT_PART_INSTALL/
      tools/mkenvimage -r -s 131072 -o $SNAPCRAFT_PART_INSTALL/uboot.env ../../../uboot.env.in
      cd $SNAPCRAFT_PART_INSTALL/; ln -s uboot.env uboot.conf
    build-packages:
      - bc
      - build-essential
      - libpython2.7-dev
      - on amd64 to armhf:
          - gcc-arm-linux-gnueabi:amd64

I also tried this but got *amd64.snap after snapcrafting:

    build: |
      CROSS_COMPILE=arm-linux-gnueabi- make
    build-packages:
      - libpython2.7-dev
      - build-essential
      - bc
      - gcc-arm-linux-gnueabi

Btw, using this u-boot version: 2015.04

Thanks for the help.

@rarep I think CROSS_COMPILE=arm-linux-gnueabi- make will work if you add to the yaml:

architectures:
  - armhf

Otherwise, you can resort to compile on an armhf chroot/VM or on an armhf device, for instance an RPi with Ubuntu classic.

Hi,
I have already added the “architectures:”.
I was able to run snapcraft --target-arch=armhf successfully when I changed the plugin from ‘make’ to ‘nil’ and removed the artifacts.
I thought the “build:” scriptlet will override the ‘make’ call.
Thanks.