# Microchip-sama5d27-som1-ek1 integrate with google IOT cloud

**URL:** https://hub.mender.io/t/microchip-sama5d27-som1-ek1-integrate-with-google-iot-cloud/892
**Category:** General Discussions
**Created:** [August 7, 2019, 5:26am UTC](https://hub.mender.io/t/microchip-sama5d27-som1-ek1-integrate-with-google-iot-cloud/892 "2019-08-07T05:26:50Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![nidev01](https://avatars.discourse-cdn.com/v4/letter/n/3d9bf3/32.png) [@nidev01](https://hub.mender.io/u/nidev01)
#### Post date: [August 7, 2019, 5:26am UTC](https://hub.mender.io/t/microchip-sama5d27-som1-ek1-integrate-with-google-iot-cloud/892/1 "2019-08-07T05:26:50Z")

</div>

Used this link for setting up for atmel platform using [Microchip SAMA5d27-SOM1-EK1](https://hub.mender.io/t/microchip-sama5d27-som1-ek1/127)  
This works great with demo server.

Then followed this link [https://mkrak.org/wp-content/uploads/2019/04/Integrate-IoT-cloud-analytics-and-over-the-air-OTA-updates-with-Google-and-Mender.io\_.pdf](https://mkrak.org/wp-content/uploads/2019/04/Integrate-IoT-cloud-analytics-and-over-the-air-OTA-updates-with-Google-and-Mender.io_.pdf)  
In order to integrate with google IoT cloud.  
Used your link in the document for [https://cloud.google.com/community/tutorials/cloud-iot-mender-ota](https://cloud.google.com/community/tutorials/cloud-iot-mender-ota) and modified mender-gcp-build.sh to what I thought would work for my build. I have enclosed the modified script below.  
On first run got this:

```auto
 ERROR: Layer meta-gcp-iot is not compatible with the core layer which only supports these series: thud (layer is compatible with rocko master sumo)

```

So modified the conf file for meta-gcp-iot to include thud.  
And then I got this error:

```auto
ERROR: /home/nima/wip/mender-atmel/sources/community/tutorials/cloud-iot-mender-ota/image/meta-gcp-iot/recipes-gcp/images/gcp-mender-demo-image.bb: MENDER_DATA_PART_DIR is deprecated. Please use recipes to add files directly to /data instead.
ERROR: Failed to parse recipe: /home/nima/wip/mender-atmel/sources/community/tutorials/cloud-iot-mender-ota/image/meta-gcp-iot/recipes-gcp/images/gcp-mender-demo-image.bb

```

Can you provide some guidance on steps to proceed to correct this error? I attempted the suggested options based on your documentation but the build did not contain the mender.conf files among others in /data partition.  
Thank you

* * *

content of modified script used for mender-gcp-build.sh:

```auto
#!/bin/bash
#
cd sources
[-d meta-gcp-iot] || git clone -b master https://github.com/GoogleCloudPlatform/community.git
source ../setup-environment atmel
if [-d ~/downloads] ; then
    rm -rf ./downloads
    ln -s ~/downloads .
fi
if [-d ~/sstate-cache]; then
    rm -rf ./sstate-cache
    ln -s ~/sstate-cache .
fi
bitbake-layers add-layer -F /home/nima/wip/mender-atmel/sources/meta-openembedded/meta-oe
bitbake-layers add-layer -F /home/nima/wip/mender-atmel/sources/meta-openembedded/meta-python
bitbake-layers add-layer -F /home/nima/wip/mender-atmel/sources/meta-openembedded/meta-multimedia
bitbake-layers add-layer -F /home/nima/wip/mender-atmel/sources/meta-openembedded/meta-networking
bitbake-layers add-layer -F /home/nima/wip/mender-atmel/sources/meta-java
bitbake-layers add-layer -F /home/nima/wip/mender-atmel/sources/meta-iot-cloud
bitbake-layers add-layer -F /home/nima/wip/mender-atmel/sources/community/tutorials/cloud-iot-mender-ota/image/meta-gcp-iot
cat > conf/auto.conf <<- EOF
	MENDER_SERVER_URL = "https://mender.gcpotademo.com"
	PACKAGE_CLASSES = "package_ipk"
	INHERIT += "rm_work"
EOF
export FULL_PROJECT=$(gcloud config list project --format "value(core.project)")
export PROJECT_ID="$(echo $FULL_PROJECT | cut -f2 -d ':')"
export REGION_ID='us-central1'
export REGISTRY_ID='mender-demo'
export IMAGE='gcp-mender-demo-image'
export MACHINE='sama5d27-som1-ek-sd'

# Ensure that the GCP variables defined above are passed into the bitbake environment
export BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE PROJECT_ID REGION_ID REGISTRY_ID"

bitbake ${IMAGE}
cp ./tmp/deploy/images/${MACHINE}/${IMAGE}-${MACHINE}-*.sdimg ./tmp/deploy/images/${MACHINE}/${IMAGE}-${MACHINE}-*.img
gsutil cp $(find ./tmp/deploy/images/${MACHINE}/${IMAGE}-${MACHINE}-*.sdimg -type f) gs://$PROJECT_ID-mender-builds/${IMAGE}-${MACHINE}.sdimg
gsutil cp $(find ./tmp/deploy/images/${MACHINE}/${IMAGE}-${MACHINE}-*.sdimg.bmap -type f) gs://$PROJECT_ID-mender-builds/${IMAGE}-${MACHINE}.sdimg.bmap
gsutil cp $(find ./tmp/deploy/images/${MACHINE}/${IMAGE}-${MACHINE}-*.img -type f) gs://$PROJECT_ID-mender-builds/${IMAGE}-${MACHINE}.img
cat >> conf/auto.conf <<-	EOF
	MENDER_ARTIFACT_NAME = "release-2"
	IMAGE_INSTALL_append = " python-docs-samples"
EOF
bitbake ${IMAGE}
gsutil cp $(find ./tmp/deploy/images/${MACHINE}/${IMAGE}-${MACHINE}-*.mender -type f) gs://$PROJECT_ID-mender-builds/${IMAGE}-${MACHINE}.mender

```

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [August 7, 2019, 11:23am UTC](https://hub.mender.io/t/microchip-sama5d27-som1-ek1-integrate-with-google-iot-cloud/892/2 "2019-08-07T11:23:39Z")

</div>

> [@nidev01](#):
>
> ```auto
> ERROR: /home/nima/wip/mender-atmel/sources/community/tutorials/cloud-iot-mender-ota/image/meta-gcp-iot/recipes-gcp/images/gcp-mender-demo-image.bb: MENDER_DATA_PART_DIR is deprecated. Please use recipes to add files directly to /data instead. 
> ERROR: Failed to parse recipe: /home/nima/wip/mender-atmel/sources/community/tutorials/cloud-iot-mender-ota/image/meta-gcp-iot/recipes-gcp/images/gcp-mender-demo-image.bb
> 
> ```

Can you please share the changes you did to get around this? There are a couple of locations which use the “old method” to install to `/data` and all of them need to be updated.

That said, this was only on `rocko`, and might require some additional updates to work on `thud`

---

<div class="post-metadata">

### Author: ![nidev01](https://avatars.discourse-cdn.com/v4/letter/n/3d9bf3/32.png) [@nidev01](https://hub.mender.io/u/nidev01)
#### Post date: [August 7, 2019, 7:01pm UTC](https://hub.mender.io/t/microchip-sama5d27-som1-ek1-integrate-with-google-iot-cloud/892/3 "2019-08-07T19:01:40Z")

</div>

replace

```auto
MENDER_DATA_PART_DIR = "${DEPLOY_DIR_IMAGE}/persist"

```

with

```auto
inherit deploy
do_deploy() {
    install -d ${DEPLOYDIR}/persist
    install -m 0644 persistent.txt ${DEPLOYDIR}/persist
}
addtask do_deploy after do_compile before do_build

```

Unfortunately the first time I did not document all of my steps as well as this time. So there maybe a few things that are missing from that run. However, I got to a good compile and after I burned an sd image, I saw that the ln file in etc/mender was correctly pointing to /data/mender but did not see an mender.conf in the corresponding /data/mender directory.  
I have made the change above and it is now compiling again. I will confirm if I see the same problem. If you already see an issue with what I have done then please let me know as it will take a few hours to compile.  
Thank you.

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [August 7, 2019, 7:46pm UTC](https://hub.mender.io/t/microchip-sama5d27-som1-ek1-integrate-with-google-iot-cloud/892/4 "2019-08-07T19:46:48Z")

</div>

Which version of the docs did you get that from?

The most recent example can be found here,

> <https://github.com/mendersoftware/meta-mender/blob/master/meta-mender-demo/recipes-mender/hello-mender/hello-mender.bb>

Nowadays you just install to `${D} /data` like you would normally and this will be converted to the data partition

---

<div class="post-metadata">

### Author: ![nidev01](https://avatars.discourse-cdn.com/v4/letter/n/3d9bf3/32.png) [@nidev01](https://hub.mender.io/u/nidev01)
#### Post date: [August 8, 2019, 12:23am UTC](https://hub.mender.io/t/microchip-sama5d27-som1-ek1-integrate-with-google-iot-cloud/892/5 "2019-08-08T00:23:46Z")

</div>

2.0:  
[https://docs.mender.io/2.0/artifacts/yocto-project/variables](https://docs.mender.io/2.0/artifacts/yocto-project/variables)  
but I will follow your recommendation now.

---

<div class="post-metadata">

### Author: ![nidev01](https://avatars.discourse-cdn.com/v4/letter/n/3d9bf3/32.png) [@nidev01](https://hub.mender.io/u/nidev01)
#### Post date: [August 8, 2019, 2:44am UTC](https://hub.mender.io/t/microchip-sama5d27-som1-ek1-integrate-with-google-iot-cloud/892/6 "2019-08-08T02:44:31Z")

</div>

I understood that MENDER\_DATA\_PART\_DIR was used to add files to the data partition of mender.  
In examining source of what is building the mender conf file it seems like it is mender-gcp-iot.inc:

```auto
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI += " \
    file://gcp-iot-mender-device-identity \
    file://mender.conf \
    file://mender-generate-certificate \
"

FILES_${PN} += " \
     ${sbindir}/mender-keygen-client \
     ${sbindir}/mender-generate-certificate \
"

do_install_prepend() {
    # Update the service file to invoke mender-generate-certificate
    cat >> ${WORKDIR}/${SYSTEMD_SERVICE_${PN}} <<-EOF
	
	[Service]
	ExecStartPre=${sbindir}/mender-generate-certificate
	EOF
}

do_install_append() {
    install -d ${D}/${datadir}/mender/identity
    install -m 0755 ${WORKDIR}/gcp-iot-mender-device-identity ${D}/${datadir}/mender/identity/mender-device-identity
    install -d ${D}/${sbindir}
    install -m 0700 ${S}/src/${GO_IMPORT}/support/keygen-client ${D}/${sbindir}/mender-keygen-client
    install -m 0700 ${WORKDIR}/mender-generate-certificate ${D}/${sbindir}/
}

MENDER_UPDATE_POLL_INTERVAL_SECONDS = "30"
MENDER_INVENTORY_POLL_INTERVAL_SECONDS = "30"
MENDER_RETRY_POLL_INTERVAL_SECONDS = "30"

do_compile_prepend() {
  bbwarn "You are building with the meta-gcp-iot layer, which is not intended for production use"
}

RDEPENDS_${PN} += " bash openssl"

inherit deploy

do_deploy() {
   install -d ${DEPLOYDIR}/persist/mender
   mv ${D}${sysconfdir}/mender/mender.conf ${DEPLOYDIR}/persist/mender
   ln -s /data/mender/mender.conf ${D}${sysconfdir}/mender/mender.conf
}
addtask do_deploy after do_install before do_package

```

Are you suggesting to keep this file intact and just focus on the changing where this statement MENDER\_DATA\_PART\_DIR = “${DEPLOY\_DIR\_IMAGE}/persist” was placed with your version?  
Or should I also make similar changes to the mender-gcp-iot.inc file?

Normally I would experiment more on my own but it takes so many hours to just get a good compile that I rather ask a bit ahead of my next compile.

Thank you.

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [August 8, 2019, 6:48am UTC](https://hub.mender.io/t/microchip-sama5d27-som1-ek1-integrate-with-google-iot-cloud/892/7 "2019-08-08T06:48:50Z")

</div>

`mender.conf` is created by the `mender` recipe, `mender-gcp-iot.inc` is used in a `mender_%.bbappend`

You can remove `MENDER_DATA_PART_DIR = “${DEPLOY_DIR_IMAGE}/persist”`. As this is not used anymore.

And you need to change,

```auto
do_deploy() {
   install -d ${DEPLOYDIR}/persist/mender
   mv ${D}${sysconfdir}/mender/mender.conf ${DEPLOYDIR}/persist/mender
   ln -s /data/mender/mender.conf ${D}${sysconfdir}/mender/mender.conf
}

```

to

```auto
do_install() {
   install -d ${D}/data/mender
   mv ${D}${sysconfdir}/mender/mender.conf ${D}/data/mender
   ln -s /data/mender/mender.conf ${D}${sysconfdir}/mender/mender.conf
}

```

You do not necessary need to create a new `do_install` but can add above to the existing `do_install_append` function in the `mender-gcp-iot.inc` file.

---

<div class="post-metadata">

### Author: ![nidev01](https://avatars.discourse-cdn.com/v4/letter/n/3d9bf3/32.png) [@nidev01](https://hub.mender.io/u/nidev01)
#### Post date: [August 13, 2019, 5:45pm UTC](https://hub.mender.io/t/microchip-sama5d27-som1-ek1-integrate-with-google-iot-cloud/892/8 "2019-08-13T17:45:16Z")

</div>

I have incorporated the changes as specified. That is very helpful. I am not very clear on the mixed-use of ${D} in old code but have not had a chance to find documentation or examine the source code.

It is still not compiling but the problem is with YOCTO at this point. I have been seeking suggestions on the Yocto IRC but thought I would post it here too in case you have a suggestion.

I am getting:

```auto
![image|690x332](upload://2y3711hT3nremsyKO4UWiSGBvXm.png) Running pm_to_blib for cpan/version directly
LD_LIBRARY_PATH=~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/perl-5.24.4 ./miniperl -Ilib make_ext.pl dist/XSLoader/pm_to_blib MAKE="make" LIBPERL_A=libperl.so
make[1]: Entering directory '~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/perl-5.24.4/dist/XSLoader'
make[1]: Leaving directory~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/perl-5.24.4/dist/XSLoader'
LD_LIBRARY_PATH=~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/perl-5.24.4 ./miniperl -Ilib lib/unicore/mktables -C lib/unicore -P pod -maketest -makelist -p
lib/unicore/mktables: Files seem to be ok, not bothering to rebuild. Add '-w' option to force build
LD_LIBRARY_PATH=~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/perl-5.24.4 ./miniperl -Ilib -Ilib -MExtUtils::Miniperl -e 'writemain(\"perlmain.c", @ARGV)' DynaLoader 
gcc -c -DPERL_CORE -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -std=c89 -O2 -Wall -Werror=declaration-after-statement -Wextra -Wc++-compat -Wwrite-strings -fPIC perlmain.c
LD_LIBRARY_PATH=~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/perl-5.24.4 ./miniperl -Ilib make_ext.pl DynaLoader.o MAKE="make" LIBPERL_A=libperl.so LINKTYPE=static 
make[1]: Entering directory '~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/perl-5.24.4/ext/DynaLoader'
make[1]: Leaving directory '~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/perl-5.24.4/ext/DynaLoader'
rm -f libperl.so
gcc -o libperl.so -L~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/recipe-sysroot-native/usr/lib -L~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/recipe-sysroot-native/lib -Wl,-rpath-link,~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/recipe-sysroot-native/usr/lib -Wl,-rpath-link~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/recipe-sysroot-native/lib -Wl,-rpath~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/recipe-sysroot-native/usr/lib -Wl,-rpath~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/recipe-sysroot-native/lib -Wl,-O1 -Wl,--allow-shlib-undefined -Wl,--dynamic-linker=~/wip/mender-atmel/build/tmp/sysroots-uninative/x86_64-linux/lib/ld-linux-x86-64.so.2 -shared -L/usr/local/lib op.o perl.o gv.o toke.o perly.o pad.o regcomp.o dump.o util.o mg.o reentr.o mro_core.o keywords.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o doop.o doio.o regexec.o utf8.o taint.o deb.o universal.o globals.o perlio.o perlapi.o numeric.o mathoms.o locale.o pp_pack.o pp_sort.o caretx.o dquote.o time64.o DynaLoader.o -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc 
~/wip/mender-atmel/build/tmp/hosttools/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcrypt.a(crypt-entry.o): relocation R_X86_64_PC32 against symbol `_ufc_foobar' can not be used when making a shared object; recompile with -fPIC
~/wip/mender-atmel/build/tmp/hosttools/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
ERROR: oe_runmake failed
makefile:358: recipe for target 'libperl.so' failed
make: *** [libperl.so] Error 1
WARNING: exit code 1 from a shell command.
ERROR: Function failed: do_compile (log file is located at ~/wip/mender-atmel/build/tmp/work/x86_64-linux/perl-native/5.24.4-r0/temp/log.do_compile.24783)

```

I tried adding -fPIC in a few places but did not get anywhere.  
in bitbake.conf under …/poky/meta/conf/bitbake.conf:

```auto
TUNE_LDARGS += " -fPIC"

```

In …/poky/meta/recipes-devtools/perl/perl\_5.4.4.bb:

```auto
# LDFLAGS for shared libraries
export LDDLFLAGS = "${LDFLAGS} -shared -fPIC"
CFLAGS += "-DDEBIAN -fPIC" # and tried this too!

```

in ./poky/meta/recipes-devtools/perl/perl-native\_5.24.4.bb:

```auto
inherit native
##CC += " -fPIC" -- tried this too

export LD="${CCLD} -fPIC"

```

I can see the -fPIC in gcc statement but looks like I have to add it somewhere else. That is why I tried upstream but that did not work either.

Thank you.
