RA1981
Posts: 3
Joined: Tue Aug 13, 2019 8:11 pm

Recommendations for development environment

Tue Aug 13, 2019 10:18 pm

Hi,

I'm just new to the world of Raspberry. Since I'm a Windows user with very little knowledge about Linux etc., I'm struggling with figuring out what the proper environment for my goals is.
First, a few words about myself: I'm a hardware developer located in germany, specialized in microcontroller circuits, where I also write small test software in C for board bring up and smaller end applications. This is also one of my hobbies, so I'd say I've medium experience on developing software for microcontrollers. Recently I got a Pi 3B+, and I find it quite interesting. So, I decided to dig deeper into it.

Since I'm primarily a hardware guy, my "roadmap" is hardware centric and as follows (please excuse if I'm using Linux specific keywords in the wrong context, I'm just at the beginning of a journey):
  1. small command line apps in user code for controlling GPIOs, I2C, SPI, etc.
  2. writing own device drivers, for the interfaces like I2C, SPI, etc. itself as well as for attached devices like EEPROM, GPIO expander, etc. (keyword kernel module?), including attaching the devices to the device tree
  3. writing GUI applications which can use the device drivers
  4. making my own small HAT :)
  5. building a kernel myself (building a device driver into the kernel rather than using modules)
The above order is what I think is a good way to learn.

My first intention was to look for an environment for Windows, but from my investigations so far the main recommendation is to use a Linux environment (for which it looks like there are many more options than for Windows, especially when considering the above roadmap).
It seems that there are two main positions: develop either on a Linux PC or directly on the PI. Since one of the end goals is to also build the kernel itself, I think using a Linux PC is the right way.

So, currently I've two main tasks:
  1. choosing and setting up the right Linux distribution
  2. getting an appropriate development toolchain
For the first point, I'm especially interested in how to get Linux development system secure - since Linux is new for me, I want to know which steps need to be done in configuring the system. The Raspberry equivalent is to change the default password, setup a user with default permissions (not root like user 'pi'), don't use VNC when the PI is connected to the internet, etc. I only know Windows, here I know at least the basic steps to get it secure. I know that Linux is considered to be more safe than Windows in general, but I'm a bit paranoic on that. For example, what about firewall, virus scanner, etc.?

For the second point, I know that there can't be the one and only answer - some people prefer to edit the sourcecode in a simple text editor, create the makefiles themself and doing magic on the bash CLI like hell, others prefer to use an IDE including editor, automatically created makefiles etc. From my experience with microcontrollers, I'd prefer the IDE approach - usually microcontroller vendors provide their own IDEs (some of them based on Eclipse), which aid in configuring the devices and take care of all the linker stuff etc - typically only finetuning is neccessary for memory layout & optimizations etc.
This point also includes the question about neccessary hardware equipment to develop on a PI: is there anything special needed (or additionally recommended) for hardware stuff? For microcontrollers running simple C software (keyword bare-metal?) without OS, usually there's a JTAG/SWD debug probe connected for single stepping, viewing variables, etc. I've seen that there are some PI developments using a JTAG probe. When would this probe be needed?

I'd be glad if someone could help me getting started to start :)

Regards

User avatar
Gavinmc42
Posts: 3727
Joined: Wed Aug 28, 2013 3:31 am

Re: Recommendations for development environment

Wed Aug 14, 2019 7:19 am

Welcome to Pi land.

At work I use a Windows10 with two screens for Altium PCB design and various Micro IDEs.
I'm also a micro guy trying to master Linux with the help of Pi's, lots of Pi's ;)

These are just my list of tools.

If you want to use Pi4's for development then Raspbian Buster on the Pi4 with 4GB and dual screens will probably be a familiar starting point..
I'm told Kicad is ok for PCB's, I have installed it but have yet to learn it and do any pcbs.

Probably the easiest micro tool is Arduino, the IDE just installs and works.
My default "IDE" is Geany it is just fancy editor but it works with most languages.

I have not installed Netbeans or Processing for Java coding, but they should be workable now.
Bit slow on previous Pi's.

Python and Thonny IDE is standard on Pi's.

For Pi's baremetal I use the Ultibo IDE, it is based on Lazarus and Free Pascal.
I have also installed the normal Lazarus/FPC for Pi Linux coding.
I have found Free Pascal a refreshing change from C, less dependencies, mainly because Ultibo/Laz/FPC comes with decent libs.
And much less debugging.

There are debug tools that just work.

