-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathbdev_test.sh
More file actions
executable file
·79 lines (69 loc) · 1.87 KB
/
Copy pathbdev_test.sh
File metadata and controls
executable file
·79 lines (69 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
set -e
cat >tmppt.json << EOL
{
"version": [1, 0],
"unpartitioned": {
"families": ["absolute"],
"permissions": {
"secure": "rw",
"nonsecure": "rw",
"bootloader": "rw"
}
},
"partitions": [
{
"name": "Filesystem",
"id": "0x626C6F636B646576",
"size": "100K",
"families": [],
"permissions": {
"secure": "rw",
"nonsecure": "rw",
"bootloader": "rw"
}
}
]
}
EOL
picotool erase || true
picotool reboot
while ! picotool info; do sleep 1; done
picotool partition create tmppt.json tmppt.bin
picotool load -x tmppt.bin
while ! picotool info; do sleep 1; done
declare -a filesystems=("littlefs" "fatfs")
for filesystem in "${filesystems[@]}"
do
picotool bdev format --filesystem $filesystem
echo "this is file 1" > tmpfile1.txt
echo "this is file 2" > tmpfile2.txt
picotool bdev cp tmpfile1.txt :/
picotool bdev cp tmpfile2.txt :/
picotool bdev ls | grep "tmpfile2.txt"
picotool bdev rm tmpfile2.txt
if picotool bdev ls | grep "tmpfile2.txt"; then
echo "Error: tmpfile2.txt was not deleted"
exit 1
fi
picotool bdev cat tmpfile1.txt
picotool bdev cat tmpfile1.txt > tmpfile1.txt.device
if ! cmp -s tmpfile1.txt tmpfile1.txt.device; then
echo "Error: tmpfile1.txt content has changed"
exit 1
fi
echo "this is new file 2" > tmpfile2.txt
picotool bdev cp tmpfile2.txt :/
picotool bdev cat tmpfile2.txt
picotool bdev cat tmpfile2.txt > tmpfile2.txt.device
if ! cmp -s tmpfile2.txt tmpfile2.txt.device; then
echo "Error: tmpfile2.txt content has changed"
exit 1
fi
done
rm tmpfile1.txt
rm tmpfile1.txt.device
rm tmpfile2.txt
rm tmpfile2.txt.device
rm tmppt.json
rm tmppt.bin