summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Goger <klaus.goger@theobroma-systems.com>2016-09-18 16:53:58 +0200
committerKlaus Goger <klaus.goger@theobroma-systems.com>2016-09-18 16:53:58 +0200
commit839e0f9a8278c9801fa4426cb7dde80ffd744774 (patch)
tree5428e26dc9ccfe2dd9148ba3e9dfd6759eafcfec
Initial commitHEADmaster
-rw-r--r--.gitignore1
-rw-r--r--Makefile2
-rw-r--r--README3
-rw-r--r--boot.cmd10
-rw-r--r--cortex-m0/README.rst27
-rwxr-xr-xcortex-m0/cortex-m0.binbin0 -> 31796 bytes
-rwxr-xr-xcortex-m0/cortex-m0.sh88
7 files changed, 131 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d973aa5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+boot.scr
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..f301fdf
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,2 @@
+boot.scr: boot.cmd
+ mkimage -C none -A arm -T script -d boot.cmd boot.scr
diff --git a/README b/README
new file mode 100644
index 0000000..359c85a
--- /dev/null
+++ b/README
@@ -0,0 +1,3 @@
+Boot script and related tools
+for the A80 Q7 board (codename Armadillo)
+by Theobroma Systems
diff --git a/boot.cmd b/boot.cmd
new file mode 100644
index 0000000..e0027c6
--- /dev/null
+++ b/boot.cmd
@@ -0,0 +1,10 @@
+# Boot script for the A80 Q7 board by Theobroma Systems, codename Armadillo
+#
+# Compile this file:
+# mkimage -C none -A arm -T script -d boot.cmd boot.scr
+
+if emmcboot; then rootdevice=mmcblk0p1; else rootdevice=mmcblk1p1; fi
+setenv bootargs console=ttyS4,115200 root=/dev/${rootdevice} rw rootwait
+ext4load mmc 0:1 $kernel_addr_r boot/uImage
+ext4load mmc 0:1 $fdt_addr_r boot/sun9i-a80-armadillo.dtb
+bootm $kernel_addr_r - $fdt_addr_r
diff --git a/cortex-m0/README.rst b/cortex-m0/README.rst
new file mode 100644
index 0000000..570af2a
--- /dev/null
+++ b/cortex-m0/README.rst
@@ -0,0 +1,27 @@
+==============================================================
+Tools and Firmware for the Cortex M0 Companion Microcontroller
+==============================================================
+
+- ``cortex-m0.bin`` - firmware for the companion mcu
+- ``cortex-m0.sh`` - tool to reset and flash the companion mcu
+
+cortex-m0.sh
+------------
+
+Usage:
+######
+
+--reset resets the companion mcu
+--dfu enables the dfu mode
+--disable enables the mcu reset line to keep it in reset
+--flash firmware flash the mcu with given firmware
+
+cortex-m0.bin
+-------------
+
+Features:
+#########
+
+- emulates an TI AMC6821 fan controller on I2C address 0x18
+- emulates an Interil ISL1208 RTC on I2C address 0x6f
+- external watchdog form the Qseven watchdog pins
diff --git a/cortex-m0/cortex-m0.bin b/cortex-m0/cortex-m0.bin
new file mode 100755
index 0000000..01fe35a
--- /dev/null
+++ b/cortex-m0/cortex-m0.bin
Binary files differ
diff --git a/cortex-m0/cortex-m0.sh b/cortex-m0/cortex-m0.sh
new file mode 100755
index 0000000..17bbdf2
--- /dev/null
+++ b/cortex-m0/cortex-m0.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+
+RESET_PIN=128
+BOOT0_PIN=129
+
+SYSFSPATH=/sys/class/gpio
+
+die() {
+ echo "$*" 1>&2
+ exit 1
+}
+
+usage() {
+ echo "Usage: $0 [--reset|--dfu|--disable|--flash <firmware>]"
+ echo " --reset - resets the Cortex M0"
+ echo " --dfu - enables DFU loader"
+ echo " --disable - keep Cortex M0 in reset"
+ echo " --flash <firmware> - flash the given firmware"
+
+ exit 1
+}
+
+gpiosetup() {
+ for PIN in $RESET_PIN $BOOT0_PIN
+ do
+ if [ ! -d ${SYSFSPATH}/gpio${PIN} ] ; then
+ echo $PIN > ${SYSFSPATH}/export
+ echo out > ${SYSFSPATH}/gpio${PIN}/direction
+ fi
+ done
+}
+
+reset_stm32() {
+ echo 0 > ${SYSFSPATH}/gpio${RESET_PIN}/value
+ echo 0 > ${SYSFSPATH}/gpio${BOOT0_PIN}/value
+ sleep 0.1
+ echo 1 > ${SYSFSPATH}/gpio${RESET_PIN}/value
+}
+
+enable_dfu() {
+ gpiosetup
+ echo 0 > ${SYSFSPATH}/gpio${RESET_PIN}/value
+ echo 1 > ${SYSFSPATH}/gpio${BOOT0_PIN}/value
+ sleep 0.1
+ echo 1 > ${SYSFSPATH}/gpio${RESET_PIN}/value
+}
+
+case "$1" in
+--reset) echo "reseting Cortex M0"
+ gpiosetup
+ reset_stm32
+ ;;
+--dfu) echo "enabling DFU loader"
+ gpiosetup
+ enable_dfu
+ ;;
+--disable) echo "disabling Cortex M0"
+ gpiosetup
+ echo 0 > ${SYSFSPATH}/gpio${RESET_PIN}/value
+ ;;
+--flash)
+ [ $# -eq 2 ] || usage
+ command -v dfu-util >/dev/null 2>&1 || die "dfu-util needed but not found"
+ [ -f "$2" ] || die "flash file does not exist"
+ echo "flashing Cortex M0"
+ gpiosetup
+ enable_dfu
+ echo waiting for DFU loader
+ if [ command -v lsusb >/dev/null 2>&1 ]; then
+ while ! lsusb -d 0483:df11 > /dev/null
+ do
+ sleep .1
+ echo -n .
+ done
+ echo -e "\nfound"
+ else
+ sleep 5
+ fi
+ dfu-util -d 0483:df11 -a 0 -s 0x08000000 -D $2
+ reset_stm32
+ ;;
+--*) usage
+ ;;
+*) usage
+ ;;
+esac
+
+exit 0