I have a question I don't readily see answered here or in general on the web, which I think a general step by step account would be useful to many users…
I have a C program which I developed in the Eclipse IDE environment. It runs fine on my Edison breakout boards when uploaded via WiFi. My question is how I get a final runtine program to run without uploading it with the IDE.
A few specifics.
The program is the only thing the Edison breakout boards will ever do. Essentially I and looking at the GPIO pins and responding accordingly. (the UART, PWM etc. are wasted, a whole other issue). I want the units to power up and run only that C program. Not even WiFi is required. The program is called S100.c in Eclipse.
How does one do this? Can just add a line S100.exe to the end of my .profile text file in root\home and boot? Where should S100.exe be located?
I see all kinds of write-ups/discussions on the web about placing files (of differing names and complexity) in directories like /etc./init.d Most of the discussions see to be concerned with WiFi. As I said I don't need it. Does that simplify things?
Also in my current Eclipse S100.c program I have printf("text etc.") statements proving diagnostic feedback to the Eclipse console. I will remove them in the final runtime version, but I'm curious if I left them there would they hang the program.
Thanks, I saw that tread some time back. It's so convoluted it's really unclear what I (minimally) need to do. My application is very simple. I do not need Bluetooth or WiFi. about which that tread seems to be concerned about. Mine is a "Hello World" type application. I read somewhere (but cannot find it now), that I just need to put my program "S100.exe" at the end of my .profile file as a single line followed by a \n.
Questions (not answered):-
1. Is that the case
2. If not, is it asking too much for a few lines/example of how to do it.
3. Where should my S100.exe file reside.
4. Can I leave the Eclipse Console printf() functions in the runtime code. Will the hang the program or just be ignored.
Please help, this has got to be a common problem for newbies for which the is a well known solution.
This is a general Linux question, really. You can just Google "Linux run program at boot" and get lots of directions for how to do this. The key to knowing which to follow is knowing that you want to use systemd to do it.
Here is a guide that should work for what you've described:
http://unix.stackexchange.com/questions/47695/how-to-write-startup-script-for-systemd How to write startup script for systemd - Unix & Linux Stack Exchange
Thank you for contacting us. Let us try to help you.
More specifically, what you want is to avoid using any external IDE (Eclipse, Arduino, etc.) and instead take your code directly to the Edison, compile it and run it all in there, am I right? Please correct me if I'm wrong.
In that case, what you'll need to do is the following:
- Create a file in your Edison using vi or nano text editors with the extension .c, e.g. mycode.c, and then paste your code in that file.
- After that, you'll want to compile it. Use GCC to do this, a really basic way to compile it would be with the following command gcc mycode.c –o mycode. This will take your code, compile it (gcc mycode.c) and generate an executable output called mycode (-o mycode). If you're using any specific library you'll need to add it to the compilation command as a parameter. For example, if you're using MRAA in your code your complete command will be like this gcc mycode.c –o mycode –lmraa.
- To run the newly created script just use ./mycode
Thanks for the fast reply Pablo. That helps but does not quite answer my need.
In your last line you say "To run the newly created script just use ./mycode". I assume you mean type that text in from the command line.
I want the code to run upon power up each time. I do not want to interact with the Edison in ANY way.
Do you mean put the text "./mycode" in the .profile file in/home/root as the last line in that text file and just power up.
Again where should the compiled file reside?
I also disappointed/surprised that I cannot do something like that directly with the Eclipse compiled file. It seems odd that after all the work setting up the Eclipse IDE one cannot simply execute a compiled file directly upon power up instead of going over to GCC. Anybody/everybody is this the case?
Nniles: thank you very much for your help on this case.
Monahanz: regarding your question about how to avoid having to go into the Edison's console to run the new program every time, you can write a service that runs the program automatically.
- Check the instructions below:
System services on Edison are handled by systemd, this tool is an init system that some Linux distributions use to manage all processes subsequently. I will not go deeper than that in this document but if you would like to learn more about systemd I highly recommend you to read the following documents:
For this example the code will be called blink.js and the service will be called blink.service. Nevertheless, these files can be called however you like as long as the service ends with the .service extension.
The blink example will be stored in /home/root/ and it will look like the following:
- var mraa = require('mraa');
- var BLED = new mraa.Gpio(13);
- var LEDSt = true;
- function blink()
- LEDSt = !LEDSt;
- # !/bin/sh
- Description=Edison Arduino board LED Blinker
- ExecStart=/usr/bin/node /home/root/blink.js
Now give executable rights to blink.js with the command chmod +x blink.js.
To enable the service type the command systemctl enable blink.service. After rebooting the board the next time, the script should start automatically.
- Now, to answer your question about Eclipse, the approach is not very different from the one I just explained, the only difference is that you need to know where the Eclipse executable is being created. I just did some tests with Eclipse (Intel System Studio) and you can see in Eclipse's console where the program is being run. My program was called blinkEdison, and it was located on /temp. Have you checked that directory? Is your Eclipse program there?
Thanks Pablo, I'm getting there! Unfortunately I will not be able to get to trying this for a day or two.
What you have is most helpful thanks.
I do remember seeing cases where people had test power up programs as the last line in their .profile file in /home/root/
In fact I'm almost sure I compiled "HelloWorld.exe" and ran it on my own initial system in .profile and had it run on power up.
Your blink.js is a script driven file. I wondering if it's because you are not running a straight compiled .exe file you have to run is as a service.
Can you/anybody confirm that you cannot run a GCC C program in .profile.
In your above code:-
- # !/bin/sh
- Description=Edison Arduino board LED Blinker
- ExecStart=/usr/bin/node /home/root/blink.js
What text do I enter for [Unit], [Service] and [Installed]
Thanks in advance
.profile is only run when a user logs in, so that method will not cause the program/script to be run unattended at boot (which is what it sounds like you want).
systemd will allow you to start a program at boot without having to log in.
All you need to change in the blink.service file is what comes after ExecStart= so that it points at your program/script (full path) rather than calling node blink.js. You might also want to name the file something other than blink.service...
So if your program is called myexe and is located in /temp, change that line to:
I am still having a problem getting the Edison (with breakout board only) to run a program on power up without user signon. Some suggestions were presented by Pablo and others a few days back. Only now can I check them out as I did not have access to the hardware for a few days.
I have spent 8 hours on this and now have gotten very frustrated. It's an application for the Edison that I can only assume others will later run into the same problem for IoT applications.
First let me say I'm amazed/disappointed that the Intel engineers have not built into Eclipse for the Edison such a capability. Is this "on the list"?
From previous treads It appears one must take an Eclipse debugged application, splice it into a text file on the Edison and run the old command line GCC compiler to generate a .exe file that can then be used as I outline below. Seems we are going backwards….
Anyway here is what I have so far based on recommendations.
I use the following simple C program called S100.c
printf("Edison S100 Board Initilized\n");
I place it in /home/root and compile it with GCC
GCC ./S100.c –o ./S100
From the command line I can then run S100.EXE with
I get the output:- Edison S100 Board Initilized working fine
So far so good. All this is done from the directory /home/root
As recommended by Pablo I then go to the directory: /lib/systemd/system
I enter a text file named S100.service which contains:-
Description=My Edison S100 Activation
From within the directory /home/root I type:- systemctl enable S100.service. No errors were reported.
I then power down are reboot the Edison. Using the serial connection (not WiFi). The unit seems to power up fine with lines upon lines of "OK" info.
Amongst the text is:-
Starting My Edison S100 Activation...
[ OK ] Started My Edison S100 Activation.
This seems to indicate that the service was activated.
However there is no text following which says:-
Edison S100 Board Initilized working fine
So it looks as if S100.exe is not actually being executed
I'm at a complete loss to know what the problem is or what to do next.
Perhaps this will help. I moved the S100.service to be the very last thing being called just in case a service was required to print on the screen the text from S100.exe:- Edison S100 Board Initilized working fine.
In my setup PulseAudio Sound System seems to be the last service called. So I entered the following S100.service file
Description=My Edison S100 Activation
Still this did not help.
Also, I can't guarantee that you will see text output to stdout from a program run as a service during boot. It might work, but if you don't see the output after you make the change above, you might have more luck writing to a file.
Well deleting "/usr/bin/node" from the ExecStart line did not seem to make a difference nniles.
Any chance you could give me a few lines for the S100.c program that would absolutely guarantee to write a string to a file opened within the service and that I could examine later. Where should this file be located? S100.exe is in /root/home.
S100.exe writes fine to the console when the user signs on. It's essential that it's able to run the from breakout board without a user signon however. Since the Edison is streaming out info on startup I would think it would be able to also send S100.exe generated text.
Thanks in advance
Read the accepted answer in this post: http://unix.stackexchange.com/questions/20399/view-stdout-stderr-of-systemd-service logs - View stdout/stderr of systemd service - Unix & Linux Stack Exchange
You should be able to look through the log files with journalctl or add a StandardOutput=tty (or ttyS0, or ?) to the service description file, or probably both to see the output.
Unfortunately what is in that link is above my capabilities. Please keep in mind I a total Linux newbie. This is a question many first time users to the Edison I suspect will have. Many would be just interested in using the Edison hardware for a specific application and do not want/need to dig deep into the bowels of Linux to understand the complex software it uses.
Anybody, please review:-
1. Can somebody out there supply a detailed example of running say this simple code named test.c (which resides in /home/root):-
# include "mraa.h"
printf(">>>>> Test Program Initilized <<<<<\n");<p> }
using the following service named, test.service (which resides in /lib/systemd/system):-
Description=Test Program Activated <-----------------</span>
And is activated with:- systemctl enable test.service
How many loops more do I have to do to get the Edison to print on power-up on a simple Edison breakout board:-
>>>>> Test Program Initilized <<<<<</span>
I cannot believe this has not been addressed/done for users that are not Linux gurus.
If this Edison thing is going to catch on for wide use there needs to be more help provided that is simple, detailed, and helpful to beginners. Just slapping off links to othere links that point to other links… on and on, getting deeper and deeper is just no help.
I don't know who supervises this forum but somewhere there needs to be a section for simple essential startup issues/applications like this. They should address things like this in detail. Take a look at the Raspberry and the likes, forums – totally different.
Finally the elephant in the room issue with this Edison is that it appears that one cannot use the code developed in the Eclipse to directly run code (at least c code) on an Edison on power-up (every time) once uploaded.
If this is true again those responsible for the unit need to address this rather than spend time on exotic applications that few would use. Telling people to take their code and 'splice' it into a GCC compatible file and compile on the Edison it is ridiculous. The whole point of the Eclipse is to make repeated code building simple and rapid. Who is directing these projects at Edison. Hopefully somebody will pass these comments along.
Any others who feel the same way please also do so. Should I move this up to the more general Edison forum section
Perhaps something will get done.
I'm sorry to hear our suggestions didn't help you with your project. Regarding your comments about the available documentation for beginners, we would definitely pass your feedback to the Development department so they can take the appropriate measures. Again, thank you for your feedback, it helps us to improve.
Just wondering if you have made any progress on this.
I am afraid that I agree with you that this Edison system is profoundly lacking in newbie support. I am trying to do the same thing that you are - get a fairly simple program to execute at start up. You'd think it was brain surgery.
Hearing now that I have to splice and rebuild my projects using GCC instead of deploying from Eclipse - like any sane person would expect from a development environment in the year 2017 - and I think I am going to have to move on to a system that is more accessible to beginners.
Hi Mark, through a lot of trial and error (& time), I did manage to get my system more or less working. I have written up some help information here:-
http://s100computers.com/My%20System%20Pages/Edison%20Board/Edison%20CPU%20Board.htm S100 Computers - Edison CPU Board
You would think this is the type of thing Intel would do, but It was like pulling teeth.
I still have a problem running my program as a service in that the OS never returns back to the login prompt. No indication/feedback or indeed help what one can do.
If anybody at Intel is reading this:-
The Edison will never catch on without strong support for newbies (including Linux newbies). Learn a lesson from Raspberry.
- Address the reams of information spewed out on Linux startup. Don't use the copout it's a Linux problem, Its on your system. List what each does. can it be simplified fort a dedicated setup, where is the list stored etc.
- Allow at least as a option the ability to make ALL pins GPIO pins and nothing else. I.e. a real basic setup with no bells and whistles just the ability to turn on/off a pin. A absolutely minimal system. Part of the problem is Intel has so many layers of complexity on the system Its hopeless to build a system from start. i.e. not all pins are created equal. Typical engineering problem of "gilding the rose". Somebody there should insist less is more.
- Don't get me started about the initial configuration from the web downloads. Suffice to say there is a drastic need for a better/smoother interface (particulary for desktops with already multiple already attached ports). Use Java updates as your model. One click - done.
I could go on and on but I have found nobody there does anything about us small group of beginners. They are focused on large "commercial applications"
Finally Intel don't bother ackknowledgeing you read this and are working on it. Heard that a few times now.