M4PROJECTS-STM32MP1: rework recipe and manage compliance with python3

Align also gcc option to STM32CubeIDE ones

Change-Id: I415f79bd655e354faebff16b628537fc281e2ac4
Signed-off-by: Romuald JEANNE <romuald.jeanne@st.com>
This commit is contained in:
Romuald JEANNE committed 2020-06-23 17:23:51 +02:00
1 parent a0b7db0c1e
commit 8391f7b748
7 files changed
+242 -198

No files matched your search

@@ -27,6 +27,9 @@ TESTBIN := $(BUILD_OUT)/$(PROJ_NAME).bin
# CFLAGS rules
CFLAGS += $(COMMONFLAGS)
CFLAGS += -Os
#CFLAGS += -Og
CFLAGS += -std=gnu11
CFLAGS += -fstack-usage
CFLAGS += -Wall -fmessage-length=0 -ffunction-sections -c -fmessage-length=0 -MMD -MP
#CFLAGS += -Wno-unused-function
#CFLAGS += -Wno-unused-variable
@@ -9,8 +9,7 @@ from sys import argv as arg
# cflags
# ldflags
print "start"
print("start")
# arg1: path of the project
prj=arg[1]
@@ -21,10 +20,10 @@ myroot=arg[3]
confdir=myroot+"/out/"+buildconfig+"/conf"
print "prj: "+prj
print "myroot: "+myroot
print "confdir: "+confdir
print "buildconfig: "+buildconfig
print("prj: "+prj)
print("myroot: "+myroot)
print("confdir: "+confdir)
print("buildconfig: "+buildconfig)
os.chdir(prj)
@@ -34,42 +33,40 @@ cproj_tree = ET.parse(".cproject")
#os.chdir(myroot)
if os.path.exists(confdir)!=True:
os.mkdir(confdir)
os.mkdir(confdir)
if prj.find("(")!=-1:
print "bad prj path"
sys.stderr.write("bad prj path: "+prj+"\n")
exit(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);
# 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
# 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"
print("file list")
f=open(confdir+"/config.in", 'w')
@@ -77,39 +74,37 @@ 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)
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 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/", "../")
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)
#print(temp)
temp=fullpath(temp)
f.write(temp+" \\\n")
f.write(temp+" \\\n")
f.write("\n")
cflags=""
ldlibs=""
ldscript=""
@@ -118,56 +113,56 @@ 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"
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 == '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 == '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.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
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
print("cflags="+cflags)
f.write("CFLAGS += "+cflags+"\n")
f.write("\n")
print "ldlibs="+ldlibs
print("ldlibs="+ldlibs)
f.write("LDLIBS += "+ldlibs+"\n")
f.write("\n")
@@ -176,4 +171,4 @@ f.write("\n")
f.close();
print "exit"
print("exit")
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh -
# test if we are a stm32mp1
if ! $(grep -q "stm32mp157[acdf]-dk\|ev" /proc/device-tree/compatible) ;
then
exit 0
fi
case $1 in
halt)
# action to do in case of halt
/sbin/st-m4firmware-load-default.sh stop
;;
poweroff)
# action to do in case of poweroff
/sbin/st-m4firmware-load-default.sh stop
;;
reboot)
# action to do in case of reboot
;;
kexec)
# action to do in case of kexec (for crashdump on memory)
;;
esac
exit 0
@@ -8,10 +8,10 @@ then
fi
#search on device tree compatible entry the board type
if $(grep -q "stm32mp157c-ev" /proc/device-tree/compatible) ;
if $(grep -q "stm32mp157[acdf]-ev" /proc/device-tree/compatible) ;
then
board="STM32MP15_M4_EVAL"
else if $(grep -q "stm32mp157c-dk" /proc/device-tree/compatible) ;
else if $(grep -q "stm32mp157[acdf]-dk" /proc/device-tree/compatible) ;
then
board="STM32MP15_M4_DISCO"
else
@@ -47,8 +47,12 @@ 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
if [ $(cat /sys/class/remoteproc/remoteproc0/state) == "running" ]; then
echo stop >/sys/class/remoteproc/remoteproc0/state
echo "Stopping fw image ${board}_@default_fw@.elf" > /dev/kmsg
else
echo "Default copro already stopped" > /dev/kmsg
fi
}
board=""