From e0a1fea1252e26f95f5a6302f0079d4e7649ffc2 Mon Sep 17 00:00:00 2001 From: Ola Redell Date: Fri, 15 Dec 2017 15:39:29 +0100 Subject: Added example cell recipe with freertos-cell --- README.md | 23 +++++++-- .../Bananapi-config-fix-for-Jailhouse-0.6.patch | 30 +++++++++++ .../freertos-cell/freertos-cell/Fix-Makefile.patch | 22 ++++++++ .../Remove-check-of-interrupt-mask.patch | 60 ++++++++++++++++++++++ .../freertos-cell/freertos-cell_1.0.bb | 28 ++++++++++ 5 files changed, 160 insertions(+), 3 deletions(-) create mode 100644 recipes-jailhouse/freertos-cell/freertos-cell/Bananapi-config-fix-for-Jailhouse-0.6.patch create mode 100644 recipes-jailhouse/freertos-cell/freertos-cell/Fix-Makefile.patch create mode 100644 recipes-jailhouse/freertos-cell/freertos-cell/Remove-check-of-interrupt-mask.patch create mode 100644 recipes-jailhouse/freertos-cell/freertos-cell_1.0.bb diff --git a/README.md b/README.md index e5d21a1..29a9edc 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,8 @@ The jailhouse inmates and cells are by default placed under `/usr/share/jailhouse/{inmates,cells}`. These locations can be adjusted using the variables in **jailhouse-defs.inc**. -The jailhouse build system builds binary cell configuration (*.cell) files -from cell configuration sources (*.c). To allow cell configurations to be +The jailhouse build system builds binary cell configuration (.cell) files +from cell configuration sources (.c). To allow cell configurations to be defined in cell recipes and imported into the jailhouse build, the jailhouse recipe defines a CELLS variable that lists all recipes that provide cells (and inmates) for the jailhouse build. Adapt the CELLS variable according to your @@ -78,6 +78,7 @@ needs, e.g. CELLS_append = " freertos-cell" +in `local.conf`. With this declaration, freertos-cell entries will be added both to the DEPENDS and the RDEPENDS_jailhouse variables, and the jailhouse recipe will pull cell descriptions from the staging directory before building. @@ -87,7 +88,7 @@ Packages produced by a jailhouse.inc based recipe ------------------------------------------------- The Jailhouse recipes based on the file jailhouse.inc produce -the follwing packages: +the following packages: * **jailhouse**, with the `jailhouse.bin` firmware, the `jailhouse` user space application, along with all inmate binaries that come with the jailhouse @@ -113,6 +114,22 @@ Using this class and variables ensures that the file designated by the `CELLCONFIG` variable is pulled into the jailhouse build such that a corresponding *.cell file is created. +Example cell +------------ + +An example cell recipe for the freertos-cell from Siemens is available +under `recipes-jailhouse/freertos-cell`. To use this, set the +`CELLS` variable accordingly as described above. + +Test the cell by executing the following sequence once booted. + + export JAILHOUSE_DIR=/usr/share/jailhouse + jailhouse enable ${JAILHOUSE_DIR}/cells/plamics-bpi-root.cell + jailhouse cell create ${JAILHOUSE_DIR}/cells/freertos-cell.cell + jailhouse cell load FreeRTOS ${JAILHOUSE_DIR}/inmates/freertos-demo.bin + jailhouse cell start FreeRTOS + +You should see output on the serial port used by the FreeRTOS inmate. Important Variables =================== diff --git a/recipes-jailhouse/freertos-cell/freertos-cell/Bananapi-config-fix-for-Jailhouse-0.6.patch b/recipes-jailhouse/freertos-cell/freertos-cell/Bananapi-config-fix-for-Jailhouse-0.6.patch new file mode 100644 index 0000000..2421d8a --- /dev/null +++ b/recipes-jailhouse/freertos-cell/freertos-cell/Bananapi-config-fix-for-Jailhouse-0.6.patch @@ -0,0 +1,30 @@ +From 6b55388a1b2375f4deca7dbf1a974d9ce22add86 Mon Sep 17 00:00:00 2001 +From: Ola Redell +Date: Sat, 28 Jan 2017 23:16:06 +0100 +Subject: [PATCH 2/2] bananapi: fix for newer versions of Jailhouse + +--- + jailhouse-configs/bananapi-freertos-demo.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/jailhouse-configs/bananapi-freertos-demo.c b/jailhouse-configs/bananapi-freertos-demo.c +index f9488c5..094c387 100644 +--- a/jailhouse-configs/bananapi-freertos-demo.c ++++ b/jailhouse-configs/bananapi-freertos-demo.c +@@ -1,4 +1,4 @@ +-#include ++#include + #include + + #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +@@ -15,6 +15,7 @@ struct { + } __attribute__((packed)) config = { + .cell = { + .signature = JAILHOUSE_CELL_DESC_SIGNATURE, ++ .revision = JAILHOUSE_CONFIG_REVISION, + .name = "FreeRTOS", + .flags = JAILHOUSE_CELL_PASSIVE_COMMREG, + +-- +1.9.1 + diff --git a/recipes-jailhouse/freertos-cell/freertos-cell/Fix-Makefile.patch b/recipes-jailhouse/freertos-cell/freertos-cell/Fix-Makefile.patch new file mode 100644 index 0000000..c680b03 --- /dev/null +++ b/recipes-jailhouse/freertos-cell/freertos-cell/Fix-Makefile.patch @@ -0,0 +1,22 @@ +diff --git a/Makefile b/Makefile +index d49c25f..f9d295a 100644 +--- a/Makefile ++++ b/Makefile +@@ -4,12 +4,12 @@ src = $(CURDIR) + + CROSS_COMPILE ?= arm-linux-gnueabihf- + +-CC = $(CROSS_COMPILE)gcc +-LD = $(CROSS_COMPILE)ld +-AR = $(CROSS_COMPILE)ar +-OBJCOPY = $(CROSS_COMPILE)objcopy ++#CC = $(CROSS_COMPILE)gcc ++#LD = $(CROSS_COMPILE)ld ++#AR = $(CROSS_COMPILE)ar ++#OBJCOPY = $(CROSS_COMPILE)objcopy + +-CFLAGS += -mcpu=cortex-a7 -mtune=cortex-a7 -mfpu=vfpv4-d16 -mfloat-abi=hard -O2 ++CFLAGS += -mcpu=cortex-a7 -mtune=cortex-a7 -mfpu=vfpv4-d16 -mfloat-abi=hard -O0 + CFLAGS += -DCONFIG_MACH_SUN7I=1 + CFLAGS += -Wall -MMD -pipe + CFLAGS += -I $(src) -I $(src)/freertos/Source/include -I $(src)/freertos-runtime -I $(src)/freertos/Source/portable/GCC/ARM_A7jailhouse diff --git a/recipes-jailhouse/freertos-cell/freertos-cell/Remove-check-of-interrupt-mask.patch b/recipes-jailhouse/freertos-cell/freertos-cell/Remove-check-of-interrupt-mask.patch new file mode 100644 index 0000000..a343eff --- /dev/null +++ b/recipes-jailhouse/freertos-cell/freertos-cell/Remove-check-of-interrupt-mask.patch @@ -0,0 +1,60 @@ +From 1b1d05fa9e086e7161f8ef2df43874a3712ff8e0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Anders=20T=C3=B6rnqvist?= +Date: Fri, 27 Jan 2017 16:20:29 +0100 +Subject: [PATCH 1/2] Remove check of interrupt mask check that probably is not + needed in recent versions of Jailhouse. This check causes FreeRTOS to hang + for ever in the while loop. The commit in Jailhouse that is close to this is + 902ee9cfd32652f6926da709b259d46a68bdebf4 + +--- + .../Source/portable/GCC/ARM_A7jailhouse/port.c | 34 ---------------------- + 1 file changed, 34 deletions(-) + +diff --git a/freertos/Source/portable/GCC/ARM_A7jailhouse/port.c b/freertos/Source/portable/GCC/ARM_A7jailhouse/port.c +index dd739c3..6084939 100644 +--- a/freertos/Source/portable/GCC/ARM_A7jailhouse/port.c ++++ b/freertos/Source/portable/GCC/ARM_A7jailhouse/port.c +@@ -323,40 +323,6 @@ BaseType_t xPortStartScheduler( void ) + { + uint32_t ulAPSR; + +- #if( configASSERT_DEFINED == 1 ) +- { +- volatile uint32_t ulOriginalPriority; +- volatile uint8_t * const pucFirstUserPriorityRegister = ( volatile uint8_t * const ) ( gic_v2_gicd_get_address() + portINTERRUPT_PRIORITY_REGISTER_OFFSET ); +- volatile uint8_t ucMaxPriorityValue; +- +- /* Determine how many priority bits are implemented in the GIC. +- +- Save the interrupt priority value that is about to be clobbered. */ +- ulOriginalPriority = *pucFirstUserPriorityRegister; +- +- /* Determine the number of priority bits available. First write to +- all possible bits. */ +- *pucFirstUserPriorityRegister = portMAX_8_BIT_VALUE; +- +- /* Read the value back to see how many bits stuck. */ +- ucMaxPriorityValue = *pucFirstUserPriorityRegister; +- +- /* Shift to the least significant bits. */ +- while( ( ucMaxPriorityValue & portBIT_0_SET ) != portBIT_0_SET ) +- { +- ucMaxPriorityValue >>= ( uint8_t ) 0x01; +- } +- +- /* Sanity check configUNIQUE_INTERRUPT_PRIORITIES matches the read +- value. */ +- configASSERT( ucMaxPriorityValue == portLOWEST_INTERRUPT_PRIORITY ); +- +- /* Restore the clobbered interrupt priority register to its original +- value. */ +- *pucFirstUserPriorityRegister = ulOriginalPriority; +- } +- #endif /* conifgASSERT_DEFINED */ +- + ulICCIAR = ulICCEOIR = ulICCPMR = (uint32_t) gic_v2_gicc_get_address(); + ulICCIAR += portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET; + ulICCEOIR += portICCEOIR_END_OF_INTERRUPT_OFFSET; +-- +1.9.1 + diff --git a/recipes-jailhouse/freertos-cell/freertos-cell_1.0.bb b/recipes-jailhouse/freertos-cell/freertos-cell_1.0.bb new file mode 100644 index 0000000..a61dd80 --- /dev/null +++ b/recipes-jailhouse/freertos-cell/freertos-cell_1.0.bb @@ -0,0 +1,28 @@ +SUMMARY = "FreeRTOS for Jailhouse" +HOMEPAGE = "https://github.com/siemens/freertos-cell" + +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://freertos/License/license.txt;md5=ff3ee34806c13760712131849e183a35\ + file://LICENSE;md5=494a529748a63071fbdf44f61db2391c" + +DEPENDS = "virtual/kernel make-native" + +SRC_URI = "git://github.com/siemens/freertos-cell.git;protocol=https;branch=master; \ + file://Fix-Makefile.patch \ + file://Remove-check-of-interrupt-mask.patch \ + file://Bananapi-config-fix-for-Jailhouse-0.6.patch" + +SRCREV = "6ad80637be066d196d81c1640bc1bd5b66e0ec45" + +S ="${WORKDIR}/git" + +inherit jailhouse-cell + +INMATE = "${S}/freertos-demo.bin" +CELLCONFIG = "${S}/jailhouse-configs/bananapi-freertos-demo.c" +CELLCONFIG_TARGET = "freertos-cell.c" + + +do_compile() { + LDFLAGS="" oe_runmake +} -- cgit v1.2.3-54-g00ecf