Community
cancel
Showing results for 
Search instead for 
Did you mean: 
AAxel1
Novice
1,174 Views

Arduino analogRead(), strange behavior after reboot

Hallo.

I just got the solution to my last problem with the Galileo gen1, and this leads me right into the next one.

I just got the SD card working that saves the Arduino sketch and loads it again after a power off and it works now. After a reboot the last uploaded sketch is loaded again (after a little time).

But from here it gets strange. If i upload a sketch that uses the "analogRead()" command, it works correctly at first. By turning the potentiometer i get a value between 0 and 1023 (given out on the serial Monitor).

Then i unplug the power-supply and plug it in again.

Every sketch that does not include the "analogRead()" command would get loaded again and works as it is supposed to.

The sketches with the "analogRead()" command get loaded too, but when they should give values between 0 and 1023, they just give back 0 regardless of the voltage on the pin i am reading.

This happens to my sketches and to the examplesketches in the Arduino IDE.

26 Replies
idata
Community Manager
116 Views

Hi

 

 

This is an interesting behavior. I ran one of the sample sketches on the Arduino IDE. This example had the analogRead() function, but was unable to see the same behavior as you. Once I uploaded the code to the board I ran the ps command in the Linux console and saw the sketch.elf file. I unplugged the power supply and plugged it again and the sketch.elf process was running. This means that the sketch should still be active. Can you see the sketch.elf process running after a reboot? Are you using the same Arduino IDE and serial monitor window to view the data? What's the result of rebooting the board, closing the IDE and serial monitor and opening them again?

 

 

We'll be waiting for your response.

 

 

-Sergio

 

AAxel1
Novice
116 Views

Hallo.

I am using the Arduino IDE version 1.64. It is the version that can be dowwnloaded from intel.

I have no idear about the processes in Linux. I am in no way familiar with Linux. There fore i would need a step by step instruction.

I Just made the Image like the tutorial told me.

In many other Posts i was told, that the SD Card should have several objects as contend after mounting the image and one of them should be the "sketch.elf."

My SD Card just has two objects, the "boot" folder and the "bzimage".

To make the SD Card i used the "iot-devkit-prof-dev-image-galileo-20160606" and "Win32Diskimager".

Strange is, that every oder sketch not using the "analogRead()" just works perfectly after the reboot.

idata
Community Manager
116 Views

Hi A-Ba,

 

 

Don't worry, we'll guide you through the process of entering to the Linux console. First, you need the appropriate connector. You can see more information on the cables required here http://www.intel.com/content/www/us/en/support/boards-and-kits/intel-galileo-boards/000006142.html http://www.intel.com/content/www/us/en/support/boards-and-kits/intel-galileo-boards/000006142.html . For the Gen 1, install the drivers that should have been provided with your serial to USB converter from the manufacturer. You can see more information here https://software.intel.com/en-us/articles/getting-started-with-the-intel-galileo-board-on-windows https://software.intel.com/en-us/articles/getting-started-with-the-intel-galileo-board-on-windows .

 

 

Now, inside the Linux console, we can monitor the process of the sketch.elf. Before uploading the Arduino sketch, type ps in the console, look at all the process list and notice there shouldn't be any sketch.elf file.

 

 

Next, upload the Arduino sketch to your board. Once the transfer is complete run the ps command again in the console. Now you should see a process called sketch.elf.

 

If the sketch persistent feature is enabled, then after restarting the board you should still see this process running. Please let us know if with the analogRead() example you're trying out if this behavior happens.

 

 

Now, for the contents of the SD card. It's important to know that there are two kinds of images available, the uclibc and the eglibc.

 

The uclibc image has the following contents on the SD card: boot, bzImage, core-image-minimal-initramfs-clanton.cpio.gz, grub.efi, image-full-galileo-clanton.ext3

 

The eglibc image has the following contents on the SD card: boot, firmware, win-driver and bzimage. This can be confirmed here https://software.intel.com/en-us/get-started-galileo-windows-step1 https://software.intel.com/en-us/get-started-galileo-windows-step1 .Did you followed this guide?

 

 

-Sergio

 

AAxel1
Novice
116 Views

Hmm.

I have tryed ti establish a connection to the Galileo using "PuTTY" and my frustration reached new levels.

Folowing your tutorial i used the direct LAN method, because i have no UART connector.

I found several tutorials how to start the ethernet using this arduino sketch.

"

void setup()

{

system("telnetd -l /bin/sh");

system("ifconfig eth0 169.254.1.1 netmask 255.255.0.0 up");

}

void loop(){}

"

After uploading the sketch, rebooting the Galileo and conecting it to the Laptop via Lan, I started PuTTY with the following settings.

The following connection lastet for 30 seconds before an Network error occured.

Before that i typed "ps" into the console with no response.

