This project is about developing a framework in Ada 2012 for developing the control software for the NXP cup race car. The NXP cup race car, officially known as "TFC-KIT: The NXP Cup Intelligent Car Development System", is a "toy size" race car chassis coupled with a FRDM-KL25Z board and a TFC-shield board. The car kit also includes two DC motors for the rear wheels, a steering servo for the front wheels and a line scan camera. The car runs on a white track that has turns, intersections, hills and wavy (slalom) segments, and must detect the finish line to stop. The control software for the car is stored in the flash memory of the FRDM-KL25Z board's microcontroller. The microcontroller is an NXP Kinetis KL25Z chip, with Cortex-M0+ core, 128KB of NOR flash and 16KB of SRAM. The software runs out of flash and can only use the SRAM in the micrcocontroller, to store program variables. This constraint makes the KL25Z micrcontroller an interesting platform to demonstrate that Ada 2012 and the gnat compiler can be used successfully to build embedded software for such small devices.
The control software consists of a control loop that reads frames from the line-scan camera, analyzes each frame to decide where to steer the car, and sends commands to the steering servo and rear wheel motors. The goal of the control algorithm is to keep the car inside track at all times while traversing it as fast as possible.
The main deliverable of this project is a software framework for developing the control software for the NXP cup race car. This framework will enable students and hobbyists alike to use Ada 2012 to develop their own control software for the little car, and to experiment with different image processing algorithms to analyze camera frames as well as with different control algorithms for autonomous driving of the car. They will be able to concentrate on the core problems, without having to write the whole software stack for the car, from scratch.
The car control software framework will be architected in three layers: - Layer 3: Platform-independent car control application layer. This layer is the framework itself. It will sit on top of the "Embedded Software building blocks" layer and the "Small Foot Print Ravenscar" gnat runtime library. Layer 3 sits on top of Layer 2 and Layer 1. - Layer 2: Embedded software building blocks layer for the NXP FRDM-KL25Z. This is an infrastructure layer of reusable software abstractions for embedded software development, that provide a board-independent interface or HAL (hardware abstraction layer). It is meant to be application independent, and thus reusable for any bare-metal software project in Ada 2012 targeted for the FRDM-KL25Z board. Even further, this layer is designed to be easily portable to different boards that have a Cortex-M-based microcontroller and similar peripherals. Layer 2 sits on top of Layer 1. - Port of the "Small Foot Print Ravenscar" gnat runtime library for the NXP Kinetis KL25Z microcontroller
Project LogFinished porting the GNAT Ravenscar-SFP runtime library to the Kinetis KL25ZI posted the code of the Kinetis KL25Z port of the GNAT Ravenscar-SFP runtime library in GitHub at https://github.com/jgrivera67/gnat-runtime-libs-for-kinetis-microcontrollers.
Source Code SkeletonI posted a source code skeleton for The Autonomous Car software in Github at:
https://github.com/jgrivera67/make-with-ada
in the frdmkl25zautonomous_car folder.
I also included a test program for the Kinetis KL25Z port of the GNAT Ravenscar-SFP runtime library in the frdmkl25zgnatruntimetest folder.
Links to Code repositories in GitHubMy Make-With-Ada ProjectsGNAT Ravenscar-SFP Runtime Library Ports for Kinetis MCUsIssues Found with the svd2Ada ToolThe Ada code generated by the svd2ada tool for Freescale Kinetis micrcontrollers is broken, as I reported in the following issues:Issue 1 lssue 2
So, for now I have decided to manually write the code for the I/O register type declrations for the peripherals I'm using.
Project AchievementsSummary of Accomplishments to Date- Ported GNAT Ravenscar SFP Runtime library to the FRDM-KL25Z board.
- Written System reset counter facility integrated into the GNAT Runtime library
- Written a stack trace capture facility to help debug code that use the small foot print or zero foot print flavors of the GNAT Ravenscar Runtime library (which does not provide the GNAT.Traceback package).
- Written in-memory runtime tracing log facility that is persisten across system resets.
- Written Pin Muxer, GPIO and UART drivers for the Kinetis KL25Z MCU
- Written full-screen (VT100) serial console and command-line facilities on top of the UART driver.
- Architected a framework for developing control algorithms for the NXP cup race car (see project overview slides). Although I ran out of time to complete the implementation before the deadline for Make-with-Ada, I will continue working until it is finished, as outlined in the future plans section below.
- Approximate amount of code written to date: Line metrics summed over 59 units all lines : 7779 code lines : 3981 comment lines : 2708 end-of-line comments : 11 comment percentage : 40.64 blank lines : 1090 These numbers were gathered with the GNAT metrics tool on the frdmkl25zautonomous_car project. These numbers do not include code written to port The GNAT Ravenscar SFP runtime library to the target platform.
- Finish implementing layer 2-4 of the UDP/IP networking stack
- Finish implementing the IoT demo application components
- Write SPI driver for the K64F MCU and RF driver for the RF2400 nordic radio add-on board
- Replace the cellphone as the bluetooth master in the IoT stack dem with the Hexiwear device. To do this, I need to develop the following components:
- I2C and accelerometer drivers for the K64F MCU
- Bluetooth (BLE) software interface from the K64F MCU to the KW40 MCU in the Hexiwear board, using the FSCI message protocol
- Hexiwear LCD driver
- Hexiwear touch screen driver
- My Project is under the BSD license
- It's hosted on Github. The project is divided in two repositories:
- gnat-runtime-libs-for-kinetis-microcontrollersThis repository contains ports of the GNAT Ravenscar-SFP Runtime Library for the two NXP Kinetis micrcontrollers I used for my two *Make with Ada" projects.
- make-with-adaThis repository contains therest of the code I wrote for my two Make with Ada projects, on top of the GNAT Ravenscar-SFP Runtime Library.
- I used the GNAT GPL 2016 toolchain - ARM ELF format (hosted on Windows), including the GPS IDE. I also used the svd2ada tool to generate Ada code from SVD XML files for the Kinetis micrcontrollers I used.
- I submitted a pull request to the GNAT Embedded Runtimes Project (embedded-runtimes GitHub repository) to contribute the three ports of the GNAT Ravenscar SFP runtime that I made as part of my "Make-with-Ada" project work (see pull request).
- I helped improve the svd2ada tool by submitted two bugs I found when using it.
- I developed several device drivers for several peripherals for the target boards I used, that can be easily reused. I plan to submit them to the Ada Drivers Library GitHub project.
- I have structured the Ada code of my project in a way that decouples the platform indpendent portions from the MCU specific and board-specfic portions (see Source Code Architecture diagrams). This will enable others to reuse portions of this code and port it to other platforms.
- Disciplined use of information hiding principles to architect the code to ensure high levels of maintainability and portability, and to avoid code duplication across projects and across platforms.
- Leveraged extensively the data encapsulation and modularity features of the Ada language such as private types and child units including private child units, and in some cases subunits and nested subprograms.
- Used gnatdoc comments to document key data structures and subprograms
- Used Ada 2012 contract-based programming features and assertions extensively
- Used range-based types extensively to leverage the Ada power to detect invalid integer values.
- Used Ada 2012 aspect constructs wherever possible
- Used GNAT coding style. I use the
-gnaty3abcdefhiklmnoOprstux
GNAT compiler option to chekc compliance with this standard. (I ran out of time to clean style warnings in some files, but I intend to have all the code compliant)
- Used GNAT flags to enable rigorous compile-time checks, such as
-gnato13 -gnatf -gnatwa -gnatVa -Wall
.
- I developed an extension to the GNAT runtime library to provide a mechanism to count system resets (see reset_counter.ads and linker script changes). On top of this, I built a facility to provide in-memory runtime logs whose contents persist across resets (see runtime_logs.ads).
- I developed a stack trace capture facility for non-full flavors for the Ravenscar runtime. This facility does not depend on traceback tables (see [stacktracecapture.ads] (https://github.com/jgrivera67/make-with-ada/blob/master/buildingblocks/portable/stacktracecapture.ads)). I used this facility to enhance the diagnostics information captured in the LastChanceHandler routine, by capturing a raw stack trace for the exception that trigger the LastChance_Handler call. This combined with reset-persistent runtime logs can be a very valuable first-failure-data-capture aid for production code.
- Ported GNAT Ravenscar SFP Runtime library to the FRDM-KL25Z board.
- Written System reset counter facility integrated into the GNAT Runtime library
- Written a stack trace capture facility to help debug code that use the small foot print or zero foot print flavors of the GNAT Ravenscar Runtime library (which does not provide the GNAT.Traceback package).
- Written in-memory runtime tracing log facility that is persisten across system resets.
- Written Pin Muxer, GPIO and UART drivers for the Kinetis KL25Z MCU
- Written full-screen (VT100) serial console and command-line facilities on top of the UART driver.
- Architected a framework for developing control algorithms for the NXP cup race car (see project overview slides). Although I ran out of time to complete the implementation before the deadline for Make-with-Ada, I will continue working until it is finished, as outlined in the future plans section below.
- Approximate amount of code written to date: Line metrics summed over 59 units all lines : 7779 code lines : 3981 comment lines : 2708 end-of-line comments : 11 comment percentage : 40.64 blank lines : 1090 These numbers were gathered with the GNAT metrics tool on the frdmkl25zautonomous_car project. These numbers do not include code written to port The GNAT Ravenscar SFP runtime library to the target platform.
- Write PWM, periodic timer and A/D converter drivers for the Kinetis KL25Z MCU
- Write Line-scan camera driver on top of the A/D converter
- Write servo and DC motor drivers on top of the PWM driver
- Implement the Autonomous Car control framework
- Write I2C driver for the Kinetis KL25Z MCU
- Write Accelerometer driver on top of the I2C driver
- Enhance control framework by using accelerometer data
- My Project is under the BSD license
- It's hosted on Github. The project is divided in two repositories:
- gnat-runtime-libs-for-kinetis-microcontrollersThis repository contains ports of the GNAT Ravenscar-SFP Runtime Library for the two NXP Kinetis micrcontrollers I used for my two *Make with Ada" projects.
- make-with-adaThis repository contains therest of the code I wrote for my two Make with Ada projects, on top of the GNAT Ravenscar-SFP Runtime Library.
- I used the GNAT GPL 2016 toolchain - ARM ELF format (hosted on Windows), including the GPS IDE. I also used the svd2ada tool to generate Ada code from SVD XML files for the Kinetis micrcontrollers I used.
- I submitted a pull request to the GNAT Embedded Runtimes Project (embedded-runtimes GitHub repository) to contribute the three ports of the GNAT Ravenscar SFP runtime that I made as part of my "Make-with-Ada" project work (see pull request).
- I helped improve the svd2ada tool by submitted two bugs I found when using it.
- I developed several device drivers for several peripherals for the target boards I used, that can be easily reused. I plan to submit them to the Ada Drivers Library GitHub project.
- I have structured the Ada code of my project in a way that decouples the platform indpendent portions from the MCU specific and board-specfic portions (see Source Code Architecture diagrams). This will enable others to reuse portions of this code and port it to other platforms.
- Disciplined use of information hiding principles to architect the code to ensure high levels of maintainability and portability, and to avoid code duplication across projects and across platforms.
- Leveraged extensively the data encapsulation and modularity features of the Ada language such as private types and child units including private child units, and in some cases subunits and nested subprograms.
- Used gnatdoc comments to document key data structures and subprograms
- Used Ada 2012 contract-based programming features and assertions extensively
- Used range-based types extensively to leverage the Ada power to detect invalid integer values.
- Used Ada 2012 aspect constructs wherever possible
- Used GNAT coding style. I use the
-gnaty3abcdefhiklmnoOprstux
GNAT compiler option to chekc compliance with this standard. (I ran out of time to clean style warnings in some files, but I intend to have all the code compliant)
- Used GNAT flags to enable rigorous compile-time checks, such as
-gnato13 -gnatf -gnatwa -gnatVa -Wall
.
- I developed an extension to the GNAT runtime library to provide a mechanism to count system resets (see reset_counter.ads and linker script changes). On top of this, I built a facility to provide in-memory runtime logs whose contents persist across resets (see runtime_logs.ads).
- I developed a stack trace capture facility for non-full flavors for the Ravenscar runtime. This facility does not depend on traceback tables (see [stacktracecapture.ads] (https://github.com/jgrivera67/make-with-ada/blob/master/buildingblocks/portable/stacktracecapture.ads)). I used this facility to enhance the diagnostics information captured in the LastChanceHandler routine, by capturing a raw stack trace for the exception that trigger the LastChance_Handler call. This combined with reset-persistent runtime logs can be a very valuable first-failure-data-capture aid for production code.
- Ported GNAT Ravenscar SFP Runtime library to the FRDM-KL25Z board.
- Written System reset counter facility integrated into the GNAT Runtime library
- Written a stack trace capture facility to help debug code that use the small foot print or zero foot print flavors of the GNAT Ravenscar Runtime library (which does not provide the GNAT.Traceback package).
- Written in-memory runtime tracing log facility that is persisten across system resets.
- Written Pin Muxer, GPIO and UART drivers for the Kinetis KL25Z MCU
- Written full-screen (VT100) serial console and command-line facilities on top of the UART driver.
- Architected a framework for developing control algorithms for the NXP cup race car (see project overview slides). Although I ran out of time to complete the implementation before the deadline for Make-with-Ada, I will continue working until it is finished, as outlined in the future plans section below.
- Approximate amount of code written to date: Line metrics summed over 59 units all lines : 7779 code lines : 3981 comment lines : 2708 end-of-line comments : 11 comment percentage : 40.64 blank lines : 1090 These numbers were gathered with the GNAT metrics tool on the frdmkl25zautonomous_car project. These numbers do not include code written to port The GNAT Ravenscar SFP runtime library to the target platform.
- Write PWM, periodic timer and A/D converter drivers for the Kinetis KL25Z MCU
- Write Line-scan camera driver on top of the A/D converter
- Write servo and DC motor drivers on top of the PWM driver
- Implement the Autonomous Car control framework
- Write I2C driver for the Kinetis KL25Z MCU
- Write Accelerometer driver on top of the I2C driver
- Enhance control framework by using accelerometer data
- My Project is under the BSD license
- It's hosted on Github. The project is divided in two repositories:
- gnat-runtime-libs-for-kinetis-microcontrollersThis repository contains ports of the GNAT Ravenscar-SFP Runtime Library for the two NXP Kinetis micrcontrollers I used for my two *Make with Ada" projects.
- make-with-adaThis repository contains therest of the code I wrote for my two Make with Ada projects, on top of the GNAT Ravenscar-SFP Runtime Library.
- I used the GNAT GPL 2016 toolchain - ARM ELF format (hosted on Windows), including the GPS IDE. I also used the svd2ada tool to generate Ada code from SVD XML files for the Kinetis micrcontrollers I used.
- I submitted a pull request to the GNAT Embedded Runtimes Project (embedded-runtimes GitHub repository) to contribute the three ports of the GNAT Ravenscar SFP runtime that I made as part of my "Make-with-Ada" project work (see pull request).
- I helped improve the svd2ada tool by submitted two bugs I found when using it.
- I developed several device drivers for several peripherals for the target boards I used, that can be easily reused. I plan to submit them to the Ada Drivers Library GitHub project.
- I have structured the Ada code of my project in a way that decouples the platform indpendent portions from the MCU specific and board-specfic portions (see Source Code Architecture diagrams). This will enable others to reuse portions of this code and port it to other platforms.
- Disciplined use of information hiding principles to architect the code to ensure high levels of maintainability and portability, and to avoid code duplication across projects and across platforms. Indeed, there is a lot of code sharing with my other project (see IoT Networking Stack project).
- Leveraged extensively the data encapsulation and modularity features of the Ada language such as private types and child units including private child units, and in some cases subunits and nested subprograms.
- Used gnatdoc comments to document key data structures and subprograms
- Used Ada 2012 contract-based programming features and assertions extensively
- Used range-based types extensively to leverage the Ada power to detect invalid integer values.
- Used Ada 2012 aspect constructs wherever possible
- Used GNAT coding style. I use the
-gnaty3abcdefhiklmnoOprstux
GNAT compiler option to chekc compliance with this standard. (I ran out of time to clean style warnings in some files, but I intend to have all the code compliant)
- Used GNAT flags to enable rigorous compile-time checks, such as
-gnato13 -gnatf -gnatwa -gnatVa -Wall
.
- I developed an extension to the GNAT runtime library to provide a mechanism to count system resets (see reset_counter.ads and linker script changes). On top of this, I built a facility to provide in-memory runtime logs whose contents persist across resets (see runtime_logs.ads).
- I developed a stack trace capture facility for non-full flavors for the Ravenscar runtime. This facility does not depend on traceback tables (see [stacktracecapture.ads] (https://github.com/jgrivera67/make-with-ada/blob/master/buildingblocks/portable/stacktracecapture.ads)). I used this facility to enhance the diagnostics information captured in the LastChanceHandler routine, by capturing a raw stack trace for the exception that trigger the LastChance_Handler call. This combined with reset-persistent runtime logs can be a very valuable first-failure-data-capture aid for production code.
- Ported GNAT Ravenscar SFP Runtime library to the FRDM-KL25Z board.
- Written System reset counter facility integrated into the GNAT Runtime library
- Written a stack trace capture facility to help debug code that use the small foot print or zero foot print flavors of the GNAT Ravenscar Runtime library (which does not provide the GNAT.Traceback package).
- Written in-memory runtime tracing log facility that is persisten across system resets.
- Written Pin Muxer, GPIO and UART drivers for the Kinetis KL25Z MCU
- Written full-screen (VT100) serial console and command-line facilities on top of the UART driver.
- Architected a framework for developing control algorithms for the NXP cup race car (see project overview slides). Although I ran out of time to complete the implementation before the deadline for Make-with-Ada, I will continue working until it is finished, as outlined in the future plans section below.
- Currently, I have an skeletal application with 3 tasks running on the FRDM-KL25Z. It proves that the GNAT Ravenscar SFP library can run on this memory-constrained MCU. This application consumes 11k out of the 16K of SRAM in the KL25Z. Although, 4K left for the real application is a little tight, past experience tells me that I can still fit the data structures for the completed application in the available SRAM.
- Approximate amount of code written to date: Line metrics summed over 59 units all lines : 7779 code lines : 3981 comment lines : 2708 end-of-line comments : 11 comment percentage : 40.64 blank lines : 1090 These numbers were gathered with the GNAT metrics tool on the frdmkl25zautonomous_car project. These numbers do not include code written to port The GNAT Ravenscar SFP runtime library to the target platform.
- Write PWM, periodic timer and A/D converter drivers for the Kinetis KL25Z MCU
- Write Line-scan camera driver on top of the A/D converter
- Write servo and DC motor drivers on top of the PWM driver
- Implement the Autonomous Car control framework
- Write I2C driver for the Kinetis KL25Z MCU
- Write Accelerometer driver on top of the I2C driver
- Enhance control framework by using accelerometer data
- My Project is under the BSD license
- It's hosted on Github. The project is divided in two repositories:
- gnat-runtime-libs-for-kinetis-microcontrollersThis repository contains ports of the GNAT Ravenscar-SFP Runtime Library for the two NXP Kinetis micrcontrollers I used for my two *Make with Ada" projects.
- make-with-adaThis repository contains therest of the code I wrote for my two Make with Ada projects, on top of the GNAT Ravenscar-SFP Runtime Library.
- I used the GNAT GPL 2016 toolchain - ARM ELF format (hosted on Windows), including the GPS IDE. I also used the svd2ada tool to generate Ada code from SVD XML files for the Kinetis micrcontrollers I used.
- I submitted a pull request to the GNAT Embedded Runtimes Project (embedded-runtimes GitHub repository) to contribute the FRDM-KL25Z port of the GNAT Ravenscar SFP runtime that I made (see pull request). This port is particularly important as until now the GNAT Ravenscar Runtimes for ARM only supported Cortex-M4 platforms. This is the first port that support a Cortex-M0+ platform. There are many low-power MCUs that use Cortex-M0+ core. So, having Ada running on Cortex-M0+ can be very useful.
- I helped improve the svd2ada tool by submitted two bugs I found when using it.
- I developed several device drivers for several peripherals for the target boards I used, that can be easily reused. I plan to submit them to the Ada Drivers Library GitHub project.
- I have structured the Ada code of my project in a way that decouples the platform independent portions from the MCU specific and board-specfic portions (see Source Code Architecture diagrams:1,2,3). This will enable others to reuse portions of this code and port it to other platforms.
- Disciplined use of information hiding principles to architect the code to ensure high levels of maintainability and portability, and to avoid code duplication across projects and across platforms. Indeed, there is a lot of code sharing with my other project (see IoT Networking Stack project).
- Leveraged extensively the data encapsulation and modularity features of the Ada language such as private types and child units including private child units, and in some cases subunits and nested subprograms.
- Used gnatdoc comments to document key data structures and subprograms
- Used Ada 2012 contract-based programming features and assertions extensively
- Used range-based types extensively to leverage the Ada power to detect invalid integer values.
- Used Ada 2012 aspect constructs wherever possible
- Used GNAT coding style. I use the
-gnaty3abcdefhiklmnoOprstux
GNAT compiler option to chekc compliance with this standard. (I ran out of time to clean style warnings in some files, but I intend to have all the code compliant)
- Used GNAT flags to enable rigorous compile-time checks, such as
-gnato13 -gnatf -gnatwa -gnatVa -Wall
.
- I developed an extension to the GNAT runtime library to provide a mechanism to count system resets (see reset_counter.ads and linker script changes). On top of this, I built a facility to provide in-memory runtime logs whose contents persist across resets (see runtime_logs.ads).
- I developed a stack trace capture facility for non-full flavors for the Ravenscar runtime. This facility does not depend on traceback tables (see [stacktracecapture.ads] (https://github.com/jgrivera67/make-with-ada/blob/master/buildingblocks/portable/stacktracecapture.ads)). It uses an innovative stack unwinding algorithm that traverses the call chain backwards, locating the "links" in the call chain by scanning backwards the machine instructions of a subprogram, looking for its prolog code sequence. I used this facility to enhance the diagnostics information captured in the LastChanceHandler routine, by capturing a raw stack trace for the exception that trigger the LastChance_Handler call. This combined with reset-persistent runtime logs can be a very valuable first-failure-data-capture aid for production code.
This project is about developing a framework in Ada 2012 for developing the control software for the NXP cup race car. The NXP cup race car, officially known as "TFC-KIT: The NXP Cup Intelligent Car Development System", is a "toy size" race car chassis coupled with a FRDM-KL25Z board and a TFC-shield board. The car kit also includes two DC motors for the rear wheels, a steering servo for the front wheels and a line scan camera. The car runs on a white track that has turns, intersections, hills and wavy (slalom) segments, and must detect the finish line to stop. The control software for the car is stored in the flash memory of the FRDM-KL25Z board's microcontroller. The microcontroller is an NXP Kinetis KL25Z chip, with Cortex-M0+ core, 128KB of NOR flash and 16KB of SRAM. The software runs out of flash and can only use the SRAM in the micrcocontroller, to store program variables. This constraint makes the KL25Z micrcontroller an interesting platform to demonstrate that Ada 2012 and the gnat compiler can be used successfully to build embedded software for such small devices.
The control software consists of a control loop that reads frames from the line-scan camera, analyzes each frame to decide where to steer the car, and sends commands to the steering servo and rear wheel motors. The goal of the control algorithm is to keep the car inside track at all times while traversing it as fast as possible.
The main deliverable of this project is a software framework for developing the control software for the NXP cup race car. This framework will enable students and hobbyists alike to use Ada 2012 to develop their own control software for the little car, and to experiment with different image processing algorithms to analyze camera frames as well as with different control algorithms for autonomous driving of the car. They will be able to concentrate on the core problems, without having to write the whole software stack for the car, from scratch.
The car control software framework will be architected in three layers: - Layer 3: Platform-independent car control application layer. This layer is the framework itself. It will sit on top of the "Embedded Software building blocks" layer and the "Small Foot Print Ravenscar" gnat runtime library. Layer 3 sits on top of Layer 2 and Layer 1. - Layer 2: Embedded software building blocks layer for the NXP FRDM-KL25Z. This is an infrastructure layer of reusable software abstractions for embedded software development, that provide a board-independent interface or HAL (hardware abstraction layer). It is meant to be application independent, and thus reusable for any bare-metal software project in Ada 2012 targeted for the FRDM-KL25Z board. Even further, this layer is designed to be easily portable to different boards that have a Cortex-M-based microcontroller and similar peripherals. Layer 2 sits on top of Layer 1. - Port of the "Small Foot Print Ravenscar" gnat runtime library for the NXP Kinetis KL25Z microcontroller.
Project LogFinished porting the GNAT Ravenscar-SFP runtime library to the Kinetis KL25ZI posted the code of the Kinetis KL25Z port of the GNAT Ravenscar-SFP runtime library in GitHub at https://github.com/jgrivera67/gnat-runtime-libs-for-kinetis-microcontrollers.
Source Code SkeletonI posted a source code skeleton for The Autonomous Car software in Github at:
https://github.com/jgrivera67/make-with-ada
in the frdmkl25zautonomous_car folder.
I also included a test program for the Kinetis KL25Z port of the GNAT Ravenscar-SFP runtime library in the frdmkl25zgnatruntimetest folder.
Links to Code repositories in GitHubMy Make-With-Ada ProjectsGNAT Ravenscar-SFP Runtime Library Ports for Kinetis MCUsIssues Found with the svd2Ada ToolThe Ada code generated by the svd2ada tool for Freescale Kinetis micrcontrollers is broken, as I reported in the following issues:Issue 1 lssue 2
So, for now I have decided to manually write the code for the I/O register type declrations for the peripherals I'm using.
Project AchievementsSummary of Accomplishments to Date- Ported GNAT Ravenscar SFP Runtime library to the FRDM-KL25Z board.
- Written System reset counter facility integrated into the GNAT Runtime library
- Written a stack trace capture facility to help debug code that use the small foot print or zero foot print flavors of the GNAT Ravenscar Runtime library (which does not provide the GNAT.Traceback package).
- Written in-memory runtime tracing log facility that is persisten across system resets.
- Written Pin Muxer, GPIO and UART drivers for the Kinetis KL25Z MCU
- Written full-screen (VT100) serial console and command-line facilities on top of the UART driver.
- Architected a framework for developing control algorithms for the NXP cup race car (see project overview slides). Although I ran out of time to complete the implementation before the deadline for Make-with-Ada, I will continue working until it is finished, as outlined in the future plans section below.
- Approximate amount of code written to date: Line metrics summed over 59 units all lines : 7779 code lines : 3981 comment lines : 2708 end-of-line comments : 11 comment percentage : 40.64 blank lines : 1090 These numbers were gathered with the GNAT metrics tool on the frdmkl25zautonomous_car project. These numbers do not include code written to port The GNAT Ravenscar SFP runtime library to the target platform.
- Finish implementing layer 2-4 of the UDP/IP networking stack
- Finish implementing the IoT demo application components
- Write SPI driver for the K64F MCU and RF driver for the RF2400 nordic radio add-on board
- Replace the cellphone as the bluetooth master in the IoT stack dem with the Hexiwear device. To do this, I need to develop the following components:
- I2C and accelerometer drivers for the K64F MCU
- Bluetooth (BLE) software interface from the K64F MCU to the KW40 MCU in the Hexiwear board, using the FSCI message protocol
- Hexiwear LCD driver
- Hexiwear touch screen driver
- My Project is under the BSD license
- It's hosted on Github. The project is divided in two repositories:
- gnat-runtime-libs-for-kinetis-microcontrollersThis repository contains ports of the GNAT Ravenscar-SFP Runtime Library for the two NXP Kinetis micrcontrollers I used for my two *Make with Ada" projects.
- make-with-adaThis repository contains therest of the code I wrote for my two Make with Ada projects, on top of the GNAT Ravenscar-SFP Runtime Library.
- I used the GNAT GPL 2016 toolchain - ARM ELF format (hosted on Windows), including the GPS IDE. I also used the svd2ada tool to generate Ada code from SVD XML files for the Kinetis micrcontrollers I used.
- I submitted a pull request to the GNAT Embedded Runtimes Project (embedded-runtimes GitHub repository) to contribute the three ports of the GNAT Ravenscar SFP runtime that I made as part of my "Make-with-Ada" project work (see pull request).
- I helped improve the svd2ada tool by submitted two bugs I found when using it.
- I developed several device drivers for several peripherals for the target boards I used, that can be easily reused. I plan to submit them to the Ada Drivers Library GitHub project.
- I have structured the Ada code of my project in a way that decouples the platform indpendent portions from the MCU specific and board-specfic portions (see Source Code Architecture diagrams). This will enable others to reuse portions of this code and port it to other platforms.
- Disciplined use of information hiding principles to architect the code to ensure high levels of maintainability and portability, and to avoid code duplication across projects and across platforms.
- Leveraged extensively the data encapsulation and modularity features of the Ada language such as private types and child units including private child units, and in some cases subunits and nested subprograms.
- Used gnatdoc comments to document key data structures and subprograms
- Used Ada 2012 contract-based programming features and assertions extensively
- Used range-based types extensively to leverage the Ada power to detect invalid integer values.
- Used Ada 2012 aspect constructs wherever possible
- Used GNAT coding style. I use the
-gnaty3abcdefhiklmnoOprstux
GNAT compiler option to chekc compliance with this standard. (I ran out of time to clean style warnings in some files, but I intend to have all the code compliant)
- Used GNAT flags to enable rigorous compile-time checks, such as
-gnato13 -gnatf -gnatwa -gnatVa -Wall
.
- I developed an extension to the GNAT runtime library to provide a mechanism to count system resets (see reset_counter.ads and linker script changes). On top of this, I built a facility to provide in-memory runtime logs whose contents persist across resets (see runtime_logs.ads).
- I developed a stack trace capture facility for non-full flavors for the Ravenscar runtime. This facility does not depend on traceback tables (see [stacktracecapture.ads] (https://github.com/jgrivera67/make-with-ada/blob/master/buildingblocks/portable/stacktracecapture.ads)). I used this facility to enhance the diagnostics information captured in the LastChanceHandler routine, by capturing a raw stack trace for the exception that trigger the LastChance_Handler call. This combined with reset-persistent runtime logs can be a very valuable first-failure-data-capture aid for production code.
- Ported GNAT Ravenscar SFP Runtime library to the FRDM-KL25Z board.
- Written System reset counter facility integrated into the GNAT Runtime library
- Written a stack trace capture facility to help debug code that use the small foot print or zero foot print flavors of the GNAT Ravenscar Runtime library (which does not provide the GNAT.Traceback package).
- Written in-memory runtime tracing log facility that is persisten across system resets.
- Written Pin Muxer, GPIO and UART drivers for the Kinetis KL25Z MCU
- Written full-screen (VT100) serial console and command-line facilities on top of the UART driver.
- Architected a framework for developing control algorithms for the NXP cup race car (see project overview slides). Although I ran out of time to complete the implementation before the deadline for Make-with-Ada, I will continue working until it is finished, as outlined in the future plans section below.
- Approximate amount of code written to date: Line metrics summed over 59 units all lines : 7779 code lines : 3981 comment lines : 2708 end-of-line comments : 11 comment percentage : 40.64 blank lines : 1090 These numbers were gathered with the GNAT metrics tool on the frdmkl25zautonomous_car project. These numbers do not include code written to port The GNAT Ravenscar SFP runtime library to the target platform.
- Write PWM, periodic timer and A/D converter drivers for the Kinetis KL25Z MCU
- Write Line-scan camera driver on top of the A/D converter
- Write servo and DC motor drivers on top of the PWM driver
- Implement the Autonomous Car control framework
- Write I2C driver for the Kinetis KL25Z MCU
- Write Accelerometer driver on top of the I2C driver
- Enhance control framework by using accelerometer data
- My Project is under the BSD license
- It's hosted on Github. The project is divided in two repositories:
- gnat-runtime-libs-for-kinetis-microcontrollersThis repository contains ports of the GNAT Ravenscar-SFP Runtime Library for the two NXP Kinetis micrcontrollers I used for my two *Make with Ada" projects.
- make-with-adaThis repository contains therest of the code I wrote for my two Make with Ada projects, on top of the GNAT Ravenscar-SFP Runtime Library.
- I used the GNAT GPL 2016 toolchain - ARM ELF format (hosted on Windows), including the GPS IDE. I also used the svd2ada tool to generate Ada code from SVD XML files for the Kinetis micrcontrollers I used.
- I submitted a pull request to the GNAT Embedded Runtimes Project (embedded-runtimes GitHub repository) to contribute the three ports of the GNAT Ravenscar SFP runtime that I made as part of my "Make-with-Ada" project work (see pull request).
- I helped improve the svd2ada tool by submitted two bugs I found when using it.
- I developed several device drivers for several peripherals for the target boards I used, that can be easily reused. I plan to submit them to the Ada Drivers Library GitHub project.
- I have structured the Ada code of my project in a way that decouples the platform indpendent portions from the MCU specific and board-specfic portions (see Source Code Architecture diagrams). This will enable others to reuse portions of this code and port it to other platforms.
- Disciplined use of information hiding principles to architect the code to ensure high levels of maintainability and portability, and to avoid code duplication across projects and across platforms.
- Leveraged extensively the data encapsulation and modularity features of the Ada language such as private types and child units including private child units, and in some cases subunits and nested subprograms.
- Used gnatdoc comments to document key data structures and subprograms
- Used Ada 2012 contract-based programming features and assertions extensively
- Used range-based types extensively to leverage the Ada power to detect invalid integer values.
- Used Ada 2012 aspect constructs wherever possible
- Used GNAT coding style. I use the
-gnaty3abcdefhiklmnoOprstux
GNAT compiler option to chekc compliance with this standard. (I ran out of time to clean style warnings in some files, but I intend to have all the code compliant)
- Used GNAT flags to enable rigorous compile-time checks, such as
-gnato13 -gnatf -gnatwa -gnatVa -Wall
.
- I developed an extension to the GNAT runtime library to provide a mechanism to count system resets (see reset_counter.ads and linker script changes). On top of this, I built a facility to provide in-memory runtime logs whose contents persist across resets (see runtime_logs.ads).
- I developed a stack trace capture facility for non-full flavors for the Ravenscar runtime. This facility does not depend on traceback tables (see [stacktracecapture.ads] (https://github.com/jgrivera67/make-with-ada/blob/master/buildingblocks/portable/stacktracecapture.ads)). I used this facility to enhance the diagnostics information captured in the LastChanceHandler routine, by capturing a raw stack trace for the exception that trigger the LastChance_Handler call. This combined with reset-persistent runtime logs can be a very valuable first-failure-data-capture aid for production code.
Project Achievements (version 3)
Summary of Accomplishments to Date- Ported GNAT Ravenscar SFP Runtime library to the FRDM-KL25Z board.
- Written System reset counter facility integrated into the GNAT Runtime library
- Written a stack trace capture facility to help debug code that use the small foot print or zero foot print flavors of the GNAT Ravenscar Runtime library (which does not provide the GNAT.Traceback package).
- Written in-memory runtime tracing log facility that is persisten across system resets.
- Written Pin Muxer, GPIO and UART drivers for the Kinetis KL25Z MCU
- Written full-screen (VT100) serial console and command-line facilities on top of the UART driver.
- Architected a framework for developing control algorithms for the NXP cup race car (see project overview slides). Although I ran out of time to complete the implementation before the deadline for Make-with-Ada, I will continue working until it is finished, as outlined in the future plans section below.
- Approximate amount of code written to date: Line metrics summed over 59 units all lines : 7779 code lines : 3981 comment lines : 2708 end-of-line comments : 11 comment percentage : 40.64 blank lines : 1090 These numbers were gathered with the GNAT metrics tool on the frdmkl25zautonomous_car project. These numbers do not include code written to port The GNAT Ravenscar SFP runtime library to the target platform.
- Write PWM, periodic timer and A/D converter drivers for the Kinetis KL25Z MCU
- Write Line-scan camera driver on top of the A/D converter
- Write servo and DC motor drivers on top of the PWM driver
- Implement the Autonomous Car control framework
- Write I2C driver for the Kinetis KL25Z MCU
- Write Accelerometer driver on top of the I2C driver
- Enhance control framework by using accelerometer data
- My Project is under the BSD license
- It's hosted on Github. The project is divided in two repositories:
- gnat-runtime-libs-for-kinetis-microcontrollersThis repository contains ports of the GNAT Ravenscar-SFP Runtime Library for the two NXP Kinetis micrcontrollers I used for my two *Make with Ada" projects.
- make-with-adaThis repository contains therest of the code I wrote for my two Make with Ada projects, on top of the GNAT Ravenscar-SFP Runtime Library.
- I used the GNAT GPL 2016 toolchain - ARM ELF format (hosted on Windows), including the GPS IDE. I also used the svd2ada tool to generate Ada code from SVD XML files for the Kinetis micrcontrollers I used.
- I submitted a pull request to the GNAT Embedded Runtimes Project (embedded-runtimes GitHub repository) to contribute the three ports of the GNAT Ravenscar SFP runtime that I made as part of my "Make-with-Ada" project work (see pull request).
- I helped improve the svd2ada tool by submitted two bugs I found when using it.
- I developed several device drivers for several peripherals for the target boards I used, that can be easily reused. I plan to submit them to the Ada Drivers Library GitHub project.
- I have structured the Ada code of my project in a way that decouples the platform indpendent portions from the MCU specific and board-specfic portions (see Source Code Architecture diagrams). This will enable others to reuse portions of this code and port it to other platforms.
- Disciplined use of information hiding principles to architect the code to ensure high levels of maintainability and portability, and to avoid code duplication across projects and across platforms. Indeed, there is a lot of code sharing with my other project (see IoT Networking Stack project).
- Leveraged extensively the data encapsulation and modularity features of the Ada language such as private types and child units including private child units, and in some cases subunits and nested subprograms.
- Used gnatdoc comments to document key data structures and subprograms
- Used Ada 2012 contract-based programming features and assertions extensively
- Used range-based types extensively to leverage the Ada power to detect invalid integer values.
- Used Ada 2012 aspect constructs wherever possible
- Used GNAT coding style. I use the
-gnaty3abcdefhiklmnoOprstux
GNAT compiler option to chekc compliance with this standard. (I ran out of time to clean style warnings in some files, but I intend to have all the code compliant)
- Used GNAT flags to enable rigorous compile-time checks, such as
-gnato13 -gnatf -gnatwa -gnatVa -Wall
.
- I developed an extension to the GNAT runtime library to provide a mechanism to count system resets (see reset_counter.ads and linker script changes). On top of this, I built a facility to provide in-memory runtime logs whose contents persist across resets (see runtime_logs.ads).
- I developed a stack trace capture facility for non-full flavors for the Ravenscar runtime. This facility does not depend on traceback tables (see [stacktracecapture.ads] (https://github.com/jgrivera67/make-with-ada/blob/master/buildingblocks/portable/stacktracecapture.ads)). I used this facility to enhance the diagnostics information captured in the LastChanceHandler routine, by capturing a raw stack trace for the exception that trigger the LastChance_Handler call. This combined with reset-persistent runtime logs can be a very valuable first-failure-data-capture aid for production code.
- Ported GNAT Ravenscar SFP Runtime library to the FRDM-KL25Z board.
- Written System reset counter facility integrated into the GNAT Runtime library
- Written a stack trace capture facility to help debug code that use the small foot print or zero foot print flavors of the GNAT Ravenscar Runtime library (which does not provide the GNAT.Traceback package).
- Written in-memory runtime tracing log facility that is persisten across system resets.
- Written Pin Muxer, GPIO and UART drivers for the Kinetis KL25Z MCU
- Written full-screen (VT100) serial console and command-line facilities on top of the UART driver.
- Architected a framework for developing control algorithms for the NXP cup race car (see project overview slides). Although I ran out of time to complete the implementation before the deadline for Make-with-Ada, I will continue working until it is finished, as outlined in the future plans section below.
- Currently, I have an skeletal application with 3 tasks running on the FRDM-KL25Z. It proves that the GNAT Ravenscar SFP library can run on this memory-constrained MCU. This application consumes 11k out of the 16K of SRAM in the KL25Z. Although, 4K left for the real application is a little tight, past experience tells me that I can still fit the data structures for the completed application in the available SRAM.
- Approximate amount of code written to date: Line metrics summed over 59 units all lines : 7779 code lines : 3981 comment lines : 2708 end-of-line comments : 11 comment percentage : 40.64 blank lines : 1090 These numbers were gathered with the GNAT metrics tool on the frdmkl25zautonomous_car project. These numbers do not include code written to port The GNAT Ravenscar SFP runtime library to the target platform.
- Write PWM, periodic timer and A/D converter drivers for the Kinetis KL25Z MCU
- Write Line-scan camera driver on top of the A/D converter
- Write servo and DC motor drivers on top of the PWM driver
- Implement the Autonomous Car control framework
- Write I2C driver for the Kinetis KL25Z MCU
- Write Accelerometer driver on top of the I2C driver
- Enhance control framework by using accelerometer data
- My Project is under the BSD license
- It's hosted on Github. The project is divided in two repositories:
- gnat-runtime-libs-for-kinetis-microcontrollersThis repository contains ports of the GNAT Ravenscar-SFP Runtime Library for the two NXP Kinetis micrcontrollers I used for my two *Make with Ada" projects.
- make-with-adaThis repository contains therest of the code I wrote for my two Make with Ada projects, on top of the GNAT Ravenscar-SFP Runtime Library.
- I used the GNAT GPL 2016 toolchain - ARM ELF format (hosted on Windows), including the GPS IDE. I also used the svd2ada tool to generate Ada code from SVD XML files for the Kinetis micrcontrollers I used.
- I submitted a pull request to the GNAT Embedded Runtimes Project (embedded-runtimes GitHub repository) to contribute the FRDM-KL25Z port of the GNAT Ravenscar SFP runtime that I made (see pull request). This port is particularly important as until now the GNAT Ravenscar Runtimes for ARM only supported Cortex-M4 platforms. This is the first port that support a Cortex-M0+ platform. There are many low-power MCUs that use Cortex-M0+ core. So, having Ada running on Cortex-M0+ can be very useful.
- I helped improve the svd2ada tool by submitted two bugs I found when using it.
- I developed several device drivers for several peripherals for the target boards I used, that can be easily reused. I plan to submit them to the Ada Drivers Library GitHub project.
- I have structured the Ada code of my project in a way that decouples the platform independent portions from the MCU specific and board-specfic portions (see Source Code Architecture diagrams:1,2,3). This will enable others to reuse portions of this code and port it to other platforms.
- Disciplined use of information hiding principles to architect the code to ensure high levels of maintainability and portability, and to avoid code duplication across projects and across platforms. Indeed, there is a lot of code sharing with my other project (see IoT Networking Stack project).
- Leveraged extensively the data encapsulation and modularity features of the Ada language such as private types and child units including private child units, and in some cases subunits and nested subprograms.
- Used gnatdoc comments to document key data structures and subprograms
- Used Ada 2012 contract-based programming features and assertions extensively
- Used range-based types extensively to leverage the Ada power to detect invalid integer values.
- Used Ada 2012 aspect constructs wherever possible
- Used GNAT coding style. I use the
-gnaty3abcdefhiklmnoOprstux
GNAT compiler option to chekc compliance with this standard. (I ran out of time to clean style warnings in some files, but I intend to have all the code compliant)
- Used GNAT flags to enable rigorous compile-time checks, such as
-gnato13 -gnatf -gnatwa -gnatVa -Wall
.
- I developed an extension to the GNAT runtime library to provide a mechanism to count system resets (see reset_counter.ads and linker script changes). On top of this, I built a facility to provide in-memory runtime logs whose contents persist across resets (see runtime_logs.ads).
- I developed a stack trace capture facility for non-full flavors for the Ravenscar runtime. This facility does not depend on traceback tables (see [stacktracecapture.ads] (https://github.com/jgrivera67/make-with-ada/blob/master/buildingblocks/portable/stacktracecapture.ads)). It uses an innovative stack unwinding algorithm that traverses the call chain backwards, locating the "links" in the call chain by scanning backwards the machine instructions of a subprogram, looking for its prolog code sequence. I used this facility to enhance the diagnostics information captured in the LastChanceHandler routine, by capturing a raw stack trace for the exception that trigger the LastChance_Handler call. This combined with reset-persistent runtime logs can be a very valuable first-failure-data-capture aid for production code.
Comments