Connect IOT Ethernet on mangho red


#1

Hello,

I want use a IOT Ethernet card on Mangho red.
when I start the Mangho the leds are off on the IOT.
I found in another topic the following instructions to activate the IOT:

echo 2 > /sys/class/gpio/export_
echo out > /sys/class/gpio/gpio2/direction_
echo 1 > /sys/class/gpio/gpio2/value_
/etc/init.d/networking restart_

After these commands I have eth0 enabled and I have an IP address.
But, when I reboot the mangho, I lose the eth0 configuration.

Is there a solution for the configuration to be definitive?

Best regards


#2

You mean this: Unable to use USB to Ethernet IOT card ?


#3

Yes,
I am referring to this topic.

but i am looking for a solution that activates eth0 correctly every time i start the mangho, without entering the commands manually.


#4

I continue my tests.

I created a shell script in the directory init.d.

#!/bin/sh
case “$1” in
_ start)_
_ echo 2 > /sys/class/gpio/export_
_ echo out > /sys/class/gpio/gpio2/direction_
_ echo 1 > /sys/class/gpio/gpio2/value_
_ sleep 5_
_ ifup eth0_
_ ;;_

_ stop)_

_ ;;_

_ *)_
_ echo ‘Usage: /etc/init.d/rj45 {start|stop}’_
_ exit 1_
_ ;;_
esac
exit 0

if I run it manually, it works.
but I can not get it started automatically.
I tested with a symbolic link in rcS.d, Without effect.

Can you help me?


#5

Hi Laurent,
To start the IoT board automatically, you have to edit startlegato.sh script in /etc/init.d/ to add the following commands (the ones you’ve sent manually)

echo 2 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio2/direction
echo 1 > /sys/class/gpio/gpio2/value
sleep 5
ifup eth0

like that:

#!/bin/sh

Copyright © Sierra Wireless, Inc.

Provides a hook for legato into the init scripts

LEGATO_START=/mnt/legato/start
case “$1” in
start)
echo “Legato start sequence”
$LEGATO_START
echo 2 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio2/direction
echo 1 > /sys/class/gpio/gpio2/value
sleep 5
ifup eth0
;;
stop)

Do something to stop Legato

echo “Legato shutdown sequence”
$LEGATO_START stop
;;

*)

exit 1
;;

esac

echo “Finished Legato $1 Sequence”


#6

The forum has interpreted “#” character before “Copyright…”, “Provides a hook…”, “Do something …” and “echo Finished…” as a formatting character (bold).
Make sure there is # at the beginning of those lines in startlegato.sh to comment the line.

dpm


#7

Hi Laurent, you could also use yocto directly to install your script in init.d folder and make it starts with update-rc.d (as you did in ). I followed this tutorial which was taken from another topic here, this works. You can inspire from other recipe for startup script in Yocto. You would change the image directory regarding to your module (mdm9x28 or mdm9x15).

Create new layer.pdf (22.0 KB)


#8

HI Alex.

I already tested with a script in init.d folder. (rj45.sh)

I created a symbolic link in rc2.d (or rcS.d) folder with a high priority to be executed last. ( S99rj45.sh -> …/init.d/rj45.sh)

but whether in rc2.d or rcS.d, it does not work.

I think rj45.sh is not executed.

If I look at the startup log, there is no reference to eth0 (dmesg)

if I run the file rj45.sh by hand, after booting, I can see in the log dmesg:

*[ 180.338980] gpio_sync_ri: RI owner is Modem

[ 180.339004] gpio_map_name_to_num: find GPIO 38

[ 180.339015] export_store: Export GPIO: 38

[ 180.339039] gpio_sync_ri: RI owner is Modem

[ 180.339052] gpiod_export: sierra–find GPIO,chipdev = -826439152,chipngpio = 80,chipbase = 0

[ 180.730153] usb 1-1.2: new high-speed USB device number 4 using msm_hsic_host

[ 180.841890] usb 1-1.2: New USB device found, idVendor=0424, idProduct=9e00

[ 180.841912] usb 1-1.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0

[ 180.845269] smsc95xx v1.0.4

[ 180.932197] smsc95xx 1-1.2:1.0 eth0: register ‘smsc95xx’ at usb-7c00000.hsic_host-1.2, smsc95xx USB 2.0 Ethernet, cce26e48

[ 181.060946] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready

[ 181.065925] USB QCMAP NL IOCTL Snd GETNEIGH Succ

[ 182.857226] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

[ 182.859925] smsc95xx 1-1.2:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xC5E1

[ 182.885432] QTI:LINK_UP Processed

[ 182.887442] QTI:ETH mode

[ 182.896809] QTI:LINK_UP message posted

[ 207.140572] nf_conntrack: automatic helper assignment is deprecated and it will be removed soon. Use the iptables CT target to attach helpers instead.*

So, If I use the startlegato.sh file I can see in dmesg log:

  • From [16.8…] to [23.7…] the configuration of eth0 ==>
    At that moment, I see the RJ45 led ON
  • From [26.63] you can see “Kernel is trying to unregister eth0” ??? ==> I think at that moment, the LED are OFF

At the end of the boot, eth0 don’t exist (ifconfig).

If I use the cmd “echo 2 > /sys/class/gpio/export” I have the error : sh: write error: Device or resource busy

If I use the cmd “ifup eth0” I have the error : ifup: interface eth0 already configured

best regards

Laurent

rj45.sh (838 Bytes)

cfg_in_startlegato.txt (69.9 KB)


#9

Yes we can’t use update-rc.d directly on the mangOH because as it is read-only filesystem it won’t deal with new feature. So I downloaded the tarball from Sierra Source (3GB) and created image for yocto. The tutorial posted before let you install files in the image. When you got your layer, you can add something like this in your .bb file.

SUMMARY = “Start RJ45”
SECTION = “examples”
LICENSE = “MIT”
LIC_FILES_CHKSUM = “file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302”

SRC_URI = “file://rj45.sh”

S = “${WORKDIR}”

inherit update-rc.d

INITSCRIPT_NAME = “rj45.sh”
INITSCRIPT_PARAMS= “start 99 S .”

do_install() {
#install -d {D}{bindir}
install -m 0755 {WORKDIR}/rj45.sh -D {D}${sysconfdir}/init.d/rj45.sh
}

rj45.sh file should be put in the folder ‘example’ which you rename ‘files’. Then add your layer in meta-swi-extra/build.sh (around line 280) and add INSTALL_IMAGE+=“rj45” in mdm9x28-image-minimal.inc.

You have your file directly started at boot now. :slight_smile:

With what you’ve done, I will compare with mine to determine what really happens.


#10

Hi All,

I found a solution without use yocto. I need to use the basic installation process of the Mangho (cf Getting Started).
So I stubbornly insisted on the use of init.d folder. We are still on linux :slight_smile:

I can start the IoT Ethernet Board automatically, by not using startlegato.sh script but by using data-init script.
startlegato.sh is executed too early in the boot process.Something to run later must disable eth0

So with instruction in data-init file, it is OK.

I find it strange that I can edit and modify an existing file and it works.
While if I add my own file in init.d, it has no action.

Laurent