I had a look at the link you send me regarding the image. I downloaded my image from this page, so i think i have the "eglibc image". The content on the sd looks like this.

What have i done wrong?

wcaro
New Contributor I
116 Views

good night.

I have the answer to your fault, the problem is that Intel provides new updates on Linux but does not expose lso changes required under the new platform.

I discovered connecting me and checking for linux terminal.

so you must write your code:

system ( "ifconfig enp0s20f6 down");

system ( "ifconfig enp0s20f6 192.168.0.5 netmask 255.255.255.0 up");

system ( "telnetd -l / bin / sh"); // Start the telnet server on Galileo

Try it and you'll notice that it works.

Greetings and excuse my English

idata
Community Manager
116 Views

Hi A-Ba,

Please let us know what's the result of following @wilson's suggestion. Basically, you must turn the interface off, assign an ip, enable the interface and then connect through telnet. You should do this using the system commands in the Arduino IDE.

Let us know if you're successful in using the Linux console.

-Sergio

AAxel1
Novice
116 Views

I tryed your code to stard the LAN adapter today.

I did the exact same steps like before, but with the new Code in the Arduino IDE. I just disabled the old lines and used the new ip.

"

void setup()

{

//system("telnetd -l /bin/sh");

//system("ifconfig eth0 169.254.1.1 netmask 255.255.0.0 up");

system ( "ifconfig enp0s20f6 down");

system ( "ifconfig enp0s20f6 192.168.0.5 netmask 255.255.255.0 up");

system ( "telnetd -l / bin / sh"); // Start the telnet server on Galileo

}

void loop(){}

"

I am sorry, but the result is still the same.

It feels just like something is really off with this thing.

wcaro
New Contributor I
116 Views

I forgot to indicate the following:

DO NOT connect a cable network direct Galileo to the computer. You must pass it by a switch. in this way if it works

AAxel1
Novice
116 Views

Hallo.

I managed to get the conection to the Galileo with your (Wilson caro) code yesterday.

It was a stupid little mistake in the IP. But your code works fine with the direct conection if a cross over is used.

I managed to find the find the file i had to find (sketch.elf) with the commands provided here.

Unfortunately like the analogRead command, the commandlines for the Lan Start also stop working after the reboot.

So i started to narrow in what of the basic arduino functions exactly works ant what does not work after the reboot.

Serial communication works

Mathematics (+, -, *, /) works

digitalRead() works

analogRead() does not work

digitalWrite() works

analogWrite() works

From time to time it takes several uploads to get a sketch to get loaded again after restart. Once i had the strange situation, that a sketch i tryed some hours before reapeared after uploading an other sketch and rebooting the Galileo.

idata
Community Manager
116 Views

From your previous reply it seems you were able to access the Linux console and see the sketch.elf file using ps.

 

 

I've a few steps to help us get a clearer picture of your issue
  1. Kill the Arduino sketch process and make sure there's no sketch.elf file.
  2. Upload one of the working sketches, such as the blink to see if the sketch.elf file was created.
  3. If the file was created, reboot the board and check ps again.
  4. Add a picture of step 1,2 and 3 to help us follow your progress.
  5. Confirm you can do this with all sketches except with the analogRead().
Also, please attach the exact same sketch you're using to test this behavior ourselves. What Arduino IDE version you're using?

 

 

We'll be waiting for your response.

 

 

-Sergio

 

AAxel1
Novice
116 Views

I am sorry, but the problem i am having prevents me from doing as you told me.

I could kill the sketch process (dont know the right commants yet) and upload a new sketch to the galileo.

But there will be no lan connection after the reboot. Like i told in the last posts. Just like the analogRead somehow the Lan that works after freshly uploading the sketch , stops working with the reboot.

My version of the arduino IDE is 1.64.

idata
Community Manager
116 Views

I'm confused. You said in your previous message that you managed to get a connection to the Galileo and find the sketch.elf file. Before attempting to fix the analogRead() issue, confirm you're able to login to the terminal using Putty. Now, from your previous replies you said you were attempting to connect to Putty using the "Use the LAN connection direct to your PC (via SSH)."method described here http://www.intel.com/content/www/us/en/support/boards-and-kits/intel-galileo-boards/000006142.html http://www.intel.com/content/www/us/en/support/boards-and-kits/intel-galileo-boards/000006142.html . Is this correct?

 

 

Once you have Putty access you can move on and follow the steps we posted on our reply from September 30. To kill a sketch you need to use the kill command from the Linux console. To use kill just type kill . The process ID is found with the ps command. You can see more information here https://www.maketecheasier.com/kill-command-in-linux/ https://www.maketecheasier.com/kill-command-in-linux/ .

 

 

Confirm you have Putty access, are following "Use the LAN connection direct to your PC (via SSH)." method and followed our steps from our previous reply.

 