OpenOCD can use the GPIO pins for JTAG interfacing to micros.
In theory you could use one Pi to JTAG another ;)
GPIO pins are 3V3 so if your micro is also 3V3 then all you is the few JTAG wires.
You can even get premade wires with connectors on the ends, Adafruit have many sets.
No need for fancy, expensive probe.

Flashrom can program SPI/I2C chips etc.

I have read and written i2c sensors on my own hats/motherboards with many software languages.
Even via shell script, but I prefer Ultibo these days.

There are now some FPGA free tools that work with smaller FPGAs.
I tried them on a Pi3B+ but have yet to install on this Pi4.

And you have the usual huge choice of Compilers, including gcc.
If there is not one for Raspbian Debian, you can compile your own version.

I'm told Eclipse and VScode work, but I find them a bit bloated for my simple stuff.

Oh and this is all free and open source.
With many more options to explore.

What's a firewall and virus scanner?
Just kidding, those are around too, never felt the need.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

hippy
Posts: 5942
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Recommendations for development environment

Wed Aug 14, 2019 4:42 pm

RA1981 wrote:
Tue Aug 13, 2019 10:18 pm
It seems that there are two main positions: develop either on a Linux PC or directly on the PI.
One can cross-develop on Windows but that can be more tricky to set-up than cross-developing on a Linux PC, and will often involve 'faking a Linux environment' which suggests one might as well use Linux to start with.

Windows 10 has Windows Subsystem for Linux (WSL) which means you can have the best of both worlds but it is probably easiest to start by developing on a Pi as that should have all the tools you need pre-installed. Raspbian should be a suitable distro, and the toolchain is already there. That's a lot of 'nothing more to do' which will help you get down to doing it rather than thinking about how to.

I would suggest starting by developing on a Pi and see how it goes, get a feel for what you use and need. That will allow you to determine what doing cross-development would require if you choose to go that way later. If something proves hard to do on a Pi it is likely even harder from off the Pi.

RA1981
Posts: 3
Joined: Tue Aug 13, 2019 8:11 pm

Re: Recommendations for development environment

Wed Aug 14, 2019 7:46 pm

Gavinmc42 wrote:
Wed Aug 14, 2019 7:19 am
Welcome to Pi land.
Thank you :)
Gavinmc42 wrote: At work I use a Windows10 with two screens for Altium PCB design and various Micro IDEs.
I'm also a micro guy trying to master Linux with the help of Pi's, lots of Pi's ;)
Cool, we're also using AD - I'm on three screens :D Which types of micros are you using?
Gavinmc42 wrote: If you want to use Pi4's for development then Raspbian Buster on the Pi4 with 4GB and dual screens will probably be a familiar starting point..
Shouldn't be a problem to also get a Pi4. Do you know if it's possible to compile on the PI4 and then simply copy to the PI3?
Gavinmc42 wrote: I'm told Kicad is ok for PCB's, I have installed it but have yet to learn it and do any pcbs.
Haven't tried anything other than AD, except when I was a trainee. There we used Eagle.
Gavinmc42 wrote: Probably the easiest micro tool is Arduino, the IDE just installs and works.
My default "IDE" is Geany it is just fancy editor but it works with most languages.
Arduino is out of my scope, I learned micros with 8051 and derivates, now I'm on Cortex-M, primarily STM32 and PSoC.
Gavinmc42 wrote: I have not installed Netbeans or Processing for Java coding, but they should be workable now.
Bit slow on previous Pi's.
I don't like Java, my focus is on C. C++ is something I want to learn. And sometimes I think about to spend some time to do assembly on Cortex-M (back to the good old trainee time with 8051 assembler :D )
Gavinmc42 wrote: Python and Thonny IDE is standard on Pi's.
Python is also out of my scope, since it's a interpreter language as far as I know. Without knowing much about it I've the feeling that such languages are always slow.
Gavinmc42 wrote: For Pi's baremetal I use the Ultibo IDE, it is based on Lazarus and Free Pascal.
I have also installed the normal Lazarus/FPC for Pi Linux coding.
I have found Free Pascal a refreshing change from C, less dependencies, mainly because Ultibo/Laz/FPC comes with decent libs.
And much less debugging.
Also out of scope, but sounds interesting.
Gavinmc42 wrote: OpenOCD can use the GPIO pins for JTAG interfacing to micros.
In theory you could use one Pi to JTAG another ;)
GPIO pins are 3V3 so if your micro is also 3V3 then all you is the few JTAG wires.
You can even get premade wires with connectors on the ends, Adafruit have many sets.
No need for fancy, expensive probe.
But in fact it's not absolutely neccessary to have JTAG equipment (at the beginning)?
Gavinmc42 wrote: I have read and written i2c sensors on my own hats/motherboards with many software languages.
Even via shell script, but I prefer Ultibo these days.
So also made the corresponding EEPROM settings for the HATs? Can you tell a bit more about that? If the EEPROM is fed with the right content the PI will configure the ports automatically? Or is there a counterpart piece of software needed on the PI?
Gavinmc42 wrote: There are now some FPGA free tools that work with smaller FPGAs.
I tried them on a Pi3B+ but have yet to install on this Pi4.
Hmmm... also interesting. PSoC couldn't be done on the PI, but having small FPGA HATs would be an interesting piece of hardware.
hippy wrote: One can cross-develop on Windows but that can be more tricky to set-up than cross-developing on a Linux PC, and will often involve 'faking a Linux environment' which suggests one might as well use Linux to start with.
Another good point for using Linux, either on dedicated PC or VM.
hippy wrote: Windows 10 has Windows Subsystem for Linux (WSL) which means you can have the best of both worlds but it is probably easiest to start by developing on a Pi as that should have all the tools you need pre-installed. Raspbian should be a suitable distro, and the toolchain is already there. That's a lot of 'nothing more to do' which will help you get down to doing it rather than thinking about how to.
Currently I'm on Win7, so no WSL. I'll try both Linux and PI directly.
hippy wrote: I would suggest starting by developing on a Pi and see how it goes, get a feel for what you use and need. That will allow you to determine what doing cross-development would require if you choose to go that way later. If something proves hard to do on a Pi it is likely even harder from off the Pi.
Also a good point, you convinced me :D

