## 4 System Design
#### Rewire
The first one is responsible for the communication between the processors, while the second one manages the firmware objects, as detailed in the following:  
Part I: The inter-processor communication stack running on Processor 1 utilizes interfaces exposed to Linux user space by the OpenAMP framework. From a user-space perspective, it looks like any Linux character device, and accordingly, it provides the standard system calls-based API to interact with a device of this type. In fact, it represents an RPMsg device, which is managed by means of a series of kernel drivers implementing APIs defined in VirtIO, Remoteproc, and RPMsg frameworks of Linux. In Processor 0, the communication must be supported by the bare-metal counterpart of the mentioned frameworks. Both parts of the REWIRE, running at Processor 0 and Processor 1, interact with each other through an RPMsg communication channel. This is made possible by utilizing an external SDRAM memory for the data exchanges and IPIs for the notifications about new data transactions. Part II: The second main part of REWIRE processes the firmware objects. As already mentioned, the ELF format is used for the object and executable files. Another part of the firmware responsible for the RR is a function or, in terms of C language a set of functions and associated structures, with a \"self-contained\" state. This function is mainly responsible for the initial configuration of the IP blocks inside the PL (i.e., executed once at the time when the Linux side of REWIRE notifies the bare-metal side that a new partial firmware is available). Essentially this part of the firmware must represent a single C translation  
Figure 1: A high-level overview of REWIRE. unit, which after compilation will result in a single object file. In turn, the main static executable stores a pointer to the function managing the associated RR and indirectly calls this function when a new object file is delivered and processed by REWIRE. Accordingly, a predefined address of a memory region is assigned to this function pointer. This approach is applied for all sections of the object file (i.e., code, data, read-only data, and so on); in other words, a predefined amount of memory in the main executable is reserved in order to account for different firmware object deliverables. Laying out memory regions of firmware is achieved by the means of low-level GCC attributes and a linker script. The static executable ELF file for Processor 0 is created among other files from a function main.c and the firmware dummy function dummy_prm_func.c, which simply displays a \"Hello world\" message. The linking of object files is done using a linker script file, which includes the following specifications:  
1. The size of the sections that make up the firmware function code is defined; before proceeding with reprogramming a newly produced and fetched firmware, the size compliance of the sections must be verified, because the new code will be downloaded into the memory where the bare-metal program of Processor 0 is executed. Any potential failure could block the execution of the code on Processor_0: [leftmargin=*] _PR_MODULE_FUNC_CODE_SIZE = 0x10,000; _PR_MODULE_FUNC_DATA_SIZE = 0x1000; _PR_MODULE_FUNC_RODATA_SIZE = 0x1000; ]
2. The memory direction for loading the static ELF executable file is defined as follows: MEMORY { ps7_ddr_0_S_AXL_BASEADDR: ORIGIN = 0x3e000000,LENGTH = 0x00400000 Ps7_ram_0_S_AXL_BASEADDR: ORIGIN = 0x0000000,LENGTH = 0x00030000 Ps7_ram_1_S_AXL_BASEADDR: ORIGIN = 0 xFFFF0000,LENGTH = 0x0000 FE00 ]
3. The sections of the firmware dummy_prm_func.c object code are defined and the pr_func_start, pr_data_start, and pr_rodata_start symbols are created: [leftmargin=*] _pr_mod_func:_ {. = ALIGN(0x10,000); _pr_func_start =. ; _dummy_prm_func.o(.text) _dummy_prm_func.o(.text. *) _. = _pr_func_start +_PR_MODULE_FUNC_CODE_SIZE; _pr_func_end =. ; ] > ps7_ddr_0_S_AXL_BASEADDR ] _pr_mod_data: ALIGN(0x1000) [ _pr_data_start =. ; _dummy_prm_func.o(.data) _dummy_prm_func.o(.data. *) _.