Attach the Arduino sketch you're using so we can test this behavior.

 

 

We'll be waiting for your response.

 

 

-Sergio

 

AAxel1
Novice
116 Views

Ok. The Probleem is the folowing one.

The Lan conection runs good in the moment i upload the sketch with the Lanstart. I can easily log in on the Galileo with Putty and find the sketch.elf. Given the example that i do not erase the sketch.elf, the Galileo should boot up the sketch with the Lanstart after the Reboot. Is that correct so far?

Now here comes the problem. Even if the Lanstartsketch was the last uploaded sketch, i can not reach the Galileo with Putty after the reboot. To get a connection again i need to upload the Lanstart sketch fresh. This way i get a new connection via Putty. And of cause there is a sketch.elf to find after i log in again, i just uploaded it to get the Lan working again.

Is there a way to config the Lan in the Linux itself? Is there a way to get the lan running without using a Arduiinosketch to geet it running?

idata
Community Manager
116 Views

Hi A-Ba,

 

 

Thank you for letting us know you already have Putty access. With the eglibc image you should have your sketch starting after reboot. Now, you say you can't reach Putty after a reboot. This should be working because you're establishing the connection with an Arduino sketch which is supposed to be enabled after reboot, thus making you able to log on to Putty afterwards.

 

 

You can try to do this from the Linux side. You can create a shell script with the LAN configuration. And then create a system service. After creating the service you can have it configured to start after a reboot.

 

 

Let us know if this approach works for you.

 

 

-Sergio

 

AAxel1
Novice
116 Views

Thank you for the advice. I will give it a try in about a week. Any suggestions for a good tutorial on that for total Linuxnoobs?

Right now i have little time because of some upcomming tests in the university.

I might not be able to work with the Galileo for a week or so.

idata
Community Manager
116 Views

It's hard to point to a specific tutorial. I found a community thread that has lots of useful information /message/381193# 381193 https://communities.intel.com/message/381193# 381193 . On Linux, the best approach is to look for specific problems to find tutorials related to your problem. Looking for error messages and other keywords in google is a good way to start to troubleshoot issues with Linux. If you have other issues you can open a new thread and we'd gladly take a look at it to help you.

 

 

-Sergio

 

idata
Community Manager
116 Views

Hi A-Ba,

 

 

Do you still need assistance with this case?

 

 

-Sergio

 

AAxel1
Novice
116 Views

Sorry.

I am still searching for a tutorial that suits my level of understanding of Linux, which is practically nonexistent.

A friend of mine has agreed to help me with this shellscript on friday. I also tryed to establish an UART connection using an Arduino UNO as USB to Serial Adapter, but i didn`t manage to establish a connection via Putty.

Until than i want to try some different things. I get why I need to establish a link to the Galileo after reboot to look for the sketch.elf file after the reboot.

But I think that this file will be there, because the Galileo is able to load any sketch again that does not use the analogRead(). The blinkexample for example works fine after a reboot and so do many other examples EXCEPT the analogRead().

When the LINUX Image is working correctly, there can still be a fault in the firmware or in the hardware itself.

So i am trying some other things as well.

My boss also has a Galileo which he wants to bring along in the next weeks. He is as much a noob as me with it, but it is verry unlikely, that two different devices show the same fault.

I also want to upgreade the firmware again to rule it out as the source of the problem.

At last there is still the Linuximage itself. With this i am needing some professional help, because here ends my level of expertise.

Thank you again for all your help with my strange problem.

This

AAxel1
Novice
116 Views

Ok.

Here some partial success pared with some strange new observations.

I ran the firmwareupdater again and updated the firmware from v1.04 to v1.04.

Now after the reboot i get some correct analogreadings from Analog-In 0 to 3. Analog-In 4 and 5 still behave as before (Analog-In stops reading after reboot and gives back just the value "0").

So what did i learn from that?

The Linux Image is working perfectly and does everything as it is supposed to. The hardware seems fine too, but there seems to be something off with the firmware. I tried to find the version 1.03 to downgrade the firmware for further testing, but this version seems to be banned from all of intels downloadservers i found.

Does one of you guys have an updater to this version lying around somewhere? Or maybe a link to one?

For my current project this degree of functionality of the Galileo is enough for now, but for future projects i`d like to get the problem solved once and for all.

I am open to suggestions regarding this problem.

idata
Community Manager
58 Views

Take a look at https://downloadcenter.intel.com/download/24272/Intel-Galileo-Board-Software-Package https://downloadcenter.intel.com/download/24272/Intel-Galileo-Board-Software-Package . Here you'll find the software packages for 1.0.3. Let us know if you're able to get the analogread() to work after downgrading to 1.0.3.

 

 

We'll be waiting for your results.

 

 

-Sergio

 

Reply