From 91eff5154b25701d95ccd77f09e5bf5a9639f051 Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Mon, 28 May 2018 20:49:25 +0200 Subject: [PATCH 01/11] Semihosting.Filesystem: Fix unreferenced param warning --- arch/ARM/cortex_m/src/semihosting-filesystem.adb | 16 ++++++++++++++++ arch/ARM/cortex_m/src/semihosting-filesystem.ads | 3 +-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/arch/ARM/cortex_m/src/semihosting-filesystem.adb b/arch/ARM/cortex_m/src/semihosting-filesystem.adb index 428b8a758..91ebc069a 100644 --- a/arch/ARM/cortex_m/src/semihosting-filesystem.adb +++ b/arch/ARM/cortex_m/src/semihosting-filesystem.adb @@ -190,6 +190,22 @@ package body Semihosting.Filesystem is return Operation_Not_Permitted; end Open; + --------------- + -- Root_Node -- + --------------- + + overriding + function Root_Node + (This : in out SHFS; + As : String; + Handle : out Any_Node_Handle) + return Status_Code + is + pragma Unreferenced (As, Handle, This); + begin + return Operation_Not_Permitted; + end Root_Node; + --------------------- -- Get_File_Handle -- --------------------- diff --git a/arch/ARM/cortex_m/src/semihosting-filesystem.ads b/arch/ARM/cortex_m/src/semihosting-filesystem.ads index 812dd06ca..ce38cd790 100644 --- a/arch/ARM/cortex_m/src/semihosting-filesystem.ads +++ b/arch/ARM/cortex_m/src/semihosting-filesystem.ads @@ -100,8 +100,7 @@ package Semihosting.Filesystem is (This : in out SHFS; As : String; Handle : out Any_Node_Handle) - return Status_Code - is (Operation_Not_Permitted); + return Status_Code; overriding procedure Close (This : in out SHFS); From dac5ef5d7fe821b32a8cd1406824d1867a2e2048 Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Mon, 28 May 2018 19:33:23 +0200 Subject: [PATCH 02/11] HiFive1 example: Update for GNAT Community 2018 --- examples/HiFive1/hifive1_example.gpr | 4 ++-- scripts/install_dependencies.py | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/examples/HiFive1/hifive1_example.gpr b/examples/HiFive1/hifive1_example.gpr index 53224da30..802fc63cd 100644 --- a/examples/HiFive1/hifive1_example.gpr +++ b/examples/HiFive1/hifive1_example.gpr @@ -2,8 +2,8 @@ with "../../boards/HiFive1/hifive1_zfp.gpr"; project HiFive1_Example is - for Runtime ("ada") use Project'Project_Dir & "/zfp-hifive1"; - for Target use "riscv32-unknown-elf"; + for Runtime ("ada") use "zfp-hifive1"; + for Target use "riscv32-elf"; for Main use ("main.adb"); for Languages use ("Ada"); for Source_Dirs use ("src"); diff --git a/scripts/install_dependencies.py b/scripts/install_dependencies.py index a7e3bad6a..55012af8e 100755 --- a/scripts/install_dependencies.py +++ b/scripts/install_dependencies.py @@ -78,12 +78,6 @@ def git_clone(repo_url, branch, dst, recursive=False): "examples/MicroBit/zfp-nrf51", False, None), - - ("https://github.com/Fabien-Chouteau/zfp-hifive1.git", - None, - "examples/HiFive1/zfp-hifive1", - False, - None) ] parser = argparse.ArgumentParser('Download and install dependencies') From 4393bb829dd40238b5084583ae621fefa30de7f9 Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Mon, 28 May 2018 21:12:30 +0200 Subject: [PATCH 03/11] Micro:bit example: Update for GNAT Community 2018 --- arch/ARM/Nordic/drivers/nrf51-interrupts.adb | 41 +++++++++++++++++++- arch/ARM/Nordic/drivers/nrf51-interrupts.ads | 7 ++++ boards/MicroBit/microbit_zfp.gpr | 6 +-- boards/MicroBit/src/microbit-time.adb | 4 +- boards/MicroBit/src/zfp/adl_config.ads | 4 +- examples/MicroBit/microbit_example.gpr | 2 +- scripts/config/boards.py | 2 +- scripts/install_dependencies.py | 6 --- 8 files changed, 57 insertions(+), 15 deletions(-) diff --git a/arch/ARM/Nordic/drivers/nrf51-interrupts.adb b/arch/ARM/Nordic/drivers/nrf51-interrupts.adb index 4811c72ef..11886288d 100644 --- a/arch/ARM/Nordic/drivers/nrf51-interrupts.adb +++ b/arch/ARM/Nordic/drivers/nrf51-interrupts.adb @@ -1,6 +1,6 @@ ------------------------------------------------------------------------------ -- -- --- Copyright (C) 2016, AdaCore -- +-- Copyright (C) 2016-2018, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- @@ -30,9 +30,16 @@ ------------------------------------------------------------------------------ with Cortex_M.NVIC; +with System.Machine_Code; use System.Machine_Code; package body nRF51.Interrupts is + Handlers : array (nRF51.Interrupts.Interrupt_Name) of Handler + := (others => null); + + procedure GNAT_IRQ_Handler; + pragma Export (Asm, GNAT_IRQ_Handler, "__gnat_irq_trap"); + ------------------ -- Set_Priority -- ------------------ @@ -69,4 +76,36 @@ package body nRF51.Interrupts is return Cortex_M.NVIC.Pending (Int'Enum_Rep); end Pending; + -------------- + -- Register -- + -------------- + + procedure Register (Id : nRF51.Interrupts.Interrupt_Name; + Hdl : Handler) + is + begin + Handlers (Id) := Hdl; + end Register; + + ---------------------- + -- GNAT_IRQ_Handler -- + ---------------------- + + procedure GNAT_IRQ_Handler is + Id : nRF51.Interrupts.Interrupt_Name; + IPSR : UInt32; + begin + Asm ("mrs %0, ipsr", + UInt32'Asm_Output ("=r", IPSR), + Volatile => True); + + IPSR := IPSR and 16#FF#; + + Id := nRF51.Interrupts.Interrupt_Name'Val (IPSR - 16); + + if Handlers (Id) /= null then + Handlers (Id).all; + end if; + end GNAT_IRQ_Handler; + end nRF51.Interrupts; diff --git a/arch/ARM/Nordic/drivers/nrf51-interrupts.ads b/arch/ARM/Nordic/drivers/nrf51-interrupts.ads index 8a816d4c0..fe80487bc 100644 --- a/arch/ARM/Nordic/drivers/nrf51-interrupts.ads +++ b/arch/ARM/Nordic/drivers/nrf51-interrupts.ads @@ -73,6 +73,13 @@ package nRF51.Interrupts is procedure Disable (Int : Interrupt_Name); function Pending (Int : Interrupt_Name) return Boolean; + type Handler is access procedure; + + procedure Register (Id : nRF51.Interrupts.Interrupt_Name; + Hdl : Handler); + -- Register a handler for the given interrupt. There can be only one handler + -- for each interrupt so the previous one, if any, will be removed. + private for Interrupt_Name use (POWER_CLOCK_Interrupt => 0, diff --git a/boards/MicroBit/microbit_zfp.gpr b/boards/MicroBit/microbit_zfp.gpr index 32cd9ccb2..0202dd501 100644 --- a/boards/MicroBit/microbit_zfp.gpr +++ b/boards/MicroBit/microbit_zfp.gpr @@ -37,7 +37,7 @@ library project MicroBit_ZFP is for Library_Kind use "static"; for Library_Name use "ada_drivers_library"; for Target use "arm-eabi"; - for Runtime ("Ada") use "zfp-nrf51"; + for Runtime ("Ada") use "zfp-microbit"; Vendor := "Nordic"; -- From board definition Max_Mount_Points := "2"; -- From default value @@ -45,14 +45,14 @@ library project MicroBit_ZFP is Runtime_Profile := "zfp"; -- From command line Device_Name := "nRF51822xxAA"; -- From board definition Device_Family := "nRF51"; -- From board definition - Runtime_Name := "zfp-nrf51"; -- From default value + Runtime_Name := "zfp-microbit"; -- From default value Has_Ravenscar_Full_Runtime := "False"; -- From board definition CPU_Core := "ARM Cortex-M0"; -- From mcu definition Board := "MicroBit"; -- From command line Has_ZFP_Runtime := "True"; -- From board definition Has_Ravenscar_SFP_Runtime := "False"; -- From board definition Max_Path_Length := "1024"; -- From default value - Runtime_Name_Suffix := "nrf51"; -- From board definition + Runtime_Name_Suffix := "microbit"; -- From board definition Architecture := "ARM"; -- From board definition -- Project source directories diff --git a/boards/MicroBit/src/microbit-time.adb b/boards/MicroBit/src/microbit-time.adb index c01675f90..5a1ebddf3 100644 --- a/boards/MicroBit/src/microbit-time.adb +++ b/boards/MicroBit/src/microbit-time.adb @@ -48,7 +48,6 @@ package body MicroBit.Time is procedure Initialize; procedure Update_Clock; procedure RTC1_IRQHandler; - pragma Export (C, RTC1_IRQHandler, "RTC1_IRQHandler"); ---------------- -- Initialize -- @@ -75,6 +74,9 @@ package body MicroBit.Time is nRF51.Events.Enable_Interrupt (nRF51.Events.RTC_1_COMPARE_0); + nRF51.Interrupts.Register (nRF51.Interrupts.RTC1_Interrupt, + RTC1_IRQHandler'Access); + nRF51.Interrupts.Enable (nRF51.Interrupts.RTC1_Interrupt); Start (RTC_1); diff --git a/boards/MicroBit/src/zfp/adl_config.ads b/boards/MicroBit/src/zfp/adl_config.ads index 972415dff..db3a2e122 100644 --- a/boards/MicroBit/src/zfp/adl_config.ads +++ b/boards/MicroBit/src/zfp/adl_config.ads @@ -6,13 +6,13 @@ package ADL_Config is Runtime_Profile : constant String := "zfp"; -- From command line Device_Name : constant String := "nRF51822xxAA"; -- From board definition Device_Family : constant String := "nRF51"; -- From board definition - Runtime_Name : constant String := "zfp-nrf51"; -- From default value + Runtime_Name : constant String := "zfp-microbit"; -- From default value Has_Ravenscar_Full_Runtime : constant String := "False"; -- From board definition CPU_Core : constant String := "ARM Cortex-M0"; -- From mcu definition Board : constant String := "MicroBit"; -- From command line Has_ZFP_Runtime : constant String := "True"; -- From board definition Has_Ravenscar_SFP_Runtime : constant String := "False"; -- From board definition Max_Path_Length : constant := 1024; -- From default value - Runtime_Name_Suffix : constant String := "nrf51"; -- From board definition + Runtime_Name_Suffix : constant String := "microbit"; -- From board definition Architecture : constant String := "ARM"; -- From board definition end ADL_Config; diff --git a/examples/MicroBit/microbit_example.gpr b/examples/MicroBit/microbit_example.gpr index dec2a8a2e..5ffbc97f0 100644 --- a/examples/MicroBit/microbit_example.gpr +++ b/examples/MicroBit/microbit_example.gpr @@ -2,7 +2,7 @@ with "../../boards/MicroBit/microbit_zfp.gpr"; project MicroBit_Example is - for Runtime ("ada") use Project'Project_Dir & "/zfp-nrf51"; + for Runtime ("ada") use "zfp-microbit"; for Target use "arm-eabi"; for Main use ("main.adb"); for Languages use ("Ada"); diff --git a/scripts/config/boards.py b/scripts/config/boards.py index d6434f828..d029b5f72 100644 --- a/scripts/config/boards.py +++ b/scripts/config/boards.py @@ -131,7 +131,7 @@ def load_board_config(config): config.pre_define('Has_ZFP_Runtime', 'True', origin) config.pre_define('Has_Ravenscar_SFP_Runtime', 'False', origin) config.pre_define('Has_Ravenscar_Full_Runtime', 'False', origin) - config.pre_define('Runtime_Name_Suffix', 'nrf51', origin) + config.pre_define('Runtime_Name_Suffix', 'microbit', origin) config.add_source_dir('boards/MicroBit/src/', origin) elif board == "HiFive1": diff --git a/scripts/install_dependencies.py b/scripts/install_dependencies.py index 55012af8e..42739d67d 100755 --- a/scripts/install_dependencies.py +++ b/scripts/install_dependencies.py @@ -72,12 +72,6 @@ def git_clone(repo_url, branch, dst, recursive=False): "embedded-runtimes", False, ["python", ROOT_DIR + "/embedded-runtimes/install.py"]), - - ("https://github.com/Fabien-Chouteau/zfp-nrf51", - None, - "examples/MicroBit/zfp-nrf51", - False, - None), ] parser = argparse.ArgumentParser('Download and install dependencies') From 30c03009262cf177b230a90c6034ea8a47b8ecdc Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Mon, 25 Jun 2018 16:02:08 +0200 Subject: [PATCH 04/11] scripts/install_dependencies.py: Update for community-2018 branch --- scripts/install_dependencies.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/install_dependencies.py b/scripts/install_dependencies.py index 42739d67d..7d3213e4f 100755 --- a/scripts/install_dependencies.py +++ b/scripts/install_dependencies.py @@ -9,10 +9,11 @@ ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../')) -def run_program(*argv): +def run_program(argv, cwd=os.path.dirname(os.path.realpath(__file__))): print "$ %s" % " ".join(argv) p = subprocess.Popen( argv, + cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) @@ -39,8 +40,7 @@ def git_clone(repo_url, branch, dst, recursive=False): # Clone the repo returncode, stdout, stderr = run_program( - 'git', 'clone', repo_url, dst, *extra_args - ) + ['git', 'clone', repo_url, dst] + extra_args) print stdout if returncode: @@ -67,11 +67,11 @@ def git_clone(repo_url, branch, dst, recursive=False): # - Destination directory # - Recursive clone? # - install command (if any) -git_repos = [("https://github.com/AdaCore/embedded-runtimes", - "gpl2017_uninstall", - "embedded-runtimes", +git_repos = [("https://github.com/AdaCore/bb-runtimes", + None, + "bb-runtimes", False, - ["python", ROOT_DIR + "/embedded-runtimes/install.py"]), + ["python", ROOT_DIR + "/bb-runtimes/install.py", "--arch=arm-eabi"]), ] parser = argparse.ArgumentParser('Download and install dependencies') @@ -104,7 +104,7 @@ def main(args): if build_cmd: print "Running build command:" - ret, stdout, stderr = run_program(*build_cmd) + ret, stdout, stderr = run_program(build_cmd, dest) print stdout From cd24698ba3e8ffee1e68a82b6504e69bc65ad6f2 Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Mon, 25 Jun 2018 16:03:04 +0200 Subject: [PATCH 05/11] STM32F429: Fix example project files --- examples/STM32F429_Discovery/dma2d_stm32f429disco.gpr | 2 +- examples/STM32F429_Discovery/draw_stm32f429disco.gpr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/STM32F429_Discovery/dma2d_stm32f429disco.gpr b/examples/STM32F429_Discovery/dma2d_stm32f429disco.gpr index 1d012e94f..431e98822 100644 --- a/examples/STM32F429_Discovery/dma2d_stm32f429disco.gpr +++ b/examples/STM32F429_Discovery/dma2d_stm32f429disco.gpr @@ -11,7 +11,7 @@ project Dma2d_STM32F429Disco extends "../shared/common/common.gpr" is package Linker is for Default_Switches ("ada") use - ("-gc-section", "-Wl,--print-memory-usage"); + ("-Wl,-gc-section", "-Wl,--print-memory-usage"); end Linker; package Compiler renames STM32F429_Discovery_Full.Compiler; diff --git a/examples/STM32F429_Discovery/draw_stm32f429disco.gpr b/examples/STM32F429_Discovery/draw_stm32f429disco.gpr index 84d51c24c..2d20f31e3 100644 --- a/examples/STM32F429_Discovery/draw_stm32f429disco.gpr +++ b/examples/STM32F429_Discovery/draw_stm32f429disco.gpr @@ -11,7 +11,7 @@ project Draw_STM32F429Disco extends "../shared/common/common.gpr" is package Linker is for Default_Switches ("ada") use - ("-gc-section", "-Wl,--print-memory-usage"); + ("-Wl,-gc-section", "-Wl,--print-memory-usage"); end Linker; package Compiler renames STM32F429_Discovery_Full.Compiler; From 74216b4ce8cb966fbc8c61adf07578db5b07932c Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Tue, 3 Jul 2018 17:58:15 +0200 Subject: [PATCH 06/11] Update CI scripts for Travis and Appveyor --- .appveyor.yml | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ .travis.yml | 26 ++++++++++++++----- appveyor.yml | 56 ----------------------------------------- 3 files changed, 89 insertions(+), 62 deletions(-) create mode 100644 .appveyor.yml delete mode 100644 appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 000000000..10ac8fca0 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,69 @@ +# Appveyor continuous builder configuration + +# Version format, we don't have version number for ADL yet +version: 0.0.{build} + +# Setup python for build and test-suite scripts +environment: + PYTHON: C:\\Python27 + TOOLS_DIR: C:\ADL_tools\ + GNAT_NATIVE_INSTALLER: C:\ADL_tools\gnat-community-2018-x86_64-windows-bin.exe + GNAT_ARM_ELF_INSTALLER: C:\ADL_tools\gnat-community-2018-arm-elf-windows-bin.exe + INSTALL_DIR: C:\Install\ + INSTALL_CONTROL_SCRIPT: C:\projects\ada-drivers-library\scripts\GNAT_CE_2018_install_control.qs + +# Cache directories will be preseved from one build to the other +cache: + - C:\ADL_tools + +on_failure: + - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + +install: +# Show current dir and its content +- cmd: cd +- cmd: dir + +# Create the tool dir if it doesn't exists +- ps: md -f $env:TOOLS_DIR +- ps: md -f $env:INSTALL_DIR + +# Show content of tool dir +- cmd: dir %TOOLS_DIR% +- cmd: dir %INSTALL_DIR% + +# Download compiler installer if not already in the tool dir +- ps: If (Test-Path $env:GNAT_NATIVE_INSTALLER){echo compiler already in cache}Else{(new-object net.webclient).DownloadFile('http://mirrors.cdn.adacore.com/art/5b30f4e6c7a4477116360355', $env:GNAT_NATIVE_INSTALLER)} +- ps: If (Test-Path $env:GNAT_ARM_ELF_INSTALLER){echo compiler already in cache}Else{(new-object net.webclient).DownloadFile('http://mirrors.cdn.adacore.com/art/5b0843e7a3f5d75c215f46b6', $env:GNAT_ARM_ELF_INSTALLER)} + +# Show content of tool dir again so we can see if the download was ok +- cmd: dir %TOOLS_DIR% + +- ps: Invoke-WebRequest https://raw.githubusercontent.com/AdaCore/gnat_community_install_script/master/install_package.bat -OutFile install_package.bat +- ps: Invoke-WebRequest https://raw.githubusercontent.com/AdaCore/gnat_community_install_script/master/install_script.qs -OutFile install_script.qs + +# Install the compilers +- cmd: install_package.bat %GNAT_NATIVE_INSTALLER% C:\Install\native +- cmd: install_package.bat %GNAT_ARM_ELF_INSTALLER% C:\Install\arm-elf + +# Show content of install dir so we can see if install was ok +- cmd: dir %INSTALL_DIR% +- cmd: dir C:\Install\ + +# Add compiler to the PATH +- ps: $env:Path += ";" + $env:INSTALL_DIR +"\native\bin" +- ps: $env:Path += ";" + $env:INSTALL_DIR +"\arm-elf\bin" + +# Check that we can run the compiler (also display the version) +- ps: arm-eabi-gnatls -v + +# Install optional dependencies +- cmd: python scripts/install_dependencies.py + +# We don't need a build step +build: off + +# Run the test scripts +test_script: +- cmd: python scripts/build_all_examples.py +- cmd: python testsuite/run.py diff --git a/.travis.yml b/.travis.yml index bc32c287e..460ed0b4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,9 @@ python: env: global: - TOOLS_DIR=$HOME/build_tools - - GNAT_TAR_PATH=$TOOLS_DIR/gnat-gpl-2017-x86_64-linux-bin.tar.gz + - GNAT_BIN_PATH=$TOOLS_DIR/gnat-community-2018-x86_64-linux-bin + - GNAT_ARM_BIN_PATH=$TOOLS_DIR/gnat-community-2018-arm-elf-bin + - INSTALL_CONTROL_SCRIPT=$PWD/scripts/GNAT_CE_2018_install_control.qs os: - linux @@ -21,17 +23,29 @@ cache: install: # Check if the GNAT package is already available in the cache directory. If # not, download it. - - test -f $GNAT_TAR_PATH ||( mkdir -p $TOOLS_DIR && wget http://mirrors.cdn.adacore.com/art/591c6d80c7a447af2deed1d7 -O $GNAT_TAR_PATH) + - test -f $GNAT_BIN_PATH ||( mkdir -p $TOOLS_DIR && wget http://mirrors.cdn.adacore.com/art/5b0d7bffa3f5d709751e3e04 -O $GNAT_BIN_PATH) + - test -f $GNAT_ARM_BIN_PATH ||( mkdir -p $TOOLS_DIR && wget http://mirrors.cdn.adacore.com/art/5b0c1227a3f5d7097625478d -O $GNAT_ARM_BIN_PATH) - # Extract GNAT from its package - - tar -xf $GNAT_TAR_PATH + - wget https://raw.githubusercontent.com/AdaCore/gnat_community_install_script/master/install_package.sh + - wget https://raw.githubusercontent.com/AdaCore/gnat_community_install_script/master/install_script.qs + + - sh install_package.sh $GNAT_BIN_PATH $TOOLS_DIR/native/ + - sh install_package.sh $GNAT_ARM_BIN_PATH $TOOLS_DIR/arm-elf/ # Add GNAT to $PATH - - export PATH=$PATH:$PWD/gnat-gpl-2017-x86_64-linux-bin/bin/ + - export PATH=$PATH:$TOOLS_DIR/native/bin/ + - export PATH=$PATH:$TOOLS_DIR/arm-elf/bin/ script: # Show GNAT version for the record - - $PWD/gnat-gpl-2017-x86_64-linux-bin/bin/gprbuild --version + - $TOOLS_DIR/native/bin/gprbuild --version + - $TOOLS_DIR/arm-elf/bin/gprbuild --version + + # Install extra run-times + - python $PWD/scripts/install_dependencies.py + + # Build all examples + - python $PWD/scripts/build_all_examples.py # Start the testsuite - python $PWD/testsuite/run.py diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 284ddc4da..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,56 +0,0 @@ -# Appveyor continuous builder configuration - -# Version format, we don't have version number for ADL yet -version: 0.0.{build} - -# Setup python for build and test-suite scripts -environment: - PYTHON: C:\\Python27 - TOOLS_DIR: C:\ADL_tools\ - GNAT_ARM_ELF_INSTALLER: C:\ADL_tools\gnat-gpl-2017-arm-elf-windows-bin.exe - INSTALL_DIR: C:\Install\ - -# Cache directories will be preseved from one build to the other -cache: - - C:\ADL_tools - -install: -# Show current dir and its content -- cmd: cd -- cmd: dir - -# Create the tool dir if it doesn't exists -- ps: md -f $env:TOOLS_DIR -- ps: md -f $env:INSTALL_DIR - -# Show content of tool dir -- cmd: dir %TOOLS_DIR% -- cmd: dir %INSTALL_DIR% - -# Download compiler installer if not already in the tool dir -- ps: If (Test-Path $env:GNAT_ARM_ELF_INSTALLER){echo compiler already in cache}Else{(new-object net.webclient).DownloadFile('http://mirrors.cdn.adacore.com/art/591cd401a3f5d779efba822d', $env:GNAT_ARM_ELF_INSTALLER)} - -# Show content of tool dir again so we can see if the download was ok -- cmd: dir %TOOLS_DIR% - -# Install the compiler -- cmd: cmd /c start /wait %GNAT_ARM_ELF_INSTALLER% /S /D=%INSTALL_DIR% - -# Show content of install dir so we can see if install was ok -- cmd: dir %INSTALL_DIR% - -# Add compiler to the PATH -- ps: $env:Path += ";" + $env:INSTALL_DIR +"bin" - -# Check that we can run the compiler (also display the version) -- ps: arm-eabi-gnatls -v - -# Install optional dependencies -- cmd: python scripts/install_dependencies.py - -# We don't need a build step -build: off - -# Run the test script(s) -test_script: -- cmd: python scripts/build_all_examples.py From 3fa7c1a5939a27fa1916309a6e178a962fb318e9 Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Thu, 28 Jun 2018 16:22:45 +0200 Subject: [PATCH 07/11] Update README.md --- README.md | 56 +++++++++++++++++++++---------------------------------- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 2b3fb538b..a5c40037a 100644 --- a/README.md +++ b/README.md @@ -3,18 +3,25 @@ # 1. Introduction -This repository contains Ada source code and complete sample GNAT projects for -selected bare-board platforms supported by GNAT. Initially the repository -contains software for ARM platforms from a specific vendor, but we intend this -to be a location for both AdaCore and the community in general to contribute -support for additional processors, platforms, and vendors. +This repository contains drivers and sample projects to program +micro-controllers with the Ada and SPARK languages. The library also provides +some middleware services and drivers for external devices such as sensors. We +intend this to be a location for both AdaCore and the community in general to +contribute support for additional processors, platforms, and vendors. -# 2. Getting started +# 3. Supported hardware -To start using the Ada_Drivers_Library, please go to the [examples directory](examples/) -where you will find instructions to run your first project. +Ada_Drivers_Library provides support for various devices in the ARM Cortex-M +and RISC-V architectures. Some devices are only partially supported. Go to the +[boards directory](boards/) for a list of supported hardware. -# 3. License +# 3. Getting started + +To start using the Ada_Drivers_Library, please go to the [examples +directory](examples/) where you will find instructions to run your first +project. + +# 4. License All files are provided under a 3-clause Berkeley Software Distribution (BSD) license. As such, and within the conditions required by the license, the files @@ -22,7 +29,7 @@ are available both for proprietary ("commercial") and non-proprietary use. For details, see the `LICENSE` file in the root directory. -# 4. Requirements +# 5. Requirements The software is written in Ada 2012 and uses, for example, preconditions, postconditions, and the high-level iterator form of for-loops. @@ -35,31 +42,9 @@ wishing to submit additions to the library should see the GNAT Reference Manual for details. Therefore, building with the sources requires a compiler supporting both Ada -2012 and the GNAT-defined pragma `Volatile_Full_Access`. The "GNAT GPL 2017" -compiler for ARM ELF is one such compiler [(Download it -here)](http://libre.adacore.com/download/configurations). A recent GNAT Pro -compiler for that target will also suffice. - -# 5. Content - -Initial provision is for the hardware in the STM32F4 family of 32-bit MCUs, as -defined in the "RM0090 Reference Manual" (Doc ID 018909 Rev 6, Feb 2014) by -STMicroelectronics and made available on the "STM32F4 Discovery" and the -"STM32F429 Discovery" kit boards. - -Specifically, there are low-level device drivers, higher-level component drivers, -small demonstration programs for the drivers, and larger example applications. -"Component" drivers are those that are implemented using the lower-level device -drivers (e.g., SPI or GPIO), such as the gyroscope and accelerometer on the -Discovery boards. - -The small driver demonstration programs and the larger applications programs are -provided as full projects, including GNAT project files, and are ready to build -either within GPS or on the command-line. - -Not all devices defined by the Reference Manual are supported, and not all those -supported are complete. We encourage contributions of corrections, enhancements, -and new drivers. +2012 and the GNAT-defined pragma `Volatile_Full_Access`. For instance a recent +GNAT Pro compiler or GNAT Community 2018 for ARM ELF or RISC-V ELF [(Download +here)](http://adacore.com/download). # 6. Roadmap @@ -91,3 +76,4 @@ https://github.com/AdaCore/Lunar_Lander_Rotation_Demo) * [Bare metal sudoku solver](https://github.com/stangassinger/sudoku) (Add yours to the list!) + From 6bec366fe17072e6bb376e29b0ad84a4d7079aae Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Thu, 28 Jun 2018 18:44:48 +0200 Subject: [PATCH 08/11] Update design.md --- docs/design.md | 70 +++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/docs/design.md b/docs/design.md index 8f96bebbc..35100286c 100644 --- a/docs/design.md +++ b/docs/design.md @@ -12,53 +12,59 @@ an nRF51 or even a Raspberry Pi running Linux. ## Overall architecture -There's 2 main logical parts in this project: +There are four main logical parts in this project: -Driver, it is where the low-level drivers for micro-controller features are -implemented. Examples: Timers, GPIO, I2C controllers, DMA, etc. -Middleware, it's a machine agnostic part that provides - or will provide - a -variety of service like bitmap drawing, communication stacks, file systems or -component drivers (more on that later). + - **`Driver`**, it is where the low-level drivers for micro-controller + peripherals are implemented. The low-level drivers are based on an hardware + mapping (generated by SVD2Ada) and provide a more easy to use and more safe + interface to the peripherals of a device. Examples: Timers, GPIO, I2C + controllers, DMA, etc. -| Driver | Middleware | -|-----------------------|-----------------------| -| Machine specific code | Machine agnostic code | + - **`Middleware`**, it is a machine agnostic part that provides a variety of + service like bitmap drawing, communication stacks, file systems or + component drivers (more on that later). -Middleware often needs to rely on Driver to provide its services. The HAL -(Hardware Abstraction Layer) defines interfaces to allow communication between -the two parts. The HAL is the heart of the project, seen and used by everything -so it's important that it remains as light as possible and depends only on -itself or on Ada features available on every configuration. For those reasons, -the HAL provides only definitions of features - using Ada interfaces - and no -implementation. + - **`HAL`**, `Middleware` often needs to rely on `Driver` to provide its + services. The HAL (Hardware Abstraction Layer) defines interfaces to allow + communication between the two parts. The HAL is the heart of the project, + seen and used by everything so it's important that it remains as light as + possible and depends only on itself or on Ada features available on every + configuration. For those reasons, the HAL provides only definitions of + features - using Ada interfaces - and no implementation. -Note that it is not a problem for the Driver code to use features of the -Middleware when necessary, however it's is crucial that Middleware never -directly depend on the Driver otherwise it's not agnostic anymore... + - **`Board support`**, it is a collection of packages that provide an easy + access to the features of a given board. For instance if a board has a + screen, an audio DAC or an accelerometer sensor. To do so they will use + both the `Driver` and `Middleware`. -Both part of the project can be quite large and they will continue to grow. -That is why we put in place subdivisions in the form of libraries. +Note that it is not a problem for the `Driver` code to use features of the +`Middleware` when necessary, however it's is crucial that `Middleware` never +directly depend on the `Driver` otherwise it's not machine agnostic anymore... -The drivers are divided by architectures, vendors and then chips. For the +The drivers are divided by architectures, vendors and then devices. For the moment we have: - * ARM - * STM32 - * STM32F40x - * STM32F7x9 - * ... - * Nordic - * nRF51 + * arch + * ARM + * STM32 + * STM32F40x + * STM32F7x9 + * ... + * Nordic + * nRF51 + * RISC-V + * SiFive + * FE310 -The most of the Middleware part is located in the middleware/ directory at the +Most of the `Middleware` part is located in the middleware/ directory at the root of the project. It is subdivided in Protocols, Bitmap_Drawings, Audio, Tools, etc. -There is also the Components library, it's a little bit special because it +There is also the `Components` library, it is a little bit special because it implements drivers for external chips (IO expander, gyro, thermal printer, etc). That doesn't sound very hardware agnostic, however the code can be used on any micro-controller. From a logical standpoint, it belongs in the machine agnostic part of the project. Because of this specificity and for historical -reason, The Components library has its own subdir in the root of the project. +reason, The `Components` library has its own subdir in the root of the project. It might move to the middleware/ directory at some point. From 6a182269e8c0049cc16c68dfb3811feed2d5158d Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Thu, 28 Jun 2018 19:06:25 +0200 Subject: [PATCH 09/11] Update examples/README.md --- examples/README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/README.md b/examples/README.md index 07239af06..fca7c6b4d 100644 --- a/examples/README.md +++ b/examples/README.md @@ -21,7 +21,8 @@ Most of the boards/micro-controller supported are based on the ARM Cortex-M architecture. If you have a GNAT Pro subscription, you can download the compiler (GNAT) and IDE (GNAT Programming Studio) from your account. Otherwise, AdaCore provides a community version of GNAT that you can download -[here](http://libre.adacore.com/download/configurations). +[here](http://adacore.com/download). We recomend to download the cross compiler +and also the native one because it contains the GNAT Programming Studio IDE. Follow the instructions to install GNAT and GPS. @@ -58,9 +59,11 @@ git clone --recursive https://github.com/AdaCore/Ada_Drivers_Library.git ## Build and install the run-times -Not all the GNAT run-times used in the Ada_Drivers_Library are packaged with the compiler. +Not all the GNAT run-times used in the Ada_Drivers_Library are packaged with +the compiler. -To build and install the missing run-times, use the `install_dependencies.py` script: +To build and install the missing run-times, use the `install_dependencies.py` +script: ```shell python ./scripts/install_dependencies.py @@ -91,8 +94,8 @@ For the STM32 board, use the "Flash to board" button in the tool bar. # ### We need your help -If you notice an error in these instructions, or if you want -to improve them, please go to [Ada_Drivers_Library GitHub +If you notice an error in these instructions, or if you want to improve them, +please go to [Ada_Drivers_Library GitHub repository](https://github.com/AdaCore/Ada_Drivers_Library). Thank you in advance. From e1568986c3630dd1b2313fe4d0843e21c91c32b7 Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Thu, 28 Jun 2018 19:19:40 +0200 Subject: [PATCH 10/11] Update examlpes/MicroBit/README.md --- examples/MicroBit/README.md | 86 +++++++++---------------------------- 1 file changed, 21 insertions(+), 65 deletions(-) diff --git a/examples/MicroBit/README.md b/examples/MicroBit/README.md index 4b4ec06e0..452bff0e0 100644 --- a/examples/MicroBit/README.md +++ b/examples/MicroBit/README.md @@ -11,90 +11,46 @@ at: # How to setup the Ada development environment for the Micro:Bit +GNAT Community now comes with micro:bit and pyOCD support built-in. So you only +need to download the ARM ELF and the native package from +[here](adacore.com/download) + ## pyOCD programmer The Micro:Bit comes with an embedded programming/debugging probe implementing the [CMSIS-DAP](https://docs.mbed.com/docs/mbed-os-handbook/en/latest/advanced/DAP/) -protocol defined by ARM. In order to use it, you have to install a Python -library called pyOCD. Here's the procedure: - -``` -$ sudo apt-get install python-pip -$ pip install --pre -U pyocd -``` - -pyOCD will need permissions to talk with the Micro:Bit. Instead of running the -pyOCD as privileged user (root), it's better to add a UDEV rules saying that -the device is accessible for non-privileged users: +protocol defined by ARM. -`$ sudo sh -c 'echo SUBSYSTEM==\"usb\", ATTR{idVendor}==\"0d28\", ATTR{idProduct}==\"0204\", MODE:=\"666\" > /etc/udev/rules.d/mbed.rules'` - -Now that there's a new UDEV rule and if you already plugged your Micro:Bit -before, you have to unplug it and plug it back again. - -To run pyOCD, use the following command: +To use it on Linux, you might need privileges to access the USB ports without +which the flash program will say "No connected boards". +To do this on Ubuntu, you can do it by creating (as administrator) the file +/etc/udev/rules.d/mbed.rules and add the line: ``` -$ pyocd-gdbserver -S -p 1234 -INFO:root:DAP SWD MODE initialised -INFO:root:ROM table #0 @ 0xf0000000 cidr=b105100d pidr=2007c4001 -INFO:root:[0] -INFO:root:ROM table #1 @ 0xe00ff000 cidr=b105100d pidr=4000bb471 -INFO:root:[0] -INFO:root:[1] -INFO:root:[2] -INFO:root:[1] -INFO:root:CPU core is Cortex-M0 -INFO:root:4 hardware breakpoints, 0 literal comparators -INFO:root:2 hardware watchpoints -INFO:root:Telnet: server started on port 4444 -INFO:root:GDB server started at port:1234 -[...] + SUBSYSTEM=="usb",MODE:="666" ``` +then restarting the service by doing -`-S` is to enable semihosting support, `-p 1234` is the port that Gdb will use -to talk with pyOCD. - -At this point, pyOCD is waiting for a connection from Gdb. - -## Install the Ada ZFP run-time - -Go to the Micro:Bit example directory and download or clone the run-time from -this GitHub repository: https://github.com/Fabien-Chouteau/zfp-nrf51 - -``` -$ cd Ada_Drivers_Library/examples/MicroBit/ -$ git clone https://github.com/Fabien-Chouteau/zfp-nrf51 +```shell +$ sudo udevadm trigger ``` ## Open the example project and build it -Start GNAT Programming studio (GPS) and open the Micro:Bit example project: +Start GNAT Programming studio (GPS) and open the micro:bit example project: "Ada_Drivers_Library/examples/MicroBit/microbit_example.gpr". Press F4 and then press Enter to build the project. -## program and debug the board - -In GPS, start a debug session with the top menu "Debug -> Initialize -> main". -GPS will start Gdb and connect it to pyOCD. - -In the gdb console, use the "load" command to program the board: - -``` -(gdb) load -Loading section .text, size 0xbd04 lma 0x0 -Loading section .ARM.exidx, size 0x8 lma 0xbd04 -[...] -``` -Reset the board with this command: +## Program the board -`(gdb) monitor reset` +Plug your micro:bit board with a USB cable, and wait for the system to +recognize it. This can take a few seconds -And finally use the "continue" command to run the program: +In the GPS toolbar, click on the "flash to board" button to program the +micro:bit. -`(gdb) continue` +After a few seconds, you should see a text scrolling on the LED matrix. -You can interrupt the execution with the "CTRL+backslash" shortcut and then -insert breakpoints, step through the application, inspect memory, etc. +That's it, you are ready to hack the micro:bit with Ada! From 35a2e8b1ddf60673f0b4d4245dc280db3ce49db8 Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Thu, 28 Jun 2018 19:22:35 +0200 Subject: [PATCH 11/11] Update examples/HiFive1/README.md --- examples/HiFive1/README.md | 41 ++++++++------------------------------ 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/examples/HiFive1/README.md b/examples/HiFive1/README.md index 34d2ba75b..8e6f9dc7c 100644 --- a/examples/HiFive1/README.md +++ b/examples/HiFive1/README.md @@ -3,43 +3,18 @@ E310 micro-controller. You can get it at [sifive.com](https://www.sifive.com/products/hifive1/). -As of today, the HiFive1 and FE310 support in Ada_Drivers_Library is -experimental. We document here a procedure to build the toolchain on Linux. +## How to setup the Ada development environment for the HiFive1 -## Building the tool chain - -SiFive - manufacturer of the MCU - provides an SDK repository with scripts to build a cross RISC-V GCC. There is a fork of this repository modified to enable Ada support in the compiler. - -Just clone it - -`$ git clone --recursive https://github.com/Fabien-Chouteau/freedom-e-sdk` - -install a native GNAT from your Linux distrib (for instance on Ubuntu) - -`$ sudo apt-get install gnat` - -and start the build - -``` -$ cd freedom-e-sdk -$ make tools -``` - -This step will also download a release of GNAT GPL for arm-elf to give you access to gprbuild and Gnat Programming Studio. -If you have a problem with this procedure don’t hesitate to open an issue on GitHub. - -## The run-time - -Ada programs always need a run-time library, but there are different run-time profiles depending on the constraints of the platform. In GNAT we have the so called Zero FootPrint run-time (ZFP) that provides the bare minimum and therefore is quite easy to port to a new platform (no exception propagation, no tasking, no containers, no file system access, etc.). - -You can find the ZFP run-time for the HiFive1 in this repository: https://github.com/Fabien-Chouteau/zfp-hifive1 - -Clone it in `examples/HiFive1` directory (where this README is). +GNAT Community now comes with HiFive1 support built-in. So you only need to +download the RISC-V32 ELF and the native package from +[here](adacore.com/download). ## Building the example -To build the example, make sure sure you have all the tools in your PATH and run: +To build the example, make sure sure you have all the tools in your PATH and +run: `$ gprbuild -f -p -P hifive1_example.gpr -XPLATFORM_BUILD=Debug` -Follow the instructions in the freedom-e-sdk to flash the example on the board using OpenOCD. +Follow the instructions in the freedom-e-sdk to flash the example on the board +using OpenOCD.