tools/testing/selftests/firmware/fw_upload.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/firmware/fw_upload.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/firmware/fw_upload.sh- Extension
.sh- Size
- 4023 bytes
- Lines
- 215
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# This validates the user-initiated fw upload mechanism of the firmware
# loader. It verifies that one or more firmware devices can be created
# for a device driver. It also verifies the data transfer, the
# cancellation support, and the error flows.
set -e
TEST_REQS_FW_UPLOAD="yes"
TEST_DIR=$(dirname $0)
progress_states="preparing transferring programming"
errors="hw-error
timeout
device-busy
invalid-file-size
read-write-error
flash-wearout"
error_abort="user-abort"
fwname1=fw1
fwname2=fw2
fwname3=fw3
source $TEST_DIR/fw_lib.sh
check_mods
check_setup
verify_reqs
trap "upload_finish" EXIT
upload_finish() {
local fwdevs="$fwname1 $fwname2 $fwname3"
for name in $fwdevs; do
if [ -e "$DIR/$name" ]; then
echo -n "$name" > "$DIR"/upload_unregister
fi
done
}
upload_fw() {
local name="$1"
local file="$2"
echo 1 > "$DIR"/"$name"/loading
cat "$file" > "$DIR"/"$name"/data
echo 0 > "$DIR"/"$name"/loading
}
verify_fw() {
local name="$1"
local file="$2"
echo -n "$name" > "$DIR"/config_upload_name
if ! cmp "$file" "$DIR"/upload_read > /dev/null 2>&1; then
echo "$0: firmware compare for $name did not match" >&2
exit 1
fi
echo "$0: firmware upload for $name works" >&2
return 0
}
inject_error() {
local name="$1"
local status="$2"
local error="$3"
echo 1 > "$DIR"/"$name"/loading
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.