Method for defining a code to be executed by programmable control devices comprising: —providing a programming language; —providing a code written in that programming language; —compiling such code in machine language; —transferring said machine language code on a program memory for its execution by the control device, wherein said machine language code is divided into core code and application code, said application code being loaded into the program memory regardless of the core code, without performing a linking operation of the two codes before said transfer. A corresponding system is also disclosed.
|
14. A control system comprising:
a programmable control device;
a configurable memory device containing software that, when executed by the control device, causes the software in the memory to be at least partially overwritten by a software received from an uplinker component configured to transfer only those parts of the software needed for a specific application with symbols resolved based on information exchanged between the control device and the uplinker component, wherein said software comprises a complied application code and/or a core code and said uplinker component is further configured to transfer the application code into the memory of the device independently of the core code and without performing an operation of linking of the two codes.
1. A computer-implemented method for defining a code to be executed by programmable control devices comprising:
having a programming language;
having a code written by using said programming language, the code comprising at least one module;
compiling the code by using the machine language;
transferring said machine language code onto a program memory to be executed by the control device,
wherein said machine language code is divided into a core code and an application code, said application code being loaded into the program memory independently of the core code without performing an operation of linking of the two codes before said transfer and according to an allocation table built after the compilation phase, said table comprising the size, and start location and end location of each module forming the code.
3. A computer-implemented method for defining a code to be executed by programmable control devices comprising:
having a high-level programming language;
having one or more scripts written in that programming language;
compiling said scripts to generate a bytecode;
having a virtual machine capable of interpreting bytecode;
providing specific low-level codes for the control device and its peripheral devices, said low-level codes being the core code and said virtual machine being configured to run a core code;
having a real-time operating system;
building, after the compilation phase, a memory allocation table in which locations of the scripts in bytecode format are assigned;
loading the core code and the bytecode in the program memory for their execution by the control device,
wherein the bytecodes comprise a core and an application code, said application code being loaded into the program memory independently of the core code without performing an operation of linking of the two codes before said transfer and according to the information included in the memory allocation table.
11. A computer-implemented system for transferring a compiled application code and / or a core code to a memory for being executed by a programmable control device, the system comprising:
a virtual machine hosted by the device to run a core code loaded into the memory independently of the application code;
an uplinker component for transferring the application code into the memory of the device independently of the core code and without performing an operation of linking of the two codes;
a communication link between the virtual machine and the uplinker;
wherein the virtual machine is configured to:
send the uplinker a symbol table and desired memory size and position for the application code;
receive from the uplinker the code to be stored;
store the code as received in the memory,
the uplinker being configured to:
resolve missing symbols by static linking based on the symbol table received from the virtual machine;
pack the application code according to memory size and position as communicated by the virtual machine;
send the application code to the virtual machine for being stored in the memory the application code being adapted to be executed without any performance penalty due to the absence of dynamic linking.
2. Method according to
4. Method according to
5. Method according to
6. Method according to
7. Method according to
8. Method according to
9. Method according to
10. Method according to
12. system according to
13. system according to
|
The present invention is directed to methods and systems for preparing and transferring code to a memory of a programmable control device, particularly a non-volatile memory image representing ROM of a device hosting a virtual machine (VM).
Microcontrollers are electronic devices integrated on a single chip. Their principle of operation is common to the microprocessors, which are differentiated by the fact of having on board the memory elements and the interface devices required for the digital control specific applications mostly in embedded systems that include sensors and actuators for most varied purposes.
Microcontrollers, as well as microprocessors, need to be programmed, i.e. equipped, internally or on an external memory, with binary language code providing the sequence of instructions that each device must perform during its operation.
In order to set-up the microcontroller functional program it is possible to use low-level programming languages like assembler as well as languages of slightly higher level such as C/C++. Both these programming solutions are closely related and linked to the hardware characteristics of the microcontroller and the board where it is slotted. They are, namely, single-platform programming solutions.
Alternatively, there are systems that allow the usage of high-level languages (e.g. Python) to abstract the specific microcontroller board to be programmed. These system enable a cross-platform structure able to reuse or supplement the developed code on different boards, in the form of scripts to compile and link with additional modules, libraries, as well as low level drivers to build the binary code to be transferred on the program memory.
A very efficient multi-platform system to achieve the above mentioned functionalities is a solution that makes use of a Python 3.4 subset to make highly powerful architectures for embedded systems.
For each hardware architecture (Microprocessor+peripherals) a Virtual Machine (VM) is set and copied to the on-board program flash along with the real time operating system (RTOS) and the low-level specific codes for the present microcontroller and peripherals (Hardware Abstraction Layer—HAL).
The real time operating system along with the low-level codes represent the core that interprets Python scripts compiled as bytecodes.
The C language compiled codes are translated into machine instructions immediately readable by the controller without the need to be interpreted by the virtual machine.
The operation that allows to develop the executable code, defined “linking”, allows the various modules to be assembled together in order to become a unique code with a very specific memory allocation.
The linking operation is present both in high-level and low level languages, and it represents the final phase of a code development process before it is transferred to the program memory that will be executed by the microcontroller.
This is a highly inefficient process because it must be replicated whenever a single part of the program is modified, entailing a scratch transfer of the entire machine code.
Document U.S. Pat. No. 7,017,004 discloses a system for upgrading a non-volatile memory image by partitioning the memory into a plurality of regions that can be directly overwritten without having to overwrite the whole memory. This system, however, still requires linking the modules either statically or dynamically. In the former case, all drivers, also those unused, need always to be loaded in the memory thus leading to a waste of memory. In the latter case, a dynamic code is generated that requires a symbol resolution mechanism at runtime thus leading to a waste of time.
It is thus an object of the present invention to provide a method and system for high-level programming of microcontroller/microprocessor boards which allows to optimize the lead time needed to transfer the machine language code in the program memory for its execution, memory occupation and runtime speed.
In accordance with embodiments herein, systems, computer program products and computer implemented methods are provided for the preparation of code to be executed by programmable control devices, the systems, program products and methods comprising, under control of one or more computer systems configured with specific executable instructions:
In practice, the link operation is performed at the time of the upload of the binary code rather than in the previous phase as commonly occurs in the systems according to the prior art. All thanks to the use of an allocation memory that keeps track of the lengths of the code as well as of the beginning and end of each module to be loaded so that the core does not need to be reloaded every time as well as the modules not subject to changes.
This is particularly advantageous in case of use of high-level programming languages.
Embodiments also relate to systems for transferring a compiled application code to a memory for being executed by a programmable control device, the system comprising:
Embodiments also relate to a control system comprising:
Further characteristics and improvements are object of the subclaims.
The characteristics of the invention and the advantages derived therefrom will appear more clearly from the following detailed description of the accompanying figures.
With reference to
The architecture comprises a set of programming tools 110, an application program 120, a set of code modules 130 acting as a middleware between the application 120 and the low level code 140 implementing the multithreading mechanisms and the hardware abstraction layer, a hardware 150 represented by a board 151 with mcu/mpu capabilities installed together with a persistent memory 153 and possibly a set of sensors and actuators 152.
The set of programming tools 110 comprises a code editor 114 that enables the writing of programs. Such programs can be written in high level languages (e.g. Python) and optionally in low level languages (e.g. C) and are transformed in two stages: the first stage is performed by the compiler 115 that, given a program, converts it in a non executable low level code consisting of bytecode and optionally assembly code. Such non-executable low level code is then transformed again by the uplinker 111 in the second stage to obtain the final application code 120. The term uplinker is used in the present disclosure to identify a software/hardware module configured to transfer unlinked code to a program memory.
The set of programming tools is also composed of a mobile app 113 which is able to connect to devices programmed with a specific mobile-enabled application code 120 and to display a graphical user interface; moreover the mobile app 113 is able to establish a bidirectional connection with a device and exchange messages with it. The mobile app 113 features a mechanism for the discovery of devices programmed with a mobile-enabled application code.
The set of programming tools is completed by a module for cloud connectivity 116 that saves remotely both the development environment configuration and the programmer project files; and a package manager 112 for managing the extension of the set of programming tools with additional modules and components.
The Hardware 2100 may be composed of a Processor/Controller unit mounted on a Board 2101, Sensors and Actuators 2102 and a ROM Flash Memory 2103.
The Software running on a mcu/mpu 2200 comprises a Virtual Machine 2210, a RTOS 2220, a Memory Manager 2240 and a Hardware Abstraction Layer (HAL) 2230.
The Computer system hosting the code transferring toolchain 2400 is composed of an Application code 2410, a Compiler 2420 and an Uplinker 2430.
The Communication 2300 represents the interaction between the Computer 2400 and the Software 2200 running on Hardware 2100.
The Application code 2410 can be composed of Software Modules 2411 written in low level language (e.g. the C language), Modules implementing parts of the HAL 2413 written in low level language (e.g. the C language) and programs written in High Level Languages 2412 (e.g. Python).
The Compiler 2420 takes as input Software Modules 2411 and Modules implementing parts of the HAL 2413 producing Assembly code 2422; it also takes as input programs written in High Level Languages 2412 producing Bytecode 2421.
The Virtual Machine 2210 comprises a System Initialization 2211 and a Bytecode Interpreter 2212 while the RTOS 2220 comprises a Scheduler 2221 and Threading Primitives 2222 (e.g. Mutexes, Semaphores, etc.); The Memory Manager 2240 organizes RAM in a Heap 2241 managed by a Garbage Collector 2242. The Hardware Abstraction Layer (HAL) 2230 abstracts the hardware 2100
When a program is written in a high level language (such as Python or JavaScript) from which C functions are called, the computer interprets the high level language and turns it into bytecode or in a particular dialect that the virtual machine is able to interpret or, with regard to the C functions, they are directly converted into the assembler.
Actually the real time operating system and the core code of the VM occupy a determined memory space (almost constant), while the remaining flash space is gradually filled with the software modules and the hardware modules. When the Python or JavaScript or LUA script is ready and the board is configured, the uplinker statically calculates the size of all modules at compile phase, preparing the table with the start and end position and saves them in the flash while minimizing RAM usage.
The virtual machine is able to run in machine language code, not interpreted, obtained by compiling the intermediate level language (C/C++) and linked at the time of the upload in a manner comparable to the bytecode. In order to be executed by the virtual machine, the machine language code is subject to the following constraint: the functions that are called and not contained in it belong exclusively to the set of functions exposed by the core code of the VM. The architecture described in
The layout of ROM image 600 is intended to group both VM code and Application code with all the necessary components within specific regions. The size of each region is dependent upon the code intended to reside within each region.
A region containing VM code 610 contains specific segments of code implementing different set of functionalities such as System Initialization segment 611, Bytecode Interpreter segment 612, RTOS segment 620, HAL segment 630 and an optional AdHocData segment 640. A region containing VM code is advantageously partitioned in such a way that the System Initialization segment 611 is the first to be executed.
A region containing Application code may contain specific segments of code and segments of data with a layout computed by the Uplinker 111.
System initialization is smartly achieved. When the mcu/mpu is powered, the first code to be executed is the System Initilization 611. In this phase the microcontroller is configured to optimally execute the bytecode interpreter 612. The configuration parameters are taken from the persistent memory segment called AdHocData 640. Among the configuration data stored in the AdHocData segment there are flags recording the status of the previous System initialization phase (OK or Failed) together with the address to jump to in order to continue execution after the System Initialization phase.
This mechanism allows to have multiple Virtual Machines 610, 670 hosted on the same board and to select one of them to be executed according to the AdHocData segment 640 parameters.
AdHocData segment parameters can be modified from Application code by calling specific VM function(s) (F0 in
A method for transferring code to a non-volatile memory image representing ROM of the device hosting a VM 610 involves establishing communication between a software component (Uplinker) running on the computer hosting the toolchain and the VM running on the device.
At 301, the uplinker loads the compiled code consisting of bytecode and (optionally) non-executable assembly code due to unresolved symbols. At 302, the Uplinker establishes communication with the target VM running on a device, by exchanging a message sequence over a transport layer, such sequence realizing a handshake step where compatibility between Uplinker and VM versions is checked. At 303, the VM sends to the Uplinker the Symbol Table (
In
As it can be noticed in
Flash 520 can also be used to load html templates, json files, images, etc. and a method of data exposure related to the sensors and actuators and code in bidirectional mode (from micro to mobile and vice versa). When the object carrying the bytecode generated by the development environment is recognized by a mobile device via wifi, bluetooth, zigbee, etc then the MOBILE APP 10 (
The subject matter is described with specificity to meet statutory. However, the description itself is not intended to limit the scope of this patent. Rather, the inventors have contemplated that the claimed subject matter might also be embodied in other ways, to include different elements or combinations of elements similar to the ones described in this document, in conjunction with other present or future technologies.
Mazzei, Daniele, Montelisciani, Gabriele, Fantoni, Gualtiero, Baldi, Giacomo
Patent | Priority | Assignee | Title |
11455155, | Jul 04 2018 | GRAPHCORE LIMITED | Code compilation for scaling accelerators |
Patent | Priority | Assignee | Title |
7017004, | Mar 29 2002 | Microsoft Technology Licensing, LLC | System and method for updating contents of a flash ROM |
20060129794, | |||
20120311555, | |||
20130054807, | |||
20160246620, |
Executed on | Assignor | Assignee | Conveyance | Frame | Reel | Doc |
Jun 22 2016 | TOI S.R.L. | (assignment on the face of the patent) | / | |||
Nov 15 2017 | FANTONI, GUALTIERO | TOI S R L | CORRECTIVE ASSIGNMENT TO CORRECT THE ASSIGNEE NAME PREVIOUSLY RECORDED AT REEL: 044887 FRAME: 0220 ASSIGNOR S HEREBY CONFIRMS THE ASSIGNMENT | 047597 | /0636 | |
Nov 15 2017 | MAZZEI, DANIELE | TOI S R L | CORRECTIVE ASSIGNMENT TO CORRECT THE ASSIGNEE NAME PREVIOUSLY RECORDED AT REEL: 044887 FRAME: 0220 ASSIGNOR S HEREBY CONFIRMS THE ASSIGNMENT | 047597 | /0636 | |
Nov 15 2017 | MONTELISCIANI, GABRIELE | TOI S R L | CORRECTIVE ASSIGNMENT TO CORRECT THE ASSIGNEE NAME PREVIOUSLY RECORDED AT REEL: 044887 FRAME: 0220 ASSIGNOR S HEREBY CONFIRMS THE ASSIGNMENT | 047597 | /0636 | |
Nov 15 2017 | BALDI, GIACOMO | TOI SRL | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 044969 | /0748 | |
Nov 15 2017 | PANTONI, GUALTIERO | TOI SRL | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 044969 | /0748 | |
Nov 15 2017 | MAZZEI, DANIELE | TOI SRL | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 044969 | /0748 | |
Nov 15 2017 | MONTELISCIANI, GABRIELE | TOI SRL | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 044969 | /0748 | |
Nov 15 2017 | BALDI, GIACOMO | TOI S R I | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 044887 | /0220 | |
Nov 15 2017 | FANTONI, GUALTIERO | TOI S R I | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 044887 | /0220 | |
Nov 15 2017 | MAZZEI, DANIELE | TOI S R I | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 044887 | /0220 | |
Nov 15 2017 | MONTELISCIANI, GABRIELE | TOI S R I | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 044887 | /0220 | |
Nov 15 2017 | BALDI, GIACOMO | TOI S R L | CORRECTIVE ASSIGNMENT TO CORRECT THE ASSIGNEE NAME PREVIOUSLY RECORDED AT REEL: 044887 FRAME: 0220 ASSIGNOR S HEREBY CONFIRMS THE ASSIGNMENT | 047597 | /0636 | |
Feb 01 2018 | TOI S R L | KINZICA VENTURES LLC | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 048017 | /0956 | |
Jan 20 2020 | KINZICA VENTURES LLC | TOI S R L | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 051579 | /0245 | |
Feb 10 2023 | TOI S R L | ZERYNTH S P A | CHANGE OF NAME SEE DOCUMENT FOR DETAILS | 063268 | /0214 |
Date | Maintenance Fee Events |
Dec 15 2017 | BIG: Entity status set to Undiscounted (note the period is included in the code). |
Dec 22 2017 | SMAL: Entity status set to Small. |
Apr 05 2023 | M2551: Payment of Maintenance Fee, 4th Yr, Small Entity. |
Date | Maintenance Schedule |
Oct 22 2022 | 4 years fee payment window open |
Apr 22 2023 | 6 months grace period start (w surcharge) |
Oct 22 2023 | patent expiry (for year 4) |
Oct 22 2025 | 2 years to revive unintentionally abandoned end. (for year 4) |
Oct 22 2026 | 8 years fee payment window open |
Apr 22 2027 | 6 months grace period start (w surcharge) |
Oct 22 2027 | patent expiry (for year 8) |
Oct 22 2029 | 2 years to revive unintentionally abandoned end. (for year 8) |
Oct 22 2030 | 12 years fee payment window open |
Apr 22 2031 | 6 months grace period start (w surcharge) |
Oct 22 2031 | patent expiry (for year 12) |
Oct 22 2033 | 2 years to revive unintentionally abandoned end. (for year 12) |