Regards

User avatar
Gavinmc42
Posts: 3727
Joined: Wed Aug 28, 2013 3:31 am

Re: Recommendations for development environment

Thu Aug 15, 2019 2:11 am

Arduino is out of my scope, I learned micros with 8051 and derivates, now I'm on Cortex-M, primarily STM32 and PSoC.
I mainly use PSoCs too, the PSoC 1's 24123A makes handy i2c analog sensor interfaces.
PSoc4 because they are so cheap. Some of the Bluetooth modules.

PSoC Designer and Creator are not Linuxable,
The PSoC 6 has an Eclipse based tool that might work on Pi's.
But the Cortex PSoC's use GCC, just not sure how to do the digital blocks on Linux yet.

I use Arduino but on the Adafruit Feathers with the SAM Cortex micros.
For quick 1-2hour jobs they are hard to beat.
Need a custom 3 button USB HIB for a controller on a bigger Linux box - Arduino tools.
Ditto for Python or Micropython, good for quick simple stuff.

Soon we will have a choice of 64bit OS's on Pi4, then it will be like cross compiling back to armhf 32bit.

I find somethings the C dependencies can get in the way of compiling on one Linux OS for a different one on Pi's.
Every time it just works I am surprised, lots of code is involved.

Hat EEPROMs I think call up Linux device overlay files, never use them myself.
Plug and play Hats? Mine are custom hats, mostly one off, so no need.

Tried the WSL, why bother Linux is just easier., especially with SD card partitions.
I have a Linux Mint box sitting next to the Win10 box.
4 screens on my desk, left screen - Mint, middle two Win10, right screen is for Pi's.
3 lots of mice and keyboard, just because I'm too lazy to install Synergy.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

markkuk
Posts: 122
Joined: Thu Mar 22, 2018 1:02 pm
Location: Finland

Re: Recommendations for development environment

Thu Aug 15, 2019 6:09 am

RA1981 wrote:
Wed Aug 14, 2019 7:46 pm
Shouldn't be a problem to also get a Pi4. Do you know if it's possible to compile on the PI4 and then simply copy to the PI3?
As long as you use the same OS on both there shouldn't be any problems. Just make sure that the necessary run-time libraries are on the target system. Packaging the application as a .deb (for Raspbian) helps.
RA1981 wrote:
Wed Aug 14, 2019 7:46 pm
But in fact it's not absolutely neccessary to have JTAG equipment (at the beginning)?
JTAG shouldn't be necessary at all unless you are doing bare metal or custom hardware development.

hippy
Posts: 5942
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Recommendations for development environment

Thu Aug 15, 2019 2:45 pm

Gavinmc42 wrote:
Thu Aug 15, 2019 2:11 am
Tried the WSL, why bother Linux is just easier., especially with SD card partitions.
Depends what one is doing and what one has.

WSL let me do what I needed to do when Pi's are my only Linux machines and what I was trying to do would not run on a Pi because it does not have enough memory.

