Skip to content

Commit

Permalink
Update release creation on GitHub to generate the XML files and a tar…
Browse files Browse the repository at this point in the history
… file with all necessary parts (#200)
  • Loading branch information
pwittich authored Nov 18, 2023
1 parent 035e085 commit a26a372
Show file tree
Hide file tree
Showing 13 changed files with 209 additions and 442 deletions.
29 changes: 19 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ jobs:
cp projects/cm_mcu/gcc/cm_mcu.axf cm_mcu_noecn001_rev1.axf
make clean REV1=1
make -k REV1=1
cp projects/cm_mcu/gcc/cm_mcu.bin cm_mcu_rev1.bin
cp projects/cm_mcu/gcc/cm_mcu.axf cm_mcu_rev1.axf
cp projects/boot_loader/gcc/bl_main.bin bl_main_rev1.bin
cp projects/boot_loader/gcc/bl_main.axf bl_main_rev1.axf
mkdir REV1
cp projects/cm_mcu/gcc/cm_mcu.bin REV1/cm_mcu_rev1.bin
cp projects/cm_mcu/gcc/cm_mcu.axf REV1/cm_mcu_rev1.axf
cp projects/boot_loader/gcc/bl_main.bin REV1/bl_main_rev1.bin
cp projects/boot_loader/gcc/bl_main.axf REV1/bl_main_rev1.axf
make release
mv PL_MEM_CM_rev1.xml REV1
tar zcvpf cm_mcu_rev1.tar.gz REV1
- name: make with GCC for Rev2
run: |
export PATH=${PATH}:$HOME/work/_temp/arm-none-eabi/bin:
Expand All @@ -50,16 +54,21 @@ jobs:
cp projects/cm_mcu/gcc/cm_mcu.axf cm_mcu_noecn001_rev2.axf
make clean REV2=1
make -k REV2=1
cp projects/cm_mcu/gcc/cm_mcu.bin cm_mcu_rev2.bin
cp projects/cm_mcu/gcc/cm_mcu.axf cm_mcu_rev2.axf
cp projects/boot_loader/gcc/bl_main.bin bl_main_rev2.bin
cp projects/boot_loader/gcc/bl_main.axf bl_main_rev2.axf
mkdir REV2
cp projects/cm_mcu/gcc/cm_mcu.bin REV2/cm_mcu_rev2.bin
cp projects/cm_mcu/gcc/cm_mcu.axf REV2/cm_mcu_rev2.axf
cp projects/boot_loader/gcc/bl_main.bin REV2/bl_main_rev2.bin
cp projects/boot_loader/gcc/bl_main.axf REV2/bl_main_rev2.axf
make release
mv PL_MEM_CM_rev2.xml REV2
tar zcvpf cm_mcu_rev2.tar.gz REV2
- name: test
run: pwd; ls -R ; find . -type f -name '*.axf' -print
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
./cm_mcu*.*
./bl_main*.*
./REV1/*
./REV2/*
*.tar.gz
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ c_cpp_properties.json
/.metadata/
projects/cm_mcu/ZynqMon_addresses.c
projects/cm_mcu/ZynqMon_addresses.h
PL_MEM_CM_rev1.xml
PL_MEM_CM_rev2.xml
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ check-and-reinit-submodules:
git submodule update --init; \
fi

release:
@$(MAKE) -C projects/cm_mcu release

.PHONY: all clean $(DIRS) $(DIRSCLEAN) check-and-reinit-submodules
29 changes: 25 additions & 4 deletions projects/cm_mcu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,40 @@ all: ${COMPILER}/cm_mcu.axf
# The rule to clean out all the build products.
#
clean:
@rm -rf ${COMPILER} ${wildcard *~} ZynqMon_addresses.c ZynqMon_addresses.h
@rm -rf ${COMPILER} ${wildcard *~} ZynqMon_addresses.c ZynqMon_addresses.h ${ROOT}/PL_MEM*.xml

#
# The rule to create the target directory.
#
${COMPILER}:
@mkdir -p ${COMPILER}


## Zynq address table -- MCU code
YAML_FILES=$(wildcard ${ROOT}/sm_cm_config/data/*.yml)
#
# for building tar files in a release
#
release: ${YAML_FILES}
@for f in ${YAML_FILES}; do \
if [ 'x${VERBOSE}' = x ]; then \
echo " PY $(notdir $$f)"; \
else \
echo ${ROOT}/sm_cm_config/src/xml_generate.py -d ${ROOT} $$f; \
fi; \
python ${ROOT}/sm_cm_config/src/xml_generate.py -d ${ROOT} $$f; \
done

#
# Zynq address table -- MCU code
#
ZynqMon_addresses.c ZynqMon_addresses.h &: ${YAML_FILES}
python ${ROOT}/sm_cm_config/src/mcu_generate.py -o $@ ${YAML_FILES}
@if [ 'x${VERBOSE}' = x ]; \
then \
echo " PY $(notdir $?)"; \
else \
echo ${ROOT}/sm_cm_config/src/mcu_generate.py -o $@ ${YAML_FILES}; \
fi
@python ${ROOT}/sm_cm_config/src/mcu_generate.py -o $@ ${YAML_FILES}

# these rules are required to force the generation of the ZynqMon_addresses.c
# and .h file. The second one depends on the .h file only, but putting that
Expand Down Expand Up @@ -183,4 +204,4 @@ ifneq (${MAKECMDGOALS},clean)
-include ${wildcard ${COMPILER}/*.d} __dummy__
endif

.PHONY: ${COMPILER}
.PHONY: ${COMPILER} release
2 changes: 2 additions & 0 deletions sm_cm_config/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,6 @@ dmypy.json

# testing xml output
src/test.xml
src/test2.xml
.DS_Store
**/*.xml
2 changes: 1 addition & 1 deletion sm_cm_config/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ ignore-imports=yes
ignore-signatures=yes

#Minimum lines number of a similarity.
min-similarity-lines=4
min-similarity-lines=10


[SPELLING]
Expand Down
13 changes: 11 additions & 2 deletions sm_cm_config/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
#sm_cm_config
Configuration files for SM and CM firmware
# sm_cm_config
Configuration file and code to generate the memory mapping between the MCU and the Zynq. Here we generate the C code used on the MCU which sends the data and the XML files used on the Zynq to interpret the data.

On the MCU side, we define which addresses the MCU will send with the data. (python code `mcu_generate.py`)

On the Zynq side, the XML files allow us to decode the memory on the zynq according to the data as laid out in the MCU. (python code `xml_generate.py`)

The input files are in the `data` directory and are given by `zynqmon_<i>.yaml` where `i` refers to the CM revision number.
There are two outputs:
1. The `C` code consists of a `c` and a header file. It is compiled into the MCU binary in the `cm_mcu` repo
1. The xml files must be included in the Zynq in ... (add directory info here)
File renamed without changes.
File renamed without changes.
20 changes: 12 additions & 8 deletions sm_cm_config/src/mcu_generate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#! /usr/bin/env python
""" Generate the C code for the microcontroller using the yaml files in the data directory"""
import os
import sys
import argparse
import subprocess

import yaml

parser = argparse.ArgumentParser(description='Process YAML for MCU.')
Expand All @@ -17,7 +17,7 @@

args = parser.parse_args()

if args.output:
if args.output and args.verbose:
print('Output file name:', args.output)

# sort the input file names.Default appears to be random(or order in the filesystem)
Expand Down Expand Up @@ -118,12 +118,16 @@

# reformat the c file using clang-format
# -style=file:$HOME/src/apollo_cm_mcu/.clang-format
r = subprocess.run(["clang-format", "-i", args.output], check=False)
if r.returncode != 0:
print('clang-format failed')
sys.exit(1)
if args.verbose:
print('clang-format complete')
# if the clang-format fails, we just ignore it
try:
r = subprocess.run(["clang-format", "-i", args.output], check=False)
if r.returncode != 0 and args.verbose:
print('clang-format failed')
if args.verbose:
print('clang-format complete')
except FileNotFoundError as e:
if args.verbose:
print(f"clang-format not found: {e}")

# open output header file for writing.
# first chekc that ZM_VALID_ENTRIES has exactly two entries
Expand Down
Loading

0 comments on commit a26a372

Please sign in to comment.