1 2 Previous Next 19 Replies Latest reply on Jan 3, 2017 3:47 PM by Intel Corporation

    Running a C program on an Edison Breakout board on power up.

    monahanz

      I have been unsuccessful in getting help in another section (Re: Uploading a final C program on an Edison Breakout board to run without Eclipse etc. ) of finding a solution to a simple issue.  I want to have a program written in C (with the Eclipse IDE) run on an Edison breakout board run each time on power up without any user interaction.

      I'm a Linux newbie and I'm looking for a simple step by step example of how one would do this. This has got to be a common situation yet I see no detailed documentation.

      Please see the above forum tread first for more info. Just pointing me to endless treads of previous treads going deeper and deeper is of no help.

      Thanks in advance

      John

        • 1. Re: Running a C program on an Edison Breakout board on power up.
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hi John,

           

          Thanks for your interest in the Intel Edison Platform.

           

          In the thread Re: Uploading a final C program on an Edison Breakout board to run without Eclipse etc. they gave you the correct solution. In here you can find the original document: How to create a system service with systemd on Edison and Galileo’s eglibc image

           

          I would recommend to do the system service for the blink example, then try to do your own system service.

           

          I hope you find this information useful, have a nice day!

           

          Best Regards,
          -Jose.

          • 2. Re: Running a C program on an Edison Breakout board on power up.
            monahanz

            Thanks for the fast reply Jose.

            First I don't have a Arduino board to do the LED Blinker example. I have 6 Edison breakout boards.  I guess I will have to rig up a single LED/bit to emulate the example.

             

            I know about systemd/systemctl and how to active a .service.  If you read through the tread mentioned above you will see that my test program was 'activated'.  However the program itself was written to simply put a line of text on the console.  No such line appears.

            That's the problem.  -- No solution so far!!!!

             

            Would like help in getting a c program to put a line of text on the screen on power-up using a breakout board connected via a serial (or WiFi) link. Does not seem like I'm asking a lot.

             

            John

            • 3. Re: Running a C program on an Edison Breakout board on power up.
              joe-iot

              Hey John - If I follow you, you don't see the output of your program on the console (connecting to it via serial?) Do you know if it is getting executed (can you have it write the time to a file in /tmp to show it ran?)

               

              But how I would do what you want is to call the wall command in your systemd unit file. The wall command will echo something to all outputs.

              i.e.

              root@edison1:# wall "Hello World"

                                                                                            

              Broadcast message from root@edison1 (pts/0) (Thu Dec 22 20:55:11 2016):       

                                                                                            

              Hello World

               

              root@edison1: #

               

              Now an example of something I have running on boot is to get the IP address and print it on a SparkFun OLED shield on boot using python . You can check that out here: GitHub - joemcmanus/sparkfunOledBlock: Sample Programs for using the Sparkfun OLED Block

               

              Hope that helps.

               

              Cheers,

              -Joe

              • 4. Re: Running a C program on an Edison Breakout board on power up.
                monahanz

                Hi Joe, I'm afraid I don't quite understand your suggestion.

                My C code (test.c) is:-

                main()

                {

                printf("Edison Board Initilized\n");

                }

                 

                My test.systemd file (test.system) is:-

                 

                #!/bin/sh

                [Unit]

                Description=My Edison Activation

                [Service]

                ExecStart=/usr/bin/node     /home/root/test.exe

                [Install]

                WantedBy=basic.target

                [Install] 

                WantedBy=basic.target

                Where and what do I place in these two files to see output as you suggest on power-up?

                Thanks in advance

                John

                 

                 

                • 5. Re: Running a C program on an Edison Breakout board on power up.
                  joe-iot

                  Hey John - A couple of things stand out. I think this is really all just some simple problems with Linux, which is what the Edison runs.

                   

                  - Did you compile you C program on the Edison? I ask because you do not need the .exe extension in linux. Executables need to have the executable mode set (i.e. chmod +x fileName or chmod 755 fileName ).

                   

                  - You do not need the "shebang" or shell line in your unit file (drop the #!/bin/sh) from your file.

                  -- Did you enable the service i.e. systemctl enable test.system ?

                  -- When you launch it manually what does it say (i.e. systemctl start test )

                   

                  - Node does not run C programs, node is a javascript framework (Ok, it can call an executable, but avoid it).

                   

                  -  When you say "line of text on the console", are you connected to the edison using via ssh? I ask because if you are connected on the command line via ssh there is no need to run node, node is really just a web front end. People use it for more, but no need to interact with C if you are trying to put it on the command line/console.

                   

                  -- If you run your test.exe does it print ? To do this run ./text.exe if the file is in your current directory.

                   

                  It's a shame there is no good getting started with the Edison book.

                   

                  Cheers,

                  -Joe

                  • 6. Re: Running a C program on an Edison Breakout board on power up.
                    monahanz

                    Actually Joe I compiled the program test.c with GCC on the Edison.  I know you don’t have to have the .exe extension. I just use it to remind me what it is.  The program runs fine from the command line when I boot and then log in to the user account root and type:-    ./test.exe

                    Yes I do activate test.system with:-   systemctl enable test.system

                    It works fine with no errors feedback.

                    Upon power up as the services are being activated I do see:-

                    “My Edison Activation”  on the list.  This indicates that test.system was called.

                    What I don’t see is any text from the test.c (test.exe) program appearing;

                    On the console there should appear “Edison Board Initilized” before the logon prompt.

                    Currently I'm just connected to the Edison via a serial port --- to keep things simple.

                    On your system (whatever it is)   can you get a program to run before/without the logon prompt.

                    Agree the  absence of a decent "how to" book for the Edison/Eclipse setup is a real problem.  The one out there "Programming the Intel Edison" by Donald Norris is useless.

                    John

                    • 7. Re: Running a C program on an Edison Breakout board on power up.
                      Intel Corporation
                      This message was posted on behalf of Intel Corporation


                      Hi monahanz,

                      Your code is working! The reason you are not seeing any console output, is because in order to write any sort of text when the Edison reboots, you have to modify the kernel of your image.

                      I would recommend to create a routine that creates a text file and writes in it a "Hello World" instead of just doing a simple console output.

                      I hope you find this information useful, have a nice day!

                      Best Regards,
                      -Jose.

                      • 9. Re: Running a C program on an Edison Breakout board on power up.
                        Intel Corporation
                        This message was posted on behalf of Intel Corporation

                        Hi monahanz,

                        I'm glad to hear that figure it out by your own! If you have any more questions, please don't hesitate to contact us.

                        We hope you have a nice day!

                        Best Regards,
                        -Jose.

                        • 10. Re: Running a C program on an Edison Breakout board on power up.
                          monahanz

                          Thanks for your help Jose.

                          Actually I have one question on this.  When I run the service (S100_Edison.service)  viewing all the service messages on boot I see that my service is loaded.  However it does not run (the few) remaining services.  I currently have in the service file:-

                          [Unit]
                          Description=S100_Edison Program Activated <------
                          After=pulseaudio.service
                          [Service]
                          ExecStart=/home/root/S100_Edison
                          [Install]
                          WantedBy=basic.target

                           

                          pulseaudio seem to be near the end of the list. That one loads fine. I get after that:-

                          S100_Edison Program Activated

                          The root logon does not appear.  It's not a big problem because my program runs  OK but I'm worried something may be wrong.

                          Any suggestions what to do next?

                          John

                           

                           

                           

                          • 11. Re: Running a C program on an Edison Breakout board on power up.
                            Intel Corporation
                            This message was posted on behalf of Intel Corporation

                            Hi monahanz,

                            I'm not understanding your issue, could you maybe try to attach some screenshots?

                            Also when you mean the "root login does not appear", do you mean that you can't access your Linux console?

                            I will be waiting for your reply, have a nice day!

                            Best Regards,
                            -Jose.

                            • 12. Re: Running a C program on an Edison Breakout board on power up.
                              monahanz

                              Here is the power-on messages Jose as the Edison boots up. See the picture.

                              You can see it never gets to the /root logon & password prompt.

                              Yet the service runs fine.

                              Capture.JPG

                              • 13. Re: Running a C program on an Edison Breakout board on power up.
                                Intel Corporation
                                This message was posted on behalf of Intel Corporation


                                Hi monahanz,

                                Do you still have access to your Linux console?? If you do then everything should be working fine, if not try flashing again your image.

                                I will be waiting for your reply, have a nice day!

                                Best Regards,
                                -Jose.

                                • 14. Re: Running a C program on an Edison Breakout board on power up.
                                  monahanz

                                  Jose, when the service is running there is no response from the Linux console.   I cannot log on to /root because it never gets that far.  My application does not use the Linus console -- just the pins on the breakout board. I flashed a completely new Edison breakout board today -- same result.

                                  1 2 Previous Next