Merge upstream changes from Marlin 2.1.1
This commit is contained in:
@@ -1,57 +1,97 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# build_all_examples base_branch [resume_point]
|
||||
# Usage:
|
||||
#
|
||||
# build_all_examples [-b|--branch=<branch>] - Branch to fetch from Configurations repo
|
||||
# [-c|--continue] - Continue the paused build
|
||||
# [-d|--debug] - Print extra debug output
|
||||
# [-i|--ini] - Archive ini/json/yml files in the temp config folder
|
||||
# [-l|--limit=#] - Limit the number of builds in this run
|
||||
# [-n|--nobuild] - Don't actually build anything.
|
||||
# [-r|--resume=<path>] - Start at some config in the filesystem order
|
||||
# [-s|--skip] - Do the thing
|
||||
#
|
||||
# build_all_examples [...] branch [resume-from]
|
||||
#
|
||||
|
||||
. mfutil
|
||||
|
||||
GITREPO=https://github.com/MarlinFirmware/Configurations.git
|
||||
STAT_FILE=./.pio/.buildall
|
||||
|
||||
# Check dependencies
|
||||
which curl 1>/dev/null 2>&1 || { echo "curl not found! Please install it."; exit ; }
|
||||
which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ; }
|
||||
usage() { echo "
|
||||
Usage: $SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-r|--resume=<path>]
|
||||
$SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-c|--continue]
|
||||
$SELF [-b|--branch=<branch>] [-d|--debug] [-i|--ini] [-s|--skip]
|
||||
$SELF [-b|--branch=<branch>] [-d|--debug] [-n|--nobuild]
|
||||
$SELF [...] branch [resume-point]
|
||||
"
|
||||
}
|
||||
|
||||
SED=$(command -v gsed 2>/dev/null || command -v sed 2>/dev/null)
|
||||
[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; }
|
||||
# Assume the most recent configs
|
||||
BRANCH=import-2.1.x
|
||||
unset FIRST_CONF
|
||||
EXIT_USAGE=
|
||||
LIMIT=1000
|
||||
|
||||
SELF=`basename "$0"`
|
||||
HERE=`dirname "$0"`
|
||||
while getopts 'b:cdhil:nqr:sv-:' OFLAG; do
|
||||
case "${OFLAG}" in
|
||||
b) BRANCH=$OPTARG ; bugout "Branch: $BRANCH" ;;
|
||||
r) FIRST_CONF="$OPTARG" ; bugout "Resume: $FIRST_CONF" ;;
|
||||
c) CONTINUE=1 ; bugout "Continue" ;;
|
||||
s) CONTSKIP=1 ; bugout "Continue, skipping" ;;
|
||||
i) COPY_INI=1 ; bugout "Archive INI/JSON/YML files" ;;
|
||||
h) EXIT_USAGE=1 ; break ;;
|
||||
l) LIMIT=$OPTARG ; bugout "Limit to $LIMIT build(s)" ;;
|
||||
d|v) DEBUG=1 ; bugout "Debug ON" ;;
|
||||
n) DRYRUN=1 ; bugout "Dry Run" ;;
|
||||
-) IFS="=" read -r ONAM OVAL <<< "$OPTARG"
|
||||
case "$ONAM" in
|
||||
branch) BRANCH=$OVAL ; bugout "Branch: $BRANCH" ;;
|
||||
resume) FIRST_CONF="$OVAL" ; bugout "Resume: $FIRST_CONF" ;;
|
||||
continue) CONTINUE=1 ; bugout "Continue" ;;
|
||||
skip) CONTSKIP=2 ; bugout "Continue, skipping" ;;
|
||||
limit) LIMIT=$OVAL ; bugout "Limit to $LIMIT build(s)" ;;
|
||||
ini) COPY_INI=1 ; bugout "Archive INI/JSON/YML files" ;;
|
||||
help) [[ -z "$OVAL" ]] || perror "option can't take value $OVAL" $ONAM ; EXIT_USAGE=1 ;;
|
||||
debug) DEBUG=1 ; bugout "Debug ON" ;;
|
||||
nobuild) DRYRUN=1 ; bugout "Dry Run" ;;
|
||||
*) EXIT_USAGE=2 ; echo "$SELF: unrecognized option \`--$ONAM'" ; break ;;
|
||||
esac
|
||||
;;
|
||||
*) EXIT_USAGE=2 ; break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check if called in the right location
|
||||
[[ -e "Marlin/src" ]] || { echo -e "This script must be called from a Marlin working copy with:\n ./buildroot/bin/$SELF $1" ; exit ; }
|
||||
# Extra arguments count as BRANCH, FIRST_CONF
|
||||
shift $((OPTIND - 1))
|
||||
[[ $# > 0 ]] && { BRANCH=$1 ; shift 1 ; bugout "BRANCH=$BRANCH" ; }
|
||||
[[ $# > 0 ]] && { FIRST_CONF=$1 ; shift 1 ; bugout "FIRST_CONF=$FIRST_CONF" ; }
|
||||
[[ $# > 0 ]] && { EXIT_USAGE=2 ; echo "too many arguments" ; }
|
||||
|
||||
if [[ $# -lt 1 || $# -gt 2 ]]; then
|
||||
echo "Usage: $SELF base_branch [resume_point]
|
||||
base_branch - Configuration branch to download and build
|
||||
resume_point - Configuration path to start from"
|
||||
exit
|
||||
fi
|
||||
((EXIT_USAGE)) && { usage ; let EXIT_USAGE-- ; exit $EXIT_USAGE ; }
|
||||
|
||||
echo "This script downloads all Configurations and builds Marlin with each one."
|
||||
echo "This script downloads each Configuration and attempts to build it."
|
||||
echo "On failure the last-built configs will be left in your working copy."
|
||||
echo "Restore your configs with 'git checkout -f' or 'git reset --hard HEAD'."
|
||||
|
||||
unset BRANCH
|
||||
unset FIRST_CONF
|
||||
if [[ -f "$STAT_FILE" ]]; then
|
||||
IFS='*' read BRANCH FIRST_CONF <"$STAT_FILE"
|
||||
fi
|
||||
|
||||
# If -c is given start from the last attempted build
|
||||
if [[ $1 == '-c' ]]; then
|
||||
if ((CONTINUE)); then
|
||||
if [[ -z $BRANCH || -z $FIRST_CONF ]]; then
|
||||
echo "Nothing to continue"
|
||||
exit
|
||||
fi
|
||||
elif [[ $1 == '-s' ]]; then
|
||||
elif ((CONTSKIP)); then
|
||||
if [[ -n $BRANCH && -n $FIRST_CONF ]]; then
|
||||
SKIP_CONF=1
|
||||
else
|
||||
echo "Nothing to skip"
|
||||
exit
|
||||
fi
|
||||
else
|
||||
BRANCH=${1:-"import-2.0.x"}
|
||||
FIRST_CONF=$2
|
||||
fi
|
||||
|
||||
# Check if the current repository has unmerged changes
|
||||
@@ -69,33 +109,63 @@ TMP=./.pio/build-$BRANCH
|
||||
|
||||
# Download Configurations into the temporary folder
|
||||
if [[ ! -e "$TMP/README.md" ]]; then
|
||||
echo "Downloading Configurations from GitHub into $TMP"
|
||||
echo "Fetching Configurations from GitHub to $TMP"
|
||||
git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$TMP" || { echo "Failed to clone the configuration repository"; exit ; }
|
||||
else
|
||||
echo "Using previously downloaded Configurations at $TMP"
|
||||
echo "Using cached Configurations at $TMP"
|
||||
fi
|
||||
|
||||
echo -e "Start building now...\n====================="
|
||||
echo -e "Start build...\n====================="
|
||||
shopt -s nullglob
|
||||
IFS='
|
||||
'
|
||||
CONF_TREE=$( ls -d "$TMP"/config/examples/*/ "$TMP"/config/examples/*/*/ "$TMP"/config/examples/*/*/*/ "$TMP"/config/examples/*/*/*/*/ | grep -vE ".+\.(\w+)$" )
|
||||
DOSKIP=0
|
||||
for CONF in $CONF_TREE ; do
|
||||
|
||||
# Get a config's directory name
|
||||
DIR=$( echo $CONF | sed "s|$TMP/config/examples/||" )
|
||||
|
||||
# If looking for a config, skip others
|
||||
[[ $FIRST_CONF ]] && [[ $FIRST_CONF != $DIR && "$FIRST_CONF/" != $DIR ]] && continue
|
||||
# Once found, stop looking
|
||||
unset FIRST_CONF
|
||||
|
||||
# If skipping, don't build the found one
|
||||
[[ $SKIP_CONF ]] && { unset SKIP_CONF ; continue ; }
|
||||
|
||||
# ...if skipping, don't build this one
|
||||
compgen -G "${CONF}Con*.h" > /dev/null || continue
|
||||
echo "${BRANCH}*${DIR}" >"$STAT_FILE"
|
||||
"$HERE/build_example" "internal" "$TMP" "$DIR" || { echo "Failed to build $DIR"; exit ; }
|
||||
|
||||
# Build or print build command for --nobuild
|
||||
if [[ $DRYRUN ]]; then
|
||||
echo -e "\033[0;32m[DRYRUN] build_example internal \"$TMP\" \"$DIR\"\033[0m"
|
||||
else
|
||||
# Remember where we are in case of failure
|
||||
echo "${BRANCH}*${DIR}" >"$STAT_FILE"
|
||||
# Build folder is unknown so delete all report files
|
||||
if [[ $COPY_INI ]]; then
|
||||
IFIND='find ./.pio/build/ -name "config.ini" -o -name "schema.json" -o -name "schema.yml"'
|
||||
$IFIND -exec rm "{}" \;
|
||||
fi
|
||||
((DEBUG)) && echo "\"$HERE/build_example\" internal \"$TMP\" \"$DIR\""
|
||||
"$HERE/build_example" internal "$TMP" "$DIR" || { echo "Failed to build $DIR"; exit ; }
|
||||
# Build folder is unknown so copy all report files
|
||||
[[ $COPY_INI ]] && $IFIND -exec cp "{}" "$CONF" \;
|
||||
fi
|
||||
|
||||
((--LIMIT)) || { echo "Limit reached" ; PAUSE=1 ; break ; }
|
||||
|
||||
done
|
||||
|
||||
# Delete the temp folder and build state
|
||||
[[ -e "$TMP/config/examples" ]] && rm -rf "$TMP"
|
||||
rm "$STAT_FILE"
|
||||
# Delete the build state if not paused early
|
||||
[[ $PAUSE ]] || rm "$STAT_FILE"
|
||||
|
||||
# Delete the temp folder if not preserving generated INI files
|
||||
if [[ -e "$TMP/config/examples" ]]; then
|
||||
if [[ $COPY_INI ]]; then
|
||||
OPEN=$( which gnome-open xdg-open open | head -n1 )
|
||||
$OPEN "$TMP"
|
||||
elif [[ ! $PAUSE ]]; then
|
||||
rm -rf "$TMP"
|
||||
fi
|
||||
fi
|
||||
|
@@ -5,6 +5,8 @@
|
||||
# Usage: build_example internal config-home config-folder
|
||||
#
|
||||
|
||||
. mfutil
|
||||
|
||||
# Require 'internal' as the first argument
|
||||
[[ "$1" == "internal" ]] || { echo "Don't call this script directly, use build_all_examples instead." ; exit 1 ; }
|
||||
|
||||
@@ -22,8 +24,15 @@ cp "$SUB"/Configuration_adv.h Marlin/ 2>/dev/null
|
||||
cp "$SUB"/_Bootscreen.h Marlin/ 2>/dev/null
|
||||
cp "$SUB"/_Statusscreen.h Marlin/ 2>/dev/null
|
||||
|
||||
set -e
|
||||
|
||||
# Strip #error lines from Configuration.h
|
||||
IFS=$'\n'; set -f
|
||||
$SED -i~ -e "20,30{/#error/d}" Marlin/Configuration.h
|
||||
rm Marlin/Configuration.h~
|
||||
unset IFS; set +f
|
||||
|
||||
echo "Building the firmware now..."
|
||||
HERE=`dirname "$0"`
|
||||
$HERE/mftest -a -n1 || { echo "Failed"; exit 1; }
|
||||
$HERE/mftest -s -a -n1 || { echo "Failed"; exit 1; }
|
||||
|
||||
echo "Success"
|
||||
|
14
buildroot/bin/ci_src_filter
Executable file
14
buildroot/bin/ci_src_filter
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# exit on first failure
|
||||
set -e
|
||||
|
||||
SED=$(which gsed sed | head -n1)
|
||||
FN="platformio.ini"
|
||||
|
||||
if [[ $1 == "-n" ]]; then
|
||||
"${SED}" -i "s/default_src_filter/org_src_filter/" $FN
|
||||
"${SED}" -i "/org_src_filter/ s/^/default_src_filter = +<src\/*>\n/" $FN
|
||||
else
|
||||
git checkout $FN 2>/dev/null
|
||||
fi
|
@@ -3,7 +3,7 @@
|
||||
# mftest Select a test to apply and build
|
||||
# mftest -b [#] Build the auto-detected environment
|
||||
# mftest -u [#] Upload the auto-detected environment
|
||||
# mftest [name] [index] [-y] Set config options and optionally build a test
|
||||
# mftest -tname -n# [-y] Set config options and optionally build a test
|
||||
#
|
||||
|
||||
[[ -d Marlin/src ]] || { echo "Please 'cd' to the Marlin repo root." ; exit 1 ; }
|
||||
@@ -17,6 +17,7 @@ usage() {
|
||||
Usage: mftest [-t|--env=<env|index>] [-n|--num=<num>] [-m|--make] [-y|--build=<Y|n>]
|
||||
mftest [-a|--autobuild]
|
||||
mftest [-r|--rebuild]
|
||||
mftest [-s|--silent]
|
||||
mftest [-u|--autoupload] [-n|--num=<num>]
|
||||
|
||||
OPTIONS
|
||||
@@ -29,8 +30,9 @@ OPTIONS
|
||||
-u --autoupload PIO Upload using the MOTHERBOARD environment.
|
||||
-v --verbose Extra output for debugging.
|
||||
-s --silent Silence build output from PlatformIO.
|
||||
-d --default Restore to defaults before applying configs.
|
||||
|
||||
env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36 t40|t41
|
||||
env shortcuts: tree due esp lin lp8|lpc8 lp9|lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36 t40|t41
|
||||
"
|
||||
}
|
||||
|
||||
@@ -43,6 +45,7 @@ shopt -s extglob nocasematch
|
||||
|
||||
# Matching patterns
|
||||
ISNUM='^[0-9]+$'
|
||||
ISRST='^(restore)_'
|
||||
ISCMD='^(restore|opt|exec|use|pins|env)_'
|
||||
ISEXEC='^exec_'
|
||||
ISCONT='\\ *$'
|
||||
@@ -52,9 +55,10 @@ TESTENV='-'
|
||||
CHOICE=0
|
||||
DEBUG=0
|
||||
|
||||
while getopts 'abhmruvyn:t:-:' OFLAG; do
|
||||
while getopts 'abdhmrsuvyn:t:-:' OFLAG; do
|
||||
case "${OFLAG}" in
|
||||
a) AUTO_BUILD=1 ; bugout "Auto-Build target..." ;;
|
||||
d) DL_DEFAULTS=1 ; bugout "Restore to defaults..." ;;
|
||||
h) EXIT_USAGE=1 ;;
|
||||
m) USE_MAKE=1 ; bugout "Using make with Docker..." ;;
|
||||
n) case "$OPTARG" in
|
||||
@@ -84,8 +88,10 @@ while getopts 'abhmruvyn:t:-:' OFLAG; do
|
||||
esac
|
||||
;;
|
||||
rebuild) REBUILD=1 ; bugout "Rebuilding previous..." ;;
|
||||
silent) SILENT_FLAG="-s" ;;
|
||||
make) USE_MAKE=1 ; bugout "Using make with Docker..." ;;
|
||||
debug|verbose) DEBUG=1 ; bugout "Debug ON" ;;
|
||||
default) DL_DEFAULTS=1 ; bugout "Restore to defaults..." ;;
|
||||
build) case "$OVAL" in
|
||||
''|y|yes) BUILD_YES='Y' ;;
|
||||
n|no) BUILD_YES='N' ;;
|
||||
@@ -150,12 +156,12 @@ if ((AUTO_BUILD)); then
|
||||
*) SYS='uni' ;;
|
||||
esac
|
||||
echo ; echo -n "Auto " ; ((AUTO_BUILD == 2)) && echo "Upload..." || echo "Build..."
|
||||
MB=$( grep -E "^\s*#define MOTHERBOARD" Marlin/Configuration.h | awk '{ print $3 }' | $SED 's/BOARD_//' )
|
||||
MB=$( grep -E "^\s*#define MOTHERBOARD" Marlin/Configuration.h | awk '{ print $3 }' | $SED 's/BOARD_//;s/\r//' )
|
||||
[[ -z $MB ]] && { echo "Error - Can't read MOTHERBOARD setting." ; exit 1 ; }
|
||||
BLINE=$( grep -E "define\s+BOARD_$MB\b" Marlin/src/core/boards.h )
|
||||
BNUM=$( $SED -E 's/^.+BOARD_[^ ]+ +([0-9]+).+$/\1/' <<<"$BLINE" )
|
||||
BDESC=$( $SED -E 's/^.+\/\/ *(.+)$/\1/' <<<"$BLINE" )
|
||||
[[ -z $BNUM ]] && { echo "Error - Can't find $MB in boards list." ; exit 1 ; }
|
||||
[[ -z $BNUM ]] && { echo "Error - Can't find BOARD_$MB in core/boards.h." ; exit 1 ; }
|
||||
ENVS=( $( grep -EA1 "MB\(.*\b$MB\b.*\)" Marlin/src/pins/pins.h | grep -E "#include.+//.+(env|$SYS):[^ ]+" | grep -oE "(env|$SYS):[^ ]+" | $SED -E "s/(env|$SYS)://" ) )
|
||||
[[ -z $ENVS ]] && { errout "Error - Can't find target(s) for $MB ($BNUM)." ; exit 1 ; }
|
||||
ECOUNT=${#ENVS[*]}
|
||||
@@ -280,6 +286,11 @@ if [[ $CHOICE == 0 ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Restore to defaults if requested
|
||||
#
|
||||
((DL_DEFAULTS)) && use_example_configs
|
||||
|
||||
#
|
||||
# Run the specified test lines
|
||||
#
|
||||
@@ -301,6 +312,7 @@ echo "$OUT" | {
|
||||
}
|
||||
((IND == CHOICE)) && {
|
||||
GOTX=1
|
||||
[[ -n $DL_DEFAULTS && $LINE =~ $ISRST ]] && LINE="use_example_configs"
|
||||
[[ $CMD == "" ]] && CMD="$LINE" || CMD=$( echo -e "$CMD$LINE" | $SED -e 's/\\//g' | $SED -E 's/ +/ /g' )
|
||||
[[ $LINE =~ $ISCONT ]] || { echo "$CMD" ; eval "$CMD" ; CMD="" ; }
|
||||
}
|
||||
|
22
buildroot/bin/mfutil
Executable file
22
buildroot/bin/mfutil
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# mfutil - check env and define helpers
|
||||
#
|
||||
|
||||
# Check dependencies
|
||||
which curl 1>/dev/null 2>&1 || { echo "curl not found! Please install it."; exit ; }
|
||||
which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ; }
|
||||
|
||||
SED=$(command -v gsed 2>/dev/null || command -v sed 2>/dev/null)
|
||||
[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; }
|
||||
|
||||
OPEN=$( which gnome-open xdg-open open | head -n1 )
|
||||
|
||||
SELF=`basename "$0"`
|
||||
HERE=`dirname "$0"`
|
||||
|
||||
# Check if called in the right location
|
||||
[[ -e "Marlin/src" ]] || { echo -e "This script must be called from a Marlin working copy with:\n ./buildroot/bin/$SELF $1" ; exit ; }
|
||||
|
||||
perror() { echo -e "$0: \033[0;31m$1 -- $2\033[0m" ; }
|
||||
bugout() { ((DEBUG)) && echo -e "\033[0;32m$1\033[0m" ; }
|
33
buildroot/bin/opt_find
Executable file
33
buildroot/bin/opt_find
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# opt_find
|
||||
# Find one or more Marlin options - Configuration lines starting with #define
|
||||
#
|
||||
|
||||
MYNAME=$(basename $0)
|
||||
|
||||
[[ $# == 0 ]] && ONE="-h" || ONE=$1
|
||||
|
||||
COMM="(//\\s*)?" ; TYPE=""
|
||||
case "$ONE" in
|
||||
-d|--disabled )
|
||||
shift ; COMM="(//\\s*)" ; TYPE="disabled " ;;
|
||||
-e|--enabled )
|
||||
shift ; COMM="" ; TYPE="enabled " ;;
|
||||
-h|--help )
|
||||
echo "$MYNAME [-d|--disabled|-e|--enabled] STRING ... Find matching Marlin configuration options."
|
||||
echo ; shift ;;
|
||||
-* )
|
||||
echo "Unknown option $ONE" ; shift ;;
|
||||
esac
|
||||
|
||||
while [[ $# > 0 ]]; do
|
||||
DID=0
|
||||
for FN in Configuration Configuration_adv; do
|
||||
FOUND=$( grep -HEn "^\s*${COMM}#define\s+[A-Z0-9_]*${1}" "Marlin/$FN.h" 2>/dev/null )
|
||||
[[ -n "$FOUND" ]] && { echo "$FOUND" ; DID=1 ; }
|
||||
done
|
||||
((DID)) || { echo "ERROR: ${MYNAME} - No ${TYPE}match for ${1}" ; exit 9; }
|
||||
shift
|
||||
echo
|
||||
done
|
@@ -1,5 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
git checkout Marlin/Configuration*.h 2>/dev/null
|
||||
git checkout Marlin/src/pins/ramps/pins_RAMPS.h 2>/dev/null
|
||||
rm -f Marlin/_Bootscreen.h Marlin/_Statusscreen.h
|
||||
rm -f Marlin/_Bootscreen.h Marlin/_Statusscreen.h marlin_config.json .pio/build/mc.zip
|
||||
|
||||
if [[ $1 == '-d' || $1 == '--default' ]]; then
|
||||
use_example_configs
|
||||
else
|
||||
git checkout Marlin/Configuration.h 2>/dev/null
|
||||
git checkout Marlin/Configuration_adv.h 2>/dev/null
|
||||
git checkout Marlin/src/pins/ramps/pins_RAMPS.h 2>/dev/null
|
||||
fi
|
||||
|
@@ -1,21 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
IFS=: read -r PART1 PART2 <<< "$@"
|
||||
[ -n "${PART2}" ] && { REPO="$PART1" ; RDIR="${PART2// /%20}" ; } \
|
||||
|| { REPO=bugfix-2.0.x ; RDIR="${PART1// /%20}" ; }
|
||||
EXAMPLES="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/examples"
|
||||
#
|
||||
# use_example_configs [repo:]configpath
|
||||
#
|
||||
# Examples:
|
||||
# use_example_configs
|
||||
# use_example_configs Creality/CR-10/CrealityV1
|
||||
# use_example_configs release-2.0.9.4:Creality/CR-10/CrealityV1
|
||||
#
|
||||
# If a configpath has spaces (or quotes) escape them or enquote the path
|
||||
#
|
||||
|
||||
which curl >/dev/null && TOOL='curl -L -s -S -f -o wgot'
|
||||
which wget >/dev/null && TOOL='wget -q -O wgot'
|
||||
|
||||
CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
|
||||
[[ $CURR == "bugfix-2.0.x" ]] && BRANCH=bugfix-2.0.x || BRANCH=bugfix-2.1.x
|
||||
|
||||
REPO=$BRANCH
|
||||
|
||||
if [[ $# > 0 ]]; then
|
||||
IFS=: read -r PART1 PART2 <<< "$@"
|
||||
[[ -n $PART2 ]] && { UDIR="$PART2" ; REPO="$PART1" ; } \
|
||||
|| { UDIR="$PART1" ; }
|
||||
RDIR="${UDIR// /%20}"
|
||||
echo "Fetching $UDIR configurations from $REPO..."
|
||||
EXAMPLES="examples/$RDIR"
|
||||
else
|
||||
EXAMPLES="default"
|
||||
fi
|
||||
|
||||
CONFIGS="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/${EXAMPLES}"
|
||||
|
||||
restore_configs
|
||||
|
||||
cd Marlin
|
||||
|
||||
$TOOL "$EXAMPLES/$RDIR/Configuration.h" >/dev/null 2>&1 && mv wgot Configuration.h
|
||||
$TOOL "$EXAMPLES/$RDIR/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration_adv.h
|
||||
$TOOL "$EXAMPLES/$RDIR/_Bootscreen.h" >/dev/null 2>&1 && mv wgot _Bootscreen.h
|
||||
$TOOL "$EXAMPLES/$RDIR/_Statusscreen.h" >/dev/null 2>&1 && mv wgot _Statusscreen.h
|
||||
$TOOL "$CONFIGS/Configuration.h" >/dev/null 2>&1 && mv wgot Configuration.h
|
||||
$TOOL "$CONFIGS/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration_adv.h
|
||||
$TOOL "$CONFIGS/_Bootscreen.h" >/dev/null 2>&1 && mv wgot _Bootscreen.h
|
||||
$TOOL "$CONFIGS/_Statusscreen.h" >/dev/null 2>&1 && mv wgot _Statusscreen.h
|
||||
|
||||
rm -f wgot
|
||||
cd - >/dev/null
|
||||
|
@@ -2,23 +2,19 @@
|
||||
"build": {
|
||||
"core": "stm32",
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DSTM32F401xx -DARDUINO_STEVAL",
|
||||
"extra_flags": "-DSTM32F401xx",
|
||||
"f_cpu": "84000000L",
|
||||
"hwids": [
|
||||
[
|
||||
"0x1EAF",
|
||||
"0x0003"
|
||||
],
|
||||
[
|
||||
"0x0483",
|
||||
"0x3748"
|
||||
"0xDF11"
|
||||
]
|
||||
],
|
||||
"mcu": "stm32f401vet6",
|
||||
"variant": "MARLIN_STEVAL_F401VE"
|
||||
"mcu": "stm32f401rct6",
|
||||
"variant": "MARLIN_ARTILLERY_RUBY"
|
||||
},
|
||||
"debug": {
|
||||
"jlink_device": "STM32F401VE",
|
||||
"jlink_device": "STM32F401RC",
|
||||
"openocd_target": "stm32f4x",
|
||||
"svd_path": "STM32F40x.svd",
|
||||
"tools": {
|
||||
@@ -44,11 +40,11 @@
|
||||
"arduino",
|
||||
"stm32cube"
|
||||
],
|
||||
"name": "STM32F401VE (96k RAM. 512k Flash)",
|
||||
"name": "STM32F401RC (64k RAM. 256k Flash)",
|
||||
"upload": {
|
||||
"disable_flushing": false,
|
||||
"maximum_ram_size": 98304,
|
||||
"maximum_size": 514288,
|
||||
"maximum_ram_size": 65536,
|
||||
"maximum_size": 262144,
|
||||
"protocol": "stlink",
|
||||
"protocols": [
|
||||
"stlink",
|
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"build": {
|
||||
"core": "stm32",
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DSTM32F4 -DSTM32F407xx -DSTM32F40_41xxx",
|
||||
"f_cpu": "168000000L",
|
||||
"hwids": [
|
||||
[
|
||||
"0x1EAF",
|
||||
"0x0003"
|
||||
],
|
||||
[
|
||||
"0x0483",
|
||||
"0x3748"
|
||||
]
|
||||
],
|
||||
"mcu": "stm32f407vet6",
|
||||
"variant": "MARLIN_BIGTREE_BTT002"
|
||||
},
|
||||
"debug": {
|
||||
"jlink_device": "STM32F407VE",
|
||||
"openocd_target": "stm32f4x",
|
||||
"svd_path": "STM32F40x.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino"
|
||||
],
|
||||
"name": "STM32F407VE (192k RAM. 512k Flash)",
|
||||
"upload": {
|
||||
"disable_flushing": false,
|
||||
"maximum_ram_size": 131072,
|
||||
"maximum_size": 524288,
|
||||
"protocol": "stlink",
|
||||
"protocols": [
|
||||
"stlink",
|
||||
"dfu",
|
||||
"jlink"
|
||||
],
|
||||
"offset_address": "0x8008000",
|
||||
"require_upload_port": true,
|
||||
"use_1200bps_touch": false,
|
||||
"wait_for_upload_port": false
|
||||
},
|
||||
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f407ve.html",
|
||||
"vendor": "ST"
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"build": {
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DSTM32F4 -DSTM32F429xx",
|
||||
"f_cpu": "168000000L",
|
||||
"mcu": "stm32f429zgt6",
|
||||
"product_line": "STM32F429xx",
|
||||
"variant": "MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429"
|
||||
},
|
||||
"connectivity": [
|
||||
"can"
|
||||
],
|
||||
"debug": {
|
||||
"default_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"jlink_device": "STM32F429ZG",
|
||||
"onboard_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"openocd_board": "stm32f429",
|
||||
"openocd_target": "stm32f4x",
|
||||
"svd_path": "STM32F429x.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"cmsis",
|
||||
"mbed",
|
||||
"stm32cube",
|
||||
"libopencm3",
|
||||
"zephyr"
|
||||
],
|
||||
"name": "STM32F429ZG (128k RAM, 64k CCM RAM, 1024k Flash",
|
||||
"upload": {
|
||||
"disable_flushing": false,
|
||||
"maximum_ram_size": 131072,
|
||||
"maximum_size": 1048576,
|
||||
"protocol": "stlink",
|
||||
"protocols": [
|
||||
"stlink",
|
||||
"dfu",
|
||||
"jlink"
|
||||
],
|
||||
"require_upload_port": true,
|
||||
"use_1200bps_touch": false,
|
||||
"wait_for_upload_port": false
|
||||
},
|
||||
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f429-439.html",
|
||||
"vendor": "ST"
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"build": {
|
||||
"core": "stm32",
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DSTM32F401xx",
|
||||
"f_cpu": "84000000L",
|
||||
"hwids": [
|
||||
[
|
||||
"0x1EAF",
|
||||
"0x0003"
|
||||
],
|
||||
[
|
||||
"0x0483",
|
||||
"0x3748"
|
||||
]
|
||||
],
|
||||
"ldscript": "ldscript.ld",
|
||||
"mcu": "stm32f401rct6",
|
||||
"variant": "MARLIN_CREALITY_STM32F401RC"
|
||||
},
|
||||
"debug": {
|
||||
"jlink_device": "STM32F401RC",
|
||||
"openocd_target": "stm32f4x",
|
||||
"svd_path": "STM32F40x.svd",
|
||||
"tools": {
|
||||
"stlink": {
|
||||
"server": {
|
||||
"arguments": [
|
||||
"-f",
|
||||
"scripts/interface/stlink.cfg",
|
||||
"-c",
|
||||
"transport select hla_swd",
|
||||
"-f",
|
||||
"scripts/target/stm32f4x.cfg",
|
||||
"-c",
|
||||
"reset_config none"
|
||||
],
|
||||
"executable": "bin/openocd",
|
||||
"package": "tool-openocd"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"stm32cube"
|
||||
],
|
||||
"name": "STM32F401RC (64k RAM. 256k Flash)",
|
||||
"upload": {
|
||||
"disable_flushing": false,
|
||||
"maximum_ram_size": 65536,
|
||||
"maximum_size": 262144,
|
||||
"protocol": "stlink",
|
||||
"protocols": [
|
||||
"stlink",
|
||||
"dfu",
|
||||
"jlink"
|
||||
],
|
||||
"require_upload_port": true,
|
||||
"use_1200bps_touch": false,
|
||||
"wait_for_upload_port": false
|
||||
},
|
||||
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f401rc.html",
|
||||
"vendor": "Generic"
|
||||
}
|
@@ -14,7 +14,6 @@
|
||||
"0x3748"
|
||||
]
|
||||
],
|
||||
"ldscript": "stm32f401rc.ld",
|
||||
"mcu": "stm32f401rct6",
|
||||
"variant": "MARLIN_FYSETC_CHEETAH_V20"
|
||||
},
|
||||
@@ -56,7 +55,7 @@
|
||||
"dfu",
|
||||
"jlink"
|
||||
],
|
||||
"offset_address": "0x800C000",
|
||||
"offset_address": "0x8008000",
|
||||
"require_upload_port": true,
|
||||
"use_1200bps_touch": false,
|
||||
"wait_for_upload_port": false
|
||||
|
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"build": {
|
||||
"core": "stm32",
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DSTM32F407xx -DSTM32F4",
|
||||
"f_cpu": "168000000L",
|
||||
"hwids": [
|
||||
[
|
||||
"0x1EAF",
|
||||
"0x0003"
|
||||
],
|
||||
[
|
||||
"0x0483",
|
||||
"0x3748"
|
||||
]
|
||||
],
|
||||
"mcu": "stm32f407vet6",
|
||||
"product_line": "STM32F407xx",
|
||||
"variant": "Generic_F4x7Vx"
|
||||
},
|
||||
"debug": {
|
||||
"default_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"jlink_device": "STM32F407VE",
|
||||
"openocd_extra_args": [
|
||||
"-c",
|
||||
"reset_config none"
|
||||
],
|
||||
"openocd_target": "stm32f4x",
|
||||
"svd_path": "STM32F40x.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"cmsis",
|
||||
"stm32cube",
|
||||
"libopencm3"
|
||||
],
|
||||
"name": "STM32F407VE (128k RAM, 64k CCM RAM, 512k Flash",
|
||||
"upload": {
|
||||
"disable_flushing": false,
|
||||
"maximum_ram_size": 131072,
|
||||
"maximum_size": 524288,
|
||||
"protocol": "stlink",
|
||||
"protocols": [
|
||||
"stlink",
|
||||
"dfu",
|
||||
"jlink"
|
||||
],
|
||||
"require_upload_port": true,
|
||||
"use_1200bps_touch": false,
|
||||
"wait_for_upload_port": false
|
||||
},
|
||||
"url": "https://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32-high-performance-mcus/stm32f4-series/stm32f407-417/stm32f407vg.html",
|
||||
"vendor": "Generic"
|
||||
}
|
50
buildroot/share/PlatformIO/boards/marlin_STM32F429VGT6.json
Normal file
50
buildroot/share/PlatformIO/boards/marlin_STM32F429VGT6.json
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"build": {
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DSTM32F4 -DSTM32F429xx",
|
||||
"f_cpu": "168000000L",
|
||||
"mcu": "stm32f429vgt6",
|
||||
"product_line": "STM32F429xx",
|
||||
"variant": "MARLIN_F4x7Vx"
|
||||
},
|
||||
"connectivity": [
|
||||
"can"
|
||||
],
|
||||
"debug": {
|
||||
"default_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"jlink_device": "STM32F429VG",
|
||||
"onboard_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"openocd_board": "stm32f429",
|
||||
"openocd_target": "stm32f4x",
|
||||
"svd_path": "STM32F429x.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"cmsis",
|
||||
"mbed",
|
||||
"stm32cube",
|
||||
"libopencm3",
|
||||
"zephyr"
|
||||
],
|
||||
"name": "STM32F429VG (128k RAM, 64k CCM RAM, 1024k Flash)",
|
||||
"upload": {
|
||||
"disable_flushing": false,
|
||||
"maximum_ram_size": 131072,
|
||||
"maximum_size": 1048576,
|
||||
"protocol": "stlink",
|
||||
"protocols": [
|
||||
"stlink",
|
||||
"dfu",
|
||||
"jlink"
|
||||
],
|
||||
"require_upload_port": true,
|
||||
"use_1200bps_touch": false,
|
||||
"wait_for_upload_port": false
|
||||
},
|
||||
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f429-439.html",
|
||||
"vendor": "ST"
|
||||
}
|
47
buildroot/share/PlatformIO/boards/marlin_STM32G0B1RE.json
Normal file
47
buildroot/share/PlatformIO/boards/marlin_STM32G0B1RE.json
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"build": {
|
||||
"core": "stm32",
|
||||
"cpu": "cortex-m0plus",
|
||||
"extra_flags": "-DSTM32G0xx -DSTM32G0B1xx",
|
||||
"f_cpu": "64000000L",
|
||||
"framework_extra_flags": {
|
||||
"arduino": "-D__CORTEX_SC=0"
|
||||
},
|
||||
"mcu": "stm32g0b1ret6",
|
||||
"product_line": "STM32G0B1xx",
|
||||
"variant": "MARLIN_G0B1RE"
|
||||
},
|
||||
"debug": {
|
||||
"default_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"jlink_device": "STM32G0B1RE",
|
||||
"onboard_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"openocd_target": "stm32g0x",
|
||||
"svd_path": "STM32G0B1.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"cmsis",
|
||||
"libopencm3",
|
||||
"stm32cube",
|
||||
"zephyr"
|
||||
],
|
||||
"name": "STM32G0B1RE",
|
||||
"upload": {
|
||||
"maximum_ram_size": 147456,
|
||||
"maximum_size": 524288,
|
||||
"protocol": "stlink",
|
||||
"protocols": [
|
||||
"stlink",
|
||||
"jlink",
|
||||
"cmsis-dap",
|
||||
"blackmagic",
|
||||
"mbed"
|
||||
]
|
||||
},
|
||||
"url": "https://www.st.com/content/st_com/en/products/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus/stm32-mainstream-mcus/stm32g0-series/stm32g0x1.html",
|
||||
"vendor": "ST"
|
||||
}
|
61
buildroot/share/PlatformIO/boards/marlin_STM32H743Vx.json
Normal file
61
buildroot/share/PlatformIO/boards/marlin_STM32H743Vx.json
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"build": {
|
||||
"core": "stm32",
|
||||
"cpu": "cortex-m7",
|
||||
"extra_flags": "-DSTM32H7xx -DSTM32H743xx",
|
||||
"f_cpu": "400000000L",
|
||||
"mcu": "stm32h743vit6",
|
||||
"product_line": "STM32H743xx",
|
||||
"variant": "MARLIN_H743Vx"
|
||||
},
|
||||
"connectivity": [
|
||||
"can",
|
||||
"ethernet"
|
||||
],
|
||||
"debug": {
|
||||
"jlink_device": "STM32H743VI",
|
||||
"openocd_target": "stm32h7x",
|
||||
"svd_path": "STM32H7x3.svd",
|
||||
"tools": {
|
||||
"stlink": {
|
||||
"server": {
|
||||
"arguments": [
|
||||
"-f",
|
||||
"scripts/interface/stlink.cfg",
|
||||
"-c",
|
||||
"transport select hla_swd",
|
||||
"-f",
|
||||
"scripts/target/stm32h7x.cfg",
|
||||
"-c",
|
||||
"reset_config none"
|
||||
],
|
||||
"executable": "bin/openocd",
|
||||
"package": "tool-openocd"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"stm32cube"
|
||||
],
|
||||
"name": "STM32H743VI (1024k RAM. 2048k Flash)",
|
||||
"upload": {
|
||||
"disable_flushing": false,
|
||||
"maximum_ram_size": 1048576,
|
||||
"maximum_size": 2097152,
|
||||
"protocol": "stlink",
|
||||
"protocols": [
|
||||
"stlink",
|
||||
"dfu",
|
||||
"jlink",
|
||||
"cmsis-dap"
|
||||
],
|
||||
"offset_address": "0x8020000",
|
||||
"require_upload_port": true,
|
||||
"use_1200bps_touch": false,
|
||||
"wait_for_upload_port": false
|
||||
},
|
||||
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32h743vi.html",
|
||||
"vendor": "ST"
|
||||
}
|
@@ -15,7 +15,7 @@
|
||||
]
|
||||
],
|
||||
"mcu": "stm32f103zet6",
|
||||
"variant": "marlin_CHITU_F103"
|
||||
"variant": "marlin_maple_CHITU_F103"
|
||||
},
|
||||
"debug": {
|
||||
"jlink_device": "STM32F103ZE",
|
@@ -18,7 +18,7 @@
|
||||
"ldscript": "stm32f103xc.ld"
|
||||
},
|
||||
"mcu": "stm32f103rct6",
|
||||
"variant": "marlin_MEEB_3DP"
|
||||
"variant": "marlin_maple_MEEB_3DP"
|
||||
},
|
||||
"debug": {
|
||||
"jlink_device": "STM32F103RC",
|
@@ -5,6 +5,10 @@
|
||||
"extra_flags": "-DSTM32F407xx",
|
||||
"f_cpu": "168000000L",
|
||||
"hwids": [
|
||||
[
|
||||
"0x0483",
|
||||
"0xdf11"
|
||||
],
|
||||
[
|
||||
"0x1EAF",
|
||||
"0x0003"
|
||||
@@ -12,10 +16,6 @@
|
||||
[
|
||||
"0x0483",
|
||||
"0x3748"
|
||||
],
|
||||
[
|
||||
"0x0483",
|
||||
"0xdf11"
|
||||
]
|
||||
],
|
||||
"mcu": "stm32f407vet6",
|
||||
@@ -35,7 +35,7 @@
|
||||
"disable_flushing": false,
|
||||
"maximum_ram_size": 131072,
|
||||
"maximum_size": 524288,
|
||||
"protocol": "stlink",
|
||||
"protocol": "dfu",
|
||||
"protocols": [
|
||||
"stlink",
|
||||
"dfu",
|
50
buildroot/share/PlatformIO/debugging/launch.json
Normal file
50
buildroot/share/PlatformIO/debugging/launch.json
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Remote debugging on STM32 using the "Cortex Debug" extension.
|
||||
*
|
||||
* Copy one or more of the configurations items below into .vscode/launch.json
|
||||
* to add those debug options to the PlatformIO IDE "Run & Debug" panel.
|
||||
*
|
||||
* Examples for BigTreeTech SKR 2 (USB) and Native Simulator. Modify for your own build.
|
||||
*
|
||||
* NOTE: The PlatformIO extension will remove items when regenerating launch.json.
|
||||
*/
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug STM32 (ST-Link)",
|
||||
"request": "launch",
|
||||
"type": "cortex-debug",
|
||||
"servertype": "openocd",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"showDevDebugOutput": false,
|
||||
"configFiles": [ "interface/stlink.cfg", "target/stm32f4x.cfg" ],
|
||||
"device": "stlink",
|
||||
"executable": "${workspaceRoot}/.pio/build/BIGTREE_SKR_2_USB_debug/firmware.elf",
|
||||
"openOCDLaunchCommands": [ "init", "reset init" ],
|
||||
"svdFile": "${env:HOME}/.platformio/platforms/ststm32@12.1.1/misc/svd/STM32F40x.svd",
|
||||
},
|
||||
{
|
||||
"name": "Launch Sim (ggdb)",
|
||||
"request": "launch",
|
||||
"type": "cppdbg",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"program": "${workspaceRoot}/.pio/build/simulator_macos_debug/debug/MarlinSimulator",
|
||||
//"program": "${workspaceRoot}/.pio/build/simulator_linux_debug/MarlinSimulator",
|
||||
//"program": "${workspaceRoot}/.pio/build/simulator_windows/MarlinSimulator",
|
||||
"miDebuggerPath": "/opt/local/bin/ggdb",
|
||||
"MIMode": "gdb"
|
||||
},
|
||||
{
|
||||
"name": "Launch Sim (lldb)",
|
||||
"request": "launch",
|
||||
"type": "cppdbg",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"program": "${workspaceRoot}/.pio/build/simulator_macos_debug/debug/MarlinSimulator",
|
||||
//"program": "${workspaceRoot}/.pio/build/simulator_linux_debug/MarlinSimulator",
|
||||
//"program": "${workspaceRoot}/.pio/build/simulator_windows/MarlinSimulator",
|
||||
//"targetArchitecture": "arm64",
|
||||
"MIMode": "lldb"
|
||||
}
|
||||
]
|
||||
}
|
14
buildroot/share/PlatformIO/ldscripts/crealityPro.ld
Normal file
14
buildroot/share/PlatformIO/ldscripts/crealityPro.ld
Normal file
@@ -0,0 +1,14 @@
|
||||
MEMORY
|
||||
{
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - 40
|
||||
rom (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K
|
||||
}
|
||||
|
||||
/* Provide memory region aliases for common.inc */
|
||||
REGION_ALIAS("REGION_TEXT", rom);
|
||||
REGION_ALIAS("REGION_DATA", ram);
|
||||
REGION_ALIAS("REGION_BSS", ram);
|
||||
REGION_ALIAS("REGION_RODATA", rom);
|
||||
|
||||
/* Let common.inc handle the real work. */
|
||||
INCLUDE common.inc
|
14
buildroot/share/PlatformIO/ldscripts/eryone_ery32_mini.ld
Normal file
14
buildroot/share/PlatformIO/ldscripts/eryone_ery32_mini.ld
Normal file
@@ -0,0 +1,14 @@
|
||||
MEMORY
|
||||
{
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - 4K
|
||||
rom (rx) : ORIGIN = 0x08004000, LENGTH = 512K - 16K
|
||||
}
|
||||
|
||||
/* Provide memory region aliases for common.inc */
|
||||
REGION_ALIAS("REGION_TEXT", rom);
|
||||
REGION_ALIAS("REGION_DATA", ram);
|
||||
REGION_ALIAS("REGION_BSS", ram);
|
||||
REGION_ALIAS("REGION_RODATA", rom);
|
||||
|
||||
/* Let common.inc handle the real work. */
|
||||
INCLUDE common.inc
|
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
* Linker script for Generic STM32F103RC boards, using the generic bootloader (which takes the lower 8k of memory)
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 48K
|
||||
rom (rx) : ORIGIN = 0x08008000, LENGTH = 256K - 32K
|
||||
}
|
||||
|
||||
/* Provide memory region aliases for common.inc */
|
||||
REGION_ALIAS("REGION_TEXT", rom);
|
||||
REGION_ALIAS("REGION_DATA", ram);
|
||||
REGION_ALIAS("REGION_BSS", ram);
|
||||
REGION_ALIAS("REGION_RODATA", rom);
|
||||
|
||||
/* Let common.inc handle the real work. */
|
||||
INCLUDE common.inc
|
@@ -2,18 +2,19 @@
|
||||
# SAMD51_grandcentral_m4.py
|
||||
# Customizations for env:SAMD51_grandcentral_m4
|
||||
#
|
||||
from os.path import join, isfile
|
||||
import shutil
|
||||
from pprint import pprint
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
from os.path import join, isfile
|
||||
import shutil
|
||||
|
||||
Import("env")
|
||||
Import("env")
|
||||
|
||||
mf = env["MARLIN_FEATURES"]
|
||||
rxBuf = mf["RX_BUFFER_SIZE"] if "RX_BUFFER_SIZE" in mf else "0"
|
||||
txBuf = mf["TX_BUFFER_SIZE"] if "TX_BUFFER_SIZE" in mf else "0"
|
||||
mf = env["MARLIN_FEATURES"]
|
||||
rxBuf = mf["RX_BUFFER_SIZE"] if "RX_BUFFER_SIZE" in mf else "0"
|
||||
txBuf = mf["TX_BUFFER_SIZE"] if "TX_BUFFER_SIZE" in mf else "0"
|
||||
|
||||
serialBuf = str(max(int(rxBuf), int(txBuf), 350))
|
||||
serialBuf = str(max(int(rxBuf), int(txBuf), 350))
|
||||
|
||||
build_flags = env.get('BUILD_FLAGS')
|
||||
build_flags.append("-DSERIAL_BUFFER_SIZE=" + serialBuf)
|
||||
env.Replace(BUILD_FLAGS=build_flags)
|
||||
build_flags = env.get('BUILD_FLAGS')
|
||||
build_flags.append("-DSERIAL_BUFFER_SIZE=" + serialBuf)
|
||||
env.Replace(BUILD_FLAGS=build_flags)
|
||||
|
@@ -1,58 +1,20 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py
|
||||
# STM32F103RC_MEEB_3DP.py
|
||||
#
|
||||
try:
|
||||
import configparser
|
||||
except ImportError:
|
||||
import ConfigParser as configparser
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
|
||||
import os
|
||||
Import("env", "projenv")
|
||||
# access to global build environment
|
||||
print(env)
|
||||
# access to project build environment (is used source files in "src" folder)
|
||||
print(projenv)
|
||||
import os
|
||||
Import("env", "projenv")
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read("platformio.ini")
|
||||
flash_size = 0
|
||||
vect_tab_addr = 0
|
||||
|
||||
#com_port = config.get("env:STM32F103RC_meeb", "upload_port")
|
||||
#print('Use the {0:s} to reboot the board to dfu mode.'.format(com_port))
|
||||
for define in env['CPPDEFINES']:
|
||||
if define[0] == "VECT_TAB_ADDR":
|
||||
vect_tab_addr = define[1]
|
||||
if define[0] == "STM32_FLASH_SIZE":
|
||||
flash_size = define[1]
|
||||
|
||||
#
|
||||
# Upload actions
|
||||
#
|
||||
|
||||
def before_upload(source, target, env):
|
||||
print("before_upload")
|
||||
# do some actions
|
||||
# use com_port
|
||||
#
|
||||
env.Execute("pwd")
|
||||
|
||||
def after_upload(source, target, env):
|
||||
print("after_upload")
|
||||
# do some actions
|
||||
#
|
||||
#
|
||||
env.Execute("pwd")
|
||||
|
||||
print("Current build targets", map(str, BUILD_TARGETS))
|
||||
|
||||
env.AddPreAction("upload", before_upload)
|
||||
env.AddPostAction("upload", after_upload)
|
||||
|
||||
flash_size = 0
|
||||
vect_tab_addr = 0
|
||||
|
||||
for define in env['CPPDEFINES']:
|
||||
if define[0] == "VECT_TAB_ADDR":
|
||||
vect_tab_addr = define[1]
|
||||
if define[0] == "STM32_FLASH_SIZE":
|
||||
flash_size = define[1]
|
||||
|
||||
print('Use the {0:s} address as the marlin app entry point.'.format(vect_tab_addr))
|
||||
print('Use the {0:d}KB flash version of stm32f103rct6 chip.'.format(flash_size))
|
||||
|
||||
import marlin
|
||||
marlin.custom_ld_script("STM32F103RC_MEEB_3DP.ld")
|
||||
print('Use the {0:s} address as the marlin app entry point.'.format(vect_tab_addr))
|
||||
print('Use the {0:d}KB flash version of stm32f103rct6 chip.'.format(flash_size))
|
||||
|
@@ -1,26 +1,28 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py
|
||||
# STM32F103RC_fysetc.py
|
||||
#
|
||||
import os
|
||||
from os.path import join
|
||||
from os.path import expandvars
|
||||
Import("env")
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
import os
|
||||
from os.path import join
|
||||
from os.path import expandvars
|
||||
Import("env")
|
||||
|
||||
# Custom HEX from ELF
|
||||
env.AddPostAction(
|
||||
join("$BUILD_DIR", "${PROGNAME}.elf"),
|
||||
env.VerboseAction(" ".join([
|
||||
"$OBJCOPY", "-O ihex", "$TARGET",
|
||||
"\"" + join("$BUILD_DIR", "${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path
|
||||
]), "Building $TARGET"))
|
||||
# Custom HEX from ELF
|
||||
env.AddPostAction(
|
||||
join("$BUILD_DIR", "${PROGNAME}.elf"),
|
||||
env.VerboseAction(" ".join([
|
||||
"$OBJCOPY", "-O ihex", "$TARGET",
|
||||
"\"" + join("$BUILD_DIR", "${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path
|
||||
]), "Building $TARGET"))
|
||||
|
||||
# In-line command with arguments
|
||||
UPLOAD_TOOL="stm32flash"
|
||||
platform = env.PioPlatform()
|
||||
if platform.get_package_dir("tool-stm32duino") != None:
|
||||
UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"")
|
||||
# In-line command with arguments
|
||||
UPLOAD_TOOL="stm32flash"
|
||||
platform = env.PioPlatform()
|
||||
if platform.get_package_dir("tool-stm32duino") != None:
|
||||
UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"")
|
||||
|
||||
env.Replace(
|
||||
UPLOADER=UPLOAD_TOOL,
|
||||
UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr -R -b 115200 -g 0x8000000 -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"" + " $UPLOAD_PORT")
|
||||
)
|
||||
env.Replace(
|
||||
UPLOADER=UPLOAD_TOOL,
|
||||
UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr -R -b 115200 -g 0x8000000 -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"" + " $UPLOAD_PORT")
|
||||
)
|
||||
|
@@ -1,30 +1,31 @@
|
||||
#
|
||||
# STM32F1_create_variant.py
|
||||
#
|
||||
import os,shutil,marlin
|
||||
from SCons.Script import DefaultEnvironment
|
||||
from platformio import util
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
import shutil,marlin
|
||||
from pathlib import Path
|
||||
|
||||
env = DefaultEnvironment()
|
||||
platform = env.PioPlatform()
|
||||
board = env.BoardConfig()
|
||||
Import("env")
|
||||
platform = env.PioPlatform()
|
||||
board = env.BoardConfig()
|
||||
|
||||
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32-maple")
|
||||
assert os.path.isdir(FRAMEWORK_DIR)
|
||||
FRAMEWORK_DIR = Path(platform.get_package_dir("framework-arduinoststm32-maple"))
|
||||
assert FRAMEWORK_DIR.is_dir()
|
||||
|
||||
source_root = os.path.join("buildroot", "share", "PlatformIO", "variants")
|
||||
assert os.path.isdir(source_root)
|
||||
source_root = Path("buildroot/share/PlatformIO/variants")
|
||||
assert source_root.is_dir()
|
||||
|
||||
variant = board.get("build.variant")
|
||||
variant_dir = os.path.join(FRAMEWORK_DIR, "STM32F1", "variants", variant)
|
||||
variant = board.get("build.variant")
|
||||
variant_dir = FRAMEWORK_DIR / "STM32F1/variants" / variant
|
||||
|
||||
source_dir = os.path.join(source_root, variant)
|
||||
assert os.path.isdir(source_dir)
|
||||
source_dir = source_root / variant
|
||||
assert source_dir.is_dir()
|
||||
|
||||
if os.path.isdir(variant_dir):
|
||||
shutil.rmtree(variant_dir)
|
||||
if variant_dir.is_dir():
|
||||
shutil.rmtree(variant_dir)
|
||||
|
||||
if not os.path.isdir(variant_dir):
|
||||
os.mkdir(variant_dir)
|
||||
if not variant_dir.is_dir():
|
||||
variant_dir.mkdir()
|
||||
|
||||
marlin.copytree(source_dir, variant_dir)
|
||||
marlin.copytree(source_dir, variant_dir)
|
||||
|
0
buildroot/share/PlatformIO/scripts/__init__.py
Normal file
0
buildroot/share/PlatformIO/scripts/__init__.py
Normal file
@@ -2,4 +2,5 @@
|
||||
# add_nanolib.py
|
||||
#
|
||||
Import("env")
|
||||
|
||||
env.Append(LINKFLAGS=["--specs=nano.specs"])
|
||||
|
@@ -1,116 +1,126 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/chitu_crypt.py
|
||||
# chitu_crypt.py
|
||||
# Customizations for Chitu boards
|
||||
#
|
||||
import os,random,struct,uuid,marlin
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
import struct,uuid,marlin
|
||||
|
||||
# Relocate firmware from 0x08000000 to 0x08008800
|
||||
marlin.relocate_firmware("0x08008800")
|
||||
board = marlin.env.BoardConfig()
|
||||
|
||||
def calculate_crc(contents, seed):
|
||||
accumulating_xor_value = seed;
|
||||
def calculate_crc(contents, seed):
|
||||
accumulating_xor_value = seed;
|
||||
|
||||
for i in range(0, len(contents), 4):
|
||||
value = struct.unpack('<I', contents[ i : i + 4])[0]
|
||||
accumulating_xor_value = accumulating_xor_value ^ value
|
||||
return accumulating_xor_value
|
||||
for i in range(0, len(contents), 4):
|
||||
value = struct.unpack('<I', contents[ i : i + 4])[0]
|
||||
accumulating_xor_value = accumulating_xor_value ^ value
|
||||
return accumulating_xor_value
|
||||
|
||||
def xor_block(r0, r1, block_number, block_size, file_key):
|
||||
# This is the loop counter
|
||||
loop_counter = 0x0
|
||||
def xor_block(r0, r1, block_number, block_size, file_key):
|
||||
# This is the loop counter
|
||||
loop_counter = 0x0
|
||||
|
||||
# This is the key length
|
||||
key_length = 0x18
|
||||
# This is the key length
|
||||
key_length = 0x18
|
||||
|
||||
# This is an initial seed
|
||||
xor_seed = 0x4BAD
|
||||
# This is an initial seed
|
||||
xor_seed = 0x4BAD
|
||||
|
||||
# This is the block counter
|
||||
block_number = xor_seed * block_number
|
||||
# This is the block counter
|
||||
block_number = xor_seed * block_number
|
||||
|
||||
#load the xor key from the file
|
||||
r7 = file_key
|
||||
#load the xor key from the file
|
||||
r7 = file_key
|
||||
|
||||
for loop_counter in range(0, block_size):
|
||||
# meant to make sure different bits of the key are used.
|
||||
xor_seed = int(loop_counter / key_length)
|
||||
for loop_counter in range(0, block_size):
|
||||
# meant to make sure different bits of the key are used.
|
||||
xor_seed = int(loop_counter / key_length)
|
||||
|
||||
# IP is a scratch register / R12
|
||||
ip = loop_counter - (key_length * xor_seed)
|
||||
# IP is a scratch register / R12
|
||||
ip = loop_counter - (key_length * xor_seed)
|
||||
|
||||
# xor_seed = (loop_counter * loop_counter) + block_number
|
||||
xor_seed = (loop_counter * loop_counter) + block_number
|
||||
# xor_seed = (loop_counter * loop_counter) + block_number
|
||||
xor_seed = (loop_counter * loop_counter) + block_number
|
||||
|
||||
# shift the xor_seed left by the bits in IP.
|
||||
xor_seed = xor_seed >> ip
|
||||
# shift the xor_seed left by the bits in IP.
|
||||
xor_seed = xor_seed >> ip
|
||||
|
||||
# load a byte into IP
|
||||
ip = r0[loop_counter]
|
||||
# load a byte into IP
|
||||
ip = r0[loop_counter]
|
||||
|
||||
# XOR the seed with r7
|
||||
xor_seed = xor_seed ^ r7
|
||||
# XOR the seed with r7
|
||||
xor_seed = xor_seed ^ r7
|
||||
|
||||
# and then with IP
|
||||
xor_seed = xor_seed ^ ip
|
||||
# and then with IP
|
||||
xor_seed = xor_seed ^ ip
|
||||
|
||||
#Now store the byte back
|
||||
r1[loop_counter] = xor_seed & 0xFF
|
||||
#Now store the byte back
|
||||
r1[loop_counter] = xor_seed & 0xFF
|
||||
|
||||
#increment the loop_counter
|
||||
loop_counter = loop_counter + 1
|
||||
#increment the loop_counter
|
||||
loop_counter = loop_counter + 1
|
||||
|
||||
def encrypt_file(input, output_file, file_length):
|
||||
input_file = bytearray(input.read())
|
||||
block_size = 0x800
|
||||
key_length = 0x18
|
||||
def encrypt_file(input, output_file, file_length):
|
||||
input_file = bytearray(input.read())
|
||||
block_size = 0x800
|
||||
key_length = 0x18
|
||||
|
||||
uid_value = uuid.uuid4()
|
||||
file_key = int(uid_value.hex[0:8], 16)
|
||||
uid_value = uuid.uuid4()
|
||||
file_key = int(uid_value.hex[0:8], 16)
|
||||
|
||||
xor_crc = 0xEF3D4323;
|
||||
xor_crc = 0xEF3D4323;
|
||||
|
||||
# the input file is exepcted to be in chunks of 0x800
|
||||
# so round the size
|
||||
while len(input_file) % block_size != 0:
|
||||
input_file.extend(b'0x0')
|
||||
# the input file is exepcted to be in chunks of 0x800
|
||||
# so round the size
|
||||
while len(input_file) % block_size != 0:
|
||||
input_file.extend(b'0x0')
|
||||
|
||||
# write the file header
|
||||
output_file.write(struct.pack(">I", 0x443D2D3F))
|
||||
# encrypt the contents using a known file header key
|
||||
# write the file header
|
||||
output_file.write(struct.pack(">I", 0x443D2D3F))
|
||||
# encrypt the contents using a known file header key
|
||||
|
||||
# write the file_key
|
||||
output_file.write(struct.pack("<I", file_key))
|
||||
# write the file_key
|
||||
output_file.write(struct.pack("<I", file_key))
|
||||
|
||||
#TODO - how to enforce that the firmware aligns to block boundaries?
|
||||
block_count = int(len(input_file) / block_size)
|
||||
print ("Block Count is ", block_count)
|
||||
for block_number in range(0, block_count):
|
||||
block_offset = (block_number * block_size)
|
||||
block_end = block_offset + block_size
|
||||
block_array = bytearray(input_file[block_offset: block_end])
|
||||
xor_block(block_array, block_array, block_number, block_size, file_key)
|
||||
for n in range (0, block_size):
|
||||
input_file[block_offset + n] = block_array[n]
|
||||
#TODO - how to enforce that the firmware aligns to block boundaries?
|
||||
block_count = int(len(input_file) / block_size)
|
||||
print ("Block Count is ", block_count)
|
||||
for block_number in range(0, block_count):
|
||||
block_offset = (block_number * block_size)
|
||||
block_end = block_offset + block_size
|
||||
block_array = bytearray(input_file[block_offset: block_end])
|
||||
xor_block(block_array, block_array, block_number, block_size, file_key)
|
||||
for n in range (0, block_size):
|
||||
input_file[block_offset + n] = block_array[n]
|
||||
|
||||
# update the expected CRC value.
|
||||
xor_crc = calculate_crc(block_array, xor_crc)
|
||||
# update the expected CRC value.
|
||||
xor_crc = calculate_crc(block_array, xor_crc)
|
||||
|
||||
# write CRC
|
||||
output_file.write(struct.pack("<I", xor_crc))
|
||||
# write CRC
|
||||
output_file.write(struct.pack("<I", xor_crc))
|
||||
|
||||
# finally, append the encrypted results.
|
||||
output_file.write(input_file)
|
||||
return
|
||||
# finally, append the encrypted results.
|
||||
output_file.write(input_file)
|
||||
return
|
||||
|
||||
# Encrypt ${PROGNAME}.bin and save it as 'update.cbd'
|
||||
def encrypt(source, target, env):
|
||||
firmware = open(target[0].path, "rb")
|
||||
update = open(target[0].dir.path + '/update.cbd', "wb")
|
||||
length = os.path.getsize(target[0].path)
|
||||
# Encrypt ${PROGNAME}.bin and save it as 'update.cbd'
|
||||
def encrypt(source, target, env):
|
||||
from pathlib import Path
|
||||
|
||||
encrypt_file(firmware, update, length)
|
||||
fwpath = Path(target[0].path)
|
||||
fwsize = fwpath.stat().st_size
|
||||
|
||||
firmware.close()
|
||||
update.close()
|
||||
enname = board.get("build.crypt_chitu")
|
||||
enpath = Path(target[0].dir.path)
|
||||
|
||||
marlin.add_post_action(encrypt);
|
||||
fwfile = fwpath.open("rb")
|
||||
enfile = (enpath / enname).open("wb")
|
||||
|
||||
print(f"Encrypting {fwpath} to {enname}")
|
||||
encrypt_file(fwfile, enfile, fwsize)
|
||||
fwfile.close()
|
||||
enfile.close()
|
||||
fwpath.unlink()
|
||||
|
||||
marlin.relocate_firmware("0x08008800")
|
||||
marlin.add_post_action(encrypt);
|
||||
|
@@ -2,33 +2,38 @@
|
||||
# common-cxxflags.py
|
||||
# Convenience script to apply customizations to CPP flags
|
||||
#
|
||||
Import("env")
|
||||
env.Append(CXXFLAGS=[
|
||||
"-Wno-register"
|
||||
#"-Wno-incompatible-pointer-types",
|
||||
#"-Wno-unused-const-variable",
|
||||
#"-Wno-maybe-uninitialized",
|
||||
#"-Wno-sign-compare"
|
||||
])
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
Import("env")
|
||||
|
||||
#
|
||||
# Add CPU frequency as a compile time constant instead of a runtime variable
|
||||
#
|
||||
def add_cpu_freq():
|
||||
if 'BOARD_F_CPU' in env:
|
||||
env['BUILD_FLAGS'].append('-DBOARD_F_CPU=' + env['BOARD_F_CPU'])
|
||||
cxxflags = [
|
||||
#"-Wno-incompatible-pointer-types",
|
||||
#"-Wno-unused-const-variable",
|
||||
#"-Wno-maybe-uninitialized",
|
||||
#"-Wno-sign-compare"
|
||||
]
|
||||
if "teensy" not in env['PIOENV']:
|
||||
cxxflags += ["-Wno-register"]
|
||||
env.Append(CXXFLAGS=cxxflags)
|
||||
|
||||
# Useful for JTAG debugging
|
||||
#
|
||||
# It will separate release and debug build folders.
|
||||
# It useful to keep two live versions: a debug version for debugging and another for
|
||||
# release, for flashing when upload is not done automatically by jlink/stlink.
|
||||
# Without this, PIO needs to recompile everything twice for any small change.
|
||||
if env.GetBuildType() == "debug" and env.get('UPLOAD_PROTOCOL') not in ['jlink', 'stlink']:
|
||||
env['BUILD_DIR'] = '$PROJECT_BUILD_DIR/$PIOENV/debug'
|
||||
#
|
||||
# Add CPU frequency as a compile time constant instead of a runtime variable
|
||||
#
|
||||
def add_cpu_freq():
|
||||
if 'BOARD_F_CPU' in env:
|
||||
env['BUILD_FLAGS'].append('-DBOARD_F_CPU=' + env['BOARD_F_CPU'])
|
||||
|
||||
# On some platform, F_CPU is a runtime variable. Since it's used to convert from ns
|
||||
# to CPU cycles, this adds overhead preventing small delay (in the order of less than
|
||||
# 30 cycles) to be generated correctly. By using a compile time constant instead
|
||||
# the compiler will perform the computation and this overhead will be avoided
|
||||
add_cpu_freq()
|
||||
# Useful for JTAG debugging
|
||||
#
|
||||
# It will separate release and debug build folders.
|
||||
# It useful to keep two live versions: a debug version for debugging and another for
|
||||
# release, for flashing when upload is not done automatically by jlink/stlink.
|
||||
# Without this, PIO needs to recompile everything twice for any small change.
|
||||
if env.GetBuildType() == "debug" and env.get('UPLOAD_PROTOCOL') not in ['jlink', 'stlink', 'custom']:
|
||||
env['BUILD_DIR'] = '$PROJECT_BUILD_DIR/$PIOENV/debug'
|
||||
|
||||
# On some platform, F_CPU is a runtime variable. Since it's used to convert from ns
|
||||
# to CPU cycles, this adds overhead preventing small delay (in the order of less than
|
||||
# 30 cycles) to be generated correctly. By using a compile time constant instead
|
||||
# the compiler will perform the computation and this overhead will be avoided
|
||||
add_cpu_freq()
|
||||
|
@@ -1,16 +1,16 @@
|
||||
#
|
||||
# common-dependencies-post.py
|
||||
# post:common-dependencies-post.py
|
||||
# Convenience script to add build flags for Marlin Enabled Features
|
||||
#
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
Import("env", "projenv")
|
||||
|
||||
Import("env")
|
||||
Import("projenv")
|
||||
def apply_board_build_flags():
|
||||
if not 'BOARD_CUSTOM_BUILD_FLAGS' in env['MARLIN_FEATURES']:
|
||||
return
|
||||
projenv.Append(CCFLAGS=env['MARLIN_FEATURES']['BOARD_CUSTOM_BUILD_FLAGS'].split())
|
||||
|
||||
def apply_board_build_flags():
|
||||
if not 'BOARD_CUSTOM_BUILD_FLAGS' in env['MARLIN_FEATURES']:
|
||||
return
|
||||
projenv.Append(CCFLAGS=env['MARLIN_FEATURES']['BOARD_CUSTOM_BUILD_FLAGS'].split())
|
||||
|
||||
# We need to add the board build flags in a post script
|
||||
# so the platform build script doesn't overwrite the custom CCFLAGS
|
||||
apply_board_build_flags()
|
||||
# We need to add the board build flags in a post script
|
||||
# so the platform build script doesn't overwrite the custom CCFLAGS
|
||||
apply_board_build_flags()
|
||||
|
@@ -45,19 +45,15 @@
|
||||
#define HAS_SAVED_POSITIONS
|
||||
#endif
|
||||
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT) && DISABLED(EMERGENCY_PARSER)
|
||||
#define HAS_GCODE_M876
|
||||
#endif
|
||||
|
||||
#if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
|
||||
#define HAS_SMART_EFF_MOD
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
#if HAS_MARLINUI_MENU
|
||||
#if ENABLED(BACKLASH_GCODE)
|
||||
#define HAS_MENU_BACKLASH
|
||||
#endif
|
||||
#if ENABLED(LEVEL_BED_CORNERS)
|
||||
#if ENABLED(LCD_BED_TRAMMING)
|
||||
#define HAS_MENU_BED_CORNERS
|
||||
#endif
|
||||
#if ENABLED(CANCEL_OBJECTS)
|
||||
|
@@ -2,317 +2,250 @@
|
||||
# common-dependencies.py
|
||||
# Convenience script to check dependencies and add libs and sources for Marlin Enabled Features
|
||||
#
|
||||
import subprocess,os,re
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
|
||||
PIO_VERSION_MIN = (5, 0, 3)
|
||||
try:
|
||||
from platformio import VERSION as PIO_VERSION
|
||||
weights = (1000, 100, 1)
|
||||
version_min = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION_MIN)])
|
||||
version_cur = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION)])
|
||||
if version_cur < version_min:
|
||||
print()
|
||||
print("**************************************************")
|
||||
print("****** An update to PlatformIO is ******")
|
||||
print("****** required to build Marlin Firmware. ******")
|
||||
print("****** ******")
|
||||
print("****** Minimum version: ", PIO_VERSION_MIN, " ******")
|
||||
print("****** Current Version: ", PIO_VERSION, " ******")
|
||||
print("****** ******")
|
||||
print("****** Update PlatformIO and try again. ******")
|
||||
print("**************************************************")
|
||||
print()
|
||||
exit(1)
|
||||
except SystemExit:
|
||||
exit(1)
|
||||
except:
|
||||
print("Can't detect PlatformIO Version")
|
||||
import subprocess,os,re
|
||||
Import("env")
|
||||
|
||||
from platformio.package.meta import PackageSpec
|
||||
from platformio.project.config import ProjectConfig
|
||||
from platformio.package.meta import PackageSpec
|
||||
from platformio.project.config import ProjectConfig
|
||||
|
||||
Import("env")
|
||||
|
||||
#print(env.Dump())
|
||||
|
||||
try:
|
||||
verbose = int(env.GetProjectOption('custom_verbose'))
|
||||
except:
|
||||
verbose = 0
|
||||
FEATURE_CONFIG = {}
|
||||
|
||||
def blab(str,level=1):
|
||||
if verbose >= level:
|
||||
print("[deps] %s" % str)
|
||||
def validate_pio():
|
||||
PIO_VERSION_MIN = (6, 0, 1)
|
||||
try:
|
||||
from platformio import VERSION as PIO_VERSION
|
||||
weights = (1000, 100, 1)
|
||||
version_min = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION_MIN)])
|
||||
version_cur = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION)])
|
||||
if version_cur < version_min:
|
||||
print()
|
||||
print("**************************************************")
|
||||
print("****** An update to PlatformIO is ******")
|
||||
print("****** required to build Marlin Firmware. ******")
|
||||
print("****** ******")
|
||||
print("****** Minimum version: ", PIO_VERSION_MIN, " ******")
|
||||
print("****** Current Version: ", PIO_VERSION, " ******")
|
||||
print("****** ******")
|
||||
print("****** Update PlatformIO and try again. ******")
|
||||
print("**************************************************")
|
||||
print()
|
||||
exit(1)
|
||||
except SystemExit:
|
||||
exit(1)
|
||||
except:
|
||||
print("Can't detect PlatformIO Version")
|
||||
|
||||
FEATURE_CONFIG = {}
|
||||
def blab(str,level=1):
|
||||
if verbose >= level:
|
||||
print("[deps] %s" % str)
|
||||
|
||||
def add_to_feat_cnf(feature, flines):
|
||||
def add_to_feat_cnf(feature, flines):
|
||||
|
||||
try:
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
except:
|
||||
FEATURE_CONFIG[feature] = {}
|
||||
|
||||
# Get a reference to the FEATURE_CONFIG under construction
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
|
||||
# Split up passed lines on commas or newlines and iterate
|
||||
# Add common options to the features config under construction
|
||||
# For lib_deps replace a previous instance of the same library
|
||||
atoms = re.sub(r',\\s*', '\n', flines).strip().split('\n')
|
||||
for line in atoms:
|
||||
parts = line.split('=')
|
||||
name = parts.pop(0)
|
||||
if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']:
|
||||
feat[name] = '='.join(parts)
|
||||
blab("[%s] %s=%s" % (feature, name, feat[name]), 3)
|
||||
else:
|
||||
for dep in re.split(r",\s*", line):
|
||||
lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0)
|
||||
lib_re = re.compile('(?!^' + lib_name + '\\b)')
|
||||
feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep]
|
||||
blab("[%s] lib_deps = %s" % (feature, dep), 3)
|
||||
|
||||
def load_config():
|
||||
blab("========== Gather [features] entries...")
|
||||
items = ProjectConfig().items('features')
|
||||
for key in items:
|
||||
feature = key[0].upper()
|
||||
if not feature in FEATURE_CONFIG:
|
||||
FEATURE_CONFIG[feature] = { 'lib_deps': [] }
|
||||
add_to_feat_cnf(feature, key[1])
|
||||
|
||||
# Add options matching custom_marlin.MY_OPTION to the pile
|
||||
blab("========== Gather custom_marlin entries...")
|
||||
all_opts = env.GetProjectOptions()
|
||||
for n in all_opts:
|
||||
key = n[0]
|
||||
mat = re.match(r'custom_marlin\.(.+)', key)
|
||||
if mat:
|
||||
try:
|
||||
val = env.GetProjectOption(key)
|
||||
except:
|
||||
val = None
|
||||
if val:
|
||||
opt = mat.group(1).upper()
|
||||
blab("%s.custom_marlin.%s = '%s'" % ( env['PIOENV'], opt, val ))
|
||||
add_to_feat_cnf(opt, val)
|
||||
|
||||
def get_all_known_libs():
|
||||
known_libs = []
|
||||
for feature in FEATURE_CONFIG:
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
if not 'lib_deps' in feat:
|
||||
continue
|
||||
for dep in feat['lib_deps']:
|
||||
known_libs.append(PackageSpec(dep).name)
|
||||
return known_libs
|
||||
|
||||
def get_all_env_libs():
|
||||
env_libs = []
|
||||
lib_deps = env.GetProjectOption('lib_deps')
|
||||
for dep in lib_deps:
|
||||
env_libs.append(PackageSpec(dep).name)
|
||||
return env_libs
|
||||
|
||||
def set_env_field(field, value):
|
||||
proj = env.GetProjectConfig()
|
||||
proj.set("env:" + env['PIOENV'], field, value)
|
||||
|
||||
# All unused libs should be ignored so that if a library
|
||||
# exists in .pio/lib_deps it will not break compilation.
|
||||
def force_ignore_unused_libs():
|
||||
env_libs = get_all_env_libs()
|
||||
known_libs = get_all_known_libs()
|
||||
diff = (list(set(known_libs) - set(env_libs)))
|
||||
lib_ignore = env.GetProjectOption('lib_ignore') + diff
|
||||
blab("Ignore libraries: %s" % lib_ignore)
|
||||
set_env_field('lib_ignore', lib_ignore)
|
||||
|
||||
def apply_features_config():
|
||||
load_config()
|
||||
blab("========== Apply enabled features...")
|
||||
for feature in FEATURE_CONFIG:
|
||||
if not env.MarlinFeatureIsEnabled(feature):
|
||||
continue
|
||||
try:
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
except:
|
||||
FEATURE_CONFIG[feature] = {}
|
||||
|
||||
# Get a reference to the FEATURE_CONFIG under construction
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
|
||||
if 'lib_deps' in feat and len(feat['lib_deps']):
|
||||
blab("========== Adding lib_deps for %s... " % feature, 2)
|
||||
# Split up passed lines on commas or newlines and iterate
|
||||
# Add common options to the features config under construction
|
||||
# For lib_deps replace a previous instance of the same library
|
||||
atoms = re.sub(r',\s*', '\n', flines).strip().split('\n')
|
||||
for line in atoms:
|
||||
parts = line.split('=')
|
||||
name = parts.pop(0)
|
||||
if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']:
|
||||
feat[name] = '='.join(parts)
|
||||
blab("[%s] %s=%s" % (feature, name, feat[name]), 3)
|
||||
else:
|
||||
for dep in re.split(r',\s*', line):
|
||||
lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0)
|
||||
lib_re = re.compile('(?!^' + lib_name + '\\b)')
|
||||
feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep]
|
||||
blab("[%s] lib_deps = %s" % (feature, dep), 3)
|
||||
|
||||
# feat to add
|
||||
deps_to_add = {}
|
||||
def load_features():
|
||||
blab("========== Gather [features] entries...")
|
||||
for key in ProjectConfig().items('features'):
|
||||
feature = key[0].upper()
|
||||
if not feature in FEATURE_CONFIG:
|
||||
FEATURE_CONFIG[feature] = { 'lib_deps': [] }
|
||||
add_to_feat_cnf(feature, key[1])
|
||||
|
||||
# Add options matching custom_marlin.MY_OPTION to the pile
|
||||
blab("========== Gather custom_marlin entries...")
|
||||
for n in env.GetProjectOptions():
|
||||
key = n[0]
|
||||
mat = re.match(r'custom_marlin\.(.+)', key)
|
||||
if mat:
|
||||
try:
|
||||
val = env.GetProjectOption(key)
|
||||
except:
|
||||
val = None
|
||||
if val:
|
||||
opt = mat[1].upper()
|
||||
blab("%s.custom_marlin.%s = '%s'" % ( env['PIOENV'], opt, val ))
|
||||
add_to_feat_cnf(opt, val)
|
||||
|
||||
def get_all_known_libs():
|
||||
known_libs = []
|
||||
for feature in FEATURE_CONFIG:
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
if not 'lib_deps' in feat:
|
||||
continue
|
||||
for dep in feat['lib_deps']:
|
||||
deps_to_add[PackageSpec(dep).name] = dep
|
||||
blab("==================== %s... " % dep, 2)
|
||||
known_libs.append(PackageSpec(dep).name)
|
||||
return known_libs
|
||||
|
||||
# Does the env already have the dependency?
|
||||
deps = env.GetProjectOption('lib_deps')
|
||||
for dep in deps:
|
||||
name = PackageSpec(dep).name
|
||||
if name in deps_to_add:
|
||||
del deps_to_add[name]
|
||||
def get_all_env_libs():
|
||||
env_libs = []
|
||||
lib_deps = env.GetProjectOption('lib_deps')
|
||||
for dep in lib_deps:
|
||||
env_libs.append(PackageSpec(dep).name)
|
||||
return env_libs
|
||||
|
||||
# Are there any libraries that should be ignored?
|
||||
lib_ignore = env.GetProjectOption('lib_ignore')
|
||||
for dep in deps:
|
||||
name = PackageSpec(dep).name
|
||||
if name in deps_to_add:
|
||||
del deps_to_add[name]
|
||||
def set_env_field(field, value):
|
||||
proj = env.GetProjectConfig()
|
||||
proj.set("env:" + env['PIOENV'], field, value)
|
||||
|
||||
# Is there anything left?
|
||||
if len(deps_to_add) > 0:
|
||||
# Only add the missing dependencies
|
||||
set_env_field('lib_deps', deps + list(deps_to_add.values()))
|
||||
# All unused libs should be ignored so that if a library
|
||||
# exists in .pio/lib_deps it will not break compilation.
|
||||
def force_ignore_unused_libs():
|
||||
env_libs = get_all_env_libs()
|
||||
known_libs = get_all_known_libs()
|
||||
diff = (list(set(known_libs) - set(env_libs)))
|
||||
lib_ignore = env.GetProjectOption('lib_ignore') + diff
|
||||
blab("Ignore libraries: %s" % lib_ignore)
|
||||
set_env_field('lib_ignore', lib_ignore)
|
||||
|
||||
if 'build_flags' in feat:
|
||||
f = feat['build_flags']
|
||||
blab("========== Adding build_flags for %s: %s" % (feature, f), 2)
|
||||
new_flags = env.GetProjectOption('build_flags') + [ f ]
|
||||
env.Replace(BUILD_FLAGS=new_flags)
|
||||
def apply_features_config():
|
||||
load_features()
|
||||
blab("========== Apply enabled features...")
|
||||
for feature in FEATURE_CONFIG:
|
||||
if not env.MarlinHas(feature):
|
||||
continue
|
||||
|
||||
if 'extra_scripts' in feat:
|
||||
blab("Running extra_scripts for %s... " % feature, 2)
|
||||
env.SConscript(feat['extra_scripts'], exports="env")
|
||||
feat = FEATURE_CONFIG[feature]
|
||||
|
||||
if 'src_filter' in feat:
|
||||
blab("========== Adding src_filter for %s... " % feature, 2)
|
||||
src_filter = ' '.join(env.GetProjectOption('src_filter'))
|
||||
# first we need to remove the references to the same folder
|
||||
my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter'])
|
||||
cur_srcs = re.findall(r'[+-](<.*?>)', src_filter)
|
||||
for d in my_srcs:
|
||||
if d in cur_srcs:
|
||||
src_filter = re.sub(r'[+-]' + d, '', src_filter)
|
||||
if 'lib_deps' in feat and len(feat['lib_deps']):
|
||||
blab("========== Adding lib_deps for %s... " % feature, 2)
|
||||
|
||||
src_filter = feat['src_filter'] + ' ' + src_filter
|
||||
set_env_field('src_filter', [src_filter])
|
||||
env.Replace(SRC_FILTER=src_filter)
|
||||
# feat to add
|
||||
deps_to_add = {}
|
||||
for dep in feat['lib_deps']:
|
||||
deps_to_add[PackageSpec(dep).name] = dep
|
||||
blab("==================== %s... " % dep, 2)
|
||||
|
||||
if 'lib_ignore' in feat:
|
||||
blab("========== Adding lib_ignore for %s... " % feature, 2)
|
||||
lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']]
|
||||
set_env_field('lib_ignore', lib_ignore)
|
||||
# Does the env already have the dependency?
|
||||
deps = env.GetProjectOption('lib_deps')
|
||||
for dep in deps:
|
||||
name = PackageSpec(dep).name
|
||||
if name in deps_to_add:
|
||||
del deps_to_add[name]
|
||||
|
||||
# Are there any libraries that should be ignored?
|
||||
lib_ignore = env.GetProjectOption('lib_ignore')
|
||||
for dep in deps:
|
||||
name = PackageSpec(dep).name
|
||||
if name in deps_to_add:
|
||||
del deps_to_add[name]
|
||||
|
||||
# Is there anything left?
|
||||
if len(deps_to_add) > 0:
|
||||
# Only add the missing dependencies
|
||||
set_env_field('lib_deps', deps + list(deps_to_add.values()))
|
||||
|
||||
if 'build_flags' in feat:
|
||||
f = feat['build_flags']
|
||||
blab("========== Adding build_flags for %s: %s" % (feature, f), 2)
|
||||
new_flags = env.GetProjectOption('build_flags') + [ f ]
|
||||
env.Replace(BUILD_FLAGS=new_flags)
|
||||
|
||||
if 'extra_scripts' in feat:
|
||||
blab("Running extra_scripts for %s... " % feature, 2)
|
||||
env.SConscript(feat['extra_scripts'], exports="env")
|
||||
|
||||
if 'src_filter' in feat:
|
||||
blab("========== Adding build_src_filter for %s... " % feature, 2)
|
||||
src_filter = ' '.join(env.GetProjectOption('src_filter'))
|
||||
# first we need to remove the references to the same folder
|
||||
my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter'])
|
||||
cur_srcs = re.findall(r'[+-](<.*?>)', src_filter)
|
||||
for d in my_srcs:
|
||||
if d in cur_srcs:
|
||||
src_filter = re.sub(r'[+-]' + d, '', src_filter)
|
||||
|
||||
src_filter = feat['src_filter'] + ' ' + src_filter
|
||||
set_env_field('build_src_filter', [src_filter])
|
||||
env.Replace(SRC_FILTER=src_filter)
|
||||
|
||||
if 'lib_ignore' in feat:
|
||||
blab("========== Adding lib_ignore for %s... " % feature, 2)
|
||||
lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']]
|
||||
set_env_field('lib_ignore', lib_ignore)
|
||||
|
||||
#
|
||||
# Use the compiler to get a list of all enabled features
|
||||
#
|
||||
def load_marlin_features():
|
||||
if 'MARLIN_FEATURES' in env:
|
||||
return
|
||||
|
||||
# Process defines
|
||||
from preprocessor import run_preprocessor
|
||||
define_list = run_preprocessor(env)
|
||||
marlin_features = {}
|
||||
for define in define_list:
|
||||
feature = define[8:].strip().decode().split(' ')
|
||||
feature, definition = feature[0], ' '.join(feature[1:])
|
||||
marlin_features[feature] = definition
|
||||
env['MARLIN_FEATURES'] = marlin_features
|
||||
|
||||
#
|
||||
# Return True if a matching feature is enabled
|
||||
#
|
||||
def MarlinHas(env, feature):
|
||||
load_marlin_features()
|
||||
r = re.compile('^' + feature + '$')
|
||||
found = list(filter(r.match, env['MARLIN_FEATURES']))
|
||||
|
||||
# Defines could still be 'false' or '0', so check
|
||||
some_on = False
|
||||
if len(found):
|
||||
for f in found:
|
||||
val = env['MARLIN_FEATURES'][f]
|
||||
if val in [ '', '1', 'true' ]:
|
||||
some_on = True
|
||||
elif val in env['MARLIN_FEATURES']:
|
||||
some_on = env.MarlinHas(val)
|
||||
|
||||
return some_on
|
||||
|
||||
validate_pio()
|
||||
|
||||
#
|
||||
# Find a compiler, considering the OS
|
||||
#
|
||||
ENV_BUILD_PATH = os.path.join(env.Dictionary('PROJECT_BUILD_DIR'), env['PIOENV'])
|
||||
GCC_PATH_CACHE = os.path.join(ENV_BUILD_PATH, ".gcc_path")
|
||||
def search_compiler():
|
||||
try:
|
||||
filepath = env.GetProjectOption('custom_gcc')
|
||||
blab("Getting compiler from env")
|
||||
return filepath
|
||||
verbose = int(env.GetProjectOption('custom_verbose'))
|
||||
except:
|
||||
pass
|
||||
|
||||
if os.path.exists(GCC_PATH_CACHE):
|
||||
with open(GCC_PATH_CACHE, 'r') as f:
|
||||
return f.read()
|
||||
#
|
||||
# Add a method for other PIO scripts to query enabled features
|
||||
#
|
||||
env.AddMethod(MarlinHas)
|
||||
|
||||
# Find the current platform compiler by searching the $PATH
|
||||
# which will be in a platformio toolchain bin folder
|
||||
path_regex = re.escape(env['PROJECT_PACKAGES_DIR'])
|
||||
#
|
||||
# Add dependencies for enabled Marlin features
|
||||
#
|
||||
apply_features_config()
|
||||
force_ignore_unused_libs()
|
||||
|
||||
# See if the environment provides a default compiler
|
||||
try:
|
||||
gcc = env.GetProjectOption('custom_deps_gcc')
|
||||
except:
|
||||
gcc = "g++"
|
||||
#print(env.Dump())
|
||||
|
||||
if env['PLATFORM'] == 'win32':
|
||||
path_separator = ';'
|
||||
path_regex += r'.*\\bin'
|
||||
gcc += ".exe"
|
||||
else:
|
||||
path_separator = ':'
|
||||
path_regex += r'/.+/bin'
|
||||
|
||||
# Search for the compiler
|
||||
for pathdir in env['ENV']['PATH'].split(path_separator):
|
||||
if not re.search(path_regex, pathdir, re.IGNORECASE):
|
||||
continue
|
||||
for filepath in os.listdir(pathdir):
|
||||
if not filepath.endswith(gcc):
|
||||
continue
|
||||
# Use entire path to not rely on env PATH
|
||||
filepath = os.path.sep.join([pathdir, filepath])
|
||||
# Cache the g++ path to no search always
|
||||
if os.path.exists(ENV_BUILD_PATH):
|
||||
with open(GCC_PATH_CACHE, 'w+') as f:
|
||||
f.write(filepath)
|
||||
|
||||
return filepath
|
||||
|
||||
filepath = env.get('CXX')
|
||||
if filepath == 'CC':
|
||||
filepath = gcc
|
||||
blab("Couldn't find a compiler! Fallback to %s" % filepath)
|
||||
return filepath
|
||||
|
||||
#
|
||||
# Use the compiler to get a list of all enabled features
|
||||
#
|
||||
def load_marlin_features():
|
||||
if 'MARLIN_FEATURES' in env:
|
||||
return
|
||||
|
||||
# Process defines
|
||||
build_flags = env.get('BUILD_FLAGS')
|
||||
build_flags = env.ParseFlagsExtended(build_flags)
|
||||
|
||||
cxx = search_compiler()
|
||||
cmd = ['"' + cxx + '"']
|
||||
|
||||
# Build flags from board.json
|
||||
#if 'BOARD' in env:
|
||||
# cmd += [env.BoardConfig().get("build.extra_flags")]
|
||||
for s in build_flags['CPPDEFINES']:
|
||||
if isinstance(s, tuple):
|
||||
cmd += ['-D' + s[0] + '=' + str(s[1])]
|
||||
else:
|
||||
cmd += ['-D' + s]
|
||||
|
||||
cmd += ['-D__MARLIN_DEPS__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h']
|
||||
cmd = ' '.join(cmd)
|
||||
blab(cmd, 4)
|
||||
define_list = subprocess.check_output(cmd, shell=True).splitlines()
|
||||
marlin_features = {}
|
||||
for define in define_list:
|
||||
feature = define[8:].strip().decode().split(' ')
|
||||
feature, definition = feature[0], ' '.join(feature[1:])
|
||||
marlin_features[feature] = definition
|
||||
env['MARLIN_FEATURES'] = marlin_features
|
||||
|
||||
#
|
||||
# Return True if a matching feature is enabled
|
||||
#
|
||||
def MarlinFeatureIsEnabled(env, feature):
|
||||
load_marlin_features()
|
||||
r = re.compile('^' + feature + '$')
|
||||
found = list(filter(r.match, env['MARLIN_FEATURES']))
|
||||
|
||||
# Defines could still be 'false' or '0', so check
|
||||
some_on = False
|
||||
if len(found):
|
||||
for f in found:
|
||||
val = env['MARLIN_FEATURES'][f]
|
||||
if val in [ '', '1', 'true' ]:
|
||||
some_on = True
|
||||
elif val in env['MARLIN_FEATURES']:
|
||||
some_on = env.MarlinFeatureIsEnabled(val)
|
||||
|
||||
return some_on
|
||||
|
||||
#
|
||||
# Add a method for other PIO scripts to query enabled features
|
||||
#
|
||||
env.AddMethod(MarlinFeatureIsEnabled)
|
||||
|
||||
#
|
||||
# Add dependencies for enabled Marlin features
|
||||
#
|
||||
apply_features_config()
|
||||
force_ignore_unused_libs()
|
||||
from signature import compute_build_signature
|
||||
compute_build_signature(env)
|
||||
|
239
buildroot/share/PlatformIO/scripts/configuration.py
Normal file
239
buildroot/share/PlatformIO/scripts/configuration.py
Normal file
@@ -0,0 +1,239 @@
|
||||
#
|
||||
# configuration.py
|
||||
# Apply options from config.ini to the existing Configuration headers
|
||||
#
|
||||
import re, shutil, configparser
|
||||
from pathlib import Path
|
||||
|
||||
verbose = 0
|
||||
def blab(str,level=1):
|
||||
if verbose >= level: print(f"[config] {str}")
|
||||
|
||||
def config_path(cpath):
|
||||
return Path("Marlin", cpath)
|
||||
|
||||
# Apply a single name = on/off ; name = value ; etc.
|
||||
# TODO: Limit to the given (optional) configuration
|
||||
def apply_opt(name, val, conf=None):
|
||||
if name == "lcd": name, val = val, "on"
|
||||
|
||||
# Create a regex to match the option and capture parts of the line
|
||||
regex = re.compile(rf'^(\s*)(//\s*)?(#define\s+)({name}\b)(\s*)(.*?)(\s*)(//.*)?$', re.IGNORECASE)
|
||||
|
||||
# Find and enable and/or update all matches
|
||||
for file in ("Configuration.h", "Configuration_adv.h"):
|
||||
fullpath = config_path(file)
|
||||
lines = fullpath.read_text().split('\n')
|
||||
found = False
|
||||
for i in range(len(lines)):
|
||||
line = lines[i]
|
||||
match = regex.match(line)
|
||||
if match and match[4].upper() == name.upper():
|
||||
found = True
|
||||
# For boolean options un/comment the define
|
||||
if val in ("on", "", None):
|
||||
newline = re.sub(r'^(\s*)//+\s*(#define)(\s{1,3})?(\s*)', r'\1\2 \4', line)
|
||||
elif val == "off":
|
||||
newline = re.sub(r'^(\s*)(#define)(\s{1,3})?(\s*)', r'\1//\2 \4', line)
|
||||
else:
|
||||
# For options with values, enable and set the value
|
||||
newline = match[1] + match[3] + match[4] + match[5] + val
|
||||
if match[8]:
|
||||
sp = match[7] if match[7] else ' '
|
||||
newline += sp + match[8]
|
||||
lines[i] = newline
|
||||
blab(f"Set {name} to {val}")
|
||||
|
||||
# If the option was found, write the modified lines
|
||||
if found:
|
||||
fullpath.write_text('\n'.join(lines))
|
||||
break
|
||||
|
||||
# If the option didn't appear in either config file, add it
|
||||
if not found:
|
||||
# OFF options are added as disabled items so they appear
|
||||
# in config dumps. Useful for custom settings.
|
||||
prefix = ""
|
||||
if val == "off":
|
||||
prefix, val = "//", "" # Item doesn't appear in config dump
|
||||
#val = "false" # Item appears in config dump
|
||||
|
||||
# Uppercase the option unless already mixed/uppercase
|
||||
added = name.upper() if name.islower() else name
|
||||
|
||||
# Add the provided value after the name
|
||||
if val != "on" and val != "" and val is not None:
|
||||
added += " " + val
|
||||
|
||||
# Prepend the new option after the first set of #define lines
|
||||
fullpath = config_path("Configuration.h")
|
||||
with fullpath.open() as f:
|
||||
lines = f.readlines()
|
||||
linenum = 0
|
||||
gotdef = False
|
||||
for line in lines:
|
||||
isdef = line.startswith("#define")
|
||||
if not gotdef:
|
||||
gotdef = isdef
|
||||
elif not isdef:
|
||||
break
|
||||
linenum += 1
|
||||
lines.insert(linenum, f"{prefix}#define {added} // Added by config.ini\n")
|
||||
fullpath.write_text('\n'.join(lines))
|
||||
|
||||
# Fetch configuration files from GitHub given the path.
|
||||
# Return True if any files were fetched.
|
||||
def fetch_example(path):
|
||||
if path.endswith("/"):
|
||||
path = path[:-1]
|
||||
|
||||
if '@' in path:
|
||||
path, brch = map(strip, path.split('@'))
|
||||
|
||||
url = path.replace("%", "%25").replace(" ", "%20")
|
||||
if not path.startswith('http'):
|
||||
url = "https://raw.githubusercontent.com/MarlinFirmware/Configurations/bugfix-2.1.x/config/%s" % url
|
||||
|
||||
# Find a suitable fetch command
|
||||
if shutil.which("curl") is not None:
|
||||
fetch = "curl -L -s -S -f -o"
|
||||
elif shutil.which("wget") is not None:
|
||||
fetch = "wget -q -O"
|
||||
else:
|
||||
blab("Couldn't find curl or wget", -1)
|
||||
return False
|
||||
|
||||
import os
|
||||
|
||||
# Reset configurations to default
|
||||
os.system("git reset --hard HEAD")
|
||||
|
||||
gotfile = False
|
||||
|
||||
# Try to fetch the remote files
|
||||
for fn in ("Configuration.h", "Configuration_adv.h", "_Bootscreen.h", "_Statusscreen.h"):
|
||||
if os.system("%s wgot %s/%s >/dev/null 2>&1" % (fetch, url, fn)) == 0:
|
||||
shutil.move('wgot', config_path(fn))
|
||||
gotfile = True
|
||||
|
||||
if Path('wgot').exists():
|
||||
shutil.rmtree('wgot')
|
||||
|
||||
return gotfile
|
||||
|
||||
def section_items(cp, sectkey):
|
||||
return cp.items(sectkey) if sectkey in cp.sections() else []
|
||||
|
||||
# Apply all items from a config section
|
||||
def apply_ini_by_name(cp, sect):
|
||||
iniok = True
|
||||
if sect in ('config:base', 'config:root'):
|
||||
iniok = False
|
||||
items = section_items(cp, 'config:base') + section_items(cp, 'config:root')
|
||||
else:
|
||||
items = cp.items(sect)
|
||||
|
||||
for item in items:
|
||||
if iniok or not item[0].startswith('ini_'):
|
||||
apply_opt(item[0], item[1])
|
||||
|
||||
# Apply all config sections from a parsed file
|
||||
def apply_all_sections(cp):
|
||||
for sect in cp.sections():
|
||||
if sect.startswith('config:'):
|
||||
apply_ini_by_name(cp, sect)
|
||||
|
||||
# Apply certain config sections from a parsed file
|
||||
def apply_sections(cp, ckey='all', addbase=False):
|
||||
blab("[config] apply section key: %s" % ckey)
|
||||
if ckey == 'all':
|
||||
apply_all_sections(cp)
|
||||
else:
|
||||
# Apply the base/root config.ini settings after external files are done
|
||||
if addbase or ckey in ('base', 'root'):
|
||||
apply_ini_by_name(cp, 'config:base')
|
||||
|
||||
# Apply historically 'Configuration.h' settings everywhere
|
||||
if ckey == 'basic':
|
||||
apply_ini_by_name(cp, 'config:basic')
|
||||
|
||||
# Apply historically Configuration_adv.h settings everywhere
|
||||
# (Some of which rely on defines in 'Conditionals_LCD.h')
|
||||
elif ckey in ('adv', 'advanced'):
|
||||
apply_ini_by_name(cp, 'config:advanced')
|
||||
|
||||
# Apply a specific config:<name> section directly
|
||||
elif ckey.startswith('config:'):
|
||||
apply_ini_by_name(cp, ckey)
|
||||
|
||||
# Apply settings from a top level config.ini
|
||||
def apply_config_ini(cp):
|
||||
blab("=" * 20 + " Gather 'config.ini' entries...")
|
||||
|
||||
# Pre-scan for ini_use_config to get config_keys
|
||||
base_items = section_items(cp, 'config:base') + section_items(cp, 'config:root')
|
||||
config_keys = ['base']
|
||||
for ikey, ival in base_items:
|
||||
if ikey == 'ini_use_config':
|
||||
config_keys = [ x.strip() for x in ival.split(',') ]
|
||||
|
||||
# For each ini_use_config item perform an action
|
||||
for ckey in config_keys:
|
||||
addbase = False
|
||||
|
||||
# For a key ending in .ini load and parse another .ini file
|
||||
if ckey.endswith('.ini'):
|
||||
sect = 'base'
|
||||
if '@' in ckey: sect, ckey = ckey.split('@')
|
||||
other_ini = configparser.ConfigParser()
|
||||
other_ini.read(config_path(ckey))
|
||||
apply_sections(other_ini, sect)
|
||||
|
||||
# (Allow 'example/' as a shortcut for 'examples/')
|
||||
elif ckey.startswith('example/'):
|
||||
ckey = 'examples' + ckey[7:]
|
||||
|
||||
# For 'examples/<path>' fetch an example set from GitHub.
|
||||
# For https?:// do a direct fetch of the URL.
|
||||
elif ckey.startswith('examples/') or ckey.startswith('http'):
|
||||
addbase = True
|
||||
fetch_example(ckey)
|
||||
|
||||
# Apply keyed sections after external files are done
|
||||
apply_sections(cp, 'config:' + ckey, addbase)
|
||||
|
||||
if __name__ == "__main__":
|
||||
#
|
||||
# From command line use the given file name
|
||||
#
|
||||
import sys
|
||||
args = sys.argv[1:]
|
||||
if len(args) > 0:
|
||||
if args[0].endswith('.ini'):
|
||||
ini_file = args[0]
|
||||
else:
|
||||
print("Usage: %s <.ini file>" % sys.argv[0])
|
||||
else:
|
||||
ini_file = config_path('config.ini')
|
||||
|
||||
if ini_file:
|
||||
user_ini = configparser.ConfigParser()
|
||||
user_ini.read(ini_file)
|
||||
apply_config_ini(user_ini)
|
||||
|
||||
else:
|
||||
#
|
||||
# From within PlatformIO use the loaded INI file
|
||||
#
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
|
||||
Import("env")
|
||||
|
||||
try:
|
||||
verbose = int(env.GetProjectOption('custom_verbose'))
|
||||
except:
|
||||
pass
|
||||
|
||||
from platformio.project.config import ProjectConfig
|
||||
apply_config_ini(ProjectConfig())
|
@@ -1,16 +1,18 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/custom_board.py
|
||||
# custom_board.py
|
||||
#
|
||||
# - For build.address replace VECT_TAB_ADDR to relocate the firmware
|
||||
# - For build.ldscript use one of the linker scripts in buildroot/share/PlatformIO/ldscripts
|
||||
#
|
||||
import marlin
|
||||
board = marlin.env.BoardConfig()
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
import marlin
|
||||
board = marlin.env.BoardConfig()
|
||||
|
||||
address = board.get("build.address", "")
|
||||
if address:
|
||||
marlin.relocate_firmware(address)
|
||||
address = board.get("build.address", "")
|
||||
if address:
|
||||
marlin.relocate_firmware(address)
|
||||
|
||||
ldscript = board.get("build.ldscript", "")
|
||||
if ldscript:
|
||||
marlin.custom_ld_script(ldscript)
|
||||
ldscript = board.get("build.ldscript", "")
|
||||
if ldscript:
|
||||
marlin.custom_ld_script(ldscript)
|
||||
|
@@ -1,46 +1,53 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/download_mks_assets.py
|
||||
# download_mks_assets.py
|
||||
# Added by HAS_TFT_LVGL_UI to download assets from Makerbase repo
|
||||
#
|
||||
Import("env")
|
||||
import os,requests,zipfile,tempfile,shutil
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
Import("env")
|
||||
import requests,zipfile,tempfile,shutil
|
||||
from pathlib import Path
|
||||
|
||||
url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/master.zip"
|
||||
zip_path = os.path.join(env.Dictionary("PROJECT_LIBDEPS_DIR"), "mks-assets.zip")
|
||||
assets_path = os.path.join(env.Dictionary("PROJECT_BUILD_DIR"), env.Dictionary("PIOENV"), "assets")
|
||||
url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/0263cdaccf.zip"
|
||||
deps_path = Path(env.Dictionary("PROJECT_LIBDEPS_DIR"))
|
||||
zip_path = deps_path / "mks-assets.zip"
|
||||
assets_path = Path(env.Dictionary("PROJECT_BUILD_DIR"), env.Dictionary("PIOENV"), "assets")
|
||||
|
||||
def download_mks_assets():
|
||||
print("Downloading MKS Assets")
|
||||
r = requests.get(url, stream=True)
|
||||
# the user may have a very clean workspace,
|
||||
# so create the PROJECT_LIBDEPS_DIR directory if not exits
|
||||
if os.path.exists(env.Dictionary("PROJECT_LIBDEPS_DIR")) == False:
|
||||
os.mkdir(env.Dictionary("PROJECT_LIBDEPS_DIR"))
|
||||
with open(zip_path, 'wb') as fd:
|
||||
for chunk in r.iter_content(chunk_size=128):
|
||||
fd.write(chunk)
|
||||
def download_mks_assets():
|
||||
print("Downloading MKS Assets")
|
||||
r = requests.get(url, stream=True)
|
||||
# the user may have a very clean workspace,
|
||||
# so create the PROJECT_LIBDEPS_DIR directory if not exits
|
||||
if not deps_path.exists():
|
||||
deps_path.mkdir()
|
||||
with zip_path.open('wb') as fd:
|
||||
for chunk in r.iter_content(chunk_size=128):
|
||||
fd.write(chunk)
|
||||
|
||||
def copy_mks_assets():
|
||||
print("Copying MKS Assets")
|
||||
output_path = tempfile.mkdtemp()
|
||||
zip_obj = zipfile.ZipFile(zip_path, 'r')
|
||||
zip_obj.extractall(output_path)
|
||||
zip_obj.close()
|
||||
if os.path.exists(assets_path) == True and os.path.isdir(assets_path) == False:
|
||||
os.unlink(assets_path)
|
||||
if os.path.exists(assets_path) == False:
|
||||
os.mkdir(assets_path)
|
||||
base_path = ''
|
||||
for filename in os.listdir(output_path):
|
||||
base_path = filename
|
||||
for filename in os.listdir(os.path.join(output_path, base_path, 'Firmware', 'mks_font')):
|
||||
shutil.copy(os.path.join(output_path, base_path, 'Firmware', 'mks_font', filename), assets_path)
|
||||
for filename in os.listdir(os.path.join(output_path, base_path, 'Firmware', 'mks_pic')):
|
||||
shutil.copy(os.path.join(output_path, base_path, 'Firmware', 'mks_pic', filename), assets_path)
|
||||
shutil.rmtree(output_path, ignore_errors=True)
|
||||
def copy_mks_assets():
|
||||
print("Copying MKS Assets")
|
||||
output_path = Path(tempfile.mkdtemp())
|
||||
zip_obj = zipfile.ZipFile(zip_path, 'r')
|
||||
zip_obj.extractall(output_path)
|
||||
zip_obj.close()
|
||||
if assets_path.exists() and not assets_path.is_dir():
|
||||
assets_path.unlink()
|
||||
if not assets_path.exists():
|
||||
assets_path.mkdir()
|
||||
base_path = ''
|
||||
for filename in output_path.iterdir():
|
||||
base_path = filename
|
||||
fw_path = (output_path / base_path / 'Firmware')
|
||||
font_path = fw_path / 'mks_font'
|
||||
for filename in font_path.iterdir():
|
||||
shutil.copy(font_path / filename, assets_path)
|
||||
pic_path = fw_path / 'mks_pic'
|
||||
for filename in pic_path.iterdir():
|
||||
shutil.copy(pic_path / filename, assets_path)
|
||||
shutil.rmtree(output_path, ignore_errors=True)
|
||||
|
||||
if os.path.exists(zip_path) == False:
|
||||
download_mks_assets()
|
||||
if not zip_path.exists():
|
||||
download_mks_assets()
|
||||
|
||||
if os.path.exists(assets_path) == False:
|
||||
copy_mks_assets()
|
||||
if not assets_path.exists():
|
||||
copy_mks_assets()
|
||||
|
@@ -1,32 +1,35 @@
|
||||
#
|
||||
# fix_framework_weakness.py
|
||||
#
|
||||
from os.path import join, isfile
|
||||
import shutil
|
||||
from pprint import pprint
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
|
||||
Import("env")
|
||||
import shutil
|
||||
from os.path import join, isfile
|
||||
from pprint import pprint
|
||||
|
||||
if env.MarlinFeatureIsEnabled("POSTMORTEM_DEBUGGING"):
|
||||
FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoststm32-maple")
|
||||
patchflag_path = join(FRAMEWORK_DIR, ".exc-patching-done")
|
||||
Import("env")
|
||||
|
||||
# patch file only if we didn't do it before
|
||||
if not isfile(patchflag_path):
|
||||
print("Patching libmaple exception handlers")
|
||||
original_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S")
|
||||
backup_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S.bak")
|
||||
src_file = join("buildroot", "share", "PlatformIO", "scripts", "exc.S")
|
||||
if env.MarlinHas("POSTMORTEM_DEBUGGING"):
|
||||
FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoststm32-maple")
|
||||
patchflag_path = join(FRAMEWORK_DIR, ".exc-patching-done")
|
||||
|
||||
assert isfile(original_file) and isfile(src_file)
|
||||
shutil.copyfile(original_file, backup_file)
|
||||
shutil.copyfile(src_file, original_file);
|
||||
# patch file only if we didn't do it before
|
||||
if not isfile(patchflag_path):
|
||||
print("Patching libmaple exception handlers")
|
||||
original_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S")
|
||||
backup_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S.bak")
|
||||
src_file = join("buildroot", "share", "PlatformIO", "scripts", "exc.S")
|
||||
|
||||
def _touch(path):
|
||||
with open(path, "w") as fp:
|
||||
fp.write("")
|
||||
assert isfile(original_file) and isfile(src_file)
|
||||
shutil.copyfile(original_file, backup_file)
|
||||
shutil.copyfile(src_file, original_file);
|
||||
|
||||
env.Execute(lambda *args, **kwargs: _touch(patchflag_path))
|
||||
print("Done patching exception handler")
|
||||
def _touch(path):
|
||||
with open(path, "w") as fp:
|
||||
fp.write("")
|
||||
|
||||
print("Libmaple modified and ready for post mortem debugging")
|
||||
env.Execute(lambda *args, **kwargs: _touch(patchflag_path))
|
||||
print("Done patching exception handler")
|
||||
|
||||
print("Libmaple modified and ready for post mortem debugging")
|
||||
|
@@ -5,50 +5,54 @@
|
||||
# the appropriate framework variants folder, so that its contents
|
||||
# will be picked up by PlatformIO just like any other variant.
|
||||
#
|
||||
import os,shutil,marlin
|
||||
from SCons.Script import DefaultEnvironment
|
||||
from platformio import util
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
import shutil,marlin
|
||||
from pathlib import Path
|
||||
|
||||
env = DefaultEnvironment()
|
||||
#
|
||||
# Get the platform name from the 'platform_packages' option,
|
||||
# or look it up by the platform.class.name.
|
||||
#
|
||||
env = marlin.env
|
||||
platform = env.PioPlatform()
|
||||
|
||||
#
|
||||
# Get the platform name from the 'platform_packages' option,
|
||||
# or look it up by the platform.class.name.
|
||||
#
|
||||
platform = env.PioPlatform()
|
||||
from platformio.package.meta import PackageSpec
|
||||
platform_packages = env.GetProjectOption('platform_packages')
|
||||
|
||||
from platformio.package.meta import PackageSpec
|
||||
platform_packages = env.GetProjectOption('platform_packages')
|
||||
if len(platform_packages) == 0:
|
||||
framewords = {
|
||||
"Ststm32Platform": "framework-arduinoststm32",
|
||||
"AtmelavrPlatform": "framework-arduino-avr"
|
||||
}
|
||||
platform_name = framewords[platform.__class__.__name__]
|
||||
else:
|
||||
platform_name = PackageSpec(platform_packages[0]).name
|
||||
# Remove all tool items from platform_packages
|
||||
platform_packages = [x for x in platform_packages if not x.startswith("platformio/tool-")]
|
||||
|
||||
if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "usb-host-msc-cdc-msc-3", "tool-stm32duino" ]:
|
||||
platform_name = "framework-arduinoststm32"
|
||||
if len(platform_packages) == 0:
|
||||
framewords = {
|
||||
"Ststm32Platform": "framework-arduinoststm32",
|
||||
"AtmelavrPlatform": "framework-arduino-avr"
|
||||
}
|
||||
platform_name = framewords[platform.__class__.__name__]
|
||||
else:
|
||||
platform_name = PackageSpec(platform_packages[0]).name
|
||||
|
||||
FRAMEWORK_DIR = platform.get_package_dir(platform_name)
|
||||
assert os.path.isdir(FRAMEWORK_DIR)
|
||||
if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "usb-host-msc-cdc-msc-3", "tool-stm32duino", "biqu-bx-workaround", "main" ]:
|
||||
platform_name = "framework-arduinoststm32"
|
||||
|
||||
board = env.BoardConfig()
|
||||
FRAMEWORK_DIR = Path(platform.get_package_dir(platform_name))
|
||||
assert FRAMEWORK_DIR.is_dir()
|
||||
|
||||
#mcu_type = board.get("build.mcu")[:-2]
|
||||
variant = board.get("build.variant")
|
||||
#series = mcu_type[:7].upper() + "xx"
|
||||
board = env.BoardConfig()
|
||||
|
||||
# Prepare a new empty folder at the destination
|
||||
variant_dir = os.path.join(FRAMEWORK_DIR, "variants", variant)
|
||||
if os.path.isdir(variant_dir):
|
||||
shutil.rmtree(variant_dir)
|
||||
if not os.path.isdir(variant_dir):
|
||||
os.mkdir(variant_dir)
|
||||
#mcu_type = board.get("build.mcu")[:-2]
|
||||
variant = board.get("build.variant")
|
||||
#series = mcu_type[:7].upper() + "xx"
|
||||
|
||||
# Source dir is a local variant sub-folder
|
||||
source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant)
|
||||
assert os.path.isdir(source_dir)
|
||||
# Prepare a new empty folder at the destination
|
||||
variant_dir = FRAMEWORK_DIR / "variants" / variant
|
||||
if variant_dir.is_dir():
|
||||
shutil.rmtree(variant_dir)
|
||||
if not variant_dir.is_dir():
|
||||
variant_dir.mkdir()
|
||||
|
||||
marlin.copytree(source_dir, variant_dir)
|
||||
# Source dir is a local variant sub-folder
|
||||
source_dir = Path("buildroot/share/PlatformIO/variants", variant)
|
||||
assert source_dir.is_dir()
|
||||
|
||||
marlin.copytree(source_dir, variant_dir)
|
||||
|
@@ -1,39 +1,35 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py
|
||||
# jgaurora_a5s_a1_with_bootloader.py
|
||||
# Customizations for env:jgaurora_a5s_a1
|
||||
#
|
||||
import os,marlin
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
|
||||
# Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin'
|
||||
def addboot(source, target, env):
|
||||
firmware = open(target[0].path, "rb")
|
||||
lengthfirmware = os.path.getsize(target[0].path)
|
||||
bootloader_bin = "buildroot/share/PlatformIO/scripts/" + "jgaurora_bootloader.bin"
|
||||
bootloader = open(bootloader_bin, "rb")
|
||||
lengthbootloader = os.path.getsize(bootloader_bin)
|
||||
# Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin'
|
||||
def addboot(source, target, env):
|
||||
from pathlib import Path
|
||||
|
||||
firmware_with_boothloader_bin = target[0].dir.path + '/firmware_with_bootloader.bin'
|
||||
if os.path.exists(firmware_with_boothloader_bin):
|
||||
os.remove(firmware_with_boothloader_bin)
|
||||
firmwareimage = open(firmware_with_boothloader_bin, "wb")
|
||||
position = 0
|
||||
while position < lengthbootloader:
|
||||
byte = bootloader.read(1)
|
||||
firmwareimage.write(byte)
|
||||
position += 1
|
||||
position = 0
|
||||
while position < lengthfirmware:
|
||||
byte = firmware.read(1)
|
||||
firmwareimage.write(byte)
|
||||
position += 1
|
||||
bootloader.close()
|
||||
firmware.close()
|
||||
firmwareimage.close()
|
||||
fw_path = Path(target[0].path)
|
||||
fwb_path = fw_path.parent / 'firmware_with_bootloader.bin'
|
||||
with fwb_path.open("wb") as fwb_file:
|
||||
bl_path = Path("buildroot/share/PlatformIO/scripts/jgaurora_bootloader.bin")
|
||||
bl_file = bl_path.open("rb")
|
||||
while True:
|
||||
b = bl_file.read(1)
|
||||
if b == b'': break
|
||||
else: fwb_file.write(b)
|
||||
|
||||
firmware_without_bootloader_bin = target[0].dir.path + '/firmware_for_sd_upload.bin'
|
||||
if os.path.exists(firmware_without_bootloader_bin):
|
||||
os.remove(firmware_without_bootloader_bin)
|
||||
os.rename(target[0].path, firmware_without_bootloader_bin)
|
||||
#os.rename(target[0].dir.path+'/firmware_with_bootloader.bin', target[0].dir.path+'/firmware.bin')
|
||||
with fw_path.open("rb") as fw_file:
|
||||
while True:
|
||||
b = fw_file.read(1)
|
||||
if b == b'': break
|
||||
else: fwb_file.write(b)
|
||||
|
||||
marlin.add_post_action(addboot);
|
||||
fws_path = Path(target[0].dir.path, 'firmware_for_sd_upload.bin')
|
||||
if fws_path.exists():
|
||||
fws_path.unlink()
|
||||
|
||||
fw_path.rename(fws_path)
|
||||
|
||||
import marlin
|
||||
marlin.add_post_action(addboot);
|
||||
|
@@ -1,48 +1,47 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/lerdge.py
|
||||
# lerdge.py
|
||||
# Customizations for Lerdge build environments:
|
||||
# env:LERDGEX env:LERDGEX_usb_flash_drive
|
||||
# env:LERDGES env:LERDGES_usb_flash_drive
|
||||
# env:LERDGEK env:LERDGEK_usb_flash_drive
|
||||
#
|
||||
import os,marlin
|
||||
Import("env")
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
import os,marlin
|
||||
|
||||
from SCons.Script import DefaultEnvironment
|
||||
board = DefaultEnvironment().BoardConfig()
|
||||
board = marlin.env.BoardConfig()
|
||||
|
||||
def encryptByte(byte):
|
||||
byte = 0xFF & ((byte << 6) | (byte >> 2))
|
||||
i = 0x58 + byte
|
||||
j = 0x05 + byte + (i >> 8)
|
||||
byte = (0xF8 & i) | (0x07 & j)
|
||||
return byte
|
||||
def encryptByte(byte):
|
||||
byte = 0xFF & ((byte << 6) | (byte >> 2))
|
||||
i = 0x58 + byte
|
||||
j = 0x05 + byte + (i >> 8)
|
||||
byte = (0xF8 & i) | (0x07 & j)
|
||||
return byte
|
||||
|
||||
def encrypt_file(input, output_file, file_length):
|
||||
input_file = bytearray(input.read())
|
||||
for i in range(len(input_file)):
|
||||
result = encryptByte(input_file[i])
|
||||
input_file[i] = result
|
||||
def encrypt_file(input, output_file, file_length):
|
||||
input_file = bytearray(input.read())
|
||||
for i in range(len(input_file)):
|
||||
input_file[i] = encryptByte(input_file[i])
|
||||
output_file.write(input_file)
|
||||
|
||||
output_file.write(input_file)
|
||||
return
|
||||
# Encrypt ${PROGNAME}.bin and save it with the name given in build.crypt_lerdge
|
||||
def encrypt(source, target, env):
|
||||
fwpath = target[0].path
|
||||
enname = board.get("build.crypt_lerdge")
|
||||
print("Encrypting %s to %s" % (fwpath, enname))
|
||||
fwfile = open(fwpath, "rb")
|
||||
enfile = open(target[0].dir.path + "/" + enname, "wb")
|
||||
length = os.path.getsize(fwpath)
|
||||
|
||||
# Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt
|
||||
def encrypt(source, target, env):
|
||||
fwname = board.get("build.encrypt")
|
||||
print("Encrypting %s to %s" % (target[0].path, fwname))
|
||||
firmware = open(target[0].path, "rb")
|
||||
renamed = open(target[0].dir.path + "/" + fwname, "wb")
|
||||
length = os.path.getsize(target[0].path)
|
||||
encrypt_file(fwfile, enfile, length)
|
||||
|
||||
encrypt_file(firmware, renamed, length)
|
||||
fwfile.close()
|
||||
enfile.close()
|
||||
os.remove(fwpath)
|
||||
|
||||
firmware.close()
|
||||
renamed.close()
|
||||
|
||||
if 'encrypt' in board.get("build").keys():
|
||||
if board.get("build.encrypt") != "":
|
||||
marlin.add_post_action(encrypt)
|
||||
else:
|
||||
print("LERDGE builds require output file via board_build.encrypt = 'filename' parameter")
|
||||
exit(1)
|
||||
if 'crypt_lerdge' in board.get("build").keys():
|
||||
if board.get("build.crypt_lerdge") != "":
|
||||
marlin.add_post_action(encrypt)
|
||||
else:
|
||||
print("LERDGE builds require output file via board_build.crypt_lerdge = 'filename' parameter")
|
||||
exit(1)
|
||||
|
@@ -1,22 +1,19 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/marlin.py
|
||||
# marlin.py
|
||||
# Helper module with some commonly-used functions
|
||||
#
|
||||
import os,shutil
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
from SCons.Script import DefaultEnvironment
|
||||
env = DefaultEnvironment()
|
||||
|
||||
from os.path import join
|
||||
|
||||
def copytree(src, dst, symlinks=False, ignore=None):
|
||||
for item in os.listdir(src):
|
||||
s = join(src, item)
|
||||
d = join(dst, item)
|
||||
if os.path.isdir(s):
|
||||
shutil.copytree(s, d, symlinks, ignore)
|
||||
else:
|
||||
shutil.copy2(s, d)
|
||||
for item in src.iterdir():
|
||||
if item.is_dir():
|
||||
shutil.copytree(item, dst / item.name, symlinks, ignore)
|
||||
else:
|
||||
shutil.copy2(item, dst / item.name)
|
||||
|
||||
def replace_define(field, value):
|
||||
for define in env['CPPDEFINES']:
|
||||
@@ -34,36 +31,42 @@ def relocate_vtab(address):
|
||||
|
||||
# Replace the existing -Wl,-T with the given ldscript path
|
||||
def custom_ld_script(ldname):
|
||||
apath = os.path.abspath("buildroot/share/PlatformIO/ldscripts/" + ldname)
|
||||
apath = str(Path("buildroot/share/PlatformIO/ldscripts", ldname).resolve())
|
||||
for i, flag in enumerate(env["LINKFLAGS"]):
|
||||
if "-Wl,-T" in flag:
|
||||
env["LINKFLAGS"][i] = "-Wl,-T" + apath
|
||||
elif flag == "-T":
|
||||
env["LINKFLAGS"][i + 1] = apath
|
||||
|
||||
# Encrypt ${PROGNAME}.bin and save it with a new name
|
||||
# Called by specific encrypt() functions, mostly for MKS boards
|
||||
# Encrypt ${PROGNAME}.bin and save it with a new name. This applies (mostly) to MKS boards
|
||||
# This PostAction is set up by offset_and_rename.py for envs with 'build.encrypt_mks'.
|
||||
def encrypt_mks(source, target, env, new_name):
|
||||
import sys
|
||||
|
||||
key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E]
|
||||
|
||||
firmware = open(target[0].path, "rb")
|
||||
renamed = open(target[0].dir.path + "/" + new_name, "wb")
|
||||
length = os.path.getsize(target[0].path)
|
||||
# If FIRMWARE_BIN is defined by config, override all
|
||||
mf = env["MARLIN_FEATURES"]
|
||||
if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"]
|
||||
|
||||
fwpath = Path(target[0].path)
|
||||
fwfile = fwpath.open("rb")
|
||||
enfile = Path(target[0].dir.path, new_name).open("wb")
|
||||
length = fwpath.stat().st_size
|
||||
position = 0
|
||||
try:
|
||||
while position < length:
|
||||
byte = firmware.read(1)
|
||||
if position >= 320 and position < 31040:
|
||||
byte = fwfile.read(1)
|
||||
if 320 <= position < 31040:
|
||||
byte = chr(ord(byte) ^ key[position & 31])
|
||||
if sys.version_info[0] > 2:
|
||||
byte = bytes(byte, 'latin1')
|
||||
renamed.write(byte)
|
||||
enfile.write(byte)
|
||||
position += 1
|
||||
finally:
|
||||
firmware.close()
|
||||
renamed.close()
|
||||
fwfile.close()
|
||||
enfile.close()
|
||||
fwpath.unlink()
|
||||
|
||||
def add_post_action(action):
|
||||
env.AddPostAction(join("$BUILD_DIR", "${PROGNAME}.bin"), action);
|
||||
env.AddPostAction(str(Path("$BUILD_DIR", "${PROGNAME}.bin")), action);
|
||||
|
69
buildroot/share/PlatformIO/scripts/mc-apply.py
Executable file
69
buildroot/share/PlatformIO/scripts/mc-apply.py
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Create a Configuration from marlin_config.json
|
||||
#
|
||||
import json
|
||||
import sys
|
||||
import shutil
|
||||
import re
|
||||
|
||||
opt_output = '--opt' in sys.argv
|
||||
output_suffix = '.sh' if opt_output else '' if '--bare-output' in sys.argv else '.gen'
|
||||
|
||||
try:
|
||||
with open('marlin_config.json', 'r') as infile:
|
||||
conf = json.load(infile)
|
||||
for key in conf:
|
||||
# We don't care about the hash when restoring here
|
||||
if key == '__INITIAL_HASH':
|
||||
continue
|
||||
if key == 'VERSION':
|
||||
for k, v in sorted(conf[key].items()):
|
||||
print(k + ': ' + v)
|
||||
continue
|
||||
# The key is the file name, so let's build it now
|
||||
outfile = open('Marlin/' + key + output_suffix, 'w')
|
||||
for k, v in sorted(conf[key].items()):
|
||||
# Make define line now
|
||||
if opt_output:
|
||||
if v != '':
|
||||
if '"' in v:
|
||||
v = "'%s'" % v
|
||||
elif ' ' in v:
|
||||
v = '"%s"' % v
|
||||
define = 'opt_set ' + k + ' ' + v + '\n'
|
||||
else:
|
||||
define = 'opt_enable ' + k + '\n'
|
||||
else:
|
||||
define = '#define ' + k + ' ' + v + '\n'
|
||||
outfile.write(define)
|
||||
outfile.close()
|
||||
|
||||
# Try to apply changes to the actual configuration file (in order to keep useful comments)
|
||||
if output_suffix != '':
|
||||
# Move the existing configuration so it doesn't interfere
|
||||
shutil.move('Marlin/' + key, 'Marlin/' + key + '.orig')
|
||||
infile_lines = open('Marlin/' + key + '.orig', 'r').read().split('\n')
|
||||
outfile = open('Marlin/' + key, 'w')
|
||||
for line in infile_lines:
|
||||
sline = line.strip(" \t\n\r")
|
||||
if sline[:7] == "#define":
|
||||
# Extract the key here (we don't care about the value)
|
||||
kv = sline[8:].strip().split(' ')
|
||||
if kv[0] in conf[key]:
|
||||
outfile.write('#define ' + kv[0] + ' ' + conf[key][kv[0]] + '\n')
|
||||
# Remove the key from the dict, so we can still write all missing keys at the end of the file
|
||||
del conf[key][kv[0]]
|
||||
else:
|
||||
outfile.write(line + '\n')
|
||||
else:
|
||||
outfile.write(line + '\n')
|
||||
# Process any remaining defines here
|
||||
for k, v in sorted(conf[key].items()):
|
||||
define = '#define ' + k + ' ' + v + '\n'
|
||||
outfile.write(define)
|
||||
outfile.close()
|
||||
|
||||
print('Output configuration written to: ' + 'Marlin/' + key + output_suffix)
|
||||
except:
|
||||
print('No marlin_config.json found.')
|
@@ -1,5 +0,0 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/mks_robin.py
|
||||
#
|
||||
import robin
|
||||
robin.prepare("0x08007000", "mks_robin.ld", "Robin.bin")
|
@@ -1,5 +0,0 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/mks_robin_e3.py
|
||||
#
|
||||
import robin
|
||||
robin.prepare("0x08005000", "mks_robin_e3.ld", "Robin_e3.bin")
|
@@ -1,5 +0,0 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/mks_robin_e3p.py
|
||||
#
|
||||
import robin
|
||||
robin.prepare("0x08007000", "mks_robin_e3p.ld", "Robin_e3p.bin")
|
@@ -1,5 +0,0 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/mks_robin_lite.py
|
||||
#
|
||||
import robin
|
||||
robin.prepare("0x08005000", "mks_robin_lite.ld", "mksLite.bin")
|
@@ -1,5 +0,0 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/mks_robin_lite3.py
|
||||
#
|
||||
import robin
|
||||
robin.prepare("0x08005000", "mks_robin_lite.ld", "mksLite3.bin")
|
@@ -1,5 +0,0 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/mks_robin_mini.py
|
||||
#
|
||||
import robin
|
||||
robin.prepare("0x08007000", "mks_robin_mini.ld", "Robin_mini.bin")
|
@@ -1,5 +0,0 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/mks_robin_nano.py
|
||||
#
|
||||
import robin
|
||||
robin.prepare("0x08007000", "mks_robin_nano.ld", "Robin_nano.bin")
|
@@ -1,5 +0,0 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/mks_robin_nano35.py
|
||||
#
|
||||
import robin
|
||||
robin.prepare("0x08007000", "mks_robin_nano.ld", "Robin_nano35.bin")
|
@@ -1,5 +0,0 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/mks_robin_pro.py
|
||||
#
|
||||
import robin
|
||||
robin.prepare("0x08007000", "mks_robin_pro.ld", "Robin_pro.bin")
|
@@ -8,54 +8,53 @@
|
||||
#
|
||||
# - For 'board_build.rename' add a post-action to rename the firmware file.
|
||||
#
|
||||
import os,sys,marlin
|
||||
Import("env")
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
import sys,marlin
|
||||
|
||||
from SCons.Script import DefaultEnvironment
|
||||
board = DefaultEnvironment().BoardConfig()
|
||||
env = marlin.env
|
||||
board = env.BoardConfig()
|
||||
board_keys = board.get("build").keys()
|
||||
|
||||
board_keys = board.get("build").keys()
|
||||
#
|
||||
# For build.offset define LD_FLASH_OFFSET, used by ldscript.ld
|
||||
#
|
||||
if 'offset' in board_keys:
|
||||
LD_FLASH_OFFSET = board.get("build.offset")
|
||||
marlin.relocate_vtab(LD_FLASH_OFFSET)
|
||||
|
||||
#
|
||||
# For build.offset define LD_FLASH_OFFSET, used by ldscript.ld
|
||||
#
|
||||
if 'offset' in board_keys:
|
||||
LD_FLASH_OFFSET = board.get("build.offset")
|
||||
marlin.relocate_vtab(LD_FLASH_OFFSET)
|
||||
# Flash size
|
||||
maximum_flash_size = int(board.get("upload.maximum_size") / 1024)
|
||||
marlin.replace_define('STM32_FLASH_SIZE', maximum_flash_size)
|
||||
|
||||
# Flash size
|
||||
maximum_flash_size = int(board.get("upload.maximum_size") / 1024)
|
||||
marlin.replace_define('STM32_FLASH_SIZE', maximum_flash_size)
|
||||
# Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json)
|
||||
maximum_ram_size = board.get("upload.maximum_ram_size")
|
||||
|
||||
# Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json)
|
||||
maximum_ram_size = board.get("upload.maximum_ram_size")
|
||||
for i, flag in enumerate(env["LINKFLAGS"]):
|
||||
if "-Wl,--defsym=LD_FLASH_OFFSET" in flag:
|
||||
env["LINKFLAGS"][i] = "-Wl,--defsym=LD_FLASH_OFFSET=" + LD_FLASH_OFFSET
|
||||
if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag:
|
||||
env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40)
|
||||
|
||||
for i, flag in enumerate(env["LINKFLAGS"]):
|
||||
if "-Wl,--defsym=LD_FLASH_OFFSET" in flag:
|
||||
env["LINKFLAGS"][i] = "-Wl,--defsym=LD_FLASH_OFFSET=" + LD_FLASH_OFFSET
|
||||
if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag:
|
||||
env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40)
|
||||
#
|
||||
# For build.encrypt_mks rename and encode the firmware file.
|
||||
#
|
||||
if 'encrypt_mks' in board_keys:
|
||||
|
||||
#
|
||||
# For build.encrypt rename and encode the firmware file.
|
||||
#
|
||||
if 'encrypt' in board_keys:
|
||||
# Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt_mks
|
||||
def encrypt(source, target, env):
|
||||
marlin.encrypt_mks(source, target, env, board.get("build.encrypt_mks"))
|
||||
|
||||
# Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt
|
||||
def encrypt(source, target, env):
|
||||
marlin.encrypt_mks(source, target, env, board.get("build.encrypt"))
|
||||
if board.get("build.encrypt_mks") != "":
|
||||
marlin.add_post_action(encrypt)
|
||||
|
||||
if board.get("build.encrypt") != "":
|
||||
marlin.add_post_action(encrypt)
|
||||
#
|
||||
# For build.rename simply rename the firmware file.
|
||||
#
|
||||
if 'rename' in board_keys:
|
||||
|
||||
#
|
||||
# For build.rename simply rename the firmware file.
|
||||
#
|
||||
if 'rename' in board_keys:
|
||||
def rename_target(source, target, env):
|
||||
from pathlib import Path
|
||||
Path(target[0].path).replace(Path(target[0].dir.path, board.get("build.rename")))
|
||||
|
||||
def rename_target(source, target, env):
|
||||
firmware = os.path.join(target[0].dir.path, board.get("build.rename"))
|
||||
import shutil
|
||||
shutil.copy(target[0].path, firmware)
|
||||
|
||||
marlin.add_post_action(rename_target)
|
||||
marlin.add_post_action(rename_target)
|
||||
|
@@ -1,18 +1,20 @@
|
||||
#
|
||||
# Convert the ELF to an SREC file suitable for some bootloaders
|
||||
#
|
||||
import os,sys
|
||||
from os.path import join
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
import os,sys
|
||||
from os.path import join
|
||||
|
||||
Import("env")
|
||||
Import("env")
|
||||
|
||||
board = env.BoardConfig()
|
||||
board_keys = board.get("build").keys()
|
||||
if 'encrypt' in board_keys:
|
||||
env.AddPostAction(
|
||||
join("$BUILD_DIR", "${PROGNAME}.bin"),
|
||||
env.VerboseAction(" ".join([
|
||||
"$OBJCOPY", "-O", "srec",
|
||||
"\"$BUILD_DIR/${PROGNAME}.elf\"", "\"" + join("$BUILD_DIR", board.get("build.encrypt")) + "\""
|
||||
]), "Building $TARGET")
|
||||
)
|
||||
board = env.BoardConfig()
|
||||
board_keys = board.get("build").keys()
|
||||
if 'encode' in board_keys:
|
||||
env.AddPostAction(
|
||||
join("$BUILD_DIR", "${PROGNAME}.bin"),
|
||||
env.VerboseAction(" ".join([
|
||||
"$OBJCOPY", "-O", "srec",
|
||||
"\"$BUILD_DIR/${PROGNAME}.elf\"", "\"" + join("$BUILD_DIR", board.get("build.encode")) + "\""
|
||||
]), "Building " + board.get("build.encode"))
|
||||
)
|
||||
|
13
buildroot/share/PlatformIO/scripts/pioutil.py
Normal file
13
buildroot/share/PlatformIO/scripts/pioutil.py
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# pioutil.py
|
||||
#
|
||||
|
||||
# Make sure 'vscode init' is not the current command
|
||||
def is_pio_build():
|
||||
from SCons.Script import DefaultEnvironment
|
||||
env = DefaultEnvironment()
|
||||
return not env.IsIntegrationDump()
|
||||
|
||||
def get_pio_version():
|
||||
from platformio import util
|
||||
return util.pioversion_to_intstr()
|
@@ -2,99 +2,126 @@
|
||||
# preflight-checks.py
|
||||
# Check for common issues prior to compiling
|
||||
#
|
||||
import os,re,sys
|
||||
Import("env")
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
|
||||
def get_envs_for_board(board):
|
||||
with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file:
|
||||
import os,re,sys
|
||||
from pathlib import Path
|
||||
Import("env")
|
||||
|
||||
if sys.platform == 'win32':
|
||||
envregex = r"(?:env|win):"
|
||||
elif sys.platform == 'darwin':
|
||||
envregex = r"(?:env|mac|uni):"
|
||||
elif sys.platform == 'linux':
|
||||
envregex = r"(?:env|lin|uni):"
|
||||
else:
|
||||
envregex = r"(?:env):"
|
||||
def get_envs_for_board(board):
|
||||
ppath = Path("Marlin/src/pins/pins.h")
|
||||
with ppath.open() as file:
|
||||
|
||||
r = re.compile(r"if\s+MB\((.+)\)")
|
||||
if board.startswith("BOARD_"):
|
||||
board = board[6:]
|
||||
if sys.platform == 'win32':
|
||||
envregex = r"(?:env|win):"
|
||||
elif sys.platform == 'darwin':
|
||||
envregex = r"(?:env|mac|uni):"
|
||||
elif sys.platform == 'linux':
|
||||
envregex = r"(?:env|lin|uni):"
|
||||
else:
|
||||
envregex = r"(?:env):"
|
||||
|
||||
for line in file:
|
||||
mbs = r.findall(line)
|
||||
if mbs and board in re.split(r",\s*", mbs[0]):
|
||||
line = file.readline()
|
||||
found_envs = re.match(r"\s*#include .+" + envregex, line)
|
||||
if found_envs:
|
||||
envlist = re.findall(envregex + r"(\w+)", line)
|
||||
return [ "env:"+s for s in envlist ]
|
||||
return []
|
||||
r = re.compile(r"if\s+MB\((.+)\)")
|
||||
if board.startswith("BOARD_"):
|
||||
board = board[6:]
|
||||
|
||||
def check_envs(build_env, board_envs, config):
|
||||
if build_env in board_envs:
|
||||
return True
|
||||
ext = config.get(build_env, 'extends', default=None)
|
||||
if ext:
|
||||
if isinstance(ext, str):
|
||||
return check_envs(ext, board_envs, config)
|
||||
elif isinstance(ext, list):
|
||||
for ext_env in ext:
|
||||
if check_envs(ext_env, board_envs, config):
|
||||
return True
|
||||
return False
|
||||
for line in file:
|
||||
mbs = r.findall(line)
|
||||
if mbs and board in re.split(r",\s*", mbs[0]):
|
||||
line = file.readline()
|
||||
found_envs = re.match(r"\s*#include .+" + envregex, line)
|
||||
if found_envs:
|
||||
envlist = re.findall(envregex + r"(\w+)", line)
|
||||
return [ "env:"+s for s in envlist ]
|
||||
return []
|
||||
|
||||
def sanity_check_target():
|
||||
# Sanity checks:
|
||||
if 'PIOENV' not in env:
|
||||
raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO")
|
||||
def check_envs(build_env, board_envs, config):
|
||||
if build_env in board_envs:
|
||||
return True
|
||||
ext = config.get(build_env, 'extends', default=None)
|
||||
if ext:
|
||||
if isinstance(ext, str):
|
||||
return check_envs(ext, board_envs, config)
|
||||
elif isinstance(ext, list):
|
||||
for ext_env in ext:
|
||||
if check_envs(ext_env, board_envs, config):
|
||||
return True
|
||||
return False
|
||||
|
||||
if 'MARLIN_FEATURES' not in env:
|
||||
raise SystemExit("Error: this script should be used after common Marlin scripts")
|
||||
def sanity_check_target():
|
||||
# Sanity checks:
|
||||
if 'PIOENV' not in env:
|
||||
raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO")
|
||||
|
||||
if 'MOTHERBOARD' not in env['MARLIN_FEATURES']:
|
||||
raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h")
|
||||
# Require PlatformIO 6.1.1 or later
|
||||
vers = pioutil.get_pio_version()
|
||||
if vers < [6, 1, 1]:
|
||||
raise SystemExit("Error: Marlin requires PlatformIO >= 6.1.1. Use 'pio upgrade' to get a newer version.")
|
||||
|
||||
build_env = env['PIOENV']
|
||||
motherboard = env['MARLIN_FEATURES']['MOTHERBOARD']
|
||||
board_envs = get_envs_for_board(motherboard)
|
||||
config = env.GetProjectConfig()
|
||||
result = check_envs("env:"+build_env, board_envs, config)
|
||||
if 'MARLIN_FEATURES' not in env:
|
||||
raise SystemExit("Error: this script should be used after common Marlin scripts")
|
||||
|
||||
if not result:
|
||||
err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \
|
||||
( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) )
|
||||
raise SystemExit(err)
|
||||
if 'MOTHERBOARD' not in env['MARLIN_FEATURES']:
|
||||
raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h")
|
||||
|
||||
#
|
||||
# Check for Config files in two common incorrect places
|
||||
#
|
||||
for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]:
|
||||
for f in [ "Configuration.h", "Configuration_adv.h" ]:
|
||||
if os.path.isfile(os.path.join(p, f)):
|
||||
err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p
|
||||
raise SystemExit(err)
|
||||
build_env = env['PIOENV']
|
||||
motherboard = env['MARLIN_FEATURES']['MOTHERBOARD']
|
||||
board_envs = get_envs_for_board(motherboard)
|
||||
config = env.GetProjectConfig()
|
||||
result = check_envs("env:"+build_env, board_envs, config)
|
||||
|
||||
#
|
||||
# Give warnings on every build
|
||||
#
|
||||
warnfile = os.path.join(env['PROJECT_BUILD_DIR'], build_env, "src", "src", "inc", "Warnings.cpp.o")
|
||||
if os.path.exists(warnfile):
|
||||
os.remove(warnfile)
|
||||
if not result:
|
||||
err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \
|
||||
( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) )
|
||||
raise SystemExit(err)
|
||||
|
||||
#
|
||||
# Check for old files indicating an entangled Marlin (mixing old and new code)
|
||||
#
|
||||
mixedin = []
|
||||
p = os.path.join(env['PROJECT_DIR'], "Marlin", "src", "lcd", "dogm")
|
||||
for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]:
|
||||
if os.path.isfile(os.path.join(p, f)):
|
||||
mixedin += [ f ]
|
||||
if mixedin:
|
||||
err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin)
|
||||
raise SystemExit(err)
|
||||
#
|
||||
# Check for Config files in two common incorrect places
|
||||
#
|
||||
epath = Path(env['PROJECT_DIR'])
|
||||
for p in [ epath, epath / "config" ]:
|
||||
for f in ("Configuration.h", "Configuration_adv.h"):
|
||||
if (p / f).is_file():
|
||||
err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p
|
||||
raise SystemExit(err)
|
||||
|
||||
#
|
||||
# Find the name.cpp.o or name.o and remove it
|
||||
#
|
||||
def rm_ofile(subdir, name):
|
||||
build_dir = Path(env['PROJECT_BUILD_DIR'], build_env);
|
||||
for outdir in (build_dir, build_dir / "debug"):
|
||||
for ext in (".cpp.o", ".o"):
|
||||
fpath = outdir / "src/src" / subdir / (name + ext)
|
||||
if fpath.exists():
|
||||
fpath.unlink()
|
||||
|
||||
#
|
||||
# Give warnings on every build
|
||||
#
|
||||
rm_ofile("inc", "Warnings")
|
||||
|
||||
#
|
||||
# Rebuild 'settings.cpp' for EEPROM_INIT_NOW
|
||||
#
|
||||
if 'EEPROM_INIT_NOW' in env['MARLIN_FEATURES']:
|
||||
rm_ofile("module", "settings")
|
||||
|
||||
#
|
||||
# Check for old files indicating an entangled Marlin (mixing old and new code)
|
||||
#
|
||||
mixedin = []
|
||||
p = Path(env['PROJECT_DIR'], "Marlin/src/lcd/dogm")
|
||||
for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]:
|
||||
if (p / f).is_file():
|
||||
mixedin += [ f ]
|
||||
p = Path(env['PROJECT_DIR'], "Marlin/src/feature/bedlevel/abl")
|
||||
for f in [ "abl.cpp", "abl.h" ]:
|
||||
if (p / f).is_file():
|
||||
mixedin += [ f ]
|
||||
if mixedin:
|
||||
err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin)
|
||||
raise SystemExit(err)
|
||||
|
||||
# Detect that 'vscode init' is running
|
||||
from SCons.Script import COMMAND_LINE_TARGETS
|
||||
if "idedata" not in COMMAND_LINE_TARGETS:
|
||||
sanity_check_target()
|
||||
|
94
buildroot/share/PlatformIO/scripts/preprocessor.py
Normal file
94
buildroot/share/PlatformIO/scripts/preprocessor.py
Normal file
@@ -0,0 +1,94 @@
|
||||
#
|
||||
# preprocessor.py
|
||||
#
|
||||
import subprocess,re
|
||||
|
||||
nocache = 1
|
||||
verbose = 0
|
||||
|
||||
def blab(str):
|
||||
if verbose:
|
||||
print(str)
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Invoke GCC to run the preprocessor and extract enabled features
|
||||
#
|
||||
preprocessor_cache = {}
|
||||
def run_preprocessor(env, fn=None):
|
||||
filename = fn or 'buildroot/share/PlatformIO/scripts/common-dependencies.h'
|
||||
if filename in preprocessor_cache:
|
||||
return preprocessor_cache[filename]
|
||||
|
||||
# Process defines
|
||||
build_flags = env.get('BUILD_FLAGS')
|
||||
build_flags = env.ParseFlagsExtended(build_flags)
|
||||
|
||||
cxx = search_compiler(env)
|
||||
cmd = ['"' + cxx + '"']
|
||||
|
||||
# Build flags from board.json
|
||||
#if 'BOARD' in env:
|
||||
# cmd += [env.BoardConfig().get("build.extra_flags")]
|
||||
for s in build_flags['CPPDEFINES']:
|
||||
if isinstance(s, tuple):
|
||||
cmd += ['-D' + s[0] + '=' + str(s[1])]
|
||||
else:
|
||||
cmd += ['-D' + s]
|
||||
|
||||
cmd += ['-D__MARLIN_DEPS__ -w -dM -E -x c++']
|
||||
depcmd = cmd + [ filename ]
|
||||
cmd = ' '.join(depcmd)
|
||||
blab(cmd)
|
||||
try:
|
||||
define_list = subprocess.check_output(cmd, shell=True).splitlines()
|
||||
except:
|
||||
define_list = {}
|
||||
preprocessor_cache[filename] = define_list
|
||||
return define_list
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Find a compiler, considering the OS
|
||||
#
|
||||
def search_compiler(env):
|
||||
|
||||
from pathlib import Path, PurePath
|
||||
|
||||
ENV_BUILD_PATH = Path(env['PROJECT_BUILD_DIR'], env['PIOENV'])
|
||||
GCC_PATH_CACHE = ENV_BUILD_PATH / ".gcc_path"
|
||||
|
||||
try:
|
||||
gccpath = env.GetProjectOption('custom_gcc')
|
||||
blab("Getting compiler from env")
|
||||
return gccpath
|
||||
except:
|
||||
pass
|
||||
|
||||
# Warning: The cached .gcc_path will obscure a newly-installed toolkit
|
||||
if not nocache and GCC_PATH_CACHE.exists():
|
||||
blab("Getting g++ path from cache")
|
||||
return GCC_PATH_CACHE.read_text()
|
||||
|
||||
# Use any item in $PATH corresponding to a platformio toolchain bin folder
|
||||
path_separator = ':'
|
||||
gcc_exe = '*g++'
|
||||
if env['PLATFORM'] == 'win32':
|
||||
path_separator = ';'
|
||||
gcc_exe += ".exe"
|
||||
|
||||
# Search for the compiler in PATH
|
||||
for ppath in map(Path, env['ENV']['PATH'].split(path_separator)):
|
||||
if ppath.match(env['PROJECT_PACKAGES_DIR'] + "/**/bin"):
|
||||
for gpath in ppath.glob(gcc_exe):
|
||||
gccpath = str(gpath.resolve())
|
||||
# Cache the g++ path to no search always
|
||||
if not nocache and ENV_BUILD_PATH.exists():
|
||||
blab("Caching g++ for current env")
|
||||
GCC_PATH_CACHE.write_text(gccpath)
|
||||
return gccpath
|
||||
|
||||
gccpath = env.get('CXX')
|
||||
blab("Couldn't find a compiler! Fallback to %s" % gccpath)
|
||||
return gccpath
|
@@ -2,8 +2,8 @@
|
||||
# random-bin.py
|
||||
# Set a unique firmware name based on current date and time
|
||||
#
|
||||
Import("env")
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
env['PROGNAME'] = datetime.now().strftime("firmware-%Y%m%d-%H%M%S")
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
from datetime import datetime
|
||||
Import("env")
|
||||
env['PROGNAME'] = datetime.now().strftime("firmware-%Y%m%d-%H%M%S")
|
||||
|
@@ -1,12 +0,0 @@
|
||||
#
|
||||
# buildroot/share/PlatformIO/scripts/robin.py
|
||||
#
|
||||
import marlin
|
||||
|
||||
# Apply customizations for a MKS Robin
|
||||
def prepare(address, ldname, fwname):
|
||||
def encrypt(source, target, env):
|
||||
marlin.encrypt_mks(source, target, env, fwname)
|
||||
marlin.relocate_firmware(address)
|
||||
marlin.custom_ld_script(ldname)
|
||||
marlin.add_post_action(encrypt);
|
403
buildroot/share/PlatformIO/scripts/schema.py
Executable file
403
buildroot/share/PlatformIO/scripts/schema.py
Executable file
@@ -0,0 +1,403 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# schema.py
|
||||
#
|
||||
# Used by signature.py via common-dependencies.py to generate a schema file during the PlatformIO build.
|
||||
# This script can also be run standalone from within the Marlin repo to generate all schema files.
|
||||
#
|
||||
import re,json
|
||||
from pathlib import Path
|
||||
|
||||
def extend_dict(d:dict, k:tuple):
|
||||
if len(k) >= 1 and k[0] not in d:
|
||||
d[k[0]] = {}
|
||||
if len(k) >= 2 and k[1] not in d[k[0]]:
|
||||
d[k[0]][k[1]] = {}
|
||||
if len(k) >= 3 and k[2] not in d[k[0]][k[1]]:
|
||||
d[k[0]][k[1]][k[2]] = {}
|
||||
|
||||
grouping_patterns = [
|
||||
re.compile(r'^([XYZIJKUVW]|[XYZ]2|Z[34]|E[0-7])$'),
|
||||
re.compile(r'^AXIS\d$'),
|
||||
re.compile(r'^(MIN|MAX)$'),
|
||||
re.compile(r'^[0-8]$'),
|
||||
re.compile(r'^HOTEND[0-7]$'),
|
||||
re.compile(r'^(HOTENDS|BED|PROBE|COOLER)$'),
|
||||
re.compile(r'^[XYZIJKUVW]M(IN|AX)$')
|
||||
]
|
||||
# If the indexed part of the option name matches a pattern
|
||||
# then add it to the dictionary.
|
||||
def find_grouping(gdict, filekey, sectkey, optkey, pindex):
|
||||
optparts = optkey.split('_')
|
||||
if 1 < len(optparts) > pindex:
|
||||
for patt in grouping_patterns:
|
||||
if patt.match(optparts[pindex]):
|
||||
subkey = optparts[pindex]
|
||||
modkey = '_'.join(optparts)
|
||||
optparts[pindex] = '*'
|
||||
wildkey = '_'.join(optparts)
|
||||
kkey = f'{filekey}|{sectkey}|{wildkey}'
|
||||
if kkey not in gdict: gdict[kkey] = []
|
||||
gdict[kkey].append((subkey, modkey))
|
||||
|
||||
# Build a list of potential groups. Only those with multiple items will be grouped.
|
||||
def group_options(schema):
|
||||
for pindex in range(10, -1, -1):
|
||||
found_groups = {}
|
||||
for filekey, f in schema.items():
|
||||
for sectkey, s in f.items():
|
||||
for optkey in s:
|
||||
find_grouping(found_groups, filekey, sectkey, optkey, pindex)
|
||||
|
||||
fkeys = [ k for k in found_groups.keys() ]
|
||||
for kkey in fkeys:
|
||||
items = found_groups[kkey]
|
||||
if len(items) > 1:
|
||||
f, s, w = kkey.split('|')
|
||||
extend_dict(schema, (f, s, w)) # Add wildcard group to schema
|
||||
for subkey, optkey in items: # Add all items to wildcard group
|
||||
schema[f][s][w][subkey] = schema[f][s][optkey] # Move non-wildcard item to wildcard group
|
||||
del schema[f][s][optkey]
|
||||
del found_groups[kkey]
|
||||
|
||||
# Extract all board names from boards.h
|
||||
def load_boards():
|
||||
bpath = Path("Marlin/src/core/boards.h")
|
||||
if bpath.is_file():
|
||||
with bpath.open() as bfile:
|
||||
boards = []
|
||||
for line in bfile:
|
||||
if line.startswith("#define BOARD_"):
|
||||
bname = line.split()[1]
|
||||
if bname != "BOARD_UNKNOWN": boards.append(bname)
|
||||
return "['" + "','".join(boards) + "']"
|
||||
return ''
|
||||
|
||||
#
|
||||
# Extract a schema from the current configuration files
|
||||
#
|
||||
def extract():
|
||||
# Load board names from boards.h
|
||||
boards = load_boards()
|
||||
|
||||
# Parsing states
|
||||
class Parse:
|
||||
NORMAL = 0 # No condition yet
|
||||
BLOCK_COMMENT = 1 # Looking for the end of the block comment
|
||||
EOL_COMMENT = 2 # EOL comment started, maybe add the next comment?
|
||||
GET_SENSORS = 3 # Gathering temperature sensor options
|
||||
ERROR = 9 # Syntax error
|
||||
|
||||
# List of files to process, with shorthand
|
||||
filekey = { 'Configuration.h':'basic', 'Configuration_adv.h':'advanced' }
|
||||
# A JSON object to store the data
|
||||
sch_out = { 'basic':{}, 'advanced':{} }
|
||||
# Regex for #define NAME [VALUE] [COMMENT] with sanitized line
|
||||
defgrep = re.compile(r'^(//)?\s*(#define)\s+([A-Za-z0-9_]+)\s*(.*?)\s*(//.+)?$')
|
||||
# Defines to ignore
|
||||
ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXPORT')
|
||||
# Start with unknown state
|
||||
state = Parse.NORMAL
|
||||
# Serial ID
|
||||
sid = 0
|
||||
# Loop through files and parse them line by line
|
||||
for fn, fk in filekey.items():
|
||||
with Path("Marlin", fn).open() as fileobj:
|
||||
section = 'none' # Current Settings section
|
||||
line_number = 0 # Counter for the line number of the file
|
||||
conditions = [] # Create a condition stack for the current file
|
||||
comment_buff = [] # A temporary buffer for comments
|
||||
options_json = '' # A buffer for the most recent options JSON found
|
||||
eol_options = False # The options came from end of line, so only apply once
|
||||
join_line = False # A flag that the line should be joined with the previous one
|
||||
line = '' # A line buffer to handle \ continuation
|
||||
last_added_ref = None # Reference to the last added item
|
||||
# Loop through the lines in the file
|
||||
for the_line in fileobj.readlines():
|
||||
line_number += 1
|
||||
|
||||
# Clean the line for easier parsing
|
||||
the_line = the_line.strip()
|
||||
|
||||
if join_line: # A previous line is being made longer
|
||||
line += (' ' if line else '') + the_line
|
||||
else: # Otherwise, start the line anew
|
||||
line, line_start = the_line, line_number
|
||||
|
||||
# If the resulting line ends with a \, don't process now.
|
||||
# Strip the end off. The next line will be joined with it.
|
||||
join_line = line.endswith("\\")
|
||||
if join_line:
|
||||
line = line[:-1].strip()
|
||||
continue
|
||||
else:
|
||||
line_end = line_number
|
||||
|
||||
defmatch = defgrep.match(line)
|
||||
|
||||
# Special handling for EOL comments after a #define.
|
||||
# At this point the #define is already digested and inserted,
|
||||
# so we have to extend it
|
||||
if state == Parse.EOL_COMMENT:
|
||||
# If the line is not a comment, we're done with the EOL comment
|
||||
if not defmatch and the_line.startswith('//'):
|
||||
comment_buff.append(the_line[2:].strip())
|
||||
else:
|
||||
last_added_ref['comment'] = ' '.join(comment_buff)
|
||||
comment_buff = []
|
||||
state = Parse.NORMAL
|
||||
|
||||
def use_comment(c, opt, sec, bufref):
|
||||
if c.startswith(':'): # If the comment starts with : then it has magic JSON
|
||||
d = c[1:].strip() # Strip the leading :
|
||||
cbr = c.rindex('}') if d.startswith('{') else c.rindex(']') if d.startswith('[') else 0
|
||||
if cbr:
|
||||
opt, cmt = c[1:cbr+1].strip(), c[cbr+1:].strip()
|
||||
if cmt != '': bufref.append(cmt)
|
||||
else:
|
||||
opt = c[1:].strip()
|
||||
elif c.startswith('@section'): # Start a new section
|
||||
sec = c[8:].strip()
|
||||
elif not c.startswith('========'):
|
||||
bufref.append(c)
|
||||
return opt, sec
|
||||
|
||||
# In a block comment, capture lines up to the end of the comment.
|
||||
# Assume nothing follows the comment closure.
|
||||
if state in (Parse.BLOCK_COMMENT, Parse.GET_SENSORS):
|
||||
endpos = line.find('*/')
|
||||
if endpos < 0:
|
||||
cline = line
|
||||
else:
|
||||
cline, line = line[:endpos].strip(), line[endpos+2:].strip()
|
||||
|
||||
# Temperature sensors are done
|
||||
if state == Parse.GET_SENSORS:
|
||||
options_json = f'[ {options_json[:-2]} ]'
|
||||
|
||||
state = Parse.NORMAL
|
||||
|
||||
# Strip the leading '*' from block comments
|
||||
if cline.startswith('*'): cline = cline[1:].strip()
|
||||
|
||||
# Collect temperature sensors
|
||||
if state == Parse.GET_SENSORS:
|
||||
sens = re.match(r'^(-?\d+)\s*:\s*(.+)$', cline)
|
||||
if sens:
|
||||
s2 = sens[2].replace("'","''")
|
||||
options_json += f"{sens[1]}:'{s2}', "
|
||||
|
||||
elif state == Parse.BLOCK_COMMENT:
|
||||
|
||||
# Look for temperature sensors
|
||||
if cline == "Temperature sensors available:":
|
||||
state, cline = Parse.GET_SENSORS, "Temperature Sensors"
|
||||
|
||||
options_json, section = use_comment(cline, options_json, section, comment_buff)
|
||||
|
||||
# For the normal state we're looking for any non-blank line
|
||||
elif state == Parse.NORMAL:
|
||||
# Skip a commented define when evaluating comment opening
|
||||
st = 2 if re.match(r'^//\s*#define', line) else 0
|
||||
cpos1 = line.find('/*') # Start a block comment on the line?
|
||||
cpos2 = line.find('//', st) # Start an end of line comment on the line?
|
||||
|
||||
# Only the first comment starter gets evaluated
|
||||
cpos = -1
|
||||
if cpos1 != -1 and (cpos1 < cpos2 or cpos2 == -1):
|
||||
cpos = cpos1
|
||||
comment_buff = []
|
||||
state = Parse.BLOCK_COMMENT
|
||||
eol_options = False
|
||||
|
||||
elif cpos2 != -1 and (cpos2 < cpos1 or cpos1 == -1):
|
||||
cpos = cpos2
|
||||
|
||||
# Expire end-of-line options after first use
|
||||
if cline.startswith(':'): eol_options = True
|
||||
|
||||
# Comment after a define may be continued on the following lines
|
||||
if state == Parse.NORMAL and defmatch != None and cpos > 10:
|
||||
state = Parse.EOL_COMMENT
|
||||
comment_buff = []
|
||||
|
||||
# Process the start of a new comment
|
||||
if cpos != -1:
|
||||
cline, line = line[cpos+2:].strip(), line[:cpos].strip()
|
||||
|
||||
# Strip leading '*' from block comments
|
||||
if state == Parse.BLOCK_COMMENT:
|
||||
if cline.startswith('*'): cline = cline[1:].strip()
|
||||
|
||||
# Buffer a non-empty comment start
|
||||
if cline != '':
|
||||
options_json, section = use_comment(cline, options_json, section, comment_buff)
|
||||
|
||||
# If the line has nothing before the comment, go to the next line
|
||||
if line == '':
|
||||
options_json = ''
|
||||
continue
|
||||
|
||||
# Parenthesize the given expression if needed
|
||||
def atomize(s):
|
||||
if s == '' \
|
||||
or re.match(r'^[A-Za-z0-9_]*(\([^)]+\))?$', s) \
|
||||
or re.match(r'^[A-Za-z0-9_]+ == \d+?$', s):
|
||||
return s
|
||||
return f'({s})'
|
||||
|
||||
#
|
||||
# The conditions stack is an array containing condition-arrays.
|
||||
# Each condition-array lists the conditions for the current block.
|
||||
# IF/N/DEF adds a new condition-array to the stack.
|
||||
# ELSE/ELIF/ENDIF pop the condition-array.
|
||||
# ELSE/ELIF negate the last item in the popped condition-array.
|
||||
# ELIF adds a new condition to the end of the array.
|
||||
# ELSE/ELIF re-push the condition-array.
|
||||
#
|
||||
cparts = line.split()
|
||||
iselif, iselse = cparts[0] == '#elif', cparts[0] == '#else'
|
||||
if iselif or iselse or cparts[0] == '#endif':
|
||||
if len(conditions) == 0:
|
||||
raise Exception(f'no #if block at line {line_number}')
|
||||
|
||||
# Pop the last condition-array from the stack
|
||||
prev = conditions.pop()
|
||||
|
||||
if iselif or iselse:
|
||||
prev[-1] = '!' + prev[-1] # Invert the last condition
|
||||
if iselif: prev.append(atomize(line[5:].strip()))
|
||||
conditions.append(prev)
|
||||
|
||||
elif cparts[0] == '#if':
|
||||
conditions.append([ atomize(line[3:].strip()) ])
|
||||
elif cparts[0] == '#ifdef':
|
||||
conditions.append([ f'defined({line[6:].strip()})' ])
|
||||
elif cparts[0] == '#ifndef':
|
||||
conditions.append([ f'!defined({line[7:].strip()})' ])
|
||||
|
||||
# Handle a complete #define line
|
||||
elif defmatch != None:
|
||||
|
||||
# Get the match groups into vars
|
||||
enabled, define_name, val = defmatch[1] == None, defmatch[3], defmatch[4]
|
||||
|
||||
# Increment the serial ID
|
||||
sid += 1
|
||||
|
||||
# Create a new dictionary for the current #define
|
||||
define_info = {
|
||||
'section': section,
|
||||
'name': define_name,
|
||||
'enabled': enabled,
|
||||
'line': line_start,
|
||||
'sid': sid
|
||||
}
|
||||
|
||||
if val != '': define_info['value'] = val
|
||||
|
||||
# Type is based on the value
|
||||
if val == '':
|
||||
value_type = 'switch'
|
||||
elif re.match(r'^(true|false)$', val):
|
||||
value_type = 'bool'
|
||||
val = val == 'true'
|
||||
elif re.match(r'^[-+]?\s*\d+$', val):
|
||||
value_type = 'int'
|
||||
val = int(val)
|
||||
elif re.match(r'[-+]?\s*(\d+\.|\d*\.\d+)([eE][-+]?\d+)?[fF]?', val):
|
||||
value_type = 'float'
|
||||
val = float(val.replace('f',''))
|
||||
else:
|
||||
value_type = 'string' if val[0] == '"' \
|
||||
else 'char' if val[0] == "'" \
|
||||
else 'state' if re.match(r'^(LOW|HIGH)$', val) \
|
||||
else 'enum' if re.match(r'^[A-Za-z0-9_]{3,}$', val) \
|
||||
else 'int[]' if re.match(r'^{(\s*[-+]?\s*\d+\s*(,\s*)?)+}$', val) \
|
||||
else 'float[]' if re.match(r'^{(\s*[-+]?\s*(\d+\.|\d*\.\d+)([eE][-+]?\d+)?[fF]?\s*(,\s*)?)+}$', val) \
|
||||
else 'array' if val[0] == '{' \
|
||||
else ''
|
||||
|
||||
if value_type != '': define_info['type'] = value_type
|
||||
|
||||
# Join up accumulated conditions with &&
|
||||
if conditions: define_info['requires'] = ' && '.join(sum(conditions, []))
|
||||
|
||||
# If the comment_buff is not empty, add the comment to the info
|
||||
if comment_buff:
|
||||
full_comment = '\n'.join(comment_buff)
|
||||
|
||||
# An EOL comment will be added later
|
||||
# The handling could go here instead of above
|
||||
if state == Parse.EOL_COMMENT:
|
||||
define_info['comment'] = ''
|
||||
else:
|
||||
define_info['comment'] = full_comment
|
||||
comment_buff = []
|
||||
|
||||
# If the comment specifies units, add that to the info
|
||||
units = re.match(r'^\(([^)]+)\)', full_comment)
|
||||
if units:
|
||||
units = units[1]
|
||||
if units == 's' or units == 'sec': units = 'seconds'
|
||||
define_info['units'] = units
|
||||
|
||||
# Set the options for the current #define
|
||||
if define_name == "MOTHERBOARD" and boards != '':
|
||||
define_info['options'] = boards
|
||||
elif options_json != '':
|
||||
define_info['options'] = options_json
|
||||
if eol_options: options_json = ''
|
||||
|
||||
# Create section dict if it doesn't exist yet
|
||||
if section not in sch_out[fk]: sch_out[fk][section] = {}
|
||||
|
||||
# If define has already been seen...
|
||||
if define_name in sch_out[fk][section]:
|
||||
info = sch_out[fk][section][define_name]
|
||||
if isinstance(info, dict): info = [ info ] # Convert a single dict into a list
|
||||
info.append(define_info) # Add to the list
|
||||
else:
|
||||
# Add the define dict with name as key
|
||||
sch_out[fk][section][define_name] = define_info
|
||||
|
||||
if state == Parse.EOL_COMMENT:
|
||||
last_added_ref = define_info
|
||||
|
||||
return sch_out
|
||||
|
||||
def dump_json(schema:dict, jpath:Path):
|
||||
with jpath.open('w') as jfile:
|
||||
json.dump(schema, jfile, ensure_ascii=False, indent=2)
|
||||
|
||||
def dump_yaml(schema:dict, ypath:Path):
|
||||
import yaml
|
||||
with ypath.open('w') as yfile:
|
||||
yaml.dump(schema, yfile, default_flow_style=False, width=120, indent=2)
|
||||
|
||||
def main():
|
||||
try:
|
||||
schema = extract()
|
||||
except Exception as exc:
|
||||
print("Error: " + str(exc))
|
||||
schema = None
|
||||
|
||||
if schema:
|
||||
print("Generating JSON ...")
|
||||
dump_json(schema, Path('schema.json'))
|
||||
group_options(schema)
|
||||
dump_json(schema, Path('schema_grouped.json'))
|
||||
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
print("Installing YAML module ...")
|
||||
import subprocess
|
||||
subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml'])
|
||||
import yaml
|
||||
|
||||
print("Generating YML ...")
|
||||
dump_yaml(schema, Path('schema.yml'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
276
buildroot/share/PlatformIO/scripts/signature.py
Normal file
276
buildroot/share/PlatformIO/scripts/signature.py
Normal file
@@ -0,0 +1,276 @@
|
||||
#
|
||||
# signature.py
|
||||
#
|
||||
import schema
|
||||
|
||||
import subprocess,re,json,hashlib
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
#
|
||||
# Return all macro names in a header as an array, so we can take
|
||||
# the intersection with the preprocessor output, giving a decent
|
||||
# reflection of all enabled options that (probably) came from the
|
||||
# configuration files. We end up with the actual configured state,
|
||||
# better than what the config files say. You can then use the
|
||||
# resulting config.ini to produce more exact configuration files.
|
||||
#
|
||||
def extract_defines(filepath):
|
||||
f = open(filepath, encoding="utf8").read().split("\n")
|
||||
a = []
|
||||
for line in f:
|
||||
sline = line.strip()
|
||||
if sline[:7] == "#define":
|
||||
# Extract the key here (we don't care about the value)
|
||||
kv = sline[8:].strip().split()
|
||||
a.append(kv[0])
|
||||
return a
|
||||
|
||||
# Compute the SHA256 hash of a file
|
||||
def get_file_sha256sum(filepath):
|
||||
sha256_hash = hashlib.sha256()
|
||||
with open(filepath,"rb") as f:
|
||||
# Read and update hash string value in blocks of 4K
|
||||
for byte_block in iter(lambda: f.read(4096),b""):
|
||||
sha256_hash.update(byte_block)
|
||||
return sha256_hash.hexdigest()
|
||||
|
||||
#
|
||||
# Compress a JSON file into a zip file
|
||||
#
|
||||
import zipfile
|
||||
def compress_file(filepath, outpath):
|
||||
with zipfile.ZipFile(outpath, 'w', compression=zipfile.ZIP_BZIP2, compresslevel=9) as zipf:
|
||||
zipf.write(filepath, compress_type=zipfile.ZIP_BZIP2, compresslevel=9)
|
||||
|
||||
#
|
||||
# Compute the build signature. The idea is to extract all defines in the configuration headers
|
||||
# to build a unique reversible signature from this build so it can be included in the binary
|
||||
# We can reverse the signature to get a 1:1 equivalent configuration file
|
||||
#
|
||||
def compute_build_signature(env):
|
||||
if 'BUILD_SIGNATURE' in env:
|
||||
return
|
||||
|
||||
# Definitions from these files will be kept
|
||||
files_to_keep = [ 'Marlin/Configuration.h', 'Marlin/Configuration_adv.h' ]
|
||||
|
||||
build_path = Path(env['PROJECT_BUILD_DIR'], env['PIOENV'])
|
||||
|
||||
# Check if we can skip processing
|
||||
hashes = ''
|
||||
for header in files_to_keep:
|
||||
hashes += get_file_sha256sum(header)[0:10]
|
||||
|
||||
marlin_json = build_path / 'marlin_config.json'
|
||||
marlin_zip = build_path / 'mc.zip'
|
||||
|
||||
# Read existing config file
|
||||
try:
|
||||
with marlin_json.open() as infile:
|
||||
conf = json.load(infile)
|
||||
if conf['__INITIAL_HASH'] == hashes:
|
||||
# Same configuration, skip recomputing the building signature
|
||||
compress_file(marlin_json, marlin_zip)
|
||||
return
|
||||
except:
|
||||
pass
|
||||
|
||||
# Get enabled config options based on preprocessor
|
||||
from preprocessor import run_preprocessor
|
||||
complete_cfg = run_preprocessor(env)
|
||||
|
||||
# Dumb #define extraction from the configuration files
|
||||
conf_defines = {}
|
||||
all_defines = []
|
||||
for header in files_to_keep:
|
||||
defines = extract_defines(header)
|
||||
# To filter only the define we want
|
||||
all_defines += defines
|
||||
# To remember from which file it cames from
|
||||
conf_defines[header.split('/')[-1]] = defines
|
||||
|
||||
r = re.compile(r"\(+(\s*-*\s*_.*)\)+")
|
||||
|
||||
# First step is to collect all valid macros
|
||||
defines = {}
|
||||
for line in complete_cfg:
|
||||
|
||||
# Split the define from the value
|
||||
key_val = line[8:].strip().decode().split(' ')
|
||||
key, value = key_val[0], ' '.join(key_val[1:])
|
||||
|
||||
# Ignore values starting with two underscore, since it's low level
|
||||
if len(key) > 2 and key[0:2] == "__" :
|
||||
continue
|
||||
# Ignore values containing a parenthesis (likely a function macro)
|
||||
if '(' in key and ')' in key:
|
||||
continue
|
||||
|
||||
# Then filter dumb values
|
||||
if r.match(value):
|
||||
continue
|
||||
|
||||
defines[key] = value if len(value) else ""
|
||||
|
||||
#
|
||||
# Continue to gather data for CONFIGURATION_EMBEDDING or CONFIG_EXPORT
|
||||
#
|
||||
if not ('CONFIGURATION_EMBEDDING' in defines or 'CONFIG_EXPORT' in defines):
|
||||
return
|
||||
|
||||
# Second step is to filter useless macro
|
||||
resolved_defines = {}
|
||||
for key in defines:
|
||||
# Remove all boards now
|
||||
if key.startswith("BOARD_") and key != "BOARD_INFO_NAME":
|
||||
continue
|
||||
# Remove all keys ending by "_NAME" as it does not make a difference to the configuration
|
||||
if key.endswith("_NAME") and key != "CUSTOM_MACHINE_NAME":
|
||||
continue
|
||||
# Remove all keys ending by "_T_DECLARED" as it's a copy of extraneous system stuff
|
||||
if key.endswith("_T_DECLARED"):
|
||||
continue
|
||||
# Remove keys that are not in the #define list in the Configuration list
|
||||
if key not in all_defines + [ 'DETAILED_BUILD_VERSION', 'STRING_DISTRIBUTION_DATE' ]:
|
||||
continue
|
||||
|
||||
# Don't be that smart guy here
|
||||
resolved_defines[key] = defines[key]
|
||||
|
||||
# Generate a build signature now
|
||||
# We are making an object that's a bit more complex than a basic dictionary here
|
||||
data = {}
|
||||
data['__INITIAL_HASH'] = hashes
|
||||
# First create a key for each header here
|
||||
for header in conf_defines:
|
||||
data[header] = {}
|
||||
|
||||
# Then populate the object where each key is going to (that's a O(N^2) algorithm here...)
|
||||
for key in resolved_defines:
|
||||
for header in conf_defines:
|
||||
if key in conf_defines[header]:
|
||||
data[header][key] = resolved_defines[key]
|
||||
|
||||
# Every python needs this toy
|
||||
def tryint(key):
|
||||
try:
|
||||
return int(defines[key])
|
||||
except:
|
||||
return 0
|
||||
|
||||
config_dump = tryint('CONFIG_EXPORT')
|
||||
|
||||
#
|
||||
# Produce an INI file if CONFIG_EXPORT == 2
|
||||
#
|
||||
if config_dump == 2:
|
||||
print("Generating config.ini ...")
|
||||
config_ini = build_path / 'config.ini'
|
||||
with config_ini.open('w') as outfile:
|
||||
ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXPORT')
|
||||
filegrp = { 'Configuration.h':'config:basic', 'Configuration_adv.h':'config:advanced' }
|
||||
vers = defines["CONFIGURATION_H_VERSION"]
|
||||
dt_string = datetime.now().strftime("%Y-%m-%d at %H:%M:%S")
|
||||
ini_fmt = '{0:40}{1}\n'
|
||||
outfile.write(
|
||||
'#\n'
|
||||
+ '# Marlin Firmware\n'
|
||||
+ '# config.ini - Options to apply before the build\n'
|
||||
+ '#\n'
|
||||
+ f'# Generated by Marlin build on {dt_string}\n'
|
||||
+ '#\n'
|
||||
+ '\n'
|
||||
+ '[config:base]\n'
|
||||
+ ini_fmt.format('ini_use_config', ' = all')
|
||||
+ ini_fmt.format('ini_config_vers', f' = {vers}')
|
||||
)
|
||||
# Loop through the data array of arrays
|
||||
for header in data:
|
||||
if header.startswith('__'):
|
||||
continue
|
||||
outfile.write('\n[' + filegrp[header] + ']\n')
|
||||
for key in sorted(data[header]):
|
||||
if key not in ignore:
|
||||
val = 'on' if data[header][key] == '' else data[header][key]
|
||||
outfile.write(ini_fmt.format(key.lower(), ' = ' + val))
|
||||
|
||||
#
|
||||
# Produce a schema.json file if CONFIG_EXPORT == 3
|
||||
#
|
||||
if config_dump >= 3:
|
||||
try:
|
||||
conf_schema = schema.extract()
|
||||
except Exception as exc:
|
||||
print("Error: " + str(exc))
|
||||
conf_schema = None
|
||||
|
||||
if conf_schema:
|
||||
#
|
||||
# Produce a schema.json file if CONFIG_EXPORT == 3
|
||||
#
|
||||
if config_dump in (3, 13):
|
||||
print("Generating schema.json ...")
|
||||
schema.dump_json(conf_schema, build_path / 'schema.json')
|
||||
if config_dump == 13:
|
||||
schema.group_options(conf_schema)
|
||||
schema.dump_json(conf_schema, build_path / 'schema_grouped.json')
|
||||
|
||||
#
|
||||
# Produce a schema.yml file if CONFIG_EXPORT == 4
|
||||
#
|
||||
elif config_dump == 4:
|
||||
print("Generating schema.yml ...")
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
env.Execute(env.VerboseAction(
|
||||
'$PYTHONEXE -m pip install "pyyaml"',
|
||||
"Installing YAML for schema.yml export",
|
||||
))
|
||||
import yaml
|
||||
schema.dump_yaml(conf_schema, build_path / 'schema.yml')
|
||||
|
||||
# Append the source code version and date
|
||||
data['VERSION'] = {}
|
||||
data['VERSION']['DETAILED_BUILD_VERSION'] = resolved_defines['DETAILED_BUILD_VERSION']
|
||||
data['VERSION']['STRING_DISTRIBUTION_DATE'] = resolved_defines['STRING_DISTRIBUTION_DATE']
|
||||
try:
|
||||
curver = subprocess.check_output(["git", "describe", "--match=NeVeRmAtCh", "--always"]).strip()
|
||||
data['VERSION']['GIT_REF'] = curver.decode()
|
||||
except:
|
||||
pass
|
||||
|
||||
#
|
||||
# Produce a JSON file for CONFIGURATION_EMBEDDING or CONFIG_EXPORT == 1
|
||||
#
|
||||
if config_dump == 1 or 'CONFIGURATION_EMBEDDING' in defines:
|
||||
with marlin_json.open('w') as outfile:
|
||||
json.dump(data, outfile, separators=(',', ':'))
|
||||
|
||||
#
|
||||
# The rest only applies to CONFIGURATION_EMBEDDING
|
||||
#
|
||||
if not 'CONFIGURATION_EMBEDDING' in defines:
|
||||
return
|
||||
|
||||
# Compress the JSON file as much as we can
|
||||
compress_file(marlin_json, marlin_zip)
|
||||
|
||||
# Generate a C source file for storing this array
|
||||
with open('Marlin/src/mczip.h','wb') as result_file:
|
||||
result_file.write(
|
||||
b'#ifndef NO_CONFIGURATION_EMBEDDING_WARNING\n'
|
||||
+ b' #warning "Generated file \'mc.zip\' is embedded (Define NO_CONFIGURATION_EMBEDDING_WARNING to suppress this warning.)"\n'
|
||||
+ b'#endif\n'
|
||||
+ b'const unsigned char mc_zip[] PROGMEM = {\n '
|
||||
)
|
||||
count = 0
|
||||
for b in (build_path / 'mc.zip').open('rb').read():
|
||||
result_file.write(b' 0x%02X,' % b)
|
||||
count += 1
|
||||
if count % 16 == 0:
|
||||
result_file.write(b'\n ')
|
||||
if count % 16:
|
||||
result_file.write(b'\n')
|
||||
result_file.write(b'};\n')
|
@@ -1,52 +1,52 @@
|
||||
#
|
||||
# simulator.py
|
||||
# PlatformIO pre: script for simulator builds
|
||||
#
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
# Get the environment thus far for the build
|
||||
Import("env")
|
||||
|
||||
# Get the environment thus far for the build
|
||||
Import("env")
|
||||
#print(env.Dump())
|
||||
|
||||
#print(env.Dump())
|
||||
#
|
||||
# Give the binary a distinctive name
|
||||
#
|
||||
|
||||
#
|
||||
# Give the binary a distinctive name
|
||||
#
|
||||
env['PROGNAME'] = "MarlinSimulator"
|
||||
|
||||
env['PROGNAME'] = "MarlinSimulator"
|
||||
#
|
||||
# If Xcode is installed add the path to its Frameworks folder,
|
||||
# or if Mesa is installed try to use its GL/gl.h.
|
||||
#
|
||||
|
||||
#
|
||||
# If Xcode is installed add the path to its Frameworks folder,
|
||||
# or if Mesa is installed try to use its GL/gl.h.
|
||||
#
|
||||
import sys
|
||||
if sys.platform == 'darwin':
|
||||
|
||||
import sys
|
||||
if sys.platform == 'darwin':
|
||||
#
|
||||
# Silence half of the ranlib warnings. (No equivalent for 'ARFLAGS')
|
||||
#
|
||||
env['RANLIBFLAGS'] += [ "-no_warning_for_no_symbols" ]
|
||||
|
||||
#
|
||||
# Silence half of the ranlib warnings. (No equivalent for 'ARFLAGS')
|
||||
#
|
||||
env['RANLIBFLAGS'] += [ "-no_warning_for_no_symbols" ]
|
||||
# Default paths for Xcode and a lucky GL/gl.h dropped by Mesa
|
||||
xcode_path = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
|
||||
mesa_path = "/opt/local/include/GL/gl.h"
|
||||
|
||||
# Default paths for Xcode and a lucky GL/gl.h dropped by Mesa
|
||||
xcode_path = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
|
||||
mesa_path = "/opt/local/include/GL/gl.h"
|
||||
import os.path
|
||||
|
||||
import os.path
|
||||
if os.path.exists(xcode_path):
|
||||
|
||||
if os.path.exists(xcode_path):
|
||||
env['BUILD_FLAGS'] += [ "-F" + xcode_path ]
|
||||
print("Using OpenGL framework headers from Xcode.app")
|
||||
|
||||
env['BUILD_FLAGS'] += [ "-F" + xcode_path ]
|
||||
print("Using OpenGL framework headers from Xcode.app")
|
||||
elif os.path.exists(mesa_path):
|
||||
|
||||
elif os.path.exists(mesa_path):
|
||||
env['BUILD_FLAGS'] += [ '-D__MESA__' ]
|
||||
print("Using OpenGL header from", mesa_path)
|
||||
|
||||
env['BUILD_FLAGS'] += [ '-D__MESA__' ]
|
||||
print("Using OpenGL header from", mesa_path)
|
||||
else:
|
||||
|
||||
else:
|
||||
print("\n\nNo OpenGL headers found. Install Xcode for matching headers, or use 'sudo port install mesa' to get a GL/gl.h.\n\n")
|
||||
|
||||
print("\n\nNo OpenGL headers found. Install Xcode for matching headers, or use 'sudo port install mesa' to get a GL/gl.h.\n\n")
|
||||
|
||||
# Break out of the PIO build immediately
|
||||
sys.exit(1)
|
||||
|
||||
env.AddCustomTarget("upload", "$BUILD_DIR/${PROGNAME}", "$BUILD_DIR/${PROGNAME}")
|
||||
# Break out of the PIO build immediately
|
||||
sys.exit(1)
|
||||
|
@@ -1,59 +1,61 @@
|
||||
#
|
||||
# stm32_serialbuffer.py
|
||||
#
|
||||
Import("env")
|
||||
import pioutil
|
||||
if pioutil.is_pio_build():
|
||||
Import("env")
|
||||
|
||||
# Marlin uses the `RX_BUFFER_SIZE` \ `TX_BUFFER_SIZE` options to
|
||||
# configure buffer sizes for receiving \ transmitting serial data.
|
||||
# Stm32duino uses another set of defines for the same purpose, so this
|
||||
# script gets the values from the configuration and uses them to define
|
||||
# `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE` as global build
|
||||
# flags so they are available for use by the platform.
|
||||
#
|
||||
# The script will set the value as the default one (64 bytes)
|
||||
# or the user-configured one, whichever is higher.
|
||||
#
|
||||
# Marlin's default buffer sizes are 128 for RX and 32 for TX.
|
||||
# The highest value is taken (128/64).
|
||||
#
|
||||
# If MF_*_BUFFER_SIZE, SERIAL_*_BUFFER_SIZE, USART_*_BUF_SIZE, are
|
||||
# defined, the first of these values will be used as the minimum.
|
||||
build_flags = env.ParseFlags(env.get('BUILD_FLAGS'))["CPPDEFINES"]
|
||||
mf = env["MARLIN_FEATURES"]
|
||||
# Get a build flag's value or None
|
||||
def getBuildFlagValue(name):
|
||||
for flag in build_flags:
|
||||
if isinstance(flag, list) and flag[0] == name:
|
||||
return flag[1]
|
||||
|
||||
# Get a build flag's value or None
|
||||
def getBuildFlagValue(name):
|
||||
for flag in build_flags:
|
||||
if isinstance(flag, list) and flag[0] == name:
|
||||
return flag[1]
|
||||
return None
|
||||
|
||||
return None
|
||||
# Get an overriding buffer size for RX or TX from the build flags
|
||||
def getInternalSize(side):
|
||||
return getBuildFlagValue(f"MF_{side}_BUFFER_SIZE") or \
|
||||
getBuildFlagValue(f"SERIAL_{side}_BUFFER_SIZE") or \
|
||||
getBuildFlagValue(f"USART_{side}_BUF_SIZE")
|
||||
|
||||
# Get an overriding buffer size for RX or TX from the build flags
|
||||
def getInternalSize(side):
|
||||
return getBuildFlagValue(f"MF_{side}_BUFFER_SIZE") or \
|
||||
getBuildFlagValue(f"SERIAL_{side}_BUFFER_SIZE") or \
|
||||
getBuildFlagValue(f"USART_{side}_BUF_SIZE")
|
||||
# Get the largest defined buffer size for RX or TX
|
||||
def getBufferSize(side, default):
|
||||
# Get a build flag value or fall back to the given default
|
||||
internal = int(getInternalSize(side) or default)
|
||||
flag = side + "_BUFFER_SIZE"
|
||||
# Return the largest value
|
||||
return max(int(mf[flag]), internal) if flag in mf else internal
|
||||
|
||||
# Get the largest defined buffer size for RX or TX
|
||||
def getBufferSize(side, default):
|
||||
# Get a build flag value or fall back to the given default
|
||||
internal = int(getInternalSize(side) or default)
|
||||
flag = side + "_BUFFER_SIZE"
|
||||
# Return the largest value
|
||||
return max(int(mf[flag]), internal) if flag in mf else internal
|
||||
# Add a build flag if it's not already defined
|
||||
def tryAddFlag(name, value):
|
||||
if getBuildFlagValue(name) is None:
|
||||
env.Append(BUILD_FLAGS=[f"-D{name}={value}"])
|
||||
|
||||
# Add a build flag if it's not already defined
|
||||
def tryAddFlag(name, value):
|
||||
if getBuildFlagValue(name) is None:
|
||||
env.Append(BUILD_FLAGS=[f"-D{name}={value}"])
|
||||
# Marlin uses the `RX_BUFFER_SIZE` \ `TX_BUFFER_SIZE` options to
|
||||
# configure buffer sizes for receiving \ transmitting serial data.
|
||||
# Stm32duino uses another set of defines for the same purpose, so this
|
||||
# script gets the values from the configuration and uses them to define
|
||||
# `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE` as global build
|
||||
# flags so they are available for use by the platform.
|
||||
#
|
||||
# The script will set the value as the default one (64 bytes)
|
||||
# or the user-configured one, whichever is higher.
|
||||
#
|
||||
# Marlin's default buffer sizes are 128 for RX and 32 for TX.
|
||||
# The highest value is taken (128/64).
|
||||
#
|
||||
# If MF_*_BUFFER_SIZE, SERIAL_*_BUFFER_SIZE, USART_*_BUF_SIZE, are
|
||||
# defined, the first of these values will be used as the minimum.
|
||||
build_flags = env.ParseFlags(env.get('BUILD_FLAGS'))["CPPDEFINES"]
|
||||
mf = env["MARLIN_FEATURES"]
|
||||
|
||||
# Get the largest defined buffer sizes for RX or TX, using defaults for undefined
|
||||
rxBuf = getBufferSize("RX", 128)
|
||||
txBuf = getBufferSize("TX", 64)
|
||||
# Get the largest defined buffer sizes for RX or TX, using defaults for undefined
|
||||
rxBuf = getBufferSize("RX", 128)
|
||||
txBuf = getBufferSize("TX", 64)
|
||||
|
||||
# Provide serial buffer sizes to the stm32duino platform
|
||||
tryAddFlag("SERIAL_RX_BUFFER_SIZE", rxBuf)
|
||||
tryAddFlag("SERIAL_TX_BUFFER_SIZE", txBuf)
|
||||
tryAddFlag("USART_RX_BUF_SIZE", rxBuf)
|
||||
tryAddFlag("USART_TX_BUF_SIZE", txBuf)
|
||||
# Provide serial buffer sizes to the stm32duino platform
|
||||
tryAddFlag("SERIAL_RX_BUFFER_SIZE", rxBuf)
|
||||
tryAddFlag("SERIAL_TX_BUFFER_SIZE", txBuf)
|
||||
tryAddFlag("USART_RX_BUF_SIZE", rxBuf)
|
||||
tryAddFlag("USART_TX_BUF_SIZE", txBuf)
|
||||
|
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2019, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
*******************************************************************************
|
||||
* Automatically generated from STM32F401R(B-C)Tx.xml
|
||||
*/
|
||||
#include "Arduino.h"
|
||||
#include "PeripheralPins.h"
|
||||
|
||||
/* =====
|
||||
* Note: Commented lines are alternative possibilities which are not used per default.
|
||||
* If you change them, you will have to know what you do
|
||||
* =====
|
||||
*/
|
||||
|
||||
//*** ADC ***
|
||||
|
||||
#ifdef HAL_ADC_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_ADC[] = {
|
||||
{PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0
|
||||
{PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1
|
||||
{PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2
|
||||
{PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3
|
||||
{PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4
|
||||
{PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5
|
||||
{PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6
|
||||
{PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7
|
||||
{PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8
|
||||
{PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9
|
||||
{PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10
|
||||
{PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11
|
||||
{PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12
|
||||
{PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13
|
||||
{PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14
|
||||
{PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** No DAC ***
|
||||
|
||||
//*** I2C ***
|
||||
|
||||
#ifdef HAL_I2C_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_I2C_SDA[] = {
|
||||
{PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C2)},
|
||||
{PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)},
|
||||
{PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
{PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
{PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_I2C_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_I2C_SCL[] = {
|
||||
{PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
|
||||
{PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
{PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
{PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** PWM ***
|
||||
|
||||
#ifdef HAL_TIM_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_PWM[] = {
|
||||
{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
|
||||
{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1
|
||||
{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2
|
||||
{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2
|
||||
{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3
|
||||
{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3
|
||||
{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1
|
||||
{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4
|
||||
{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4
|
||||
{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2
|
||||
{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
|
||||
{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
|
||||
{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N
|
||||
{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
|
||||
{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1
|
||||
{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2
|
||||
{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3
|
||||
{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4
|
||||
{PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
|
||||
{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
|
||||
{PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3
|
||||
{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
|
||||
{PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4
|
||||
{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2
|
||||
{PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
|
||||
{PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
|
||||
{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1
|
||||
{PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2
|
||||
{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3
|
||||
{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1
|
||||
{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4
|
||||
{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1
|
||||
{PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3
|
||||
{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N
|
||||
{PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
|
||||
{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
|
||||
{PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
|
||||
{PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
|
||||
{PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3
|
||||
{PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** SERIAL ***
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_UART_TX[] = {
|
||||
{PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PA_11, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
|
||||
{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_UART_RX[] = {
|
||||
{PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PA_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
|
||||
{PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_UART_RTS[] = {
|
||||
{PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_UART_CTS[] = {
|
||||
{PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** SPI ***
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_SPI_MOSI[] = {
|
||||
{PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_SPI_MISO[] = {
|
||||
{PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_SPI_SCLK[] = {
|
||||
{PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_SPI_SSEL[] = {
|
||||
{PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** No CAN ***
|
||||
|
||||
//*** No ETHERNET ***
|
||||
|
||||
//*** No QUADSPI ***
|
||||
|
||||
//*** USB ***
|
||||
|
||||
#ifdef HAL_PCD_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_USB_OTG_FS[] = {
|
||||
{PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF
|
||||
{PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS
|
||||
{PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID
|
||||
{PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM
|
||||
{PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** No USB_OTG_HS ***
|
||||
|
||||
//*** SD ***
|
||||
|
||||
#ifdef HAL_SD_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_SD[] = {
|
||||
{PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4
|
||||
{PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5
|
||||
{PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6
|
||||
{PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7
|
||||
{PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0
|
||||
{PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1
|
||||
{PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2
|
||||
{PC_11, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D3
|
||||
{PC_12, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK
|
||||
{PD_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CMD
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
@@ -0,0 +1,33 @@
|
||||
/* SYS_WKUP */
|
||||
#ifdef PWR_WAKEUP_PIN1
|
||||
SYS_WKUP1 = PA_0,
|
||||
#endif
|
||||
#ifdef PWR_WAKEUP_PIN2
|
||||
SYS_WKUP2 = NC,
|
||||
#endif
|
||||
#ifdef PWR_WAKEUP_PIN3
|
||||
SYS_WKUP3 = NC,
|
||||
#endif
|
||||
#ifdef PWR_WAKEUP_PIN4
|
||||
SYS_WKUP4 = NC,
|
||||
#endif
|
||||
#ifdef PWR_WAKEUP_PIN5
|
||||
SYS_WKUP5 = NC,
|
||||
#endif
|
||||
#ifdef PWR_WAKEUP_PIN6
|
||||
SYS_WKUP6 = NC,
|
||||
#endif
|
||||
#ifdef PWR_WAKEUP_PIN7
|
||||
SYS_WKUP7 = NC,
|
||||
#endif
|
||||
#ifdef PWR_WAKEUP_PIN8
|
||||
SYS_WKUP8 = NC,
|
||||
#endif
|
||||
/* USB */
|
||||
#ifdef USBCON
|
||||
USB_OTG_FS_SOF = PA_8,
|
||||
USB_OTG_FS_VBUS = PA_9,
|
||||
USB_OTG_FS_ID = PA_10,
|
||||
USB_OTG_FS_DM = PA_11,
|
||||
USB_OTG_FS_DP = PA_12,
|
||||
#endif
|
@@ -0,0 +1,496 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f4xx_hal_conf.h
|
||||
* @brief HAL configuration file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F4xx_HAL_CONF_CUSTOM
|
||||
#define __STM32F4xx_HAL_CONF_CUSTOM
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* ########################## Module Selection ############################## */
|
||||
/**
|
||||
* @brief This is the list of modules to be used in the HAL driver
|
||||
*/
|
||||
#define HAL_MODULE_ENABLED
|
||||
#define HAL_ADC_MODULE_ENABLED
|
||||
/* #define HAL_CAN_MODULE_ENABLED */
|
||||
/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
|
||||
/* #define HAL_CRC_MODULE_ENABLED */
|
||||
/* #define HAL_CEC_MODULE_ENABLED */
|
||||
/* #define HAL_CRYP_MODULE_ENABLED */
|
||||
//#define HAL_DAC_MODULE_ENABLED
|
||||
/* #define HAL_DCMI_MODULE_ENABLED */
|
||||
#define HAL_DMA_MODULE_ENABLED
|
||||
/* #define HAL_DMA2D_MODULE_ENABLED */
|
||||
/* #define HAL_ETH_MODULE_ENABLED */
|
||||
#define HAL_FLASH_MODULE_ENABLED
|
||||
/* #define HAL_NAND_MODULE_ENABLED */
|
||||
/* #define HAL_NOR_MODULE_ENABLED */
|
||||
/* #define HAL_PCCARD_MODULE_ENABLED */
|
||||
/* #define HAL_SRAM_MODULE_ENABLED */
|
||||
/* #define HAL_SDRAM_MODULE_ENABLED */
|
||||
/* #define HAL_HASH_MODULE_ENABLED */
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
#define HAL_EXTI_MODULE_ENABLED
|
||||
#define HAL_I2C_MODULE_ENABLED
|
||||
/* #define HAL_SMBUS_MODULE_ENABLED */
|
||||
/* #define HAL_I2S_MODULE_ENABLED */
|
||||
/* #define HAL_IWDG_MODULE_ENABLED */
|
||||
/* #define HAL_LTDC_MODULE_ENABLED */
|
||||
/* #define HAL_DSI_MODULE_ENABLED */
|
||||
#define HAL_PWR_MODULE_ENABLED
|
||||
/* #define HAL_QSPI_MODULE_ENABLED */
|
||||
#define HAL_RCC_MODULE_ENABLED
|
||||
/* #define HAL_RNG_MODULE_ENABLED */
|
||||
/* #define HAL_RTC_MODULE_ENABLED */
|
||||
/* #define HAL_SAI_MODULE_ENABLED */
|
||||
/* #define HAL_SD_MODULE_ENABLED */
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
#define HAL_TIM_MODULE_ENABLED
|
||||
/* #define HAL_UART_MODULE_ENABLED */
|
||||
/* #define HAL_USART_MODULE_ENABLED */
|
||||
/* #define HAL_IRDA_MODULE_ENABLED */
|
||||
/* #define HAL_SMARTCARD_MODULE_ENABLED */
|
||||
/* #define HAL_WWDG_MODULE_ENABLED */
|
||||
#define HAL_CORTEX_MODULE_ENABLED
|
||||
#ifndef HAL_PCD_MODULE_ENABLED
|
||||
#define HAL_PCD_MODULE_ENABLED //Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE)
|
||||
#endif
|
||||
/* #define HAL_HCD_MODULE_ENABLED */
|
||||
/* #define HAL_FMPI2C_MODULE_ENABLED */
|
||||
/* #define HAL_SPDIFRX_MODULE_ENABLED */
|
||||
/* #define HAL_DFSDM_MODULE_ENABLED */
|
||||
/* #define HAL_LPTIM_MODULE_ENABLED */
|
||||
/* #define HAL_MMC_MODULE_ENABLED */
|
||||
|
||||
/* ########################## HSE/HSI Values adaptation ##################### */
|
||||
/**
|
||||
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
|
||||
* This value is used by the RCC HAL module to compute the system frequency
|
||||
* (when HSE is used as system clock source, directly or through the PLL).
|
||||
*/
|
||||
#ifndef HSE_VALUE
|
||||
#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
|
||||
#endif /* HSE_VALUE */
|
||||
|
||||
#ifndef HSE_STARTUP_TIMEOUT
|
||||
#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
|
||||
#endif /* HSE_STARTUP_TIMEOUT */
|
||||
|
||||
/**
|
||||
* @brief Internal High Speed oscillator (HSI) value.
|
||||
* This value is used by the RCC HAL module to compute the system frequency
|
||||
* (when HSI is used as system clock source, directly or through the PLL).
|
||||
*/
|
||||
#ifndef HSI_VALUE
|
||||
#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */
|
||||
#endif /* HSI_VALUE */
|
||||
|
||||
/**
|
||||
* @brief Internal Low Speed oscillator (LSI) value.
|
||||
*/
|
||||
#ifndef LSI_VALUE
|
||||
#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */
|
||||
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
|
||||
The real value may vary depending on the variations
|
||||
in voltage and temperature. */
|
||||
/**
|
||||
* @brief External Low Speed oscillator (LSE) value.
|
||||
*/
|
||||
#ifndef LSE_VALUE
|
||||
#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */
|
||||
#endif /* LSE_VALUE */
|
||||
|
||||
#ifndef LSE_STARTUP_TIMEOUT
|
||||
#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
|
||||
#endif /* LSE_STARTUP_TIMEOUT */
|
||||
|
||||
/**
|
||||
* @brief External clock source for I2S peripheral
|
||||
* This value is used by the I2S HAL module to compute the I2S clock source
|
||||
* frequency, this source is inserted directly through I2S_CKIN pad.
|
||||
*/
|
||||
#ifndef EXTERNAL_CLOCK_VALUE
|
||||
#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/
|
||||
#endif /* EXTERNAL_CLOCK_VALUE */
|
||||
|
||||
/* Tip: To avoid modifying this file each time you need to use different HSE,
|
||||
=== you can define the HSE value in your toolchain compiler preprocessor. */
|
||||
|
||||
/* ########################### System Configuration ######################### */
|
||||
/**
|
||||
* @brief This is the HAL system configuration section
|
||||
*/
|
||||
#if !defined (VDD_VALUE)
|
||||
#define VDD_VALUE 3300U /*!< Value of VDD in mv */
|
||||
#endif
|
||||
#if !defined (TICK_INT_PRIORITY)
|
||||
#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */
|
||||
#endif
|
||||
#if !defined (USE_RTOS)
|
||||
#define USE_RTOS 0U
|
||||
#endif
|
||||
#if !defined (PREFETCH_ENABLE)
|
||||
#define PREFETCH_ENABLE 1U
|
||||
#endif
|
||||
#if !defined (INSTRUCTION_CACHE_ENABLE)
|
||||
#define INSTRUCTION_CACHE_ENABLE 1U
|
||||
#endif
|
||||
#if !defined (DATA_CACHE_ENABLE)
|
||||
#define DATA_CACHE_ENABLE 1U
|
||||
#endif
|
||||
|
||||
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
|
||||
#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
|
||||
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
|
||||
#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
|
||||
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
|
||||
#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
|
||||
#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
|
||||
#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
|
||||
#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
|
||||
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
|
||||
#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
|
||||
#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
|
||||
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
|
||||
#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */
|
||||
#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
|
||||
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
|
||||
#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
|
||||
#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
|
||||
#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
|
||||
#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
|
||||
#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
|
||||
#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
|
||||
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
|
||||
#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
|
||||
#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
|
||||
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
|
||||
#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
|
||||
#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
|
||||
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
|
||||
#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
|
||||
#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
|
||||
#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
|
||||
#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
|
||||
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
|
||||
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
|
||||
#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
|
||||
#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
|
||||
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
|
||||
|
||||
/* ########################## Assert Selection ############################## */
|
||||
/**
|
||||
* @brief Uncomment the line below to expanse the "assert_param" macro in the
|
||||
* HAL drivers code
|
||||
*/
|
||||
/* #define USE_FULL_ASSERT 1U */
|
||||
|
||||
/* ################## Ethernet peripheral configuration ##################### */
|
||||
|
||||
/* Section 1 : Ethernet peripheral configuration */
|
||||
|
||||
/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
|
||||
#define MAC_ADDR0 2U
|
||||
#define MAC_ADDR1 0U
|
||||
#define MAC_ADDR2 0U
|
||||
#define MAC_ADDR3 0U
|
||||
#define MAC_ADDR4 0U
|
||||
#define MAC_ADDR5 0U
|
||||
|
||||
/* Definition of the Ethernet driver buffers size and count */
|
||||
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
|
||||
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
|
||||
#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
|
||||
#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
|
||||
|
||||
/* Section 2: PHY configuration section */
|
||||
|
||||
/* DP83848_PHY_ADDRESS Address*/
|
||||
#define DP83848_PHY_ADDRESS 0x01U
|
||||
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
|
||||
#define PHY_RESET_DELAY 0x000000FFU
|
||||
/* PHY Configuration delay */
|
||||
#define PHY_CONFIG_DELAY 0x00000FFFU
|
||||
|
||||
#define PHY_READ_TO 0x0000FFFFU
|
||||
#define PHY_WRITE_TO 0x0000FFFFU
|
||||
|
||||
/* Section 3: Common PHY Registers */
|
||||
|
||||
#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */
|
||||
#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */
|
||||
|
||||
#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
|
||||
#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
|
||||
#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
|
||||
#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
|
||||
#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
|
||||
#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
|
||||
#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
|
||||
#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
|
||||
#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
|
||||
#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
|
||||
|
||||
#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
|
||||
#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
|
||||
#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
|
||||
|
||||
/* Section 4: Extended PHY Registers */
|
||||
#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
|
||||
|
||||
#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
|
||||
#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
|
||||
|
||||
/* ################## SPI peripheral configuration ########################## */
|
||||
|
||||
/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
|
||||
* Activated: CRC code is present inside driver
|
||||
* Deactivated: CRC code cleaned from driver
|
||||
*/
|
||||
#ifndef USE_SPI_CRC
|
||||
#define USE_SPI_CRC 0U
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Include module's header file
|
||||
*/
|
||||
|
||||
#ifdef HAL_RCC_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_rcc.h"
|
||||
#endif /* HAL_RCC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_GPIO_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_gpio.h"
|
||||
#endif /* HAL_GPIO_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_EXTI_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_exti.h"
|
||||
#endif /* HAL_EXTI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DMA_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_dma.h"
|
||||
#endif /* HAL_DMA_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CORTEX_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_cortex.h"
|
||||
#endif /* HAL_CORTEX_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_ADC_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_adc.h"
|
||||
#endif /* HAL_ADC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CAN_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_can.h"
|
||||
#endif /* HAL_CAN_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_can_legacy.h"
|
||||
#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CRC_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_crc.h"
|
||||
#endif /* HAL_CRC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CRYP_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_cryp.h"
|
||||
#endif /* HAL_CRYP_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DMA2D_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_dma2d.h"
|
||||
#endif /* HAL_DMA2D_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DAC_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_dac.h"
|
||||
#endif /* HAL_DAC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DCMI_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_dcmi.h"
|
||||
#endif /* HAL_DCMI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_ETH_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_eth.h"
|
||||
#endif /* HAL_ETH_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_FLASH_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_flash.h"
|
||||
#endif /* HAL_FLASH_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SRAM_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_sram.h"
|
||||
#endif /* HAL_SRAM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_NOR_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_nor.h"
|
||||
#endif /* HAL_NOR_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_NAND_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_nand.h"
|
||||
#endif /* HAL_NAND_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PCCARD_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_pccard.h"
|
||||
#endif /* HAL_PCCARD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SDRAM_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_sdram.h"
|
||||
#endif /* HAL_SDRAM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_HASH_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_hash.h"
|
||||
#endif /* HAL_HASH_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_I2C_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_i2c.h"
|
||||
#endif /* HAL_I2C_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SMBUS_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_smbus.h"
|
||||
#endif /* HAL_SMBUS_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_I2S_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_i2s.h"
|
||||
#endif /* HAL_I2S_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_IWDG_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_iwdg.h"
|
||||
#endif /* HAL_IWDG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_LTDC_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_ltdc.h"
|
||||
#endif /* HAL_LTDC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PWR_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_pwr.h"
|
||||
#endif /* HAL_PWR_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_RNG_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_rng.h"
|
||||
#endif /* HAL_RNG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_RTC_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_rtc.h"
|
||||
#endif /* HAL_RTC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SAI_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_sai.h"
|
||||
#endif /* HAL_SAI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SD_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_sd.h"
|
||||
#endif /* HAL_SD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_spi.h"
|
||||
#endif /* HAL_SPI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_TIM_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_tim.h"
|
||||
#endif /* HAL_TIM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_uart.h"
|
||||
#endif /* HAL_UART_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_USART_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_usart.h"
|
||||
#endif /* HAL_USART_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_IRDA_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_irda.h"
|
||||
#endif /* HAL_IRDA_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SMARTCARD_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_smartcard.h"
|
||||
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_WWDG_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_wwdg.h"
|
||||
#endif /* HAL_WWDG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PCD_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_pcd.h"
|
||||
#endif /* HAL_PCD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_HCD_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_hcd.h"
|
||||
#endif /* HAL_HCD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DSI_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_dsi.h"
|
||||
#endif /* HAL_DSI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_QSPI_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_qspi.h"
|
||||
#endif /* HAL_QSPI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CEC_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_cec.h"
|
||||
#endif /* HAL_CEC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_FMPI2C_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_fmpi2c.h"
|
||||
#endif /* HAL_FMPI2C_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SPDIFRX_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_spdifrx.h"
|
||||
#endif /* HAL_SPDIFRX_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DFSDM_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_dfsdm.h"
|
||||
#endif /* HAL_DFSDM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_LPTIM_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_lptim.h"
|
||||
#endif /* HAL_LPTIM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_MMC_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_mmc.h"
|
||||
#endif /* HAL_MMC_MODULE_ENABLED */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifdef USE_FULL_ASSERT
|
||||
/**
|
||||
* @brief The assert_param macro is used for function's parameters check.
|
||||
* @param expr If expr is false, it calls assert_failed function
|
||||
* which reports the name of the source file and the source
|
||||
* line number of the call that failed.
|
||||
* If expr is true, it returns no value.
|
||||
* @retval None
|
||||
*/
|
||||
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void assert_failed(uint8_t *file, uint32_t line);
|
||||
#else
|
||||
#define assert_param(expr) ((void)0U)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32F4xx_HAL_CONF_CUSTOM_H */
|
||||
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@@ -51,7 +51,7 @@
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20018000; /* end of RAM */
|
||||
_estack = 0x20010000; /* end of RAM */
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
_Min_Heap_Size = 0x200; /* required amount of heap */
|
||||
_Min_Stack_Size = 0x400; /* required amount of stack */
|
||||
@@ -59,8 +59,10 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K
|
||||
BOOT (rx) : ORIGIN = 0x08000000, LENGTH = 16K
|
||||
EMULATED_EEPROM (rx) : ORIGIN = 0x08004000, LENGTH = 16K
|
||||
FLASH (rx) : ORIGIN = 0x08008000, LENGTH = 256K - 16K * 2
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
@@ -72,7 +74,14 @@ SECTIONS
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
} >BOOT
|
||||
|
||||
.boot :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text.Reset_Handler)
|
||||
. = ALIGN(4);
|
||||
} >BOOT
|
||||
|
||||
/* The program code and other data goes into FLASH */
|
||||
.text :
|
||||
@@ -148,7 +157,7 @@ SECTIONS
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss section */
|
||||
/* This is used by the startup in order to initialize the .bss secion */
|
||||
_sbss = .; /* define a global symbol at bss start */
|
||||
__bss_start__ = _sbss;
|
||||
*(.bss)
|
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file startup_stm32f401xc.s
|
||||
* @author MCD Application Team
|
||||
* @version V2.4.2
|
||||
* @date 13-November-2015
|
||||
* @brief STM32F401xCxx Devices vector table for GCC based toolchains.
|
||||
* This module performs:
|
||||
* - Set the initial SP
|
||||
* - Set the initial PC == Reset_Handler,
|
||||
* - Set the vector table entries with the exceptions ISR address
|
||||
* - Branches to main in the C library (which eventually
|
||||
* calls main()).
|
||||
* After Reset the Cortex-M4 processor is in Thread mode,
|
||||
* priority is Privileged, and the Stack is set to Main.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2015 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
.syntax unified
|
||||
.cpu cortex-m4
|
||||
.fpu softvfp
|
||||
.thumb
|
||||
|
||||
/**
|
||||
* @brief This is the code that gets called when the processor first
|
||||
* starts execution following a reset event. Only the absolutely
|
||||
* necessary set is performed, after which the application
|
||||
* supplied main() routine is called.
|
||||
* @param None
|
||||
* @retval : None
|
||||
*/
|
||||
|
||||
.section .text.Reset_Handler
|
||||
.globl Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
/* Check for magic code at the end of SRAM to detemine whether to jump to DFU */
|
||||
ldr r0, =0x2000FFF0 // End of SRAM for your CPU
|
||||
ldr r1, =0xDEADBEEF
|
||||
ldr r2, [r0, #0]
|
||||
str r0, [r0, #0] // Invalidate
|
||||
cmp r2, r1
|
||||
beq Jump_To_DFU
|
||||
|
||||
/* Original Reset_Handler code */
|
||||
ldr sp, =_estack /* set stack pointer */
|
||||
|
||||
/* Copy the data segment initializers from flash to SRAM */
|
||||
movs r1, #0
|
||||
b LoopCopyDataInit
|
||||
|
||||
CopyDataInit:
|
||||
ldr r3, =_sidata
|
||||
ldr r3, [r3, r1]
|
||||
str r3, [r0, r1]
|
||||
adds r1, r1, #4
|
||||
|
||||
LoopCopyDataInit:
|
||||
ldr r0, =_sdata
|
||||
ldr r3, =_edata
|
||||
adds r2, r0, r1
|
||||
cmp r2, r3
|
||||
bcc CopyDataInit
|
||||
ldr r2, =_sbss
|
||||
b LoopFillZerobss
|
||||
/* Zero fill the bss segment. */
|
||||
FillZerobss:
|
||||
movs r3, #0
|
||||
str r3, [r2], #4
|
||||
|
||||
LoopFillZerobss:
|
||||
ldr r3, = _ebss
|
||||
cmp r2, r3
|
||||
bcc FillZerobss
|
||||
|
||||
/* Call the clock system intitialization function.*/
|
||||
bl SystemInit
|
||||
/* Call static constructors */
|
||||
bl __libc_init_array
|
||||
/* Call the application's entry point.*/
|
||||
bl main
|
||||
bx lr
|
||||
|
||||
Jump_To_DFU:
|
||||
ldr r0, =0x40023844 // RCC_APB2ENR
|
||||
ldr r1, =0x00004000 // ENABLE SYSCFG CLOCK
|
||||
str r1, [r0, #0]
|
||||
ldr r0, =0x40013800 // SYSCFG_MEMRMP
|
||||
ldr r1, =0x00000001 // MAP ROM AT ZERO
|
||||
str r1, [r0, #0]
|
||||
ldr r0, =0x1FFF0000 // ROM BASE
|
||||
ldr sp, [r0, #0] // SP @ +0
|
||||
ldr r0, [r0, #4] // PC @ +4
|
||||
bx r0
|
||||
.size Reset_Handler, .-Reset_Handler
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
Copyright (c) 2011 Arduino. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "pins_arduino.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Pin number
|
||||
const PinName digitalPin[] = {
|
||||
PA_0, //D0
|
||||
PA_1, //D1
|
||||
PA_2, //D2
|
||||
PA_3, //D3
|
||||
PA_4, //D4
|
||||
PA_5, //D5
|
||||
PA_6, //D6
|
||||
PA_7, //D7
|
||||
PA_8, //D8
|
||||
PA_9, //D9
|
||||
PA_10, //D10
|
||||
PA_11, //D11
|
||||
PA_12, //D12
|
||||
PA_13, //D13
|
||||
PA_14, //D14
|
||||
PA_15, //D15
|
||||
PB_0, //D16
|
||||
PB_1, //D17
|
||||
PB_2, //D18
|
||||
PB_3, //D19
|
||||
PB_4, //D20
|
||||
PB_5, //D21
|
||||
PB_6, //D22
|
||||
PB_7, //D23
|
||||
PB_8, //D24
|
||||
PB_9, //D25
|
||||
PB_10, //D26
|
||||
PB_12, //D27
|
||||
PB_13, //D28
|
||||
PB_14, //D29
|
||||
PB_15, //D30
|
||||
PC_0, //D31
|
||||
PC_1, //D32
|
||||
PC_2, //D33
|
||||
PC_3, //D34
|
||||
PC_4, //D35
|
||||
PC_5, //D36
|
||||
PC_6, //D37
|
||||
PC_7, //D38
|
||||
PC_8, //D39
|
||||
PC_9, //D40
|
||||
PC_10, //D41
|
||||
PC_11, //D42
|
||||
PC_12, //D43
|
||||
PC_13, //D44
|
||||
PC_14, //D45
|
||||
PC_15, //D46
|
||||
PD_2, //D47
|
||||
PH_0, //D48
|
||||
PH_1, //D49
|
||||
|
||||
//Duplicated ADC Pins
|
||||
PA_0, //D50/A0
|
||||
PA_1, //D51/A1
|
||||
PA_2, //D52/A2
|
||||
PA_3, //D53/A3
|
||||
PA_4, //D54/A4
|
||||
PA_5, //D55/A5
|
||||
PA_6, //D56/A6
|
||||
PA_7, //D57/A7
|
||||
PB_0, //D58/A8
|
||||
PB_1, //D59/A9
|
||||
PC_0, //D60/A10
|
||||
PC_1, //D61/A11
|
||||
PC_2, //D62/A12
|
||||
PC_3, //D63/A13
|
||||
PC_4, //D64/A14
|
||||
PC_5 //D65/A15
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/**
|
||||
* @brief System Clock Configuration
|
||||
* The system Clock is configured as follow :
|
||||
* System Clock source = PLL (HSE)
|
||||
* SYSCLK(Hz) = 84000000
|
||||
* HCLK(Hz) = 84000000
|
||||
* AHB Prescaler = 1
|
||||
* APB1 Prescaler = 2
|
||||
* APB2 Prescaler = 1
|
||||
* HSE Frequency(Hz) = 8000000
|
||||
* PLL_M = 8
|
||||
* PLL_N = 336
|
||||
* PLL_P = 4
|
||||
* PLL_Q = 7
|
||||
* VDD(V) = 3.3
|
||||
* Main regulator output voltage = Scale2 mode
|
||||
* Flash Latency(WS) = 2
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
WEAK void SystemClock_Config(void)
|
||||
{
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
|
||||
/* Enable Power Control clock */
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
|
||||
/* The voltage scaling allows optimizing the power consumption when the device is
|
||||
clocked below the maximum system frequency, to update the voltage scaling value
|
||||
regarding system frequency refer to product datasheet. */
|
||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
|
||||
|
||||
/* Enable HSI Oscillator and activate PLL with HSI as source */
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLM = 8;
|
||||
RCC_OscInitStruct.PLL.PLLN = 336;
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
|
||||
RCC_OscInitStruct.PLL.PLLQ = 7;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
||||
/* Initialization Error */
|
||||
while (1);
|
||||
}
|
||||
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
|
||||
clocks dividers */
|
||||
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
|
||||
/* Initialization Error */
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
void flashFirmware(const int16_t) {
|
||||
*((unsigned long *)0x2000FFF0) = 0xDEADBEEF; // End of RAM
|
||||
NVIC_SystemReset();
|
||||
}
|
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
Copyright (c) 2011 Arduino. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VARIANT_ARDUINO_STM32_
|
||||
#define _VARIANT_ARDUINO_STM32_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Pins
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#define PA0 0 //D0
|
||||
#define PA1 1 //D1
|
||||
#define PA2 2 //D2
|
||||
#define PA3 3 //D3
|
||||
#define PA4 4 //D4
|
||||
#define PA5 5 //D5
|
||||
#define PA6 6 //D6
|
||||
#define PA7 7 //D7
|
||||
#define PA8 8 //D8
|
||||
#define PA9 9 //D9
|
||||
#define PA10 10 //D10
|
||||
#define PA11 11 //D11
|
||||
#define PA12 12 //D12
|
||||
#define PA13 13 //D13
|
||||
#define PA14 14 //D14
|
||||
#define PA15 15 //D15
|
||||
#define PB0 16 //D16
|
||||
#define PB1 17 //D17
|
||||
#define PB2 18 //D18
|
||||
#define PB3 19 //D19
|
||||
#define PB4 20 //D20
|
||||
#define PB5 21 //D21
|
||||
#define PB6 22 //D22
|
||||
#define PB7 23 //D23
|
||||
#define PB8 24 //D24
|
||||
#define PB9 25 //D25
|
||||
#define PB10 26 //D26
|
||||
#define PB12 27 //D27
|
||||
#define PB13 28 //D28
|
||||
#define PB14 29 //D29
|
||||
#define PB15 30 //D30
|
||||
#define PC0 31 //D31
|
||||
#define PC1 32 //D32
|
||||
#define PC2 33 //D33
|
||||
#define PC3 34 //D34
|
||||
#define PC4 35 //D35
|
||||
#define PC5 36 //D36
|
||||
#define PC6 37 //D37
|
||||
#define PC7 38 //D38
|
||||
#define PC8 39 //D39
|
||||
#define PC9 40 //D40
|
||||
#define PC10 41 //D41
|
||||
#define PC11 42 //D42
|
||||
#define PC12 43 //D43
|
||||
#define PC13 44 //D44
|
||||
#define PC14 45 //D45
|
||||
#define PC15 46 //D46
|
||||
#define PD2 47 //D47
|
||||
#define PH0 48 //D48
|
||||
#define PH1 49 //D49
|
||||
|
||||
// This must be a literal
|
||||
#define NUM_DIGITAL_PINS 66
|
||||
// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS
|
||||
#define NUM_ANALOG_INPUTS 16
|
||||
#define NUM_ANALOG_FIRST 50
|
||||
|
||||
/*
|
||||
// PWM resolution
|
||||
#define PWM_RESOLUTION 8
|
||||
#define PWM_FREQUENCY 20000 // >= 20 Khz => inaudible noise for fans
|
||||
#define PWM_MAX_DUTY_CYCLE 255
|
||||
*/
|
||||
|
||||
// SPI Definitions
|
||||
#define PIN_SPI_MOSI PC12
|
||||
#define PIN_SPI_MISO PC11
|
||||
#define PIN_SPI_SCK PC10
|
||||
#define PIN_SPI_SS PA15
|
||||
|
||||
// Timer Definitions
|
||||
// TIM1 - Hardware PWM (HB)
|
||||
// TIM2 - TIMER_SERVO
|
||||
// TIM3 - Hardware PWM (FAN0/1/2, HE0)
|
||||
// TIM4 - Hardware PWM (LED_R/G/B)
|
||||
// TIM5 - TIMER_TONE
|
||||
// TIM9 - STEP_TIMER
|
||||
// TIM10 - TEMP_TIMER
|
||||
// TIM11 -
|
||||
#define TIMER_SERVO TIM2 // TIMER_SERVO must be defined in this file
|
||||
#define TIMER_TONE TIM5 // TIMER_TONE must be defined in this file
|
||||
|
||||
// UART Definitions
|
||||
#define SERIAL_UART_INSTANCE 1
|
||||
|
||||
// Default pin used for 'Serial' instance (ex: ST-Link)
|
||||
// Mandatory for Firmata
|
||||
#define PIN_SERIAL_RX PA10
|
||||
#define PIN_SERIAL_TX PA9
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
/*----------------------------------------------------------------------------
|
||||
* Arduino objects - C++ only
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
// These serial port names are intended to allow libraries and architecture-neutral
|
||||
// sketches to automatically default to the correct port name for a particular type
|
||||
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
|
||||
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
|
||||
//
|
||||
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
|
||||
//
|
||||
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
|
||||
//
|
||||
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
|
||||
//
|
||||
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
|
||||
//
|
||||
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
|
||||
// pins are NOT connected to anything by default.
|
||||
#define SERIAL_PORT_MONITOR Serial
|
||||
#define SERIAL_PORT_HARDWARE Serial
|
||||
#endif
|
||||
|
||||
#endif /* _VARIANT_ARDUINO_STM32_ */
|
@@ -245,9 +245,9 @@ extern "C" {
|
||||
|
||||
// Timer Definitions
|
||||
// Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c
|
||||
#define TIMER_TONE TIM7
|
||||
#define TIMER_SERVO TIM5
|
||||
#define TIMER_SERIAL TIM2
|
||||
#define TIMER_TONE TIM7 // TIMER_TONE must be defined in this file
|
||||
#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file
|
||||
#define TIMER_SERIAL TIM2 // TIMER_SERIAL must be defined in this file
|
||||
|
||||
// UART Definitions
|
||||
// Define here Serial instance number to map on Serial generic name
|
||||
|
@@ -245,9 +245,9 @@ extern "C" {
|
||||
|
||||
// Timer Definitions
|
||||
// Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c
|
||||
#define TIMER_TONE TIM7
|
||||
#define TIMER_SERVO TIM5
|
||||
#define TIMER_SERIAL TIM8
|
||||
#define TIMER_TONE TIM7 // TIMER_TONE must be defined in this file
|
||||
#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file
|
||||
#define TIMER_SERIAL TIM8 // TIMER_SERIAL must be defined in this file
|
||||
|
||||
// UART Definitions
|
||||
// Define here Serial instance number to map on Serial generic name
|
||||
|
@@ -255,9 +255,9 @@ extern "C" {
|
||||
|
||||
// Timer Definitions
|
||||
// Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c
|
||||
#define TIMER_TONE TIM10
|
||||
#define TIMER_SERVO TIM5
|
||||
#define TIMER_SERIAL TIM7
|
||||
#define TIMER_TONE TIM10 // TIMER_TONE must be defined in this file
|
||||
#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file
|
||||
#define TIMER_SERIAL TIM7 // TIMER_SERIAL must be defined in this file
|
||||
|
||||
// UART Definitions
|
||||
//#define ENABLE_HWSERIAL1 done automatically by the #define SERIAL_UART_INSTANCE below
|
||||
|
@@ -0,0 +1,433 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2016, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "Arduino.h"
|
||||
#include "PeripheralPins.h"
|
||||
|
||||
// =====
|
||||
// Note: Commented lines are alternative possibilities which are not used per default.
|
||||
// If you change them, you will have to know what you do
|
||||
// =====
|
||||
|
||||
|
||||
//*** ADC ***
|
||||
|
||||
#ifdef HAL_ADC_MODULE_ENABLED
|
||||
const PinMap PinMap_ADC[] = {
|
||||
{PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3
|
||||
{PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4
|
||||
{PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10
|
||||
{PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11
|
||||
{PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12
|
||||
{PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13
|
||||
{PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14
|
||||
{PF_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC3_IN9 TH_0
|
||||
{PF_4, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC3_IN14 TH_1
|
||||
{PF_5, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC3_IN15 TH_2
|
||||
{PF_6, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 TH_3
|
||||
{PF_7, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC3_IN5 EXP_13
|
||||
{PF_8, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC3_IN6 PT100
|
||||
{NC, NP, 0}
|
||||
|
||||
// {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0
|
||||
// {PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0
|
||||
// {PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0
|
||||
// {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1
|
||||
// {PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1
|
||||
// {PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1
|
||||
// {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2
|
||||
// {PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2
|
||||
// {PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2
|
||||
// {PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3
|
||||
// {PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3
|
||||
//{PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4
|
||||
// {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5
|
||||
// {PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5
|
||||
// {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6
|
||||
// {PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6
|
||||
// {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7
|
||||
// {PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7
|
||||
// {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8
|
||||
// {PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8
|
||||
// {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9
|
||||
// {PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9
|
||||
// {PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10
|
||||
// {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10
|
||||
// {PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11
|
||||
// {PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11
|
||||
// {PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12
|
||||
// {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12
|
||||
// {PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13
|
||||
// {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13
|
||||
// {PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14
|
||||
// {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15
|
||||
// {PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** DAC ***
|
||||
|
||||
#ifdef HAL_DAC_MODULE_ENABLED
|
||||
const PinMap PinMap_DAC[] = {
|
||||
// {PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1
|
||||
// {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 - LD2
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** I2C ***
|
||||
|
||||
#ifdef HAL_I2C_MODULE_ENABLED
|
||||
const PinMap PinMap_I2C_SDA[] = {
|
||||
// {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
|
||||
// {PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
|
||||
// {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
{PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
// {PC_7, FMPI2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)},
|
||||
// {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
|
||||
// {PC_12, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_I2C_MODULE_ENABLED
|
||||
const PinMap PinMap_I2C_SCL[] = {
|
||||
// {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
|
||||
// {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
{PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
// {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
|
||||
// {PC_6, FMPI2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** PWM ***
|
||||
|
||||
#ifdef HAL_TIM_MODULE_ENABLED
|
||||
const PinMap PinMap_PWM[] = {
|
||||
{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 BED
|
||||
{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 HEATER0
|
||||
{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 HEATER1
|
||||
{PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 HEATER2
|
||||
{PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 HEATER3
|
||||
{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 FAN0
|
||||
{PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 FAN1
|
||||
{PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 FAN2
|
||||
{PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 FAN3
|
||||
{PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 FAN4
|
||||
{PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 FAN5
|
||||
|
||||
/**
|
||||
* Unused by specifications on Octopus.
|
||||
* Uncomment the corresponding line if you want to have HardwarePWM on some pins.
|
||||
* WARNING: check timers' usage first to avoid conflicts.
|
||||
* If you don't know what you're doing leave things as they are or you WILL break something (including hardware)
|
||||
* If you alter this section DO NOT report bugs to Marlin team since they are most likely caused by you. Thank you.
|
||||
*/
|
||||
//{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
|
||||
//{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1
|
||||
//{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 BLTOUCH is a "servo"
|
||||
//{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 BLTOUCH is a "servo"
|
||||
//{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2
|
||||
//{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3
|
||||
//{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1
|
||||
//{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4
|
||||
//{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4
|
||||
//{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2
|
||||
//{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
|
||||
//{PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N
|
||||
//{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
|
||||
//{PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1
|
||||
//{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N
|
||||
//{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
|
||||
//{PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N
|
||||
//{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1
|
||||
//{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1
|
||||
//{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2
|
||||
//{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3
|
||||
//{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4
|
||||
//{PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
|
||||
//{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
|
||||
//{PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N
|
||||
//{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
|
||||
//{PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N
|
||||
//{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2
|
||||
//{PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
|
||||
//{PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
|
||||
//{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1
|
||||
//{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3
|
||||
//{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1
|
||||
//{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4
|
||||
//{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1
|
||||
//{PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3
|
||||
//{PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4
|
||||
//{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N
|
||||
//{PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
|
||||
//{PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N
|
||||
//{PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1
|
||||
//{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
|
||||
//{PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N
|
||||
//{PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2
|
||||
//{PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1
|
||||
//{PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
|
||||
//{PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2
|
||||
//{PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3
|
||||
//{PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4
|
||||
//{PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2
|
||||
//{PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4
|
||||
//{PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N
|
||||
//{PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1
|
||||
//{PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
|
||||
//{PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2
|
||||
//{PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
|
||||
//{PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3
|
||||
//{PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4
|
||||
//144 pins mcu, 114 gpio
|
||||
//{PF_6, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1
|
||||
//{PF_7, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1
|
||||
//{PF_8, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1
|
||||
//{PF_9, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1
|
||||
|
||||
//176 pins mcu, 140 gpio
|
||||
//{PH_10, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1
|
||||
//{PH_6, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1
|
||||
//{PH_11, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2
|
||||
//{PI_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1
|
||||
//{PI_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2
|
||||
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** SERIAL ***
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
const PinMap PinMap_UART_TX[] = {
|
||||
// {PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
// {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
// {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
// {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
// {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
|
||||
// {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
//{PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
// {PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
const PinMap PinMap_UART_RX[] = {
|
||||
// {PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
// {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PD_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
// {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
// {PC_5, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
// {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
|
||||
// {PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
//{PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
// {PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
const PinMap PinMap_UART_RTS[] = {
|
||||
// {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
// {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
// {PA_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
// {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
// {PC_8, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
const PinMap PinMap_UART_CTS[] = {
|
||||
// {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
// {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
// {PB_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
|
||||
// {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
// {PC_9, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** SPI ***
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
const PinMap PinMap_SPI_MOSI[] = {
|
||||
{PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
// {PB_0, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)},
|
||||
// {PB_2, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)},
|
||||
// {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
// {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
// {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
// {PC_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)},
|
||||
// {PC_1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)},
|
||||
// {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
// {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
const PinMap PinMap_SPI_MISO[] = {
|
||||
{PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
// {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
// {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
// {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
// {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
// {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
const PinMap PinMap_SPI_SCLK[] = {
|
||||
{PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
// {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
// {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
// {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
// {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
// {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
// {PC_7, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
// {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
const PinMap PinMap_SPI_SSEL[] = {
|
||||
{PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
// {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
// {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
// {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
// {PB_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)},
|
||||
// {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
// {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** CAN ***
|
||||
|
||||
#ifdef HAL_CAN_MODULE_ENABLED
|
||||
const PinMap PinMap_CAN_RD[] = {
|
||||
// {PA_11, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
|
||||
// {PB_5, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
|
||||
// {PB_8, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
|
||||
// {PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef HAL_CAN_MODULE_ENABLED
|
||||
const PinMap PinMap_CAN_TD[] = {
|
||||
// {PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
|
||||
// {PB_6, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
|
||||
// {PB_9, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
|
||||
// {PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** ETHERNET ***
|
||||
|
||||
//*** No Ethernet ***
|
||||
|
||||
//*** QUADSPI ***
|
||||
|
||||
#ifdef HAL_QSPI_MODULE_ENABLED
|
||||
const PinMap PinMap_QUADSPI[] = {
|
||||
// {PA_1, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO3
|
||||
// {PB_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_CLK
|
||||
// {PB_6, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK1_NCS
|
||||
// {PC_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO0
|
||||
// {PC_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO1
|
||||
// {PC_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK2_NCS
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** USB ***
|
||||
|
||||
#ifdef HAL_PCD_MODULE_ENABLED
|
||||
const PinMap PinMap_USB_OTG_FS[] = {
|
||||
// {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF
|
||||
// {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)}, // USB_OTG_FS_VBUS
|
||||
// {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID
|
||||
{PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM
|
||||
{PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP
|
||||
{NC, NP, 0}
|
||||
};
|
||||
|
||||
const PinMap PinMap_USB_OTG_HS[] = {
|
||||
//{PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID
|
||||
//{PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS
|
||||
{PB_14, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM
|
||||
{PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP
|
||||
|
||||
/*#error "USB in HS mode isn't supported by the board"
|
||||
{PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D0
|
||||
{PB_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D1
|
||||
{PB_1, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D2
|
||||
{PB_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D7
|
||||
{PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D3
|
||||
{PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D5
|
||||
{PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D6
|
||||
{PC_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_STP
|
||||
{PC_2, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_DIR
|
||||
{PC_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_NXT
|
||||
*/
|
||||
{NC, NP, 0}
|
||||
};
|
||||
|
||||
|
||||
#ifdef HAL_SD_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_SD[] = {
|
||||
// {PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4
|
||||
// {PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5
|
||||
// {PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6
|
||||
// {PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7
|
||||
{PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0
|
||||
{PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1
|
||||
{PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2
|
||||
{PC_11, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D3
|
||||
{PC_12, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK
|
||||
{PD_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CMD
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
#endif
|
@@ -0,0 +1,30 @@
|
||||
/* SYS_WKUP */
|
||||
#ifdef PWR_WAKEUP_PIN1
|
||||
SYS_WKUP1 = PA_0, /* SYS_WKUP0 */
|
||||
#endif
|
||||
#ifdef PWR_WAKEUP_PIN2
|
||||
SYS_WKUP2 = NC,
|
||||
#endif
|
||||
#ifdef PWR_WAKEUP_PIN3
|
||||
SYS_WKUP3 = NC,
|
||||
#endif
|
||||
#ifdef PWR_WAKEUP_PIN4
|
||||
SYS_WKUP4 = NC,
|
||||
#endif
|
||||
#ifdef PWR_WAKEUP_PIN5
|
||||
SYS_WKUP5 = NC,
|
||||
#endif
|
||||
#ifdef PWR_WAKEUP_PIN6
|
||||
SYS_WKUP6 = NC,
|
||||
#endif
|
||||
#ifdef PWR_WAKEUP_PIN7
|
||||
SYS_WKUP7 = NC,
|
||||
#endif
|
||||
#ifdef PWR_WAKEUP_PIN8
|
||||
SYS_WKUP8 = NC,
|
||||
#endif
|
||||
/* USB */
|
||||
#ifdef USBCON
|
||||
USB_OTG_FS_DM = PA_11,
|
||||
USB_OTG_FS_DP = PA_12,
|
||||
#endif
|
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#define HAL_MODULE_ENABLED
|
||||
#define HAL_ADC_MODULE_ENABLED
|
||||
#define HAL_CRC_MODULE_ENABLED
|
||||
#define HAL_DMA_MODULE_ENABLED
|
||||
#define HAL_EXTI_MODULE_ENABLED // Needed for Endstop (and other external) Interrupts
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
#define HAL_I2C_MODULE_ENABLED
|
||||
#define HAL_PWR_MODULE_ENABLED
|
||||
#define HAL_RCC_MODULE_ENABLED
|
||||
//#define HAL_RTC_MODULE_ENABLED // Real Time Clock...do we use it?
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
#define HAL_TIM_MODULE_ENABLED
|
||||
#define HAL_USART_MODULE_ENABLED
|
||||
#define HAL_CORTEX_MODULE_ENABLED
|
||||
//#define HAL_UART_MODULE_ENABLED // by default
|
||||
//#define HAL_PCD_MODULE_ENABLED // Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE)
|
||||
#define HAL_SD_MODULE_ENABLED
|
||||
|
||||
//#undef HAL_SD_MODULE_ENABLED
|
||||
#undef HAL_DAC_MODULE_ENABLED
|
||||
#undef HAL_FLASH_MODULE_ENABLED
|
||||
#undef HAL_CAN_MODULE_ENABLED
|
||||
#undef HAL_CAN_LEGACY_MODULE_ENABLED
|
||||
#undef HAL_CEC_MODULE_ENABLED
|
||||
#undef HAL_CRYP_MODULE_ENABLED
|
||||
#undef HAL_DCMI_MODULE_ENABLED
|
||||
#undef HAL_DMA2D_MODULE_ENABLED
|
||||
#undef HAL_ETH_MODULE_ENABLED
|
||||
#undef HAL_NAND_MODULE_ENABLED
|
||||
#undef HAL_NOR_MODULE_ENABLED
|
||||
#undef HAL_PCCARD_MODULE_ENABLED
|
||||
#undef HAL_SRAM_MODULE_ENABLED
|
||||
#undef HAL_SDRAM_MODULE_ENABLED
|
||||
#undef HAL_HASH_MODULE_ENABLED
|
||||
#undef HAL_SMBUS_MODULE_ENABLED
|
||||
#undef HAL_I2S_MODULE_ENABLED
|
||||
#undef HAL_IWDG_MODULE_ENABLED
|
||||
#undef HAL_LTDC_MODULE_ENABLED
|
||||
#undef HAL_DSI_MODULE_ENABLED
|
||||
#undef HAL_QSPI_MODULE_ENABLED
|
||||
#undef HAL_RNG_MODULE_ENABLED
|
||||
#undef HAL_SAI_MODULE_ENABLED
|
||||
#undef HAL_IRDA_MODULE_ENABLED
|
||||
#undef HAL_SMARTCARD_MODULE_ENABLED
|
||||
#undef HAL_WWDG_MODULE_ENABLED
|
||||
//#undef HAL_HCD_MODULE_ENABLED
|
||||
#undef HAL_FMPI2C_MODULE_ENABLED
|
||||
#undef HAL_SPDIFRX_MODULE_ENABLED
|
||||
#undef HAL_DFSDM_MODULE_ENABLED
|
||||
#undef HAL_LPTIM_MODULE_ENABLED
|
||||
#undef HAL_MMC_MODULE_ENABLED
|
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
**
|
||||
|
||||
** File : LinkerScript.ld
|
||||
**
|
||||
** Abstract : Linker script for STM32F429VGTx Device with
|
||||
** 2048KByte FLASH, 192KByte RAM
|
||||
**
|
||||
** Set heap size, stack size and stack location according
|
||||
** to application requirements.
|
||||
**
|
||||
** Set memory bank area and size if external memory is used.
|
||||
**
|
||||
** Target : STMicroelectronics STM32
|
||||
**
|
||||
**
|
||||
** Distribution: The file is distributed as is, without any warranty
|
||||
** of any kind.
|
||||
**
|
||||
*****************************************************************************
|
||||
** @attention
|
||||
**
|
||||
** <h2><center>© COPYRIGHT(c) 2014 Ac6</center></h2>
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
** 1. Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
** this list of conditions and the following disclaimer in the documentation
|
||||
** and/or other materials provided with the distribution.
|
||||
** 3. Neither the name of Ac6 nor the names of its contributors
|
||||
** may be used to endorse or promote products derived from this software
|
||||
** without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20000000 + LD_MAX_DATA_SIZE; /* end of RAM */
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
_Min_Heap_Size = 0x200; /* required amount of heap */
|
||||
_Min_Stack_Size = 0x400; /* required amount of stack */
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE
|
||||
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
|
||||
MEMORY_ARRAY (rw) : ORIGIN = 0x10000000, LENGTH = 0x144
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into FLASH */
|
||||
.isr_vector :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
/* The program code and other data goes into FLASH */
|
||||
.text ALIGN(4):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} >FLASH
|
||||
|
||||
/* Constant data goes into FLASH */
|
||||
.rodata ALIGN(4) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} >FLASH
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} >FLASH
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} >FLASH
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} >FLASH
|
||||
|
||||
/* used by the startup to initialize data */
|
||||
_sidata = LOADADDR(.data);
|
||||
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} >RAM AT> FLASH
|
||||
|
||||
|
||||
_siccmram = LOADADDR(.ccmram);
|
||||
|
||||
/* CCM-RAM section
|
||||
*
|
||||
* IMPORTANT NOTE!
|
||||
* If initialized variables will be placed in this section,
|
||||
* the startup code needs to be modified to copy the init-values.
|
||||
*/
|
||||
.ccmram :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sccmram = .; /* create a global symbol at ccmram start */
|
||||
*(.ccmram)
|
||||
*(.ccmram*)
|
||||
|
||||
. = ALIGN(4);
|
||||
_eccmram = .; /* create a global symbol at ccmram end */
|
||||
} >CCMRAM AT> FLASH
|
||||
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss secion */
|
||||
_sbss = .; /* define a global symbol at bss start */
|
||||
__bss_start__ = _sbss;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
_ebss = .; /* define a global symbol at bss end */
|
||||
__bss_end__ = _ebss;
|
||||
} >RAM
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
. = . + _Min_Heap_Size;
|
||||
. = . + _Min_Stack_Size;
|
||||
. = ALIGN(8);
|
||||
} >RAM
|
||||
|
||||
|
||||
|
||||
/* Remove information from the standard libraries */
|
||||
/DISCARD/ :
|
||||
{
|
||||
libc.a ( * )
|
||||
libm.a ( * )
|
||||
libgcc.a ( * )
|
||||
}
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
ExtRAMData : {*(.ExtRAMData)} >MEMORY_ARRAY
|
||||
}
|
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
Copyright (c) 2011 Arduino. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "pins_arduino.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Pin number
|
||||
const PinName digitalPin[] = {
|
||||
PA_0, //D0
|
||||
PA_1, //D1
|
||||
PA_2, //D2
|
||||
PA_3, //D3
|
||||
PA_4, //D4
|
||||
PA_5, //D5
|
||||
PA_6, //D6
|
||||
PA_7, //D7
|
||||
PA_8, //D8
|
||||
PA_9, //D9
|
||||
PA_10, //D10
|
||||
PA_11, //D11
|
||||
PA_12, //D12
|
||||
PA_13, //D13
|
||||
PA_14, //D14
|
||||
PA_15, //D15
|
||||
PB_0, //D16
|
||||
PB_1, //D17
|
||||
PB_2, //D18
|
||||
PB_3, //D19
|
||||
PB_4, //D20
|
||||
PB_5, //D21
|
||||
PB_6, //D22
|
||||
PB_7, //D23
|
||||
PB_8, //D24
|
||||
PB_9, //D25
|
||||
PB_10, //D26
|
||||
PB_11, //D27
|
||||
PB_12, //D28
|
||||
PB_13, //D29
|
||||
PB_14, //D30
|
||||
PB_15, //D31
|
||||
PC_0, //D32
|
||||
PC_1, //D33
|
||||
PC_2, //D34
|
||||
PC_3, //D35
|
||||
PC_4, //D36
|
||||
PC_5, //D37
|
||||
PC_6, //D38
|
||||
PC_7, //D39
|
||||
PC_8, //D40
|
||||
PC_9, //D41
|
||||
PC_10, //D42
|
||||
PC_11, //D43
|
||||
PC_12, //D44
|
||||
PC_13, //D45
|
||||
PC_14, //D46
|
||||
PC_15, //D47
|
||||
PD_0, //D48
|
||||
PD_1, //D49
|
||||
PD_2, //D50
|
||||
PD_3, //D51
|
||||
PD_4, //D52
|
||||
PD_5, //D53
|
||||
PD_6, //D54
|
||||
PD_7, //D55
|
||||
PD_8, //D56
|
||||
PD_9, //D57
|
||||
PD_10, //D58
|
||||
PD_11, //D59
|
||||
PD_12, //D60
|
||||
PD_13, //D61
|
||||
PD_14, //D62
|
||||
PD_15, //D63
|
||||
PE_0, //D64
|
||||
PE_1, //D65
|
||||
PE_2, //D66
|
||||
PE_3, //D67
|
||||
PE_4, //D68
|
||||
PE_5, //D69
|
||||
PE_6, //D70
|
||||
PE_7, //D71
|
||||
PE_8, //D72
|
||||
PE_9, //D73
|
||||
PE_10, //D74
|
||||
PE_11, //D75
|
||||
PE_12, //D76
|
||||
PE_13, //D77
|
||||
PE_14, //D78
|
||||
PE_15, //D79
|
||||
PF_0, //D80
|
||||
PF_1, //D81
|
||||
PF_2, //D82
|
||||
PF_3, //D83
|
||||
PF_4, //D84
|
||||
PF_5, //D85
|
||||
PF_6, //D86
|
||||
PF_7, //D87
|
||||
PF_8, //D88
|
||||
PF_9, //D89
|
||||
PF_10, //D90
|
||||
PF_11, //D91
|
||||
PF_12, //D92
|
||||
PF_13, //D93
|
||||
PF_14, //D94
|
||||
PF_15, //D95
|
||||
PG_0, //D96
|
||||
PG_1, //D97
|
||||
PG_2, //D98
|
||||
PG_3, //D99
|
||||
PG_4, //D100
|
||||
PG_5, //D101
|
||||
PG_6, //D102
|
||||
PG_7, //D103
|
||||
PG_8, //D104
|
||||
PG_9, //D105
|
||||
PG_10, //D106
|
||||
PG_11, //D107
|
||||
PG_12, //D108
|
||||
PG_13, //D109
|
||||
PG_14, //D110
|
||||
PG_15, //D111
|
||||
|
||||
//Duplicated ADC Pins
|
||||
PA_3, //D112/A0
|
||||
PA_4, //D113/A1
|
||||
PC_0, //D114/A2
|
||||
PC_1, //D115/A3
|
||||
PC_2, //D116/A4
|
||||
PC_3, //D117/A5
|
||||
PC_4, //D118/A6
|
||||
PF_3, //D119/A16 - 1:FSMC_A3 2:ADC3_IN9
|
||||
PF_4, //D120/A17 - 1:FSMC_A4 2:ADC3_IN14
|
||||
PF_5, //D121/A18 - 1:FSMC_A5 2:ADC3_IN15
|
||||
PF_6, //D122/A19 - 1:TIM10_CH1 2:ADC3_IN4
|
||||
PF_7, //D123/A20 - 1:TIM11_CH1 2:ADC3_IN5
|
||||
PF_8, //D124/A20 - 1:TIM11_CH1 2:ADC3_IN6
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief System Clock Configuration
|
||||
* The system Clock is configured as follow :
|
||||
* System Clock source = PLL (HSE)
|
||||
* SYSCLK(Hz) = 168000000
|
||||
* HCLK(Hz) = 168000000
|
||||
* AHB Prescaler = 1
|
||||
* APB1 Prescaler = 4
|
||||
* APB2 Prescaler = 2
|
||||
* HSE Frequency(Hz) = 8000000
|
||||
* PLL_M = 8
|
||||
* PLL_N = 336
|
||||
* PLL_P = 2
|
||||
* PLL_Q = 7
|
||||
* VDD(V) = 3.3
|
||||
* Main regulator output voltage = Scale1 mode
|
||||
* Flash Latency(WS) = 5
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
WEAK void SystemClock_Config(void)
|
||||
{
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
|
||||
/* Enable Power Control clock */
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
|
||||
/* The voltage scaling allows optimizing the power consumption when the device is
|
||||
clocked below the maximum system frequency, to update the voltage scaling value
|
||||
regarding system frequency refer to product datasheet. */
|
||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
||||
|
||||
/* Enable HSE Oscillator and activate PLL with HSE as source */
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLM = 8;
|
||||
RCC_OscInitStruct.PLL.PLLN = 336;
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLQ = 7;
|
||||
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
/* Initialization Error */
|
||||
}
|
||||
|
||||
if(HAL_PWREx_EnableOverDrive() != HAL_OK)
|
||||
{
|
||||
/* Initialization Error */
|
||||
}
|
||||
|
||||
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
|
||||
clocks dividers */
|
||||
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
|
||||
if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
|
||||
{
|
||||
/* Initialization Error */
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
Copyright (c) 2011 Arduino. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VARIANT_ARDUINO_STM32_
|
||||
#define _VARIANT_ARDUINO_STM32_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Pins
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define PA0 0 //D0
|
||||
#define PA1 1 //D1
|
||||
#define PA2 2 //D2
|
||||
#define PA3 3 //D3
|
||||
#define PA4 4 //D4
|
||||
#define PA5 5 //D5
|
||||
#define PA6 6 //D6
|
||||
#define PA7 7 //D7
|
||||
#define PA8 8 //D8
|
||||
#define PA9 9 //D9
|
||||
#define PA10 10 //D10
|
||||
#define PA11 11 //D11
|
||||
#define PA12 12 //D12
|
||||
#define PA13 13 //D13
|
||||
#define PA14 14 //D14
|
||||
#define PA15 15 //D15
|
||||
#define PB0 16 //D16
|
||||
#define PB1 17 //D17
|
||||
#define PB2 18 //D18
|
||||
#define PB3 19 //D19
|
||||
#define PB4 20 //D20
|
||||
#define PB5 21 //D21
|
||||
#define PB6 22 //D22
|
||||
#define PB7 23 //D23
|
||||
#define PB8 24 //D24
|
||||
#define PB9 25 //D25
|
||||
#define PB10 26 //D26
|
||||
#define PB11 27 //D27
|
||||
#define PB12 28 //D28
|
||||
#define PB13 29 //D29
|
||||
#define PB14 30 //D30
|
||||
#define PB15 31 //D31
|
||||
#define PC0 32 //D32
|
||||
#define PC1 33 //D33
|
||||
#define PC2 34 //D34
|
||||
#define PC3 35 //D35
|
||||
#define PC4 36 //D36
|
||||
#define PC5 37 //D37
|
||||
#define PC6 38 //D38
|
||||
#define PC7 39 //D39
|
||||
#define PC8 40 //D40
|
||||
#define PC9 41 //D41
|
||||
#define PC10 42 //D42
|
||||
#define PC11 43 //D43
|
||||
#define PC12 44 //D44
|
||||
#define PC13 45 //D45
|
||||
#define PC14 46 //D46
|
||||
#define PC15 47 //D47
|
||||
#define PD0 48 //D48
|
||||
#define PD1 49 //D49
|
||||
#define PD2 50 //D50
|
||||
#define PD3 51 //D51
|
||||
#define PD4 52 //D52
|
||||
#define PD5 53 //D53
|
||||
#define PD6 54 //D54
|
||||
#define PD7 55 //D55
|
||||
#define PD8 56 //D56
|
||||
#define PD9 57 //D57
|
||||
#define PD10 58 //D58
|
||||
#define PD11 59 //D59
|
||||
#define PD12 60 //D60
|
||||
#define PD13 61 //D61
|
||||
#define PD14 62 //D62
|
||||
#define PD15 63 //D63
|
||||
#define PE0 64 //D64
|
||||
#define PE1 65 //D65
|
||||
#define PE2 66 //D66
|
||||
#define PE3 67 //D67
|
||||
#define PE4 68 //D68
|
||||
#define PE5 69 //D69
|
||||
#define PE6 70 //D70
|
||||
#define PE7 71 //D71
|
||||
#define PE8 72 //D72
|
||||
#define PE9 73 //D73
|
||||
#define PE10 74 //D74
|
||||
#define PE11 75 //D75
|
||||
#define PE12 76 //D76
|
||||
#define PE13 77 //D77
|
||||
#define PE14 78 //D78
|
||||
#define PE15 79 //D79
|
||||
#define PF0 80 //D64
|
||||
#define PF1 81 //D65
|
||||
#define PF2 82 //D66
|
||||
#define PF3 83 //D67
|
||||
#define PF4 84 //D68
|
||||
#define PF5 85 //D69
|
||||
#define PF6 86 //D70
|
||||
#define PF7 87 //D71
|
||||
#define PF8 88 //D72
|
||||
#define PF9 89 //D73
|
||||
#define PF10 90 //D74
|
||||
#define PF11 91 //D75
|
||||
#define PF12 92 //D76
|
||||
#define PF13 93 //D77
|
||||
#define PF14 94 //D78
|
||||
#define PF15 95 //D79
|
||||
#define PG0 96 //D64
|
||||
#define PG1 97 //D65
|
||||
#define PG2 98 //D66
|
||||
#define PG3 99 //D67
|
||||
#define PG4 100 //D68
|
||||
#define PG5 101 //D69
|
||||
#define PG6 102 //D70
|
||||
#define PG7 103 //D71
|
||||
#define PG8 104 //D72
|
||||
#define PG9 105 //D73
|
||||
#define PG10 106 //D74
|
||||
#define PG11 107 //D75
|
||||
#define PG12 108 //D76
|
||||
#define PG13 109 //D77
|
||||
#define PG14 110 //D78
|
||||
#define PG15 111 //D79
|
||||
|
||||
// This must be a literal with the same value as PEND
|
||||
#define NUM_DIGITAL_PINS 112
|
||||
// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS
|
||||
#define NUM_ANALOG_INPUTS 13
|
||||
#define NUM_ANALOG_FIRST NUM_DIGITAL_PINS
|
||||
|
||||
//#define ADC_RESOLUTION 12
|
||||
|
||||
// PWM resolution
|
||||
//#define PWM_RESOLUTION 12
|
||||
#define PWM_FREQUENCY 1000 // >= 20 Khz => inaudible noise for fans
|
||||
#define PWM_MAX_DUTY_CYCLE 255
|
||||
|
||||
// SPI Definitions
|
||||
#define PIN_SPI_SS PA4
|
||||
#define PIN_SPI_MOSI PA7
|
||||
#define PIN_SPI_MISO PA6
|
||||
#define PIN_SPI_SCK PA5
|
||||
|
||||
// I2C Definitions
|
||||
#define PIN_WIRE_SDA PB9
|
||||
#define PIN_WIRE_SCL PB8
|
||||
|
||||
// Timer Definitions
|
||||
// Do not use timer used by PWM pin. See PinMap_PWM.
|
||||
#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file
|
||||
#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file
|
||||
#define TIMER_SERIAL TIM7 // TIMER_SERIAL must be defined in this file
|
||||
|
||||
// UART Definitions
|
||||
//#define SERIAL_UART_INSTANCE 1 // Connected to EXP3 header
|
||||
/* Enable Serial 3 */
|
||||
#define HAVE_HWSERIAL1
|
||||
#define HAVE_HWSERIAL3
|
||||
|
||||
// Default pin used for 'Serial' instance (ex: ST-Link)
|
||||
// Mandatory for Firmata
|
||||
#define PIN_SERIAL_RX PA10
|
||||
#define PIN_SERIAL_TX PA9
|
||||
|
||||
/* HAL configuration */
|
||||
#define HSE_VALUE 8000000U
|
||||
|
||||
#define FLASH_PAGE_SIZE (4U * 1024U)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Arduino objects - C++ only
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
// These serial port names are intended to allow libraries and architecture-neutral
|
||||
// sketches to automatically default to the correct port name for a particular type
|
||||
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
|
||||
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
|
||||
//
|
||||
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
|
||||
//
|
||||
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
|
||||
//
|
||||
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
|
||||
//
|
||||
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
|
||||
//
|
||||
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
|
||||
// pins are NOT connected to anything by default.
|
||||
#define SERIAL_PORT_MONITOR Serial
|
||||
#define SERIAL_PORT_HARDWARE_OPEN Serial
|
||||
#endif
|
||||
|
||||
#endif /* _VARIANT_ARDUINO_STM32_ */
|
@@ -141,10 +141,10 @@ extern "C" {
|
||||
#define PG15 111 //D79
|
||||
|
||||
// This must be a literal with the same value as PEND
|
||||
#define NUM_DIGITAL_PINS 125
|
||||
#define NUM_DIGITAL_PINS 112
|
||||
// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS
|
||||
#define NUM_ANALOG_INPUTS 13
|
||||
#define NUM_ANALOG_FIRST 112
|
||||
#define NUM_ANALOG_FIRST NUM_DIGITAL_PINS
|
||||
|
||||
//#define ADC_RESOLUTION 12
|
||||
|
||||
@@ -165,9 +165,9 @@ extern "C" {
|
||||
|
||||
// Timer Definitions
|
||||
// Do not use timer used by PWM pin. See PinMap_PWM.
|
||||
#define TIMER_TONE TIM6
|
||||
#define TIMER_SERVO TIM5
|
||||
#define TIMER_SERIAL TIM7
|
||||
#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file
|
||||
#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file
|
||||
#define TIMER_SERIAL TIM7 // TIMER_SERIAL must be defined in this file
|
||||
|
||||
// UART Definitions
|
||||
//#define SERIAL_UART_INSTANCE 1 // Connected to EXP3 header
|
||||
|
@@ -255,9 +255,9 @@ extern "C" {
|
||||
|
||||
// Timer Definitions
|
||||
// Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c
|
||||
#define TIMER_TONE TIM2
|
||||
#define TIMER_SERVO TIM5 // Only 1 Servo PIN on SKR-PRO, so use the same timer as defined in PeripheralPins
|
||||
#define TIMER_SERIAL TIM7
|
||||
#define TIMER_TONE TIM2 // TIMER_TONE must be defined in this file
|
||||
#define TIMER_SERVO TIM5 // Only 1 Servo PIN on SKR-PRO, so use the same timer as defined in PeripheralPins
|
||||
#define TIMER_SERIAL TIM7 // TIMER_SERIAL must be defined in this file
|
||||
|
||||
// UART Definitions
|
||||
//#define ENABLE_HWSERIAL1 done automatically by the #define SERIAL_UART_INSTANCE below
|
||||
|
@@ -157,9 +157,9 @@ extern "C" {
|
||||
|
||||
// Timer Definitions
|
||||
// Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c
|
||||
#define TIMER_TONE TIM2
|
||||
#define TIMER_SERVO TIM5
|
||||
#define TIMER_SERIAL TIM7
|
||||
#define TIMER_TONE TIM2 // TIMER_TONE must be defined in this file
|
||||
#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file
|
||||
#define TIMER_SERIAL TIM7 // TIMER_SERIAL must be defined in this file
|
||||
|
||||
// UART1 for TFT port
|
||||
#define ENABLE_HWSERIAL1
|
||||
|
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2019, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
* Automatically generated from STM32F401R[(B-C)|(D-E)]Tx.xml
|
||||
*/
|
||||
#include "Arduino.h"
|
||||
#include "PeripheralPins.h"
|
||||
|
||||
/* =====
|
||||
* Note: Commented lines are alternative possibilities which are not used per default.
|
||||
* If you change them, you will have to know what you do
|
||||
* =====
|
||||
*/
|
||||
|
||||
//*** ADC ***
|
||||
|
||||
#ifdef HAL_ADC_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_ADC[] = {
|
||||
{PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0
|
||||
{PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1
|
||||
{PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2
|
||||
{PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3
|
||||
{PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4
|
||||
{PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5
|
||||
{PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6
|
||||
{PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7
|
||||
{PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8
|
||||
{PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9
|
||||
{PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10
|
||||
{PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11
|
||||
{PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12
|
||||
{PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13
|
||||
{PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14
|
||||
{PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** No DAC ***
|
||||
|
||||
//*** I2C ***
|
||||
|
||||
#ifdef HAL_I2C_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_I2C_SDA[] = {
|
||||
{PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C2)},
|
||||
{PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)},
|
||||
{PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
{PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
{PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
|
||||
WEAK const PinMap PinMap_I2C_SCL[] = {
|
||||
{PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
|
||||
{PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
{PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
{PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** PWM ***
|
||||
|
||||
#ifdef HAL_TIM_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_PWM[] = {
|
||||
//{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
|
||||
{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1
|
||||
//{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2
|
||||
{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2
|
||||
//{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3
|
||||
{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3
|
||||
//{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1
|
||||
//{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4
|
||||
{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4
|
||||
//{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2
|
||||
{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
|
||||
{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
|
||||
//{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N
|
||||
{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
|
||||
{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1
|
||||
{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2
|
||||
{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3
|
||||
{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4
|
||||
{PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
|
||||
//{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
|
||||
{PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3
|
||||
//{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
|
||||
{PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4
|
||||
{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2
|
||||
{PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
|
||||
{PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
|
||||
{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1
|
||||
{PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2
|
||||
{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3
|
||||
//{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1
|
||||
{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4
|
||||
//{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1
|
||||
{PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3
|
||||
{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N
|
||||
{PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
|
||||
{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
|
||||
{PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
|
||||
{PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
|
||||
{PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3
|
||||
{PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** SERIAL ***
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_UART_TX[] = {
|
||||
{PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PA_11, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
|
||||
{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
|
||||
WEAK const PinMap PinMap_UART_RX[] = {
|
||||
{PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PA_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
|
||||
{PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
|
||||
WEAK const PinMap PinMap_UART_RTS[] = {
|
||||
{PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
|
||||
WEAK const PinMap PinMap_UART_CTS[] = {
|
||||
{PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** SPI ***
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_SPI_MOSI[] = {
|
||||
{PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
//{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
|
||||
WEAK const PinMap PinMap_SPI_MISO[] = {
|
||||
{PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
//{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
|
||||
WEAK const PinMap PinMap_SPI_SCLK[] = {
|
||||
{PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
//{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
|
||||
WEAK const PinMap PinMap_SPI_SSEL[] = {
|
||||
{PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
//{PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
//{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** No CAN ***
|
||||
|
||||
//*** No ETHERNET ***
|
||||
|
||||
//*** No QUADSPI ***
|
||||
|
||||
//*** USB ***
|
||||
|
||||
#ifdef HAL_PCD_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_USB_OTG_FS[] = {
|
||||
#ifndef ARDUINO_CoreBoard_F401RC
|
||||
{PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF
|
||||
{PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS
|
||||
{PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID
|
||||
#endif
|
||||
{PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM
|
||||
{PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*** No USB_OTG_HS ***
|
||||
|
||||
//*** SD ***
|
||||
|
||||
#ifdef HAL_SD_MODULE_ENABLED
|
||||
WEAK const PinMap PinMap_SD[] = {
|
||||
{PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4
|
||||
{PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5
|
||||
{PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6
|
||||
{PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7
|
||||
{PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0
|
||||
{PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1
|
||||
{PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2
|
||||
{PC_11, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D3
|
||||
{PC_12, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK
|
||||
{PD_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CMD
|
||||
{NC, NP, 0}
|
||||
};
|
||||
#endif
|
@@ -25,9 +25,9 @@
|
||||
#endif
|
||||
/* USB */
|
||||
#ifdef USBCON
|
||||
USB_OTG_FS_SOF = PA_8,
|
||||
USB_OTG_FS_SOF = PA_8,
|
||||
USB_OTG_FS_VBUS = PA_9,
|
||||
USB_OTG_FS_ID = PA_10,
|
||||
USB_OTG_FS_DM = PA_11,
|
||||
USB_OTG_FS_DP = PA_12,
|
||||
#endif
|
||||
USB_OTG_FS_ID = PA_10,
|
||||
USB_OTG_FS_DM = PA_11,
|
||||
USB_OTG_FS_DP = PA_12,
|
||||
#endif
|
@@ -35,7 +35,6 @@ extern "C" {
|
||||
#define HAL_ADC_MODULE_ENABLED
|
||||
#define HAL_CRC_MODULE_ENABLED
|
||||
#define HAL_DMA_MODULE_ENABLED
|
||||
#define HAL_EXTI_MODULE_ENABLED // Needed for Endstop (and other external) Interrupts
|
||||
#define HAL_FLASH_MODULE_ENABLED
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
#define HAL_I2C_MODULE_ENABLED
|
||||
@@ -43,7 +42,6 @@ extern "C" {
|
||||
#define HAL_PWR_MODULE_ENABLED
|
||||
#define HAL_RCC_MODULE_ENABLED
|
||||
#define HAL_RTC_MODULE_ENABLED
|
||||
#define HAL_SD_MODULE_ENABLED
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
#define HAL_TIM_MODULE_ENABLED
|
||||
#define HAL_CORTEX_MODULE_ENABLED
|
||||
@@ -63,6 +61,7 @@ extern "C" {
|
||||
//#define HAL_SRAM_MODULE_ENABLED
|
||||
//#define HAL_SDRAM_MODULE_ENABLED
|
||||
//#define HAL_HASH_MODULE_ENABLED
|
||||
//#define HAL_EXTI_MODULE_ENABLED
|
||||
//#define HAL_SMBUS_MODULE_ENABLED
|
||||
//#define HAL_I2S_MODULE_ENABLED
|
||||
//#define HAL_LTDC_MODULE_ENABLED
|
||||
@@ -70,7 +69,8 @@ extern "C" {
|
||||
//#define HAL_QSPI_MODULE_ENABLED
|
||||
//#define HAL_RNG_MODULE_ENABLED
|
||||
//#define HAL_SAI_MODULE_ENABLED
|
||||
//#define HAL_UART_MODULE_ENABLED // by default
|
||||
#define HAL_SD_MODULE_ENABLED
|
||||
//#define HAL_UART_MODULE_ENABLED
|
||||
//#define HAL_USART_MODULE_ENABLED
|
||||
//#define HAL_IRDA_MODULE_ENABLED
|
||||
//#define HAL_SMARTCARD_MODULE_ENABLED
|
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
**
|
||||
|
||||
** File : LinkerScript.ld
|
||||
**
|
||||
** Abstract : Linker script for STM32F401RETx Device with
|
||||
** 512KByte FLASH, 96KByte RAM
|
||||
**
|
||||
** Set heap size, stack size and stack location according
|
||||
** to application requirements.
|
||||
**
|
||||
** Set memory bank area and size if external memory is used.
|
||||
**
|
||||
** Target : STMicroelectronics STM32
|
||||
**
|
||||
**
|
||||
** Distribution: The file is distributed as is, without any warranty
|
||||
** of any kind.
|
||||
**
|
||||
*****************************************************************************
|
||||
** @attention
|
||||
**
|
||||
** <h2><center>© COPYRIGHT(c) 2014 Ac6</center></h2>
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
** 1. Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
** this list of conditions and the following disclaimer in the documentation
|
||||
** and/or other materials provided with the distribution.
|
||||
** 3. Neither the name of Ac6 nor the names of its contributors
|
||||
** may be used to endorse or promote products derived from this software
|
||||
** without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20010000; /* end of RAM */
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
_Min_Heap_Size = 0x200;; /* required amount of heap */
|
||||
_Min_Stack_Size = 0x400;; /* required amount of stack */
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into FLASH */
|
||||
.isr_vector :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
/* The program code and other data goes into FLASH */
|
||||
.text ALIGN(4):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} >FLASH
|
||||
|
||||
/* Constant data goes into FLASH */
|
||||
.rodata :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} >FLASH
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} >FLASH
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} >FLASH
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} >FLASH
|
||||
|
||||
/* used by the startup to initialize data */
|
||||
_sidata = LOADADDR(.data);
|
||||
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} >RAM AT> FLASH
|
||||
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss secion */
|
||||
_sbss = .; /* define a global symbol at bss start */
|
||||
__bss_start__ = _sbss;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
_ebss = .; /* define a global symbol at bss end */
|
||||
__bss_end__ = _ebss;
|
||||
} >RAM
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
. = . + _Min_Heap_Size;
|
||||
. = . + _Min_Stack_Size;
|
||||
. = ALIGN(8);
|
||||
} >RAM
|
||||
|
||||
|
||||
|
||||
/* Remove information from the standard libraries */
|
||||
/DISCARD/ :
|
||||
{
|
||||
libc.a ( * )
|
||||
libm.a ( * )
|
||||
libgcc.a ( * )
|
||||
}
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
Copyright (c) 2011 Arduino. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "pins_arduino.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Digital PinName array
|
||||
const PinName digitalPin[] = {
|
||||
PA_0, // Digital pin 0
|
||||
PA_1, // Digital pin 1
|
||||
PA_2, // Digital pin 2
|
||||
PA_3, // Digital pin 3
|
||||
PA_4, // Digital pin 4
|
||||
PA_5, // Digital pin 5
|
||||
PA_6, // Digital pin 6
|
||||
PA_7, // Digital pin 7
|
||||
PA_8, // Digital pin 8
|
||||
PA_9, // Digital pin 9
|
||||
PA_10, // Digital pin 10
|
||||
PA_11, // Digital pin 11
|
||||
PA_12, // Digital pin 12
|
||||
PA_13, // Digital pin 13
|
||||
PA_14, // Digital pin 14
|
||||
PA_15, // Digital pin 15
|
||||
|
||||
PB_0, // Digital pin 16
|
||||
PB_1, // Digital pin 17
|
||||
PB_2, // Digital pin 18
|
||||
PB_3, // Digital pin 19
|
||||
PB_4, // Digital pin 20
|
||||
PB_5, // Digital pin 21
|
||||
PB_6, // Digital pin 22
|
||||
PB_7, // Digital pin 23
|
||||
PB_8, // Digital pin 24
|
||||
PB_9, // Digital pin 25
|
||||
PB_10, // Digital pin 26
|
||||
PB_12, // Digital pin 27
|
||||
PB_13, // Digital pin 28
|
||||
PB_14, // Digital pin 29
|
||||
PB_15, // Digital pin 30
|
||||
|
||||
PC_0, // Digital pin 31
|
||||
PC_1, // Digital pin 32
|
||||
PC_2, // Digital pin 33
|
||||
PC_3, // Digital pin 34
|
||||
PC_4, // Digital pin 35
|
||||
PC_5, // Digital pin 36
|
||||
PC_6, // Digital pin 37
|
||||
PC_7, // Digital pin 38
|
||||
PC_8, // Digital pin 39
|
||||
PC_9, // Digital pin 40
|
||||
PC_10, // Digital pin 41
|
||||
PC_11, // Digital pin 42
|
||||
PC_12, // Digital pin 43
|
||||
PC_13, // Digital pin 44
|
||||
PC_14, // Digital pin 45
|
||||
PC_15, // Digital pin 46
|
||||
|
||||
PD_2, // Digital pin 47
|
||||
|
||||
PH_0, // Digital pin 48, used by the external oscillator
|
||||
PH_1 // Digital pin 49, used by the external oscillator
|
||||
};
|
||||
|
||||
// Analog (Ax) pin number array
|
||||
const uint32_t analogInputPin[] = {
|
||||
0, // A0, PA0
|
||||
1, // A1, PA1
|
||||
2, // A2, PA2
|
||||
3, // A3, PA3
|
||||
4, // A4, PA4
|
||||
5, // A5, PA5
|
||||
6, // A6, PA6
|
||||
7, // A7, PA7
|
||||
16, // A8, PB0
|
||||
17, // A9, PB1
|
||||
31, // A10, PC0
|
||||
32, // A11, PC1
|
||||
33, // A12, PC2
|
||||
34, // A13, PC3
|
||||
35, // A14, PC4
|
||||
36 // A15, PC5
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @brief Configures the System clock source, PLL Multiplier and Divider factors,
|
||||
* AHB/APBx prescalers and Flash settings
|
||||
* @note This function should be called only once the RCC clock configuration
|
||||
* is reset to the default reset state (done in SystemInit() function).
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
/******************************************************************************/
|
||||
/* PLL (clocked by HSE) used as System clock source */
|
||||
/******************************************************************************/
|
||||
static uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
|
||||
{
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||
|
||||
/* The voltage scaling allows optimizing the power consumption when the device is
|
||||
clocked below the maximum system frequency, to update the voltage scaling value
|
||||
regarding system frequency refer to product datasheet. */
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
|
||||
|
||||
// Enable HSE oscillator and activate PLL with HSE as source
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
if (bypass == 0) {
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON; // External 8 MHz xtal on OSC_IN/OSC_OUT
|
||||
} else {
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; // External 8 MHz clock on OSC_IN
|
||||
}
|
||||
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLM = HSE_VALUE / 1000000L; // Expects an 8 MHz external clock by default. Redefine HSE_VALUE if not
|
||||
RCC_OscInitStruct.PLL.PLLN = 336; // VCO output clock = 336 MHz (1 MHz * 336)
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; // PLLCLK = 84 MHz (336 MHz / 4)
|
||||
RCC_OscInitStruct.PLL.PLLQ = 7; // USB clock = 48 MHz (336 MHz / 7) --> OK for USB
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
||||
return 0; // FAIL
|
||||
}
|
||||
|
||||
// Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 84 MHz
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 84 MHz
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 42 MHz
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 84 MHz
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
|
||||
return 0; // FAIL
|
||||
}
|
||||
|
||||
/* Output clock on MCO1 pin(PA8) for debugging purpose */
|
||||
/*
|
||||
if (bypass == 0)
|
||||
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_2); // 4 MHz
|
||||
else
|
||||
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); // 8 MHz
|
||||
*/
|
||||
|
||||
return 1; // OK
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* PLL (clocked by HSI) used as System clock source */
|
||||
/******************************************************************************/
|
||||
uint8_t SetSysClock_PLL_HSI(void)
|
||||
{
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||
|
||||
/* The voltage scaling allows optimizing the power consumption when the device is
|
||||
clocked below the maximum system frequency, to update the voltage scaling value
|
||||
regarding system frequency refer to product datasheet. */
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
|
||||
|
||||
// Enable HSI oscillator and activate PLL with HSI as source
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
|
||||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
||||
RCC_OscInitStruct.PLL.PLLM = 16; // VCO input clock = 1 MHz (16 MHz / 16)
|
||||
RCC_OscInitStruct.PLL.PLLN = 336; // VCO output clock = 336 MHz (1 MHz * 336)
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; // PLLCLK = 84 MHz (336 MHz / 4)
|
||||
RCC_OscInitStruct.PLL.PLLQ = 7; // USB clock = 48 MHz (336 MHz / 7) --> freq is ok but not precise enough
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
||||
return 0; // FAIL
|
||||
}
|
||||
|
||||
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
|
||||
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 84 MHz
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 84 MHz
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 42 MHz
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 84 MHz
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
|
||||
return 0; // FAIL
|
||||
}
|
||||
|
||||
/* Output clock on MCO1 pin(PA8) for debugging purpose */
|
||||
//HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 16 MHz
|
||||
|
||||
return 1; // OK
|
||||
}
|
||||
|
||||
WEAK void SystemClock_Config(void)
|
||||
{
|
||||
/* 1- If fail try to start with HSE and external xtal */
|
||||
if (SetSysClock_PLL_HSE(0) == 0) {
|
||||
/* 2- Try to start with HSE and external clock */
|
||||
if (SetSysClock_PLL_HSE(1) == 0) {
|
||||
/* 3- If fail start with HSI clock */
|
||||
if (SetSysClock_PLL_HSI() == 0) {
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Output clock on MCO2 pin(PC9) for debugging purpose */
|
||||
//HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_4);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
Copyright (c) 2011 Arduino. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VARIANT_ARDUINO_STM32_
|
||||
#define _VARIANT_ARDUINO_STM32_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
// | DIGITAL | ANALOG | USART | TWI | SPI | SPECIAL |
|
||||
// |---------|--------|-----------|----------|------------------------|-----------|
|
||||
#define PA0 0 // | 0 | A0 | | | | |
|
||||
#define PA1 1 // | 1 | A1 | | | | |
|
||||
#define PA2 2 // | 2 | A2 | USART2_TX | | | |
|
||||
#define PA3 3 // | 3 | A3 | USART2_RX | | | |
|
||||
#define PA4 4 // | 4 | A4 | | | SPI1_SS, (SPI3_SS) | |
|
||||
#define PA5 5 // | 5 | A5 | | | SPI1_SCK | |
|
||||
#define PA6 6 // | 6 | A6 | | | SPI1_MISO | |
|
||||
#define PA7 7 // | 7 | A7 | | | SPI1_MOSI | |
|
||||
#define PA8 8 // | 8 | | | TWI3_SCL | | |
|
||||
#define PA9 9 // | 9 | | USART1_TX | | | |
|
||||
#define PA10 10 // | 10 | | USART1_RX | | | |
|
||||
#define PA11 11 // | 11 | | USART6_TX | | | |
|
||||
#define PA12 12 // | 12 | | USART6_RX | | | |
|
||||
#define PA13 13 // | 13 | | | | | SWD_SWDIO |
|
||||
#define PA14 14 // | 14 | | | | | SWD_SWCLK |
|
||||
#define PA15 15 // | 15 | | | | SPI3_SS, (SPI1_SS) | |
|
||||
// |---------|--------|-----------|----------|------------------------|-----------|
|
||||
#define PB0 16 // | 16 | A8 | | | | |
|
||||
#define PB1 17 // | 17 | A9 | | | | |
|
||||
#define PB2 18 // | 18 | | | | | BOOT1 |
|
||||
#define PB3 19 // | 19 | | | TWI2_SDA | SPI3_SCK, (SPI1_SCK) | |
|
||||
#define PB4 20 // | 20 | | | TWI3_SDA | SPI3_MISO, (SPI1_MISO) | |
|
||||
#define PB5 21 // | 21 | | | | SPI3_MOSI, (SPI1_MOSI) | |
|
||||
#define PB6 22 // | 22 | | USART1_TX | TWI1_SCL | | |
|
||||
#define PB7 23 // | 23 | | USART1_RX | TWI1_SDA | | |
|
||||
#define PB8 24 // | 24 | | | TWI1_SCL | | |
|
||||
#define PB9 25 // | 25 | | | TWI1_SDA | SPI2_SS | |
|
||||
#define PB10 26 // | 26 | | | TWI2_SCL | SPI2_SCK | |
|
||||
#define PB12 27 // | 27 | | | | SPI2_SS | |
|
||||
#define PB13 28 // | 28 | | | | SPI2_SCK | |
|
||||
#define PB14 29 // | 29 | | | | SPI2_MISO | |
|
||||
#define PB15 30 // | 30 | | | | SPI2_MOSI | |
|
||||
// |---------|--------|-----------|----------|------------------------|-----------|
|
||||
#define PC0 31 // | 31 | A10 | | | | |
|
||||
#define PC1 32 // | 32 | A11 | | | | |
|
||||
#define PC2 33 // | 33 | A12 | | | SPI2_MISO | |
|
||||
#define PC3 34 // | 34 | A13 | | | SPI2_MOSI | |
|
||||
#define PC4 35 // | 35 | A14 | | | | |
|
||||
#define PC5 36 // | 36 | A15 | | | | |
|
||||
#define PC6 37 // | 37 | | USART6_TX | | | |
|
||||
#define PC7 38 // | 38 | | USART6_RX | | | |
|
||||
#define PC8 39 // | 39 | | | | | |
|
||||
#define PC9 40 // | 40 | | | TWI3_SDA | | |
|
||||
#define PC10 41 // | 41 | | | | SPI3_SCK | |
|
||||
#define PC11 42 // | 42 | | | | SPI3_MISO | |
|
||||
#define PC12 43 // | 43 | | | | SPI3_MOSI | |
|
||||
#define PC13 44 // | 44 | | | | | |
|
||||
#define PC14 45 // | 45 | | | | | OSC32_IN |
|
||||
#define PC15 46 // | 46 | | | | | OSC32_OUT |
|
||||
// |---------|--------|-----------|----------|------------------------|-----------|
|
||||
#define PD2 47 // | 47 | | | | | |
|
||||
// |---------|--------|-----------|----------|------------------------|-----------|
|
||||
#define PH0 48 // | 48 | | | | | OSC_IN |
|
||||
#define PH1 49 // | 49 | | | | | OSC_OUT |
|
||||
// |---------|--------|-----------|----------|------------------------|-----------|
|
||||
|
||||
// This must be a literal
|
||||
#define NUM_DIGITAL_PINS 50
|
||||
#define NUM_ANALOG_INPUTS 16
|
||||
|
||||
// SPI definitions
|
||||
#define PIN_SPI_SS PA4
|
||||
#define PIN_SPI_SS1 PA4
|
||||
#define PIN_SPI_MOSI PA7
|
||||
#define PIN_SPI_MISO PA6
|
||||
#define PIN_SPI_SCK PA5
|
||||
|
||||
|
||||
// Timer Definitions
|
||||
#define TIMER_TONE TIM2
|
||||
#define TIMER_SERVO TIM5
|
||||
#define TIMER_SERIAL TIM11
|
||||
|
||||
// UART Definitions
|
||||
//#define ENABLE_HWSERIAL1 done automatically by the #define SERIAL_UART_INSTANCE below
|
||||
#define ENABLE_HWSERIAL2
|
||||
|
||||
|
||||
// Define here Serial instance number to map on Serial generic name (if not already used by SerialUSB)
|
||||
#define SERIAL_UART_INSTANCE 1 //1 for Serial = Serial1 (USART1)
|
||||
|
||||
// Default pin used for 'Serial' instance
|
||||
// Mandatory for Firmata
|
||||
#define PIN_SERIAL_RX PA10
|
||||
#define PIN_SERIAL_TX PA9
|
||||
|
||||
// Used when user instanciate a hardware Serial using its peripheral name.
|
||||
// Example: HardwareSerial mySerial(USART3);
|
||||
// will use PIN_SERIAL3_RX and PIN_SERIAL3_TX if defined.
|
||||
#define PIN_SERIAL1_RX PA10
|
||||
#define PIN_SERIAL1_TX PA9
|
||||
#define PIN_SERIAL2_RX PA3
|
||||
#define PIN_SERIAL2_TX PA2
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
/*----------------------------------------------------------------------------
|
||||
* Arduino objects - C++ only
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
// These serial port names are intended to allow libraries and architecture-neutral
|
||||
// sketches to automatically default to the correct port name for a particular type
|
||||
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
|
||||
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
|
||||
//
|
||||
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
|
||||
//
|
||||
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
|
||||
//
|
||||
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
|
||||
//
|
||||
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
|
||||
//
|
||||
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
|
||||
// pins are NOT connected to anything by default.
|
||||
#define SERIAL_PORT_MONITOR Serial
|
||||
#define SERIAL_PORT_HARDWARE Serial1
|
||||
#define SERIAL_PORT_HARDWARE_OPEN Serial2
|
||||
#endif
|
||||
|
||||
#endif /* _VARIANT_ARDUINO_STM32_ */
|
@@ -105,14 +105,14 @@ extern "C" {
|
||||
// SPI Definitions
|
||||
#if DEFAULT_SPI == 3
|
||||
#define PIN_SPI_SS PA15
|
||||
#define PIN_SPI_MOSI PB3
|
||||
#define PIN_SPI_MOSI PB5
|
||||
#define PIN_SPI_MISO PB4
|
||||
#define PIN_SPI_SCK PB5
|
||||
#define PIN_SPI_SCK PB3
|
||||
#elif DEFAULT_SPI == 2
|
||||
#define PIN_SPI_SS PB12
|
||||
#define PIN_SPI_MOSI PB13
|
||||
#define PIN_SPI_MOSI PB15
|
||||
#define PIN_SPI_MISO PB14
|
||||
#define PIN_SPI_SCK PB15
|
||||
#define PIN_SPI_SCK PB13
|
||||
#else
|
||||
#define PIN_SPI_SS PA4
|
||||
#define PIN_SPI_MOSI PA7
|
||||
@@ -126,10 +126,10 @@ extern "C" {
|
||||
|
||||
// Timer Definitions
|
||||
#ifndef TIMER_TONE
|
||||
#define TIMER_TONE TIM3
|
||||
#define TIMER_TONE TIM3 // TIMER_TONE must be defined in this file
|
||||
#endif
|
||||
#ifndef TIMER_SERVO
|
||||
#define TIMER_SERVO TIM2
|
||||
#define TIMER_SERVO TIM2 // TIMER_SERVO must be defined in this file
|
||||
#endif
|
||||
|
||||
// UART Definitions
|
||||
|
@@ -118,7 +118,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef LSE_STARTUP_TIMEOUT
|
||||
#define LSE_STARTUP_TIMEOUT 50U // No 32.7KHz LSE on this board, reduced to avoid delays
|
||||
#define LSE_STARTUP_TIMEOUT 50U // No 32.7kHz LSE on this board, reduced to avoid delays
|
||||
#endif
|
||||
|
||||
/* Tip: To avoid modifying this file each time you need to use different HSE,
|
||||
|
@@ -121,9 +121,9 @@ extern "C" {
|
||||
#define TEMP_TIMER 3
|
||||
// Leave TIMER 4 for TFT backlight PWM or Servo freq...
|
||||
#define STEP_TIMER 5
|
||||
#define TIMER_TONE TIM6
|
||||
#define TIMER_SERVO TIM7
|
||||
#define TIMER_SERIAL TIM8
|
||||
#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file
|
||||
#define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file
|
||||
#define TIMER_SERIAL TIM8 // TIMER_SERIAL must be defined in this file
|
||||
|
||||
// UART Definitions
|
||||
// Define here Serial instance number to map on Serial generic name
|
||||
|
@@ -133,10 +133,10 @@ extern "C" {
|
||||
// Timer Definitions (optional)
|
||||
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
|
||||
#ifndef TIMER_TONE
|
||||
#define TIMER_TONE TIM6
|
||||
#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file
|
||||
#endif
|
||||
#ifndef TIMER_SERVO
|
||||
#define TIMER_SERVO TIM7
|
||||
#define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file
|
||||
#endif
|
||||
|
||||
// UART Definitions
|
||||
|
@@ -177,8 +177,8 @@ extern "C" {
|
||||
|
||||
// Timer Definitions (optional)
|
||||
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
|
||||
#define TIMER_TONE TIM6
|
||||
#define TIMER_SERVO TIM7
|
||||
#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file
|
||||
#define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file
|
||||
|
||||
// UART Definitions
|
||||
// Define here Serial instance number to map on Serial generic name
|
||||
|
@@ -299,10 +299,10 @@ extern "C" {
|
||||
|
||||
// Timer Definitions
|
||||
// Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c
|
||||
#define TIMER_TONE TIM6
|
||||
#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file
|
||||
|
||||
// Do not use basic timer: OC is required
|
||||
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
|
||||
#define TIMER_SERVO TIM2 // TODO: advanced-control timers don't work
|
||||
|
||||
// UART Definitions
|
||||
// Define here Serial instance number to map on Serial generic name
|
||||
|
@@ -134,15 +134,15 @@ extern "C" {
|
||||
// Timer Definitions
|
||||
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
|
||||
#ifndef TIMER_TONE
|
||||
#define TIMER_TONE TIM6
|
||||
#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file
|
||||
#endif
|
||||
|
||||
#ifndef TIMER_SERVO
|
||||
#define TIMER_SERVO TIM7
|
||||
#define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file
|
||||
#endif
|
||||
|
||||
#ifndef TIMER_SERIAL
|
||||
#define TIMER_SERIAL TIM9
|
||||
#define TIMER_SERIAL TIM9 // TIMER_SERIAL must be defined in this file
|
||||
#endif
|
||||
|
||||
// UART Definitions
|
||||
|
@@ -153,13 +153,13 @@ extern "C" {
|
||||
// Timer Definitions
|
||||
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
|
||||
#ifndef TIMER_TONE
|
||||
#define TIMER_TONE TIM6
|
||||
#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file
|
||||
#endif
|
||||
#ifndef TIMER_SERVO
|
||||
#define TIMER_SERVO TIM7
|
||||
#define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file
|
||||
#endif
|
||||
#ifndef TIMER_SERIAL
|
||||
#define TIMER_SERIAL TIM5
|
||||
#define TIMER_SERIAL TIM5 // TIMER_SERIAL must be defined in this file
|
||||
#endif
|
||||
|
||||
// UART Definitions
|
||||
|
@@ -185,10 +185,10 @@ extern "C" {
|
||||
|
||||
// Timer Definitions
|
||||
// Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c
|
||||
#define TIMER_TONE TIM6
|
||||
#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file
|
||||
|
||||
// Do not use basic timer: OC is required
|
||||
#define TIMER_SERVO TIM1 //TODO: advanced-control timers don't work
|
||||
#define TIMER_SERVO TIM1 // TODO: advanced-control timers don't work
|
||||
|
||||
// UART Definitions
|
||||
// Define here Serial instance number to map on Serial generic name
|
||||
|
@@ -61,7 +61,7 @@ _Min_Stack_Size = 0x400;; /* required amount of stack */
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x800C000, LENGTH = 256K
|
||||
FLASH (rx) : ORIGIN = 0x8008000, LENGTH = 256K - 32K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
|
||||
}
|
||||
|
||||
|
@@ -93,17 +93,15 @@ extern "C" {
|
||||
#define PIN_SPI_MISO PA6
|
||||
#define PIN_SPI_SCK PA5
|
||||
|
||||
|
||||
// Timer Definitions
|
||||
#define TIMER_TONE TIM2
|
||||
#define TIMER_SERVO TIM5
|
||||
#define TIMER_SERIAL TIM11
|
||||
#define TIMER_TONE TIM2 // TIMER_TONE must be defined in this file
|
||||
#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file
|
||||
#define TIMER_SERIAL TIM11 // TIMER_SERIAL must be defined in this file
|
||||
|
||||
// UART Definitions
|
||||
//#define ENABLE_HWSERIAL1 done automatically by the #define SERIAL_UART_INSTANCE below
|
||||
#define ENABLE_HWSERIAL2
|
||||
|
||||
|
||||
// Define here Serial instance number to map on Serial generic name (if not already used by SerialUSB)
|
||||
#define SERIAL_UART_INSTANCE 1 //1 for Serial = Serial1 (USART1)
|
||||
|
||||
@@ -148,4 +146,4 @@ extern "C" {
|
||||
#define SERIAL_PORT_HARDWARE_OPEN Serial2
|
||||
#endif
|
||||
|
||||
#endif /* _VARIANT_ARDUINO_STM32_ */
|
||||
#endif /* _VARIANT_ARDUINO_STM32_ */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user