WSL saved me from having to find another PC to run Linux, setting up dual-booting or installing any other Linux VM. I don't recall there was much difference between using WSL and using my Pi over Telnet/SSH, so perfectly usable even if not 'real Linux'.

RA1981
Posts: 3
Joined: Tue Aug 13, 2019 8:11 pm

Re: Recommendations for development environment

Mon Aug 19, 2019 4:59 pm

Hi,

sorry for the late reply.
Gavinmc42 wrote:
Arduino is out of my scope, I learned micros with 8051 and derivates, now I'm on Cortex-M, primarily STM32 and PSoC.
I mainly use PSoCs too, the PSoC 1's 24123A makes handy i2c analog sensor interfaces.
PSoc4 because they are so cheap. Some of the Bluetooth modules.
Yes, I'm thinking of using PSoCs as Rpi slaves, too.
Gavinmc42 wrote: PSoC Designer and Creator are not Linuxable,
The PSoC 6 has an Eclipse based tool that might work on Pi's.
But the Cortex PSoC's use GCC, just not sure how to do the digital blocks on Linux yet.
PSoC6 is also a Cortex. You're right, as far as I know the IDE for PSoC 3, 4 and 5 is Windows only.
Regarding the digital blocks, I never figured out in detail how PSoC Creator translates the components into input for the digital assembler. I only know that the components create verilog code and inject this code into the main verilog file for the project. But I don't know how and with which parameters this file is taken by the digital assembler and how the result is injected back into the HEX/ELF file.
Gavinmc42 wrote: Soon we will have a choice of 64bit OS's on Pi4, then it will be like cross compiling back to armhf 32bit.
Sounds interesting.
Gavinmc42 wrote: I find somethings the C dependencies can get in the way of compiling on one Linux OS for a different one on Pi's.
Every time it just works I am surprised, lots of code is involved.
Oh, okay... For now, I decided to compile on the PI directly, so this shouldn't be a problem. But if I'd make bigger projects like kernel or similar this might become an issue.
Gavinmc42 wrote: Hat EEPROMs I think call up Linux device overlay files, never use them myself.
Plug and play Hats? Mine are custom hats, mostly one off, so no need.
Ah, then I missunderstood you. I thought you made extensions according to the official HAT specifications :)
markkuk wrote:
RA1981 wrote:
Wed Aug 14, 2019 7:46 pm
Shouldn't be a problem to also get a Pi4. Do you know if it's possible to compile on the PI4 and then simply copy to the PI3?
As long as you use the same OS on both there shouldn't be any problems. Just make sure that the necessary run-time libraries are on the target system. Packaging the application as a .deb (for Raspbian) helps.
Thank you for the explanation, I'll search about 'packaging' when the Rpi4 arrives :)
RA1981 wrote:
Wed Aug 14, 2019 7:46 pm
But in fact it's not absolutely neccessary to have JTAG equipment (at the beginning)?
JTAG shouldn't be necessary at all unless you are doing bare metal or custom hardware development.
Custom hardware in the sense of a own HAT circuit? Or do you mean an custom integrated circuit?
One of my long-term goals is to write device drivers for (HAT) extension circuits.
hippy wrote:
Gavinmc42 wrote:
Thu Aug 15, 2019 2:11 am
Tried the WSL, why bother Linux is just easier., especially with SD card partitions.
Depends what one is doing and what one has.

WSL let me do what I needed to do when Pi's are my only Linux machines and what I was trying to do would not run on a Pi because it does not have enough memory.

WSL saved me from having to find another PC to run Linux, setting up dual-booting or installing any other Linux VM. I don't recall there was much difference between using WSL and using my Pi over Telnet/SSH, so perfectly usable even if not 'real Linux'.
Good hint, so I'll take WSL into account when I'll get a new desktop PC.

@all:
Just an update, my current setup now is compiling directly on the Rpi (sufficient for the first steps) using Code::Blocks IDE. Connected to the main PC by using VNC.
I choosed Code::Blocks mainly because it's used in a Rpi programming book I bought recently, so at least for the beginning I could be sure that the examples provided with the book will run. It seems that Code::Blocks wasn't updated since a few years, so I might switch to a more recent IDE in future.
Oh, and one question regarding security came up while I was searching about writing drivers: some Rpi tutorials recommend to set a root password (beside of setting a password for user 'pi'), while others say that the root password shouldn't be set. This would prevent to login as root directly. So, don't having a password set prevents direct login is normal behaviour in Linux?

Thank you all for your help, I think the main questions for this topic have been answered :)

Regards

Return to “Beginners”