blob: 7fabe6b5634e08742547100c3701acd4d7bd20ff [file] [log] [blame]
Patrick Georgi5ac6a632020-10-28 17:29:38 +01001#!/bin/sh
2set -e
3
Nico Huber819ba502023-03-07 22:59:01 +00004TEMP_DIR=$(mktemp -d)
5trap "rm -rf ${TEMP_DIR}" EXIT
6
Nico Huber71c97ee2023-03-07 23:01:53 +00007if command -v meson >/dev/null 2>&1; then
8 meson setup --buildtype release ${TEMP_DIR}/build
9 ninja ${CPUS:+-j${CPUS}} -C ${TEMP_DIR}/build
Nico Huberc3b02dc2023-08-12 01:13:45 +020010 FLASHPROG=${TEMP_DIR}/build/flashprog
Nico Huber71c97ee2023-03-07 23:01:53 +000011else
12 ${MAKECMD:-make} clean
13 ${MAKECMD:-make} -j${CPUS:-$(nproc)} CC="${CC:-ccache cc}" CONFIG_EVERYTHING=yes
Nico Huberc3b02dc2023-08-12 01:13:45 +020014 FLASHPROG=./flashprog
Nico Huber71c97ee2023-03-07 23:01:53 +000015fi
Nico Huber819ba502023-03-07 22:59:01 +000016
17dd bs=128K count=1 </dev/urandom >${TEMP_DIR}/rand
Nico Huberc3b02dc2023-08-12 01:13:45 +020018${FLASHPROG} -p dummy:emulate=M25P10.RES,image=${TEMP_DIR}/image -w ${TEMP_DIR}/rand
19${FLASHPROG} -p dummy:emulate=M25P10.RES,image=${TEMP_DIR}/image -r ${TEMP_DIR}/bak
Nico Huber819ba502023-03-07 22:59:01 +000020cmp ${TEMP_DIR}/rand ${TEMP_DIR}/bak
21
22dd bs=128K count=1 </dev/urandom >${TEMP_DIR}/rand
Nico Huberc3b02dc2023-08-12 01:13:45 +020023${FLASHPROG} -p dummy:emulate=M25P10.RES,image=${TEMP_DIR}/image -c M25P10 -w ${TEMP_DIR}/rand
24${FLASHPROG} -p dummy:emulate=M25P10.RES,image=${TEMP_DIR}/image -c M25P10 -v ${TEMP_DIR}/rand
Nico Huber7a480312023-04-10 14:54:22 +020025
26dd bs=128K count=1 </dev/zero | tr '\000' '\377' >${TEMP_DIR}/empty
Nico Huberc3b02dc2023-08-12 01:13:45 +020027${FLASHPROG} -p dummy:emulate=M25P10.RES,image=${TEMP_DIR}/image -c M25P10 -E
28${FLASHPROG} -p dummy:emulate=M25P10.RES,image=${TEMP_DIR}/image -c M25P10 -v ${TEMP_DIR}/empty