Add M4 example

Signed-off-by: Christophe Priouzeau <christophe.priouzeau@st.com>
This commit is contained in:
Christophe Priouzeau committed 2019-02-05 11:25:34 +01:00
1 parent b848fd8712
commit 02fce41bed
7 files changed
+1191

No files matched your search

@@ -0,0 +1,628 @@
From 56696e74c6de23f39c56a3eb114dfca4534e0ae8 Mon Sep 17 00:00:00 2001
From: christophe montaud <christophe.montaud@st.com>
Date: Wed, 3 Oct 2018 17:23:23 +0200
Subject: [PATCH] DTSO: align to new kernel delivery r3-rc4
DTBO: update pin config names
DTBO: align to new kernel stm32mp157c-m4-srm.dtsi
so
DTBO: disable DMA at the end
---
.../stm32mp157-dk/M4ResourcesForAllExamples.dtso | 204 +++++++++---------
.../stm32mp157-ev/M4ResourcesForAllExamples.dtso | 239 +++++++++++----------
2 files changed, 234 insertions(+), 209 deletions(-)
diff --git a/Utilities/DTSO/stm32mp157-dk/M4ResourcesForAllExamples.dtso b/Utilities/DTSO/stm32mp157-dk/M4ResourcesForAllExamples.dtso
index 9a0e508..c0c9dd7 100644
--- a/Utilities/DTSO/stm32mp157-dk/M4ResourcesForAllExamples.dtso
+++ b/Utilities/DTSO/stm32mp157-dk/M4ResourcesForAllExamples.dtso
@@ -8,7 +8,7 @@
compatible = "st,stm32mp157";
fragment@0 {
- target = <&dma2>;
+ target = <&dac>;
__overlay__ {
status = "disabled";
@@ -16,7 +16,7 @@
};
fragment@1 {
- target = <&dac>;
+ target = <&adc>;
__overlay__ {
status = "disabled";
@@ -24,7 +24,7 @@
};
fragment@2 {
- target = <&adc>;
+ target = <&timers1>;
__overlay__ {
status = "disabled";
@@ -32,7 +32,7 @@
};
fragment@3 {
- target = <&timers1>;
+ target = <&dma2>;
__overlay__ {
status = "disabled";
@@ -44,7 +44,7 @@
__overlay__ {
dma-masters = <&dma1>;
- dma-channels = <8>;
+ dma-channels = <8>;
};
};
@@ -55,120 +55,132 @@
m4_system_resources {
status = "okay";
- m4_crc2: crc@4c00400 {
+ button {
compatible = "rproc-srm-dev";
- reg = <0x4c00400 0x400>;
- clocks = <&rcc CRC2>;
+ interrupt-parent = <&gpioa>;
+ interrupts = <14 2>;
+ interrupt-names = "irq";
status = "okay";
};
- m4_cryp2: cryp@4c005000 {
+ m4_led: m4_led {
compatible = "rproc-srm-dev";
- reg = <0x4c005000 0x400>;
- clocks = <&rcc CRYP2>;
+ pinctrl-names = "rproc_default", "rproc_sleep";
+ pinctrl-0 = <&leds_orange_pins>;
+ pinctrl-1 = <&leds_orange_sleep_pins>;
status = "okay";
};
+ };
+ };
+ };
- m4_hash2: hash@4c002000 {
- compatible = "rproc-srm-dev";
- reg = <0x4c002000 0x400>;
- clocks = <&rcc HASH2>;
- status = "okay";
- };
+ fragment@6 {
+ target = <&m4_crc2>;
- m4_rng2: rng@4c003000 {
- compatible = "rproc-srm-dev";
- reg = <0x4c003000 0x400>;
- clocks = <&rcc RNG2_K>;
- status = "okay";
- };
+ __overlay__ {
+ status = "okay";
+ };
+ };
- m4_uart7: serial@40018000 {
- compatible = "rproc-srm-dev";
- reg = <0x40018000 0x400>;
- clocks = <&rcc UART7_K>;
- pinctrl-names = "default";
- pinctrl-0 = <&uart7_pins>;
- status = "okay";
- };
+ fragment@7 {
+ target = <&m4_cryp2>;
- m4_spi4: spi@44005000 {
- compatible = "rproc-srm-dev";
- reg = <0x44005000 0x400>;
- clocks = <&rcc SPI4_K>;
- pinctrl-names = "default";
- pinctrl-0 = <&spi4_pins_a>;
- status = "okay";
- };
+ __overlay__ {
+ status = "okay";
+ };
+ };
- m4_i2c5: i2c@40015000 {
- compatible = "rproc-srm-dev";
- reg = <0x40015000 0x400>;
- clocks = <&rcc I2C5_K>;
- pinctrl-names = "default";
- pinctrl-0 = <&i2c5_pins_a>;
- status = "okay";
- };
+ fragment@8 {
+ target = <&m4_hash2>;
- m4_timers2: timer@40000000 {
- compatible = "rproc-srm-dev";
- reg = <0x40000000 0x400>;
- clocks = <&rcc TIM2_K>;
- status = "okay";
- };
+ __overlay__ {
+ status = "okay";
+ };
+ };
- m4_timers1: timer@44000000 {
- compatible = "rproc-srm-dev";
- reg = <0x44000000 0x400>;
- clocks = <&rcc TIM1_K>;
- pinctrl-names = "default";
- pinctrl-0 = <&timer1_pins>;
- status = "okay";
- };
+ fragment@9 {
+ target = <&m4_rng2>;
- m4_dac: dac@40017000 {
- compatible = "rproc-srm-dev";
- reg = <0x40017000 0x400>;
- clocks = <&rcc DAC12>;
- status = "okay";
- };
+ __overlay__ {
+ status = "okay";
+ };
+ };
- m4_adc: adc@48003000 {
- compatible = "rproc-srm-dev";
- reg = <0x48003000 0x400>;
- vref-supply = <&vrefbuf>;
- clocks = <&rcc ADC12>, <&rcc ADC12_K>;
- status = "okay";
- };
+ fragment@10 {
+ target = <&m4_uart7>;
- m4_dma2: dma@48001000 {
- compatible = "rproc-srm-dev";
- reg = <0x48001000 0x400>;
- clocks = <&rcc DMA2>;
- status = "okay";
- };
+ __overlay__ {
+ pinctrl-names = "rproc_default";
+ pinctrl-0 = <&uart7_pins>;
+ status = "okay";
+ };
+ };
- button {
- compatible = "rproc-srm-dev";
- interrupt-parent = <&gpioa>;
- interrupts = <14 2>;
- interrupt-names = "irq";
- status = "okay";
- };
+ fragment@11 {
+ target = <&m4_spi4>;
- m4_led: m4_led {
- compatible = "rproc-srm-dev";
- pinctrl-names = "default", "sleep";
- pinctrl-0 = <&leds_orange_pins>;
- pinctrl-1 = <&leds_orange_sleep_pins>;
- status = "okay";
- };
- };
+ __overlay__ {
+ pinctrl-names = "rproc_default";
+ pinctrl-0 = <&spi4_pins_a>;
+ status = "okay";
};
};
+ fragment@12 {
+ target = <&m4_i2c5>;
- fragment@6 {
+ __overlay__ {
+ pinctrl-names = "rproc_default";
+ pinctrl-0 = <&i2c5_pins_a>;
+ status = "okay";
+ };
+ };
+
+ fragment@13 {
+ target = <&m4_timers2>;
+
+ __overlay__ {
+ pinctrl-names = "rproc_default";
+ status = "okay";
+ };
+ };
+
+ fragment@14 {
+ target = <&m4_timers1>;
+
+ __overlay__ {
+ pinctrl-names = "rproc_default";
+ pinctrl-0 = <&timer1_pins>;
+ status = "okay";
+ };
+ };
+
+ fragment@15 {
+ target = <&m4_dac>;
+
+ __overlay__ {
+ status = "okay";
+ };
+ };
+
+ fragment@16 {
+ target = <&m4_adc>;
+
+ __overlay__ {
+ vref-supply = <&vrefbuf>;
+ status = "okay";
+ };
+ };
+
+ fragment@17 {
+ target = <&m4_dma2>;
+
+ __overlay__ {
+ status = "okay";
+ };
+ };
+
+ fragment@18 {
target = <&pinctrl>;
__overlay__ {
diff --git a/Utilities/DTSO/stm32mp157-ev/M4ResourcesForAllExamples.dtso b/Utilities/DTSO/stm32mp157-ev/M4ResourcesForAllExamples.dtso
index 37e73d1..84cf399 100644
--- a/Utilities/DTSO/stm32mp157-ev/M4ResourcesForAllExamples.dtso
+++ b/Utilities/DTSO/stm32mp157-ev/M4ResourcesForAllExamples.dtso
@@ -8,7 +8,7 @@
compatible = "st,stm32mp157";
fragment@0 {
- target = <&dma2>;
+ target = <&dac>;
__overlay__ {
status = "disabled";
@@ -16,7 +16,7 @@
};
fragment@1 {
- target = <&dac>;
+ target = <&adc>;
__overlay__ {
status = "disabled";
@@ -24,7 +24,7 @@
};
fragment@2 {
- target = <&adc>;
+ target = <&timers2>;
__overlay__ {
status = "disabled";
@@ -32,7 +32,7 @@
};
fragment@3 {
- target = <&timers2>;
+ target = <&sai2b>;
__overlay__ {
status = "disabled";
@@ -40,7 +40,7 @@
};
fragment@4 {
- target = <&sai2b>;
+ target = <&fmc2_nand>;
__overlay__ {
status = "disabled";
@@ -48,7 +48,7 @@
};
fragment@5 {
- target = <&fmc2_nand>;
+ target = <&i2c5>;
__overlay__ {
status = "disabled";
@@ -56,16 +56,15 @@
};
fragment@6 {
- target = <&dmamux1>;
+ target = <&qspi>;
__overlay__ {
- dma-masters = <&dma1>;
- dma-channels = <8>;
+ status = "disabled";
};
};
fragment@7 {
- target = <&i2c5>;
+ target = <&dma2>;
__overlay__ {
status = "disabled";
@@ -73,10 +72,11 @@
};
fragment@8 {
- target = <&qspi>;
+ target = <&dmamux1>;
__overlay__ {
- status = "disabled";
+ dma-masters = <&dma1>;
+ dma-channels = <8>;
};
};
@@ -87,131 +87,144 @@
m4_system_resources {
status = "okay";
- m4_crc2: crc@4c00400 {
+
+ button {
compatible = "rproc-srm-dev";
- reg = <0x4c00400 0x400>;
- clocks = <&rcc CRC2>;
+ interrupt-parent = <&gpioa>;
+ interrupts = <14 2>;
+ interrupt-names = "irq";
status = "okay";
};
- m4_cryp2: cryp@4c005000 {
+ m4_led: m4_led {
compatible = "rproc-srm-dev";
- reg = <0x4c005000 0x400>;
- clocks = <&rcc CRYP2>;
+ pinctrl-names = "rproc_default", "rproc_sleep";
+ pinctrl-0 = <&leds_orange_pins>;
+ pinctrl-1 = <&leds_orange_sleep_pins>;
status = "okay";
};
+ };
+ };
+ };
- m4_hash2: hash@4c002000 {
- compatible = "rproc-srm-dev";
- reg = <0x4c002000 0x400>;
- clocks = <&rcc HASH2>;
- status = "okay";
- };
+ fragment@10 {
+ target = <&m4_crc2>;
- m4_rng2: rng@4c003000 {
- compatible = "rproc-srm-dev";
- reg = <0x4c003000 0x400>;
- clocks = <&rcc RNG2_K>;
- status = "okay";
- };
+ __overlay__ {
+ status = "okay";
+ };
+ };
- m4_usart3: serial@4000f000 {
- compatible = "rproc-srm-dev";
- reg = <0x4000f000 0x400>;
- clocks = <&rcc USART3_K>;
- pinctrl-names = "default";
- pinctrl-0 = <&usart3_pins_a>;
- status = "okay";
- };
+ fragment@11 {
+ target = <&m4_cryp2>;
- m4_spi1: spi@44004000 {
- compatible = "rproc-srm-dev";
- reg = <0x44004000 0x400>;
- clocks = <&rcc SPI1_K>;
- pinctrl-names = "default";
- pinctrl-0 = <&spi1_pins_a>;
- status = "okay";
- };
+ __overlay__ {
+ status = "okay";
+ };
+ };
- m4_i2c5: i2c@40015000 {
- compatible = "rproc-srm-dev";
- reg = <0x40015000 0x400>;
- clocks = <&rcc I2C5_K>;
- pinctrl-names = "default";
- pinctrl-0 = <&i2c5_pins_a>;
- status = "okay";
- };
+ fragment@12 {
+ target = <&m4_hash2>;
- m4_timers2: timer@40000000 {
- compatible = "rproc-srm-dev";
- reg = <0x40000000 0x400>;
- pinctrl-names = "default";
- pinctrl-0 = <&pwm2_pins_a>;
- clocks = <&rcc TIM2_K>;
- status = "okay";
- };
+ __overlay__ {
+ status = "okay";
+ };
+ };
- m4_timers1: timer@44000000 {
- compatible = "rproc-srm-dev";
- reg = <0x44000000 0x400>;
- clocks = <&rcc TIM1_K>;
- pinctrl-names = "default";
- pinctrl-0 = <&pwm1_pins_a>;
- status = "okay";
- };
+ fragment@13 {
+ target = <&m4_rng2>;
- m4_dac: dac@40017000 {
- compatible = "rproc-srm-dev";
- reg = <0x40017000 0x400>;
- clocks = <&rcc DAC12>;
- status = "okay";
- };
+ __overlay__ {
+ status = "okay";
+ };
+ };
- m4_adc: adc@48003000 {
- compatible = "rproc-srm-dev";
- reg = <0x48003000 0x400>;
- vref-supply = <&vdda>;
- clocks = <&rcc ADC12>, <&rcc ADC12_K>;
- status = "okay";
- };
+ fragment@14 {
+ target = <&m4_usart3>;
- m4_dma2: dma@48001000 {
- compatible = "rproc-srm-dev";
- reg = <0x48001000 0x400>;
- clocks = <&rcc DMA2>;
- status = "okay";
- };
+ __overlay__ {
+ pinctrl-names = "rproc_default";
+ pinctrl-0 = <&usart3_pins_a>;
+ status = "okay";
+ };
+ };
- m4_qspi: qspi@58003000 {
- compatible = "rproc-srm-dev";
- reg = <0x58003000 0x1000>;
- pinctrl-names = "default";
- pinctrl-0 = <&qspi_clk_pins_a &qspi_bk1_pins_a &qspi_bk2_pins_a>;
- clocks = <&rcc QSPI_K>;
- status = "okay";
- };
+ fragment@15 {
+ target = <&m4_spi1>;
- button {
- compatible = "rproc-srm-dev";
- interrupt-parent = <&gpioa>;
- interrupts = <14 2>;
- interrupt-names = "irq";
- status = "okay";
- };
+ __overlay__ {
+ pinctrl-names = "rproc_default";
+ pinctrl-0 = <&spi1_pins_a>;
+ status = "okay";
+ };
+ };
- m4_led: m4_led {
- compatible = "rproc-srm-dev";
- pinctrl-names = "default", "sleep";
- pinctrl-0 = <&leds_orange_pins>;
- pinctrl-1 = <&leds_orange_sleep_pins>;
- status = "okay";
- };
- };
+ fragment@16 {
+ target = <&m4_i2c5>;
+
+ __overlay__ {
+ pinctrl-names = "rproc_default";
+ pinctrl-0 = <&i2c5_pins_a>;
+ status = "okay";
};
};
+ fragment@17 {
+ target = <&m4_timers2>;
- fragment@10 {
+ __overlay__ {
+ pinctrl-names = "rproc_default";
+ pinctrl-0 = <&pwm2_pins_a>;
+ status = "okay";
+ };
+ };
+
+ fragment@18 {
+ target = <&m4_timers1>;
+
+ __overlay__ {
+ pinctrl-names = "rproc_default";
+ pinctrl-0 = <&pwm1_pins_a>;
+ status = "okay";
+ };
+ };
+
+ fragment@19 {
+ target = <&m4_dac>;
+
+ __overlay__ {
+ status = "okay";
+ };
+ };
+
+ fragment@20 {
+ target = <&m4_adc>;
+
+ __overlay__ {
+ vref-supply = <&vdda>;
+ status = "okay";
+ };
+ };
+
+ fragment@21 {
+ target = <&m4_dma2>;
+
+ __overlay__ {
+ status = "okay";
+ };
+ };
+
+ fragment@22 {
+ target = <&m4_qspi>;
+
+ __overlay__ {
+ pinctrl-names = "rproc_default";
+ pinctrl-0 = <&qspi_clk_pins_a &qspi_bk1_pins_a &qspi_bk2_pins_a>;
+ status = "okay";
+ };
+ };
+
+ fragment@23 {
target = <&pinctrl>;
__overlay__ {
--
2.7.4
@@ -0,0 +1,82 @@
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
AS := $(CROSS_COMPILE)ar
STRIP := $(CROSS_COMPILE)strip
OBJCOPY := $(CROSS_COMPILE)objcopy
SIZE := $(CROSS_COMPILE)size
ifeq ($(CPU_TYPE),M4)
COMMONFLAGS += -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16
endif
ifeq ($(CPU_TYPE),A7)
COMMONFLAGS += -mcpu=cortex-a7 -mthumb -mfloat-abi=hard -mfpu=neon-vfpv4
endif
# Project settings
PROJ_DIR := $(PROJECT_DIR)
PROJ_NAME := $(BIN_NAME)
# Output
OUT := $(PROJ_DIR)/out
BUILD_OUT := $(OUT)/$(BUILD_CONFIG)
# Bin
TESTELF := $(BUILD_OUT)/$(PROJ_NAME).elf
TESTBIN := $(BUILD_OUT)/$(PROJ_NAME).bin
# CFLAGS rules
CFLAGS += $(COMMONFLAGS)
CFLAGS += -Os
CFLAGS += -Wall -fmessage-length=0 -ffunction-sections -c -fmessage-length=0 -MMD -MP
#CFLAGS += -Wno-unused-function
#CFLAGS += -Wno-unused-variable
CFLAGS += -g3
#CFLAGS += -g
#CFLAGS += -Werror
# LDFLAGS rules
LDFLAGS += $(COMMONFLAGS)
LDFLAGS += -specs=nosys.specs -specs=nano.specs
LDFLAGS += -Wl,-Map=$(BUILD_OUT)/output.map -Wl,--gc-sections -lm
#LDFLAGS += -D__MEM_START__=0x2ffc2000 -D__MEM_END__=0x2fff3000 -D__MEM_SIZE__=0x31000
#debug LINKER
#LDFLAGS += -Wl,--verbose
# Get config code from the project to compile (source, cflags, ldflags, ldlibs)
include $(BUILD_OUT)/conf/config.in
# Build rule
define c-compilation-rule
$1: $2 $(LDSCRIPT)
@echo $2 \< $1
@mkdir -pv `dirname $1`
$(CC) $(CFLAGS) -c $2 -o $1
COBJ+=$1
endef
# generate a compilation rule for each source file
$(foreach r,$(CSRC), $(eval $(call c-compilation-rule,$(BUILD_OUT)/$(r).o,$(r))))
# Include dep files
#DEPS= $(foreach file,$(CSRC),$(file).d)
#-include $(DEPS)
# Build elf output
$(TESTELF): $(COBJ)
@echo link $@
$(CC) $(LDFLAGS) -o $@.sym $^ $(LDLIBS) -T$(LDSCRIPT)
@cp $@.sym $@
@$(STRIP) -g $@
@$(SIZE) $@
# Build bin output
$(TESTBIN): $(TESTELF)
@$(OBJCOPY) -O binary $(TESTELF) $(TESTBIN)
clean:
rm -rf $(COBJ) $(TESTELF) $(TESTBIN)
all: $(TESTBIN)
@@ -0,0 +1,179 @@
import os
import sys
import xml.etree.ElementTree as ET
from sys import argv as arg
#
# the goal is to parse SW4STM32 project configs files to get
# list of files to compile
# cflags
# ldflags
print "start"
# arg1: path of the project
prj=arg[1]
# arg2: name of the build configuration
buildconfig=arg[2]
# arg3: root of the compilation
myroot=arg[3]
confdir=myroot+"/out/"+buildconfig+"/conf"
print "prj: "+prj
print "myroot: "+myroot
print "confdir: "+confdir
print "buildconfig: "+buildconfig
os.chdir(prj)
proj_tree = ET.parse(".project")
cproj_tree = ET.parse(".cproject")
#os.chdir(myroot)
if os.path.exists(confdir)!=True:
os.mkdir(confdir)
if prj.find("(")!=-1:
print "bad prj path"
sys.stderr.write("bad prj path: "+prj+"\n")
exit(1)
#
# convert path and checks that path is valid
#
def fullpath(filename):
# get absolute path
p=os.path.abspath(filename);
# workaround: there is a mistake in some projects
p=p.replace("STM32_USB_HOST_Library","STM32_USB_Host_Library")
# some path contain windows style
p=p.replace("\\","/")
# containts space at the end
p=p.replace(" ","")
# check if path is valid
#print "check path: "+p
if os.path.exists(p)!=True:
print "prj: "+prj
print "original path: "+filename
sys.stderr.write("error check path: "+p+" fails\n")
exit(1);
return p
#
# get the source code file list
#
print "file list"
f=open(confdir+"/config.in", 'w')
root = proj_tree.getroot()
f.write("CSRC += \\\n")
for i in root.iter('link'):
a=i.find('locationURI')
if a==None:
a=i.find('location')
if a==None:
print "could not find any file"
exit(1)
if a.text is None:
print "no text"
else:
#print "text:"+a.text
temp=a.text
if ((temp.find(".txt")==-1) & (temp.find(".gdb")==-1) & (temp.find(".launch")==-1) & (temp.find(".sh")==-1) & (temp.find("README")==-1)):
temp=temp.replace("PARENT-1-PROJECT_LOC/", "../")
temp=temp.replace("PARENT-2-PROJECT_LOC/", "../../")
temp=temp.replace("PARENT-3-PROJECT_LOC/", "../../../")
temp=temp.replace("PARENT-4-PROJECT_LOC/", "../../../../")
temp=temp.replace("PARENT-5-PROJECT_LOC/", "../../../../../")
temp=temp.replace("PARENT-6-PROJECT_LOC/", "../../../../../../")
temp=temp.replace("PARENT-7-PROJECT_LOC/", "../../../../../../../")
temp=temp.replace("PROJECT_LOC/", "../")
#print temp
temp=fullpath(temp)
f.write(temp+" \\\n")
f.write("\n")
cflags=""
ldlibs=""
ldscript=""
root = cproj_tree.getroot()
count=0
for j in root.iter('configuration'):
temp=j.get('name')
if temp == buildconfig:
for i in j.iter('option'):
a=i.get('superClass')
if a == 'gnu.c.compiler.option.include.paths':
for j in i.iter('listOptionValue'):
temp=j.get('value')
if temp != "":
temp=temp.replace("\\","/")
#workaround remove first occurency of "../"
temp=temp.replace("../", "",1)
temp=fullpath(temp)
#print temp
cflags=cflags+" -I"+temp+" \\\n"
if a == 'gnu.c.compiler.option.preprocessor.def.symbols':
for j in i.iter('listOptionValue'):
temp=j.get('value')
if temp != "":
#print temp
cflags=cflags+" -D"+temp+" \\\n"
if a == 'fr.ac6.managedbuild.tool.gnu.cross.c.linker.script':
temp=i.get('value')
temp=temp.replace("../", "",1)
temp=fullpath(temp)
#print temp
ldscript=temp
if a == 'gnu.c.link.option.paths':
for j in i.iter('listOptionValue'):
temp=j.get('value')
temp=temp.replace("../", "",1)
temp=fullpath(temp)
ldlibs=ldlibs+" -L"+temp+"/"
if a == 'gnu.c.link.option.libs':
for j in i.iter('listOptionValue'):
temp=j.get('value')
ldlibs=ldlibs+" -l"+temp
#workaround for STM327x6G_EVAL
#cflags=cflags+" -DUSE_IOEXPANDER"
print "cflags="+cflags
f.write("CFLAGS += "+cflags+"\n")
f.write("\n")
print "ldlibs="+ldlibs
f.write("LDLIBS += "+ldlibs+"\n")
f.write("\n")
f.write("LDSCRIPT += "+ldscript+"\n")
f.write("\n")
f.close();
print "exit"
@@ -0,0 +1,75 @@
#!/bin/sh -
autodetect_board() {
if [ ! -d /proc/device-tree/ ];
then
echo "Proc Device tree are not available, Could not detect on which board we are" > /dev/kmsg
exit 1
fi
#search on device tree compatible entry the board type
if $(grep -q "stm32mp157c-ev" /proc/device-tree/compatible) ;
then
board="STM32MP15_M4_EVAL"
else if $(grep -q "stm32mp157c-dk" /proc/device-tree/compatible) ;
then
board="STM32MP15_M4_DISCO"
else
echo "Board is not an EVAL or a DISCO BOARD" > /dev/kmsg
exit 1
fi
fi
}
copy_default_M4_fw() {
#Test if ${board}_@default_fw@.elf is existing
if [ -z "$(find @userfs_mount_point@/examples/* -name ${board}_@default_fw@.elf)" ]; then
echo "The default copro example ${board}_@default_fw@ doesn't exist" > /dev/kmsg
exit 1
else
#copy ${board}_@default_fw@.elf into /lib/firmware/
cp $(find @userfs_mount_point@/examples/* -name ${board}_@default_fw@.elf) /lib/firmware/.
fi
}
firmware_load_start() {
# Change the name of the firmware
echo -n ${board}_@default_fw@.elf > /sys/class/remoteproc/remoteproc0/firmware
# Change path to found firmware
#echo -n /home/root >/sys/module/firmware_class/parameters/path
# Restart firmware
echo start >/sys/class/remoteproc/remoteproc0/state
echo "Booting fw image ${board}_@default_fw@.elf" > /dev/kmsg
}
firmware_load_stop() {
# Stop the firmware
echo stop >/sys/class/remoteproc/remoteproc0/state
echo "Stoping fw image ${board}_@default_fw@.elf" > /dev/kmsg
}
board=""
autodetect_board
case "$1" in
start)
copy_default_M4_fw
firmware_load_stop
firmware_load_start
;;
stop)
firmware_load_stop
;;
restart)
firmware_load_stop
firmware_load_start
;;
*)
echo "HELP: $0 [start|stop|restart]"
;;
esac
exit 0
@@ -0,0 +1,11 @@
[Unit]
Description=ST Load M4 firmware via remoteproc
After=systemd-modules-load.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/st-m4firmware-load-default.sh start
[Install]
WantedBy=sysinit.target