-2

I recently started learning about RTOS’s and came across the subject “porting”. I always tought that I could copy the RTOS files from github, paste it in my project and use it without any problems on any device. So I am a little confused about porting. I have two questions:

  1. What is porting in terms of RTOS?
  2. Why do I need porting of RTOS’s?

Thanks in advance,

Arjon

Arjon Arts
  • 39
  • 3
  • 1
    Did you Google for "porting freertos?" Here's the one of the top hits from when I tried it just now: freertos.org/FreeRTOS-porting-guide.html – Solomon Slow Feb 26 '20 at 19:38
  • @SolomonSlow that explains the how question but not why porting is necessary and what porting is. – Arjon Arts Feb 26 '20 at 19:44
  • @ArjonArts A little research goes a long way: https://en.wikipedia.org/wiki/Porting Its the act of taking software that runs on one system and modifying it so it runs on another system. –  Feb 26 '20 at 19:58
  • @Amy All I am asking is a simple explenation of my two question and not a link to an external website that is hard to follow. Keep iT simple please. – Arjon Arts Feb 26 '20 at 20:10
  • @ArjonArts That is simple. Try reading the opening paragraph, or the part of my comment after the link, which tells you in a *single sentence* what porting is and why it is needed. –  Feb 26 '20 at 20:11
  • Also read [How much research is expected of Stack Overflow users?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users). You are expected to do research before asking questions. –  Feb 26 '20 at 20:11
  • "It's the act of taking software meant for one system and modifying it so it runs on another system." Can you be more specific about what you don't understand about that very simple sentence? –  Feb 26 '20 at 20:15
  • I've explained it three times and linked you to a Wikipedia article about it. I've asked what you don't understand. You have a responsibility to describe what you don't understand, and have yet to meet that obligation. As well, you also have a responsibility to do research before asking for help, which you have also not done. So far the only feedback you've given is "that is too complicated for me!" which isn't constructive. So, once again. **What *specifically* do you not understand about the definition I've quoted?** –  Feb 26 '20 at 20:24
  • As well, what **specifically** do you not understand from the Wikipedia article? –  Feb 26 '20 at 20:29
  • I don't see a specific relation to FreeRTOS - virtually every RTOS needs some portable part if it isn't meant to be tied to one particular architecture. FreeRTOS makes the `port`/`portable.h` separation particular clear, but that's just a detail. Therefore I suggest to remove the tag [tag:freertos]. – HelpingHand May 01 '20 at 16:31

2 Answers2

2

Porting is the act of taking software written to run on one system and modifying it so it runs on another system. From Wikipedia,

In software engineering, porting is the process of adapting software for the purpose of achieving some form of execution in a computing environment that is different from the one that a given program (meant for such execution) was originally designed for

And,

When code is not compatible with a particular operating system or architecture, the code must be [ported] to the new system.

And,

Porting is also the term used when a video game designed to run on one platform, be it an arcade, video game console, or personal computer, is converted to run on a different platform

In other words, you have some software you want to run on a real-time operating system (RTOS). That software was not written to run on RTOS, and will fail unless it is modified accordingly. It must be ported to RTOS before it can run. If you don't port the software, it will not run on the new system.

The nature and scope of those modifications depends on the software and the specific RTOS.

1

An RTOS interacts directly with processor and platform hardware. When an RTOS is designed to run of different hardware, you necessarily have target specific code to adapt the generic code to the specific hardware and processor architecture.

As a minimum an RTOS requires a system timer generating an interrupt, and to perform context switch it requires direct access to the processor registers in order to restore the context, set the stack pointer for the task to switch to and effect a jump by setting the program counter - that cannot be done with generic code since it requires intimate hardware knowledge.

The "port" of an RTOS requires code written specifically for the target platform including code to handle the timer interrupt, select which timer will be used as the system timer, and effect a context switch. Often much of this code must be written in assembler for direct register access which is necessarily architecture specific.

In addition to the kernel scheduler, depending on the scope of the RTOS in terms of the services it provides, there may be code required to deal with target specific MMU/MPU support and I/O drivers for filesystems, networking etc.

Clifford
  • 88,407
  • 13
  • 85
  • 165