Higher level overview of developing with Linux

Sorry if this question is very simple for you guys but I was wondering if someone can give me a “50,000ft level” overview of programming with embedded linux. I have done quite a bit of programming with the Cortex M series using FreeRTOS and Segger emBOS but I am not understanding how to tie all this together with Debian GNU/Linux 9.

I am also not looking for details, I just need to understand the overall process. If I just want to create a simple blinky example…how would I implement this with Linux?

Normally with FreeRTOS I would create a thread that handles output to a LED for instance…rebuild the new thread code with the RTOS and download the new image to the device. But with this device, we have a Embedded Linux being booted from the SD card.

Will I need to create the a new thread that runs in parallel, rebuild all of Embedded Linux and then copy the new image to the SD card every time I make a change to the thread.

Again, sorry if this question is very simple for the group, but I am just breaking into the Linux world(in terms of creating custom image). I can work my way around Linux pretty good. Thanks

It all depends on what you would like to do.

Programming via linux

  1. You can use the linux headers and write your programs in C based on the functions exposed by the kernel. Plenty of tutorials around for that.

  2. You can also get a compiler for your favorite language and write your programs using that, or you can use python or other scripting language.

Bare metal/ FreeRTOS

  1. The SAMA5D27 can be “bare metal” programmed. There is a small bootloader, but aside from that it just runs your C code. It is possible to load your C programs from the micro sd card. Microchip provides a software package with some examples. Here is a link to the bare metal resources. If you need some pointers are setting up the at91bootstrap to load your baremetal examples, let me know.

  2. In the same example pack provided by Microchip, there is a freeRTOS example. If you would prefer to go that route.

While I’ve only tested to see if things work, I have little experience using these other methods with the Giant Board. I’m sure I’m missing more details here, but covers most of the general ways you can program the Giant Board.

1 Like

I typically just make executables using C, Python, or language of choice. In the case of C, this is where the linux headers and such come into play. That executable, when it runs, is a process that can run single-theaded or can create more threads using a threading library (like pthreads or such).

You can develop and compile it all locally on the target board, or for C, you can cross-compile (on another machine with the linux headers and such) then copy the executable to the SD. You can then run the executable temporarily from the terminal. To make changes quickly without rebooting, I usually get the network and an SSH server involved so I can copy things back and forth quickly with scp commands and the like.

You can use the init system to start and stop your executable on boot (or on other events like timers). In Debian’s case, this init system is the system daemon (systemd). So to run my executable, I typically create a systemd service file to start/stop my executable and then install that (to /etc/system/systemd for user apps). You can specify when to start your app with the systemd service file (like on boot after networking is started or the like).

You could install all of this to an image just by copying the executable and systemd files to the rootfs while building the image, but the more debianesque way is to package these files into a .deb and then install that. In that case, it would be tracked along with all the other system packages using dpkg and apt. Easiest way to do that is to make the .deb, copy it to the rootfs while building the image, and then install it with dpkg during the chroot. More advanced way is to make a debian repository server, add your repository to the /etc/apt/sources.list, and just install with apt.

That’s a general overview of my process. Hope it helps.

1 Like

Groguard and Alt-Tek,

Wow thank you so much both for the abundance of information. It is quite a bit and will take some time to digest here.

I am sure I will eventually stumble my way through it slowly. I am so used to the simpler boot scenarios with some of the ST and NXP devices. It seems like the whole process becomes an order more complicated when you add U-boot into the mix and embedded Linux.

Its really cool though what you have done with this board, providing the schematics and all. I would like to eventually get the SWD interface working for debug. I have a couple Ijets(IAR) and Jlinks laying around here. I’m just afraid if I try to solder right next to the MCU I will screw something up.

Im also working on my masters right now in Data Analytics. Trying to think of some machine learning application with this boards. Would be really cool to get some NN up and running.

Colin

Looks like if you want to use sam-ba, you are forced to use the command line. It doesn’y look like the GUI based version supports the ATSAMA5D2xx series. However Sam-ba ver 3.3.1 command line does appear to have this device as a command line option. I will have to test it later. Thanks again for the help

You may have already figured this out, but another thing to keep in mind when writing Linux apps is typically you can debug with gdb (pdb with python) or some other userspace debugger over a network interface if you are looking to step through code and such. Using the stdio and good ol’ print statements is also more useful with a full terminal and filesystem and all. I keep my JLink in the drawer for other more bare-metal stuff. I imagine using it in a Linux environment would be more setup than what you get out of it, but I really wouldn’t know, I’ve never bothered to try.

Like alt-tek says, the simplest method of developing programs for an embedded Linux system is to use Linux based tools. This depends on your preferred language.

If you use C/C++ then i would recommend using Eclipse IDE and cross develop using ethernet/wifi connection to the embedded device and debug on the live system using gdb.

If you want a graphical front end then the easiest is to use javascript by running nodejs on the embedded device and using chrome web browser as the interface. This allows for very easy debugging and also makes charts and diagrams very easing using google apps. A good IDE for development is Atom or Eclipse. If you want to go one step further and develop your javascript code in a graphical drag-and-drop method, then you can also use Node-red to develop your javascript code. Note that with nodejs you can write a whole web server in about 6 lines of code. try doing that bare-metal.

If you develop in Java then again i would use Eclipse IDE and gdb on the embedded device.
I dont use Python but there are great tools for that language.

Take advantage of the very powerful Linux based development tools for this board as you will find that development and debugging is much faster and easier than going bare-metal.

Interesting discussion! Programming in C for Linux is new to me. I have managed to program sketches into NodeMCUs and integrate MQTT and NodeRed on Mac & Windows.

I have my GiantBoard running MQTT and NodeRed. Exploring the various gpio packages on NodeRed. Will it be possible to proceed with those, or do I need to get ready to learn something really new?

Please guide me in the right direction. I, like the OP, am not looking for details, but whether Node Red could control the board.

not really familiar with node-red but without a doubt there are gpio packages, i2c packages, spi packages, analog package, etc, available.

If no packages are available (and i doubt it), Node-red has the ability to execute command line commands, then you can access the board through sysfs or other standard interfaces.