diff --git a/tools/alif/alif/SP-AB1C1F1M41010HH-rev-a0-dev.bin b/tools/alif/alif/SP-AB1C1F1M41010HH-rev-a0-dev.bin
new file mode 100755
index 000000000..fb17629f8
Binary files /dev/null and b/tools/alif/alif/SP-AB1C1F1M41010HH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41010HH-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AB1C1F1M41010HH-rev-a0-dev.bin.sign
index 4f8af5131..59e2abef5 100755
Binary files a/tools/alif/alif/SP-AB1C1F1M41010HH-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AB1C1F1M41010HH-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41010HH-rev-a0.bin b/tools/alif/alif/SP-AB1C1F1M41010HH-rev-a0.bin
new file mode 100755
index 000000000..03c443aae
Binary files /dev/null and b/tools/alif/alif/SP-AB1C1F1M41010HH-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41010HH-rev-a0.bin.sign b/tools/alif/alif/SP-AB1C1F1M41010HH-rev-a0.bin.sign
index d859b5f03..2e2e64b87 100755
Binary files a/tools/alif/alif/SP-AB1C1F1M41010HH-rev-a0.bin.sign and b/tools/alif/alif/SP-AB1C1F1M41010HH-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41010PH-rev-a0-dev.bin b/tools/alif/alif/SP-AB1C1F1M41010PH-rev-a0-dev.bin
new file mode 100755
index 000000000..f0a8e8176
Binary files /dev/null and b/tools/alif/alif/SP-AB1C1F1M41010PH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41010PH-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AB1C1F1M41010PH-rev-a0-dev.bin.sign
index 67f9d1074..541c88329 100755
Binary files a/tools/alif/alif/SP-AB1C1F1M41010PH-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AB1C1F1M41010PH-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41010PH-rev-a0.bin b/tools/alif/alif/SP-AB1C1F1M41010PH-rev-a0.bin
new file mode 100755
index 000000000..e1b76b21f
Binary files /dev/null and b/tools/alif/alif/SP-AB1C1F1M41010PH-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41010PH-rev-a0.bin.sign b/tools/alif/alif/SP-AB1C1F1M41010PH-rev-a0.bin.sign
index 155c4fdff..5f4101695 100755
Binary files a/tools/alif/alif/SP-AB1C1F1M41010PH-rev-a0.bin.sign and b/tools/alif/alif/SP-AB1C1F1M41010PH-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41820HH-rev-a0-dev.bin b/tools/alif/alif/SP-AB1C1F1M41820HH-rev-a0-dev.bin
new file mode 100755
index 000000000..d9cfeed9e
Binary files /dev/null and b/tools/alif/alif/SP-AB1C1F1M41820HH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41820HH-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AB1C1F1M41820HH-rev-a0-dev.bin.sign
index c8945c4ea..92aa3d29e 100755
Binary files a/tools/alif/alif/SP-AB1C1F1M41820HH-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AB1C1F1M41820HH-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41820HH-rev-a0.bin b/tools/alif/alif/SP-AB1C1F1M41820HH-rev-a0.bin
new file mode 100755
index 000000000..f97f8d975
Binary files /dev/null and b/tools/alif/alif/SP-AB1C1F1M41820HH-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41820HH-rev-a0.bin.sign b/tools/alif/alif/SP-AB1C1F1M41820HH-rev-a0.bin.sign
index 4a611e899..ec6b6be84 100755
Binary files a/tools/alif/alif/SP-AB1C1F1M41820HH-rev-a0.bin.sign and b/tools/alif/alif/SP-AB1C1F1M41820HH-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41820PH-rev-a0-dev.bin b/tools/alif/alif/SP-AB1C1F1M41820PH-rev-a0-dev.bin
new file mode 100755
index 000000000..51ef4a484
Binary files /dev/null and b/tools/alif/alif/SP-AB1C1F1M41820PH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41820PH-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AB1C1F1M41820PH-rev-a0-dev.bin.sign
index 5dd47b60e..eccb76896 100755
Binary files a/tools/alif/alif/SP-AB1C1F1M41820PH-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AB1C1F1M41820PH-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41820PH-rev-a0.bin b/tools/alif/alif/SP-AB1C1F1M41820PH-rev-a0.bin
new file mode 100755
index 000000000..84e32fb1e
Binary files /dev/null and b/tools/alif/alif/SP-AB1C1F1M41820PH-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AB1C1F1M41820PH-rev-a0.bin.sign b/tools/alif/alif/SP-AB1C1F1M41820PH-rev-a0.bin.sign
index a1faffbdf..e05f8ceff 100755
Binary files a/tools/alif/alif/SP-AB1C1F1M41820PH-rev-a0.bin.sign and b/tools/alif/alif/SP-AB1C1F1M41820PH-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AB1C1F4M51820HH-rev-a0-dev.bin b/tools/alif/alif/SP-AB1C1F4M51820HH-rev-a0-dev.bin
new file mode 100755
index 000000000..578b080f7
Binary files /dev/null and b/tools/alif/alif/SP-AB1C1F4M51820HH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AB1C1F4M51820HH-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AB1C1F4M51820HH-rev-a0-dev.bin.sign
index 606560222..63ea00dda 100755
Binary files a/tools/alif/alif/SP-AB1C1F4M51820HH-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AB1C1F4M51820HH-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AB1C1F4M51820HH-rev-a0.bin b/tools/alif/alif/SP-AB1C1F4M51820HH-rev-a0.bin
new file mode 100755
index 000000000..09adac8da
Binary files /dev/null and b/tools/alif/alif/SP-AB1C1F4M51820HH-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AB1C1F4M51820HH-rev-a0.bin.sign b/tools/alif/alif/SP-AB1C1F4M51820HH-rev-a0.bin.sign
index 2e056563d..617242f63 100755
Binary files a/tools/alif/alif/SP-AB1C1F4M51820HH-rev-a0.bin.sign and b/tools/alif/alif/SP-AB1C1F4M51820HH-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AB1C1F4M51820PH-rev-a0-dev.bin b/tools/alif/alif/SP-AB1C1F4M51820PH-rev-a0-dev.bin
new file mode 100755
index 000000000..c4c4cc531
Binary files /dev/null and b/tools/alif/alif/SP-AB1C1F4M51820PH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AB1C1F4M51820PH-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AB1C1F4M51820PH-rev-a0-dev.bin.sign
index 2f752ae16..7c72faa1d 100755
Binary files a/tools/alif/alif/SP-AB1C1F4M51820PH-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AB1C1F4M51820PH-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AB1C1F4M51820PH-rev-a0.bin b/tools/alif/alif/SP-AB1C1F4M51820PH-rev-a0.bin
new file mode 100755
index 000000000..5f178d4f5
Binary files /dev/null and b/tools/alif/alif/SP-AB1C1F4M51820PH-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AB1C1F4M51820PH-rev-a0.bin.sign b/tools/alif/alif/SP-AB1C1F4M51820PH-rev-a0.bin.sign
index 5fcd0de67..cddd76714 100755
Binary files a/tools/alif/alif/SP-AB1C1F4M51820PH-rev-a0.bin.sign and b/tools/alif/alif/SP-AB1C1F4M51820PH-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AE101F4071542LH-rev-b2-dev.bin b/tools/alif/alif/SP-AE101F4071542LH-rev-b2-dev.bin
index f52558689..efd2616a2 100755
Binary files a/tools/alif/alif/SP-AE101F4071542LH-rev-b2-dev.bin and b/tools/alif/alif/SP-AE101F4071542LH-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/SP-AE101F4071542LH-rev-b2-dev.bin.sign b/tools/alif/alif/SP-AE101F4071542LH-rev-b2-dev.bin.sign
index 83bde7ffe..4eb3d766e 100755
Binary files a/tools/alif/alif/SP-AE101F4071542LH-rev-b2-dev.bin.sign and b/tools/alif/alif/SP-AE101F4071542LH-rev-b2-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE101F4071542LH-rev-b2.bin b/tools/alif/alif/SP-AE101F4071542LH-rev-b2.bin
index 92c14d1f2..8667efd00 100755
Binary files a/tools/alif/alif/SP-AE101F4071542LH-rev-b2.bin and b/tools/alif/alif/SP-AE101F4071542LH-rev-b2.bin differ
diff --git a/tools/alif/alif/SP-AE101F4071542LH-rev-b2.bin.sign b/tools/alif/alif/SP-AE101F4071542LH-rev-b2.bin.sign
index a91992831..b39e209e7 100755
Binary files a/tools/alif/alif/SP-AE101F4071542LH-rev-b2.bin.sign and b/tools/alif/alif/SP-AE101F4071542LH-rev-b2.bin.sign differ
diff --git a/tools/alif/alif/SP-AE101F4071542LH-rev-b3-dev.bin b/tools/alif/alif/SP-AE101F4071542LH-rev-b3-dev.bin
index 076400e2f..3490d2d5a 100755
Binary files a/tools/alif/alif/SP-AE101F4071542LH-rev-b3-dev.bin and b/tools/alif/alif/SP-AE101F4071542LH-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/SP-AE101F4071542LH-rev-b3-dev.bin.sign b/tools/alif/alif/SP-AE101F4071542LH-rev-b3-dev.bin.sign
index 03e9ddbb1..b3a138a51 100755
Binary files a/tools/alif/alif/SP-AE101F4071542LH-rev-b3-dev.bin.sign and b/tools/alif/alif/SP-AE101F4071542LH-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE101F4071542LH-rev-b3.bin b/tools/alif/alif/SP-AE101F4071542LH-rev-b3.bin
index 808d65457..1d2c4bacc 100755
Binary files a/tools/alif/alif/SP-AE101F4071542LH-rev-b3.bin and b/tools/alif/alif/SP-AE101F4071542LH-rev-b3.bin differ
diff --git a/tools/alif/alif/SP-AE101F4071542LH-rev-b3.bin.sign b/tools/alif/alif/SP-AE101F4071542LH-rev-b3.bin.sign
index 3d89f12ca..41068337b 100755
Binary files a/tools/alif/alif/SP-AE101F4071542LH-rev-b3.bin.sign and b/tools/alif/alif/SP-AE101F4071542LH-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/SP-AE101F4071542LH-rev-b4-dev.bin b/tools/alif/alif/SP-AE101F4071542LH-rev-b4-dev.bin
index 8e41357fe..0b39c0a33 100755
Binary files a/tools/alif/alif/SP-AE101F4071542LH-rev-b4-dev.bin and b/tools/alif/alif/SP-AE101F4071542LH-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/SP-AE101F4071542LH-rev-b4-dev.bin.sign b/tools/alif/alif/SP-AE101F4071542LH-rev-b4-dev.bin.sign
index 5c0a1ee40..efe17a802 100755
Binary files a/tools/alif/alif/SP-AE101F4071542LH-rev-b4-dev.bin.sign and b/tools/alif/alif/SP-AE101F4071542LH-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE101F4071542LH-rev-b4.bin b/tools/alif/alif/SP-AE101F4071542LH-rev-b4.bin
index 41e9aa9da..dea047003 100755
Binary files a/tools/alif/alif/SP-AE101F4071542LH-rev-b4.bin and b/tools/alif/alif/SP-AE101F4071542LH-rev-b4.bin differ
diff --git a/tools/alif/alif/SP-AE101F4071542LH-rev-b4.bin.sign b/tools/alif/alif/SP-AE101F4071542LH-rev-b4.bin.sign
index d0bdbed5e..b66e8c2eb 100755
Binary files a/tools/alif/alif/SP-AE101F4071542LH-rev-b4.bin.sign and b/tools/alif/alif/SP-AE101F4071542LH-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F10405055H-rev-a0-dev.bin b/tools/alif/alif/SP-AE1C1F10405055H-rev-a0-dev.bin
new file mode 100755
index 000000000..3f6639216
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F10405055H-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F10405055H-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AE1C1F10405055H-rev-a0-dev.bin.sign
index 961dca6f7..3e696826b 100755
Binary files a/tools/alif/alif/SP-AE1C1F10405055H-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AE1C1F10405055H-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F10405055H-rev-a0.bin b/tools/alif/alif/SP-AE1C1F10405055H-rev-a0.bin
new file mode 100755
index 000000000..7e264d24f
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F10405055H-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F10405055H-rev-a0.bin.sign b/tools/alif/alif/SP-AE1C1F10405055H-rev-a0.bin.sign
index df7be6c08..f94a9a38c 100755
Binary files a/tools/alif/alif/SP-AE1C1F10405055H-rev-a0.bin.sign and b/tools/alif/alif/SP-AE1C1F10405055H-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F1040505HH-rev-a0-dev.bin b/tools/alif/alif/SP-AE1C1F1040505HH-rev-a0-dev.bin
new file mode 100755
index 000000000..f939d9055
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F1040505HH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F1040505HH-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AE1C1F1040505HH-rev-a0-dev.bin.sign
index 95cd3f2b1..3ff0152aa 100755
Binary files a/tools/alif/alif/SP-AE1C1F1040505HH-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AE1C1F1040505HH-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F1040505HH-rev-a0.bin b/tools/alif/alif/SP-AE1C1F1040505HH-rev-a0.bin
new file mode 100755
index 000000000..c840de82b
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F1040505HH-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F1040505HH-rev-a0.bin.sign b/tools/alif/alif/SP-AE1C1F1040505HH-rev-a0.bin.sign
index 259a960db..6e441f5ce 100755
Binary files a/tools/alif/alif/SP-AE1C1F1040505HH-rev-a0.bin.sign and b/tools/alif/alif/SP-AE1C1F1040505HH-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F1040505PH-rev-a0-dev.bin b/tools/alif/alif/SP-AE1C1F1040505PH-rev-a0-dev.bin
new file mode 100755
index 000000000..232c4abb3
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F1040505PH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F1040505PH-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AE1C1F1040505PH-rev-a0-dev.bin.sign
index 22531f7ac..4f5081c8b 100755
Binary files a/tools/alif/alif/SP-AE1C1F1040505PH-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AE1C1F1040505PH-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F1040505PH-rev-a0.bin b/tools/alif/alif/SP-AE1C1F1040505PH-rev-a0.bin
new file mode 100755
index 000000000..5b08685ae
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F1040505PH-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F1040505PH-rev-a0.bin.sign b/tools/alif/alif/SP-AE1C1F1040505PH-rev-a0.bin.sign
index df3f6386f..46de10ffd 100755
Binary files a/tools/alif/alif/SP-AE1C1F1040505PH-rev-a0.bin.sign and b/tools/alif/alif/SP-AE1C1F1040505PH-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F10410105H-rev-a0-dev.bin b/tools/alif/alif/SP-AE1C1F10410105H-rev-a0-dev.bin
new file mode 100755
index 000000000..32ac683b9
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F10410105H-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F10410105H-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AE1C1F10410105H-rev-a0-dev.bin.sign
index b515715a5..72d3a651a 100755
Binary files a/tools/alif/alif/SP-AE1C1F10410105H-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AE1C1F10410105H-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F10410105H-rev-a0.bin b/tools/alif/alif/SP-AE1C1F10410105H-rev-a0.bin
new file mode 100755
index 000000000..e0c5166a4
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F10410105H-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F10410105H-rev-a0.bin.sign b/tools/alif/alif/SP-AE1C1F10410105H-rev-a0.bin.sign
index 59074ad44..22f53fc14 100755
Binary files a/tools/alif/alif/SP-AE1C1F10410105H-rev-a0.bin.sign and b/tools/alif/alif/SP-AE1C1F10410105H-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F1041010HH-rev-a0-dev.bin b/tools/alif/alif/SP-AE1C1F1041010HH-rev-a0-dev.bin
new file mode 100755
index 000000000..f94714b13
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F1041010HH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F1041010HH-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AE1C1F1041010HH-rev-a0-dev.bin.sign
index 16270bf9a..dce7ea566 100755
Binary files a/tools/alif/alif/SP-AE1C1F1041010HH-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AE1C1F1041010HH-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F1041010HH-rev-a0.bin b/tools/alif/alif/SP-AE1C1F1041010HH-rev-a0.bin
new file mode 100755
index 000000000..9df9a5f40
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F1041010HH-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F1041010HH-rev-a0.bin.sign b/tools/alif/alif/SP-AE1C1F1041010HH-rev-a0.bin.sign
index 00176c866..c428820ca 100755
Binary files a/tools/alif/alif/SP-AE1C1F1041010HH-rev-a0.bin.sign and b/tools/alif/alif/SP-AE1C1F1041010HH-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F1041010PH-rev-a0-dev.bin b/tools/alif/alif/SP-AE1C1F1041010PH-rev-a0-dev.bin
new file mode 100755
index 000000000..283ea4e20
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F1041010PH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F1041010PH-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AE1C1F1041010PH-rev-a0-dev.bin.sign
index c78837907..494037aa4 100755
Binary files a/tools/alif/alif/SP-AE1C1F1041010PH-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AE1C1F1041010PH-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F1041010PH-rev-a0.bin b/tools/alif/alif/SP-AE1C1F1041010PH-rev-a0.bin
new file mode 100755
index 000000000..fc85a6c02
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F1041010PH-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F1041010PH-rev-a0.bin.sign b/tools/alif/alif/SP-AE1C1F1041010PH-rev-a0.bin.sign
index 574736efa..52280b830 100755
Binary files a/tools/alif/alif/SP-AE1C1F1041010PH-rev-a0.bin.sign and b/tools/alif/alif/SP-AE1C1F1041010PH-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F40319205H-rev-a0-dev.bin b/tools/alif/alif/SP-AE1C1F40319205H-rev-a0-dev.bin
new file mode 100755
index 000000000..7d591cf4f
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F40319205H-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F40319205H-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AE1C1F40319205H-rev-a0-dev.bin.sign
index 93671dbd1..ef21c108c 100755
Binary files a/tools/alif/alif/SP-AE1C1F40319205H-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AE1C1F40319205H-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F40319205H-rev-a0.bin b/tools/alif/alif/SP-AE1C1F40319205H-rev-a0.bin
new file mode 100755
index 000000000..b3de74bee
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F40319205H-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F40319205H-rev-a0.bin.sign b/tools/alif/alif/SP-AE1C1F40319205H-rev-a0.bin.sign
index 16d4a43cf..124d3ed98 100755
Binary files a/tools/alif/alif/SP-AE1C1F40319205H-rev-a0.bin.sign and b/tools/alif/alif/SP-AE1C1F40319205H-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F4051920HH-rev-a0-dev.bin b/tools/alif/alif/SP-AE1C1F4051920HH-rev-a0-dev.bin
new file mode 100755
index 000000000..a273cec96
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F4051920HH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F4051920HH-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AE1C1F4051920HH-rev-a0-dev.bin.sign
index 11ba86047..bccf57067 100755
Binary files a/tools/alif/alif/SP-AE1C1F4051920HH-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AE1C1F4051920HH-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F4051920HH-rev-a0.bin b/tools/alif/alif/SP-AE1C1F4051920HH-rev-a0.bin
new file mode 100755
index 000000000..85fc3145e
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F4051920HH-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F4051920HH-rev-a0.bin.sign b/tools/alif/alif/SP-AE1C1F4051920HH-rev-a0.bin.sign
index 207951548..75dae6637 100755
Binary files a/tools/alif/alif/SP-AE1C1F4051920HH-rev-a0.bin.sign and b/tools/alif/alif/SP-AE1C1F4051920HH-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F4051920PH-rev-a0-dev.bin b/tools/alif/alif/SP-AE1C1F4051920PH-rev-a0-dev.bin
new file mode 100755
index 000000000..3281b6187
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F4051920PH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F4051920PH-rev-a0-dev.bin.sign b/tools/alif/alif/SP-AE1C1F4051920PH-rev-a0-dev.bin.sign
index 337a20a71..24fe92c1c 100755
Binary files a/tools/alif/alif/SP-AE1C1F4051920PH-rev-a0-dev.bin.sign and b/tools/alif/alif/SP-AE1C1F4051920PH-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE1C1F4051920PH-rev-a0.bin b/tools/alif/alif/SP-AE1C1F4051920PH-rev-a0.bin
new file mode 100755
index 000000000..024a643e0
Binary files /dev/null and b/tools/alif/alif/SP-AE1C1F4051920PH-rev-a0.bin differ
diff --git a/tools/alif/alif/SP-AE1C1F4051920PH-rev-a0.bin.sign b/tools/alif/alif/SP-AE1C1F4051920PH-rev-a0.bin.sign
index 5e7f0415b..169a851d2 100755
Binary files a/tools/alif/alif/SP-AE1C1F4051920PH-rev-a0.bin.sign and b/tools/alif/alif/SP-AE1C1F4051920PH-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F40C1537LE-rev-b2-dev.bin b/tools/alif/alif/SP-AE302F40C1537LE-rev-b2-dev.bin
index 7d7f4216a..012dd521c 100755
Binary files a/tools/alif/alif/SP-AE302F40C1537LE-rev-b2-dev.bin and b/tools/alif/alif/SP-AE302F40C1537LE-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F40C1537LE-rev-b2-dev.bin.sign b/tools/alif/alif/SP-AE302F40C1537LE-rev-b2-dev.bin.sign
index 1fad415d0..50100b249 100755
Binary files a/tools/alif/alif/SP-AE302F40C1537LE-rev-b2-dev.bin.sign and b/tools/alif/alif/SP-AE302F40C1537LE-rev-b2-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F40C1537LE-rev-b2.bin b/tools/alif/alif/SP-AE302F40C1537LE-rev-b2.bin
index c316b8d66..735425f63 100755
Binary files a/tools/alif/alif/SP-AE302F40C1537LE-rev-b2.bin and b/tools/alif/alif/SP-AE302F40C1537LE-rev-b2.bin differ
diff --git a/tools/alif/alif/SP-AE302F40C1537LE-rev-b2.bin.sign b/tools/alif/alif/SP-AE302F40C1537LE-rev-b2.bin.sign
index 0536de40c..1cb0c53a9 100755
Binary files a/tools/alif/alif/SP-AE302F40C1537LE-rev-b2.bin.sign and b/tools/alif/alif/SP-AE302F40C1537LE-rev-b2.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F40C1537LE-rev-b3-dev.bin b/tools/alif/alif/SP-AE302F40C1537LE-rev-b3-dev.bin
index 36fff9e1f..f6a71e9f3 100755
Binary files a/tools/alif/alif/SP-AE302F40C1537LE-rev-b3-dev.bin and b/tools/alif/alif/SP-AE302F40C1537LE-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F40C1537LE-rev-b3-dev.bin.sign b/tools/alif/alif/SP-AE302F40C1537LE-rev-b3-dev.bin.sign
index 8be495518..5a33a1cfc 100755
Binary files a/tools/alif/alif/SP-AE302F40C1537LE-rev-b3-dev.bin.sign and b/tools/alif/alif/SP-AE302F40C1537LE-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F40C1537LE-rev-b3.bin b/tools/alif/alif/SP-AE302F40C1537LE-rev-b3.bin
index cfc30d812..87c9dba0b 100755
Binary files a/tools/alif/alif/SP-AE302F40C1537LE-rev-b3.bin and b/tools/alif/alif/SP-AE302F40C1537LE-rev-b3.bin differ
diff --git a/tools/alif/alif/SP-AE302F40C1537LE-rev-b3.bin.sign b/tools/alif/alif/SP-AE302F40C1537LE-rev-b3.bin.sign
index 3e611d028..0d831620b 100755
Binary files a/tools/alif/alif/SP-AE302F40C1537LE-rev-b3.bin.sign and b/tools/alif/alif/SP-AE302F40C1537LE-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F40C1537LE-rev-b4-dev.bin b/tools/alif/alif/SP-AE302F40C1537LE-rev-b4-dev.bin
index f8d9810cd..61e577977 100755
Binary files a/tools/alif/alif/SP-AE302F40C1537LE-rev-b4-dev.bin and b/tools/alif/alif/SP-AE302F40C1537LE-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F40C1537LE-rev-b4-dev.bin.sign b/tools/alif/alif/SP-AE302F40C1537LE-rev-b4-dev.bin.sign
index ac850d8f7..aed41310f 100755
Binary files a/tools/alif/alif/SP-AE302F40C1537LE-rev-b4-dev.bin.sign and b/tools/alif/alif/SP-AE302F40C1537LE-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F40C1537LE-rev-b4.bin b/tools/alif/alif/SP-AE302F40C1537LE-rev-b4.bin
index 271787b92..948027e19 100755
Binary files a/tools/alif/alif/SP-AE302F40C1537LE-rev-b4.bin and b/tools/alif/alif/SP-AE302F40C1537LE-rev-b4.bin differ
diff --git a/tools/alif/alif/SP-AE302F40C1537LE-rev-b4.bin.sign b/tools/alif/alif/SP-AE302F40C1537LE-rev-b4.bin.sign
index a11e5c4cc..643c84cc0 100755
Binary files a/tools/alif/alif/SP-AE302F40C1537LE-rev-b4.bin.sign and b/tools/alif/alif/SP-AE302F40C1537LE-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80C1557LE-rev-b2-dev.bin b/tools/alif/alif/SP-AE302F80C1557LE-rev-b2-dev.bin
index 02e70312f..a7b55cab8 100755
Binary files a/tools/alif/alif/SP-AE302F80C1557LE-rev-b2-dev.bin and b/tools/alif/alif/SP-AE302F80C1557LE-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F80C1557LE-rev-b2-dev.bin.sign b/tools/alif/alif/SP-AE302F80C1557LE-rev-b2-dev.bin.sign
index 57c377e93..0c627f225 100755
Binary files a/tools/alif/alif/SP-AE302F80C1557LE-rev-b2-dev.bin.sign and b/tools/alif/alif/SP-AE302F80C1557LE-rev-b2-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80C1557LE-rev-b2.bin b/tools/alif/alif/SP-AE302F80C1557LE-rev-b2.bin
index 63934f33b..eb6d3573a 100755
Binary files a/tools/alif/alif/SP-AE302F80C1557LE-rev-b2.bin and b/tools/alif/alif/SP-AE302F80C1557LE-rev-b2.bin differ
diff --git a/tools/alif/alif/SP-AE302F80C1557LE-rev-b2.bin.sign b/tools/alif/alif/SP-AE302F80C1557LE-rev-b2.bin.sign
index d474f30ad..b39d69d54 100755
Binary files a/tools/alif/alif/SP-AE302F80C1557LE-rev-b2.bin.sign and b/tools/alif/alif/SP-AE302F80C1557LE-rev-b2.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80C1557LE-rev-b3-dev.bin b/tools/alif/alif/SP-AE302F80C1557LE-rev-b3-dev.bin
index 0414358bb..068143974 100755
Binary files a/tools/alif/alif/SP-AE302F80C1557LE-rev-b3-dev.bin and b/tools/alif/alif/SP-AE302F80C1557LE-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F80C1557LE-rev-b3-dev.bin.sign b/tools/alif/alif/SP-AE302F80C1557LE-rev-b3-dev.bin.sign
index f0ed95138..579b0459b 100755
Binary files a/tools/alif/alif/SP-AE302F80C1557LE-rev-b3-dev.bin.sign and b/tools/alif/alif/SP-AE302F80C1557LE-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80C1557LE-rev-b3.bin b/tools/alif/alif/SP-AE302F80C1557LE-rev-b3.bin
index f36e34b43..a3a801022 100755
Binary files a/tools/alif/alif/SP-AE302F80C1557LE-rev-b3.bin and b/tools/alif/alif/SP-AE302F80C1557LE-rev-b3.bin differ
diff --git a/tools/alif/alif/SP-AE302F80C1557LE-rev-b3.bin.sign b/tools/alif/alif/SP-AE302F80C1557LE-rev-b3.bin.sign
index 3a0670404..fc501de12 100755
Binary files a/tools/alif/alif/SP-AE302F80C1557LE-rev-b3.bin.sign and b/tools/alif/alif/SP-AE302F80C1557LE-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80C1557LE-rev-b4-dev.bin b/tools/alif/alif/SP-AE302F80C1557LE-rev-b4-dev.bin
index 282db3899..cbb36f56e 100755
Binary files a/tools/alif/alif/SP-AE302F80C1557LE-rev-b4-dev.bin and b/tools/alif/alif/SP-AE302F80C1557LE-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F80C1557LE-rev-b4-dev.bin.sign b/tools/alif/alif/SP-AE302F80C1557LE-rev-b4-dev.bin.sign
index 2955c42a4..93003e556 100755
Binary files a/tools/alif/alif/SP-AE302F80C1557LE-rev-b4-dev.bin.sign and b/tools/alif/alif/SP-AE302F80C1557LE-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80C1557LE-rev-b4.bin b/tools/alif/alif/SP-AE302F80C1557LE-rev-b4.bin
index 905c23a8f..21671cbe7 100755
Binary files a/tools/alif/alif/SP-AE302F80C1557LE-rev-b4.bin and b/tools/alif/alif/SP-AE302F80C1557LE-rev-b4.bin differ
diff --git a/tools/alif/alif/SP-AE302F80C1557LE-rev-b4.bin.sign b/tools/alif/alif/SP-AE302F80C1557LE-rev-b4.bin.sign
index d87bfae2e..156c5c189 100755
Binary files a/tools/alif/alif/SP-AE302F80C1557LE-rev-b4.bin.sign and b/tools/alif/alif/SP-AE302F80C1557LE-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F5582AE-rev-b3-dev.bin b/tools/alif/alif/SP-AE302F80F5582AE-rev-b3-dev.bin
index f5cfbd164..47c5e34a2 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582AE-rev-b3-dev.bin and b/tools/alif/alif/SP-AE302F80F5582AE-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F5582AE-rev-b3-dev.bin.sign b/tools/alif/alif/SP-AE302F80F5582AE-rev-b3-dev.bin.sign
index 623da530e..f9df86d5e 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582AE-rev-b3-dev.bin.sign and b/tools/alif/alif/SP-AE302F80F5582AE-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F5582AE-rev-b3.bin b/tools/alif/alif/SP-AE302F80F5582AE-rev-b3.bin
index 5e697876a..6a34e08b7 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582AE-rev-b3.bin and b/tools/alif/alif/SP-AE302F80F5582AE-rev-b3.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F5582AE-rev-b3.bin.sign b/tools/alif/alif/SP-AE302F80F5582AE-rev-b3.bin.sign
index 8c307da56..6e68274ed 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582AE-rev-b3.bin.sign and b/tools/alif/alif/SP-AE302F80F5582AE-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F5582AE-rev-b4-dev.bin b/tools/alif/alif/SP-AE302F80F5582AE-rev-b4-dev.bin
index fc7a99d0a..68f6a2977 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582AE-rev-b4-dev.bin and b/tools/alif/alif/SP-AE302F80F5582AE-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F5582AE-rev-b4-dev.bin.sign b/tools/alif/alif/SP-AE302F80F5582AE-rev-b4-dev.bin.sign
index 4c166a7db..090b081ae 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582AE-rev-b4-dev.bin.sign and b/tools/alif/alif/SP-AE302F80F5582AE-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F5582AE-rev-b4.bin b/tools/alif/alif/SP-AE302F80F5582AE-rev-b4.bin
index cb97887cd..6da511feb 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582AE-rev-b4.bin and b/tools/alif/alif/SP-AE302F80F5582AE-rev-b4.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F5582AE-rev-b4.bin.sign b/tools/alif/alif/SP-AE302F80F5582AE-rev-b4.bin.sign
index a91e6c2de..9dec78d65 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582AE-rev-b4.bin.sign and b/tools/alif/alif/SP-AE302F80F5582AE-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F5582LE-rev-b3-dev.bin b/tools/alif/alif/SP-AE302F80F5582LE-rev-b3-dev.bin
index df62b279c..22adfea69 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582LE-rev-b3-dev.bin and b/tools/alif/alif/SP-AE302F80F5582LE-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F5582LE-rev-b3-dev.bin.sign b/tools/alif/alif/SP-AE302F80F5582LE-rev-b3-dev.bin.sign
index b67e32da8..68b3914af 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582LE-rev-b3-dev.bin.sign and b/tools/alif/alif/SP-AE302F80F5582LE-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F5582LE-rev-b3.bin b/tools/alif/alif/SP-AE302F80F5582LE-rev-b3.bin
index 994a108a3..2f1504cc6 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582LE-rev-b3.bin and b/tools/alif/alif/SP-AE302F80F5582LE-rev-b3.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F5582LE-rev-b3.bin.sign b/tools/alif/alif/SP-AE302F80F5582LE-rev-b3.bin.sign
index 30f00618a..dd1286746 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582LE-rev-b3.bin.sign and b/tools/alif/alif/SP-AE302F80F5582LE-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F5582LE-rev-b4-dev.bin b/tools/alif/alif/SP-AE302F80F5582LE-rev-b4-dev.bin
index aaa026f7d..0f8b30c26 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582LE-rev-b4-dev.bin and b/tools/alif/alif/SP-AE302F80F5582LE-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F5582LE-rev-b4-dev.bin.sign b/tools/alif/alif/SP-AE302F80F5582LE-rev-b4-dev.bin.sign
index 22363d9c8..d34b3a685 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582LE-rev-b4-dev.bin.sign and b/tools/alif/alif/SP-AE302F80F5582LE-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F5582LE-rev-b4.bin b/tools/alif/alif/SP-AE302F80F5582LE-rev-b4.bin
index ae72864e0..b4c2db771 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582LE-rev-b4.bin and b/tools/alif/alif/SP-AE302F80F5582LE-rev-b4.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F5582LE-rev-b4.bin.sign b/tools/alif/alif/SP-AE302F80F5582LE-rev-b4.bin.sign
index 3300b2364..3557ac712 100755
Binary files a/tools/alif/alif/SP-AE302F80F5582LE-rev-b4.bin.sign and b/tools/alif/alif/SP-AE302F80F5582LE-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2-dev.bin b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2-dev.bin
index 71fc15be7..e56fddafe 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2-dev.bin and b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2-dev.bin.sign b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2-dev.bin.sign
index 82faa0ca5..655881b40 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2-dev.bin.sign and b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2.bin b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2.bin
index b7fe27f3e..366fdddec 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2.bin and b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2.bin.sign b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2.bin.sign
index 9a70e6dfe..5158f50c0 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2.bin.sign and b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b2.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3-dev.bin b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3-dev.bin
index ceed2e97d..57777de09 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3-dev.bin and b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3-dev.bin.sign b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3-dev.bin.sign
index 0cfd839f3..64b41991f 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3-dev.bin.sign and b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3.bin b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3.bin
index 50ae8684b..1a215d868 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3.bin and b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3.bin.sign b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3.bin.sign
index 5b70b0586..7d032984d 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3.bin.sign and b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4-dev.bin b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4-dev.bin
index 89ae0e43d..44ef8cf38 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4-dev.bin and b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4-dev.bin.sign b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4-dev.bin.sign
index b0d955edb..a01579f84 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4-dev.bin.sign and b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4.bin b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4.bin
index 65106a89d..b8b0fdd84 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4.bin and b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4.bin.sign b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4.bin.sign
index dc71e256d..7aee2d13b 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4.bin.sign and b/tools/alif/alif/SP-AE302F80F55D5AE-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2-dev.bin b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2-dev.bin
index 3a3bdde45..df7213e5c 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2-dev.bin and b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2-dev.bin.sign b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2-dev.bin.sign
index 587401491..0989e72da 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2-dev.bin.sign and b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2.bin b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2.bin
index c448545cd..6c98c03c9 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2.bin and b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2.bin.sign b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2.bin.sign
index 65c0fa7b4..76cccc90a 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2.bin.sign and b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b2.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3-dev.bin b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3-dev.bin
index a614eba34..32f8ac9e5 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3-dev.bin and b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3-dev.bin.sign b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3-dev.bin.sign
index 886b07bc7..7eb27da1f 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3-dev.bin.sign and b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3.bin b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3.bin
index 29f88c311..2a0bbef09 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3.bin and b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3.bin.sign b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3.bin.sign
index be8756c13..6dfb9fa50 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3.bin.sign and b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4-dev.bin b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4-dev.bin
index 0803031cd..fc2e76884 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4-dev.bin and b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4-dev.bin.sign b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4-dev.bin.sign
index 89a192436..c117cd5c8 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4-dev.bin.sign and b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4.bin b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4.bin
index b33fdf2a5..017a4a857 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4.bin and b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4.bin differ
diff --git a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4.bin.sign b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4.bin.sign
index f122208ff..289532e50 100755
Binary files a/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4.bin.sign and b/tools/alif/alif/SP-AE302F80F55D5LE-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F5582AS-rev-b3-dev.bin b/tools/alif/alif/SP-AE512F80F5582AS-rev-b3-dev.bin
index adbe99a3a..34f20b9df 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582AS-rev-b3-dev.bin and b/tools/alif/alif/SP-AE512F80F5582AS-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F5582AS-rev-b3-dev.bin.sign b/tools/alif/alif/SP-AE512F80F5582AS-rev-b3-dev.bin.sign
index db9705817..2c4adace3 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582AS-rev-b3-dev.bin.sign and b/tools/alif/alif/SP-AE512F80F5582AS-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F5582AS-rev-b3.bin b/tools/alif/alif/SP-AE512F80F5582AS-rev-b3.bin
index 23cc4edab..d3baac21e 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582AS-rev-b3.bin and b/tools/alif/alif/SP-AE512F80F5582AS-rev-b3.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F5582AS-rev-b3.bin.sign b/tools/alif/alif/SP-AE512F80F5582AS-rev-b3.bin.sign
index d142fa1a2..24ca1733b 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582AS-rev-b3.bin.sign and b/tools/alif/alif/SP-AE512F80F5582AS-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F5582AS-rev-b4-dev.bin b/tools/alif/alif/SP-AE512F80F5582AS-rev-b4-dev.bin
index 47dd0e8c9..aa367f47a 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582AS-rev-b4-dev.bin and b/tools/alif/alif/SP-AE512F80F5582AS-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F5582AS-rev-b4-dev.bin.sign b/tools/alif/alif/SP-AE512F80F5582AS-rev-b4-dev.bin.sign
index bc8b38231..1f0f339de 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582AS-rev-b4-dev.bin.sign and b/tools/alif/alif/SP-AE512F80F5582AS-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F5582AS-rev-b4.bin b/tools/alif/alif/SP-AE512F80F5582AS-rev-b4.bin
index 9cade882d..5ece2c988 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582AS-rev-b4.bin and b/tools/alif/alif/SP-AE512F80F5582AS-rev-b4.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F5582AS-rev-b4.bin.sign b/tools/alif/alif/SP-AE512F80F5582AS-rev-b4.bin.sign
index accf36c3a..db3595cb6 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582AS-rev-b4.bin.sign and b/tools/alif/alif/SP-AE512F80F5582AS-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F5582LS-rev-b3-dev.bin b/tools/alif/alif/SP-AE512F80F5582LS-rev-b3-dev.bin
index 89f3282be..608e5485a 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582LS-rev-b3-dev.bin and b/tools/alif/alif/SP-AE512F80F5582LS-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F5582LS-rev-b3-dev.bin.sign b/tools/alif/alif/SP-AE512F80F5582LS-rev-b3-dev.bin.sign
index 848ee64b3..adc1d5598 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582LS-rev-b3-dev.bin.sign and b/tools/alif/alif/SP-AE512F80F5582LS-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F5582LS-rev-b3.bin b/tools/alif/alif/SP-AE512F80F5582LS-rev-b3.bin
index 14733895c..13af01ebe 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582LS-rev-b3.bin and b/tools/alif/alif/SP-AE512F80F5582LS-rev-b3.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F5582LS-rev-b3.bin.sign b/tools/alif/alif/SP-AE512F80F5582LS-rev-b3.bin.sign
index 1dee3d055..7f493e96e 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582LS-rev-b3.bin.sign and b/tools/alif/alif/SP-AE512F80F5582LS-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F5582LS-rev-b4-dev.bin b/tools/alif/alif/SP-AE512F80F5582LS-rev-b4-dev.bin
index b90994238..bdb0544cf 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582LS-rev-b4-dev.bin and b/tools/alif/alif/SP-AE512F80F5582LS-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F5582LS-rev-b4-dev.bin.sign b/tools/alif/alif/SP-AE512F80F5582LS-rev-b4-dev.bin.sign
index e64e2af7e..a95f9b46c 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582LS-rev-b4-dev.bin.sign and b/tools/alif/alif/SP-AE512F80F5582LS-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F5582LS-rev-b4.bin b/tools/alif/alif/SP-AE512F80F5582LS-rev-b4.bin
index 5fb00fc2a..15136aee6 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582LS-rev-b4.bin and b/tools/alif/alif/SP-AE512F80F5582LS-rev-b4.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F5582LS-rev-b4.bin.sign b/tools/alif/alif/SP-AE512F80F5582LS-rev-b4.bin.sign
index 99d29d6cf..323180639 100755
Binary files a/tools/alif/alif/SP-AE512F80F5582LS-rev-b4.bin.sign and b/tools/alif/alif/SP-AE512F80F5582LS-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2-dev.bin b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2-dev.bin
index 09ec61478..8c10775cc 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2-dev.bin and b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2-dev.bin.sign b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2-dev.bin.sign
index e255fb911..c2e618607 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2-dev.bin.sign and b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2.bin b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2.bin
index 50e9f696a..03dd92d2f 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2.bin and b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2.bin.sign b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2.bin.sign
index e7f6d9cbc..44470b1d0 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2.bin.sign and b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b2.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3-dev.bin b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3-dev.bin
index 2807ccd2a..88d4309bc 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3-dev.bin and b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3-dev.bin.sign b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3-dev.bin.sign
index af343729d..f042f81d5 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3-dev.bin.sign and b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3.bin b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3.bin
index f0b0f3f00..cfe40b161 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3.bin and b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3.bin.sign b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3.bin.sign
index 6138635b2..b3042381e 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3.bin.sign and b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4-dev.bin b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4-dev.bin
index 49edb240c..3cdff737e 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4-dev.bin and b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4-dev.bin.sign b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4-dev.bin.sign
index b8963fd42..a0e1bba15 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4-dev.bin.sign and b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4.bin b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4.bin
index 5be707b4d..e2a2f28f0 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4.bin and b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4.bin.sign b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4.bin.sign
index 308d9747e..3da96c8c4 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4.bin.sign and b/tools/alif/alif/SP-AE512F80F55D5AS-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2-dev.bin b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2-dev.bin
index 9e8dcf9ee..70c252454 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2-dev.bin and b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2-dev.bin.sign b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2-dev.bin.sign
index 29fc908b1..d9da0d436 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2-dev.bin.sign and b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2.bin b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2.bin
index 3d2be604f..375be50c8 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2.bin and b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2.bin.sign b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2.bin.sign
index 8b80d2387..9ff39ada2 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2.bin.sign and b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b2.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3-dev.bin b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3-dev.bin
index 04fb94c10..5be74d50a 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3-dev.bin and b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3-dev.bin.sign b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3-dev.bin.sign
index f52db6536..bd7f1558e 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3-dev.bin.sign and b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3.bin b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3.bin
index 1bee374f2..ab5693a72 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3.bin and b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3.bin.sign b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3.bin.sign
index 1426db826..667519c7c 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3.bin.sign and b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4-dev.bin b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4-dev.bin
index 4900944b4..58571601b 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4-dev.bin and b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4-dev.bin.sign b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4-dev.bin.sign
index 2d38cba92..638b70f00 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4-dev.bin.sign and b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4.bin b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4.bin
index cae39a6b8..cc299b458 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4.bin and b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4.bin differ
diff --git a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4.bin.sign b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4.bin.sign
index 7a66622f6..8d788309a 100755
Binary files a/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4.bin.sign and b/tools/alif/alif/SP-AE512F80F55D5LS-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2-dev.bin b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2-dev.bin
index 876961b4b..da2301092 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2-dev.bin and b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2-dev.bin.sign b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2-dev.bin.sign
index 5d8ce0963..6f1291d11 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2-dev.bin.sign and b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2.bin b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2.bin
index f8e6a1354..f19033112 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2.bin and b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2.bin differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2.bin.sign b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2.bin.sign
index 4e5860cb9..cbc491c14 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2.bin.sign and b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b2.bin.sign differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3-dev.bin b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3-dev.bin
index 7ae08925f..ec7be23cc 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3-dev.bin and b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3-dev.bin.sign b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3-dev.bin.sign
index 26a333741..3a9fe44ff 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3-dev.bin.sign and b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3.bin b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3.bin
index 50fd0a967..873963c7a 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3.bin and b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3.bin differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3.bin.sign b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3.bin.sign
index e1e700515..1fd04a875 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3.bin.sign and b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4-dev.bin b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4-dev.bin
index 4c4f14efc..96e90876d 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4-dev.bin and b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4-dev.bin.sign b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4-dev.bin.sign
index a003645f2..20e675b60 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4-dev.bin.sign and b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4.bin b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4.bin
index 32a447220..97b867067 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4.bin and b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4.bin differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4.bin.sign b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4.bin.sign
index f1095ddd8..a26342256 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4.bin.sign and b/tools/alif/alif/SP-AE722F80F55D5AS-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2-dev.bin b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2-dev.bin
index f7894c0fb..43101169c 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2-dev.bin and b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2-dev.bin.sign b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2-dev.bin.sign
index a0a08ee8c..0f052251e 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2-dev.bin.sign and b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2.bin b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2.bin
index 09dbce978..aef4c27b8 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2.bin and b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2.bin differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2.bin.sign b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2.bin.sign
index 5e0b8dd91..129e8a595 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2.bin.sign and b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b2.bin.sign differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3-dev.bin b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3-dev.bin
index bb046613f..81f87b0f5 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3-dev.bin and b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3-dev.bin.sign b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3-dev.bin.sign
index 74233108a..72cf1508e 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3-dev.bin.sign and b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3.bin b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3.bin
index 50b2f570e..8d9995194 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3.bin and b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3.bin differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3.bin.sign b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3.bin.sign
index d71022600..ac4f9d595 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3.bin.sign and b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4-dev.bin b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4-dev.bin
index b540e30e4..08b88ca09 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4-dev.bin and b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4-dev.bin.sign b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4-dev.bin.sign
index 1f7650ea4..0ab566d47 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4-dev.bin.sign and b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4.bin b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4.bin
index 5c6c3b77c..3228eb5bd 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4.bin and b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4.bin differ
diff --git a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4.bin.sign b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4.bin.sign
index ce9a6f0e8..c7521f03e 100755
Binary files a/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4.bin.sign and b/tools/alif/alif/SP-AE722F80F55D5LS-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/offset-08-rev-a0-dev.bin b/tools/alif/alif/offset-08-rev-a0-dev.bin
new file mode 100755
index 000000000..475c82b44
Binary files /dev/null and b/tools/alif/alif/offset-08-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/offset-08-rev-a0-dev.bin.sign b/tools/alif/alif/offset-08-rev-a0-dev.bin.sign
index d51feac14..781991c7d 100755
Binary files a/tools/alif/alif/offset-08-rev-a0-dev.bin.sign and b/tools/alif/alif/offset-08-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/offset-08-rev-a0.bin b/tools/alif/alif/offset-08-rev-a0.bin
new file mode 100755
index 000000000..475c82b44
Binary files /dev/null and b/tools/alif/alif/offset-08-rev-a0.bin differ
diff --git a/tools/alif/alif/offset-08-rev-a0.bin.sign b/tools/alif/alif/offset-08-rev-a0.bin.sign
index d74565ed5..d7d8ae477 100755
Binary files a/tools/alif/alif/offset-08-rev-a0.bin.sign and b/tools/alif/alif/offset-08-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/offset-10-rev-a0-dev.bin b/tools/alif/alif/offset-10-rev-a0-dev.bin
new file mode 100755
index 000000000..27177c951
Binary files /dev/null and b/tools/alif/alif/offset-10-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/offset-10-rev-a0-dev.bin.sign b/tools/alif/alif/offset-10-rev-a0-dev.bin.sign
index e0505b50b..f846e8c8b 100755
Binary files a/tools/alif/alif/offset-10-rev-a0-dev.bin.sign and b/tools/alif/alif/offset-10-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/offset-10-rev-a0.bin b/tools/alif/alif/offset-10-rev-a0.bin
new file mode 100755
index 000000000..27177c951
Binary files /dev/null and b/tools/alif/alif/offset-10-rev-a0.bin differ
diff --git a/tools/alif/alif/offset-10-rev-a0.bin.sign b/tools/alif/alif/offset-10-rev-a0.bin.sign
index f8d8ed9ef..908ba5c6a 100755
Binary files a/tools/alif/alif/offset-10-rev-a0.bin.sign and b/tools/alif/alif/offset-10-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/offset-18-rev-b2-dev.bin.sign b/tools/alif/alif/offset-18-rev-b2-dev.bin.sign
index 654f376ce..7034c7dc3 100755
Binary files a/tools/alif/alif/offset-18-rev-b2-dev.bin.sign and b/tools/alif/alif/offset-18-rev-b2-dev.bin.sign differ
diff --git a/tools/alif/alif/offset-18-rev-b2.bin.sign b/tools/alif/alif/offset-18-rev-b2.bin.sign
index 6693e8c9d..d67f3b27b 100755
Binary files a/tools/alif/alif/offset-18-rev-b2.bin.sign and b/tools/alif/alif/offset-18-rev-b2.bin.sign differ
diff --git a/tools/alif/alif/offset-18-rev-b3-dev.bin.sign b/tools/alif/alif/offset-18-rev-b3-dev.bin.sign
index eaf21afce..a071b8273 100755
Binary files a/tools/alif/alif/offset-18-rev-b3-dev.bin.sign and b/tools/alif/alif/offset-18-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/offset-18-rev-b3.bin.sign b/tools/alif/alif/offset-18-rev-b3.bin.sign
index 9d3a76f4d..d1e8fbd5d 100755
Binary files a/tools/alif/alif/offset-18-rev-b3.bin.sign and b/tools/alif/alif/offset-18-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/offset-18-rev-b4-dev.bin.sign b/tools/alif/alif/offset-18-rev-b4-dev.bin.sign
index c405a3683..876eab8d6 100755
Binary files a/tools/alif/alif/offset-18-rev-b4-dev.bin.sign and b/tools/alif/alif/offset-18-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/offset-18-rev-b4.bin.sign b/tools/alif/alif/offset-18-rev-b4.bin.sign
index 2c5cacf8c..8fecd4833 100755
Binary files a/tools/alif/alif/offset-18-rev-b4.bin.sign and b/tools/alif/alif/offset-18-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/offset-1C-rev-a0-dev.bin b/tools/alif/alif/offset-1C-rev-a0-dev.bin
new file mode 100755
index 000000000..4d7559f84
Binary files /dev/null and b/tools/alif/alif/offset-1C-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/offset-1C-rev-a0-dev.bin.sign b/tools/alif/alif/offset-1C-rev-a0-dev.bin.sign
index e77631254..e5503063d 100755
Binary files a/tools/alif/alif/offset-1C-rev-a0-dev.bin.sign and b/tools/alif/alif/offset-1C-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/offset-1C-rev-a0.bin b/tools/alif/alif/offset-1C-rev-a0.bin
new file mode 100755
index 000000000..4d7559f84
Binary files /dev/null and b/tools/alif/alif/offset-1C-rev-a0.bin differ
diff --git a/tools/alif/alif/offset-1C-rev-a0.bin.sign b/tools/alif/alif/offset-1C-rev-a0.bin.sign
index 73e483bde..4588f1a4d 100755
Binary files a/tools/alif/alif/offset-1C-rev-a0.bin.sign and b/tools/alif/alif/offset-1C-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/offset-1D-rev-a0-dev.bin b/tools/alif/alif/offset-1D-rev-a0-dev.bin
new file mode 100755
index 000000000..2a08aad1e
Binary files /dev/null and b/tools/alif/alif/offset-1D-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/offset-1D-rev-a0-dev.bin.sign b/tools/alif/alif/offset-1D-rev-a0-dev.bin.sign
index 592ea5f5c..1cf138715 100755
Binary files a/tools/alif/alif/offset-1D-rev-a0-dev.bin.sign and b/tools/alif/alif/offset-1D-rev-a0-dev.bin.sign differ
diff --git a/tools/alif/alif/offset-1D-rev-a0.bin b/tools/alif/alif/offset-1D-rev-a0.bin
new file mode 100755
index 000000000..2a08aad1e
Binary files /dev/null and b/tools/alif/alif/offset-1D-rev-a0.bin differ
diff --git a/tools/alif/alif/offset-1D-rev-a0.bin.sign b/tools/alif/alif/offset-1D-rev-a0.bin.sign
index 0dfeaeb4e..d73627dc7 100755
Binary files a/tools/alif/alif/offset-1D-rev-a0.bin.sign and b/tools/alif/alif/offset-1D-rev-a0.bin.sign differ
diff --git a/tools/alif/alif/offset-58-rev-b2-dev.bin.sign b/tools/alif/alif/offset-58-rev-b2-dev.bin.sign
index e9274a0c5..685053ce2 100755
Binary files a/tools/alif/alif/offset-58-rev-b2-dev.bin.sign and b/tools/alif/alif/offset-58-rev-b2-dev.bin.sign differ
diff --git a/tools/alif/alif/offset-58-rev-b2.bin.sign b/tools/alif/alif/offset-58-rev-b2.bin.sign
index 74d914512..5178c9bd5 100755
Binary files a/tools/alif/alif/offset-58-rev-b2.bin.sign and b/tools/alif/alif/offset-58-rev-b2.bin.sign differ
diff --git a/tools/alif/alif/offset-58-rev-b3-dev.bin.sign b/tools/alif/alif/offset-58-rev-b3-dev.bin.sign
index cc2beb667..6ce4cdf66 100755
Binary files a/tools/alif/alif/offset-58-rev-b3-dev.bin.sign and b/tools/alif/alif/offset-58-rev-b3-dev.bin.sign differ
diff --git a/tools/alif/alif/offset-58-rev-b3.bin.sign b/tools/alif/alif/offset-58-rev-b3.bin.sign
index 5eb44be9e..a170054b9 100755
Binary files a/tools/alif/alif/offset-58-rev-b3.bin.sign and b/tools/alif/alif/offset-58-rev-b3.bin.sign differ
diff --git a/tools/alif/alif/offset-58-rev-b4-dev.bin.sign b/tools/alif/alif/offset-58-rev-b4-dev.bin.sign
index efe7e4fc9..198183f9e 100755
Binary files a/tools/alif/alif/offset-58-rev-b4-dev.bin.sign and b/tools/alif/alif/offset-58-rev-b4-dev.bin.sign differ
diff --git a/tools/alif/alif/offset-58-rev-b4.bin.sign b/tools/alif/alif/offset-58-rev-b4.bin.sign
index 884efc768..e5957f2a2 100755
Binary files a/tools/alif/alif/offset-58-rev-b4.bin.sign and b/tools/alif/alif/offset-58-rev-b4.bin.sign differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41010HH-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41010HH-rev-a0-dev.bin
new file mode 100755
index 000000000..a27ffdb9d
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41010HH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41010HH-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41010HH-rev-a0.bin
new file mode 100755
index 000000000..5b05fde29
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41010HH-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41010PH-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41010PH-rev-a0-dev.bin
new file mode 100755
index 000000000..dcd241f6b
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41010PH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41010PH-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41010PH-rev-a0.bin
new file mode 100755
index 000000000..0a9e914d7
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41010PH-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41820HH-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41820HH-rev-a0-dev.bin
new file mode 100755
index 000000000..100d0e804
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41820HH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41820HH-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41820HH-rev-a0.bin
new file mode 100755
index 000000000..c19d51a7b
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41820HH-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41820PH-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41820PH-rev-a0-dev.bin
new file mode 100755
index 000000000..7722007c8
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41820PH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41820PH-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41820PH-rev-a0.bin
new file mode 100755
index 000000000..e80dd7dc7
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F1M41820PH-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F4M51820HH-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F4M51820HH-rev-a0-dev.bin
new file mode 100755
index 000000000..8906e6eeb
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F4M51820HH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F4M51820HH-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F4M51820HH-rev-a0.bin
new file mode 100755
index 000000000..bc7f7fd32
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F4M51820HH-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F4M51820PH-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F4M51820PH-rev-a0-dev.bin
new file mode 100755
index 000000000..5dd8b76a3
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F4M51820PH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F4M51820PH-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F4M51820PH-rev-a0.bin
new file mode 100755
index 000000000..c09196244
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AB1C1F4M51820PH-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b2-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b2-dev.bin
new file mode 100755
index 000000000..3feb63ba4
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b2.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b2.bin
new file mode 100755
index 000000000..40d6af91c
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b2.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b3-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b3-dev.bin
new file mode 100755
index 000000000..a7ed79f07
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b3.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b3.bin
new file mode 100755
index 000000000..5afef81d1
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b3.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b4-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b4-dev.bin
new file mode 100755
index 000000000..b26b8403b
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b4.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b4.bin
new file mode 100755
index 000000000..0d74b9974
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE101F4071542LH-rev-b4.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F10405055H-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F10405055H-rev-a0-dev.bin
new file mode 100755
index 000000000..e60beb412
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F10405055H-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F10405055H-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F10405055H-rev-a0.bin
new file mode 100755
index 000000000..d9d91877a
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F10405055H-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1040505HH-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1040505HH-rev-a0-dev.bin
new file mode 100755
index 000000000..b9ab3823d
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1040505HH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1040505HH-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1040505HH-rev-a0.bin
new file mode 100755
index 000000000..000241754
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1040505HH-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1040505PH-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1040505PH-rev-a0-dev.bin
new file mode 100755
index 000000000..41f84701d
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1040505PH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1040505PH-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1040505PH-rev-a0.bin
new file mode 100755
index 000000000..08bdcc73f
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1040505PH-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F10410105H-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F10410105H-rev-a0-dev.bin
new file mode 100755
index 000000000..31b6c4a14
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F10410105H-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F10410105H-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F10410105H-rev-a0.bin
new file mode 100755
index 000000000..408c56d0d
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F10410105H-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1041010HH-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1041010HH-rev-a0-dev.bin
new file mode 100755
index 000000000..0e8f8a9e1
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1041010HH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1041010HH-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1041010HH-rev-a0.bin
new file mode 100755
index 000000000..325faea74
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1041010HH-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1041010PH-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1041010PH-rev-a0-dev.bin
new file mode 100755
index 000000000..ba125ee7d
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1041010PH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1041010PH-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1041010PH-rev-a0.bin
new file mode 100755
index 000000000..7fa5cb0dc
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F1041010PH-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F40319205H-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F40319205H-rev-a0-dev.bin
new file mode 100755
index 000000000..0aa13a7b0
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F40319205H-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F40319205H-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F40319205H-rev-a0.bin
new file mode 100755
index 000000000..e11da6b4d
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F40319205H-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F4051920HH-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F4051920HH-rev-a0-dev.bin
new file mode 100755
index 000000000..885ce66d5
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F4051920HH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F4051920HH-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F4051920HH-rev-a0.bin
new file mode 100755
index 000000000..e37b2f6f5
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F4051920HH-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F4051920PH-rev-a0-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F4051920PH-rev-a0-dev.bin
new file mode 100755
index 000000000..5c079fcba
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F4051920PH-rev-a0-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F4051920PH-rev-a0.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F4051920PH-rev-a0.bin
new file mode 100755
index 000000000..ed0767a3b
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE1C1F4051920PH-rev-a0.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b2-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b2-dev.bin
new file mode 100755
index 000000000..04d599e6e
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b2.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b2.bin
new file mode 100755
index 000000000..d4df7462b
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b2.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b3-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b3-dev.bin
new file mode 100755
index 000000000..69c770785
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b3.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b3.bin
new file mode 100755
index 000000000..3f782c91e
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b3.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b4-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b4-dev.bin
new file mode 100755
index 000000000..929262c72
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b4.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b4.bin
new file mode 100755
index 000000000..340a81c57
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F40C1537LE-rev-b4.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b2-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b2-dev.bin
new file mode 100755
index 000000000..eae7ab952
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b2.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b2.bin
new file mode 100755
index 000000000..119aad8ab
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b2.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b3-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b3-dev.bin
new file mode 100755
index 000000000..ba4c02df9
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b3.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b3.bin
new file mode 100755
index 000000000..39500f00b
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b3.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b4-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b4-dev.bin
new file mode 100755
index 000000000..20392cc91
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b4.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b4.bin
new file mode 100755
index 000000000..bfdc1ef34
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80C1557LE-rev-b4.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582AE-rev-b3-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582AE-rev-b3-dev.bin
new file mode 100755
index 000000000..f2de27b00
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582AE-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582AE-rev-b3.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582AE-rev-b3.bin
new file mode 100755
index 000000000..5f07afc05
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582AE-rev-b3.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582AE-rev-b4-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582AE-rev-b4-dev.bin
new file mode 100755
index 000000000..49e136bd7
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582AE-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582AE-rev-b4.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582AE-rev-b4.bin
new file mode 100755
index 000000000..49f2ecfe0
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582AE-rev-b4.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582LE-rev-b3-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582LE-rev-b3-dev.bin
new file mode 100755
index 000000000..03e6c9882
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582LE-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582LE-rev-b3.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582LE-rev-b3.bin
new file mode 100755
index 000000000..4c57b7cb6
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582LE-rev-b3.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582LE-rev-b4-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582LE-rev-b4-dev.bin
new file mode 100755
index 000000000..9ebe9ac49
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582LE-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582LE-rev-b4.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582LE-rev-b4.bin
new file mode 100755
index 000000000..047589885
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F5582LE-rev-b4.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b2-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b2-dev.bin
new file mode 100755
index 000000000..483aa0590
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b2.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b2.bin
new file mode 100755
index 000000000..bd1c4da38
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b2.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b3-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b3-dev.bin
new file mode 100755
index 000000000..f7314b923
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b3.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b3.bin
new file mode 100755
index 000000000..dd83740eb
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b3.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b4-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b4-dev.bin
new file mode 100755
index 000000000..9557fae8d
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b4.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b4.bin
new file mode 100755
index 000000000..efb7df553
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5AE-rev-b4.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b2-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b2-dev.bin
new file mode 100755
index 000000000..a8fbbfbc6
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b2.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b2.bin
new file mode 100755
index 000000000..85f8e75cb
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b2.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b3-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b3-dev.bin
new file mode 100755
index 000000000..a3e4b2ce3
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b3.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b3.bin
new file mode 100755
index 000000000..e0a0a55da
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b3.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b4-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b4-dev.bin
new file mode 100755
index 000000000..e11fe04e5
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b4.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b4.bin
new file mode 100755
index 000000000..3d593f824
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE302F80F55D5LE-rev-b4.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582AS-rev-b3-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582AS-rev-b3-dev.bin
new file mode 100755
index 000000000..b8ca06876
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582AS-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582AS-rev-b3.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582AS-rev-b3.bin
new file mode 100755
index 000000000..8874002a5
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582AS-rev-b3.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582AS-rev-b4-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582AS-rev-b4-dev.bin
new file mode 100755
index 000000000..2605841ca
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582AS-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582AS-rev-b4.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582AS-rev-b4.bin
new file mode 100755
index 000000000..8e4933e1c
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582AS-rev-b4.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582LS-rev-b3-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582LS-rev-b3-dev.bin
new file mode 100755
index 000000000..3d4248166
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582LS-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582LS-rev-b3.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582LS-rev-b3.bin
new file mode 100755
index 000000000..27bb97b8d
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582LS-rev-b3.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582LS-rev-b4-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582LS-rev-b4-dev.bin
new file mode 100755
index 000000000..877afbb06
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582LS-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582LS-rev-b4.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582LS-rev-b4.bin
new file mode 100755
index 000000000..5b28d2d5a
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F5582LS-rev-b4.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b2-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b2-dev.bin
new file mode 100755
index 000000000..fef57c2f4
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b2.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b2.bin
new file mode 100755
index 000000000..2d1e37cc0
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b2.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b3-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b3-dev.bin
new file mode 100755
index 000000000..e941f4b29
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b3.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b3.bin
new file mode 100755
index 000000000..70788e72b
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b3.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b4-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b4-dev.bin
new file mode 100755
index 000000000..479b997dc
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b4.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b4.bin
new file mode 100755
index 000000000..ff9481f62
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5AS-rev-b4.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b2-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b2-dev.bin
new file mode 100755
index 000000000..5e26dd8de
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b2.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b2.bin
new file mode 100755
index 000000000..92b865eb1
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b2.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b3-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b3-dev.bin
new file mode 100755
index 000000000..54c04292c
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b3.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b3.bin
new file mode 100755
index 000000000..4dc7d9636
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b3.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b4-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b4-dev.bin
new file mode 100755
index 000000000..6fe039e4c
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b4.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b4.bin
new file mode 100755
index 000000000..2c496d5bb
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE512F80F55D5LS-rev-b4.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b2-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b2-dev.bin
new file mode 100755
index 000000000..b46f35d0e
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b2.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b2.bin
new file mode 100755
index 000000000..5203ff478
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b2.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b3-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b3-dev.bin
new file mode 100755
index 000000000..974cc2333
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b3.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b3.bin
new file mode 100755
index 000000000..d5b6475c8
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b3.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b4-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b4-dev.bin
new file mode 100755
index 000000000..4afe32e03
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b4.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b4.bin
new file mode 100755
index 000000000..82e40349c
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5AS-rev-b4.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b2-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b2-dev.bin
new file mode 100755
index 000000000..4e954672a
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b2-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b2.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b2.bin
new file mode 100755
index 000000000..3dc181e8d
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b2.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b3-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b3-dev.bin
new file mode 100755
index 000000000..46ce37c14
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b3-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b3.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b3.bin
new file mode 100755
index 000000000..a7d9581ab
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b3.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b4-dev.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b4-dev.bin
new file mode 100755
index 000000000..1c39265ef
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b4-dev.bin differ
diff --git a/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b4.bin b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b4.bin
new file mode 100755
index 000000000..858116fa1
Binary files /dev/null and b/tools/alif/alif/upd-packages/full-upd-SP-AE722F80F55D5LS-rev-b4.bin differ
diff --git a/tools/alif/app-write-mram.py b/tools/alif/app-write-mram.py
index 12f68d091..3f17cc4d7 100755
--- a/tools/alif/app-write-mram.py
+++ b/tools/alif/app-write-mram.py
@@ -1,376 +1,397 @@
-#!/usr/bin/env python3
-"""
- MRAM (NVM) burning / writing utility
- Support
- - APPLICATION TOC package writing
- - image write at any address in NVM (MRAM)
- - image erase of any | range of addresses in NVM (MRAM)
-
- __author__ = ""
- __copyright__ = "ALIF Seminconductor"
- __version__ = "0.16.0"
- __status__ = "Dev" "
-"""
-import os
-import sys
-import signal
-import argparse
-from utils.discover import getValues, getJlinkSN
-import utils.config
-from utils.config import *
-from utils.user_validations import validateArgList
-sys.path.append("./isp")
-from serialport import serialPort
-from serialport import COM_BAUD_RATE_MAXIMUM
-#import ispcommands
-from isp_core import *
-from isp_util import *
-import pylink
-import datetime
-#from array import array
-
-# Version Feature
-# 0.22.000 Added support for MAC OS (J-Link not included yet)
-# 0.21.000 get baudrate from DBs
-# 0.20.007 Added padding option for binaries not multiple of 16
-# 0.20.006 Added Python error exit code
-# 0.20.005 Fixed J-Link+Pylink issue writing binaries
-# 0.20.004 REV_A0 dynamic baud rate support
-# 0.20.003 remove maintenance mode output unless -v is used)
-# 0.20.002 Reset option set as default
-# 0.20.001 Added Erase option
-# 0.20.000 Added option to skip user managed images
-# 0.19.000 Removed JTAG access
-# 0.16.000 Addition of baud rate increase for bulk transfer
-# 0.15.000 Fixes for Block sizes and left overs
-TOOL_VERSION ="0.22.000" # Define Version constant for each separate tool
-
-EXIT_WITH_ERROR = 1
-
-def readImageList(dsFile):
- """
- readImageList = read images from arm-ds command file
- """
- try:
- f = open(dsFile, 'r')
- imageList = f.read()
- f.close()
- # search for image list
- start = imageList.find('args')
- end = imageList.find('continue')
- if start == -1 or end == -1:
- print('[ERROR] There is a problem with the Debug Script information')
- sys.exit(EXIT_WITH_ERROR)
- imageList = imageList[start + 5: end]
- except:
- print('[ERROR] opening Debug Script file',dsFile)
- sys.exit(EXIT_WITH_ERROR)
-
- return imageList
-
-def app_mram_erase(isp,args, ALIF_BASE_ADDRESS, ALIF_MRAM_SIZE):
- """
- app_mram_erase
- - erase the Application are of MRAM
- args
- argv[0] 'erase' Operation, can be ignored
- argv[1]
Starting address
- argv{2] Length of bytes to erase
- argv[3] Optional pattern to erase with
- argc Checked before this is called
- """
- argv = args.split()
- argc = len(argv)
-
- # nombres magiques, maybe not needed?
- address = 0x80000000
- erase_len = 16
- pattern = 0x00000000
-
- if argc >= 3:
- address = int(argv[1],base=16)
- erase_len = int(argv[2],base=16)
- erase_len_fmt = "{:,}".format(erase_len)
-
- if argc == 4:
- pattern = int(argv[3],base=16)
- print("[INFO] %s 0x%x %d (%s)" %(argv[0],address,erase_len,
- erase_len_fmt))
-
- # Validate user request for erasing is in OEM
- if (address > ALIF_BASE_ADDRESS or
- address + erase_len > ALIF_BASE_ADDRESS):
-
- if address + erase_len > ALIF_BASE_ADDRESS:
- print("[ERROR] illegal address " + hex(address+erase_len) +
- " (" + hex(address) + " + " + hex(erase_len) + ")")
- else:
- print("[ERROR] illegal address " + hex(address))
- return
-
- isp_mram_erase(isp,address,erase_len,pattern)
-
-def main():
- if sys.version_info.major == 2:
- print("[ERROR] You need Python 3 for this application!")
- sys.exit(EXIT_WITH_ERROR)
-
- exit_code = 0
- # Deal with Command Line
- parser = argparse.ArgumentParser(description=
- 'NVM Burner for Application TOC Package')
- parser.add_argument("-d" , "--discover", action='store_true', \
- default=False, help="COM port discovery")
- parser.add_argument("-b", "--baudrate", help="serial port baud rate",
- type=int)
- parser.add_argument("-e", "--erase", type=str,
- help='ERASE [APP | [] ]')
- # creating a mutually exclusive group for -i IMAGES and -S
- # (skip option doesn't make sense in a user provided list...)
- group = parser.add_mutually_exclusive_group()
- group.add_argument("-i", "--images", type=str,
- default="Application TOC Package",
- help='images list to burn into NVM \
- ("/path/image1.bin 0x80001000 /path/image2.bin 0x80003000")')
- parser.add_argument("-a", "--auth_image", action='store_true',
- help="authenticate the image by sending its signature file",
- default=False)
- parser.add_argument("-m", "--method", type=str,
- help="loading method [JTAG | ISP]")
- group.add_argument("-S", "--skip",
- help='write ATOC only - skip user managed images',
- action="store_true")
- parser.add_argument("-s", "--switch",
- help="dynamic baud rate switch toggle, default=on",
- action="store_false")
- parser.add_argument("-p", "--pad",
- help="pad the binary if size is not multiple of 16", action="store_true")
- parser.add_argument("-nr", "--no_reset", default=False,
- help="do not reset target before operation", action="store_true")
- parser.add_argument("-V" , "--version",
- help="Display Version Number", action="store_true")
- parser.add_argument("-v" , "--verbose",
- help="verbosity mode", action="store_true")
-
- args = parser.parse_args()
- if args.version:
- print(TOOL_VERSION)
- sys.exit()
-
- # memory defines for Alif/OEM MRAM Addresses and Sizes
- load_global_config()
- DEVICE_PART_NUMBER = utils.config.DEVICE_PART_NUMBER
- DEVICE_REVISION = utils.config.DEVICE_REVISION
- DEVICE_REV_BAUD_RATE = utils.config.DEVICE_REV_BAUD_RATE
- MRAM_BASE_ADDRESS = utils.config.MRAM_BASE_ADDRESS
- ALIF_BASE_ADDRESS = utils.config.ALIF_BASE_ADDRESS
- OEM_BASE_ADDRESS = utils.config.APP_BASE_ADDRESS
- MRAM_SIZE = utils.config.MRAM_SIZE
- ALIF_MRAM_SIZE = utils.config.ALIF_MRAM_SIZE
- OEM_MRAM_SIZE = utils.config.APP_MRAM_SIZE
- MRAM_BURN_INTERFACE = utils.config.MRAM_BURN_INTERFACE
- JTAG_ADAPTER = utils.config.JTAG_ADAPTER
-
- os.system('') # Help MS-DOS window with ESC sequences
-
- print('Writing MRAM with parameters:')
- print('Device Part# ' + DEVICE_PART_NUMBER + ' - Rev: ' + DEVICE_REVISION)
- print('- Available MRAM: ' + str(OEM_MRAM_SIZE) + ' bytes')
-
-# baud_rate = args.baudrate
-# if DEVICE_REVISION == 'A0':
-# """
-# For REV_A0 we need to change the default used by ALL other devices
-# """
-# default_baud_rate = COM_BAUD_RATE_REV_A0
-# if baud_rate == COM_BAUD_RATE_DEFAULT:
-# baud_rate = default_baud_rate
-# else:
-# default_baud_rate = COM_BAUD_RATE_DEFAULT
-# baud_rate = args.baudrate
-
-# if baud_rate != default_baud_rate:
-# dynamic_baud_rate_switch = False
-# else:
-# dynamic_baud_rate_switch = args.switch
-
- baud_rate = DEVICE_REV_BAUD_RATE[DEVICE_REVISION]
- if args.baudrate is not None:
- baud_rate = args.baudrate
-
- dynamic_baud_rate_switch = args.switch
-
- argList = ''
- action = 'Burning: '
- method = None
-
- if args.method == None:
- method = MRAM_BURN_INTERFACE
- elif args.method.upper() == 'ISP':
- method = 'isp'
- elif args.method.upper() == 'JTAG':
- method = 'jtag'
- else:
- print("[ERROR] Unknown connection method", args.method)
- sys.exit(EXIT_WITH_ERROR)
-
- if args.erase:
- action = 'Erasing: '
- argList = 'erase '
- if args.erase.upper() == 'APP':
- argList += hex(OEM_BASE_ADDRESS) + ' ' + hex(OEM_MRAM_SIZE)
- else:
- if args.erase.strip() == '':
- print("[ERROR] erase arguments are empty")
- sys.exit(EXIT_WITH_ERROR)
- argList += args.erase
- elif args.images != "Application TOC Package":
- argList = args.images
- else:
- dsFile = 'bin/application_package.ds'
- argList = readImageList(dsFile)
-
- if args.skip:
- idx = argList.find('../build/AppTocPackage.bin 0x')
- argList = argList[idx: idx + 37]
-
- # validate all parameters
- argList = validateArgList(action, argList.strip(), args.pad)
-
- if sys.platform == "linux" or sys.platform == "darwin":
- argList = argList.replace('../','')
-
- print("[INFO]", action + argList)
-
-
- if method == 'jtag' and not args.erase: # erase via jtag not yet supported!
- jlinkSN = getJlinkSN()
- if jlinkSN == -1:
- print('J-Link device not found!')
- sys.exit(EXIT_WITH_ERROR)
-
- print('J-Link SN: ' + jlinkSN)
-
- jlink = pylink.JLink()
- jlink.open(serial_no=int(jlinkSN))
- print(jlink.product_name)
- if not jlink.opened():
- print('Error opening J-Link')
- sys.exit(EXIT_WITH_ERROR)
-
- if not jlink.connected():
- print('Error connecting J-Link')
- sys.exit(EXIT_WITH_ERROR)
-
- print("about to connect to M0+..")
- jlink.connect("CORTEX-M0+", verbose=True)
- #jlink.connect('AC302F8A82562_HE', verbose=True)
- if not jlink.target_connected():
- print('Error connecting target')
- print('Please, power-cycle the board')
- sys.exit(EXIT_WITH_ERROR)
-
- argParams = argList.strip().split(" ")
- lenParams = len(argParams)
- i = 0
- while i < lenParams:
- f = argParams[i][3:]
- if sys.platform == "linux":
- f = argParams[i][:]
-
- print('File name: ' + f)
- file_size = os.path.getsize(f)
- print("File Size is :", file_size, "bytes")
- print('MRAM starting address: ' + argParams[i+1])
- addr = globalToLocalAddress(argParams[i+1])
- print("Writing the file to MRAM...")
- # read the file
- f = open(f,"rb")
- #fileData = array("I")
- #fileData.fromfile(f, int(file_size/4))
- fileData = list(f.read(file_size))
- f.close()
-
- # write the data to MRAM
- t1 = datetime.datetime.now()
- #jlink.memory_write32(int(addr, 16), fileData)
- jlink.memory_write8(int(addr, 16), fileData)
- t2 = datetime.datetime.now()
- print('Done in ' + str(t2-t1))
- i += 2
-
- #jlink.reset() # the reset causes an issue and the board will need to power cycle...
-
- return # end jlink tests
-
- if method == 'jtag' and args.erase: # erase via jtag not yet supported!
- print('[INFO] Erase is only supported via ISP')
-
- dynamic_string = "Enabled" if dynamic_baud_rate_switch else "Disabled"
- print("[INFO] baud rate ", baud_rate)
- print("[INFO] dynamic baud rate change ", dynamic_string)
-
- handler = CtrlCHandler()
- isp = serialPort(baud_rate) # Serial dabbling open up port.
-
- if args.discover: # discover the COM ports if requested
- isp.discoverSerialPorts()
-
- errorCode = isp.openSerial()
- if errorCode is False:
- print("[ERROR] isp openSerial failed for %s" %isp.getPort())
- sys.exit(EXIT_WITH_ERROR)
-
- print("[INFO] %s open Serial port success" %isp.getPort())
-
- isp.setBaudRate(baud_rate)
- isp.setVerbose(args.verbose)
-
- if not args.no_reset:
- put_target_in_maintenance_mode(isp, baud_rate, args.verbose)
-
- if sys.platform == "linux" or sys.platform == "darwin":
- argList = argList.replace('\\','/')
- else:
- argList = argList.replace('/','\\')
-
- items = argList.split(' ')
-
- isp_start(isp) # Start ISP Sequence
-
- if args.erase:
- app_mram_erase(isp,argList,ALIF_BASE_ADDRESS, ALIF_MRAM_SIZE)
- else:
- if dynamic_baud_rate_switch:
- isp_set_baud_rate(isp,COM_BAUD_RATE_MAXIMUM) # Jack up Baud rate
- isp.setBaudRate(COM_BAUD_RATE_MAXIMUM) # Sets the HOST baud rate
-
- # issue enquiry command to check if SERAM is in Maintenance Mode
- mode = isp_get_maintenance_status(isp)
- isp_show_maintenance_mode(isp, mode)
-
- for e in range(1, len(items),2):
- addr = items[e]
- address = int(addr,base=16)
- fileName = items[e-1]
- fileName = fileName.replace('..\\','')
-
- if burn_mram_isp(isp, handler, fileName, address,
- args.verbose, args.auth_image) == False:
-
- exit_code = EXIT_WITH_ERROR
- break
-
- # Restore the default Baud rate
- if dynamic_baud_rate_switch:
- isp_set_baud_rate(isp,baud_rate)
- isp.setBaudRate(baud_rate)
-
- isp_stop(isp) # Stop ISP Sequence
- isp_reset(isp)
-
- isp.closeSerial()
- sys.exit(exit_code)
-
-if __name__ == "__main__":
- main()
+#!/usr/bin/env python3
+"""
+ MRAM (NVM) burning / writing utility
+ Support
+ - APPLICATION TOC package writing
+ - image write at any address in NVM (MRAM)
+ - image erase of any | range of addresses in NVM (MRAM)
+
+ __author__ = ""
+ __copyright__ = "ALIF Seminconductor"
+ __version__ = "0.16.0"
+ __status__ = "Dev" "
+"""
+import os
+import sys
+import signal
+import argparse
+from utils.discover import getValues, getJlinkSN
+import utils.config
+from utils.config import *
+from utils.user_validations import validateArgList
+sys.path.append("./isp")
+from serialport import serialPort
+from serialport import COM_BAUD_RATE_MAXIMUM
+#import ispcommands
+from isp_core import *
+from isp_util import *
+import device_probe
+import pylink
+import datetime
+#from array import array
+
+# Version Feature
+# 0.23.000 Added probing to detect device stage/Part#/Rev
+# 0.22.000 Added support for MAC OS (J-Link not included yet)
+# 0.21.000 get baudrate from DBs
+# 0.20.007 Added padding option for binaries not multiple of 16
+# 0.20.006 Added Python error exit code
+# 0.20.005 Fixed J-Link+Pylink issue writing binaries
+# 0.20.004 REV_A0 dynamic baud rate support
+# 0.20.003 remove maintenance mode output unless -v is used)
+# 0.20.002 Reset option set as default
+# 0.20.001 Added Erase option
+# 0.20.000 Added option to skip user managed images
+# 0.19.000 Removed JTAG access
+# 0.16.000 Addition of baud rate increase for bulk transfer
+# 0.15.000 Fixes for Block sizes and left overs
+TOOL_VERSION ="0.23.000" # Define Version constant for each separate tool
+
+EXIT_WITH_ERROR = 1
+
+def readImageList(dsFile):
+ """
+ readImageList = read images from arm-ds command file
+ """
+ try:
+ f = open(dsFile, 'r')
+ imageList = f.read()
+ f.close()
+ # search for image list
+ start = imageList.find('args')
+ end = imageList.find('continue')
+ if start == -1 or end == -1:
+ print('[ERROR] There is a problem with the Debug Script information')
+ sys.exit(EXIT_WITH_ERROR)
+ imageList = imageList[start + 5: end]
+ except:
+ print('[ERROR] opening Debug Script file',dsFile)
+ sys.exit(EXIT_WITH_ERROR)
+
+ return imageList
+
+def app_mram_erase(isp,args, ALIF_BASE_ADDRESS, ALIF_MRAM_SIZE):
+ """
+ app_mram_erase
+ - erase the Application are of MRAM
+ args
+ argv[0] 'erase' Operation, can be ignored
+ argv[1] Starting address
+ argv{2] Length of bytes to erase
+ argv[3] Optional pattern to erase with
+ argc Checked before this is called
+ """
+ argv = args.split()
+ argc = len(argv)
+
+ # nombres magiques, maybe not needed?
+ address = 0x80000000
+ erase_len = 16
+ pattern = 0x00000000
+
+ if argc >= 3:
+ address = int(argv[1],base=16)
+ erase_len = int(argv[2],base=16)
+ erase_len_fmt = "{:,}".format(erase_len)
+
+ if argc == 4:
+ pattern = int(argv[3],base=16)
+ print("[INFO] %s 0x%x %d (%s)" %(argv[0],address,erase_len,
+ erase_len_fmt))
+
+ # Validate user request for erasing is in OEM
+ if (address > ALIF_BASE_ADDRESS or
+ address + erase_len > ALIF_BASE_ADDRESS):
+
+ if address + erase_len > ALIF_BASE_ADDRESS:
+ print("[ERROR] illegal address " + hex(address+erase_len) +
+ " (" + hex(address) + " + " + hex(erase_len) + ")")
+ else:
+ print("[ERROR] illegal address " + hex(address))
+ return
+
+ isp_mram_erase(isp,address,erase_len,pattern)
+
+def main():
+ if sys.version_info.major == 2:
+ print("[ERROR] You need Python 3 for this application!")
+ sys.exit(EXIT_WITH_ERROR)
+
+ exit_code = 0
+ # Deal with Command Line
+ parser = argparse.ArgumentParser(description=
+ 'NVM Burner for Application TOC Package')
+ parser.add_argument("-d" , "--discover", action='store_true', \
+ default=False, help="COM port discovery")
+ parser.add_argument("-b", "--baudrate", help="serial port baud rate",
+ type=int)
+ parser.add_argument("-e", "--erase", type=str,
+ help='ERASE [APP | [] ]')
+ # creating a mutually exclusive group for -i IMAGES and -S
+ # (skip option doesn't make sense in a user provided list...)
+ group = parser.add_mutually_exclusive_group()
+ group.add_argument("-i", "--images", type=str,
+ default="Application TOC Package",
+ help='images list to burn into NVM \
+ ("/path/image1.bin 0x80001000 /path/image2.bin 0x80003000")')
+ parser.add_argument("-a", "--auth_image", action='store_true',
+ help="authenticate the image by sending its signature file",
+ default=False)
+ parser.add_argument("-m", "--method", type=str,
+ help="loading method [JTAG | ISP]")
+ group.add_argument("-S", "--skip",
+ help='write ATOC only - skip user managed images',
+ action="store_true")
+ parser.add_argument("-s", "--switch",
+ help="dynamic baud rate switch toggle, default=on",
+ action="store_false")
+ parser.add_argument("-p", "--pad",
+ help="pad the binary if size is not multiple of 16", action="store_true")
+ parser.add_argument("-nr", "--no_reset", default=False,
+ help="do not reset target before operation", action="store_true")
+ parser.add_argument("-V" , "--version",
+ help="Display Version Number", action="store_true")
+ parser.add_argument("-v" , "--verbose",
+ help="verbosity mode", action="store_true")
+
+ args = parser.parse_args()
+ if args.version:
+ print(TOOL_VERSION)
+ sys.exit()
+
+ # memory defines for Alif/OEM MRAM Addresses and Sizes
+ load_global_config()
+ DEVICE_PART_NUMBER = utils.config.DEVICE_PART_NUMBER
+ DEVICE_REVISION = utils.config.DEVICE_REVISION
+ DEVICE_REV_BAUD_RATE = utils.config.DEVICE_REV_BAUD_RATE
+ MRAM_BASE_ADDRESS = utils.config.MRAM_BASE_ADDRESS
+ ALIF_BASE_ADDRESS = utils.config.ALIF_BASE_ADDRESS
+ OEM_BASE_ADDRESS = utils.config.APP_BASE_ADDRESS
+ MRAM_SIZE = utils.config.MRAM_SIZE
+ ALIF_MRAM_SIZE = utils.config.ALIF_MRAM_SIZE
+ OEM_MRAM_SIZE = utils.config.APP_MRAM_SIZE
+ MRAM_BURN_INTERFACE = utils.config.MRAM_BURN_INTERFACE
+ JTAG_ADAPTER = utils.config.JTAG_ADAPTER
+
+ os.system('') # Help MS-DOS window with ESC sequences
+
+ print('Writing MRAM with parameters:')
+ print('Device Part# ' + DEVICE_PART_NUMBER + ' - Rev: ' + DEVICE_REVISION)
+ print('- Available MRAM: ' + str(OEM_MRAM_SIZE) + ' bytes')
+
+# baud_rate = args.baudrate
+# if DEVICE_REVISION == 'A0':
+# """
+# For REV_A0 we need to change the default used by ALL other devices
+# """
+# default_baud_rate = COM_BAUD_RATE_REV_A0
+# if baud_rate == COM_BAUD_RATE_DEFAULT:
+# baud_rate = default_baud_rate
+# else:
+# default_baud_rate = COM_BAUD_RATE_DEFAULT
+# baud_rate = args.baudrate
+
+# if baud_rate != default_baud_rate:
+# dynamic_baud_rate_switch = False
+# else:
+# dynamic_baud_rate_switch = args.switch
+
+ baud_rate = DEVICE_REV_BAUD_RATE[DEVICE_REVISION]
+ if args.baudrate is not None:
+ baud_rate = args.baudrate
+
+ dynamic_baud_rate_switch = args.switch
+
+ argList = ''
+ action = 'Burning: '
+ method = None
+
+ if args.method == None:
+ method = MRAM_BURN_INTERFACE
+ elif args.method.upper() == 'ISP':
+ method = 'isp'
+ elif args.method.upper() == 'JTAG':
+ method = 'jtag'
+ else:
+ print("[ERROR] Unknown connection method", args.method)
+ sys.exit(EXIT_WITH_ERROR)
+
+ if args.erase:
+ action = 'Erasing: '
+ argList = 'erase '
+ if args.erase.upper() == 'APP':
+ argList += hex(OEM_BASE_ADDRESS) + ' ' + hex(OEM_MRAM_SIZE)
+ else:
+ if args.erase.strip() == '':
+ print("[ERROR] erase arguments are empty")
+ sys.exit(EXIT_WITH_ERROR)
+ argList += args.erase
+ elif args.images != "Application TOC Package":
+ argList = args.images
+ else:
+ dsFile = 'bin/application_package.ds'
+ argList = readImageList(dsFile)
+
+ if args.skip:
+ idx = argList.find('../build/AppTocPackage.bin 0x')
+ argList = argList[idx: idx + 37]
+
+ # validate all parameters
+ argList = validateArgList(action, argList.strip(), args.pad)
+
+ if sys.platform == "linux" or sys.platform == "darwin":
+ argList = argList.replace('../','')
+
+ print("[INFO]", action + argList)
+
+
+ if method == 'jtag' and not args.erase: # erase via jtag not yet supported!
+ jlinkSN = getJlinkSN()
+ if jlinkSN == -1:
+ print('J-Link device not found!')
+ sys.exit(EXIT_WITH_ERROR)
+
+ print('J-Link SN: ' + jlinkSN)
+
+ jlink = pylink.JLink()
+ jlink.open(serial_no=int(jlinkSN))
+ print(jlink.product_name)
+ if not jlink.opened():
+ print('Error opening J-Link')
+ sys.exit(EXIT_WITH_ERROR)
+
+ if not jlink.connected():
+ print('Error connecting J-Link')
+ sys.exit(EXIT_WITH_ERROR)
+
+ print("about to connect to M0+..")
+ jlink.connect("CORTEX-M0+", verbose=True)
+ #jlink.connect('AC302F8A82562_HE', verbose=True)
+ if not jlink.target_connected():
+ print('Error connecting target')
+ print('Please, power-cycle the board')
+ sys.exit(EXIT_WITH_ERROR)
+
+ argParams = argList.strip().split(" ")
+ lenParams = len(argParams)
+ i = 0
+ while i < lenParams:
+ f = argParams[i][3:]
+ if sys.platform == "linux":
+ f = argParams[i][:]
+
+ print('File name: ' + f)
+ file_size = os.path.getsize(f)
+ print("File Size is :", file_size, "bytes")
+ print('MRAM starting address: ' + argParams[i+1])
+ addr = globalToLocalAddress(argParams[i+1])
+ print("Writing the file to MRAM...")
+ # read the file
+ f = open(f,"rb")
+ #fileData = array("I")
+ #fileData.fromfile(f, int(file_size/4))
+ fileData = list(f.read(file_size))
+ f.close()
+
+ # write the data to MRAM
+ t1 = datetime.datetime.now()
+ #jlink.memory_write32(int(addr, 16), fileData)
+ jlink.memory_write8(int(addr, 16), fileData)
+ t2 = datetime.datetime.now()
+ print('Done in ' + str(t2-t1))
+ i += 2
+
+ #jlink.reset() # the reset causes an issue and the board will need to power cycle...
+
+ return # end jlink tests
+
+ if method == 'jtag' and args.erase: # erase via jtag not yet supported!
+ print('[INFO] Erase is only supported via ISP')
+
+ dynamic_string = "Enabled" if dynamic_baud_rate_switch else "Disabled"
+ print("[INFO] baud rate ", baud_rate)
+ print("[INFO] dynamic baud rate change ", dynamic_string)
+
+ handler = CtrlCHandler()
+ isp = serialPort(baud_rate) # Serial dabbling open up port.
+
+ if args.discover: # discover the COM ports if requested
+ isp.discoverSerialPorts()
+
+ errorCode = isp.openSerial()
+ if errorCode is False:
+ print("[ERROR] isp openSerial failed for %s" %isp.getPort())
+ sys.exit(EXIT_WITH_ERROR)
+
+ print("[INFO] %s open Serial port success" %isp.getPort())
+
+ isp.setBaudRate(baud_rate)
+ isp.setVerbose(args.verbose)
+
+ # be sure device is not in SEROM Recovery Mode
+ device = device_probe.device_get_attributes(isp)
+ if device.stage != device_probe.STAGE_SERAM:
+ print('[ERROR] The device is in RECOVERY MODE! Please use Recovery option in Maintenance Tool to recover the device!')
+ sys.exit(EXIT_WITH_ERROR)
+
+ print('[INFO] Detected Device:')
+ partDetected = device.part_number
+ print('Part# ' + partDetected + ' - Rev: ' + device.revision)
+
+ partDescription = getPartDescription(partDetected)
+
+ if partDescription != DEVICE_PART_NUMBER:
+ print('[WARN] ************ Part# detected is different than the one configured in tools-config tool!')
+
+ if device.revision != DEVICE_REVISION:
+ print('[WARN] ************ Part Revision detected is different than the one configured in tools-config tool!')
+
+
+ if not args.no_reset:
+ put_target_in_maintenance_mode(isp, baud_rate, args.verbose)
+
+ if sys.platform == "linux" or sys.platform == "darwin":
+ argList = argList.replace('\\','/')
+ else:
+ argList = argList.replace('/','\\')
+
+ items = argList.split(' ')
+
+ isp_start(isp) # Start ISP Sequence
+
+ if args.erase:
+ app_mram_erase(isp,argList,ALIF_BASE_ADDRESS, ALIF_MRAM_SIZE)
+ else:
+ if dynamic_baud_rate_switch:
+ isp_set_baud_rate(isp,COM_BAUD_RATE_MAXIMUM) # Jack up Baud rate
+ isp.setBaudRate(COM_BAUD_RATE_MAXIMUM) # Sets the HOST baud rate
+
+ # issue enquiry command to check if SERAM is in Maintenance Mode
+ mode = isp_get_maintenance_status(isp)
+ isp_show_maintenance_mode(isp, mode)
+
+ for e in range(1, len(items),2):
+ addr = items[e]
+ address = int(addr,base=16)
+ fileName = items[e-1]
+ fileName = fileName.replace('..\\','')
+
+ if burn_mram_isp(isp, handler, fileName, address,
+ args.verbose, args.auth_image) == False:
+
+ exit_code = EXIT_WITH_ERROR
+ break
+
+ # Restore the default Baud rate
+ if dynamic_baud_rate_switch:
+ isp_set_baud_rate(isp,baud_rate)
+ isp.setBaudRate(baud_rate)
+
+ isp_stop(isp) # Stop ISP Sequence
+ isp_reset(isp)
+
+ isp.closeSerial()
+ sys.exit(exit_code)
+
+if __name__ == "__main__":
+ main()
diff --git a/tools/alif/build/config/app-device-config.json b/tools/alif/build/config/app-device-config.json
index 6f8c9d30a..ef3e186d3 100755
--- a/tools/alif/build/config/app-device-config.json
+++ b/tools/alif/build/config/app-device-config.json
@@ -1,49 +1,142 @@
-{
- "metadata": {
- "device": "AB1C1F4M51820PH",
- "project": "",
- "external_clock_sources": [
- {
- "id": "OSC_HFXO",
- "enabled": true,
- "frequency": 38400000
- },
- {
- "id": "OSC_LFXO",
- "enabled": false,
- "frequency": 32768
- }
- ]
- },
- "firewall": {
- "firewall_components": []
- },
- "pinmux": [],
- "clocks": {},
- "miscellaneous": [
- {
- "id": "LFXO_CAP_CTRL",
- "value": 8
- },
- {
- "id": "LFXO_GM_CTRL",
- "value": 15
- },
- {
- "id": "HFXO_CAP_CTRL",
- "value": 2
- },
- {
- "id": "HFXO_PFET_GM_CTRL",
- "value": 16
- },
- {
- "id": "HFXO_NFET_GM_CTRL",
- "value": 16
- },
- {
- "id": "SE_BOOT_INFO",
- "value": 1
- }
- ]
+{
+ "metadata": {
+ "device": "AE722F80F55D5AS",
+ "project": "",
+ "external_clock_sources": [
+ {
+ "id": "OSC_HFXO",
+ "enabled": true,
+ "frequency": 38400000
+ },
+ {
+ "id": "OSC_LFXO",
+ "enabled": false,
+ "frequency": 32768
+ }
+ ]
+ },
+ "firewall": {
+ "firewall_components": [
+ {
+ "component_id": 4,
+ "configured_regions": [
+ {
+ "region_index": 1,
+ "start_address": "0x08000000",
+ "end_address": "0xFFFFFFFF",
+ "size": "0x1B",
+ "addr_trans_en": false,
+ "mpe_list": [
+ {
+ "mpe_id": 0,
+ "any_master": true,
+ "master_id": 0,
+ "permissions": "0xfff"
+ }
+ ],
+ "mul_n_po2": false,
+ "ma_trans_en": false,
+ "translation_flags": "0x0"
+ }
+ ]
+ },
+ {
+ "component_id": 5,
+ "configured_regions": [
+ {
+ "region_index": 1,
+ "start_address": "0x02000000",
+ "end_address": "0xFFFFFFFF",
+ "size": "0x19",
+ "addr_trans_en": false,
+ "mpe_list": [
+ {
+ "mpe_id": 0,
+ "any_master": true,
+ "master_id": 0,
+ "permissions": "0xfff"
+ }
+ ],
+ "mul_n_po2": false,
+ "ma_trans_en": false,
+ "translation_flags": "0x0"
+ }
+ ]
+ },
+ {
+ "component_id": 11,
+ "configured_regions": [
+ {
+ "region_index": 1,
+ "start_address": "0x40000000",
+ "end_address": "0xFFFFFFFF",
+ "size": "0x1D",
+ "addr_trans_en": false,
+ "mpe_list": [
+ {
+ "mpe_id": 0,
+ "any_master": true,
+ "master_id": 0,
+ "permissions": "0xfff"
+ }
+ ],
+ "mul_n_po2": false,
+ "ma_trans_en": false,
+ "translation_flags": "0x0"
+ }
+ ]
+ },
+ {
+ "component_id": 12,
+ "configured_regions": [
+ {
+ "region_index": 1,
+ "start_address": "0x60000000",
+ "end_address": "0xFFFFFFFF",
+ "size": "0x1D",
+ "addr_trans_en": false,
+ "mpe_list": [
+ {
+ "mpe_id": 0,
+ "any_master": true,
+ "master_id": 0,
+ "permissions": "0xfff"
+ }
+ ],
+ "mul_n_po2": false,
+ "ma_trans_en": false,
+ "translation_flags": "0x0"
+ }
+ ]
+ }
+ ]
+ },
+ "pinmux": [],
+ "clocks": {},
+ "miscellaneous": [
+ {
+ "id": "LFXO_CAP_CTRL",
+ "value": 8
+ },
+ {
+ "id": "LFXO_GM_CTRL",
+ "value": 15
+ },
+ {
+ "id": "HFXO_CAP_CTRL",
+ "value": 8
+ },
+ {
+ "id": "HFXO_PFET_GM_CTRL",
+ "value": 16
+ },
+ {
+ "id": "HFXO_NFET_GM_CTRL",
+ "value": 16
+ },
+ {
+ "id": "SE_BOOT_INFO",
+ "value": 1
+ }
+ ]
}
\ No newline at end of file
diff --git a/tools/alif/build/images/app-device-config.bin b/tools/alif/build/images/app-device-config.bin
index 15733d788..10fb7dd18 100755
Binary files a/tools/alif/build/images/app-device-config.bin and b/tools/alif/build/images/app-device-config.bin differ
diff --git a/tools/alif/build/images/fw_temp.bin b/tools/alif/build/images/fw_temp.bin
index 9017fd98b..fa514d302 100755
Binary files a/tools/alif/build/images/fw_temp.bin and b/tools/alif/build/images/fw_temp.bin differ
diff --git a/tools/alif/cert/SBapp-device-config.bin_0x9057c950.crt b/tools/alif/cert/SBapp-device-config.bin_0x9057c950.crt
new file mode 100755
index 000000000..e1da41f16
Binary files /dev/null and b/tools/alif/cert/SBapp-device-config.bin_0x9057c950.crt differ
diff --git a/tools/alif/cert/SBm55_blink_he.bin_0x9057d480.crt b/tools/alif/cert/SBm55_blink_he.bin_0x9057d480.crt
new file mode 100755
index 000000000..911c4ca2c
Binary files /dev/null and b/tools/alif/cert/SBm55_blink_he.bin_0x9057d480.crt differ
diff --git a/tools/alif/docs/AUGD0005-Alif-Security-Toolkit-User-Guide-v1.103.0.pdf b/tools/alif/docs/AUGD0005-Alif-Security-Toolkit-User-Guide-v1.104.0.pdf
similarity index 74%
rename from tools/alif/docs/AUGD0005-Alif-Security-Toolkit-User-Guide-v1.103.0.pdf
rename to tools/alif/docs/AUGD0005-Alif-Security-Toolkit-User-Guide-v1.104.0.pdf
index 896b5de54..6eb53ab2f 100755
Binary files a/tools/alif/docs/AUGD0005-Alif-Security-Toolkit-User-Guide-v1.103.0.pdf and b/tools/alif/docs/AUGD0005-Alif-Security-Toolkit-User-Guide-v1.104.0.pdf differ
diff --git a/tools/alif/isp/clock_decode.py b/tools/alif/isp/clock_decode.py
index 05b467256..63f1a62f4 100755
--- a/tools/alif/isp/clock_decode.py
+++ b/tools/alif/isp/clock_decode.py
@@ -1,217 +1,217 @@
-#!/usr/bin/python3
-"""
- @brief Clock Info decode and display
-
- __author__ onyettr
-"""
-# pylint: disable=unused-argument, invalid-name, consider-using-f-string
-import struct
-import ctypes
-from isp_print import isp_print_color
-
-c_uint32 = ctypes.c_uint32
-
-PLL_CLK_STATUS_XTAL_STARTED = (1 << 0)
-PLL_CLK_STATUS_PLL_LOCKED = (1 << 1)
-PLL_CLK_STATUS_SE_CLOCK_PLL = (1 << 2)
-
-CLOCK_FREQUENCY_800MHZ = 0
-CLOCK_FREQUENCY_400MHZ = 1
-CLOCK_FREQUENCY_300MHZ = 2
-CLOCK_FREQUENCY_200MHZ = 3
-CLOCK_FREQUENCY_160MHZ = 4
-CLOCK_FREQUENCY_120MHZ = 5
-CLOCK_FREQUENCY_80MHZ = 6
-CLOCK_FREQUENCY_60MHZ = 7
-CLOCK_FREQUENCY_100MHZ = 8
-CLOCK_FREQUENCY_50MHZ = 9
-CLOCK_FREQUENCY_20MHZ = 10
-CLOCK_FREQUENCY_10MHZ = 11
-CLOCK_FREQUENCY_76_8_RC_MHZ = 12
-CLOCK_FREQUENCY_38_4_RC_MHZ = 13
-CLOCK_FREQUENCY_76_8_XO_MHZ = 14
-CLOCK_FREQUENCY_38_4_XO_MHZ = 15
-CLOCK_FREQUENCY_DISABLED = 16
-
-clk_frequency_lut = {
- CLOCK_FREQUENCY_800MHZ : "800Mhz",
- CLOCK_FREQUENCY_400MHZ : "400Mhz",
- CLOCK_FREQUENCY_300MHZ : "300Mhz",
- CLOCK_FREQUENCY_200MHZ : "200Mhz",
- CLOCK_FREQUENCY_160MHZ : "160Mhz",
- CLOCK_FREQUENCY_120MHZ : "120Mhz",
- CLOCK_FREQUENCY_80MHZ : "80Mhz",
- CLOCK_FREQUENCY_60MHZ : "60Mhz",
- CLOCK_FREQUENCY_100MHZ : "100Mhz",
- CLOCK_FREQUENCY_50MHZ : "50Mhz",
- CLOCK_FREQUENCY_20MHZ : "20Mhz" ,
- CLOCK_FREQUENCY_10MHZ : "10Mhz",
- CLOCK_FREQUENCY_76_8_RC_MHZ : "76.8Mhz RC",
- CLOCK_FREQUENCY_38_4_RC_MHZ : "38.4Mhz RC",
- CLOCK_FREQUENCY_76_8_XO_MHZ : "76.8Mhz XO",
- CLOCK_FREQUENCY_38_4_XO_MHZ : "38.4Mhz XO",
- CLOCK_FREQUENCY_DISABLED : "Disabled"
-}
-
-register_names = [
- "HOSTCPUCLK_CTRL", "HOSTCPUCLK_DIV0", "HOSTCPUCLK_DIV1", "ACLK_CTRL", "ACLK_DIV0",
- "OSC_CTRL", "PLL_LOCK_CTRL", "PLL_CLK_SEL", "ESCLK_SEL", "CLK_ENA",
- "SYSTOP_CLK_DIV", "MISC_REG1", "XO_REG1", "PD4_CLK_SEL", "PD4_CLK_PLL",
- "MISC_CTRL", "DCDC_REG1", "DCDC_REG2", "VBAT_ANA_REG1", "VBAT_ANA_REG2"
-]
-
-class xo_reg1_bits(ctypes.LittleEndianStructure):
- _fields_ = [
- ("en_xtal" , c_uint32, 1),
- ("faststart" , c_uint32, 1),
- ("__reserved__0" , c_uint32, 1),
- ("en_bfr_clkpll" , c_uint32, 1),
- ("en_bfr_dig_2x" , c_uint32, 1),
- ("en_bfr_dig" , c_uint32, 1),
- ("boost" , c_uint32, 1),
- ("xtal_cap" , c_uint32, 4),
- ("gm_pfet" , c_uint32, 5),
- ("gm_nfet" , c_uint32, 5),
- ("sel_doubler_output_duty_cycle" , c_uint32, 2),
- ("sel_doubler_input_duty_cycle" , c_uint32, 5),
- ("sel_ibg" , c_uint32, 1),
- ("ibres_cont" , c_uint32, 2),
- ("__reserved__1" , c_uint32, 1)
- ]
-class XO_REG1(ctypes.Union):
- _fields_ = [("b", xo_reg1_bits), ("w", c_uint32)]
-
-class vbat_ana_reg1_bits(ctypes.LittleEndianStructure):
- _fields_ = [
- ("osc_rc_32k_freq_cont" , c_uint32, 4),
- ("ret_ldo_cont_3_0" , c_uint32, 4),
- ("ret_ldo_vbat_en" , c_uint32, 1),
- ("ret_ldo_vbat_shunt_en" , c_uint32, 1),
- ("ret_ldo_vddmain_en" , c_uint32, 1),
- ("ret_ldo_vdd_main_shunt_en", c_uint32, 1),
- ("xtal32k_en" , c_uint32, 1),
- ("xtal32k_kick" , c_uint32, 1),
- ("lpcomp_clk32k_en" , c_uint32, 1),
- ("xtal32k_gm_cont" , c_uint32, 4),
- ("xtal32k_cap_cont" , c_uint32, 6),
- ("bor_en" , c_uint32, 1),
- ("bor_hyst" , c_uint32, 3),
- ("bor_thresh" , c_uint32, 3)
- ]
-class VBAT_ANA_REG1(ctypes.Union):
- _fields_ = [("b", vbat_ana_reg1_bits), ("w", c_uint32)]
-
-class vbat_ana_reg2_bits(ctypes.LittleEndianStructure):
- _fields_ = [
- ("__reserved__" , c_uint32, 1),
- ("pmubg_vref_cont" , c_uint32, 4),
- ("dig_ldo_18_en" , c_uint32, 1),
- ("dig_ldo_cont" , c_uint32, 4),
- ("osc_76Mrc_cont_bit0" , c_uint32, 1),
- ("osc_76M_div_cont_fast" , c_uint32, 3),
- ("osc_76Mrc_cont" , c_uint32, 5),
- ("osc_76M_div_cont_slow" , c_uint32, 3),
- ("ana_periph_bg_ena" , c_uint32, 1),
- ("ana_periph_LDO_en" , c_uint32, 1),
- ("comp_lp_en" , c_uint32, 1),
- ("comp_lp0_in_p_sel" , c_uint32, 2),
- ("comp_lp0_in_m_sel" , c_uint32, 2),
- ("comp_lp0_hyst" , c_uint32, 3)
- ]
-
-class VBAT_ANA_REG2(ctypes.Union):
- _fields_ = [("b", vbat_ana_reg2_bits), ("w", c_uint32)]
-
-
-def clk_frequency_to_string(clk_frequency):
- """
- Convert input to string
-
- @param clk_frequency:
- @return: string based on input
- """
-
- return clk_frequency_lut.get(clk_frequency)
-
-def clk_status_to_string(clk_status):
- """
- parse the bit fields and return a printable string
- @param clk_status: bit encoded values
- @return: string based on input
- """
- status_string = ''
- if clk_status & PLL_CLK_STATUS_XTAL_STARTED:
- status_string += " HFXTAL STARTED\n"
- else:
- status_string += " HFXTAL OFF\n"
- if clk_status & PLL_CLK_STATUS_PLL_LOCKED:
- status_string += " PLL LOCKED\n"
- else:
- status_string += " PLL OFF\n"
- if clk_status & PLL_CLK_STATUS_SE_CLOCK_PLL:
- status_string += " SE CLOCK: PLL\n"
- else:
- status_string += " SE CLOCK: HFRC\n"
-
- return status_string
-
-def display_clock_info(message):
- """
- display clock, pll, xtal entries sent back from Target
- message -- ISP data to parse
- """
-
- # word 0 is the status word
- (status,) = struct.unpack("> 8
- isp_print_color("blue" ,"CLK freq A32 %s\n" % (clk_frequency_to_string(frequency)))
- # M55-HP frequency
- frequency = (status & 0x00FF0000) >> 16
- isp_print_color("blue" ,"CLK freq ES0 %s\n" % (clk_frequency_to_string(frequency)))
- # M55-HE frequency
- frequency = (status & 0xFF000000) >> 24
- isp_print_color("blue" ,"CLK freq ES1 %s\n" % (clk_frequency_to_string(frequency)))
-
- # word 1 is the CM0+ frequency
- (cm0_freq,) = struct.unpack("> 8
+ isp_print_color("blue" ,"CLK freq A32 %s\n" % (clk_frequency_to_string(frequency)))
+ # M55-HP frequency
+ frequency = (status & 0x00FF0000) >> 16
+ isp_print_color("blue" ,"CLK freq M55-HP %s\n" % (clk_frequency_to_string(frequency)))
+ # M55-HE frequency
+ frequency = (status & 0xFF000000) >> 24
+ isp_print_color("blue" ,"CLK freq M55-HE %s\n" % (clk_frequency_to_string(frequency)))
+
+ # word 1 is the CM0+ frequency
+ (cm0_freq,) = struct.unpack("= TOC_IMAGE_CPU_LAST: # valid values [0..8]
+ continue
+ if booted > 1: # valid values: 0 or 1
+ continue
+
+ boot_string = "YES" if booted else " "
+
+ isp_print_color("blue",
+ " |%7s |%6s| %10s |\n" % (
+ format_cpu(cpu_id),
+ boot_string.center(6),
+ format_hex(address)
+ ))
+
+ isp_print_color("blue", " +--------+------+------------+\n")
+ print(" ")
diff --git a/tools/alif/isp/device_probe.py b/tools/alif/isp/device_probe.py
index 4270f58e7..d0746d44b 100755
--- a/tools/alif/isp/device_probe.py
+++ b/tools/alif/isp/device_probe.py
@@ -1,125 +1,134 @@
-#!/usr/bin/env python3
-"""
- device_probe.py
- discovery class for finding out what is on the other end of the SE-UART
-"""
-import struct
-from isp_core import isp_start
-from isp_core import isp_stop
-from isp_core import isp_build_packet
-from isp_protocol import ISP_COMMAND_DATA_RESPONSE
-from isp_protocol import ISP_COMMAND_ENQUIRY
-from isp_protocol import ISP_COMMAND_GET
-from isp_protocol import ISP_PACKET_DATA_FIELD
-from isp_protocol import ISP_PACKET_COMMAND_FIELD
-from isp_protocol import ISP_SOURCE_SEROM
-from isp_protocol import ISP_SOURCE_SERAM
-from isp_protocol import ISP_GET_REVISION
-
-# Part# & Rev definitions
-PART_UNKNOWN = 0
-REVISIONS = {
- '0 0 0 0' : 'UNKNOWN',
- '0 161 0 0' : 'A1',
- '0 176 0 0' : 'B0',
- '0 178 0 0' : 'B2',
- '0 179 0 0' : 'B3',
- '0 180 0 0' : 'B4',
- '1 160 0 0' : 'A0',
- '2 160 0 0' : 'EG' # super hack...
- }
-
-# bootloader stages
-STAGE_UNKOWN = 0
-STAGE_SEROM = 1
-STAGE_SERAM = 2
-STAGE_TEXT = ['UNKNOWN','SEROM','SERAM']
-
-class device_get_attributes:
- """ device_get_attributes
- """
- # attributes from the device
- part_number = 'PART_UNKNOWN'
- revision = 'UNKNOWN'
- stage = STAGE_UNKOWN
- env = 'UNKNOWN' # DEV or PROD environment
-
- def __init__(self, isp):
- """
- ctor
- """
- self.isp = isp
- # retrieve device Part#
-
- # retrieve device revision
- self.revision, self.part_number, self.env = self.__get_device_info(isp)
- # probe and set device bootloader stage
- self.stage = self.__get_device_stage(isp)
-
- def __get_device_info(self, isp):
- """
- obtain the SoC Device information
- """
- isp_start(isp)
- rev = 'ERROR'
- message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_REVISION])
- cmd = message[ISP_PACKET_COMMAND_FIELD]
- if len(message) == 0:
- print("[ERROR] Target did not respond")
- return rev
-
- if cmd == ISP_COMMAND_DATA_RESPONSE:
- # silicon revision
- lst = message[2:6]
- rev1 = ' '.join(map(str,lst))
- (version,) = struct.unpack(" ISP_PACKET_HEADER_LENGTH:
- lastbyte = len(packet)
- command = packet[ISP_PACKET_COMMAND_FIELD]
-# Uncomment for more details
-# hexized = [hex(x) for x in packet]
-# print(hexized)
-
- cmdstr = isp_command_lookup.get(command)
- if not cmdstr:
- cmdstr = ">> COMMAND_UNKNOWN << "
- command = ISP_UNKNOWN_COMMAND
- if isp.getVerbose() is True:
- print(" cmd = %3x" %command, end='')
- print(" command=", cmdstr, end='')
- if (command == ISP_COMMAND_GET or command == ISP_COMMAND_SET):
- sub_command = int.from_bytes(packet[2:6], "little")
- sub_command_str = isp_subcommand_lookup.get(sub_command)
- if not sub_command_str:
- sub_command_str = ">> SUB COMMAND UNKNOWN <<"
- print(" sub command= %4x %s"
- %(sub_command, sub_command_str),end='')
- if sub_command == ISP_GET_PEEK_ADDRESS:
- address = int.from_bytes(packet[6:10], "little")
- print("address= 0x%8x" %(address))
- if sub_command == ISP_SET_POKE_ADDRESS:
- address = int.from_bytes(packet[6:10], "little")
- data = int.from_bytes(packet[10:14], "little")
- print("address= 0x%x, data= 0x%x" %(address,data))
- print(" chksum =", hex(packet[lastbyte-1]),end='')
-
-# if command != ISP_COMMAND_DOWNLOAD_DATA:
-# print(" packet=", packet,end='')
-
- if command == ISP_COMMAND_NAK: # NACK, check error code#
-# Uncomment for more details
-# hexized = [hex(x) for x in packet]
-# print(hexized)
- errstr = error_lookup.get(packet[ISP_PACKET_DATA_FIELD])
-
- if not errstr:
- errstr = ">> ERROR UNKNOWN (" + hex(packet[ISP_PACKET_DATA_FIELD]) + ") <<"
- if isp.getVerbose() is False:
- print("%s" %prompt_str, end='')
- print(" length= %3d" %len(packet), end='')
- print(" command=", cmdstr, end='')
- print(" chksum=", hex(packet[lastbyte-1]),end='')
- print(" error=", errstr)
- else:
- print(" error=", errstr, end='')
-
- # print the extended error code, if it exist
- payload_begin = ISP_PACKET_DATA_FIELD + 1 # skip the NACK error code
- payload_end = len(packet) - 1 # skip the checksum
-
- payload = packet[payload_begin:payload_end]
- if len(payload) > 0:
- hexized = [hex(x) for x in payload]
- print(" extended error=", hexized)
-
- if command == ISP_COMMAND_DATA_RESPONSE:
- payload = packet[ISP_PACKET_DATA_FIELD:len(packet)-1]
- if isp.getVerbose() is True:
- if packet[ISP_TOC_COMMAND_FIELD] == ISP_TOC_INFO_START_MARKER:
- print(" ISP_TOC_INFO_START_MARKER ", end='')
- if packet[ISP_TOC_COMMAND_FIELD] == ISP_TOC_INFO_END_MARKER:
- print(" ISP_TOC_INFO_STOP_MARKER ", end='')
- if packet[ISP_TOC_COMMAND_FIELD] == ISP_DATA_START_MARKER:
- print(" ISP_DATA_START_MARKER ", end='')
- if packet[ISP_TOC_COMMAND_FIELD] == ISP_DATA_END_MARKER:
- print(" ISP_DATA_END_MARKER ", end='')
-
-# for each_word in range(0,160,4):
-# trace_value = payload[each_word:each_word+4]
-# value = int.from_bytes(trace_value,byteorder='little')
-# print("{:4d} 0x{:08x} ".format(each_word,value))
-
- hexed = [hex(x) for x in payload]
- print(" response payload=", hexed, end='')
- print(hexed)
-
- if isp.getVerbose() is True:
- print(" ")
- sys.stdout.flush()
-
- return command
-
-def isp_readmessage(isp):
- """
- read a message from the serial port
-
- Length; Command; []; Checksum
- """
-
- packet_header = isp.readSerial(ISP_PACKET_HEADER_LENGTH)
- if len(packet_header) != ISP_PACKET_HEADER_LENGTH:
- return []
-
- packet_length = packet_header[ISP_PACKET_LENGTH_FIELD]
- if packet_length < ISP_PACKET_HEADER_LENGTH + 1:
- return []
-
-# Uncomment to test NAK packages with payload (also indent the lines after 'else:' so that Python doesn't complain
- #if packet_header[ISP_PACKET_COMMAND_FIELD] == ISP_COMMAND_NAK:
- # packet_contents = list(bytearray(isp.readSerial(packet_length - 3)))
- # packet_contents += [0x1, 0x2, 0x3, 0x4]
- # packet_contents += list(bytearray(isp.readSerial(1)))
- #else:
- # read the rest of the packet (including the checksum)
- packet_contents = list(bytearray(isp.readSerial(packet_length - ISP_PACKET_HEADER_LENGTH)))
- if packet_contents == []:
- return []
-
- packet = packet_header + packet_contents
-# print("message = ", packet)
-
- return packet
-
-def isp_wait(isp):
- """
- wait for trigger to proceed
- """
- _event = isp.eventFlag.wait(1) # Wait for operation to complete
- isp.eventFlag.clear()
-
-def isp_signal(isp):
- """
- tigeger signal to wait
- """
- isp.eventFlag.set() # tell TX we are done
-
-
-def isp_build_packet(isp, isp_command, isp_sub_commands = None, delay=0):
- """
- build the packet and send, receive and decode response
- """
- if isp_sub_commands is None:
- isp_sub_commands = []
-
- cmd_packet = [0x00, isp_command]
-
- for sub in isp_sub_commands:
- if sub == 'padding':
- cmd_packet.append(0x55)
- continue
-
- if isinstance( sub, int ):
- cmd_packet = cmd_packet + list(int_to_bytes(sub))
- else:
- cmd_packet = cmd_packet + list(sub)
-
- cmd_packet[0] = len(cmd_packet) + 1
- cmd_packet = isp.checkSum(cmd_packet) # add the checksum packet
-
- isp.writeSerial(bytearray(cmd_packet))
- isp_decode_packet(isp,"TX--> ", cmd_packet)
- if delay>0:
- time.sleep(delay)
- message = isp_readmessage(isp)
- command = isp_decode_packet(isp,"RX<-- ", message)
-
- while command == ISP_COMMAND_PRINT_DATA:
- isp_print_message('blue', message)
-
- message = isp_readmessage(isp)
- command = isp_decode_packet(isp,"RX<-- ", message)
-
- return message
-
-def isp_test_target(baud_rate, isp):
- """
- isp_test_target
-
- This command is similar to isp_start() but it does NOT exit
- when the target did not respond...Int rather resturns:
- 1 - when target responded
- -1 - when target did not respond
- """
- cmd_packet = [0x03, ISP_COMMAND_START_ISP] # start isp
- cmd_packet = isp.checkSum(cmd_packet) # add the checksum packet
-
- isp.writeSerial(bytearray(cmd_packet))
- isp_decode_packet(isp,"TX--> ", cmd_packet)
-
- # ISP START always succeeds, so there is no need to read the Ack like for the other commands.
- # Two things to look for are -
- # 1. ISP_COMMAND_ACK byte - to verify that the target responded
- # 2. Any leftover data, e.g., Flicker animations - it needs to be read/flushed
- got_ack = False
- while True:
- data = isp.readSerial(1)
- if len(data) == 0:
- break
- if data[0] == ISP_COMMAND_ACK:
- got_ack = True
- if not got_ack:
- sys.stdout.flush()
- return -1
-
- if isp.getVerbose() is True:
- print("RX<-- command= COMMAND_ACK")
-
- if got_ack == True:
- return 1
-
-def isp_start(isp):
- """
- isp_start
-
- ISP_COMMAND_START puts the SERAM isp_handler into an ISP mode. Flicker
- will be disabled, however there maybe some residual characters which
- get consumed.
- """
- cmd_packet = [0x03, ISP_COMMAND_START_ISP] # start isp
- cmd_packet = isp.checkSum(cmd_packet) # add the checksum packet
-
- isp.writeSerial(bytearray(cmd_packet))
- isp_decode_packet(isp,"TX--> ", cmd_packet)
-
- # ISP START always succeeds, so there is no need to read the Ack like for the other commands.
- # Two things to look for are -
- # 1. ISP_COMMAND_ACK byte - to verify that the target responded
- # 2. Any leftover data, e.g., Flicker animations - it needs to be read/flushed
- got_ack = False
- while True:
- data = isp.readSerial(1)
- if len(data) == 0:
- break
- if data[0] == ISP_COMMAND_ACK:
- got_ack = True
- if not got_ack:
- print("[ERROR] Target did not respond")
- sys.stdout.flush()
- # isp_start is called before any dynamic baud rate change, so it is ok to sys.exit()
- isp.closeSerial()
- sys.exit(-1)
-
- if isp.getVerbose() is True:
- print("RX<-- command= COMMAND_ACK")
-
-def isp_stop(isp):
- """
- isp_Stop
- - Send Command to Stop the isp handler on the target
- """
- isp_build_packet(isp, ISP_COMMAND_STOP_ISP)
-
-def getFilesize(fileHandle):
- """
- getFileSize
- - given a file handle return the size in bytes
- """
- fileHandle.seek(0,os.SEEK_END)
- sizeinbytes = fileHandle.tell()
-
- return sizeinbytes
-
-def isp_reset(isp):
- """
- isp_reset
- """
- isp_build_packet(isp, ISP_COMMAND_RESET_DEVICE)
-
-def isp_secure_debug(isp, auth_token, data):
- """
- isp_secure_debug
- """
- subCmd = []
- if auth_token != 0x0:
- subCmd.append(auth_token)
-
- if len(data) != 0:
- subCmd.append(data)
-
- #print("*** sub command: ", subCmd)
- isp_build_packet(isp, ISP_COMMAND_SECURE_DEBUG, subCmd)
-
-def isp_download_start(isp, address, size, auth_token):
- """
- isp_download_start
- """
- subCmd = [address,size]
- if auth_token != 0x0:
- subCmd.append(auth_token)
- isp_build_packet(isp, ISP_COMMAND_DOWNLOAD_START, subCmd)
-
-def isp_download_data(isp, data):
- """
- isp_download_data
- """
- message = isp_build_packet(isp, ISP_COMMAND_DOWNLOAD_DATA,
- ['padding', 'padding', bytearray(data)])
- if len(message) == 0:
- print("[ERROR] No response")
- return False
-
- command = message[ISP_PACKET_COMMAND_FIELD]
- if command == ISP_COMMAND_NAK:
- print("[ERROR] Command NAK")
- return False
-
- return True
-
-def isp_download_done(isp, delay = 0):
- """
- isp_download_done
- Does not wait for reader task
- """
- isp_build_packet(isp, ISP_COMMAND_DOWNLOAD_DONE, None, delay)
-
-def isp_burn_mram(isp, address, file_size, auth_token):
- """
- isp_burn_mram
- """
- subCmd = [address,file_size]
- if auth_token != 0x0:
- subCmd.append(auth_token)
- message = isp_build_packet(isp, ISP_COMMAND_BURN_MRAM, subCmd)
-
- # same error handling as in isp_download_data
- if len(message) == 0:
- print("[ERROR] No response")
- return False
-
- command = message[ISP_PACKET_COMMAND_FIELD]
- if command == ISP_COMMAND_NAK:
- print("[ERROR] Command NAK")
- return False
-
- return True
-
-
-def isp_enquiry(isp):
- """
- isp_enquiry
- """
- message = isp_build_packet(isp, ISP_COMMAND_ENQUIRY)
-
- if len(message) == 0:
- return
-
- cmd = message[ISP_PACKET_COMMAND_FIELD]
- if cmd == ISP_COMMAND_DATA_RESPONSE:
- #isp_print_response("blue",message)
- Maintenance_string = ""
- error_string = ""
- length = message[ISP_PACKET_LENGTH_FIELD]
- state = message[ISP_PACKET_DATA_FIELD]
-
- ErrorCode = (message[3:7]) # bytes 3 through 6 (limit 7)
- ExtendedErrorCode = [0,0,0,0]
- ExtendedErrorCode = (message[7:11]) # bytes 7 through 10 (limit 11)
- if state & ISP_SOURCE_SEROM:
- isp_print_color("blue","SEROM")
- error_string = serom_error_lookup.get(int.from_bytes(ErrorCode,"little"))
- Maintenance_string = ""
- if state & ISP_SOURCE_SERAM:
- isp_print_color("blue","SERAM")
- MaintenanceMode = int.from_bytes(message[11:15],"little")
- Maintenance_string = "Enabled" if (MaintenanceMode == 1) else "Disabled "
-
- isp_print_color("blue"," Error = ")
- isp_print_color("blue",hex(int.from_bytes(ErrorCode,"little")))
- if error_string:
- isp_print_color("blue"," (" + error_string + ") ")
- isp_print_color("blue"," Extended Error = ")
- isp_print_color("blue",hex(int.from_bytes(ExtendedErrorCode,"little")))
- isp_print_color("blue"," Maintenance Mode = " + Maintenance_string)
- print(" ")
-
-
-def isp_show_maintenance_mode(isp, maintenance_mode):
- """
- isp_show_maintenance_mode
- - disply the maintence mode status
- """
- Maintenance_string = "Enabled" if (maintenance_mode == 1) else "Disabled "
- isp_print_color("blue","Maintenance Mode = " + Maintenance_string)
- print(" ")
-
-def isp_get_maintenance_status(isp):
- """
- isp_get_maintenance_status
- - This is wrapper around isp_enquiry which returns the error code
- data as well, this is ignored.
- """
- MaintenanceMode = 0
- message = isp_build_packet(isp, ISP_COMMAND_ENQUIRY)
- if len(message) != 0:
- cmd = message[ISP_PACKET_COMMAND_FIELD]
-
- if cmd == ISP_COMMAND_DATA_RESPONSE:
-# isp_print_response("blue",message)
- length = message[ISP_PACKET_LENGTH_FIELD]
- state = message[ISP_PACKET_DATA_FIELD]
- if state & ISP_SOURCE_SERAM:
- MaintenanceMode = int.from_bytes(message[11:15],"little")
-
- return MaintenanceMode
-
-def isp_get_revision(isp):
- # we will add the source (SEROM or SERAM)
-
- """
- isp_enquiry
- """
- message = isp_build_packet(isp, ISP_COMMAND_ENQUIRY)
- if len(message) == 0:
- return
- cmd = message[ISP_PACKET_COMMAND_FIELD]
- if cmd == ISP_COMMAND_DATA_RESPONSE:
- state = message[ISP_PACKET_DATA_FIELD]
- isp_print_color("blue"," Source\t\t= ")
- if state & ISP_SOURCE_SEROM:
- isp_print_color("blue","SEROM\n")
- if state & ISP_SOURCE_SERAM:
- isp_print_color("blue","SERAM\n")
-
-
-
- """
- isp_get_revision handler
- """
- message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_REVISION])
-
- if len(message) == 0:
- return
- cmd = message[ISP_PACKET_COMMAND_FIELD]
-
- if cmd == ISP_COMMAND_DATA_RESPONSE:
- version_decode(isp,message)
-
-def isp_get_baud_rate(isp):
- """
- isp_get_baud_rate
- """
- baud_rate = 0
- message = isp_build_packet(isp, ISP_COMMAND_GET_BAUD_RATE)
- baud_rate = int.from_bytes(message[2:6],"little")
- isp_print_color("blue",baud_rate)
- print(" ")
-
- return baud_rate
-
-def isp_get_toc_data(isp):
- """
- isp_get_toc_data
- """
- isp_print_color("blue",
- " +----------+--------+------------+------------+------------+------------+----------+-----------+--------+----------+\n")
- isp_print_color("blue",
- " | Name | CPU | Store Addr | Obj Addr | Dest Addr | Boot Addr | Size | Version | Flags | Time (ms)|\n")
- isp_print_color("blue",
- " +----------+--------+------------+------------+------------+------------+----------+-----------+--------+----------+\n")
-
- message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_TOC_INFO])
-
- if len(message) == 0:
- return
-
- # This uses a "stream" of packets sent back from SERAM
- while (message[ISP_PACKET_COMMAND_FIELD] == ISP_COMMAND_DATA_RESPONSE and
- message[ISP_DATA_START_FIELD] == ISP_DATA_START_MARKER):
-
- display_toc_info(message[3::]) # Skip header, payload only
-
- message = isp_readmessage(isp)
- command = isp_decode_packet(isp,"RX<-- ", message)
-
- if len(message) == 0:
- return
- isp_print_color("blue",
- " +----------+--------+------------+------------+------------+------------+----------+-----------+--------+----------+\n")
-
-def isp_get_power_data(isp):
- """
- isp_get_power_data
- """
-
- message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_POWER_INFO])
-
- if len(message) == 0:
- return
- command = message[ISP_PACKET_COMMAND_FIELD]
- if command == ISP_COMMAND_NAK:
- return
-
- display_power_info(message[2::]) # Skip header, payload only
-# display_power_info(message) # Skip header, payload only
-
-def isp_get_clock_data(isp):
- """
- isp_get_power_data
- """
-
- message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_CLOCK_INFO])
-
- if len(message) == 0:
- return
- command = message[ISP_PACKET_COMMAND_FIELD]
- if command == ISP_COMMAND_NAK:
- return
-
- display_clock_info(message[2::]) # Skip header, payload only
-
-def isp_get_banner(isp):
- """
- isp_get_banner - retrieve seram banner
- sub-command ISP_GET_BANNER
- """
- message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_BANNER])
-
- if len(message) == 0:
- return
- command = message[ISP_PACKET_COMMAND_FIELD]
- if command == ISP_COMMAND_DATA_RESPONSE:
- isp_print_message("blue", message)
- print(" ")
-
-def isp_get_mram_contents(isp):
- """
- isp_get_mram_contents - retrieve MRAM details
- sub-command ISP_GET_MRAM_CONTENTS
- """
- delay = 10
- message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_MRAM_CONTENTS], delay)
-
- if len(message) == 0:
- return
-
- while (message[ISP_PACKET_COMMAND_FIELD] == ISP_COMMAND_DATA_RESPONSE and
- message[ISP_TOC_COMMAND_FIELD] == ISP_TOC_INFO_START_MARKER):
- toc_decode_toc_info(isp, message)
-
- message = isp_readmessage(isp)
- isp_decode_packet(isp,"RX<-- ", message)
-
- if len(message) == 0:
- return
-
-def isp_get_cpu_status(isp):
- """
- isp_get_cpu_state
-
- ISP_DATA_RESPONSE packet for return data
-
- CPU_ID Booted Boot Addess
- <1-byte> <1-byte> <4-bytes> = 6-bytes
- """
- message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_CPU_STATUS])
-
- if len(message) == 0: # Nothing came back
- return
- command = message[ISP_PACKET_COMMAND_FIELD]
- if command == ISP_COMMAND_DATA_RESPONSE:
- display_cpu_info(message)
-
-def isp_get_seram_metrics(isp):
- """
- isp_get_seram_metrics
-
- ISP_DATA_RESPONSE packet for return data
-
- Task Name Size Used
- <16-bytes> <4-byte> <4-bytes> = 24-bytes
- """
- message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_SERAM_METRICS])
-
- if len(message) == 0: # Nothing came back
- return
-
- if message[ISP_PACKET_COMMAND_FIELD] == ISP_COMMAND_DATA_RESPONSE:
- isp_print_color("blue", " +-------------------------------+\n")
- isp_print_color("blue", " | TaskName | Size | Used |\n")
- isp_print_color("blue", " +-----------------+------+------+\n")
-
- # unpack the data in the response. 2 CPUS x 6-bytes of data
- # @todo magic numbers need to go away and less cut and paste code
- packet_start = ISP_PACKET_DATA_FIELD
- element = message[packet_start::]
-
- # uint32_t number of tasks
- # uint32_t uptime
- # struct {
- # uint32_t stack_size
- # uint32_t stack_used
- # char task_name[16]
- #} [number_of_tasks]
- (number_of_tasks,) = struct.unpack(" for with
- """
- delay = 0
- if size >= 1048576: # ACK will take some time at this size
- delay = 20
- isp_build_packet(isp, ISP_COMMAND_ERASE_MRAM, [address,size,pattern], delay)
-
-def isp_sram_write(isp, offset, data):
- """
- isp_Sram_Write
- - send data to write to the SE RAM - SEROM only
- (used by recovery-execute-package.py)
- """
-
- #print("* write to offset ", hex(offset))
- #print("* data: ", data)
- isp_build_packet(isp, ISP_COMMAND_SRAM_WRITE, [offset, bytearray(data)])
-
-def isp_set_maintenance_flag(isp):
- """
- isp_set_maintenance_flag
- - Send Command to set the maintenance flag on the target
- """
- message = isp_build_packet(isp, ISP_COMMAND_SET_MAINTENANCE_FLAG)
-
-def isp_get_log_data(isp):
- """
- isp_get_log_data
- """
-
- # get log buffer info
- message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_LOG_BUFFER_INFO])
- if len(message) == 0:
- return None
-
- command = message[ISP_PACKET_COMMAND_FIELD]
- if command != ISP_COMMAND_DATA_RESPONSE:
- return None
-
- (buffer_size,) = struct.unpack("> 4))
+#!/usr/bin/python3
+"""
+ ISP Core commands implementation
+
+ In System Programming (ISP) protocol implementation
+
+
+ __author__ onyettr
+"""
+# pylint: disable=unused-argument, invalid-name
+import os
+import signal
+import time
+import sys
+import struct
+from isp_protocol import *
+from isp_print import isp_print_color, isp_print_response, isp_print_message
+from serom_errors import *
+from toc_decode import display_toc_info, toc_decode_toc_info
+from toc_decode import TOC_IMAGE_CPU_A32_0, TOC_IMAGE_CPU_A32_1
+from toc_decode import TOC_IMAGE_CPU_M55_HP, TOC_IMAGE_CPU_M55_HE, TOC_IMAGE_CPU_MODEM
+from toc_decode import TOC_IMAGE_CPU_GNSS, TOC_IMAGE_CPU_DSP
+from version_decode import version_decode
+from cpu_decode import display_cpu_info
+from power_decode import display_power_info
+from clock_decode import display_clock_info
+from otp import display_otp_info
+#from serom_trace import *
+
+#from seram_trace import trace_buffer_decode
+from trace_decode import trace_buffer_decode
+
+EXIT_WITH_ERROR = 1
+
+# ISP Command set
+# Command : Value
+isp_command_lookup = {
+ ISP_COMMAND_START_ISP : "COMMAND_START_ISP ",
+ ISP_COMMAND_STOP_ISP : "COMMAND_STOP_ISP ",
+ ISP_COMMAND_ABORT : "COMMAND_ABORT ",
+ ISP_COMMAND_DOWNLOAD_DATA : "COMMAND_DOWNLOAD_DATA ",
+ ISP_COMMAND_DOWNLOAD_DONE : "COMMAND_DOWNLOAD_DONE ",
+ ISP_COMMAND_BURN_MRAM : "COMMAND_BURN_MRAM ",
+ ISP_COMMAND_RESET_DEVICE : "COMMAND_RESET_DEVICE ",
+ ISP_COMMAND_PRINT_DATA : "COMMAND_PRINT_DATA ",
+ ISP_COMMAND_MRAM_WRITE : "COMMAND_MRAM_WRITE ",
+ ISP_COMMAND_SECURE_DEBUG : "COMMAND_SECURE_DEBUG ",
+ ISP_COMMAND_ENQUIRY : "COMMAND_ENQUIRY ",
+ ISP_COMMAND_GET_BAUD_RATE : "COMMAND_GET_BAUD_RATE ",
+ ISP_COMMAND_SET_BAUD_RATE : "COMMAND_SET_BAUD_RATE ",
+ ISP_COMMAND_VERIFY_IMAGE : "COMMAND_VERIFY_IMAGE ",
+ ISP_COMMAND_GET_TOC_INFO : "COMMAND_GET_TOC_INFO ",
+ ISP_COMMAND_OTP_WRITE : "COMMAND_OTP_WRITE ",
+ ISP_COMMAND_OTP_READ : "COMMAND_OTP_READ ",
+ ISP_COMMAND_GET : "COMMAND_GET ",
+ ISP_COMMAND_ERASE_MRAM : "COMMAND_ERASE_MRAM ",
+ ISP_COMMAND_SET_MAINTENANCE_FLAG: "COMMAND_SET_MAINTENANCE_FLAG",
+ ISP_COMMAND_MRAM_READ : "COMMAND_MRAM_READ ",
+ ISP_COMMAND_SET : "COMMAND_SET ",
+ ISP_COMMAND_DMPU : "COMMAND_DMPU ",
+ ISP_COMMAND_SRAM_WRITE : "COMMAND SRAM WRITE ",
+ ISP_COMMAND_VERIFY_AND_EXECUTE : "ISP_COMMAND_VERIFY_AND_EXECUTE",
+ ISP_COMMAND_DATA_RESPONSE : "COMMAND_DATA_RESPONSE ",
+ ISP_COMMAND_ACK : "COMMAND_ACK ",
+ ISP_COMMAND_NAK : "COMMAND_NAK "
+}
+
+# ISP Sub commands
+isp_subcommand_lookup = {
+ ISP_GET_TOC_INFO : "GET_TOC_INFO ",
+ ISP_GET_REVISION : "GET_REVISION ",
+ ISP_GET_BAUDRATE : "GET_BAUDRATE ",
+ ISP_GET_BANNER : "GET_BANNER ",
+ ISP_GET_MRAM_CONTENTS : "GET_MRAM_CONTENTS ",
+ ISP_GET_CPU_STATUS : "GET_CPU_STATUS ",
+ ISP_GET_SERAM_METRICS : "GET_SERAM_METRICS ",
+ ISP_GET_LOG_BUFFER_INFO : "GET_LOG_BUFFER_INFO ",
+ ISP_GET_LOG_DATA : "GET_LOG_DATA ",
+ ISP_GET_SERAM_UPDT_ADDR : "GET_STREAM_UPDT_ADDR ",
+ ISP_GET_TRACE_BUFFER : "GET_TRACE_BUFFER ",
+ ISP_GET_SERAM_TRACE_BUFFER : "GET_SERAM_TRACE_BUFFER",
+ ISP_GET_SECURE_DEBUG_TOKENS : "GET_SECURE_DEBUG_TOKENS",
+ ISP_GET_POWER_INFO : "GET_POWER_INFO ",
+ ISP_GET_PEEK_ADDRESS : "GET ADDRESS ",
+ ISP_GET_CLOCK_INFO : "GET CLOCK_INFO ",
+ ISP_GET_ECC_KEY : "GET ECC_KEY ",
+ ISP_GET_FIREWALL_CONFIG : "GET FIREWALL_CONFIG ",
+ ISP_SET_PRINTING_ENABLE : "SET PRINTING ENABLE ",
+ ISP_SET_PRINTING_DISABLE : "SET PRINTING DISABLE ",
+ ISP_SET_LOGGING_ENABLE : "SET LOGGING ENABLE ",
+ ISP_SET_LOGGING_DISABLE : "SET LOGGING DISABLE ",
+ ISP_SET_POKE_ADDRESS : "SET ADDRESS "
+}
+
+error_lookup = {
+ ISP_SUCCESS : "ISP_SUCCESS ",
+ ISP_ERROR : "ISP_ERROR ",
+ ISP_READ_TIMEOUT : "ISP_READ_TIMEOUT ",
+ ISP_WRITE_TIMEOUT : "ISP_WRITE_TIMEOUT ",
+ ISP_UNKNOWN_COMMAND : "ISP_UNKNOWN_COMMAND ",
+ ISP_COMMAND_STOP : "ISP_COMMAND_STOP ",
+ ISP_CHECKSUM_ERROR : "ISP_CHECKSUM_ERROR ",
+ ISP_NOT_SUPPORTED : "ISP_NOT_SUPPORTED ",
+ ISP_BAD_PACKET_SIZE : "ISP_BAD_PACKET_SIZE ",
+ ISP_BAD_DESTINATION_ADDR : "ISP_BAD_DEST_ADDRESS ",
+ ISP_UNEXPECTED_COMMAND : "ISP_UNEXPECTED_COMMAND",
+ ISP_HOST_AUTH_FAILED : "ISP_HOST_AUTH_FAILED ",
+ ISP_NOT_ALLOWED : "ISP_NOT_ALLOWED ",
+ ISP_BAD_AUTH_TOKEN : "ISP_BAD_AUTH_TOKEN ",
+ ISP_IMAGE_AUTHENTICATION_FAILED : "ISP_IMAGE_AUTHENTICATION_FAILED",
+ ISP_IMAGE_VERIFICATION_FAILED : "ISP_IMAGE_VERIFICATION_FAILED",
+ ISP_SECURE_DEBUG_FAILED : "ISP_SECURE_DEBUG_FAILED",
+ ISP_MRAM_WRITE_FAILED : "ISP_MRAM_WRITE_FAILED ",
+ ISP_UNKNOWN_GET_OBJECT : "ISP_UNKNOWN_GET_OBJECT",
+ ISP_ERROR_ILLEGAL_ADDRESS : "ISP_ERROR_ILLEGAL_ADDRESS",
+ ISP_ERROR_MISALIGNED : "ISP_ERROR_MISALIGNED",
+ ISP_UNKNOWN_MRAM_ERROR : "ISP_UNKNOWN_MRAM_ERROR",
+ ISP_MRAM_LENGTH_TOO_LARGE : "ISP_MRAM_LENGTH_TOO_LARGE",
+ ISP_UNKNOWN_SET_OBJECT : "ISP_UNKNOWN_SET_OBJECT",
+ ISP_CODE_VERIFY_FAILURE : "ISP_CODE_VERIFY_FAILURE",
+ ISP_INVALID_CODE_SIZE : "ISP_INVALID_CODE_SIZE",
+ ISP_MFG_DATA_MISCOMPARE : "ISP_MFG_DATA_MISCOMPARE",
+ ISP_SERAM_JUMP_FAILED : "ISP_SERAM_JUMP_FAILED",
+ ISP_MRAM_CONTROLLER_ERROR : "ISP_MRAM_CONTROLLER_ERROR"
+}
+
+cpu_name_lut = {
+ TOC_IMAGE_CPU_A32_0 : "A32_0 ",
+ TOC_IMAGE_CPU_A32_1 : "A32_1 ",
+ TOC_IMAGE_CPU_M55_HP : "M55-HP",
+ TOC_IMAGE_CPU_M55_HE : "M55-HE",
+ TOC_IMAGE_CPU_MODEM : "Modem ",
+ TOC_IMAGE_CPU_GNSS : "GNSS ",
+ TOC_IMAGE_CPU_DSP : "DSP "
+}
+
+serom_error_lookup = {
+ SEROM_STATUS_SUCCESS : "SEROM_STATUS_SUCCESS",
+ SEROM_BSV_INIT_FAIL : "SEROM_BSV_INIT_FAIL",
+ SEROM_BSV_LCS_GET_AND_INIT_FAIL : "SEROM_BSV_LCS_GET_AND_INIT_FAIL",
+ SEROM_BSV_LCS_GET_FAIL : "SEROM_BSV_LCS_GET_FAIL",
+ SEROM_BSV_SEC_MODE_SET_FAIL : "SEROM_BSV_SEC_MODE_SET_FAIL",
+ SEROM_BSV_PRIV_MODE_SET_FAIL : "SEROM_BSV_PRIV_MODE_SET_FAIL",
+ SEROM_BSV_CORE_CLK_GATING_ENABLE_FAIL : "SEROM_BSV_CORE_CLK_GATING_ENABLE_FAIL",
+ SEROM_MRAM_INITIALIZATION_FAILURE : "SEROM_MRAM_INITIALIZATION_FAILURE",
+ SEROM_MRAM_INITIALIZATION_TIMEOUT : "SEROM_MRAM_INITIALIZATION_TIMEOUT",
+ SEROM_MRAM_WRITE_FAILURE : "SEROM_MRAM_WRITE_FAILURE",
+ SEROM_ATOC_EXT_HDR_OFFSET_ZERO : "SEROM_ATOC_EXT_HDR_OFFSET_ZERO",
+ SEROM_ATOC_EXT_HDR_OFFSET_TOO_LARGE : "SEROM_ATOC_EXT_HDR_OFFSET_TOO_LARGE",
+ SEROM_ATOC_OBJECT_OFFSET_ZERO : "SEROM_ATOC_OBJECT_OFFSET_ZERO",
+ SEROM_ATOC_OBJECT_OFFSET_MISALIGNED : "SEROM_ATOC_OBJECT_OFFSET_MISALIGNED",
+ SEROM_ATOC_OBJECT_OFFSET_TOO_LARGE : "SEROM_ATOC_OBJECT_OFFSET_TOO_LARGE",
+ SEROM_ATOC_OBJECT_OFFSET_TOO_SMALL : "SEROM_ATOC_OBJECT_OFFSET_TOO_SMALL",
+ SEROM_ATOC_EXT_HDR_OFFSET_MISALIGNED : "SEROM_ATOC_EXT_HDR_OFFSET_MISALIGNED",
+ SEROM_ATOC_HEADER_OFFSET_INVALID : "SEROM_ATOC_HEADER_OFFSET_INVALID",
+ SEROM_ATOC_HEADER_CRC32_ERROR : "SEROM_ATOC_HEADER_CRC32_ERROR",
+ SEROM_ATOC_HEADER_STRING_INVALID : "SEROM_ATOC_HEADER_STRING_INVALID",
+ SEROM_ATOC_NUM_TOC_ENTRIES_INVALID : "SEROM_ATOC_NUM_TOC_ENTRIES_INVALID",
+ SEROM_CONTENT_CERTIFICATE_NULL : "SEROM_CONTENT_CERTIFICATE_NULL",
+ SEROM_CERTIFICATE_NULL : "SEROM_CERTIFICATE_NULL",
+ SEROM_CERTIFICATE_CHAIN_INVALID : "SEROM_CERTIFICATE_CHAIN_INVALID",
+ SEROM_INVALID_OEM_ROT : "SEROM_INVALID_OEM_ROT",
+ SEROM_CERTIFICATE_ERROR_BASE : "SEROM_CERTIFICATE_ERROR_BASE",
+ SEROM_CERTIFICATE_1_ERROR : "SEROM_CERTIFICATE_1_ERROR",
+ SEROM_CERTIFICATE_2_ERROR : "SEROM_CERTIFICATE_2_ERROR",
+ SEROM_CERTIFICATE_3_ERROR : "SEROM_CERTIFICATE_3_ERROR",
+ SEROM_BOOT_CODE_LOAD_ADDR_INVALID : "SEROM_BOOT_CODE_LOAD_ADDR_INVALID",
+ SEROM_BOOT_VERIFY_IN_MEMORY_CASE_INVALID : "SEROM_BOOT_VERIFY_IN_MEMORY_CASE_INVALID",
+ SEROM_BOOT_ZERO_IMAGE_LENGTH_INVALID : "SEROM_BOOT_ZERO_IMAGE_LENGTH_INVALID",
+ SEROM_BOOT_ENCRYPTED_IMAGE_INVALID : "SEROM_BOOT_ENCRYPTED_IMAGE_INVALID",
+ SEROM_BOOT_VERIFY_IN_FLASH_CASE_INVALID : "SEROM_BOOT_VERIFY_IN_FLASH_CASE_INVALID",
+ SEROM_BOOT_IMAGE_LENGTH_TOO_LARGE : "SEROM_BOOT_IMAGE_LENGTH_TOO_LARGE",
+ SEROM_BOOT_RAW_IMAGE_LOADING_NOT_ALLOWED : "SEROM_BOOT_RAW_IMAGE_LOADING_NOT_ALLOWED",
+ SEROM_BOOT_SERAM_JUMP_RETURN_ERROR : "SEROM_BOOT_SERAM_JUMP_RETURN_ERROR",
+ SEROM_BOOT_FAILED : "SEROM_BOOT_FAILED",
+ SEROM_BOOT_JUMP_ADDRESS_NOT_VALID : "SEROM_BOOT_JUMP_ADDRESS_NOT_VALID",
+ SEROM_BOTH_BANKS_INVALID : "SEROM_BOTH_BANKS_INVALID",
+ SEROM_ATOC_EXT_HDR_OFFSET_TOO_SMALL : "SEROM_ATOC_EXT_HDR_OFFSET_TOO_SMALL",
+ SEROM_BOOT_END_OF_MAIN_ERROR : "SEROM_BOOT_END_OF_MAIN_ERROR",
+ SEROM_INVALID_NULL_PTR : "SEROM_INVALID_NULL_PTR",
+ SEROM_INVALID_TOC_OFFSET : "SEROM_INVALID_TOC_OFFSET",
+}
+
+def convert_from_ms(milliseconds):
+ """
+ from the web
+ """
+ seconds, milliseconds = divmod(milliseconds,1000)
+ minutes, seconds = divmod(seconds,60)
+ hours, minutes = divmod(minutes, 60)
+ days, hours = divmod(hours, 24)
+
+# days = 0
+# seconds = (milliseconds/1000)%60
+# seconds = int(seconds)
+# minutes = (milliseconds/(1000*60))%60
+# minutes = int(minutes)
+# hours = (milliseconds/(1000*60*60))%24
+# hours = int(hours)
+ return days, hours, minutes, seconds
+
+class CtrlCHandler():
+ """
+ CtrlCHandler - handler for Ctrl-C key press
+ """
+ def __init__(self):
+ """
+ ctor
+ """
+ self.running = False
+ signal.signal(signal.SIGINT, self.Handler)
+
+ def Handler(self, signal_number, frame):
+ """
+ Handle the interupt signal
+ """
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
+ self.running = True
+
+ def Handler_reset(self):
+ """
+ start over
+ """
+ self.running = False
+
+ def Handler_exit(self):
+ """
+ return handler state
+ """
+ return self.running
+
+def int_to_bytes(number):
+ """
+ int_to_bytes
+ - integer number gets turned into bytes
+ """
+ _hrepr = hex(number).replace('0x', '')
+ return number.to_bytes(4,byteorder='little')
+
+def isp_decode_packet(isp, prompt_str, packet):
+ """
+ DecodePacket
+
+ prints details of header and packet
+ """
+
+ command = ISP_UNKNOWN_COMMAND
+
+ if isp.getVerbose() is True:
+ print("%s" %prompt_str, end='')
+ print(" length= %3d" %len(packet), end='')
+
+ # Decode further
+ if len(packet) > ISP_PACKET_HEADER_LENGTH:
+ lastbyte = len(packet)
+ command = packet[ISP_PACKET_COMMAND_FIELD]
+# Uncomment for more details
+# hexized = [hex(x) for x in packet]
+# print(hexized)
+
+ cmdstr = isp_command_lookup.get(command)
+ if not cmdstr:
+ cmdstr = ">> COMMAND_UNKNOWN << "
+ command = ISP_UNKNOWN_COMMAND
+ if isp.getVerbose() is True:
+ print(" cmd = %3x" %command, end='')
+ print(" command=", cmdstr, end='')
+ if (command == ISP_COMMAND_GET or command == ISP_COMMAND_SET):
+ sub_command = int.from_bytes(packet[2:6], "little")
+ sub_command_str = isp_subcommand_lookup.get(sub_command)
+ if not sub_command_str:
+ sub_command_str = ">> SUB COMMAND UNKNOWN <<"
+ print(" sub command= %4x %s"
+ %(sub_command, sub_command_str),end='')
+ if sub_command == ISP_GET_PEEK_ADDRESS:
+ address = int.from_bytes(packet[6:10], "little")
+ print("address= 0x%8x" %(address))
+ if sub_command == ISP_SET_POKE_ADDRESS:
+ address = int.from_bytes(packet[6:10], "little")
+ data = int.from_bytes(packet[10:14], "little")
+ print("address= 0x%x, data= 0x%x" %(address,data))
+ print(" chksum =", hex(packet[lastbyte-1]),end='')
+
+# if command != ISP_COMMAND_DOWNLOAD_DATA:
+# print(" packet=", packet,end='')
+
+ if command == ISP_COMMAND_NAK: # NACK, check error code#
+# Uncomment for more details
+# hexized = [hex(x) for x in packet]
+# print(hexized)
+ errstr = error_lookup.get(packet[ISP_PACKET_DATA_FIELD])
+
+ if not errstr:
+ errstr = ">> ERROR UNKNOWN (" + hex(packet[ISP_PACKET_DATA_FIELD]) + ") <<"
+ if isp.getVerbose() is False:
+ print("%s" %prompt_str, end='')
+ print(" length= %3d" %len(packet), end='')
+ print(" command=", cmdstr, end='')
+ print(" chksum=", hex(packet[lastbyte-1]),end='')
+ print(" error=", errstr)
+ else:
+ print(" error=", errstr, end='')
+
+ # print the extended error code, if it exist
+ payload_begin = ISP_PACKET_DATA_FIELD + 1 # skip the NACK error code
+ payload_end = len(packet) - 1 # skip the checksum
+
+ payload = packet[payload_begin:payload_end]
+ if len(payload) > 0:
+ hexized = [hex(x) for x in payload]
+ print(" extended error=", hexized)
+
+ if command == ISP_COMMAND_DATA_RESPONSE:
+ payload = packet[ISP_PACKET_DATA_FIELD:len(packet)-1]
+ if isp.getVerbose() is True:
+ if packet[ISP_TOC_COMMAND_FIELD] == ISP_TOC_INFO_START_MARKER:
+ print(" ISP_TOC_INFO_START_MARKER ", end='')
+ if packet[ISP_TOC_COMMAND_FIELD] == ISP_TOC_INFO_END_MARKER:
+ print(" ISP_TOC_INFO_STOP_MARKER ", end='')
+ if packet[ISP_TOC_COMMAND_FIELD] == ISP_DATA_START_MARKER:
+ print(" ISP_DATA_START_MARKER ", end='')
+ if packet[ISP_TOC_COMMAND_FIELD] == ISP_DATA_END_MARKER:
+ print(" ISP_DATA_END_MARKER ", end='')
+
+# for each_word in range(0,160,4):
+# trace_value = payload[each_word:each_word+4]
+# value = int.from_bytes(trace_value,byteorder='little')
+# print("{:4d} 0x{:08x} ".format(each_word,value))
+
+ hexed = [hex(x) for x in payload]
+ print(" response payload=", hexed, end='')
+ print(hexed)
+
+ if isp.getVerbose() is True:
+ print(" ")
+ sys.stdout.flush()
+
+ return command
+
+def isp_readmessage(isp):
+ """
+ read a message from the serial port
+
+ Length; Command; []; Checksum
+ """
+
+ packet_header = isp.readSerial(ISP_PACKET_HEADER_LENGTH)
+ if len(packet_header) != ISP_PACKET_HEADER_LENGTH:
+ return []
+
+ packet_length = packet_header[ISP_PACKET_LENGTH_FIELD]
+ if packet_length < ISP_PACKET_HEADER_LENGTH + 1:
+ return []
+
+# Uncomment to test NAK packages with payload (also indent the lines after 'else:' so that Python doesn't complain
+ #if packet_header[ISP_PACKET_COMMAND_FIELD] == ISP_COMMAND_NAK:
+ # packet_contents = list(bytearray(isp.readSerial(packet_length - 3)))
+ # packet_contents += [0x1, 0x2, 0x3, 0x4]
+ # packet_contents += list(bytearray(isp.readSerial(1)))
+ #else:
+ # read the rest of the packet (including the checksum)
+ packet_contents = list(bytearray(isp.readSerial(packet_length - ISP_PACKET_HEADER_LENGTH)))
+ if packet_contents == []:
+ return []
+
+ packet = packet_header + packet_contents
+# print("message = ", packet)
+
+ return packet
+
+def isp_wait(isp):
+ """
+ wait for trigger to proceed
+ """
+ _event = isp.eventFlag.wait(1) # Wait for operation to complete
+ isp.eventFlag.clear()
+
+def isp_signal(isp):
+ """
+ tigeger signal to wait
+ """
+ isp.eventFlag.set() # tell TX we are done
+
+
+def isp_build_packet(isp, isp_command, isp_sub_commands = None, delay=0):
+ """
+ build the packet and send, receive and decode response
+ """
+ if isp_sub_commands is None:
+ isp_sub_commands = []
+
+ cmd_packet = [0x00, isp_command]
+
+ for sub in isp_sub_commands:
+ if sub == 'padding':
+ cmd_packet.append(0x55)
+ continue
+
+ if isinstance( sub, int ):
+ cmd_packet = cmd_packet + list(int_to_bytes(sub))
+ else:
+ cmd_packet = cmd_packet + list(sub)
+
+ cmd_packet[0] = len(cmd_packet) + 1
+ cmd_packet = isp.checkSum(cmd_packet) # add the checksum packet
+
+ isp.writeSerial(bytearray(cmd_packet))
+ isp_decode_packet(isp,"TX--> ", cmd_packet)
+ if delay>0:
+ time.sleep(delay)
+ message = isp_readmessage(isp)
+ command = isp_decode_packet(isp,"RX<-- ", message)
+
+ while command == ISP_COMMAND_PRINT_DATA:
+ isp_print_message('blue', message)
+
+ message = isp_readmessage(isp)
+ command = isp_decode_packet(isp,"RX<-- ", message)
+
+ return message
+
+def isp_test_target(baud_rate, isp):
+ """
+ isp_test_target
+
+ This command is similar to isp_start() but it does NOT exit
+ when the target did not respond...Int rather resturns:
+ 1 - when target responded
+ -1 - when target did not respond
+ """
+ cmd_packet = [0x03, ISP_COMMAND_START_ISP] # start isp
+ cmd_packet = isp.checkSum(cmd_packet) # add the checksum packet
+
+ isp.writeSerial(bytearray(cmd_packet))
+ isp_decode_packet(isp,"TX--> ", cmd_packet)
+
+ # ISP START always succeeds, so there is no need to read the Ack like for the other commands.
+ # Two things to look for are -
+ # 1. ISP_COMMAND_ACK byte - to verify that the target responded
+ # 2. Any leftover data, e.g., Flicker animations - it needs to be read/flushed
+ got_ack = False
+ while True:
+ data = isp.readSerial(1)
+ if len(data) == 0:
+ break
+ if data[0] == ISP_COMMAND_ACK:
+ got_ack = True
+ if not got_ack:
+ sys.stdout.flush()
+ return -1
+
+ if isp.getVerbose() is True:
+ print("RX<-- command= COMMAND_ACK")
+
+ if got_ack == True:
+ return 1
+
+def isp_start(isp):
+ """
+ isp_start
+
+ ISP_COMMAND_START puts the SERAM isp_handler into an ISP mode. Flicker
+ will be disabled, however there maybe some residual characters which
+ get consumed.
+ """
+ cmd_packet = [0x03, ISP_COMMAND_START_ISP] # start isp
+ cmd_packet = isp.checkSum(cmd_packet) # add the checksum packet
+
+ isp.writeSerial(bytearray(cmd_packet))
+ isp_decode_packet(isp,"TX--> ", cmd_packet)
+
+ # ISP START always succeeds, so there is no need to read the Ack like for the other commands.
+ # Two things to look for are -
+ # 1. ISP_COMMAND_ACK byte - to verify that the target responded
+ # 2. Any leftover data, e.g., Flicker animations - it needs to be read/flushed
+ got_ack = False
+ while True:
+ data = isp.readSerial(1)
+ if len(data) == 0:
+ break
+ if data[0] == ISP_COMMAND_ACK:
+ got_ack = True
+ if not got_ack:
+ print("[ERROR] Target did not respond")
+ sys.stdout.flush()
+ # isp_start is called before any dynamic baud rate change, so it is ok to sys.exit()
+ isp.closeSerial()
+ sys.exit(EXIT_WITH_ERROR)
+
+ if isp.getVerbose() is True:
+ print("RX<-- command= COMMAND_ACK")
+
+def isp_stop(isp):
+ """
+ isp_Stop
+ - Send Command to Stop the isp handler on the target
+ """
+ isp_build_packet(isp, ISP_COMMAND_STOP_ISP)
+
+def getFilesize(fileHandle):
+ """
+ getFileSize
+ - given a file handle return the size in bytes
+ """
+ fileHandle.seek(0,os.SEEK_END)
+ sizeinbytes = fileHandle.tell()
+
+ return sizeinbytes
+
+def isp_reset(isp):
+ """
+ isp_reset
+ """
+ isp_build_packet(isp, ISP_COMMAND_RESET_DEVICE)
+
+def isp_secure_debug(isp, auth_token, data):
+ """
+ isp_secure_debug
+ """
+ subCmd = []
+ if auth_token != 0x0:
+ subCmd.append(auth_token)
+
+ if len(data) != 0:
+ subCmd.append(data)
+
+ #print("*** sub command: ", subCmd)
+ isp_build_packet(isp, ISP_COMMAND_SECURE_DEBUG, subCmd)
+
+def isp_download_start(isp, address, size, auth_token):
+ """
+ isp_download_start
+ """
+ subCmd = [address,size]
+ if auth_token != 0x0:
+ subCmd.append(auth_token)
+ isp_build_packet(isp, ISP_COMMAND_DOWNLOAD_START, subCmd)
+
+def isp_download_data(isp, data):
+ """
+ isp_download_data
+ """
+ message = isp_build_packet(isp, ISP_COMMAND_DOWNLOAD_DATA,
+ ['padding', 'padding', bytearray(data)])
+ if len(message) == 0:
+ print("[ERROR] No response")
+ return False
+
+ command = message[ISP_PACKET_COMMAND_FIELD]
+ if command == ISP_COMMAND_NAK:
+ print("[ERROR] Command NAK")
+ return False
+
+ return True
+
+def isp_download_done(isp, delay = 0):
+ """
+ isp_download_done
+ Does not wait for reader task
+ """
+ isp_build_packet(isp, ISP_COMMAND_DOWNLOAD_DONE, None, delay)
+
+def isp_burn_mram(isp, address, file_size, auth_token):
+ """
+ isp_burn_mram
+ """
+ subCmd = [address,file_size]
+ if auth_token != 0x0:
+ subCmd.append(auth_token)
+ message = isp_build_packet(isp, ISP_COMMAND_BURN_MRAM, subCmd)
+
+ # same error handling as in isp_download_data
+ if len(message) == 0:
+ print("[ERROR] No response")
+ return False
+
+ command = message[ISP_PACKET_COMMAND_FIELD]
+ if command == ISP_COMMAND_NAK:
+ print("[ERROR] Command NAK")
+ return False
+
+ return True
+
+
+def isp_enquiry(isp):
+ """
+ isp_enquiry
+ """
+ message = isp_build_packet(isp, ISP_COMMAND_ENQUIRY)
+
+ if len(message) == 0:
+ return
+
+ cmd = message[ISP_PACKET_COMMAND_FIELD]
+ if cmd == ISP_COMMAND_DATA_RESPONSE:
+ #isp_print_response("blue",message)
+ Maintenance_string = ""
+ error_string = ""
+ length = message[ISP_PACKET_LENGTH_FIELD]
+ state = message[ISP_PACKET_DATA_FIELD]
+
+ ErrorCode = (message[3:7]) # bytes 3 through 6 (limit 7)
+ ExtendedErrorCode = [0,0,0,0]
+ ExtendedErrorCode = (message[7:11]) # bytes 7 through 10 (limit 11)
+ if state & ISP_SOURCE_SEROM:
+ isp_print_color("blue","SEROM")
+ error_string = serom_error_lookup.get(int.from_bytes(ErrorCode,"little"))
+ Maintenance_string = ""
+ if state & ISP_SOURCE_SERAM:
+ isp_print_color("blue","SERAM")
+ MaintenanceMode = int.from_bytes(message[11:15],"little")
+ Maintenance_string = "Enabled" if (MaintenanceMode == 1) else "Disabled "
+
+ isp_print_color("blue"," Error = ")
+ isp_print_color("blue",hex(int.from_bytes(ErrorCode,"little")))
+ if error_string:
+ isp_print_color("blue"," (" + error_string + ") ")
+ isp_print_color("blue"," Extended Error = ")
+ isp_print_color("blue",hex(int.from_bytes(ExtendedErrorCode,"little")))
+ isp_print_color("blue"," Maintenance Mode = " + Maintenance_string)
+ print(" ")
+
+
+def isp_show_maintenance_mode(isp, maintenance_mode):
+ """
+ isp_show_maintenance_mode
+ - disply the maintence mode status
+ """
+ Maintenance_string = "Enabled" if (maintenance_mode == 1) else "Disabled "
+ isp_print_color("blue","Maintenance Mode = " + Maintenance_string)
+ print(" ")
+
+def isp_get_maintenance_status(isp):
+ """
+ isp_get_maintenance_status
+ - This is wrapper around isp_enquiry which returns the error code
+ data as well, this is ignored.
+ """
+ MaintenanceMode = 0
+ message = isp_build_packet(isp, ISP_COMMAND_ENQUIRY)
+ if len(message) != 0:
+ cmd = message[ISP_PACKET_COMMAND_FIELD]
+
+ if cmd == ISP_COMMAND_DATA_RESPONSE:
+# isp_print_response("blue",message)
+ length = message[ISP_PACKET_LENGTH_FIELD]
+ state = message[ISP_PACKET_DATA_FIELD]
+ if state & ISP_SOURCE_SERAM:
+ MaintenanceMode = int.from_bytes(message[11:15],"little")
+
+ return MaintenanceMode
+
+def isp_get_revision(isp):
+ # we will add the source (SEROM or SERAM)
+
+ """
+ isp_enquiry
+ """
+ message = isp_build_packet(isp, ISP_COMMAND_ENQUIRY)
+ if len(message) == 0:
+ return
+ cmd = message[ISP_PACKET_COMMAND_FIELD]
+ if cmd == ISP_COMMAND_DATA_RESPONSE:
+ state = message[ISP_PACKET_DATA_FIELD]
+ isp_print_color("blue"," Source\t\t= ")
+ if state & ISP_SOURCE_SEROM:
+ isp_print_color("blue","SEROM\n")
+ if state & ISP_SOURCE_SERAM:
+ isp_print_color("blue","SERAM\n")
+
+
+
+ """
+ isp_get_revision handler
+ """
+ message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_REVISION])
+
+ if len(message) == 0:
+ return
+ cmd = message[ISP_PACKET_COMMAND_FIELD]
+
+ if cmd == ISP_COMMAND_DATA_RESPONSE:
+ version_decode(isp,message)
+
+def isp_get_baud_rate(isp):
+ """
+ isp_get_baud_rate
+ """
+ baud_rate = 0
+ message = isp_build_packet(isp, ISP_COMMAND_GET_BAUD_RATE)
+ baud_rate = int.from_bytes(message[2:6],"little")
+ isp_print_color("blue",baud_rate)
+ print(" ")
+
+ return baud_rate
+
+def isp_get_toc_data(isp):
+ """
+ isp_get_toc_data
+ """
+ isp_print_color("blue",
+ " +----------+--------+------------+------------+------------+------------+----------+-----------+--------+----------+\n")
+ isp_print_color("blue",
+ " | Name | CPU | Store Addr | Obj Addr | Dest Addr | Boot Addr | Size | Version | Flags | Time (ms)|\n")
+ isp_print_color("blue",
+ " +----------+--------+------------+------------+------------+------------+----------+-----------+--------+----------+\n")
+
+ message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_TOC_INFO])
+
+ if len(message) == 0:
+ return
+
+ # This uses a "stream" of packets sent back from SERAM
+ while (message[ISP_PACKET_COMMAND_FIELD] == ISP_COMMAND_DATA_RESPONSE and
+ message[ISP_DATA_START_FIELD] == ISP_DATA_START_MARKER):
+
+ display_toc_info(message[3::]) # Skip header, payload only
+
+ message = isp_readmessage(isp)
+ command = isp_decode_packet(isp,"RX<-- ", message)
+
+ if len(message) == 0:
+ return
+ isp_print_color("blue",
+ " +----------+--------+------------+------------+------------+------------+----------+-----------+--------+----------+\n")
+
+def isp_get_power_data(isp):
+ """
+ isp_get_power_data
+ """
+
+ message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_POWER_INFO])
+
+ if len(message) == 0:
+ return
+ command = message[ISP_PACKET_COMMAND_FIELD]
+ if command == ISP_COMMAND_NAK:
+ return
+
+ display_power_info(message[2::]) # Skip header, payload only
+# display_power_info(message) # Skip header, payload only
+
+def isp_get_clock_data(isp):
+ """
+ isp_get_power_data
+ """
+
+ message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_CLOCK_INFO])
+
+ if len(message) == 0:
+ return
+ command = message[ISP_PACKET_COMMAND_FIELD]
+ if command == ISP_COMMAND_NAK:
+ return
+
+ display_clock_info(message[2::]) # Skip header, payload only
+
+def isp_get_banner(isp):
+ """
+ isp_get_banner - retrieve seram banner
+ sub-command ISP_GET_BANNER
+ """
+ message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_BANNER])
+
+ if len(message) == 0:
+ return
+ command = message[ISP_PACKET_COMMAND_FIELD]
+ if command == ISP_COMMAND_DATA_RESPONSE:
+ isp_print_message("blue", message)
+ print(" ")
+
+def isp_get_mram_contents(isp):
+ """
+ isp_get_mram_contents - retrieve MRAM details
+ sub-command ISP_GET_MRAM_CONTENTS
+ """
+ delay = 10
+ message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_MRAM_CONTENTS], delay)
+
+ if len(message) == 0:
+ return
+
+ while (message[ISP_PACKET_COMMAND_FIELD] == ISP_COMMAND_DATA_RESPONSE and
+ message[ISP_TOC_COMMAND_FIELD] == ISP_TOC_INFO_START_MARKER):
+ toc_decode_toc_info(isp, message)
+
+ message = isp_readmessage(isp)
+ isp_decode_packet(isp,"RX<-- ", message)
+
+ if len(message) == 0:
+ return
+
+def isp_get_cpu_status(isp):
+ """
+ isp_get_cpu_state
+
+ ISP_DATA_RESPONSE packet for return data
+
+ CPU_ID Booted Boot Addess
+ <1-byte> <1-byte> <4-bytes> = 6-bytes
+ """
+ message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_CPU_STATUS])
+
+ if len(message) == 0: # Nothing came back
+ return
+ command = message[ISP_PACKET_COMMAND_FIELD]
+ if command == ISP_COMMAND_DATA_RESPONSE:
+ display_cpu_info(message)
+
+def isp_get_seram_metrics(isp):
+ """
+ isp_get_seram_metrics
+
+ ISP_DATA_RESPONSE packet for return data
+
+ Task Name Size Used
+ <16-bytes> <4-byte> <4-bytes> = 24-bytes
+ """
+ message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_SERAM_METRICS])
+
+ if len(message) == 0: # Nothing came back
+ return
+
+ if message[ISP_PACKET_COMMAND_FIELD] == ISP_COMMAND_DATA_RESPONSE:
+ isp_print_color("blue", " +-------------------------------+\n")
+ isp_print_color("blue", " | TaskName | Size | Used |\n")
+ isp_print_color("blue", " +-----------------+------+------+\n")
+
+ # unpack the data in the response. 2 CPUS x 6-bytes of data
+ # @todo magic numbers need to go away and less cut and paste code
+ packet_start = ISP_PACKET_DATA_FIELD
+ element = message[packet_start::]
+
+ # uint32_t number of tasks
+ # uint32_t uptime
+ # struct {
+ # uint32_t stack_size
+ # uint32_t stack_used
+ # char task_name[16]
+ #} [number_of_tasks]
+ (number_of_tasks,) = struct.unpack(" ISP_PACKET_HEADER_LENGTH:
+ command = response[ISP_PACKET_COMMAND_FIELD]
+ if command == ISP_COMMAND_NAK: # NACK, DO NOT CONTINUE
+ print('ERROR: There was an error in the recovery process')
+ sys.exit(EXIT_WITH_ERROR)
+ else:
+ print('ERROR: There was an error in the recovery process ( invalid ISP PACKET HEADER LENGTH)!')
+ sys.exit(EXIT_WITH_ERROR)
+
+def isp_read_mram(isp,word_offset=0x0):
+ """
+ isp_read_mram
+ retrieve mram @ word_offset
+ """
+ response = isp_build_packet(isp, ISP_COMMAND_MRAM_READ, [int(word_offset),b'\x10'])
+ if len(response) == 0:
+ return
+
+ command = response[ISP_PACKET_COMMAND_FIELD]
+ if command == ISP_COMMAND_NAK:
+ error_string = error_lookup.get(response[ISP_PACKET_DATA_FIELD])
+ if not error_string:
+ error_string = "UNKNOWN"
+ isp_print_color("blue","[ERROR] 0x{:04x} {}".format(
+ word_offset, error_string))
+ print(" ")
+ if command != ISP_COMMAND_DATA_RESPONSE:
+ return None
+
+ # write out the 4 int32 values of the MRAM line
+ isp_print_color("blue","[0x{:x}] ".format(word_offset))
+ for each_word in range(2,18,4):
+ mram_value = response[each_word:each_word+4]
+ value = int.from_bytes(mram_value,byteorder='little')
+ isp_print_color("blue","0x{:08x} ".format(value))
+ print(" ")
+
+def isp_mram_erase(isp, address, size=0,pattern=0x00000000):
+ """
+ isp_erase_mram
+ - erase ATOC memory from for with
+ """
+ delay = 0
+ if size >= 1048576: # ACK will take some time at this size
+ delay = 20
+ isp_build_packet(isp, ISP_COMMAND_ERASE_MRAM, [address,size,pattern], delay)
+
+def isp_sram_write(isp, offset, data):
+ """
+ isp_Sram_Write
+ - send data to write to the SE RAM - SEROM only
+ (used by recovery-execute-package.py)
+ """
+
+ #print("* write to offset ", hex(offset))
+ #print("* data: ", data)
+ isp_build_packet(isp, ISP_COMMAND_SRAM_WRITE, [offset, bytearray(data)])
+
+def isp_set_maintenance_flag(isp):
+ """
+ isp_set_maintenance_flag
+ - Send Command to set the maintenance flag on the target
+ """
+ message = isp_build_packet(isp, ISP_COMMAND_SET_MAINTENANCE_FLAG)
+
+def isp_get_log_data(isp):
+ """
+ isp_get_log_data
+ """
+
+ # get log buffer info
+ message = isp_build_packet(isp, ISP_COMMAND_GET, [ISP_GET_LOG_BUFFER_INFO])
+ if len(message) == 0:
+ return None
+
+ command = message[ISP_PACKET_COMMAND_FIELD]
+ if command != ISP_COMMAND_DATA_RESPONSE:
+ return None
+
+ (buffer_size,) = struct.unpack("> 4))
diff --git a/tools/alif/isp/isp_util.py b/tools/alif/isp/isp_util.py
index 7168a1695..b154b8471 100755
--- a/tools/alif/isp/isp_util.py
+++ b/tools/alif/isp/isp_util.py
@@ -1,216 +1,221 @@
-
-# pylint: disable=unused-argument, invalid-name
-"""
- isp_util.py - commonly used functions used by ISP
-
- mainly used to support ISP based MRAM burning utlties.
-"""
-import os
-import sys
-import subprocess
-import random
-from isp_core import *
-from utils.toc_common import *
-import time
-
-DATA_CHUNK_SIZE = 240
-EXIT_WITH_ERROR = 1
-
-def file_get_size(fileHandle):
- """
- file_get_zsize - given a file handle return the size in bytes
- """
- fileHandle.seek(0,os.SEEK_END)
- sizeinbytes = fileHandle.tell()
-
- return sizeinbytes
-
-def progress_bar(fileName, currentSize=0, maxSize=0, enablePrint=True):
- """
- progress_bar - print a progress bar
- """
- if maxSize <= 0:
- print("\n")
- return False
-
- progress = int((currentSize / float(maxSize)) * 100)
-
- hashes = int(progress / 5)
- printBar = (fileName.ljust(32) + "[" + "#" * hashes + " " * (20 - hashes)
- + "]")
- if enablePrint:
- progressVal = "%d%%: %d/%d bytes"%(progress, currentSize, maxSize)
- else:
- progressVal = " "
-
- print(printBar + progressVal + "\r", flush=True, end='')
-
-# if progress >= 100:
-# print("\n")
-
- return True
-
-def checkArmdbgPath():
- """
- checkArmdbgPath
- """
- cmd = 'armdbg -v'
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- shell=True, universal_newlines=True)
- output, errors = p.communicate()
- #print(errors.find("'armdbg' is not recognized as an internal"))
- if errors.find("'armdbg' is not recognized as an internal") != -1:
- print('ERROR: The ARM Debugger is not found!')
- print('Be sure you are using ARM DS Command prompt')
- print('or add the /bin')
- print('directory to your PATH environmental variable')
- sys.exit(EXIT_WITH_ERROR)
- else:
- print('Invoking ARM Debugger: ' + output)
-
-def send_authentication_command(isp, command, token):
- """
- send_authenitication_packet
- """
- cmd_packet = [0x03, command] # authenticate execute
- cmd_packet = cmd_packet + list(int_to_bytes(token))
- cmd_packet[0] = len(cmd_packet) + 1
- cmd_packet = isp.checkSum(cmd_packet) # add the checksum packet
-
- isp.writeSerial(bytearray(cmd_packet))
- isp_decode_packet(isp,"TX--> ", cmd_packet)
- #isp_wait(isp)
- message = isp_readmessage(isp)
- isp_decode_packet(isp,"RX<-- ", message)
-
-certPath = Path("cert/")
-imagePath = Path("build/images")
-
-def authenticate_image(isp, fileName):
- """
- authenticate)image
- """
-
- print("Verify Certificate")
- signatureFileName = fileName + '.sign'
- print("Signature File: ", signatureFileName)
-
- try:
- f = open(signatureFileName, 'rb')
- except IOError as e:
- print('[ERROR] {0}'.format(e))
- return 0
-
- # generate a random authentication token
- token = random.randrange(0xFFFFFFFF)
- #print("Auth Token: ", hex(token))
-
- send_authentication_command(isp, ISP_COMMAND_VERIFY_IMAGE, token)
-
- #download certificate
- with f:
- fileSize = getFilesize(f)
- offset = 0
-
- while offset < fileSize:
- f.seek(offset)
- data_line = f.read(DATA_CHUNK_SIZE)
- if isp_download_data(isp, data_line) == False:
- break
- offset = offset + DATA_CHUNK_SIZE
- f.close()
-
- isp_download_done(isp)
- return token
-
-def burn_mram_isp(isp, handler, fileName, destAddress, verbose_display, auth_image):
- """
- burn_mram_isp - use ISP method to write MRAM
- """
-
- print("Authenticate Image: ", auth_image)
- token = 0x0
- if auth_image:
- token = authenticate_image(isp, fileName)
- if token == 0:
- print('Image authentication failed!')
- return False
-
- print("Download Image")
- try:
- f = open(fileName, 'rb')
- except IOError as e:
- print('[ERROR] {0}'.format(e))
- return False
-
- with f:
- fileSize = file_get_size(f)
- offset = 0
- data_size = DATA_CHUNK_SIZE
- if fileSize <= data_size: # Deal with small ones
- data_size = 16 # CHUNK_SIZE
-
- if isp_burn_mram(isp, destAddress, fileSize, token) == False:
- return False
-
- number_of_blocks = fileSize // data_size
- left_over_blocks = fileSize % data_size
-
- start_time = time.time()
- while number_of_blocks != 0:
- f.seek(offset)
- data_line = f.read(data_size)
-
- if verbose_display is False:
- progress_bar(fileName,offset+data_size,fileSize)
-
- if isp_download_data(isp, data_line) == False:
- break
-
- offset = offset + data_size
- number_of_blocks = number_of_blocks - 1
-
- if handler.Handler_exit():
- print("[INFO] CTRL-C")
- break
-
- if number_of_blocks == 0:
- if left_over_blocks != 0:
- f.seek(offset)
- mram_line = f.read(left_over_blocks)
- isp_download_data(isp, mram_line)
-
- if verbose_display is False:
- progress_bar(fileName,offset+left_over_blocks,fileSize)
-
- print("\r")
- delay = 0
- if auth_image:
- # add a delay to account for the image verification time
- delay = fileSize / 1000000
- print("Verify Image")
-
- isp_download_done(isp, delay)
- end_time = time.time()
- print("Done\n {:10.2f} seconds\n".format(end_time-start_time))
-
- return True
-
-
-def put_target_in_maintenance_mode(isp, baud_rate, Info=True):
- """
- enable target to be maintenance mode
- Info parameter toggles the output here
- """
- if Info:
- print("[INFO] Starting Maintenance Mode entry sequence...")
- isp_start(isp)
- if Info:
- print("--> Set Maintenance Flag")
- isp_set_maintenance_flag(isp)
- isp_stop(isp)
- if Info:
- print("--> Reset Target")
- isp_reset(isp)
- if Info:
- print("[INFO] Done. Target is in Maintenance Mode")
+
+# pylint: disable=unused-argument, invalid-name
+"""
+ isp_util.py - commonly used functions used by ISP
+
+ mainly used to support ISP based MRAM burning utlties.
+"""
+import os
+import sys
+import subprocess
+import random
+from isp_core import *
+from utils.toc_common import *
+import time
+
+DATA_CHUNK_SIZE = 240
+EXIT_WITH_ERROR = 1
+
+def file_get_size(fileHandle):
+ """
+ file_get_zsize - given a file handle return the size in bytes
+ """
+ fileHandle.seek(0,os.SEEK_END)
+ sizeinbytes = fileHandle.tell()
+
+ return sizeinbytes
+
+def progress_bar(fileName, currentSize=0, maxSize=0, enablePrint=True):
+ """
+ progress_bar - print a progress bar
+ """
+ if maxSize <= 0:
+ print("\n")
+ return False
+
+ progress = int((currentSize / float(maxSize)) * 100)
+
+ hashes = int(progress / 5)
+ printBar = (fileName.ljust(32) + "[" + "#" * hashes + " " * (20 - hashes)
+ + "]")
+ if enablePrint:
+ progressVal = "%d%%: %d/%d bytes"%(progress, currentSize, maxSize)
+ else:
+ progressVal = " "
+
+ print(printBar + progressVal + "\r", flush=True, end='')
+
+# if progress >= 100:
+# print("\n")
+
+ return True
+
+def checkArmdbgPath():
+ """
+ checkArmdbgPath
+ """
+ cmd = 'armdbg -v'
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ shell=True, universal_newlines=True)
+ output, errors = p.communicate()
+ #print(errors.find("'armdbg' is not recognized as an internal"))
+ if errors.find("'armdbg' is not recognized as an internal") != -1:
+ print('ERROR: The ARM Debugger is not found!')
+ print('Be sure you are using ARM DS Command prompt')
+ print('or add the /bin')
+ print('directory to your PATH environmental variable')
+ sys.exit(EXIT_WITH_ERROR)
+ else:
+ print('Invoking ARM Debugger: ' + output)
+
+def send_authentication_command(isp, command, token):
+ """
+ send_authenitication_packet
+ """
+ cmd_packet = [0x03, command] # authenticate execute
+ cmd_packet = cmd_packet + list(int_to_bytes(token))
+ cmd_packet[0] = len(cmd_packet) + 1
+ cmd_packet = isp.checkSum(cmd_packet) # add the checksum packet
+
+ isp.writeSerial(bytearray(cmd_packet))
+ isp_decode_packet(isp,"TX--> ", cmd_packet)
+ #isp_wait(isp)
+ message = isp_readmessage(isp)
+ isp_decode_packet(isp,"RX<-- ", message)
+
+certPath = Path("cert/")
+imagePath = Path("build/images")
+
+def authenticate_image(isp, fileName):
+ """
+ authenticate)image
+ """
+
+ print("Verify Certificate")
+ signatureFileName = fileName + '.sign'
+ print("Signature File: ", signatureFileName)
+
+ try:
+ f = open(signatureFileName, 'rb')
+ except IOError as e:
+ print('[ERROR] {0}'.format(e))
+ return 0
+
+ # generate a random authentication token
+ token = random.randrange(0xFFFFFFFF)
+ #print("Auth Token: ", hex(token))
+
+ send_authentication_command(isp, ISP_COMMAND_VERIFY_IMAGE, token)
+
+ #download certificate
+ with f:
+ fileSize = getFilesize(f)
+ offset = 0
+
+ while offset < fileSize:
+ f.seek(offset)
+ data_line = f.read(DATA_CHUNK_SIZE)
+ if isp_download_data(isp, data_line) == False:
+ break
+ offset = offset + DATA_CHUNK_SIZE
+ f.close()
+
+ isp_download_done(isp)
+ return token
+
+def close_isp_and_exit(isp, msg):
+ isp.closeSerial()
+ print('\n')
+ print(msg)
+ sys.exit(EXIT_WITH_ERROR)
+
+def burn_mram_isp(isp, handler, fileName, destAddress, verbose_display, auth_image):
+ """
+ burn_mram_isp - use ISP method to write MRAM
+ """
+
+ print("Authenticate Image: ", auth_image)
+ token = 0x0
+ if auth_image:
+ token = authenticate_image(isp, fileName)
+ if token == 0:
+ print('Image authentication failed!')
+ return False
+
+ print("Download Image")
+ try:
+ f = open(fileName, 'rb')
+ except IOError as e:
+ print('[ERROR] {0}'.format(e))
+ return False
+
+ with f:
+ fileSize = file_get_size(f)
+ offset = 0
+ data_size = DATA_CHUNK_SIZE
+ if fileSize <= data_size: # Deal with small ones
+ data_size = 16 # CHUNK_SIZE
+
+ if isp_burn_mram(isp, destAddress, fileSize, token) == False:
+ return False
+
+ number_of_blocks = fileSize // data_size
+ left_over_blocks = fileSize % data_size
+
+ start_time = time.time()
+ while number_of_blocks != 0:
+ f.seek(offset)
+ data_line = f.read(data_size)
+
+ if verbose_display is False:
+ progress_bar(fileName,offset+data_size,fileSize)
+
+ if isp_download_data(isp, data_line) == False:
+ break
+
+ offset = offset + data_size
+ number_of_blocks = number_of_blocks - 1
+
+ if handler.Handler_exit():
+ close_isp_and_exit(isp, "[INFO] CTRL-C detected. User aborted this process")
+
+ if number_of_blocks == 0:
+ if left_over_blocks != 0:
+ f.seek(offset)
+ mram_line = f.read(left_over_blocks)
+ isp_download_data(isp, mram_line)
+
+ if verbose_display is False:
+ progress_bar(fileName,offset+left_over_blocks,fileSize)
+
+ print("\r")
+ delay = 0
+ if auth_image:
+ # add a delay to account for the image verification time
+ delay = fileSize / 1000000
+ print("Verify Image")
+
+ isp_download_done(isp, delay)
+ end_time = time.time()
+ print("Done\n {:10.2f} seconds\n".format(end_time-start_time))
+
+ return True
+
+
+def put_target_in_maintenance_mode(isp, baud_rate, Info=True):
+ """
+ enable target to be maintenance mode
+ Info parameter toggles the output here
+ """
+ if Info:
+ print("[INFO] Starting Maintenance Mode entry sequence...")
+ isp_start(isp)
+ if Info:
+ print("--> Set Maintenance Flag")
+ isp_set_maintenance_flag(isp)
+ isp_stop(isp)
+ if Info:
+ print("--> Reset Target")
+ isp_reset(isp)
+ if Info:
+ print("[INFO] Done. Target is in Maintenance Mode")
diff --git a/tools/alif/isp/recovery.py b/tools/alif/isp/recovery.py
index 93305e431..bd6b67117 100755
--- a/tools/alif/isp/recovery.py
+++ b/tools/alif/isp/recovery.py
@@ -1,233 +1,231 @@
-#!/usr/bin/env python3
-"""
- recovery.py
-
- Support
- - SEROM Recovery mode
- - Allows updating of the MRAM through SEROM
- - This is always ISP mode.
- __author__ = ""
- __copyright__ = "ALIF Seminconductor"
- __version__ = "0.1.0"
- __status__ = "Dev"
-
- TODO:
- - baud rate should be set to the SEROM default
-"""
-# pylint: disable=unused-argument, invalid-name, bare-except
-import sys
-sys.path.append("./isp")
-from isp_protocol import *
-from isp_core import *
-from isp_util import *
-import utils.config
-from utils.config import *
-from utils.user_validations import validateArgList
-import device_probe
-import time
-
-# Probe error codes
-PROBE_OK = 0
-PROBE_SEROM = 1
-PROBE_SERAM = 2
-PROBE_NO_MESSAGE= 3
-
-EXIT_WITH_ERROR = 1
-
-BRING_UP_MODE = 1
-
-def write_mram(isp, fileName, destAddress, verbose_display):
- """
- write_mram - use ISP method to write MRAM
- """
- try:
- f = open(fileName, 'rb')
- except IOError as e:
- print('[ERROR] {0}'.format(e))
- sys.exit(EXIT_WITH_ERROR)
- with f:
- fileSize = file_get_size(f)
-# print("FILESIZE = %d" %fileSize)
-
- # SEROM Recovery uses an Offset rather than an address
- MRAM_BASE_ADDRESS = utils.config.MRAM_BASE_ADDRESS
- offset = 0
- data_size = 16
- writeAddress = int(destAddress,base=16) - MRAM_BASE_ADDRESS
-
-# print("Actual offset = ", hex(writeAddress))
- number_of_blocks = fileSize // data_size
- left_over_blocks = fileSize % data_size
-
- start_time = time.time()
- while number_of_blocks != 0:
- f.seek(offset)
- mram_line = f.read(data_size)
-
- if verbose_display is False:
- progress_bar(fileName,offset+data_size,fileSize)
- message = isp_mram_write(isp,writeAddress,mram_line)
-
- number_of_blocks = number_of_blocks - 1
- offset = offset + data_size
- writeAddress = writeAddress + data_size # increment by 16
- if isp.CTRLCHandler.Handler_exit():
- print("[INFO] CTRL-C")
- break
-
- end_time = time.time()
- print("\r")
-
- if verbose_display is False:
- print("[INFO] recovery time {:10.2f} seconds".format(end_time-start_time))
-
- f.close()
-
-def checkTargetWithSelection(targetDescription, targetRevision,
- selectedDescription, selectedRevision):
- """
- Check target selection
- """
- partIsDifferent = False
- if targetDescription != selectedDescription:
- print('Connected target is not the default Part#')
- partIsDifferent = True
-
- if targetRevision != selectedRevision:
- print('Connected target is not the default Revision')
- partIsDifferent = True
-
- if partIsDifferent:
- try:
- answer = input('Do you want to set this part as default? (y/n): ')
- except EOFError as e:
- print('\nUser aborted the process')
- sys.exit()
-
- if answer.lower() == 'y' or answer.lower() == 'yes':
- save_global_config(targetDescription, targetRevision)
-
-def recovery_action_no_reset(isp):
- """
- Recover MRAM via SEROM. Do not reset the device at the end.
- """
- # probe the device before update
- device = device_probe.device_get_attributes(isp)
- # check SERAM is the bootloader stage
- print('Bootloader stage: ' + device_probe.STAGE_TEXT[device.stage])
- if device.stage == device_probe.STAGE_SERAM:
- print('[ERROR] Device not in Recovery mode, use updateSystemPackage Tool')
- sys.exit(EXIT_WITH_ERROR)
-
- if device.revision == 'B2': #Device Part# is not retrieved by SEROM in B2
- # load parameters based on Part# selected in tools-config
- load_global_config()
- print('Device Revision: ' + device.revision)
- else:
- if ord(device.part_number[:1]) == 0: # blank Part#
- if BRING_UP_MODE:
- print('Bring Up mode - Blank part detected!')
- if device.revision in ['B0','B2','B3','B4']: # Ensemble
- device.part_number = 'AE722F80F55D5LS'
- elif device.revision in ['EG']: # Eagle A0
- device.part_number = 'AE722F80F55D5EG'
- device.revision = 'A0'
- elif device.revision in ['B1','A0']: # Balletto B1C / E1C
- device.part_number = 'AB1C1F4M51820PH'
- else:
- print('[ERROR] Revision is not reconginzed', device.revision)
- sys.exit(EXIT_WITH_ERROR)
- else:
- print('[ERROR] There is no Part# in the device!')
- sys.exit(EXIT_WITH_ERROR)
-
- # selected device from global-cfg.db
- selectedDescription = utils.config.DEVICE_PART_NUMBER
- selectedRevision = utils.config.DEVICE_REVISION
-
- # print detected device
- print('Detected Part#: ' + device.part_number)
- print('Detected Revision: ' + device.revision)
- partDescription = getPartDescription(device.part_number)
- # load configuration from detected device
- load_device_config(partDescription, device.revision)
- # check the default Part#/Rev in tools-config and offer to switch
- checkTargetWithSelection(partDescription, device.revision,
- selectedDescription, selectedRevision)
-
- # update params from either selected part (B2) or detected part (B3/B4, etc)
- DEVICE_PART_NUMBER = utils.config.DEVICE_PART_NUMBER
- DEVICE_REVISION = utils.config.DEVICE_REVISION
- DEVICE_PACKAGE = utils.config.DEVICE_PACKAGE
- DEVICE_REV_PACKAGE_EXT = utils.config.DEVICE_REV_PACKAGE_EXT
- DEVICE_OFFSET = utils.config.DEVICE_OFFSET
- MRAM_BASE_ADDRESS = utils.config.MRAM_BASE_ADDRESS
- ALIF_BASE_ADDRESS = utils.config.ALIF_BASE_ADDRESS
- MRAM_SIZE = utils.config.MRAM_SIZE
- HASHES_DB = utils.config.HASHES_DB
-
- if device.revision == 'B2':
- if device.revision != DEVICE_REVISION:
- print("[ERROR] Target device revision (%s) mismatch with configured device (%s)"
- % (device.revision,DEVICE_REVISION))
- sys.exit(EXIT_WITH_ERROR)
-
- env_ext = ''
- if device.env.lower() in HASHES_DB:
- if HASHES_DB[device.env] == 'DEV':
- env_ext = '-dev'
-
- # for devices in CM LCS, we use the DEV package
- if device.env == '00000000000000000000000000000000':
- print('Device is not provisioned!')
- env_ext = '-dev'
-
- # Start the recovery process
- print('[INFO] System TOC Recovery with parameters:')
- print('- Device Part# ' + DEVICE_PART_NUMBER + ' - Rev: ' + DEVICE_REVISION)
- print('- MRAM Base Address: ' + hex(ALIF_BASE_ADDRESS))
-
- argList = ''
- action = 'Burning: '
-
- rev_ext = DEVICE_REV_PACKAGE_EXT[DEVICE_REVISION]
- alif_image = 'alif/' + DEVICE_PACKAGE + '-' + rev_ext + env_ext + '.bin'
- alif_offset = 'alif/' + DEVICE_OFFSET + '-' + rev_ext + env_ext + '.bin'
-
- # check images exist...
- if not os.path.exists(alif_image):
- print('Image ' + alif_image + ' does not exist!')
- sys.exit(EXIT_WITH_ERROR)
-
- if not os.path.exists(alif_offset):
- print('Image ' + alif_offset + ' does not exist!')
- sys.exit(EXIT_WITH_ERROR)
-
- argList = '../' + alif_image + ' ' + hex(ALIF_BASE_ADDRESS) + \
- ' ../' + alif_offset + ' ' + hex(MRAM_BASE_ADDRESS + MRAM_SIZE - 16)
-
- # validate all parameters
- #argList = validateArgList(action, argList.strip())
- if sys.platform == "linux" or sys.platform == "darwin":
- argList = argList.replace('../','')
- else:
- argList = argList.replace('/','\\')
-
- items = argList.split(' ')
-
- for e in range(1, len(items),2):
- addr = items[e]
- fileName = items[e-1]
- fileName = fileName.replace('..\\','')
-
- write_mram(isp, fileName, addr, False)
-
-def recovery_action(isp):
- """
- Recover MRAM via SEROM. Reset the device at the end.
- """
-
- recovery_action_no_reset(isp)
-
- print("[INFO] Target reset")
- isp_reset(isp) # Reset the target
+#!/usr/bin/env python3
+"""
+ recovery.py
+
+ Support
+ - SEROM Recovery mode
+ - Allows updating of the MRAM through SEROM
+ - This is always ISP mode.
+ __author__ = ""
+ __copyright__ = "ALIF Seminconductor"
+ __version__ = "0.1.0"
+ __status__ = "Dev"
+
+ TODO:
+ - baud rate should be set to the SEROM default
+"""
+# pylint: disable=unused-argument, invalid-name, bare-except
+import sys
+sys.path.append("./isp")
+from isp_protocol import *
+from isp_core import *
+from isp_util import *
+import utils.config
+from utils.config import *
+from utils.user_validations import validateArgList
+import device_probe
+import time
+
+# Probe error codes
+PROBE_OK = 0
+PROBE_SEROM = 1
+PROBE_SERAM = 2
+PROBE_NO_MESSAGE= 3
+
+BRING_UP_MODE = 1
+
+def write_mram(isp, fileName, destAddress, verbose_display):
+ """
+ write_mram - use ISP method to write MRAM
+ """
+ try:
+ f = open(fileName, 'rb')
+ except IOError as e:
+ close_isp_and_exit(isp, '[ERROR] {0}'.format(e))
+
+ with f:
+ fileSize = file_get_size(f)
+# print("FILESIZE = %d" %fileSize)
+
+ # SEROM Recovery uses an Offset rather than an address
+ MRAM_BASE_ADDRESS = utils.config.MRAM_BASE_ADDRESS
+ offset = 0
+ data_size = 16
+ writeAddress = int(destAddress,base=16) - MRAM_BASE_ADDRESS
+
+# print("Actual offset = ", hex(writeAddress))
+ number_of_blocks = fileSize // data_size
+ left_over_blocks = fileSize % data_size
+
+ start_time = time.time()
+ while number_of_blocks != 0:
+ f.seek(offset)
+ mram_line = f.read(data_size)
+
+ if verbose_display is False:
+ progress_bar(fileName,offset+data_size,fileSize)
+ message = isp_mram_write(isp,writeAddress,mram_line)
+
+ number_of_blocks = number_of_blocks - 1
+ offset = offset + data_size
+ writeAddress = writeAddress + data_size # increment by 16
+ if isp.CTRLCHandler.Handler_exit():
+ close_isp_and_exit(isp, "[INFO] CTRL-C detected. User aborted this process")
+
+ end_time = time.time()
+ print("\r")
+
+ if verbose_display is False:
+ print("[INFO] recovery time {:10.2f} seconds".format(end_time-start_time))
+
+ f.close()
+
+def checkTargetWithSelection(targetDescription, targetRevision,
+ selectedDescription, selectedRevision):
+ """
+ Check target selection
+ """
+ partIsDifferent = False
+ if targetDescription != selectedDescription:
+ print('Connected target is not the default Part#')
+ partIsDifferent = True
+
+ if targetRevision != selectedRevision:
+ print('Connected target is not the default Revision')
+ partIsDifferent = True
+
+ if partIsDifferent:
+ try:
+ answer = input('Do you want to set this part as default? (y/n): ')
+ except EOFError as e:
+ print('\nUser aborted the process')
+ sys.exit()
+
+ if answer.lower() == 'y' or answer.lower() == 'yes':
+ save_global_config(targetDescription, targetRevision)
+
+def recovery_action_no_reset(isp):
+ """
+ Recover MRAM via SEROM. Do not reset the device at the end.
+ """
+ # probe the device before update
+ device = device_probe.device_get_attributes(isp)
+ # check SERAM is the bootloader stage
+ print('Bootloader stage: ' + device_probe.STAGE_TEXT[device.stage])
+ if device.stage == device_probe.STAGE_SERAM:
+ close_isp_and_exit(isp, '[ERROR] Device not in Recovery mode, use updateSystemPackage Tool')
+
+ if device.revision == 'B2': #Device Part# is not retrieved by SEROM in B2
+ # load parameters based on Part# selected in tools-config
+ load_global_config()
+ print('Device Revision: ' + device.revision)
+ else:
+ if ord(device.part_number[:1]) == 0: # blank Part#
+ if BRING_UP_MODE:
+ print('Bring Up mode - Blank part detected!')
+ if device.revision in ['B0','B2','B3','B4']: # Ensemble
+ device.part_number = 'AE722F80F55D5LS'
+ elif device.revision in ['EG']: # Eagle A0
+ device.part_number = 'AE722F80F55D5EG'
+ device.revision = 'A0'
+ elif device.revision in ['B1','A0','A5']: # Balletto B1C / E1C
+ device.part_number = 'AB1C1F4M51820PH'
+ else:
+ close_isp_and_exit(isp, '[ERROR] Revision is not recognized: ' + device.revision)
+ else:
+ close_isp_and_exit(isp, '[ERROR] There is no Part# in the device!')
+
+ # selected device from global-cfg.db
+ selectedDescription = utils.config.DEVICE_PART_NUMBER
+ selectedRevision = utils.config.DEVICE_REVISION
+
+ # print detected device
+ print('Detected Part#: ' + device.part_number)
+ print('Detected Revision: ' + device.revision)
+ partDescription = getPartDescription(device.part_number)
+ # load configuration from detected device
+ load_device_config(partDescription, device.revision)
+ # check the default Part#/Rev in tools-config and offer to switch
+ checkTargetWithSelection(partDescription, device.revision,
+ selectedDescription, selectedRevision)
+
+ # update params from either selected part (B2) or detected part (B3/B4, etc)
+ DEVICE_PART_NUMBER = utils.config.DEVICE_PART_NUMBER
+ DEVICE_REVISION = utils.config.DEVICE_REVISION
+ DEVICE_PACKAGE = utils.config.DEVICE_PACKAGE
+ DEVICE_REV_PACKAGE_EXT = utils.config.DEVICE_REV_PACKAGE_EXT
+ DEVICE_OFFSET = utils.config.DEVICE_OFFSET
+ MRAM_BASE_ADDRESS = utils.config.MRAM_BASE_ADDRESS
+ ALIF_BASE_ADDRESS = utils.config.ALIF_BASE_ADDRESS
+ MRAM_SIZE = utils.config.MRAM_SIZE
+ HASHES_DB = utils.config.HASHES_DB
+
+ if device.revision == 'B2':
+ if device.revision != DEVICE_REVISION:
+ close_isp_and_exit(isp, "[ERROR] Target device revision (%s) mismatch with configured device (%s)"
+ % (device.revision,DEVICE_REVISION))
+
+ env_ext = ''
+ if device.env.lower() in HASHES_DB:
+ if HASHES_DB[device.env] == 'DEV':
+ env_ext = '-dev'
+
+ # for devices in CM LCS, we use the DEV package
+ if device.env == '00000000000000000000000000000000':
+ print('Device is not provisioned!')
+ env_ext = '-dev'
+
+ # Start the recovery process
+ print('[INFO] System TOC Recovery with parameters:')
+ print('- Device Part# ' + DEVICE_PART_NUMBER + ' - Rev: ' + DEVICE_REVISION)
+ print('- MRAM Base Address: ' + hex(ALIF_BASE_ADDRESS))
+
+ argList = ''
+ action = 'Burning: '
+
+ rev_ext = DEVICE_REV_PACKAGE_EXT[DEVICE_REVISION]
+ alif_image = 'alif/' + DEVICE_PACKAGE + '-' + rev_ext + env_ext + '.bin'
+ alif_offset = 'alif/' + DEVICE_OFFSET + '-' + rev_ext + env_ext + '.bin'
+
+ # check images exist...
+ if not os.path.exists(alif_image):
+ close_isp_and_exit(isp, 'Image ' + alif_image + ' does not exist!')
+
+ if not os.path.exists(alif_offset):
+ close_isp_and_exit(isp, 'Image ' + alif_offset + ' does not exist!')
+
+ argList = '../' + alif_image + ' ' + hex(ALIF_BASE_ADDRESS) + \
+ ' ../' + alif_offset + ' ' + hex(MRAM_BASE_ADDRESS + MRAM_SIZE - 16)
+
+ # validate all parameters
+ #argList = validateArgList(action, argList.strip())
+ if sys.platform == "linux" or sys.platform == "darwin":
+ argList = argList.replace('../','')
+ else:
+ argList = argList.replace('/','\\')
+
+ items = argList.split(' ')
+
+ for e in range(1, len(items),2):
+ addr = items[e]
+ fileName = items[e-1]
+ fileName = fileName.replace('..\\','')
+
+ write_mram(isp, fileName, addr, False)
+
+ recovery_end_exit()
+
+def recovery_action(isp):
+ """
+ Recover MRAM via SEROM. Reset the device at the end.
+ """
+
+ recovery_action_no_reset(isp)
+
+ print("[INFO] Target reset")
+ isp_reset(isp) # Reset the target
+ recovery_end_exit()
+
+def recovery_end_exit():
+ print('Recovery process finished. Please reload maintenance tool for verification')
+ sys.exit(0)
\ No newline at end of file
diff --git a/tools/alif/isp/trace_decode.py b/tools/alif/isp/trace_decode.py
index ebd0046fa..17bbbd602 100755
--- a/tools/alif/isp/trace_decode.py
+++ b/tools/alif/isp/trace_decode.py
@@ -1,785 +1,792 @@
-"""
- trace buffer decoder (SEROM and SERAM)
-
- __author__ = "ronyett"
- __copyright__ = "ALIF Seminconductor"
- __version__ = "0.02.000"
- __status__ = "Dev" "
-"""
-#!/usr/bin/env python3
-#pylint: disable=invalid-name,superfluous-parens,anomalous-unicode-escape-in-string
-
-
-TRACE_BASE_ADDRESS = 0
-NUMBER_OF_TRACES = 472 #512 # SERAM Size = 0x200, 512 Words, 2K bytes
-
-# Trace field encoding data
-FLAG_MASK_SHIFT = 0
-SEQ_ID_MASK_SHIFT = 2
-MARKER_MASK_SHIFT = 8
-ADDR_MASK_SHIFT = 16
-
-FLAG_MASK = (0x00000003)
-SEQ_ID_MASK = (0x000000FC)
-MARKER_MASK = (0x0000FF00)
-ADDR_MASK = (0xFFFF0000)
-VOID_ENTRY = (0xFFFFFFFF)
-
-TRACE_FLAG_NO_DATA = 0x00 # No data
-TRACE_FLAG_BYTE_DATA = 0x01 # Marker is 8 bit data
-TRACE_FLAG_WORD_DATA = 0x02 # Next entry is 32-bit data
-TRACE_FLAG_TIMESTAMP = 0x03 # Next entry is 32 bit TimeStamp
-
-TRACE_BUFFER_END_MARKER = 0xeeeeeeee
-
-#
-# SEROM Trace Flags
-#
-TRACE_BEGIN_RESET = 0x1
-TRACE_SE_FIREWALL = 0x2
-TRACE_HOST_FIREWALL = 0x3
-TRACE_FIREWALL_CTRL_READY = 0x4
-TRACE_FIREWALLS_INITIALIZED = 0x5
-TRACE_LCS_INITIALIZATIONS = 0x6
-TRACE_LCS_CM = 0x7 #lcs=0
-TRACE_LCS_DM = 0x8 #lcs=1
-TRACE_LCS_UNKNOWN_1 = 0x9 #lcs=2
-TRACE_LCS_UNKNOWN_2 = 0xA #lcs=3
-TRACE_LCS_UNKNOWN_3 = 0xB #lcs=4
-TRACE_LCS_SE = 0xC #lcs=5
-TRACE_LCS_UNKNOWN_4 = 0xD #lcs=6
-TRACE_LCS_RMA = 0xE #lcs=7
-TRACE_BEGIN_MAIN = 0xF
-TRACE_FIND_STOC = 0x10
-TRACE_LOCATE_CERT_CHAIN = 0x11
-TRACE_RAW_BYPASS_CHECK = 0x12
-TRACE_RAW_BYPASS = 0x13
-TRACE_VERIFY_CERT_CHAIN = 0x14
-TRACE_SRAM_RETAINED = 0x15
-TRACE_SECURE_LCS_BOOT = 0x16
-TRACE_WAKE_UP_BROWNOUT = 0x17
-TRACE_START_CM55_HE = 0x18
-TRACE_CERT_CHAIN_VERIFY_START = 0x19
-TRACE_EACH_CERT_VERIFY = 0x1A
-TRACE_CERT_CHAIN_VERIFY_END = 0x1B
-TRACE_SERAM_JUMP = 0x1C
-TRACE_PROCESS_ERROR = 0x1D
-TRACE_CERTIFICATE_ERROR = 0x1E
-TRACE_CM55_HE_FORCE_COLD_BOOT = 0x1F
-
-TRACE_CLEAR_FIRST_BOOT_MRAM_WRITE_FAIL = 0x20
-TRACE_MARK_BANK_NOT_VALID_MRAM_WRITE_FAIL = 0x21
-TRACE_SET_IMAGE_BOOTED_MRAM_WRITE_FAIL = 0x22
-TRACE_UPDATE_ERROR_CODES_MRAM_WRITE_FAIL = 0x23
-TRACE_UPDATE_BOOTFLAGS_CHECKSUM_MRAM_WRITE_FAIL = 0x24
-TRACE_BANK_A_NOT_BOOTABLE = 0x25
-TRACE_BANK_B_NOT_BOOTABLE = 0x26
-TRACE_NEWER_BANK_A = 0x27
-TRACE_NEWER_BANK_B = 0x28
-TRACE_TOC1_SERAM_OFFSET_INVALID = 0x29
-TRACE_TOC2_SERAM_OFFSET_INVALID = 0x2A
-TRACE_TOC1_EXTENSION_HEADER_INVALID = 0x2B
-TRACE_TOC2_EXTENSION_HEADER_INVALID = 0x2C
-TRACE_TOC1_BOOT_FLAGS_CHECKSUM_INVALID = 0x2D
-TRACE_TOC2_BOOT_FLAGS_CHECKSUM_INVALID = 0x2E
-TRACE_BANK_A_BOOT_FAILED = 0x2F
-TRACE_BANK_B_BOOT_FAILED = 0x30
-TRACE_WAKE_UP_RESET = 0x31
-TRACE_LOAD_MSP_ADDRESS = 0x32
-TRACE_LOAD_JUMP_ADDRESS = 0x33
-TRACE_INVALID_TOC_OFFSET = 0x34
-TRACE_CM55_HE_CPU_WAIT_RELEASE = 0x35
-TRACE_PROCESS_ERROR_EXTENDED = 0x36
-TRACE_FAST_BOOT_FIREWALL_PROTECT = 0x37
-TRACE_BEGIN_CGU_CLOCK_CONFIGURATION = 0x38
-TRACE_CGU_CLOCKS_CONFIGURED = 0x39
-TRACE_MRAM_RESET_ERROR_BYPASS = 0x3A
-TRACE_MRAM_SET_ERROR_BYPASS = 0x3B
-TRACE_BAD_SERAM_JUMP_ADDRESS = 0x3C
-TRACE_BOOT_LOADER_JUMP_RETURNED = 0x3D
-TRACE_TURN_ON_SYSTEM_POWER = 0x3E
-TRACE_SERAM_RETENTION_PATTERN = 0x3F
-
-#
-# SERAM Trace Flags
-#
-TRACE_FIREWALL_STATIC_CONFIG_BEGIN = 0x40
-TRACE_FIREWALL_STATIC_CONFIG_END = 0x41
-TRACE_PLL_INIT_BEGIN = 0x42
-TRACE_PLL_INIT_END = 0x43
-TRACE_MAINTENANCE_MODE_DETECT_BEGIN = 0x44
-TRACE_MAINTENANCE_MODE_DETECT_END = 0x45
-TRACE_CC_LIB_INIT_BEGIN = 0x46
-TRACE_CC_LIB_INIT_END = 0x47
-TRACE_M55_HE_TCM_INIT_BEGIN = 0x48
-TRACE_M55_HE_TCM_INIT_END = 0x49
-TRACE_ATOC_MISC_BEGIN = 0x4A
-TRACE_ATOC_MISC_END = 0x4B
-TRACE_STOC_DEVICE_BEGIN = 0x4C
-TRACE_STOC_DEVICE_END = 0x4D
-TRACE_STOC_PART_NUMBER = 0x4E
-TRACE_START_MAIN = 0x4F
-
-TRACE_STOC_PROCESS_BEGIN = 0x50
-TRACE_ATOC_PROCESS_BEGIN = 0x51
-TRACE_TOC_PROCESS_END = 0x52
-TRACE_TOC_PRINT_BEGIN = 0x53
-TRACE_TOC_PRINT_END = 0x54
-TRACE_BANK_MAINTENANCE_BEGIN = 0x55
-TRACE_BANK_MAINTENANCE_END = 0x56
-TRACE_CPU_RELEASE = 0x57
-TRACE_CPU_BOOT = 0x58
-TRACE_WAKE_UP = 0x59
-TRACE_COLD_BOOT = 0x5A
-TRACE_M55_FASTBOOT_SERAM = 0x5B
-TRACE_M55_TCM_RETAINED = 0x5C
-TRACE_M55_VTOR_SENTINEL = 0x5D
-TRACE_STOP_MODE_ENABLE_BEGIN = 0x5E
-TRACE_1_MAIN = 0x5F
-
-TRACE_RTOS_WFI_BEGIN = 0x60
-TRACE_RTOS_WFI_END = 0x61
-TRACE_2_MAIN = 0x62
-TRACE_3_MAIN = 0x63
-TRACE_ENTER_MAINTENANCE_MODE = 0x64
-TRACE_DCU_CONFIG_BEGIN = 0x65
-TRACE_DCU_CONFIG_END = 0x66
-TRACE_RECEIVE_MHU = 0x67
-TRACE_PROCESS_MHU = 0x68
-TRACE_FINISH_MHU = 0x69
-TRACE_SERAM_TO_M55_HP = 0x6A
-TRACE_SERAM_TO_M55_HE = 0x6B
-TRACE_M55_HP_TO_SERAM = 0x6C
-TRACE_M55_HE_TO_SERAM = 0x6D
-TRACE_BEGIN_TRIMMING = 0x6E
-TRACE_FINISH_TRIMMING = 0x6F
-
-TRACE_BEGIN_SERAM_BANK_COPY = 0x70
-TRACE_END_SERAM_BANK_COPY = 0x71
-TRACE_M55_FASTBOOT_SERAM_XIP = 0x72
-TRACE_WARM_BOOT = 0x73
-TRACE_A32_0_RELEASED = 0x74
-TRACE_A32_1_RELEASED = 0x75
-TRACE_M55_HP_RELEASED = 0x76
-TRACE_M55_HE_RELEASED = 0x77
-TRACE_MODEM_RELEASED = 0x78
-TRACE_GNSS_RELEASED = 0x79
-TRACE_DSP_RELEASED = 0x7A
-TRACE_VBAT_ANA_REG2 = 0x7B
-TRACE_VBAT_ANA_REG3 = 0x7C
-TRACE_DCDC_REG1 = 0x7D
-TRACE_COMP_REG2 = 0x7E
-TRACE_NO_TRIM_VALUES_SPECIFIED = 0x7F
-
-TRACE_SERAM_BOOT_COMPLETE = 0x80
-TRACE_SERAM_BOOT_ERROR = 0x81
-TRACE_SERAM_OS_ERROR = 0x82
-TRACE_VBAT_ANA_REG1 = 0x83
-TRACE_SOC_RESET = 0x84
-TRACE_EWIC_ENABLE = 0x85
-TRACE_EWIC_STATUS = 0x86
-TRACE_SOC_ID = 0x87
-TRACE_OVERRIDE_SOC_ID = 0x88
-TRACE_ACTIVE_SW_VERSION = 0x89
-TRACE_TOGGLE_EXTSYS0_WAKEUP = 0x8A
-TRACE_TOGGLE_EXTSYS1_WAKEUP = 0x8B
-
-TRACE_SERAM_RESET_HANDLER = 0x8E
-TRACE_FAST_BOOT = 0x8B
-
-TRACE_BANK_A_VALID = 0x90
-TRACE_BANK_B_VALID = 0x91
-TRACE_BANK_A_FIRST_BOOT = 0x92
-TRACE_BANK_B_FIRST_BOOT = 0x93
-TRACE_BANK_A_INVALID = 0x94
-TRACE_BANK_B_INVALID = 0x95
-TRACE_BOOT_BANK_A = 0x96
-TRACE_BOOT_BANK_B = 0x97
-TRACE_BANK_A_BOOTED = 0x98
-TRACE_BANK_B_BOOTED = 0x99
-TRACE_PARTIAL_TRIMMING = 0x9A
-TRACE_FULL_TRIMMING = 0x9B
-TRACE_TRIM55 = 0x9C
-TRACE_TRIM56 = 0x9D
-TRACE_TRIM57 = 0x9E
-TRACE_TRIM58 = 0x9F
-
-TRACE_RISC_V_RELEASED = 0xA0
-TRACE_RISC_V_EXTSYS0_RESET = 0xA1
-TRACE_RISC_V_EXTSYS0_SHUTDOWN = 0xA2
-TRACE_RISC_V_EXTSYS0_EXTSYS1_WAKEUP = 0xA3
-TRACE_RISC_V_EXTSYS0_WRITE_WAKEUP_SENTINEL = 0xA4
-TRACE_BISR_OTP_CHECK = 0xA5
-TRACE_BISR_NOT_NEEDED = 0xA6
-TRACE_BISR_ENABLE = 0xA7
-TRACE_BISR_FINISHED = 0xA8
-TRACE_BISR_REPAIR_FAILED = 0xA9
-TRACE_RESUME_FROM_STANDBY = 0xAA
-TRACE_BOOT_TIME_US = 0xAB
-TRACE_TURN_OFF_SE_POWER = 0xAC
-TRACE_TURN_ON_HOST_POWER = 0xAD
-
-TRACE_STOP_ENABLE_END = 0xB0
-TRACE_OFF_HANDLER = 0xB1
-TRACE_STOP_VOTES_OK = 0xB2
-TRACE_SE_PPU_INTR = 0xB3
-TRACE_ES0_PPU_INTR = 0xB4
-TRACE_ES1_PPU_INTR = 0xB5
-TRACE_STOP_BEGIN = 0xB6
-TRACE_STOP_0 = 0xB7
-TRACE_STOP_1 = 0xB8
-TRACE_STOP_2 = 0xB9
-TRACE_STOP_3 = 0xBA
-TRACE_STOP_4 = 0xBB
-TRACE_STOP_5 = 0xBC
-TRACE_STOP_6 = 0xBD
-TRACE_STOP_7 = 0xBE
-TRACE_STOP_8 = 0xBF
-
-TRACE_STOP_9 = 0xD0
-TRACE_STOP_10 = 0xD1
-TRACE_STOP_11 = 0xD2
-TRACE_STOP_12 = 0xD3
-TRACE_STOP_13 = 0xD4
-TRACE_STOP_14 = 0xD5
-TRACE_STOP_15 = 0xD6
-
-TRACE_PINMUX = 0xD7
-TRACE_BOOT_INIT = 0xD8
-TRACE_POWER_INIT = 0xD9
-TRACE_SES_INIT = 0xDA
-TRACE_MRAM_CFG = 0xDB
-TRACE_MRAM_PWR_EN = 0xDC
-
-
-
-# Marker trace translation
-marker_lookup = {
- TRACE_BEGIN_RESET : 'Begin Reset_Handler',
- TRACE_SE_FIREWALL : 'SE Firewall configuration',
- TRACE_HOST_FIREWALL : 'HOST Firewall configuration',
- TRACE_FIREWALL_CTRL_READY : 'Firewall controller ready',
- TRACE_FIREWALLS_INITIALIZED : 'Firewall initialized',
- TRACE_LCS_INITIALIZATIONS : 'Begin CC312 initializations',
- TRACE_LCS_CM : 'LCS = 0 -> CM',
- TRACE_LCS_DM : 'LCS = 1 -> DM',
- TRACE_LCS_UNKNOWN_1 : 'LCS = 2 -> UNKNOWN_1',
- TRACE_LCS_UNKNOWN_2 : 'LCS = 3 -> UNKNOWN_2',
- TRACE_LCS_UNKNOWN_3 : 'LCS = 4 -> UNKNOWN_3',
- TRACE_LCS_SE : 'LCS = SE',
- TRACE_LCS_UNKNOWN_4 : 'LCS = 6 -> UNKNOWN_4',
- TRACE_LCS_RMA : 'LCS = RMA',
- TRACE_BEGIN_MAIN : 'Begin Main',
- TRACE_FIND_STOC : 'Find STOC in MRAM',
- TRACE_LOCATE_CERT_CHAIN : 'Locate certificate chain',
- TRACE_RAW_BYPASS_CHECK : 'Raw Bypass check',
- TRACE_RAW_BYPASS : 'Raw Bypass method invoked',
- TRACE_VERIFY_CERT_CHAIN : 'Verify certificate chain',
- TRACE_SRAM_RETAINED : 'SRAM retained',
- TRACE_SECURE_LCS_BOOT : 'SECURE LCS Cold Boot',
- TRACE_WAKE_UP_BROWNOUT : 'Brownout detected',
- TRACE_START_CM55_HE : 'Fast Boot Start CM55_HE',
- TRACE_CERT_CHAIN_VERIFY_START : 'Begin certificate chain verification',
- TRACE_EACH_CERT_VERIFY : 'Verify each certificate',
- TRACE_CERT_CHAIN_VERIFY_END : 'End certificate chain verification',
- TRACE_SERAM_JUMP : 'Jump to SERAM',
- TRACE_PROCESS_ERROR : 'SEROM Error Detected',
- TRACE_CERTIFICATE_ERROR : 'Certificate Processing Error Detected',
- TRACE_CM55_HE_FORCE_COLD_BOOT : 'Force CM55-HE cold boot',
- TRACE_CLEAR_FIRST_BOOT_MRAM_WRITE_FAIL : 'Clear boot flag MRAM write failed',
- TRACE_MARK_BANK_NOT_VALID_MRAM_WRITE_FAIL : 'Mark Bank not valid MRAM write failed',
- TRACE_SET_IMAGE_BOOTED_MRAM_WRITE_FAIL : 'Set Image Booted Flag in MRAM failed',
- TRACE_UPDATE_ERROR_CODES_MRAM_WRITE_FAIL : 'Update Error Codes in MRAM failed',
- TRACE_UPDATE_BOOTFLAGS_CHECKSUM_MRAM_WRITE_FAIL: 'Update Boot Flags Checksum in MRAM failed',
- TRACE_BANK_A_NOT_BOOTABLE : 'Bank A not bootable',
- TRACE_BANK_B_NOT_BOOTABLE : 'Bank B not bootable',
- TRACE_NEWER_BANK_A : 'Bank A is newer',
- TRACE_NEWER_BANK_B : 'Bank B is newer',
- TRACE_TOC1_SERAM_OFFSET_INVALID : 'TOC1 SERAM Offset invalid',
- TRACE_TOC2_SERAM_OFFSET_INVALID : 'TOC2 SERAM Offset invalid',
- TRACE_TOC1_EXTENSION_HEADER_INVALID : 'TOC1 Extension Header invalid',
- TRACE_TOC2_EXTENSION_HEADER_INVALID : 'TOC2 Extension Header invalid',
- TRACE_TOC1_BOOT_FLAGS_CHECKSUM_INVALID : 'TOC1 Boot Flags Checksum invalid',
- TRACE_TOC2_BOOT_FLAGS_CHECKSUM_INVALID : 'TOC2 Boot Flags Checksum invalid',
- TRACE_BANK_A_BOOT_FAILED : 'BANK A boot failed',
- TRACE_BANK_B_BOOT_FAILED : 'BANK B boot failed',
- TRACE_WAKE_UP_RESET : 'SOC reset was triggered',
- TRACE_LOAD_MSP_ADDRESS : 'Load MSP Address',
- TRACE_LOAD_JUMP_ADDRESS : 'Load JUMP Address',
- TRACE_INVALID_TOC_OFFSET : 'Invalid Alif TOC offset specified',
- TRACE_CM55_HE_CPU_WAIT_RELEASE : 'CM55 HE CPU wait release',
- TRACE_PROCESS_ERROR_EXTENDED : 'SEROM Error Detected - extended error',
- TRACE_FAST_BOOT_FIREWALL_PROTECT : 'FAST BOOT configure firewall protection',
- TRACE_BEGIN_CGU_CLOCK_CONFIGURATION : 'Begin CGU clock configuration',
- TRACE_CGU_CLOCKS_CONFIGURED : 'CGU clock configuration complete',
- TRACE_MRAM_RESET_ERROR_BYPASS : 'Enable MRAM ECC Error Interrupts',
- TRACE_MRAM_SET_ERROR_BYPASS : 'Disable MRAM ECC Error Interrupts',
- TRACE_BAD_SERAM_JUMP_ADDRESS : 'Bad SERAM Jump Address',
- TRACE_BOOT_LOADER_JUMP_RETURNED : 'Boot Loader Jump Returned',
- TRACE_TURN_ON_SYSTEM_POWER : 'Turn On SE System POWER Register',
- TRACE_SERAM_RETENTION_PATTERN : 'SERAM retention pattern detected',
- TRACE_FIREWALL_STATIC_CONFIG_BEGIN : 'Firewall Static BEGIN',
- TRACE_FIREWALL_STATIC_CONFIG_END : 'Firewall Static END ',
- TRACE_PLL_INIT_BEGIN : 'PLL BEGIN',
- TRACE_PLL_INIT_END : 'PLL END',
- TRACE_MAINTENANCE_MODE_DETECT_BEGIN : 'Maintenance Detection BEGIN',
- TRACE_MAINTENANCE_MODE_DETECT_END : 'Maintenance Detection END',
- TRACE_CC_LIB_INIT_BEGIN : 'CC Lib BEGIN',
- TRACE_CC_LIB_INIT_END : 'CC Lib END',
- TRACE_M55_HE_TCM_INIT_BEGIN : 'M55 HE TCM Init BEGIN',
- TRACE_M55_HE_TCM_INIT_END : 'M55 HE TCM Init END',
- TRACE_ATOC_MISC_BEGIN : 'ATOC MISC BEGIN',
- TRACE_ATOC_MISC_END : 'ATOC MISC END',
- TRACE_STOC_DEVICE_BEGIN : 'STOC DEVICE BEGIN',
- TRACE_STOC_DEVICE_END : 'STOC DEVICE END',
- TRACE_STOC_PART_NUMBER : 'STOC Part#',
- TRACE_START_MAIN : 'main() start',
-
- TRACE_STOC_PROCESS_BEGIN : 'STOC Process BEGIN',
- TRACE_ATOC_PROCESS_BEGIN : 'ATOC Process BEGIN',
- TRACE_TOC_PROCESS_END : 'TOC Process END',
- TRACE_TOC_PRINT_BEGIN : 'TOC Print BEGIN',
- TRACE_TOC_PRINT_END : 'TOC Print END',
- TRACE_BANK_MAINTENANCE_BEGIN : 'BANK Maintenance BEGIN',
- TRACE_BANK_MAINTENANCE_END : 'BANK Maintenance END',
- TRACE_CPU_RELEASE : 'CPU release',
- TRACE_CPU_BOOT : 'CPU boot',
- TRACE_WAKE_UP : 'Wake up',
- TRACE_COLD_BOOT : 'Cold boot',
- TRACE_M55_FASTBOOT_SERAM : 'M55 fast boot by SERAM',
- TRACE_M55_TCM_RETAINED : 'M55 TCM was retained',
- TRACE_M55_VTOR_SENTINEL : 'M55 VTOR SENTINEL detected',
- TRACE_STOP_MODE_ENABLE_BEGIN : 'Stop mode enable BEGIN',
- TRACE_1_MAIN : 'main() 1',
-
- TRACE_RTOS_WFI_BEGIN : 'RTOS Wfi BEGIN',
- TRACE_RTOS_WFI_END : 'RTOS Wfi END',
- TRACE_2_MAIN : 'main() 2',
- TRACE_3_MAIN : 'main() 3',
- TRACE_ENTER_MAINTENANCE_MODE : 'Enter maintenance mode',
- TRACE_DCU_CONFIG_BEGIN : 'Begin DCU configuration',
- TRACE_DCU_CONFIG_END : 'Finish DCU configuration',
- TRACE_RECEIVE_MHU : 'Receive MHU',
- TRACE_PROCESS_MHU : 'Process MHU',
- TRACE_FINISH_MHU : 'Finish MHU',
- TRACE_SERAM_TO_M55_HP : 'SERAM to M55_HP MHU',
- TRACE_SERAM_TO_M55_HE : 'SERAM to M55_HE MHU',
- TRACE_M55_HP_TO_SERAM : 'M55_HP to SERAM MHU',
- TRACE_M55_HE_TO_SERAM : 'M55_HE to SERAM MHU',
- TRACE_BEGIN_TRIMMING : 'Begin installing analog trim values',
- TRACE_FINISH_TRIMMING : 'Finish installing analog trim values',
- TRACE_BEGIN_SERAM_BANK_COPY : 'SERAM bank copy BEGIN',
- TRACE_END_SERAM_BANK_COPY : 'SERAM bank copy END',
- TRACE_M55_FASTBOOT_SERAM_XIP : 'M55 XIP fast boot by SERAM',
- TRACE_WARM_BOOT : 'Warm boot',
- TRACE_A32_0_RELEASED : 'A32_0 released',
- TRACE_A32_1_RELEASED : 'A32_1 released',
- TRACE_M55_HP_RELEASED : 'M55_HP released',
- TRACE_M55_HE_RELEASED : 'M55_HE released',
- TRACE_MODEM_RELEASED : 'M55 MODEM released',
- TRACE_GNSS_RELEASED : 'M55 GNSS released',
- TRACE_DSP_RELEASED : 'DSP released',
- TRACE_VBAT_ANA_REG1 : 'Program VBAT_ANA_REG1',
- TRACE_VBAT_ANA_REG2 : 'Program VBAT_ANA_REG2',
- TRACE_VBAT_ANA_REG3 : 'Program VBAT_ANA_REG3',
- TRACE_DCDC_REG1 : 'Program DCDC_REG1',
- TRACE_COMP_REG2 : 'Program COMP_REG2',
- TRACE_NO_TRIM_VALUES_SPECIFIED : 'No trim values specified',
- TRACE_SERAM_BOOT_COMPLETE : 'SERAM boot complete',
- TRACE_SERAM_BOOT_ERROR : 'SERAM boot error',
- TRACE_SERAM_OS_ERROR : 'SERAM operating system boot error',
- TRACE_BANK_A_VALID : 'BANK A is VALID',
- TRACE_BANK_B_VALID : 'BANK B is VALID',
- TRACE_BANK_A_FIRST_BOOT : 'BANK A is FIRST BOOT',
- TRACE_BANK_B_FIRST_BOOT : 'BANK B is FIRST BOOT',
- TRACE_BANK_A_INVALID : 'BANK A is INVALID',
- TRACE_BANK_B_INVALID : 'BANK B is INVALID',
- TRACE_BOOT_BANK_A : 'BOOT BANK A',
- TRACE_BOOT_BANK_B : 'BOOT BANK B',
- TRACE_BANK_A_BOOTED : 'BANK A BOOTED',
- TRACE_BANK_B_BOOTED : 'BANK B BOOTED',
- TRACE_FULL_TRIMMING : 'Full trim specified',
- TRACE_TRIM55 : 'Trim OTP word 0x55',
- TRACE_TRIM56 : 'Trim OTP word 0x56',
- TRACE_TRIM57 : 'Trim OTP word 0x57',
- TRACE_TRIM58 : 'Trim OTP word 0x58',
- TRACE_SOC_RESET : 'SOC Reset Cold Boot',
- TRACE_EWIC_ENABLE : 'Configure EWIC Enable',
- TRACE_EWIC_STATUS : 'Read EWIC Status',
- TRACE_SOC_ID : 'Read SOC_ID',
- TRACE_OVERRIDE_SOC_ID : 'Override SOC_ID',
- TRACE_ACTIVE_SW_VERSION : 'Certificate Active Software Version',
- TRACE_TOGGLE_EXTSYS0_WAKEUP : 'Toggle EXTSYS0 Wakeup',
- TRACE_TOGGLE_EXTSYS1_WAKEUP : 'Toggle EXTSYS1 Wakeup',
- TRACE_SERAM_RESET_HANDLER : 'SERAM reset handler',
- TRACE_FAST_BOOT : 'FAST BOOT',
- TRACE_RISC_V_RELEASED : 'RISC-V released',
- TRACE_RISC_V_EXTSYS0_RESET : 'EXTSYS0 Reset',
- TRACE_RISC_V_EXTSYS0_SHUTDOWN : 'EXTSYS0 Shutdown',
- TRACE_RISC_V_EXTSYS0_EXTSYS1_WAKEUP : 'EXTSYS1 Wakeup',
- TRACE_RISC_V_EXTSYS0_WRITE_WAKEUP_SENTINEL : 'EXTSYS0 Sentinel write',
- TRACE_BISR_OTP_CHECK : 'BISR OTP check',
- TRACE_BISR_NOT_NEEDED : 'BISR not needed',
- TRACE_BISR_ENABLE : 'BISR enable',
- TRACE_BISR_FINISHED : 'BISR finished',
- TRACE_BISR_REPAIR_FAILED : 'BISR repair failed',
- TRACE_RESUME_FROM_STANDBY : 'Resume from STANDBY mode',
- TRACE_BOOT_TIME_US : 'Boot time in us',
- TRACE_TURN_OFF_SE_POWER : 'Turn off SE POWER register',
- TRACE_TURN_ON_HOST_POWER : 'Turn on HOST POWER register',
- TRACE_BISR_REPAIR_FAILED : 'BISR repair failed',
- TRACE_STOP_ENABLE_END : 'Stop mode enable END',
- TRACE_OFF_HANDLER : 'OFF mode handler',
- TRACE_STOP_VOTES_OK : 'STOP votes OK',
- TRACE_SE_PPU_INTR : 'SE PPU interrupt',
- TRACE_ES0_PPU_INTR : 'ES0 PPU interrupt',
- TRACE_ES1_PPU_INTR : 'ES1 PPU interrupt',
- TRACE_STOP_BEGIN : 'STOP mode settings begin',
- TRACE_STOP_0 : 'STOP_0',
- TRACE_STOP_1 : 'STOP_1',
- TRACE_STOP_2 : 'STOP_2',
- TRACE_STOP_3 : 'STOP_3',
- TRACE_STOP_4 : 'STOP_4',
- TRACE_STOP_5 : 'STOP_5',
- TRACE_STOP_6 : 'STOP_6',
- TRACE_STOP_7 : 'STOP_7',
- TRACE_STOP_8 : 'STOP_8',
- TRACE_STOP_9 : 'STOP_9',
- TRACE_STOP_10 : 'STOP_10',
- TRACE_STOP_11 : 'STOP_11',
- TRACE_STOP_12 : 'STOP_12',
- TRACE_STOP_13 : 'STOP_13',
- TRACE_STOP_14 : 'STOP_14',
- TRACE_STOP_15 : 'STOP_15',
- TRACE_PINMUX : 'PinMux',
- TRACE_BOOT_INIT : 'Boot Init',
- TRACE_POWER_INIT : 'Power Init',
- TRACE_SES_INIT : 'Ses Init',
- TRACE_MRAM_CFG : 'MRAM config',
- TRACE_MRAM_PWR_EN : 'MRAM power enable'
-}
-
-service_id_lut = {
- 0 : "SERVICE_MAINTENANCE_HEARTBEAT_ID",
- 1 : "SERVICE_MAINTENANCE_RTC_ID",
-
- 100 : "SERVICE_APPLICATION_CLOCK_MANAGEMENT",
- 101 : "SERVICE_APPLICATION_PINMUX_ID",
- 102 : "SERVICE_APPLICATION_PAD_CONTROL_ID",
- 103 : "SERVICE_APPLICATION_FIRMWARE_VERSION_ID",
- 104 : 'SERVICE_APPLICATION_UART_WRITE_ID',
- 105 : "SERVICE_APPLICATION_OSPI_WRITE_KEY_ID",
- 106 : "SERVICE_APPLICATION_DMPU_ID",
-
- 200 : "SERVICE_SYSTEM_MGMT_GET_TOC_VERSION",
- 201 : "SERVICE_SYSTEM_MGMT_GET_TOC_NUMBER",
- 202 : "SERVICE_SYSTEM_MGMT_GET_TOC_FLAGS",
- 203 : "SERVICE_SYSTEM_MGMT_GET_TOC_VIA_CPU_ID",
- 204 : "SERVICE_SYSTEM_MGMT_GET_TOC_VIA_CPU_NAME",
- 205 : "SERVICE_SYSTEM_MGMT_GET_TOC_INFO",
- 206 : "SERVICE_SYSTEM_MGMT_GET_OTP_INFO",
- 207 : "SERVICE_SYSTEM_MGMT_GET_DEVICE_PART_NUMBER",
- 208 : "SERVICE_SYSTEM_MGMT_GET_DEVICE_REVISION_DATA",
- 209 : "SERVICE_SYSTEM_MGMT_SET_CAPABILITIES_DEBUG",
- 210 : "SERVICE_SYSTEM_MGMT_READ_OTP",
- 211 : "SERVICE_SYSTEM_MGMT_WRITE_OTP",
-
- 300 : "SERVICE_POWER_STOP_MODE_REQ_ID",
- 301 : "SERVICE_POWER_EWIC_CONFIG_REQ_ID",
- 302 : "SERVICE_POWER_VBAT_WAKEUP_CONFIG_REQ_ID",
- 303 : "SERVICE_POWER_MEM_RETENTION_CONFIG_REQ_ID",
- 304 : "SERVICE_POWER_M55_HE_VTOR_SAVE_REQ_ID",
- 305 : "SERVICE_POWER_M55_HP_VTOR_SAVE_REQ_ID",
- 306 : "SERVICE_POWER_GLOBAL_STANDBY_REQ_ID",
- 307 : "SERVICE_POWER_MEMORY_POWER_REQ_ID",
- 308 : "SERVICE_POWER_DCDC_VOLTAGE_REQ_ID",
- 309 : "SERVICE_POWER_LDO_VOLTAGE_REQ_ID",
- 310 : "SERVICE_POWER_GET_RUN_REQ_ID",
- 311 : "SERVICE_POWER_SET_RUN_REQ_ID",
- 312 : "SERVICE_POWER_GET_OFF_REQ_ID",
- 313 : "SERVICE_POWER_SET_OFF_REQ_ID",
- 314 : "SERVICE_POWER_SETTING_CONFIG_REQ_ID",
- 315 : "SERVICE_POWER_SETTING_GET_REQ_ID",
-
- 400 : "SERVICE_CRYPTOCELL_GET_RND",
- 401 : "SERVICE_CRYPTOCELL_GET_LCS",
- 402 : "SERVICE_CRYPTOCELL_MBEDTLS_AES_INIT",
- 403 : "SERVICE_CRYPTOCELL_MBEDTLS_AES_SET_KEY",
- 404 : "SERVICE_CRYPTOCELL_MBEDTLS_AES_CRYPT",
- 405 : "SERVICE_CRYPTOCELL_MBEDTLS_CCM_GCM_SET_KEY",
- 406 : "SERVICE_CRYPTOCELL_MBEDTLS_CCM_GCM_CRYPT",
- 407 : "SERVICE_CRYPTOCELL_MBEDTLS_CHACHA20_CRYPT",
- 408 : "SERVICE_CRYPTOCELL_MBEDTLS_CHACHAPOLY_CRYPT",
- 409 : "SERVICE_CRYPTOCELL_MBEDTLS_POLY1305_CRYPT",
- 410 : "SERVICE_CRYPTOCELL_MBEDTLS_SHA_STARTS",
- 411 : "SERVICE_CRYPTOCELL_MBEDTLS_SHA_PROCESS",
- 412 : "SERVICE_CRYPTOCELL_MBEDTLS_SHA_UPDATE",
- 413 : "SERVICE_CRYPTOCELL_MBEDTLS_SHA_FINISH",
- 414 : "SERVICE_CRYPTOCELL_MBEDTLS_TRNG_HARDWARE_POLL",
- 415 : "SERVICE_CRYPTOCELL_MBEDTLS_CMAC_INIT_SETKEY",
- 416 : "SERVICE_CRYPTOCELL_MBEDTLS_CMAC_UPDATE",
- 417 : "SERVICE_CRYPTOCELL_MBEDTLS_CMAC_FINISH",
- 418 : "SERVICE_CRYPTOCELL_MBEDTLS_CMAC_RESET",
-
- 500 : "SERVICE_BOOT_PROCESS_TOC_ENTRY",
- 501 : "SERVICE_BOOT_CPU",
- 502 : "SERVICE_BOOT_RELEASE_CPU",
- 503 : "SERVICE_BOOT_RESET_CPU",
- 504 : "SERVICE_BOOT_RESET_SOC",
- 505 : "SERVICE_BOOT_SET_VTOR",
- 506 : "SERVICE_BOOT_SET_ARGS",
-
- 600 : "SERVICE_UPDATE_STOC",
-
- 700 : "SERVICE_CLOCK_SELECT_OSC",
- 701 : "SERVICE_CLOCK_SELECT_PLL",
- 702 : "SERVICE_CLOCK_SET",
- 703 : "SERVICE_CLOCK_ES0_SE",
- 704 : "SERVICE_CLOCK_ES1_SE",
- 705 : "SERVICE_CLOCK_SELECT_A32",
- 706 : "SERVICE_CLOCK_SELECT_ACLK",
- 707 : "SERVICE_CLOCK_SET_D",
- 708 : "SERVICE_PLL_INIT",
- 709 : "SERVICE_PLL_DEINIT",
- 710 : "SERVICE_PLL_XTAL_START",
- 711 : "SERVICE_PLL_XTAL_STOP",
- 712 : "SERVICE_PLL_XTAL_IS_STARTED",
- 713 : "SERVICE_PLL_CLKPLL_START",
- 714 : "SERVICE_PLL_CLKPLL_STOP",
- 715 : "SERVICE_PLL_CLKPLL_IS_LOCKED",
- 716 : "SERVICE_CLOCK_GET",
-
- 800 : "SERVICE_EXTSYS0_BOOT_SET_ARGS",
- 801 : "SERVICE_EXTSYS0_EXTSYS1_WAKEUP",
- 802 : "SERVICE_EXTSYS0_SHUTDOWN"
-}
-
-def readMemory32(address,offset):
- """
- return an integer from byte list provided
- """
- return int.from_bytes([address[offset+0],
- address[offset+1],
- address[offset+2],
- address[offset+3]],"little")
-
-def trace_find_marker(marker_value, buffer):
- """
- look for the Trace end marker in the trace buffer
- @todo should look for the full 32-bits of the marker
- """
- marker_found = False
- position = 0
-
- if marker_value in buffer:
- marker_found = True
- position = buffer.index(marker_value)
-
- return marker_found, position
-
-def trace_find_end_marker(end_marker_value, trace_buffer):
- """
- look for the Trace end marker in the trace buffer
- @todo should look for the full 32-bits of the marker
- """
- marker_found = False
- position = 0
-
- for each_trace_item in range(0,NUMBER_OF_TRACES+4+4,4):
- trace_word = readMemory32(trace_buffer,
- each_trace_item)
-# print("[{0:08x}] {1:8x}".format(trace_word,end_marker_value))
- if trace_word == end_marker_value :
- marker_found = True
- position = each_trace_item
- #print("End marker 0x%x found at position 0x%x" %(end_marker_value, position))
- break
- return marker_found, position
-
-def trace_buffer_decode(trace_buffer, seram_flag):
- """
- trace_buffer_decode
- based on the JYTHON code from ARM-DS
-
- Instead of using actual memory addresses, it is using an array passed
-
- """
- if (seram_flag):
- print("*** SERAM Trace Buffer decode ***")
- else:
- print("*** SEROM Trace Buffer decode ***")
-
-# print("[DEBUG] trace_buffer_len %d Marker Pos %d\n" % (
-# len(trace_buffer),
-# trace_buffer.index(0xee)))
-
- # Look for the end of trace marker
- marker_found, end_of_trace = trace_find_end_marker(TRACE_BUFFER_END_MARKER,
- trace_buffer)
- if not marker_found:
- print("[ERROR] No end of trace marker was found")
- return
-
- # trace vars structure is at the end of the trace buffer
- # header start
- trace_vars_address = end_of_trace - 4
-
- trace_vars_p = readMemory32(trace_buffer, trace_vars_address)
- print("*** Trace Header ***")
- print("[0x{0:08x}] 0x{1:08x}".format(trace_vars_address,trace_vars_p))
-
- trace_total = (trace_vars_p >> 16) & 0xFF
- #print("trace_vars_p >> 16 trace_total = 0x%x" %(trace_total))
- trace_total = min(trace_total, NUMBER_OF_TRACES / 4)
-
- trace_vars_address += 4
- trace_vars_p = trace_buffer[trace_vars_address]
- print("[0x{0:08x}] 0x{1:08x}" .format(trace_vars_address,
- readMemory32(trace_buffer,trace_vars_address)))
- print("trace_total = %d" %(trace_total))
- print("********************")
-
- # Decode the trace buffer
- print(" Address Seq# LR Trace Marker Marker Data")
-
- word_offset = 0
-
- while trace_total > 0:
- #print(" ")
- #print("while() start. trace_total = 0x%x" %(trace_total))
- variable_enabled = False
- read_address = TRACE_BASE_ADDRESS + word_offset
- trace_item = readMemory32(trace_buffer,read_address)
- if trace_item == VOID_ENTRY:
- print(" XXXXXXXX")
- else:
- flag = (trace_item & FLAG_MASK) >> FLAG_MASK_SHIFT
- seq_id = (trace_item & SEQ_ID_MASK) >> SEQ_ID_MASK_SHIFT
- addr = (trace_item & ADDR_MASK) >> ADDR_MASK_SHIFT
- marker = (trace_item & MARKER_MASK) >> MARKER_MASK_SHIFT
-
- #print("word_offset = 0x%x" %(word_offset))
- #print("trace_item = 0x%x" %(trace_item))
- #print("flag = 0x%x" %(flag))
- #print("marker = 0x%x" %(marker))
- #print("read_address = 0x%x" %(read_address))
-
- if TRACE_FLAG_WORD_DATA == flag:
- #print("TRACE_FLAG_WORD_DATA")
- #trace_total = trace_total - 1 #marker + data
-
- read_address = TRACE_BASE_ADDRESS + word_offset
- # second 32-bit word is data we need, advance the word_offset
- #word_offset = word_offset + 4
- word_offset = (word_offset + 4) % NUMBER_OF_TRACES
- word_data_address = TRACE_BASE_ADDRESS + word_offset
- word_data = readMemory32(trace_buffer,word_data_address)
-
- #print("word_offset = 0x%x" %(word_offset))
- #print("word_data_address = 0x%x" %(word_data_address))
- #print("word_data = 0x%x" %(word_data))
-
- if marker in marker_lookup:
- marker_string = marker_lookup[marker]
- if marker_string is None:
- marker_string = "MARKER?"
- variable_enabled = False
- else:
- variable_enabled = True
-
- #print("marker_string = %s" %(marker_string))
- marker = (trace_item & MARKER_MASK) >> MARKER_MASK
-# print("[%08x] %2d %8X %4X %2X" %(read_address,
-# seq_id,
-# trace_item,
-# addr,
-# marker))
-# print("variable_enabled = %d" %(variable_enabled))
- if (marker_string.__eq__("Process MHU")):
- service_id_string = service_id_lut[word_data]
- print("[%08x] %2d 0x%04X %-45s %s" %(read_address,
- seq_id, addr, marker_string, service_id_string))
- elif variable_enabled is True:
- if marker_string.__eq__("STOC Part#"):
- print("PART NUMBER#1")
- print("[%08x] %2d 0x%04X %8X 0x%08X %c" %(read_address,
- addr, seq_id, 0x10, trace_item, word_data, chr(word_data & 0xFF)))
- else:
- print("[%08x] %2d 0x%04X %8X 0x%08X" %(read_address,
- seq_id, addr, trace_item, word_data))
- else:
- if marker_string.__eq__("STOC Part#"): # Decode the STOC Part #
- print("[%08x] %2d 0x%04X %-45s 0x%08X %c%c%c%c" %(read_address,
- seq_id, addr, marker_string, word_data,
- chr(word_data & 0xFF),
- chr(word_data >> 8 & 0xFF),
- chr(word_data >> 16 & 0xFF),
- chr(word_data >> 24 & 0xFF) )
- )
- else:
- print("[%08x] %2d 0x%04X %-45s 0x%08X" %(read_address,
- seq_id, addr, marker_string, word_data))
-
- elif TRACE_FLAG_TIMESTAMP == flag:
- #print("TRACE_FLAG_TIMESTAMP")
- #trace_total = trace_total - 1 #marker + timestamp
- # second 32-bit word is time stamp, advance the word_offset
- #word_offset = word_offset + 4
- word_offset = (word_offset + 4) % NUMBER_OF_TRACES
- read_address = TRACE_BASE_ADDRESS + word_offset
- trace_item_dword = readMemory32(trace_buffer,read_address)
-
- #print("word_offset = 0x%x" %(word_offset))
- #print("read_address = 0x%x" %(read_address))
- #print("trace_item_dword = 0x%x" %(trace_item_dword))
-
- if marker in marker_lookup:
- marker_string = marker_lookup[marker]
- if marker_string is None:
- marker_string = "MARKER?"
- variable_enabled = False
- else:
- variable_enabled = True
- print("[%08x] %2d 0x%04X %-45s T:%8d" %(
- read_address,
- seq_id,
- addr,
- marker_string,
- trace_item_dword))
-
- elif TRACE_FLAG_BYTE_DATA == flag:
- #print("TRACE_FLAG_BYTE_DATA")
- if marker in marker_lookup:
- marker_string = marker_lookup[marker]
- if marker_string is None:
- marker_string = "MARKER?"
- variable_enabled = False
- else:
- variable_enabled = True
-
- if variable_enabled is True:
- print("[%08x] %2d 0x%04X %2X" %(read_address,
- seq_id,
- addr,
- marker))
- else:
- print("[%08x] %2d 0x%04X %-45s" %(read_address,
- seq_id,
- addr,
- marker_string))
-
- else:
- #print("Unknown flag = 0x%x" %(flag))
- print("[%08x] %2d 0x%04X 0x%04X 0x%02X" %(read_address,
- seq_id,
- trace_item,
- addr,
- marker))
-
- word_offset = (word_offset + 4) % NUMBER_OF_TRACES
-
- trace_total = trace_total - 1
-
-# if word_offset >= (NUMBER_OF_TRACES * 4):
- if word_offset >= (NUMBER_OF_TRACES):
- break
+"""
+ trace buffer decoder (SEROM and SERAM)
+
+ __author__ = "ronyett"
+ __copyright__ = "ALIF Seminconductor"
+ __version__ = "0.02.000"
+ __status__ = "Dev" "
+"""
+#!/usr/bin/env python3
+#pylint: disable=invalid-name,superfluous-parens,anomalous-unicode-escape-in-string
+
+
+TRACE_BASE_ADDRESS = 0
+NUMBER_OF_TRACES = 472 #512 # SERAM Size = 0x200, 512 Words, 2K bytes
+
+# Trace field encoding data
+FLAG_MASK_SHIFT = 0
+SEQ_ID_MASK_SHIFT = 2
+MARKER_MASK_SHIFT = 8
+ADDR_MASK_SHIFT = 16
+
+FLAG_MASK = (0x00000003)
+SEQ_ID_MASK = (0x000000FC)
+MARKER_MASK = (0x0000FF00)
+ADDR_MASK = (0xFFFF0000)
+VOID_ENTRY = (0xFFFFFFFF)
+
+TRACE_FLAG_NO_DATA = 0x00 # No data
+TRACE_FLAG_BYTE_DATA = 0x01 # Marker is 8 bit data
+TRACE_FLAG_WORD_DATA = 0x02 # Next entry is 32-bit data
+TRACE_FLAG_TIMESTAMP = 0x03 # Next entry is 32 bit TimeStamp
+
+TRACE_BUFFER_END_MARKER = 0xeeeeeeee
+
+#
+# SEROM Trace Flags
+#
+TRACE_BEGIN_RESET = 0x1
+TRACE_SE_FIREWALL = 0x2
+TRACE_HOST_FIREWALL = 0x3
+TRACE_FIREWALL_CTRL_READY = 0x4
+TRACE_FIREWALLS_INITIALIZED = 0x5
+TRACE_LCS_INITIALIZATIONS = 0x6
+TRACE_LCS_CM = 0x7 #lcs=0
+TRACE_LCS_DM = 0x8 #lcs=1
+TRACE_LCS_UNKNOWN_1 = 0x9 #lcs=2
+TRACE_LCS_UNKNOWN_2 = 0xA #lcs=3
+TRACE_LCS_UNKNOWN_3 = 0xB #lcs=4
+TRACE_LCS_SE = 0xC #lcs=5
+TRACE_LCS_UNKNOWN_4 = 0xD #lcs=6
+TRACE_LCS_RMA = 0xE #lcs=7
+TRACE_BEGIN_MAIN = 0xF
+TRACE_FIND_STOC = 0x10
+TRACE_LOCATE_CERT_CHAIN = 0x11
+TRACE_RAW_BYPASS_CHECK = 0x12
+TRACE_RAW_BYPASS = 0x13
+TRACE_VERIFY_CERT_CHAIN = 0x14
+TRACE_SRAM_RETAINED = 0x15
+TRACE_SECURE_LCS_BOOT = 0x16
+TRACE_WAKE_UP_BROWNOUT = 0x17
+TRACE_START_CM55_HE = 0x18
+TRACE_CERT_CHAIN_VERIFY_START = 0x19
+TRACE_EACH_CERT_VERIFY = 0x1A
+TRACE_CERT_CHAIN_VERIFY_END = 0x1B
+TRACE_SERAM_JUMP = 0x1C
+TRACE_PROCESS_ERROR = 0x1D
+TRACE_CERTIFICATE_ERROR = 0x1E
+TRACE_CM55_HE_FORCE_COLD_BOOT = 0x1F
+
+TRACE_CLEAR_FIRST_BOOT_MRAM_WRITE_FAIL = 0x20
+TRACE_MARK_BANK_NOT_VALID_MRAM_WRITE_FAIL = 0x21
+TRACE_SET_IMAGE_BOOTED_MRAM_WRITE_FAIL = 0x22
+TRACE_UPDATE_ERROR_CODES_MRAM_WRITE_FAIL = 0x23
+TRACE_UPDATE_BOOTFLAGS_CHECKSUM_MRAM_WRITE_FAIL = 0x24
+TRACE_BANK_A_NOT_BOOTABLE = 0x25
+TRACE_BANK_B_NOT_BOOTABLE = 0x26
+TRACE_NEWER_BANK_A = 0x27
+TRACE_NEWER_BANK_B = 0x28
+TRACE_TOC1_SERAM_OFFSET_INVALID = 0x29
+TRACE_TOC2_SERAM_OFFSET_INVALID = 0x2A
+TRACE_TOC1_EXTENSION_HEADER_INVALID = 0x2B
+TRACE_TOC2_EXTENSION_HEADER_INVALID = 0x2C
+TRACE_TOC1_BOOT_FLAGS_CHECKSUM_INVALID = 0x2D
+TRACE_TOC2_BOOT_FLAGS_CHECKSUM_INVALID = 0x2E
+TRACE_BANK_A_BOOT_FAILED = 0x2F
+TRACE_BANK_B_BOOT_FAILED = 0x30
+TRACE_WAKE_UP_RESET = 0x31
+TRACE_LOAD_MSP_ADDRESS = 0x32
+TRACE_LOAD_JUMP_ADDRESS = 0x33
+TRACE_INVALID_TOC_OFFSET = 0x34
+TRACE_CM55_HE_CPU_WAIT_RELEASE = 0x35
+TRACE_PROCESS_ERROR_EXTENDED = 0x36
+TRACE_FAST_BOOT_FIREWALL_PROTECT = 0x37
+TRACE_BEGIN_CGU_CLOCK_CONFIGURATION = 0x38
+TRACE_CGU_CLOCKS_CONFIGURED = 0x39
+TRACE_MRAM_RESET_ERROR_BYPASS = 0x3A
+TRACE_MRAM_SET_ERROR_BYPASS = 0x3B
+TRACE_BAD_SERAM_JUMP_ADDRESS = 0x3C
+TRACE_BOOT_LOADER_JUMP_RETURNED = 0x3D
+TRACE_TURN_ON_SYSTEM_POWER = 0x3E
+TRACE_SERAM_RETENTION_PATTERN = 0x3F
+
+#
+# SERAM Trace Flags
+#
+TRACE_FIREWALL_STATIC_CONFIG_BEGIN = 0x40
+TRACE_FIREWALL_STATIC_CONFIG_END = 0x41
+TRACE_PLL_INIT_BEGIN = 0x42
+TRACE_PLL_INIT_END = 0x43
+TRACE_MAINTENANCE_MODE_DETECT_BEGIN = 0x44
+TRACE_MAINTENANCE_MODE_DETECT_END = 0x45
+TRACE_CC_LIB_INIT_BEGIN = 0x46
+TRACE_CC_LIB_INIT_END = 0x47
+TRACE_M55_HE_TCM_INIT_BEGIN = 0x48
+TRACE_M55_HE_TCM_INIT_END = 0x49
+TRACE_ATOC_MISC_BEGIN = 0x4A
+TRACE_ATOC_MISC_END = 0x4B
+TRACE_STOC_DEVICE_BEGIN = 0x4C
+TRACE_STOC_DEVICE_END = 0x4D
+TRACE_STOC_PART_NUMBER = 0x4E
+TRACE_START_MAIN = 0x4F
+
+TRACE_STOC_PROCESS_BEGIN = 0x50
+TRACE_ATOC_PROCESS_BEGIN = 0x51
+TRACE_TOC_PROCESS_END = 0x52
+TRACE_TOC_PRINT_BEGIN = 0x53
+TRACE_TOC_PRINT_END = 0x54
+TRACE_BANK_MAINTENANCE_BEGIN = 0x55
+TRACE_BANK_MAINTENANCE_END = 0x56
+TRACE_CPU_RELEASE = 0x57
+TRACE_CPU_BOOT = 0x58
+TRACE_WAKE_UP = 0x59
+TRACE_COLD_BOOT = 0x5A
+TRACE_M55_FASTBOOT_SERAM = 0x5B
+TRACE_M55_TCM_RETAINED = 0x5C
+TRACE_M55_VTOR_SENTINEL = 0x5D
+TRACE_STOP_MODE_ENABLE_BEGIN = 0x5E
+TRACE_1_MAIN = 0x5F
+
+TRACE_RTOS_WFI_BEGIN = 0x60
+TRACE_RTOS_WFI_END = 0x61
+TRACE_2_MAIN = 0x62
+TRACE_3_MAIN = 0x63
+TRACE_ENTER_MAINTENANCE_MODE = 0x64
+TRACE_DCU_CONFIG_BEGIN = 0x65
+TRACE_DCU_CONFIG_END = 0x66
+TRACE_RECEIVE_MHU = 0x67
+TRACE_PROCESS_MHU = 0x68
+TRACE_FINISH_MHU = 0x69
+TRACE_SERAM_TO_M55_HP = 0x6A
+TRACE_SERAM_TO_M55_HE = 0x6B
+TRACE_M55_HP_TO_SERAM = 0x6C
+TRACE_M55_HE_TO_SERAM = 0x6D
+TRACE_BEGIN_TRIMMING = 0x6E
+TRACE_FINISH_TRIMMING = 0x6F
+
+TRACE_BEGIN_SERAM_BANK_COPY = 0x70
+TRACE_END_SERAM_BANK_COPY = 0x71
+TRACE_M55_FASTBOOT_SERAM_XIP = 0x72
+TRACE_WARM_BOOT = 0x73
+TRACE_A32_0_RELEASED = 0x74
+TRACE_A32_1_RELEASED = 0x75
+TRACE_M55_HP_RELEASED = 0x76
+TRACE_M55_HE_RELEASED = 0x77
+TRACE_MODEM_RELEASED = 0x78
+TRACE_GNSS_RELEASED = 0x79
+TRACE_DSP_RELEASED = 0x7A
+TRACE_VBAT_ANA_REG2 = 0x7B
+TRACE_VBAT_ANA_REG3 = 0x7C
+TRACE_DCDC_REG1 = 0x7D
+TRACE_COMP_REG2 = 0x7E
+TRACE_NO_TRIM_VALUES_SPECIFIED = 0x7F
+
+TRACE_SERAM_BOOT_COMPLETE = 0x80
+TRACE_SERAM_BOOT_ERROR = 0x81
+TRACE_SERAM_OS_ERROR = 0x82
+TRACE_VBAT_ANA_REG1 = 0x83
+TRACE_SOC_RESET = 0x84
+TRACE_EWIC_ENABLE = 0x85
+TRACE_EWIC_STATUS = 0x86
+TRACE_SOC_ID = 0x87
+TRACE_OVERRIDE_SOC_ID = 0x88
+TRACE_ACTIVE_SW_VERSION = 0x89
+TRACE_TOGGLE_EXTSYS0_WAKEUP = 0x8A
+TRACE_TOGGLE_EXTSYS1_WAKEUP = 0x8B
+TRACE_MRAM_WRITE_FAILURE = 0x8C
+TRACE_MRAM_CONTROLLER_ERROR = 0x8D
+TRACE_SERAM_RESET_HANDLER = 0x8E
+TRACE_FAST_BOOT = 0x8B
+
+TRACE_BANK_A_VALID = 0x90
+TRACE_BANK_B_VALID = 0x91
+TRACE_BANK_A_FIRST_BOOT = 0x92
+TRACE_BANK_B_FIRST_BOOT = 0x93
+TRACE_BANK_A_INVALID = 0x94
+TRACE_BANK_B_INVALID = 0x95
+TRACE_BOOT_BANK_A = 0x96
+TRACE_BOOT_BANK_B = 0x97
+TRACE_BANK_A_BOOTED = 0x98
+TRACE_BANK_B_BOOTED = 0x99
+TRACE_PARTIAL_TRIMMING = 0x9A
+TRACE_FULL_TRIMMING = 0x9B
+TRACE_TRIM55 = 0x9C
+TRACE_TRIM56 = 0x9D
+TRACE_TRIM57 = 0x9E
+TRACE_TRIM58 = 0x9F
+
+TRACE_RISC_V_RELEASED = 0xA0
+TRACE_RISC_V_EXTSYS0_RESET = 0xA1
+TRACE_RISC_V_EXTSYS0_SHUTDOWN = 0xA2
+TRACE_RISC_V_EXTSYS0_EXTSYS1_WAKEUP = 0xA3
+TRACE_RISC_V_EXTSYS0_WRITE_WAKEUP_SENTINEL = 0xA4
+TRACE_BISR_OTP_CHECK = 0xA5
+TRACE_BISR_NOT_NEEDED = 0xA6
+TRACE_BISR_ENABLE = 0xA7
+TRACE_BISR_FINISHED = 0xA8
+TRACE_BISR_REPAIR_FAILED = 0xA9
+TRACE_RESUME_FROM_STANDBY = 0xAA
+TRACE_BOOT_TIME_US = 0xAB
+TRACE_TURN_OFF_SE_POWER = 0xAC
+TRACE_TURN_ON_HOST_POWER = 0xAD
+TRACE_HARD_FAULT = 0xAE
+TRACE_HARD_FAULT_PC = 0xAF
+
+TRACE_STOP_ENABLE_END = 0xB0
+TRACE_OFF_HANDLER = 0xB1
+TRACE_STOP_VOTES_OK = 0xB2
+TRACE_SE_PPU_INTR = 0xB3
+TRACE_ES0_PPU_INTR = 0xB4
+TRACE_ES1_PPU_INTR = 0xB5
+TRACE_STOP_BEGIN = 0xB6
+TRACE_STOP_0 = 0xB7
+TRACE_STOP_1 = 0xB8
+TRACE_STOP_2 = 0xB9
+TRACE_STOP_3 = 0xBA
+TRACE_STOP_4 = 0xBB
+TRACE_STOP_5 = 0xBC
+TRACE_STOP_6 = 0xBD
+TRACE_STOP_7 = 0xBE
+TRACE_STOP_8 = 0xBF
+
+TRACE_STOP_9 = 0xD0
+TRACE_STOP_10 = 0xD1
+TRACE_STOP_11 = 0xD2
+TRACE_STOP_12 = 0xD3
+TRACE_STOP_13 = 0xD4
+TRACE_STOP_14 = 0xD5
+TRACE_STOP_15 = 0xD6
+
+TRACE_PINMUX = 0xD7
+TRACE_BOOT_INIT = 0xD8
+TRACE_POWER_INIT = 0xD9
+TRACE_SES_INIT = 0xDA
+TRACE_MRAM_CFG = 0xDB
+TRACE_MRAM_PWR_EN = 0xDC
+TRACE_HARD_FAULT_LR = 0xDD
+
+# Marker trace translation
+marker_lookup = {
+ TRACE_BEGIN_RESET : 'Begin Reset_Handler',
+ TRACE_SE_FIREWALL : 'SE Firewall configuration',
+ TRACE_HOST_FIREWALL : 'HOST Firewall configuration',
+ TRACE_FIREWALL_CTRL_READY : 'Firewall controller ready',
+ TRACE_FIREWALLS_INITIALIZED : 'Firewall initialized',
+ TRACE_LCS_INITIALIZATIONS : 'Begin CC312 initializations',
+ TRACE_LCS_CM : 'LCS = 0 -> CM',
+ TRACE_LCS_DM : 'LCS = 1 -> DM',
+ TRACE_LCS_UNKNOWN_1 : 'LCS = 2 -> UNKNOWN_1',
+ TRACE_LCS_UNKNOWN_2 : 'LCS = 3 -> UNKNOWN_2',
+ TRACE_LCS_UNKNOWN_3 : 'LCS = 4 -> UNKNOWN_3',
+ TRACE_LCS_SE : 'LCS = SE',
+ TRACE_LCS_UNKNOWN_4 : 'LCS = 6 -> UNKNOWN_4',
+ TRACE_LCS_RMA : 'LCS = RMA',
+ TRACE_BEGIN_MAIN : 'Begin Main',
+ TRACE_FIND_STOC : 'Find STOC in MRAM',
+ TRACE_LOCATE_CERT_CHAIN : 'Locate certificate chain',
+ TRACE_RAW_BYPASS_CHECK : 'Raw Bypass check',
+ TRACE_RAW_BYPASS : 'Raw Bypass method invoked',
+ TRACE_VERIFY_CERT_CHAIN : 'Verify certificate chain',
+ TRACE_SRAM_RETAINED : 'SRAM retained',
+ TRACE_SECURE_LCS_BOOT : 'SECURE LCS Cold Boot',
+ TRACE_WAKE_UP_BROWNOUT : 'Brownout detected',
+ TRACE_START_CM55_HE : 'Fast Boot Start CM55_HE',
+ TRACE_CERT_CHAIN_VERIFY_START : 'Begin certificate chain verification',
+ TRACE_EACH_CERT_VERIFY : 'Verify each certificate',
+ TRACE_CERT_CHAIN_VERIFY_END : 'End certificate chain verification',
+ TRACE_SERAM_JUMP : 'Jump to SERAM',
+ TRACE_PROCESS_ERROR : 'SEROM Error Detected',
+ TRACE_CERTIFICATE_ERROR : 'Certificate Processing Error Detected',
+ TRACE_CM55_HE_FORCE_COLD_BOOT : 'Force CM55-HE cold boot',
+ TRACE_CLEAR_FIRST_BOOT_MRAM_WRITE_FAIL : 'Clear boot flag MRAM write failed',
+ TRACE_MARK_BANK_NOT_VALID_MRAM_WRITE_FAIL : 'Mark Bank not valid MRAM write failed',
+ TRACE_SET_IMAGE_BOOTED_MRAM_WRITE_FAIL : 'Set Image Booted Flag in MRAM failed',
+ TRACE_UPDATE_ERROR_CODES_MRAM_WRITE_FAIL : 'Update Error Codes in MRAM failed',
+ TRACE_UPDATE_BOOTFLAGS_CHECKSUM_MRAM_WRITE_FAIL: 'Update Boot Flags Checksum in MRAM failed',
+ TRACE_BANK_A_NOT_BOOTABLE : 'Bank A not bootable',
+ TRACE_BANK_B_NOT_BOOTABLE : 'Bank B not bootable',
+ TRACE_NEWER_BANK_A : 'Bank A is newer',
+ TRACE_NEWER_BANK_B : 'Bank B is newer',
+ TRACE_TOC1_SERAM_OFFSET_INVALID : 'TOC1 SERAM Offset invalid',
+ TRACE_TOC2_SERAM_OFFSET_INVALID : 'TOC2 SERAM Offset invalid',
+ TRACE_TOC1_EXTENSION_HEADER_INVALID : 'TOC1 Extension Header invalid',
+ TRACE_TOC2_EXTENSION_HEADER_INVALID : 'TOC2 Extension Header invalid',
+ TRACE_TOC1_BOOT_FLAGS_CHECKSUM_INVALID : 'TOC1 Boot Flags Checksum invalid',
+ TRACE_TOC2_BOOT_FLAGS_CHECKSUM_INVALID : 'TOC2 Boot Flags Checksum invalid',
+ TRACE_BANK_A_BOOT_FAILED : 'BANK A boot failed',
+ TRACE_BANK_B_BOOT_FAILED : 'BANK B boot failed',
+ TRACE_WAKE_UP_RESET : 'SOC reset was triggered',
+ TRACE_LOAD_MSP_ADDRESS : 'Load MSP Address',
+ TRACE_LOAD_JUMP_ADDRESS : 'Load JUMP Address',
+ TRACE_INVALID_TOC_OFFSET : 'Invalid Alif TOC offset specified',
+ TRACE_CM55_HE_CPU_WAIT_RELEASE : 'CM55 HE CPU wait release',
+ TRACE_PROCESS_ERROR_EXTENDED : 'SEROM Error Detected - extended error',
+ TRACE_FAST_BOOT_FIREWALL_PROTECT : 'FAST BOOT configure firewall protection',
+ TRACE_BEGIN_CGU_CLOCK_CONFIGURATION : 'Begin CGU clock configuration',
+ TRACE_CGU_CLOCKS_CONFIGURED : 'CGU clock configuration complete',
+ TRACE_MRAM_RESET_ERROR_BYPASS : 'Enable MRAM ECC Error Interrupts',
+ TRACE_MRAM_SET_ERROR_BYPASS : 'Disable MRAM ECC Error Interrupts',
+ TRACE_BAD_SERAM_JUMP_ADDRESS : 'Bad SERAM Jump Address',
+ TRACE_BOOT_LOADER_JUMP_RETURNED : 'Boot Loader Jump Returned',
+ TRACE_TURN_ON_SYSTEM_POWER : 'Turn On SE System POWER Register',
+ TRACE_SERAM_RETENTION_PATTERN : 'SERAM retention pattern detected',
+ TRACE_FIREWALL_STATIC_CONFIG_BEGIN : 'Firewall Static BEGIN',
+ TRACE_FIREWALL_STATIC_CONFIG_END : 'Firewall Static END ',
+ TRACE_PLL_INIT_BEGIN : 'PLL BEGIN',
+ TRACE_PLL_INIT_END : 'PLL END',
+ TRACE_MAINTENANCE_MODE_DETECT_BEGIN : 'Maintenance Detection BEGIN',
+ TRACE_MAINTENANCE_MODE_DETECT_END : 'Maintenance Detection END',
+ TRACE_CC_LIB_INIT_BEGIN : 'CC Lib BEGIN',
+ TRACE_CC_LIB_INIT_END : 'CC Lib END',
+ TRACE_M55_HE_TCM_INIT_BEGIN : 'M55 HE TCM Init BEGIN',
+ TRACE_M55_HE_TCM_INIT_END : 'M55 HE TCM Init END',
+ TRACE_ATOC_MISC_BEGIN : 'ATOC MISC BEGIN',
+ TRACE_ATOC_MISC_END : 'ATOC MISC END',
+ TRACE_STOC_DEVICE_BEGIN : 'STOC DEVICE BEGIN',
+ TRACE_STOC_DEVICE_END : 'STOC DEVICE END',
+ TRACE_STOC_PART_NUMBER : 'STOC Part#',
+ TRACE_START_MAIN : 'main() start',
+
+ TRACE_STOC_PROCESS_BEGIN : 'STOC Process BEGIN',
+ TRACE_ATOC_PROCESS_BEGIN : 'ATOC Process BEGIN',
+ TRACE_TOC_PROCESS_END : 'TOC Process END',
+ TRACE_TOC_PRINT_BEGIN : 'TOC Print BEGIN',
+ TRACE_TOC_PRINT_END : 'TOC Print END',
+ TRACE_BANK_MAINTENANCE_BEGIN : 'BANK Maintenance BEGIN',
+ TRACE_BANK_MAINTENANCE_END : 'BANK Maintenance END',
+ TRACE_CPU_RELEASE : 'CPU release',
+ TRACE_CPU_BOOT : 'CPU boot',
+ TRACE_WAKE_UP : 'Wake up',
+ TRACE_COLD_BOOT : 'Cold boot',
+ TRACE_M55_FASTBOOT_SERAM : 'M55 fast boot by SERAM',
+ TRACE_M55_TCM_RETAINED : 'M55 TCM was retained',
+ TRACE_M55_VTOR_SENTINEL : 'M55 VTOR SENTINEL detected',
+ TRACE_STOP_MODE_ENABLE_BEGIN : 'Stop mode enable BEGIN',
+ TRACE_1_MAIN : 'main() 1',
+
+ TRACE_RTOS_WFI_BEGIN : 'RTOS Wfi BEGIN',
+ TRACE_RTOS_WFI_END : 'RTOS Wfi END',
+ TRACE_2_MAIN : 'main() 2',
+ TRACE_3_MAIN : 'main() 3',
+ TRACE_ENTER_MAINTENANCE_MODE : 'Enter maintenance mode',
+ TRACE_DCU_CONFIG_BEGIN : 'Begin DCU configuration',
+ TRACE_DCU_CONFIG_END : 'Finish DCU configuration',
+ TRACE_RECEIVE_MHU : 'Receive MHU',
+ TRACE_PROCESS_MHU : 'Process MHU',
+ TRACE_FINISH_MHU : 'Finish MHU',
+ TRACE_SERAM_TO_M55_HP : 'SERAM to M55_HP MHU',
+ TRACE_SERAM_TO_M55_HE : 'SERAM to M55_HE MHU',
+ TRACE_M55_HP_TO_SERAM : 'M55_HP to SERAM MHU',
+ TRACE_M55_HE_TO_SERAM : 'M55_HE to SERAM MHU',
+ TRACE_BEGIN_TRIMMING : 'Begin installing analog trim values',
+ TRACE_FINISH_TRIMMING : 'Finish installing analog trim values',
+ TRACE_BEGIN_SERAM_BANK_COPY : 'SERAM bank copy BEGIN',
+ TRACE_END_SERAM_BANK_COPY : 'SERAM bank copy END',
+ TRACE_M55_FASTBOOT_SERAM_XIP : 'M55 XIP fast boot by SERAM',
+ TRACE_WARM_BOOT : 'Warm boot',
+ TRACE_A32_0_RELEASED : 'A32_0 released',
+ TRACE_A32_1_RELEASED : 'A32_1 released',
+ TRACE_M55_HP_RELEASED : 'M55_HP released',
+ TRACE_M55_HE_RELEASED : 'M55_HE released',
+ TRACE_MODEM_RELEASED : 'M55 MODEM released',
+ TRACE_GNSS_RELEASED : 'M55 GNSS released',
+ TRACE_DSP_RELEASED : 'DSP released',
+ TRACE_VBAT_ANA_REG1 : 'Program VBAT_ANA_REG1',
+ TRACE_VBAT_ANA_REG2 : 'Program VBAT_ANA_REG2',
+ TRACE_VBAT_ANA_REG3 : 'Program VBAT_ANA_REG3',
+ TRACE_DCDC_REG1 : 'Program DCDC_REG1',
+ TRACE_COMP_REG2 : 'Program COMP_REG2',
+ TRACE_NO_TRIM_VALUES_SPECIFIED : 'No trim values specified',
+ TRACE_SERAM_BOOT_COMPLETE : 'SERAM boot complete',
+ TRACE_SERAM_BOOT_ERROR : 'SERAM boot error',
+ TRACE_SERAM_OS_ERROR : 'SERAM operating system boot error',
+ TRACE_BANK_A_VALID : 'BANK A is VALID',
+ TRACE_BANK_B_VALID : 'BANK B is VALID',
+ TRACE_BANK_A_FIRST_BOOT : 'BANK A is FIRST BOOT',
+ TRACE_BANK_B_FIRST_BOOT : 'BANK B is FIRST BOOT',
+ TRACE_BANK_A_INVALID : 'BANK A is INVALID',
+ TRACE_BANK_B_INVALID : 'BANK B is INVALID',
+ TRACE_BOOT_BANK_A : 'BOOT BANK A',
+ TRACE_BOOT_BANK_B : 'BOOT BANK B',
+ TRACE_BANK_A_BOOTED : 'BANK A BOOTED',
+ TRACE_BANK_B_BOOTED : 'BANK B BOOTED',
+ TRACE_FULL_TRIMMING : 'Full trim specified',
+ TRACE_TRIM55 : 'Trim OTP word 0x55',
+ TRACE_TRIM56 : 'Trim OTP word 0x56',
+ TRACE_TRIM57 : 'Trim OTP word 0x57',
+ TRACE_TRIM58 : 'Trim OTP word 0x58',
+ TRACE_SOC_RESET : 'SOC Reset Cold Boot',
+ TRACE_EWIC_ENABLE : 'Configure EWIC Enable',
+ TRACE_EWIC_STATUS : 'Read EWIC Status',
+ TRACE_SOC_ID : 'Read SOC_ID',
+ TRACE_OVERRIDE_SOC_ID : 'Override SOC_ID',
+ TRACE_ACTIVE_SW_VERSION : 'Certificate Active Software Version',
+ TRACE_TOGGLE_EXTSYS0_WAKEUP : 'Toggle EXTSYS0 Wakeup',
+ TRACE_TOGGLE_EXTSYS1_WAKEUP : 'Toggle EXTSYS1 Wakeup',
+ TRACE_MRAM_WRITE_FAILURE : 'MRAM Write Miscompare Failure',
+ TRACE_MRAM_CONTROLLER_ERROR : 'MRAM Write Controller Error',
+ TRACE_SERAM_RESET_HANDLER : 'SERAM reset handler',
+ TRACE_FAST_BOOT : 'FAST BOOT',
+ TRACE_RISC_V_RELEASED : 'RISC-V released',
+ TRACE_RISC_V_EXTSYS0_RESET : 'EXTSYS0 Reset',
+ TRACE_RISC_V_EXTSYS0_SHUTDOWN : 'EXTSYS0 Shutdown',
+ TRACE_RISC_V_EXTSYS0_EXTSYS1_WAKEUP : 'EXTSYS1 Wakeup',
+ TRACE_RISC_V_EXTSYS0_WRITE_WAKEUP_SENTINEL : 'EXTSYS0 Sentinel write',
+ TRACE_BISR_OTP_CHECK : 'BISR OTP check',
+ TRACE_BISR_NOT_NEEDED : 'BISR not needed',
+ TRACE_BISR_ENABLE : 'BISR enable',
+ TRACE_BISR_FINISHED : 'BISR finished',
+ TRACE_BISR_REPAIR_FAILED : 'BISR repair failed',
+ TRACE_RESUME_FROM_STANDBY : 'Resume from STANDBY mode',
+ TRACE_BOOT_TIME_US : 'Boot time in us',
+ TRACE_TURN_OFF_SE_POWER : 'Turn off SE POWER register',
+ TRACE_TURN_ON_HOST_POWER : 'Turn on HOST POWER register',
+ TRACE_HARD_FAULT : 'HARD FAULT - R0',
+ TRACE_HARD_FAULT_PC : 'HARD FAULT - PC',
+ TRACE_BISR_REPAIR_FAILED : 'BISR repair failed',
+ TRACE_STOP_ENABLE_END : 'Stop mode enable END',
+ TRACE_OFF_HANDLER : 'OFF mode handler',
+ TRACE_STOP_VOTES_OK : 'STOP votes OK',
+ TRACE_SE_PPU_INTR : 'SE PPU interrupt',
+ TRACE_ES0_PPU_INTR : 'ES0 PPU interrupt',
+ TRACE_ES1_PPU_INTR : 'ES1 PPU interrupt',
+ TRACE_STOP_BEGIN : 'STOP mode settings begin',
+ TRACE_STOP_0 : 'STOP_0',
+ TRACE_STOP_1 : 'STOP_1',
+ TRACE_STOP_2 : 'STOP_2',
+ TRACE_STOP_3 : 'STOP_3',
+ TRACE_STOP_4 : 'STOP_4',
+ TRACE_STOP_5 : 'STOP_5',
+ TRACE_STOP_6 : 'STOP_6',
+ TRACE_STOP_7 : 'STOP_7',
+ TRACE_STOP_8 : 'STOP_8',
+ TRACE_STOP_9 : 'STOP_9',
+ TRACE_STOP_10 : 'STOP_10',
+ TRACE_STOP_11 : 'STOP_11',
+ TRACE_STOP_12 : 'STOP_12',
+ TRACE_STOP_13 : 'STOP_13',
+ TRACE_STOP_14 : 'STOP_14',
+ TRACE_STOP_15 : 'STOP_15',
+ TRACE_PINMUX : 'PinMux',
+ TRACE_BOOT_INIT : 'Boot Init',
+ TRACE_POWER_INIT : 'Power Init',
+ TRACE_SES_INIT : 'Ses Init',
+ TRACE_MRAM_CFG : 'MRAM config',
+ TRACE_MRAM_PWR_EN : 'MRAM power enable',
+ TRACE_HARD_FAULT_LR : 'HARD FAULT - LR'
+}
+
+service_id_lut = {
+ 0 : "SERVICE_MAINTENANCE_HEARTBEAT_ID",
+ 1 : "SERVICE_MAINTENANCE_RTC_ID",
+
+ 100 : "SERVICE_APPLICATION_CLOCK_MANAGEMENT",
+ 101 : "SERVICE_APPLICATION_PINMUX_ID",
+ 102 : "SERVICE_APPLICATION_PAD_CONTROL_ID",
+ 103 : "SERVICE_APPLICATION_FIRMWARE_VERSION_ID",
+ 104 : 'SERVICE_APPLICATION_UART_WRITE_ID',
+ 105 : "SERVICE_APPLICATION_OSPI_WRITE_KEY_ID",
+ 106 : "SERVICE_APPLICATION_DMPU_ID",
+
+ 200 : "SERVICE_SYSTEM_MGMT_GET_TOC_VERSION",
+ 201 : "SERVICE_SYSTEM_MGMT_GET_TOC_NUMBER",
+ 202 : "SERVICE_SYSTEM_MGMT_GET_TOC_FLAGS",
+ 203 : "SERVICE_SYSTEM_MGMT_GET_TOC_VIA_CPU_ID",
+ 204 : "SERVICE_SYSTEM_MGMT_GET_TOC_VIA_CPU_NAME",
+ 205 : "SERVICE_SYSTEM_MGMT_GET_TOC_INFO",
+ 206 : "SERVICE_SYSTEM_MGMT_GET_OTP_INFO",
+ 207 : "SERVICE_SYSTEM_MGMT_GET_DEVICE_PART_NUMBER",
+ 208 : "SERVICE_SYSTEM_MGMT_GET_DEVICE_REVISION_DATA",
+ 209 : "SERVICE_SYSTEM_MGMT_SET_CAPABILITIES_DEBUG",
+ 210 : "SERVICE_SYSTEM_MGMT_READ_OTP",
+ 211 : "SERVICE_SYSTEM_MGMT_WRITE_OTP",
+
+ 300 : "SERVICE_POWER_STOP_MODE_REQ_ID",
+ 301 : "SERVICE_POWER_EWIC_CONFIG_REQ_ID",
+ 302 : "SERVICE_POWER_VBAT_WAKEUP_CONFIG_REQ_ID",
+ 303 : "SERVICE_POWER_MEM_RETENTION_CONFIG_REQ_ID",
+ 304 : "SERVICE_POWER_M55_HE_VTOR_SAVE_REQ_ID",
+ 305 : "SERVICE_POWER_M55_HP_VTOR_SAVE_REQ_ID",
+ 306 : "SERVICE_POWER_GLOBAL_STANDBY_REQ_ID",
+ 307 : "SERVICE_POWER_MEMORY_POWER_REQ_ID",
+ 308 : "SERVICE_POWER_DCDC_VOLTAGE_REQ_ID",
+ 309 : "SERVICE_POWER_LDO_VOLTAGE_REQ_ID",
+ 310 : "SERVICE_POWER_GET_RUN_REQ_ID",
+ 311 : "SERVICE_POWER_SET_RUN_REQ_ID",
+ 312 : "SERVICE_POWER_GET_OFF_REQ_ID",
+ 313 : "SERVICE_POWER_SET_OFF_REQ_ID",
+ 314 : "SERVICE_POWER_SETTING_CONFIG_REQ_ID",
+ 315 : "SERVICE_POWER_SETTING_GET_REQ_ID",
+
+ 400 : "SERVICE_CRYPTOCELL_GET_RND",
+ 401 : "SERVICE_CRYPTOCELL_GET_LCS",
+ 402 : "SERVICE_CRYPTOCELL_MBEDTLS_AES_INIT",
+ 403 : "SERVICE_CRYPTOCELL_MBEDTLS_AES_SET_KEY",
+ 404 : "SERVICE_CRYPTOCELL_MBEDTLS_AES_CRYPT",
+ 405 : "SERVICE_CRYPTOCELL_MBEDTLS_CCM_GCM_SET_KEY",
+ 406 : "SERVICE_CRYPTOCELL_MBEDTLS_CCM_GCM_CRYPT",
+ 407 : "SERVICE_CRYPTOCELL_MBEDTLS_CHACHA20_CRYPT",
+ 408 : "SERVICE_CRYPTOCELL_MBEDTLS_CHACHAPOLY_CRYPT",
+ 409 : "SERVICE_CRYPTOCELL_MBEDTLS_POLY1305_CRYPT",
+ 410 : "SERVICE_CRYPTOCELL_MBEDTLS_SHA_STARTS",
+ 411 : "SERVICE_CRYPTOCELL_MBEDTLS_SHA_PROCESS",
+ 412 : "SERVICE_CRYPTOCELL_MBEDTLS_SHA_UPDATE",
+ 413 : "SERVICE_CRYPTOCELL_MBEDTLS_SHA_FINISH",
+ 414 : "SERVICE_CRYPTOCELL_MBEDTLS_TRNG_HARDWARE_POLL",
+ 415 : "SERVICE_CRYPTOCELL_MBEDTLS_CMAC_INIT_SETKEY",
+ 416 : "SERVICE_CRYPTOCELL_MBEDTLS_CMAC_UPDATE",
+ 417 : "SERVICE_CRYPTOCELL_MBEDTLS_CMAC_FINISH",
+ 418 : "SERVICE_CRYPTOCELL_MBEDTLS_CMAC_RESET",
+
+ 500 : "SERVICE_BOOT_PROCESS_TOC_ENTRY",
+ 501 : "SERVICE_BOOT_CPU",
+ 502 : "SERVICE_BOOT_RELEASE_CPU",
+ 503 : "SERVICE_BOOT_RESET_CPU",
+ 504 : "SERVICE_BOOT_RESET_SOC",
+ 505 : "SERVICE_BOOT_SET_VTOR",
+ 506 : "SERVICE_BOOT_SET_ARGS",
+
+ 600 : "SERVICE_UPDATE_STOC",
+
+ 700 : "SERVICE_CLOCK_SELECT_OSC",
+ 701 : "SERVICE_CLOCK_SELECT_PLL",
+ 702 : "SERVICE_CLOCK_SET",
+ 703 : "SERVICE_CLOCK_ES0_SE",
+ 704 : "SERVICE_CLOCK_ES1_SE",
+ 705 : "SERVICE_CLOCK_SELECT_A32",
+ 706 : "SERVICE_CLOCK_SELECT_ACLK",
+ 707 : "SERVICE_CLOCK_SET_D",
+ 708 : "SERVICE_PLL_INIT",
+ 709 : "SERVICE_PLL_DEINIT",
+ 710 : "SERVICE_PLL_XTAL_START",
+ 711 : "SERVICE_PLL_XTAL_STOP",
+ 712 : "SERVICE_PLL_XTAL_IS_STARTED",
+ 713 : "SERVICE_PLL_CLKPLL_START",
+ 714 : "SERVICE_PLL_CLKPLL_STOP",
+ 715 : "SERVICE_PLL_CLKPLL_IS_LOCKED",
+ 716 : "SERVICE_CLOCK_GET",
+
+ 800 : "SERVICE_EXTSYS0_BOOT_SET_ARGS",
+ 801 : "SERVICE_EXTSYS0_EXTSYS1_WAKEUP",
+ 802 : "SERVICE_EXTSYS0_SHUTDOWN"
+}
+
+def readMemory32(address,offset):
+ """
+ return an integer from byte list provided
+ """
+ return int.from_bytes([address[offset+0],
+ address[offset+1],
+ address[offset+2],
+ address[offset+3]],"little")
+
+def trace_find_marker(marker_value, buffer):
+ """
+ look for the Trace end marker in the trace buffer
+ @todo should look for the full 32-bits of the marker
+ """
+ marker_found = False
+ position = 0
+
+ if marker_value in buffer:
+ marker_found = True
+ position = buffer.index(marker_value)
+
+ return marker_found, position
+
+def trace_find_end_marker(end_marker_value, trace_buffer):
+ """
+ look for the Trace end marker in the trace buffer
+ @todo should look for the full 32-bits of the marker
+ """
+ marker_found = False
+ position = 0
+
+ for each_trace_item in range(0,NUMBER_OF_TRACES+4+4,4):
+ trace_word = readMemory32(trace_buffer,
+ each_trace_item)
+# print("[{0:08x}] {1:8x}".format(trace_word,end_marker_value))
+ if trace_word == end_marker_value :
+ marker_found = True
+ position = each_trace_item
+ #print("End marker 0x%x found at position 0x%x" %(end_marker_value, position))
+ break
+ return marker_found, position
+
+def trace_buffer_decode(trace_buffer, seram_flag):
+ """
+ trace_buffer_decode
+ based on the JYTHON code from ARM-DS
+
+ Instead of using actual memory addresses, it is using an array passed
+
+ """
+ if (seram_flag):
+ print("*** SERAM Trace Buffer decode ***")
+ else:
+ print("*** SEROM Trace Buffer decode ***")
+
+# print("[DEBUG] trace_buffer_len %d Marker Pos %d\n" % (
+# len(trace_buffer),
+# trace_buffer.index(0xee)))
+
+ # Look for the end of trace marker
+ marker_found, end_of_trace = trace_find_end_marker(TRACE_BUFFER_END_MARKER,
+ trace_buffer)
+ if not marker_found:
+ print("[ERROR] No end of trace marker was found")
+ return
+
+ # trace vars structure is at the end of the trace buffer
+ # header start
+ trace_vars_address = end_of_trace - 4
+
+ trace_vars_p = readMemory32(trace_buffer, trace_vars_address)
+ print("*** Trace Header ***")
+ print("[0x{0:08x}] 0x{1:08x}".format(trace_vars_address,trace_vars_p))
+
+ trace_total = (trace_vars_p >> 16) & 0xFF
+ #print("trace_vars_p >> 16 trace_total = 0x%x" %(trace_total))
+ trace_total = min(trace_total, NUMBER_OF_TRACES / 4)
+
+ trace_vars_address += 4
+ trace_vars_p = trace_buffer[trace_vars_address]
+ print("[0x{0:08x}] 0x{1:08x}" .format(trace_vars_address,
+ readMemory32(trace_buffer,trace_vars_address)))
+ print("trace_total = %d" %(trace_total))
+ print("********************")
+
+ # Decode the trace buffer
+ print(" Address Seq# LR Trace Marker Marker Data")
+
+ word_offset = 0
+
+ while trace_total > 0:
+ #print(" ")
+ #print("while() start. trace_total = 0x%x" %(trace_total))
+ variable_enabled = False
+ read_address = TRACE_BASE_ADDRESS + word_offset
+ trace_item = readMemory32(trace_buffer,read_address)
+ if trace_item == VOID_ENTRY:
+ print(" XXXXXXXX")
+ else:
+ flag = (trace_item & FLAG_MASK) >> FLAG_MASK_SHIFT
+ seq_id = (trace_item & SEQ_ID_MASK) >> SEQ_ID_MASK_SHIFT
+ addr = (trace_item & ADDR_MASK) >> ADDR_MASK_SHIFT
+ marker = (trace_item & MARKER_MASK) >> MARKER_MASK_SHIFT
+
+ #print("word_offset = 0x%x" %(word_offset))
+ #print("trace_item = 0x%x" %(trace_item))
+ #print("flag = 0x%x" %(flag))
+ #print("marker = 0x%x" %(marker))
+ #print("read_address = 0x%x" %(read_address))
+
+ if TRACE_FLAG_WORD_DATA == flag:
+ #print("TRACE_FLAG_WORD_DATA")
+ #trace_total = trace_total - 1 #marker + data
+
+ read_address = TRACE_BASE_ADDRESS + word_offset
+ # second 32-bit word is data we need, advance the word_offset
+ #word_offset = word_offset + 4
+ word_offset = (word_offset + 4) % NUMBER_OF_TRACES
+ word_data_address = TRACE_BASE_ADDRESS + word_offset
+ word_data = readMemory32(trace_buffer,word_data_address)
+
+ #print("word_offset = 0x%x" %(word_offset))
+ #print("word_data_address = 0x%x" %(word_data_address))
+ #print("word_data = 0x%x" %(word_data))
+
+ if marker in marker_lookup:
+ marker_string = marker_lookup[marker]
+ if marker_string is None:
+ marker_string = "MARKER?"
+ variable_enabled = False
+ else:
+ variable_enabled = True
+
+ #print("marker_string = %s" %(marker_string))
+ marker = (trace_item & MARKER_MASK) >> MARKER_MASK
+# print("[%08x] %2d %8X %4X %2X" %(read_address,
+# seq_id,
+# trace_item,
+# addr,
+# marker))
+# print("variable_enabled = %d" %(variable_enabled))
+ if (marker_string.__eq__("Process MHU")):
+ service_id_string = service_id_lut[word_data]
+ print("[%08x] %2d 0x%04X %-45s %s" %(read_address,
+ seq_id, addr, marker_string, service_id_string))
+ elif variable_enabled is True:
+ if marker_string.__eq__("STOC Part#"):
+ print("PART NUMBER#1")
+ print("[%08x] %2d 0x%04X %8X 0x%08X %c" %(read_address,
+ addr, seq_id, 0x10, trace_item, word_data, chr(word_data & 0xFF)))
+ else:
+ print("[%08x] %2d 0x%04X %8X 0x%08X" %(read_address,
+ seq_id, addr, trace_item, word_data))
+ else:
+ if marker_string.__eq__("STOC Part#"): # Decode the STOC Part #
+ print("[%08x] %2d 0x%04X %-45s 0x%08X %c%c%c%c" %(read_address,
+ seq_id, addr, marker_string, word_data,
+ chr(word_data & 0xFF),
+ chr(word_data >> 8 & 0xFF),
+ chr(word_data >> 16 & 0xFF),
+ chr(word_data >> 24 & 0xFF) )
+ )
+ else:
+ print("[%08x] %2d 0x%04X %-45s 0x%08X" %(read_address,
+ seq_id, addr, marker_string, word_data))
+
+ elif TRACE_FLAG_TIMESTAMP == flag:
+ #print("TRACE_FLAG_TIMESTAMP")
+ #trace_total = trace_total - 1 #marker + timestamp
+ # second 32-bit word is time stamp, advance the word_offset
+ #word_offset = word_offset + 4
+ word_offset = (word_offset + 4) % NUMBER_OF_TRACES
+ read_address = TRACE_BASE_ADDRESS + word_offset
+ trace_item_dword = readMemory32(trace_buffer,read_address)
+
+ #print("word_offset = 0x%x" %(word_offset))
+ #print("read_address = 0x%x" %(read_address))
+ #print("trace_item_dword = 0x%x" %(trace_item_dword))
+
+ if marker in marker_lookup:
+ marker_string = marker_lookup[marker]
+ if marker_string is None:
+ marker_string = "MARKER?"
+ variable_enabled = False
+ else:
+ variable_enabled = True
+ print("[%08x] %2d 0x%04X %-45s T:%8d" %(
+ read_address,
+ seq_id,
+ addr,
+ marker_string,
+ trace_item_dword))
+
+ elif TRACE_FLAG_BYTE_DATA == flag:
+ #print("TRACE_FLAG_BYTE_DATA")
+ if marker in marker_lookup:
+ marker_string = marker_lookup[marker]
+ if marker_string is None:
+ marker_string = "MARKER?"
+ variable_enabled = False
+ else:
+ variable_enabled = True
+
+ if variable_enabled is True:
+ print("[%08x] %2d 0x%04X %2X" %(read_address,
+ seq_id,
+ addr,
+ marker))
+ else:
+ print("[%08x] %2d 0x%04X %-45s" %(read_address,
+ seq_id,
+ addr,
+ marker_string))
+
+ else:
+ #print("Unknown flag = 0x%x" %(flag))
+ print("[%08x] %2d 0x%04X 0x%04X 0x%02X" %(read_address,
+ seq_id,
+ trace_item,
+ addr,
+ marker))
+
+ word_offset = (word_offset + 4) % NUMBER_OF_TRACES
+
+ trace_total = trace_total - 1
+
+# if word_offset >= (NUMBER_OF_TRACES * 4):
+ if word_offset >= (NUMBER_OF_TRACES):
+ break
diff --git a/tools/alif/maintenance.py b/tools/alif/maintenance.py
index b8680c645..ac431a76c 100755
--- a/tools/alif/maintenance.py
+++ b/tools/alif/maintenance.py
@@ -1,779 +1,798 @@
-#!/usr/bin/env python3
-#pylint: disable=invalid-name,superfluous-parens,anomalous-unicode-escape-in-string
-#pylint: disable=import-error,wrong-import-position,wildcard-import,undefined-variable
-"""
- Maintenance mode tool
-
- - Uses synchronous ISP commands
-
- __author__ = "ronyett"
- __copyright__ = "ALIF Seminconductor"
- __version__ = "0.06.000"
- __status__ = "Dev" "
-"""
-
-import os
-import sys
-import argparse
-sys.path.append("./isp")
-from serialport import serialPort # ISP Serial support
-from serialport import COM_TIMEOUT_RX_DEFAULT
-from isp_protocol import * # ISP protocol constants
-from isp_core import *
-from isp_util import *
-from isp_print import *
-#from isp_print import isp_print_color, isp_print_cursor_enable
-#from isp_print import isp_print_cursor_disable,isp_print_terminal_reset
-from toc_decode import * # ISP TOC support
-from power_decode import * # ISP POWER support
-from utils.config import *
-from utils.user_validations import validateArgList
-from recovery import recovery_action, recovery_action_no_reset
-
-MENU_DB = 'utils/maintDB.db'
-MENU_CFG = 'utils/menuconfDB.db'
-
-# Define Version constant for each separate tool
-# 0.01.000 Concept+realisation
-# 0.02.000 add get TOC
-# 0.03.000 add get CPU status
-# 0.04.000 add get MRAM contents
-# 0.05.000 add get SERAM metrics and terminal mode
-# 0.06.000 add ERASE app mram feature
-# 0.07.000 add FAST ERASE app mram feature
-# 0.07.001 Cursor reset after terminal mode
-# 0.08.001 add groups for menu items
-# 0.08.002 Cursor reset after Hard Maintenance mode
-# 0.08.003 added Ctrl-C in showAndSelectOptions()
-# 0.08.004 added python error exit code
-# 0.09.000 added menu configurations
-# 0.10.000 Integrated recoery mode
-# 0.11.000 added get POWER
-# 0.12.000 add command line option
-# 0.13.000 get baudrate from DBs
-# 0.14.000 add get clock data
-# 0.15.000 add Fast Erase including NTOC
-# 0.16.000 add Recovery MRAM_READ
-TOOL_VERSION = "0.16.000"
-
-EXIT_WITH_ERROR = 1
-
-FAST_ERASE_SIZE = 16
-
-def reset_action(isp):
- """
- reset_action
- reset the device, send ISP request to reset
- """
- isp_reset(isp)
-
-def get_revision_action(isp):
- """
- get device revision_action
- obtain the device revision info
- """
- isp_start(isp)
- isp_get_revision(isp)
- isp_stop(isp)
-
-def get_toc_action(isp):
- """
- get toc action
- obtain the TOC info from target
- """
- isp_start(isp)
- isp_get_toc_data(isp)
- isp_stop(isp)
-
-def get_power_action(isp):
- """
- get power action
- obtain the POWER info from target
- """
- isp_start(isp)
- isp_get_power_data(isp)
- isp_stop(isp)
-
-def get_clock_action(isp):
- """
- get clock action
- obtain the Clock, XTal, PLL info from target
- """
- isp_start(isp)
- isp_get_clock_data(isp)
- isp_stop(isp)
-
-def get_banner_action(isp):
- """
- get_banner_action
- obtain the SERAM banner
- """
- isp_start(isp)
- isp_get_banner(isp)
- isp_stop(isp)
-
-def get_cpu_status_action(isp):
- """
- get cpu status_action
- obtain the cpu boot info
- """
- isp_start(isp)
- isp_get_cpu_status(isp)
- isp_stop(isp)
-
-def get_enquiry_action(isp):
- """
- get_enquiry_action
- Enquire what is at the end of the cable
- """
- isp_start(isp)
- isp_enquiry(isp)
- isp_stop(isp)
-
-def get_mram_info_action(isp):
- """
- get the real MRAM details
- """
- isp_start(isp)
- isp_get_mram_contents(isp)
- isp_stop(isp)
-
-def get_seram_info_action(isp):
- """
- get_seram_info_action
- get seram metrics
- """
- isp_start(isp)
- isp_get_seram_metrics(isp)
- isp_stop(isp)
-
-def get_mram_read_action(isp):
- """
- get MRAMvalue
- """
- offset = input('Enter hex word offset: ')
- try:
- offset_hex = int(offset,16)
- except EOFError:
- print("[Ctrl-C EOF]")
- sys.exit()
- except KeyboardInterrupt:
- print("[Ctrl-C]")
- sys.exit()
- except:
- print("[ERROR] not a valid offset")
- return
-
- isp_start(isp)
- isp_read_mram(isp,offset_hex)
- isp_stop(isp)
-
-def get_otp_read(isp):
- """
- get OTP value
- """
- offset = input('Enter word addr(hex): ')
- try:
- offset_hex = int(offset,16)
- except EOFError:
- print("[Ctrl-C EOF]")
- sys.exit()
- except KeyboardInterrupt:
- print("[Ctrl-C]")
- sys.exit()
- except:
- print("[ERROR] not a valid hex offset")
- return
-
- isp_start(isp)
- isp_read_otp(isp,offset_hex)
- isp_stop(isp)
-
-def get_address_action(isp):
- """
- get address value
- """
- address = input('Enter addr(hex): ')
- try:
- address_hex = int(address,16)
- except EOFError:
- print("[Ctrl-C EOF]")
- sys.exit()
- except KeyboardInterrupt:
- print("[Ctrl-C]")
- sys.exit()
- except:
- print("[ERROR] not a valid address")
- return
-
- isp_start(isp)
- isp_get_address(isp,address_hex)
- isp_stop(isp)
-
-def set_address_action(isp):
- """
- set address value
- """
- address = input('Enter addr(hex): ')
- try:
- address_hex = int(address,16)
- except EOFError:
- print("[Ctrl-C EOF]")
- sys.exit()
- except KeyboardInterrupt:
- print("[Ctrl-C]")
- sys.exit()
- except:
- print("[ERROR] not a valid address")
- return
-
- data = input('Enter data(hex): ')
- try:
- data_hex = int(data,16)
- except EOFError:
- print("[Ctrl-C EOF]")
- sys.exit()
- except KeyboardInterrupt:
- print("[Ctrl-C]")
- sys.exit()
- except:
- print("[ERROR] not a valid address")
- return
-
- isp_set_address(isp,address_hex,data_hex)
-
-def get_trace_buffer(isp):
- """
- get SEROM trace buffer
- """
- isp_start(isp)
- isp_get_trace_buffer(isp)
- isp_stop(isp)
-
-def get_seram_trace_buffer(isp):
- """
- get SERAM trace buffer
- """
- isp_start(isp)
- try:
- isp_get_seram_trace_buffer(isp)
- except:
- print('[ERROR] Unable to get SERAM trace when SEROM is in recovery mode')
- isp_stop(isp)
-
-def set_print_enable_action(isp):
- """
- set print enable
- """
- isp_set_print_enable(isp, True)
-
-def set_print_disable_action(isp):
- """
- set print disable
- """
- isp_set_print_enable(isp, False)
-
-def set_logger_enable_action(isp):
- """
- set Logger enable
- """
- isp_set_log_enable(isp, True)
-
-def set_logger_disable_action(isp):
- """
- set Logger disable
- """
- isp_set_log_enable(isp, False)
-
-def terminal_mode(isp):
- """
- terminal_mode
- Enter terminal mode, use [CTRL-C] to exit
- """
- ctrlc = CtrlCHandler() # [CTRL-C] handling
-
- print("[TERMINAL] Ctrl-C to exit")
- going = True
-
- while going:
- output_line = isp.readSerial(ISP_MAXIMUM_PACKET_SIZE)
- raw_print = bytearray()
- for i in range(len(output_line)):
- raw_print.append(output_line[i])
- try:
- ascii_char = raw_print.decode('ascii')
- print(ascii_char,flush=True,end='')
- sys.stdout.flush()
- except UnicodeDecodeError:
- pass
- if ctrlc.Handler_exit():
- print("[INFO] CTRL-C")
- break
-
- print("[TERMINAL] Ends")
- isp_print_cursor_enable()
- isp_print_terminal_reset()
-
-def application_mram_erase(isp, address, erase_length, reset):
- """
- erase_application_mram_action
- erase the Application area of MRAM based on the device details
- """
- global baud_rate
-
- erase_length_fmt = "{:,}".format(erase_length)
- pattern = 0x00000000
-
- print("[INFO] erasing 0x%x %s bytes" %(address,erase_length_fmt))
-
- put_target_in_maintenance_mode(isp, baud_rate,False)
-
- isp_start(isp)
- isp_mram_erase(isp,address,erase_length,pattern)
- isp_stop(isp)
- if reset:
- isp_reset(isp)
-
-
-def full_erase_application_mram_action(isp):
- """
- full_erase_application_mram_action
- Full erase the Application area of MRAM based on the device details
- """
- global OEM_BASE_ADDRESS
- global OEM_MRAM_SIZE
-
- address = OEM_BASE_ADDRESS
- erase_length = OEM_MRAM_SIZE
- application_mram_erase(isp, address, erase_length, True)
- print("[INFO] Full Erase done")
-
-def fast_erase_app_include_start_mram_action(isp):
- """
- fast_erase_app_include_start_mram_action
- Fast erase the Application area of MRAM (16 bytes) based on the device details
- Plus the beginning of MRAM (0x8000-0000)
- """
- global ALIF_BASE_ADDRESS
- global OEM_BASE_ADDRESS
-
- # erase APP TOC
- address = ALIF_BASE_ADDRESS - FAST_ERASE_SIZE
- erase_length = FAST_ERASE_SIZE
- # this function can't be called twice as target stops to respond
- application_mram_erase(isp, address, erase_length, False)
-
- # erase start of mram (remove residuals from applications that start at 0x8000-0000)
- address = OEM_BASE_ADDRESS
- erase_length = FAST_ERASE_SIZE
- # this function can't be called twice as target stops to respond
- application_mram_erase(isp, address, erase_length, True)
-
- print("[INFO] Fast Erase done (incl. NTOC)")
-
-def fast_erase_application_mram_action(isp):
- """
- fast_erase_application_mram_action
- Fast erase the Application area of MRAM (16 bytes) based on the device details
- """
- global ALIF_BASE_ADDRESS
-
- address = ALIF_BASE_ADDRESS - FAST_ERASE_SIZE
- erase_length = FAST_ERASE_SIZE
-
- application_mram_erase(isp, address, erase_length, True)
- print("[INFO] Fast Erase done")
-
-def process_log_data(log_data):
- """
- process_log_data
- """
- #print("log_data: ", log_data)
- max_index = log_data[0]
- head = log_data[1]
- index = log_data[2] # start from the tail
- data = log_data[3]
- ordered_data = []
- while True:
- if index == max_index:
- index = 0
- if index == head:
- break
- ordered_data.append(chr(data[index]))
- index += 1
-
- #print("ordered data: ", ordered_data)
- isp_print_color("blue", "........\n\n")
- display_str = ""
- for ch in ordered_data:
- if ch == '\00':
- if display_str != "":
- severity = display_str[0]
- if severity >= '0' and severity <= '9':
- display_str = display_str[1:]
- isp_print_color("blue", display_str)
- display_str = ""
- else:
- display_str += ch
-
-def get_log_data_action(isp):
- """
- get_log_data_action
- """
- isp_start(isp)
- log_data = isp_get_log_data(isp)
- if log_data != None:
- process_log_data(log_data)
- isp_stop(isp)
-
-def maintenance_mode(isp):
- """
- maintenance_mode
- Enter Manitenance mode
- """
- global handler
- global baud_rate
-
- Flicks="|/-\\|/-\\"
- Flick = 0
-
- isp.setTimeout(0.1)
- isp.setBaudRate(baud_rate)
-
- isp_print_cursor_disable()
-
- print_count = 0
- se_chars = [b'S', b'E', b'P', b'C', b'T', b'L']
- se_index = 0
- expected_char = b'\0'
- while True:
- send_data = bytearray(b'ALIF')
- isp.writeSerial(send_data)
- sys.stdout.flush()
-
- recv_data = bytearray(isp.readSerial(1))
-
- print("Waiting for Target..[RESET Platform] " + Flicks[Flick] +
- '\r', flush=True, end="")
- sys.stdout.flush()
-
- # single character version
- #if (recv_data == b'\xF0'):
- # break
-
- # looking for the sequence in se_chars
- if se_index == 0:
- if recv_data == se_chars[0]:
- # start of sequence
- se_index = 1
- expected_char = se_chars[se_index]
- elif recv_data != expected_char:
- # unexpected character, reset the sequence
- se_index = 0
- expected_char = b'\0'
- else:
- # received the expected character
- if se_index >= (len(se_chars) - 1):
- # the entire sequence is received
- break
- se_index += 1
- expected_char = se_chars[se_index]
-
- if handler.Handler_exit():
- print("\n[INFO] CTRL-C")
- break
-
- print_count = print_count + 1
- if print_count > 5: # "Fake" delay, time.sleep() will halt
- Flick = Flick + 1
- if Flick == 8:
- Flick -= 8
- print_count = 0
-
- send_data = bytearray(b'ALIF')
- isp.writeSerial(send_data)
-
- sys.stdout.flush()
-
- # switch back to post pll baud rate
- isp.setTimeout(COM_TIMEOUT_RX_DEFAULT)
- isp.setBaudRate(baud_rate)
- isp_print_cursor_enable()
-
-def soft_maintenance_mode(isp):
- """
- soft_maintenance_mode
- enter Soft mode
- """
- global baud_rate
-
- put_target_in_maintenance_mode(isp, baud_rate,False)
-
-def get_ecc_key(isp):
- """
- get_ecc_key from device
- """
- isp_start(isp)
- isp_get_ecc_key(isp)
- isp_stop(isp)
-
-def get_firewall_config(isp):
- """
- get_firewall_config
- Pull back Firewall config from target
- """
- isp_start(isp)
- isp_get_firewall_config(isp)
- isp_stop(isp)
-
-def show_help(supported_commands):
- """
- show_help
- display all supported commands
- """
- print("Supported commands:")
- for item in sorted(supported_commands):
- print('\t{}'.format(supported_commands[item][0]))
-
-def maintenance_menu(supported_commands, isp):
- """
- maintenance_mode
- Show Menu options and get user input
- """
-
- option = 'x'
- while option == 'x':
- optList = []
- print('\nAvailable options:\n')
- i = 1
- for item in supported_commands:
- print("%2s - %s" % (str(i), item))
- i += 1
- optList.append(item)
-
- try:
- option = input('\nSelect an option (Enter to return): ')
- except EOFError:
- print("[Ctrl-C EOF]")
- sys.exit()
- except KeyboardInterrupt:
- print("[Ctrl-C]")
- sys.exit()
-
- if option == '':
- return
-
- try:
- idx = int(option)
- except ValueError:
- print('Invalid option - Please try again')
- option = 'x'
- continue
-
- if idx < 1 or idx > len(optList):
- print('Invalid option - Please try again')
- option = 'x'
- continue
- try:
- func = globals()[supported_commands[optList[idx-1]]]
- except ValueError:
- print("oops")
- func(isp)
- option = 'x'
-
-def showAndSelectOptions(list):
- """
- showAndSelectOptions
- """
- option = 'x'
- while option == 'x':
- print('\nAvailable options:\n')
- i = 1
- optList = []
- for opt in list:
- print("%2s - %s" % (str(i), opt))
- i += 1
- optList.append(opt)
- try:
- option = input('\nSelect an option (Enter to exit): ')
- except EOFError:
- print("[Ctrl-C EOF]")
- sys.exit(0)
-
- if option == '':
- sys.exit(0)
- try:
- idx = int(option)
- except ValueError:
- print('[ERROR] Invalid option - Please try again')
- option = 'x'
- continue
-
- if idx < 1 or idx > len(list):
- print('[ERROR] Invalid option - Please try again')
- option = 'x'
-
- return optList[idx-1]
-
-def read_json_file(file):
- """
- read_json_file
- """
- f = open(file, 'r')
- try:
- data = json.load(f)
-
- except JSONDecodeError as e:
- print("[ERROR] in JSON file.")
- print(str(e))
- sys.exit(EXIT_WITH_ERROR)
-
- except ValueError as v:
- print("[ERROR] in JSON file:")
- print(str(v))
- sys.exit(EXIT_WITH_ERROR)
- except:
- print("[ERROR] Unknown error loading JSON file")
- sys.exit(EXIT_WITH_ERROR)
-
- f.close()
- return data
-
-def checkRestrictions(menu_item, menu_config):
- """
- checkRestrictions
- """
- if menu_item in menu_config.keys():
- for item in menu_config[menu_item]:
- if globals()[item] in menu_config[menu_item][item]:
- return True
- return False
-
-def command_line_mode(isp,cli_option):
- """
- command_line_mode
- - operate on commands passed in rather than the menus
- """
- command_line_lut = {
- "sesbanner" : get_banner_action
- }
-
- if cli_option in command_line_lut:
- command_line_lut[cli_option](isp)
- else:
- print("[ERROR] Command %s not recognized" %cli_option)
- sys.exit(EXIT_WITH_ERROR)
-
-def main():
- """
- Maintenance tool
- """
- global ALIF_BASE_ADDRESS
- global OEM_BASE_ADDRESS
- global OEM_MRAM_SIZE
- global DEVICE_FEATURE_SET
- global DEVICE_FAMILY
- global DEVICE_REVISION
- global DEVICE_PART_NUMBER
- global DEVICE_FEATURE_SET_REVISION
- global handler
- global baud_rate
-
- if sys.version_info.major == 2:
- print("[ERROR] You need Python 3 for this application!")
- sys.exit(EXIT_WITH_ERROR)
-
- # Deal with Command Line
- parser = argparse.ArgumentParser(description=
- 'FUSION Maintenance Tool')
- parser.add_argument("-b", "--baudrate",
- help="serial port baud rate",
- type=int)
- parser.add_argument("-d" , "--discover", action='store_true',
- default=False, help="COM port discovery")
- parser.add_argument("-opt" ,"--option",
- type=str,default="",
- help="call option [sesbanner]")
- parser.add_argument("-V" , "--version",
- help="Display Version Number",
- action="store_true")
- parser.add_argument("-v" , "--verbose",
- help="verbosity mode",
- action="store_true")
- args = parser.parse_args()
- if args.version:
- print(TOOL_VERSION)
- sys.exit()
-
- # memory defines for Alif/OEM MRAM Addresses and Sizes
- load_global_config()
- ALIF_BASE_ADDRESS = utils.config.ALIF_BASE_ADDRESS
- OEM_BASE_ADDRESS = utils.config.APP_BASE_ADDRESS
- OEM_MRAM_SIZE = utils.config.APP_MRAM_SIZE
- DEVICE_FEATURE_SET = utils.config.DEVICE_FEATURE_SET
- DEVICE_FAMILY = utils.config.DEVICE_FAMILY
- DEVICE_REVISION = utils.config.DEVICE_REVISION
- DEVICE_PART_NUMBER = utils.config.DEVICE_PART_NUMBER
- DEVICE_REV_BAUD_RATE = utils.config.DEVICE_REV_BAUD_RATE
-
- # create a compound variable to address use cases as Fusion Rev B0
- DEVICE_FEATURE_SET_REVISION = DEVICE_FEATURE_SET + '_' + DEVICE_REVISION
-
- baud_rate = DEVICE_REV_BAUD_RATE[DEVICE_REVISION]
- if args.baudrate is not None:
- baud_rate = args.baudrate
-
- handler = CtrlCHandler() # [CTRL-C] handling
-
- os.system('') # Help MS-DOS window with ESC sequences
-
- # Serial dabbling open up port.
- isp = serialPort(baud_rate) # Create ISP session
- isp.setVerbose(args.verbose) # turn on or off verbose mode for the host
- isp.CTRLCHandler = handler # CTRL C Handler for this ISP session
-
- if args.discover: # discover the COM ports if requested
- print('Discover')
- isp.discoverSerialPorts()
-
- errorCode = isp.openSerial()
- if errorCode is False:
- print("[ERROR] isp openSerial failed for %s" %isp.getPort())
- sys.exit(EXIT_WITH_ERROR)
- print("[INFO] %s open Serial port success" %isp.getPort())
-
- # Set up the baud rate ((same calls as in recovery.py))
- #if baud_rate != COM_BAUD_RATE_DEFAULT:
- # isp.setBaudRate(baud_rate)
- print("[INFO] baud rate", isp.getBaudRate())
-
- # Process Maintenance Grouped Menus
- menuDB = read_json_file(MENU_DB)
- groupsDB = menuDB['groups']
-
- # load menu configurations
- menuCfgDB = read_json_file(MENU_CFG)
-
- if args.option:
- command_line_mode(isp,args.option)
- else:
- opt = '*'
- while opt != '':
- opt = showAndSelectOptions(groupsDB)
-
- # filter available commands based on silicon, revision, etc.
- supported_commands = menuDB[groupsDB[opt]]
- menu_options = {}
- for item in supported_commands:
- if not checkRestrictions(supported_commands[item], menuCfgDB):
- menu_options[item] = supported_commands[item]
- maintenance_menu(menu_options, isp)
-
- isp.closeSerial()
-
- # Reset the Terminal of any ANSI Escape sequence debris
- isp_print_cursor_enable()
- isp_print_terminal_reset()
-
-if __name__ == "__main__":
- main()
+#!/usr/bin/env python3
+#pylint: disable=invalid-name,superfluous-parens,anomalous-unicode-escape-in-string
+#pylint: disable=import-error,wrong-import-position,wildcard-import,undefined-variable
+"""
+ Maintenance mode tool
+
+ - Uses synchronous ISP commands
+
+ __author__ = "ronyett"
+ __copyright__ = "ALIF Seminconductor"
+ __version__ = "0.06.000"
+ __status__ = "Dev" "
+"""
+
+import os
+import sys
+import argparse
+sys.path.append("./isp")
+from serialport import serialPort # ISP Serial support
+from serialport import COM_TIMEOUT_RX_DEFAULT
+from isp_protocol import * # ISP protocol constants
+from isp_core import *
+from isp_util import *
+from isp_print import *
+import device_probe
+#from isp_print import isp_print_color, isp_print_cursor_enable
+#from isp_print import isp_print_cursor_disable,isp_print_terminal_reset
+from toc_decode import * # ISP TOC support
+from power_decode import * # ISP POWER support
+from utils.config import *
+from utils.user_validations import validateArgList
+from recovery import recovery_action, recovery_action_no_reset
+
+
+# Define Version constant for each separate tool
+# 0.01.000 Concept+realisation
+# 0.02.000 add get TOC
+# 0.03.000 add get CPU status
+# 0.04.000 add get MRAM contents
+# 0.05.000 add get SERAM metrics and terminal mode
+# 0.06.000 add ERASE app mram feature
+# 0.07.000 add FAST ERASE app mram feature
+# 0.07.001 Cursor reset after terminal mode
+# 0.08.001 add groups for menu items
+# 0.08.002 Cursor reset after Hard Maintenance mode
+# 0.08.003 added Ctrl-C in showAndSelectOptions()
+# 0.08.004 added python error exit code
+# 0.09.000 added menu configurations
+# 0.10.000 Integrated recoery mode
+# 0.11.000 added get POWER
+# 0.12.000 add command line option
+# 0.13.000 get baudrate from DBs
+# 0.14.000 add get clock data
+# 0.15.000 add Fast Erase including NTOC
+# 0.16.000 add Recovery MRAM_READ
+# 0.17.000 add different menues for SEROM/SERAM stages
+TOOL_VERSION = "0.17.000"
+
+EXIT_WITH_ERROR = 1
+TARGET_RESPONDED = 1
+FAST_ERASE_SIZE = 16
+
+def reset_action(isp):
+ """
+ reset_action
+ reset the device, send ISP request to reset
+ """
+ isp_reset(isp)
+
+def get_revision_action(isp):
+ """
+ get device revision_action
+ obtain the device revision info
+ """
+ isp_start(isp)
+ isp_get_revision(isp)
+ isp_stop(isp)
+
+def get_toc_action(isp):
+ """
+ get toc action
+ obtain the TOC info from target
+ """
+ isp_start(isp)
+ isp_get_toc_data(isp)
+ isp_stop(isp)
+
+def get_power_action(isp):
+ """
+ get power action
+ obtain the POWER info from target
+ """
+ isp_start(isp)
+ isp_get_power_data(isp)
+ isp_stop(isp)
+
+def get_clock_action(isp):
+ """
+ get clock action
+ obtain the Clock, XTal, PLL info from target
+ """
+ isp_start(isp)
+ isp_get_clock_data(isp)
+ isp_stop(isp)
+
+def get_banner_action(isp):
+ """
+ get_banner_action
+ obtain the SERAM banner
+ """
+ isp_start(isp)
+ isp_get_banner(isp)
+ isp_stop(isp)
+
+def get_cpu_status_action(isp):
+ """
+ get cpu status_action
+ obtain the cpu boot info
+ """
+ isp_start(isp)
+ isp_get_cpu_status(isp)
+ isp_stop(isp)
+
+def get_enquiry_action(isp):
+ """
+ get_enquiry_action
+ Enquire what is at the end of the cable
+ """
+ isp_start(isp)
+ isp_enquiry(isp)
+ isp_stop(isp)
+
+def get_mram_info_action(isp):
+ """
+ get the real MRAM details
+ """
+ isp_start(isp)
+ isp_get_mram_contents(isp)
+ isp_stop(isp)
+
+def get_seram_info_action(isp):
+ """
+ get_seram_info_action
+ get seram metrics
+ """
+ isp_start(isp)
+ isp_get_seram_metrics(isp)
+ isp_stop(isp)
+
+def get_mram_read_action(isp):
+ """
+ get MRAMvalue
+ """
+ offset = input('Enter hex word offset: ')
+ try:
+ offset_hex = int(offset,16)
+ except EOFError:
+ print("[Ctrl-C EOF]")
+ sys.exit()
+ except KeyboardInterrupt:
+ print("[Ctrl-C]")
+ sys.exit()
+ except:
+ print("[ERROR] not a valid offset")
+ return
+
+ isp_start(isp)
+ isp_read_mram(isp,offset_hex)
+ isp_stop(isp)
+
+def get_otp_read(isp):
+ """
+ get OTP value
+ """
+ offset = input('Enter word addr(hex): ')
+ try:
+ offset_hex = int(offset,16)
+ except EOFError:
+ print("[Ctrl-C EOF]")
+ sys.exit()
+ except KeyboardInterrupt:
+ print("[Ctrl-C]")
+ sys.exit()
+ except:
+ print("[ERROR] not a valid hex offset")
+ return
+
+ isp_start(isp)
+ isp_read_otp(isp,offset_hex)
+ isp_stop(isp)
+
+def get_address_action(isp):
+ """
+ get address value
+ """
+ address = input('Enter addr(hex): ')
+ try:
+ address_hex = int(address,16)
+ except EOFError:
+ print("[Ctrl-C EOF]")
+ sys.exit()
+ except KeyboardInterrupt:
+ print("[Ctrl-C]")
+ sys.exit()
+ except:
+ print("[ERROR] not a valid address")
+ return
+
+ isp_start(isp)
+ isp_get_address(isp,address_hex)
+ isp_stop(isp)
+
+def set_address_action(isp):
+ """
+ set address value
+ """
+ address = input('Enter addr(hex): ')
+ try:
+ address_hex = int(address,16)
+ except EOFError:
+ print("[Ctrl-C EOF]")
+ sys.exit()
+ except KeyboardInterrupt:
+ print("[Ctrl-C]")
+ sys.exit()
+ except:
+ print("[ERROR] not a valid address")
+ return
+
+ data = input('Enter data(hex): ')
+ try:
+ data_hex = int(data,16)
+ except EOFError:
+ print("[Ctrl-C EOF]")
+ sys.exit()
+ except KeyboardInterrupt:
+ print("[Ctrl-C]")
+ sys.exit()
+ except:
+ print("[ERROR] not a valid address")
+ return
+
+ isp_set_address(isp,address_hex,data_hex)
+
+def get_trace_buffer(isp):
+ """
+ get SEROM trace buffer
+ """
+ isp_start(isp)
+ isp_get_trace_buffer(isp)
+ isp_stop(isp)
+
+def get_seram_trace_buffer(isp):
+ """
+ get SERAM trace buffer
+ """
+ isp_start(isp)
+ try:
+ isp_get_seram_trace_buffer(isp)
+ except:
+ print('[ERROR] Unable to get SERAM trace when SEROM is in recovery mode')
+ isp_stop(isp)
+
+def set_print_enable_action(isp):
+ """
+ set print enable
+ """
+ isp_set_print_enable(isp, True)
+
+def set_print_disable_action(isp):
+ """
+ set print disable
+ """
+ isp_set_print_enable(isp, False)
+
+def set_logger_enable_action(isp):
+ """
+ set Logger enable
+ """
+ isp_set_log_enable(isp, True)
+
+def set_logger_disable_action(isp):
+ """
+ set Logger disable
+ """
+ isp_set_log_enable(isp, False)
+
+def terminal_mode(isp):
+ """
+ terminal_mode
+ Enter terminal mode, use [CTRL-C] to exit
+ """
+ ctrlc = CtrlCHandler() # [CTRL-C] handling
+
+ print("[TERMINAL] Ctrl-C to exit")
+ going = True
+
+ while going:
+ output_line = isp.readSerial(ISP_MAXIMUM_PACKET_SIZE)
+ raw_print = bytearray()
+ for i in range(len(output_line)):
+ raw_print.append(output_line[i])
+ try:
+ ascii_char = raw_print.decode('ascii')
+ print(ascii_char,flush=True,end='')
+ sys.stdout.flush()
+ except UnicodeDecodeError:
+ pass
+ if ctrlc.Handler_exit():
+ print("[INFO] CTRL-C")
+ break
+
+ print("[TERMINAL] Ends")
+ isp_print_cursor_enable()
+ isp_print_terminal_reset()
+
+def application_mram_erase(isp, address, erase_length, reset):
+ """
+ erase_application_mram_action
+ erase the Application area of MRAM based on the device details
+ """
+ global baud_rate
+
+ erase_length_fmt = "{:,}".format(erase_length)
+ pattern = 0x00000000
+
+ print("[INFO] erasing 0x%x %s bytes" %(address,erase_length_fmt))
+
+ put_target_in_maintenance_mode(isp, baud_rate,False)
+
+ isp_start(isp)
+ isp_mram_erase(isp,address,erase_length,pattern)
+ isp_stop(isp)
+ if reset:
+ isp_reset(isp)
+
+
+def full_erase_application_mram_action(isp):
+ """
+ full_erase_application_mram_action
+ Full erase the Application area of MRAM based on the device details
+ """
+ global OEM_BASE_ADDRESS
+ global OEM_MRAM_SIZE
+
+ address = OEM_BASE_ADDRESS
+ erase_length = OEM_MRAM_SIZE
+ application_mram_erase(isp, address, erase_length, True)
+ print("[INFO] Full Erase done")
+
+def fast_erase_app_include_start_mram_action(isp):
+ """
+ fast_erase_app_include_start_mram_action
+ Fast erase the Application area of MRAM (16 bytes) based on the device details
+ Plus the beginning of MRAM (0x8000-0000)
+ """
+ global ALIF_BASE_ADDRESS
+ global OEM_BASE_ADDRESS
+
+ # erase APP TOC
+ address = ALIF_BASE_ADDRESS - FAST_ERASE_SIZE
+ erase_length = FAST_ERASE_SIZE
+ # this function can't be called twice as target stops to respond
+ application_mram_erase(isp, address, erase_length, False)
+
+ # erase start of mram (remove residuals from applications that start at 0x8000-0000)
+ address = OEM_BASE_ADDRESS
+ erase_length = FAST_ERASE_SIZE
+ # this function can't be called twice as target stops to respond
+ application_mram_erase(isp, address, erase_length, True)
+
+ print("[INFO] Fast Erase done (incl. NTOC)")
+
+def fast_erase_application_mram_action(isp):
+ """
+ fast_erase_application_mram_action
+ Fast erase the Application area of MRAM (16 bytes) based on the device details
+ """
+ global ALIF_BASE_ADDRESS
+
+ address = ALIF_BASE_ADDRESS - FAST_ERASE_SIZE
+ erase_length = FAST_ERASE_SIZE
+
+ application_mram_erase(isp, address, erase_length, True)
+ print("[INFO] Fast Erase done")
+
+def process_log_data(log_data):
+ """
+ process_log_data
+ """
+ #print("log_data: ", log_data)
+ max_index = log_data[0]
+ head = log_data[1]
+ index = log_data[2] # start from the tail
+ data = log_data[3]
+ ordered_data = []
+ while True:
+ if index == max_index:
+ index = 0
+ if index == head:
+ break
+ ordered_data.append(chr(data[index]))
+ index += 1
+
+ #print("ordered data: ", ordered_data)
+ isp_print_color("blue", "........\n\n")
+ display_str = ""
+ for ch in ordered_data:
+ if ch == '\00':
+ if display_str != "":
+ severity = display_str[0]
+ if severity >= '0' and severity <= '9':
+ display_str = display_str[1:]
+ isp_print_color("blue", display_str)
+ display_str = ""
+ else:
+ display_str += ch
+
+def get_log_data_action(isp):
+ """
+ get_log_data_action
+ """
+ isp_start(isp)
+ log_data = isp_get_log_data(isp)
+ if log_data != None:
+ process_log_data(log_data)
+ isp_stop(isp)
+
+def maintenance_mode(isp):
+ """
+ maintenance_mode
+ Enter Manitenance mode
+ """
+ global handler
+ global baud_rate
+
+ Flicks="|/-\\|/-\\"
+ Flick = 0
+
+ isp.setTimeout(0.1)
+ isp.setBaudRate(baud_rate)
+
+ isp_print_cursor_disable()
+
+ print_count = 0
+ se_chars = [b'S', b'E', b'P', b'C', b'T', b'L']
+ se_index = 0
+ expected_char = b'\0'
+ while True:
+ send_data = bytearray(b'ALIF')
+ isp.writeSerial(send_data)
+ sys.stdout.flush()
+
+ recv_data = bytearray(isp.readSerial(1))
+
+ print("Waiting for Target..[RESET Platform] " + Flicks[Flick] +
+ '\r', flush=True, end="")
+ sys.stdout.flush()
+
+ # single character version
+ #if (recv_data == b'\xF0'):
+ # break
+
+ # looking for the sequence in se_chars
+ if se_index == 0:
+ if recv_data == se_chars[0]:
+ # start of sequence
+ se_index = 1
+ expected_char = se_chars[se_index]
+ elif recv_data != expected_char:
+ # unexpected character, reset the sequence
+ se_index = 0
+ expected_char = b'\0'
+ else:
+ # received the expected character
+ if se_index >= (len(se_chars) - 1):
+ # the entire sequence is received
+ break
+ se_index += 1
+ expected_char = se_chars[se_index]
+
+ if handler.Handler_exit():
+ print("\n[INFO] CTRL-C")
+ break
+
+ print_count = print_count + 1
+ if print_count > 5: # "Fake" delay, time.sleep() will halt
+ Flick = Flick + 1
+ if Flick == 8:
+ Flick -= 8
+ print_count = 0
+
+ send_data = bytearray(b'ALIF')
+ isp.writeSerial(send_data)
+
+ sys.stdout.flush()
+
+ # switch back to post pll baud rate
+ isp.setTimeout(COM_TIMEOUT_RX_DEFAULT)
+ isp.setBaudRate(baud_rate)
+ isp_print_cursor_enable()
+
+def soft_maintenance_mode(isp):
+ """
+ soft_maintenance_mode
+ enter Soft mode
+ """
+ global baud_rate
+
+ put_target_in_maintenance_mode(isp, baud_rate,False)
+
+def get_ecc_key(isp):
+ """
+ get_ecc_key from device
+ """
+ isp_start(isp)
+ isp_get_ecc_key(isp)
+ isp_stop(isp)
+
+def get_firewall_config(isp):
+ """
+ get_firewall_config
+ Pull back Firewall config from target
+ """
+ isp_start(isp)
+ isp_get_firewall_config(isp)
+ isp_stop(isp)
+
+def show_help(supported_commands):
+ """
+ show_help
+ display all supported commands
+ """
+ print("Supported commands:")
+ for item in sorted(supported_commands):
+ print('\t{}'.format(supported_commands[item][0]))
+
+def maintenance_menu(supported_commands, isp):
+ """
+ maintenance_mode
+ Show Menu options and get user input
+ """
+
+ option = 'x'
+ while option == 'x':
+ optList = []
+ print('\nAvailable options:\n')
+ i = 1
+ for item in supported_commands:
+ print("%2s - %s" % (str(i), item))
+ i += 1
+ optList.append(item)
+
+ try:
+ option = input('\nSelect an option (Enter to return): ')
+ except EOFError:
+ print("[Ctrl-C EOF]")
+ sys.exit()
+ except KeyboardInterrupt:
+ print("[Ctrl-C]")
+ sys.exit()
+
+ if option == '':
+ return
+
+ try:
+ idx = int(option)
+ except ValueError:
+ print('Invalid option - Please try again')
+ option = 'x'
+ continue
+
+ if idx < 1 or idx > len(optList):
+ print('Invalid option - Please try again')
+ option = 'x'
+ continue
+ try:
+ func = globals()[supported_commands[optList[idx-1]]]
+ except ValueError:
+ print("oops")
+ func(isp)
+ option = 'x'
+
+def showAndSelectOptions(list):
+ """
+ showAndSelectOptions
+ """
+ option = 'x'
+ while option == 'x':
+ print('\nAvailable options:\n')
+ i = 1
+ optList = []
+ for opt in list:
+ print("%2s - %s" % (str(i), opt))
+ i += 1
+ optList.append(opt)
+ try:
+ option = input('\nSelect an option (Enter to exit): ')
+ except EOFError:
+ print("[Ctrl-C EOF]")
+ sys.exit(0)
+
+ if option == '':
+ sys.exit(0)
+ try:
+ idx = int(option)
+ except ValueError:
+ print('[ERROR] Invalid option - Please try again')
+ option = 'x'
+ continue
+
+ if idx < 1 or idx > len(list):
+ print('[ERROR] Invalid option - Please try again')
+ option = 'x'
+
+ return optList[idx-1]
+
+def read_json_file(file):
+ """
+ read_json_file
+ """
+ f = open(file, 'r')
+ try:
+ data = json.load(f)
+
+ except JSONDecodeError as e:
+ print("[ERROR] in JSON file.")
+ print(str(e))
+ sys.exit(EXIT_WITH_ERROR)
+
+ except ValueError as v:
+ print("[ERROR] in JSON file:")
+ print(str(v))
+ sys.exit(EXIT_WITH_ERROR)
+ except:
+ print("[ERROR] Unknown error loading JSON file")
+ sys.exit(EXIT_WITH_ERROR)
+
+ f.close()
+ return data
+
+def checkRestrictions(menu_item, menu_config):
+ """
+ checkRestrictions
+ """
+ if menu_item in menu_config.keys():
+ for item in menu_config[menu_item]:
+ if globals()[item] in menu_config[menu_item][item]:
+ return True
+ return False
+
+def command_line_mode(isp,cli_option):
+ """
+ command_line_mode
+ - operate on commands passed in rather than the menus
+ """
+ command_line_lut = {
+ "sesbanner" : get_banner_action
+ }
+
+ if cli_option in command_line_lut:
+ command_line_lut[cli_option](isp)
+ else:
+ print("[ERROR] Command %s not recognized" %cli_option)
+ sys.exit(EXIT_WITH_ERROR)
+
+def main():
+ """
+ Maintenance tool
+ """
+ global ALIF_BASE_ADDRESS
+ global OEM_BASE_ADDRESS
+ global OEM_MRAM_SIZE
+ global DEVICE_FEATURE_SET
+ global DEVICE_FAMILY
+ global DEVICE_REVISION
+ global DEVICE_PART_NUMBER
+ global DEVICE_FEATURE_SET_REVISION
+ global handler
+ global baud_rate
+
+ if sys.version_info.major == 2:
+ print("[ERROR] You need Python 3 for this application!")
+ sys.exit(EXIT_WITH_ERROR)
+
+ # Deal with Command Line
+ parser = argparse.ArgumentParser(description=
+ 'FUSION Maintenance Tool')
+ parser.add_argument("-b", "--baudrate",
+ help="serial port baud rate",
+ type=int)
+ parser.add_argument("-d" , "--discover", action='store_true',
+ default=False, help="COM port discovery")
+ parser.add_argument("-opt" ,"--option",
+ type=str,default="",
+ help="call option [sesbanner]")
+ parser.add_argument("-V" , "--version",
+ help="Display Version Number",
+ action="store_true")
+ parser.add_argument("-v" , "--verbose",
+ help="verbosity mode",
+ action="store_true")
+ args = parser.parse_args()
+ if args.version:
+ print(TOOL_VERSION)
+ sys.exit()
+
+ # memory defines for Alif/OEM MRAM Addresses and Sizes
+ load_global_config()
+ ALIF_BASE_ADDRESS = utils.config.ALIF_BASE_ADDRESS
+ OEM_BASE_ADDRESS = utils.config.APP_BASE_ADDRESS
+ OEM_MRAM_SIZE = utils.config.APP_MRAM_SIZE
+ DEVICE_FEATURE_SET = utils.config.DEVICE_FEATURE_SET
+ DEVICE_FAMILY = utils.config.DEVICE_FAMILY
+ DEVICE_REVISION = utils.config.DEVICE_REVISION
+ DEVICE_PART_NUMBER = utils.config.DEVICE_PART_NUMBER
+ DEVICE_REV_BAUD_RATE = utils.config.DEVICE_REV_BAUD_RATE
+
+ # create a compound variable to address use cases as Fusion Rev B0
+ DEVICE_FEATURE_SET_REVISION = DEVICE_FEATURE_SET + '_' + DEVICE_REVISION
+
+ baud_rate = DEVICE_REV_BAUD_RATE[DEVICE_REVISION]
+ if args.baudrate is not None:
+ baud_rate = args.baudrate
+
+ handler = CtrlCHandler() # [CTRL-C] handling
+
+ os.system('') # Help MS-DOS window with ESC sequences
+
+ # Serial dabbling open up port.
+ isp = serialPort(baud_rate) # Create ISP session
+ isp.setVerbose(args.verbose) # turn on or off verbose mode for the host
+ isp.CTRLCHandler = handler # CTRL C Handler for this ISP session
+
+ if args.discover: # discover the COM ports if requested
+ print('Discover')
+ isp.discoverSerialPorts()
+
+ errorCode = isp.openSerial()
+ if errorCode is False:
+ print("[ERROR] isp openSerial failed for %s" %isp.getPort())
+ sys.exit(EXIT_WITH_ERROR)
+ print("[INFO] %s open Serial port success" %isp.getPort())
+
+ # Set up the baud rate ((same calls as in recovery.py))
+ #if baud_rate != COM_BAUD_RATE_DEFAULT:
+ # isp.setBaudRate(baud_rate)
+ print("[INFO] baud rate", isp.getBaudRate())
+
+ test_target = isp_test_target(baud_rate, isp)
+ print('[INFO] Connecting to target...', end='')
+ if test_target == TARGET_RESPONDED:
+ # be sure device is not in SEROM Recovery Mode
+ device = device_probe.device_get_attributes(isp)
+ if device.stage == device_probe.STAGE_SEROM:
+ print('Device connected in Recovery')
+ MENU_DB = 'utils/maint-recoveryDB.db'
+ else:
+ # target responded and in SERAM stage
+ print('Device connected')
+ MENU_DB = 'utils/maintDB.db'
+ else:
+ # target did not respond... set full menu
+ print('Device did not respond')
+ MENU_DB = 'utils/maintDB.db'
+
+ MENU_CFG = 'utils/menuconfDB.db'
+
+ # Process Maintenance Grouped Menus
+ menuDB = read_json_file(MENU_DB)
+ groupsDB = menuDB['groups']
+
+ # load menu configurations
+ menuCfgDB = read_json_file(MENU_CFG)
+
+ if args.option:
+ command_line_mode(isp,args.option)
+ else:
+ opt = '*'
+ while opt != '':
+ opt = showAndSelectOptions(groupsDB)
+
+ # filter available commands based on silicon, revision, etc.
+ supported_commands = menuDB[groupsDB[opt]]
+ menu_options = {}
+ for item in supported_commands:
+ if not checkRestrictions(supported_commands[item], menuCfgDB):
+ menu_options[item] = supported_commands[item]
+ maintenance_menu(menu_options, isp)
+
+ isp.closeSerial()
+
+ # Reset the Terminal of any ANSI Escape sequence debris
+ isp_print_cursor_enable()
+ isp_print_terminal_reset()
+
+if __name__ == "__main__":
+ main()
diff --git a/tools/alif/utils/LICENSE b/tools/alif/utils/LICENSE
index 2608738f4..7bfd70c98 100755
--- a/tools/alif/utils/LICENSE
+++ b/tools/alif/utils/LICENSE
@@ -1,11 +1,11 @@
-Copyright (C) Arm Limited, 2020 All rights reserved.
-
-The example code is provided to You as an aid to learning when working with Arm-based technology,
-including but not limited to programming tutorials. Arm hereby grants to you,
-subject to the terms and conditions of this Licence, a non-exclusive, non-transferable, non-sub-licensable, free-of-charge licence,
-to use and copy the Software solely for the purpose of demonstration and evaluation.
-
-You accept that the Software has not been tested by Arm therefore the Software is provided “as is”,
-without warranty of any kind, express or implied. In no event shall the authors or copyright holders be liable for any claim,
-damages or other liability, whether in action or contract, tort or otherwise, arising from,
+Copyright (C) Arm Limited, 2020 All rights reserved.
+
+The example code is provided to You as an aid to learning when working with Arm-based technology,
+including but not limited to programming tutorials. Arm hereby grants to you,
+subject to the terms and conditions of this Licence, a non-exclusive, non-transferable, non-sub-licensable, free-of-charge licence,
+to use and copy the Software solely for the purpose of demonstration and evaluation.
+
+You accept that the Software has not been tested by Arm therefore the Software is provided “as is”,
+without warranty of any kind, express or implied. In no event shall the authors or copyright holders be liable for any claim,
+damages or other liability, whether in action or contract, tort or otherwise, arising from,
out of or in connection with the Software or the use of Software.
\ No newline at end of file
diff --git a/tools/alif/utils/cert_key_util.py b/tools/alif/utils/cert_key_util.py
index 834fc65dc..6afab1e89 100755
--- a/tools/alif/utils/cert_key_util.py
+++ b/tools/alif/utils/cert_key_util.py
@@ -1,113 +1,113 @@
-#!/usr/bin/env python3
-#
-# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
-#
-
-# Key certificate structure is :
-# FIELD NAME SIZE (words)
-# ---------- ------------
-# Header token 1
-# version number 1
-# size in words (offset to signature) 1
-# Flags 1
-# N Pub key 96
-# Np 5
-# active SW version 1
-# public key HASH 8
-# RSA Signature 96
-
-####################################################################
-# Filename - cert_key_util.py
-# Description - This file contains the main functionality of the key
-# certificate generation.
-####################################################################
-
-import optparse
-import configparser
-import sys
-import os
-file_path = os.getcwd()
-sys.path.insert(0, os.path.join(file_path, "utils"))
-sys.path.append(os.path.join(sys.path[0], "..", ".."))
-
-from utils.common import util_logger
-from utils.common import global_defines
-from utils.common import certificates
-from utils.common_cert_lib.keycertificateconfig import KeyCertificateConfig
-
-# Util's log file
-LOG_FILENAME = "sb_key_cert.log"
-
-# find proj.cfg
-if "proj.cfg" in os.listdir(sys.path[0]):
- PROJ_CONFIG_PATH = os.path.join(sys.path[0], "proj.cfg")
-elif "proj.cfg" in os.listdir(sys.path[-1]):
- PROJ_CONFIG_PATH = os.path.join(sys.path[-1], "proj.cfg")
-else:
- PROJ_CONFIG_PATH = os.path.join(os.getcwd(), "proj.cfg")
-
-
-class ArgumentParser:
- def __init__(self):
- self.cfg_filename = None
- self.log_filename = LOG_FILENAME
- self.parser = optparse.OptionParser()
-
- def parse_arguments(self, args):
- (options, args) = self.parser.parse_args(args)
- if len(args) > 2 or len(args) < 1:
- self.parser.error("incorrect number of positional arguments")
- elif len(args) == 2:
- self.log_filename = args[1]
- self.cfg_filename = args[0]
-
-
-class KeyCertificateGenerator:
- def __init__(self, logger, key_cfg, certificate_version):
- self.config = key_cfg
- self.logger = logger
- self.cert_version = certificate_version
- self._certificate = None
-
- def create_certificate(self):
- self.logger.info("**** Creating Key certificate ****")
- self._certificate = certificates.KeyArmCertificate(self.config, self.cert_version, self.logger)
-
- self.logger.info("Write the certificate to file")
- with open(self.config.cert_pkg, "wb") as bin_output_file:
- bin_output_file.write(self._certificate.certificate_data)
-
- hex_formatted_cert = ["0x%02x" % i for i in list(self._certificate.certificate_data)]
- txt_filename = self.config.cert_pkg[:-4] + '_' + global_defines.Cert_FileName + global_defines.Cert_FileExtTxt
- with open(txt_filename, "w") as txt_output_file:
- txt_output_file.write("char cert_bin_image[] = {\n")
- txt_content = "".join([item+',\n' if ind % 4 == 3 else item+','
- for ind, item in enumerate(hex_formatted_cert)])
- txt_output_file.write(txt_content)
- txt_output_file.write("}")
-
-
-def main(args):
- if not (sys.version_info.major == 3 and sys.version_info.minor >= 5):
- print("The script requires Python3.5 or later!")
- sys.exit(-1)
- # parse arguments
- the_argument_parser = ArgumentParser()
- the_argument_parser.parse_arguments(args)
- # get logging up and running
- the_logger = util_logger.UtilLogger(the_argument_parser.log_filename, "Key Certificate Generation")
- # Get the project configuration values
- project_config = configparser.ConfigParser()
- with open(PROJ_CONFIG_PATH, 'r') as project_config_file:
- config_string = '[PROJ-CFG]\n' + project_config_file.read()
- project_config.read_string(config_string)
- cert_version = [project_config.getint("PROJ-CFG", "CERT_VERSION_MAJOR"),
- project_config.getint("PROJ-CFG", "CERT_VERSION_MINOR")]
- # get util configuration parameters
- key_certificate_config = KeyCertificateConfig(the_argument_parser.cfg_filename, the_logger)
- # create certificate
- cert_creator = KeyCertificateGenerator(the_logger, key_certificate_config, cert_version)
- cert_creator.create_certificate()
- the_logger.info("**** Certificate file creation has been completed successfully ****")
+#!/usr/bin/env python3
+#
+# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
+#
+
+# Key certificate structure is :
+# FIELD NAME SIZE (words)
+# ---------- ------------
+# Header token 1
+# version number 1
+# size in words (offset to signature) 1
+# Flags 1
+# N Pub key 96
+# Np 5
+# active SW version 1
+# public key HASH 8
+# RSA Signature 96
+
+####################################################################
+# Filename - cert_key_util.py
+# Description - This file contains the main functionality of the key
+# certificate generation.
+####################################################################
+
+import optparse
+import configparser
+import sys
+import os
+file_path = os.getcwd()
+sys.path.insert(0, os.path.join(file_path, "utils"))
+sys.path.append(os.path.join(sys.path[0], "..", ".."))
+
+from utils.common import util_logger
+from utils.common import global_defines
+from utils.common import certificates
+from utils.common_cert_lib.keycertificateconfig import KeyCertificateConfig
+
+# Util's log file
+LOG_FILENAME = "sb_key_cert.log"
+
+# find proj.cfg
+if "proj.cfg" in os.listdir(sys.path[0]):
+ PROJ_CONFIG_PATH = os.path.join(sys.path[0], "proj.cfg")
+elif "proj.cfg" in os.listdir(sys.path[-1]):
+ PROJ_CONFIG_PATH = os.path.join(sys.path[-1], "proj.cfg")
+else:
+ PROJ_CONFIG_PATH = os.path.join(os.getcwd(), "proj.cfg")
+
+
+class ArgumentParser:
+ def __init__(self):
+ self.cfg_filename = None
+ self.log_filename = LOG_FILENAME
+ self.parser = optparse.OptionParser()
+
+ def parse_arguments(self, args):
+ (options, args) = self.parser.parse_args(args)
+ if len(args) > 2 or len(args) < 1:
+ self.parser.error("incorrect number of positional arguments")
+ elif len(args) == 2:
+ self.log_filename = args[1]
+ self.cfg_filename = args[0]
+
+
+class KeyCertificateGenerator:
+ def __init__(self, logger, key_cfg, certificate_version):
+ self.config = key_cfg
+ self.logger = logger
+ self.cert_version = certificate_version
+ self._certificate = None
+
+ def create_certificate(self):
+ self.logger.info("**** Creating Key certificate ****")
+ self._certificate = certificates.KeyArmCertificate(self.config, self.cert_version, self.logger)
+
+ self.logger.info("Write the certificate to file")
+ with open(self.config.cert_pkg, "wb") as bin_output_file:
+ bin_output_file.write(self._certificate.certificate_data)
+
+ hex_formatted_cert = ["0x%02x" % i for i in list(self._certificate.certificate_data)]
+ txt_filename = self.config.cert_pkg[:-4] + '_' + global_defines.Cert_FileName + global_defines.Cert_FileExtTxt
+ with open(txt_filename, "w") as txt_output_file:
+ txt_output_file.write("char cert_bin_image[] = {\n")
+ txt_content = "".join([item+',\n' if ind % 4 == 3 else item+','
+ for ind, item in enumerate(hex_formatted_cert)])
+ txt_output_file.write(txt_content)
+ txt_output_file.write("}")
+
+
+def main(args):
+ if not (sys.version_info.major == 3 and sys.version_info.minor >= 5):
+ print("The script requires Python3.5 or later!")
+ sys.exit(-1)
+ # parse arguments
+ the_argument_parser = ArgumentParser()
+ the_argument_parser.parse_arguments(args)
+ # get logging up and running
+ the_logger = util_logger.UtilLogger(the_argument_parser.log_filename, "Key Certificate Generation")
+ # Get the project configuration values
+ project_config = configparser.ConfigParser()
+ with open(PROJ_CONFIG_PATH, 'r') as project_config_file:
+ config_string = '[PROJ-CFG]\n' + project_config_file.read()
+ project_config.read_string(config_string)
+ cert_version = [project_config.getint("PROJ-CFG", "CERT_VERSION_MAJOR"),
+ project_config.getint("PROJ-CFG", "CERT_VERSION_MINOR")]
+ # get util configuration parameters
+ key_certificate_config = KeyCertificateConfig(the_argument_parser.cfg_filename, the_logger)
+ # create certificate
+ cert_creator = KeyCertificateGenerator(the_logger, key_certificate_config, cert_version)
+ cert_creator.create_certificate()
+ the_logger.info("**** Certificate file creation has been completed successfully ****")
diff --git a/tools/alif/utils/cert_sb_content_util.py b/tools/alif/utils/cert_sb_content_util.py
index 42ecf0c4e..92aa90161 100755
--- a/tools/alif/utils/cert_sb_content_util.py
+++ b/tools/alif/utils/cert_sb_content_util.py
@@ -1,118 +1,118 @@
-#!/usr/bin/env python3
-#
-# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
-#
-
-# Content certificate structure is :
-# FIELD NAME SIZE (words)
-# ---------- ------------
-# Header token 1
-# version number 1
-# size in words (offset to signature) 1
-# Flags 1
-# N Pub key 96
-# Np 5
-# active SW version 1
-# NONCE 2
-# signed S/W records(hash + load address + max size + flag) N * (8+3)
-# RSA Signature 96
-# none-signed S/W records(storage address + actual size) N * (2)
-#
-
-import optparse
-import configparser
-import sys
-import os
-
-file_path = os.getcwd()
-sys.path.insert(0, os.path.join(file_path, "utils"))
-sys.path.append(os.path.join(file_path, "..", ".."))
-
-from common import util_logger
-from common import global_defines
-from common import certificates
-from utils.common_cert_lib.contentcertificateconfig import ContentCertificateConfig
-
-from printInfo import *
-
-# Util's log file
-LOG_FILENAME = "sb_content_cert.log"
-
-# find proj.cfg
-if "proj.cfg" in os.listdir(sys.path[0]):
- PROJ_CONFIG_PATH = os.path.join(sys.path[0], "proj.cfg")
-elif "proj.cfg" in os.listdir(sys.path[-1]):
- PROJ_CONFIG_PATH = os.path.join(sys.path[-1], "proj.cfg")
-else:
- PROJ_CONFIG_PATH = os.path.join(os.getcwd(), "proj.cfg")
-
-
-class ArgumentParser:
- def __init__(self):
- self.cfg_filename = None
- self.log_filename = LOG_FILENAME
- self.parser = optparse.OptionParser()
- self.parser.add_option("-c")
- self.parser.add_option("-l")
-
- def parse_arguments(self, args):
- args = self.parser.parse_args(args)
- if len(args) > 2 or len(args) < 1:
- self.parser.error("incorrect number of positional arguments")
- elif len(args) == 2:
- self.log_filename = args[0].l
- self.cfg_filename = args[0].c
-
-
-class ContentCertificateGenerator:
- def __init__(self, logger, content_cfg, certificate_version):
- self.config = content_cfg
- self.logger = logger
- self.cert_version = certificate_version
- self._certificate = None
-
- def create_certificate(self):
- if verboseModeGet():
- self.logger.info("**** Creating Content Certificate ****")
-
- self._certificate = certificates.ContentArmCertificate(self.config, self.cert_version, self.logger)
- serialized_cert_data = self._certificate.certificate_data
-
- with open(self.config.cert_pkg, "wb") as bin_output_file:
- bin_output_file.write(serialized_cert_data)
-
- hex_formatted_cert = ["0x%02x" % i for i in list(self._certificate.certificate_data)]
- txt_filename = self.config.cert_pkg[:-4] + '_' + global_defines.Cert_FileName + global_defines.Cert_FileExtTxt
- with open(txt_filename, "w") as txt_output_file:
- txt_output_file.write("char cert_bin_image[] = {\n")
- txt_content = "".join([item + ',\n' if ind % 4 == 3 else item + ','
- for ind, item in enumerate(hex_formatted_cert)])
- txt_output_file.write(txt_content)
- txt_output_file.write("}")
-
-
-def main(args):
- if not (sys.version_info.major == 3 and sys.version_info.minor >= 5):
- print("The script requires Python3.5 or later!")
- sys.exit(-1)
- # parse arguments
- the_argument_parser = ArgumentParser()
- the_argument_parser.parse_arguments(args)
- # get logging up and running
- the_logger = util_logger.UtilLogger(the_argument_parser.log_filename, "Content Certificate Generation")
- # Get the project configuration values
- project_config = configparser.ConfigParser()
- with open(PROJ_CONFIG_PATH, 'r') as project_config_file:
- config_string = '[PROJ-CFG]\n' + project_config_file.read()
- project_config.read_string(config_string)
- cert_version = [project_config.getint("PROJ-CFG", "CERT_VERSION_MAJOR"),
- project_config.getint("PROJ-CFG", "CERT_VERSION_MINOR")]
- # get util configuration parameters
- content_certificate_config = ContentCertificateConfig(the_argument_parser.cfg_filename, the_logger)
- # create certificate
- cert_creator = ContentCertificateGenerator(the_logger, content_certificate_config, cert_version)
- cert_creator.create_certificate()
- if verboseModeGet():
- the_logger.info("**** Certificate file creation has been completed successfully ****")
+#!/usr/bin/env python3
+#
+# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
+#
+
+# Content certificate structure is :
+# FIELD NAME SIZE (words)
+# ---------- ------------
+# Header token 1
+# version number 1
+# size in words (offset to signature) 1
+# Flags 1
+# N Pub key 96
+# Np 5
+# active SW version 1
+# NONCE 2
+# signed S/W records(hash + load address + max size + flag) N * (8+3)
+# RSA Signature 96
+# none-signed S/W records(storage address + actual size) N * (2)
+#
+
+import optparse
+import configparser
+import sys
+import os
+
+file_path = os.getcwd()
+sys.path.insert(0, os.path.join(file_path, "utils"))
+sys.path.append(os.path.join(file_path, "..", ".."))
+
+from common import util_logger
+from common import global_defines
+from common import certificates
+from utils.common_cert_lib.contentcertificateconfig import ContentCertificateConfig
+
+from printInfo import *
+
+# Util's log file
+LOG_FILENAME = "sb_content_cert.log"
+
+# find proj.cfg
+if "proj.cfg" in os.listdir(sys.path[0]):
+ PROJ_CONFIG_PATH = os.path.join(sys.path[0], "proj.cfg")
+elif "proj.cfg" in os.listdir(sys.path[-1]):
+ PROJ_CONFIG_PATH = os.path.join(sys.path[-1], "proj.cfg")
+else:
+ PROJ_CONFIG_PATH = os.path.join(os.getcwd(), "proj.cfg")
+
+
+class ArgumentParser:
+ def __init__(self):
+ self.cfg_filename = None
+ self.log_filename = LOG_FILENAME
+ self.parser = optparse.OptionParser()
+ self.parser.add_option("-c")
+ self.parser.add_option("-l")
+
+ def parse_arguments(self, args):
+ args = self.parser.parse_args(args)
+ if len(args) > 2 or len(args) < 1:
+ self.parser.error("incorrect number of positional arguments")
+ elif len(args) == 2:
+ self.log_filename = args[0].l
+ self.cfg_filename = args[0].c
+
+
+class ContentCertificateGenerator:
+ def __init__(self, logger, content_cfg, certificate_version):
+ self.config = content_cfg
+ self.logger = logger
+ self.cert_version = certificate_version
+ self._certificate = None
+
+ def create_certificate(self):
+ if verboseModeGet():
+ self.logger.info("**** Creating Content Certificate ****")
+
+ self._certificate = certificates.ContentArmCertificate(self.config, self.cert_version, self.logger)
+ serialized_cert_data = self._certificate.certificate_data
+
+ with open(self.config.cert_pkg, "wb") as bin_output_file:
+ bin_output_file.write(serialized_cert_data)
+
+ hex_formatted_cert = ["0x%02x" % i for i in list(self._certificate.certificate_data)]
+ txt_filename = self.config.cert_pkg[:-4] + '_' + global_defines.Cert_FileName + global_defines.Cert_FileExtTxt
+ with open(txt_filename, "w") as txt_output_file:
+ txt_output_file.write("char cert_bin_image[] = {\n")
+ txt_content = "".join([item + ',\n' if ind % 4 == 3 else item + ','
+ for ind, item in enumerate(hex_formatted_cert)])
+ txt_output_file.write(txt_content)
+ txt_output_file.write("}")
+
+
+def main(args):
+ if not (sys.version_info.major == 3 and sys.version_info.minor >= 5):
+ print("The script requires Python3.5 or later!")
+ sys.exit(-1)
+ # parse arguments
+ the_argument_parser = ArgumentParser()
+ the_argument_parser.parse_arguments(args)
+ # get logging up and running
+ the_logger = util_logger.UtilLogger(the_argument_parser.log_filename, "Content Certificate Generation")
+ # Get the project configuration values
+ project_config = configparser.ConfigParser()
+ with open(PROJ_CONFIG_PATH, 'r') as project_config_file:
+ config_string = '[PROJ-CFG]\n' + project_config_file.read()
+ project_config.read_string(config_string)
+ cert_version = [project_config.getint("PROJ-CFG", "CERT_VERSION_MAJOR"),
+ project_config.getint("PROJ-CFG", "CERT_VERSION_MINOR")]
+ # get util configuration parameters
+ content_certificate_config = ContentCertificateConfig(the_argument_parser.cfg_filename, the_logger)
+ # create certificate
+ cert_creator = ContentCertificateGenerator(the_logger, content_certificate_config, cert_version)
+ cert_creator.create_certificate()
+ if verboseModeGet():
+ the_logger.info("**** Certificate file creation has been completed successfully ****")
diff --git a/tools/alif/utils/cfg/OEMSBContent_lvs_1.cfg b/tools/alif/utils/cfg/OEMSBContent_lvs_1.cfg
index 5c6e855ac..9dcae68df 100755
--- a/tools/alif/utils/cfg/OEMSBContent_lvs_1.cfg
+++ b/tools/alif/utils/cfg/OEMSBContent_lvs_1.cfg
@@ -1,55 +1,55 @@
-# This configuration file is for the offline secure boot content certificate generation tool
-# cert_sb_content_util.py (Content Certificate Generation Tool - CCGT).
-#
-# The available parameters in this configuration file are the following
-# • [KEY-CFG] : Mandatory header.
-# The internal non-configurable header.
-# • cert-keypair : Mandatory parameter.
-# The file holding the RSA keypair for signing this certificate, in PEM format.
-# • cert-keypair-pwd : Optional. If omitted the tool prompts for direct input.
-# The passphrase file for the keypair file, in .txt format.
-# • load-verify-scheme : Mandatory parameter.
-# The SW image verification scheme. Supported schemes are:
-# - 0 : Load and verify from flash to memory.
-# - 1 : Full hash verification in Flash, with no loading to memory.
-# - 2 : Verify in memory.
-# - 3 : Load from flash.
-# Note: Option 3 is not recommended and is not allowed in Secure LCS.
-# • crypto-type : Mandatory parameter.
-# The cryptographic verification and decryption mode:
-# - 0 : Both AES and hash are calculated on the plain image.
-# - 1 : AES is calculated on the plain image, and the hash is calculated on the encrypted image.
-# Note: We recommend that you use the first mode.
-# • aes-ce-id : Mandatory parameter.
-# The ID of the key used for encryption, matching the entity that signed the certificate chain:
-# - 0 : None.
-# - 1 : Kceicv (ICV).
-# - 2 : Kce (OEM).
-# • aes-enc-key : Optional. Can be omitted if no encryption is needed.
-# The text file containing the encryption key for the authenticated SW images: Kce or Kceicv.
-# The contents of this file are comma-separated hex Bytes ("0x12,0x34 …") ending with "."
-# • images-table : Mandatory parameter.
-# The text file containing the list of SW image files to be processed. Each line refers to a single image,
-# with the following parameters: <32b mem load addr> <32b flash store addr> <32b image max size>
-#
-# Notes:
-# - If using loading scheme option 1, the memory address is 0xffffffff (nonexisting address).
-# - If using loading scheme option 2, the storage address is 0xffffffff (non-existing address).
-# - If encryption is used, an output file named _enc.bin is created for each encrypted image.
-# • nvcounter-val : Mandatory parameter.
-# The NV counter value:
-# - 0..64 : The ICV counter.
-# - 0..96 : The OEM counter.
-# - 0..160 : The full counter, if OEM and ICV are a single entity.
-# • cert-pkg : Mandatory parameter.
-# The content certificate package in binary format.
-[CNT-CFG]
-cert-keypair = key/OEMSBContent.pem
-cert-keypair-pwd = key/oem_keys_pass.pwd
-load-verify-scheme = 1
-crypto-type = 0
-aes-ce-id = 0
-aes-enc-key = key/kce.txt
-images-table = ../build/images/images.txt
-nvcounter-val = 0
-cert-pkg = ../cert/OEMSBContent.crt
+# This configuration file is for the offline secure boot content certificate generation tool
+# cert_sb_content_util.py (Content Certificate Generation Tool - CCGT).
+#
+# The available parameters in this configuration file are the following
+# • [KEY-CFG] : Mandatory header.
+# The internal non-configurable header.
+# • cert-keypair : Mandatory parameter.
+# The file holding the RSA keypair for signing this certificate, in PEM format.
+# • cert-keypair-pwd : Optional. If omitted the tool prompts for direct input.
+# The passphrase file for the keypair file, in .txt format.
+# • load-verify-scheme : Mandatory parameter.
+# The SW image verification scheme. Supported schemes are:
+# - 0 : Load and verify from flash to memory.
+# - 1 : Full hash verification in Flash, with no loading to memory.
+# - 2 : Verify in memory.
+# - 3 : Load from flash.
+# Note: Option 3 is not recommended and is not allowed in Secure LCS.
+# • crypto-type : Mandatory parameter.
+# The cryptographic verification and decryption mode:
+# - 0 : Both AES and hash are calculated on the plain image.
+# - 1 : AES is calculated on the plain image, and the hash is calculated on the encrypted image.
+# Note: We recommend that you use the first mode.
+# • aes-ce-id : Mandatory parameter.
+# The ID of the key used for encryption, matching the entity that signed the certificate chain:
+# - 0 : None.
+# - 1 : Kceicv (ICV).
+# - 2 : Kce (OEM).
+# • aes-enc-key : Optional. Can be omitted if no encryption is needed.
+# The text file containing the encryption key for the authenticated SW images: Kce or Kceicv.
+# The contents of this file are comma-separated hex Bytes ("0x12,0x34 …") ending with "."
+# • images-table : Mandatory parameter.
+# The text file containing the list of SW image files to be processed. Each line refers to a single image,
+# with the following parameters: <32b mem load addr> <32b flash store addr> <32b image max size>
+#
+# Notes:
+# - If using loading scheme option 1, the memory address is 0xffffffff (nonexisting address).
+# - If using loading scheme option 2, the storage address is 0xffffffff (non-existing address).
+# - If encryption is used, an output file named _enc.bin is created for each encrypted image.
+# • nvcounter-val : Mandatory parameter.
+# The NV counter value:
+# - 0..64 : The ICV counter.
+# - 0..96 : The OEM counter.
+# - 0..160 : The full counter, if OEM and ICV are a single entity.
+# • cert-pkg : Mandatory parameter.
+# The content certificate package in binary format.
+[CNT-CFG]
+cert-keypair = key/OEMSBContent.pem
+cert-keypair-pwd = key/oem_keys_pass.pwd
+load-verify-scheme = 1
+crypto-type = 0
+aes-ce-id = 0
+aes-enc-key = key/kce.txt
+images-table = ../build/images/images.txt
+nvcounter-val = 0
+cert-pkg = ../cert/OEMSBContent.crt
diff --git a/tools/alif/utils/cfg/OEMSBContent_lvs_2.cfg b/tools/alif/utils/cfg/OEMSBContent_lvs_2.cfg
index 8e503c1b1..adf3dda38 100755
--- a/tools/alif/utils/cfg/OEMSBContent_lvs_2.cfg
+++ b/tools/alif/utils/cfg/OEMSBContent_lvs_2.cfg
@@ -1,55 +1,55 @@
-# This configuration file is for the offline secure boot content certificate generation tool
-# cert_sb_content_util.py (Content Certificate Generation Tool - CCGT).
-#
-# The available parameters in this configuration file are the following
-# • [KEY-CFG] : Mandatory header.
-# The internal non-configurable header.
-# • cert-keypair : Mandatory parameter.
-# The file holding the RSA keypair for signing this certificate, in PEM format.
-# • cert-keypair-pwd : Optional. If omitted the tool prompts for direct input.
-# The passphrase file for the keypair file, in .txt format.
-# • load-verify-scheme : Mandatory parameter.
-# The SW image verification scheme. Supported schemes are:
-# - 0 : Load and verify from flash to memory.
-# - 1 : Full hash verification in Flash, with no loading to memory.
-# - 2 : Verify in memory.
-# - 3 : Load from flash.
-# Note: Option 3 is not recommended and is not allowed in Secure LCS.
-# • crypto-type : Mandatory parameter.
-# The cryptographic verification and decryption mode:
-# - 0 : Both AES and hash are calculated on the plain image.
-# - 1 : AES is calculated on the plain image, and the hash is calculated on the encrypted image.
-# Note: We recommend that you use the first mode.
-# • aes-ce-id : Mandatory parameter.
-# The ID of the key used for encryption, matching the entity that signed the certificate chain:
-# - 0 : None.
-# - 1 : Kceicv (ICV).
-# - 2 : Kce (OEM).
-# • aes-enc-key : Optional. Can be omitted if no encryption is needed.
-# The text file containing the encryption key for the authenticated SW images: Kce or Kceicv.
-# The contents of this file are comma-separated hex Bytes ("0x12,0x34 …") ending with "."
-# • images-table : Mandatory parameter.
-# The text file containing the list of SW image files to be processed. Each line refers to a single image,
-# with the following parameters: <32b mem load addr> <32b flash store addr> <32b image max size>
-#
-# Notes:
-# - If using loading scheme option 1, the memory address is 0xffffffff (nonexisting address).
-# - If using loading scheme option 2, the storage address is 0xffffffff (non-existing address).
-# - If encryption is used, an output file named _enc.bin is created for each encrypted image.
-# • nvcounter-val : Mandatory parameter.
-# The NV counter value:
-# - 0..64 : The ICV counter.
-# - 0..96 : The OEM counter.
-# - 0..160 : The full counter, if OEM and ICV are a single entity.
-# • cert-pkg : Mandatory parameter.
-# The content certificate package in binary format.
-[CNT-CFG]
-cert-keypair = key/OEMSBContent.pem
-cert-keypair-pwd = key/oem_keys_pass.pwd
-load-verify-scheme = 2
-crypto-type = 0
-aes-ce-id = 2
-aes-enc-key = key/kce.txt
-images-table = ../build/images/images.txt
-nvcounter-val = 0
-cert-pkg = ../cert/OEMSBContent.crt
+# This configuration file is for the offline secure boot content certificate generation tool
+# cert_sb_content_util.py (Content Certificate Generation Tool - CCGT).
+#
+# The available parameters in this configuration file are the following
+# • [KEY-CFG] : Mandatory header.
+# The internal non-configurable header.
+# • cert-keypair : Mandatory parameter.
+# The file holding the RSA keypair for signing this certificate, in PEM format.
+# • cert-keypair-pwd : Optional. If omitted the tool prompts for direct input.
+# The passphrase file for the keypair file, in .txt format.
+# • load-verify-scheme : Mandatory parameter.
+# The SW image verification scheme. Supported schemes are:
+# - 0 : Load and verify from flash to memory.
+# - 1 : Full hash verification in Flash, with no loading to memory.
+# - 2 : Verify in memory.
+# - 3 : Load from flash.
+# Note: Option 3 is not recommended and is not allowed in Secure LCS.
+# • crypto-type : Mandatory parameter.
+# The cryptographic verification and decryption mode:
+# - 0 : Both AES and hash are calculated on the plain image.
+# - 1 : AES is calculated on the plain image, and the hash is calculated on the encrypted image.
+# Note: We recommend that you use the first mode.
+# • aes-ce-id : Mandatory parameter.
+# The ID of the key used for encryption, matching the entity that signed the certificate chain:
+# - 0 : None.
+# - 1 : Kceicv (ICV).
+# - 2 : Kce (OEM).
+# • aes-enc-key : Optional. Can be omitted if no encryption is needed.
+# The text file containing the encryption key for the authenticated SW images: Kce or Kceicv.
+# The contents of this file are comma-separated hex Bytes ("0x12,0x34 …") ending with "."
+# • images-table : Mandatory parameter.
+# The text file containing the list of SW image files to be processed. Each line refers to a single image,
+# with the following parameters: <32b mem load addr> <32b flash store addr> <32b image max size>
+#
+# Notes:
+# - If using loading scheme option 1, the memory address is 0xffffffff (nonexisting address).
+# - If using loading scheme option 2, the storage address is 0xffffffff (non-existing address).
+# - If encryption is used, an output file named _enc.bin is created for each encrypted image.
+# • nvcounter-val : Mandatory parameter.
+# The NV counter value:
+# - 0..64 : The ICV counter.
+# - 0..96 : The OEM counter.
+# - 0..160 : The full counter, if OEM and ICV are a single entity.
+# • cert-pkg : Mandatory parameter.
+# The content certificate package in binary format.
+[CNT-CFG]
+cert-keypair = key/OEMSBContent.pem
+cert-keypair-pwd = key/oem_keys_pass.pwd
+load-verify-scheme = 2
+crypto-type = 0
+aes-ce-id = 2
+aes-enc-key = key/kce.txt
+images-table = ../build/images/images.txt
+nvcounter-val = 0
+cert-pkg = ../cert/OEMSBContent.crt
diff --git a/tools/alif/utils/cfg/OEMSBKey1.cfg b/tools/alif/utils/cfg/OEMSBKey1.cfg
index be28fb42f..4f42a2493 100755
--- a/tools/alif/utils/cfg/OEMSBKey1.cfg
+++ b/tools/alif/utils/cfg/OEMSBKey1.cfg
@@ -1,35 +1,35 @@
-# This configuration file is for the offline key certificate tool cert_key_util.py (Key Certificate Generation Tool - KCGT).
-#
-# The available parameters in this configuration file are the following
-# • [KEY-CFG] : Mandatory header.
-# The internal non-configurable header.
-# • cert-keypair : Mandatory parameter.
-# The file holding the RSA keypair for signing this certificate, in PEM format.
-# • cert-keypair-pwd : Optional. If omitted the tool prompts for direct input.
-# The passphrase file for the keypair file, in .txt format.
-# • hbk-id : Mandatory parameter. The tool is agnostic to the certificate usage, this parameter cannot be omitted.
-# The ID of the Hbk field in OTP memory that the public key of this certificate is verified against:
-# - 0: 128-bit Hbk0.
-# - 1: 128-bit Hbk1.
-# - 2: 256-bit Hbk.
-# The ROM code uses this field only if this certificate is the first certificate in:
-# - A two-level SB certificate chain.
-# - A three-level SB certificate chain.
-# - A three-level Secure Debug chain.
-# • nvcounter-val : Mandatory parameter.
-# The NV counter value:
-# - 0..64: the ICV counter.
-# - 0..96: the OEM counter.
-# - 0..160: the full counter, if OEM and ICV are a single entity.
-# The passphrase file for the keypair file, in .txt format.
-# • next-cert-pubkey : Mandatory parameter.
-# The file holding the RSA public key for signing the next certificate in the chain, in PEM format.
-# • cert-pkg : Mandatory parameter.
-# The key certificate package output file.
-[KEY-CFG]
-cert-keypair = utils/key/OEMRoT.pem
-cert-keypair-pwd = utils/key/oem_keys_pass.pwd
-hbk-id = 1
-nvcounter-val = 0
-next-cert-pubkey = utils/key/OEMSBKeyPublic.pem
-cert-pkg = cert/OEMSBKey1.crt
+# This configuration file is for the offline key certificate tool cert_key_util.py (Key Certificate Generation Tool - KCGT).
+#
+# The available parameters in this configuration file are the following
+# • [KEY-CFG] : Mandatory header.
+# The internal non-configurable header.
+# • cert-keypair : Mandatory parameter.
+# The file holding the RSA keypair for signing this certificate, in PEM format.
+# • cert-keypair-pwd : Optional. If omitted the tool prompts for direct input.
+# The passphrase file for the keypair file, in .txt format.
+# • hbk-id : Mandatory parameter. The tool is agnostic to the certificate usage, this parameter cannot be omitted.
+# The ID of the Hbk field in OTP memory that the public key of this certificate is verified against:
+# - 0: 128-bit Hbk0.
+# - 1: 128-bit Hbk1.
+# - 2: 256-bit Hbk.
+# The ROM code uses this field only if this certificate is the first certificate in:
+# - A two-level SB certificate chain.
+# - A three-level SB certificate chain.
+# - A three-level Secure Debug chain.
+# • nvcounter-val : Mandatory parameter.
+# The NV counter value:
+# - 0..64: the ICV counter.
+# - 0..96: the OEM counter.
+# - 0..160: the full counter, if OEM and ICV are a single entity.
+# The passphrase file for the keypair file, in .txt format.
+# • next-cert-pubkey : Mandatory parameter.
+# The file holding the RSA public key for signing the next certificate in the chain, in PEM format.
+# • cert-pkg : Mandatory parameter.
+# The key certificate package output file.
+[KEY-CFG]
+cert-keypair = utils/key/OEMRoT.pem
+cert-keypair-pwd = utils/key/oem_keys_pass.pwd
+hbk-id = 1
+nvcounter-val = 0
+next-cert-pubkey = utils/key/OEMSBKeyPublic.pem
+cert-pkg = cert/OEMSBKey1.crt
diff --git a/tools/alif/utils/cfg/OEMSBKey2.cfg b/tools/alif/utils/cfg/OEMSBKey2.cfg
index 10c66eb4c..a39b9267a 100755
--- a/tools/alif/utils/cfg/OEMSBKey2.cfg
+++ b/tools/alif/utils/cfg/OEMSBKey2.cfg
@@ -1,35 +1,35 @@
-# This configuration file is for the offline key certificate tool cert_key_util.py (Key Certificate Generation Tool - KCGT).
-#
-# The available parameters in this configuration file are the following
-# • [KEY-CFG] : Mandatory header.
-# The internal non-configurable header.
-# • cert-keypair : Mandatory parameter.
-# The file holding the RSA keypair for signing this certificate, in PEM format.
-# • cert-keypair-pwd : Optional. If omitted the tool prompts for direct input.
-# The passphrase file for the keypair file, in .txt format.
-# • hbk-id : Mandatory parameter. The tool is agnostic to the certificate usage, this parameter cannot be omitted.
-# The ID of the Hbk field in OTP memory that the public key of this certificate is verified against:
-# - 0: 128-bit Hbk0.
-# - 1: 128-bit Hbk1.
-# - 2: 256-bit Hbk.
-# The ROM code uses this field only if this certificate is the first certificate in:
-# - A two-level SB certificate chain.
-# - A three-level SB certificate chain.
-# - A three-level Secure Debug chain.
-# • nvcounter-val : Mandatory parameter.
-# The NV counter value:
-# - 0..64: the ICV counter.
-# - 0..96: the OEM counter.
-# - 0..160: the full counter, if OEM and ICV are a single entity.
-# The passphrase file for the keypair file, in .txt format.
-# • next-cert-pubkey : Mandatory parameter.
-# The file holding the RSA public key for signing the next certificate in the chain, in PEM format.
-# • cert-pkg : Mandatory parameter.
-# The key certificate package output file.
-[KEY-CFG]
-cert-keypair = utils/key/OEMSBKey.pem
-cert-keypair-pwd = utils/key/oem_keys_pass.pwd
-hbk-id = 1
-nvcounter-val = 0
-next-cert-pubkey = utils/key/OEMSBContentPublic.pem
-cert-pkg = cert/OEMSBKey2.crt
+# This configuration file is for the offline key certificate tool cert_key_util.py (Key Certificate Generation Tool - KCGT).
+#
+# The available parameters in this configuration file are the following
+# • [KEY-CFG] : Mandatory header.
+# The internal non-configurable header.
+# • cert-keypair : Mandatory parameter.
+# The file holding the RSA keypair for signing this certificate, in PEM format.
+# • cert-keypair-pwd : Optional. If omitted the tool prompts for direct input.
+# The passphrase file for the keypair file, in .txt format.
+# • hbk-id : Mandatory parameter. The tool is agnostic to the certificate usage, this parameter cannot be omitted.
+# The ID of the Hbk field in OTP memory that the public key of this certificate is verified against:
+# - 0: 128-bit Hbk0.
+# - 1: 128-bit Hbk1.
+# - 2: 256-bit Hbk.
+# The ROM code uses this field only if this certificate is the first certificate in:
+# - A two-level SB certificate chain.
+# - A three-level SB certificate chain.
+# - A three-level Secure Debug chain.
+# • nvcounter-val : Mandatory parameter.
+# The NV counter value:
+# - 0..64: the ICV counter.
+# - 0..96: the OEM counter.
+# - 0..160: the full counter, if OEM and ICV are a single entity.
+# The passphrase file for the keypair file, in .txt format.
+# • next-cert-pubkey : Mandatory parameter.
+# The file holding the RSA public key for signing the next certificate in the chain, in PEM format.
+# • cert-pkg : Mandatory parameter.
+# The key certificate package output file.
+[KEY-CFG]
+cert-keypair = utils/key/OEMSBKey.pem
+cert-keypair-pwd = utils/key/oem_keys_pass.pwd
+hbk-id = 1
+nvcounter-val = 0
+next-cert-pubkey = utils/key/OEMSBContentPublic.pem
+cert-pkg = cert/OEMSBKey2.crt
diff --git a/tools/alif/utils/clocks.py b/tools/alif/utils/clocks.py
index 606be904d..c82dce060 100755
--- a/tools/alif/utils/clocks.py
+++ b/tools/alif/utils/clocks.py
@@ -1,41 +1,41 @@
-""" clocks """
-import json
-import struct
-
-
-# pylint: disable=too-few-public-methods
-# pylint: disable=too-many-instance-attributes
-# pylint: disable=invalid-name
-# pylint: disable=attribute-defined-outside-init
-
-def processChangeSets(changeSets):
- print('Processing ChangeSets')
- data = bytearray()
- for set in changeSets:
- print(set)
- data += bytes(int(set['address'], 16).to_bytes(4, 'little'))
- data += bytes(int(set['mask'], 16).to_bytes(4, 'little'))
- data += bytes(int(set['value'], 16).to_bytes(4, 'little'))
-
- #print(data)
- #print(type(data))
- #print(len(data))
- return data
-
-def json_to_bin(jsn):
- """ Convert a JSON object into binary """
- data = bytearray()
- for sec in jsn:
- if sec == 'change_sets':
- data = processChangeSets(jsn[sec])
-
-
- return data
-
-def main():
- """ main """
- json_to_bin()
- return 0
-
-if __name__ == "__main__":
- main()
+""" clocks """
+import json
+import struct
+
+
+# pylint: disable=too-few-public-methods
+# pylint: disable=too-many-instance-attributes
+# pylint: disable=invalid-name
+# pylint: disable=attribute-defined-outside-init
+
+def processChangeSets(changeSets):
+ print('Processing ChangeSets')
+ data = bytearray()
+ for set in changeSets:
+ print(set)
+ data += bytes(int(set['address'], 16).to_bytes(4, 'little'))
+ data += bytes(int(set['mask'], 16).to_bytes(4, 'little'))
+ data += bytes(int(set['value'], 16).to_bytes(4, 'little'))
+
+ #print(data)
+ #print(type(data))
+ #print(len(data))
+ return data
+
+def json_to_bin(jsn):
+ """ Convert a JSON object into binary """
+ data = bytearray()
+ for sec in jsn:
+ if sec == 'change_sets':
+ data = processChangeSets(jsn[sec])
+
+
+ return data
+
+def main():
+ """ main """
+ json_to_bin()
+ return 0
+
+if __name__ == "__main__":
+ main()
diff --git a/tools/alif/utils/common/certificates.py b/tools/alif/utils/common/certificates.py
index 0cefd7b5f..b25a312e9 100755
--- a/tools/alif/utils/common/certificates.py
+++ b/tools/alif/utils/common/certificates.py
@@ -1,641 +1,641 @@
-# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
-#
-
-import os
-import abc
-import re
-import struct
-from utils.common import global_defines
-from utils.common import flags_global_defines
-from utils.common import cryptolayer
-from utils.common.exceptions import CertCreationError
-
-# *******************************************************************
-# Modification to handle local directories vs Azure Storage
-# when looking for Key1/key2 certs in gen-toc.py
-# *******************************************************************
-def getKeyCertificatePath():
- return "cert/" # local files
-
-# *******************************************************************
-# Modification to handle DEV vs PROD (Azure) Environments
-# when looking for the alif package name (suffix) in gen-toc.py
-# (to differentiate the name of packages for PROD vs DEV in APP Tools)
-# *******************************************************************
-def getEnvironmentSuffix():
- return '-dev' # DEV environment suffix
-
-class ArmCertificateHeader(abc.ABC):
- @property
- @abc.abstractmethod
- def magic_number(self):
- pass
-
- @property
- @abc.abstractmethod
- def cert_version_number(self):
- pass
-
- @property
- @abc.abstractmethod
- def signed_content_size(self):
- pass
-
- @property
- @abc.abstractmethod
- def flags(self):
- pass
-
- @abc.abstractmethod
- def serialize_to_bytes(self):
- pass
-
-
-class KeyArmCertificateHeader(ArmCertificateHeader):
- CERT_TOKEN = 0x53426b63
-
- def __init__(self, cert_version, hbk_id, logger=None):
- self._cert_version = (cert_version[0] << 16) + cert_version[1]
- self._hbk_id = hbk_id
- self.logger = logger
- self._signed_content_size = (global_defines.HEADER_SIZE_IN_WORDS
- + global_defines.SW_VERSION_OBJ_SIZE_IN_WORDS
- + global_defines.PUBKEY_SIZE_WORDS
- + global_defines.NP_SIZE_IN_WORDS
- + global_defines.HASH_ALGORITHM_SHA256_SIZE_IN_WORDS)
- self._flags = hbk_id
-
- def magic_number(self):
- return self.CERT_TOKEN
-
- def cert_version_number(self):
- return self._cert_version
-
- def signed_content_size(self):
- return self._signed_content_size
-
- def flags(self):
- return self._flags
-
- def serialize_to_bytes(self):
- data = (struct.pack(' global_defines.AES_DECRYPT_KEY_SIZE_IN_BYTES:
- self.logger.warning("key size in aes-enc-key file is too big - truncating parameter")
- key_data_list = [int(item, 16) for item in str_key_data_bytes]
- key_data_list = key_data_list[:global_defines.AES_DECRYPT_KEY_SIZE_IN_BYTES]
-
- # combine nonce and address into iv (8 bytes nonce + 4 bytes address + 4 bytes of zeros)
- aes_iv = self._key_nonce + bytes(item["mem_load_address_byte_list"]) + bytes(4)
- # encrypt image
- new_image_filename = item["image_filename"][:-4] + global_defines.SW_COMP_FILE_NAME_POSTFIX
- hash_of_image, actual_image_size = cryptolayer.Common.encrypt_file_with_aes_ctr(item["image_filename"],
- new_image_filename,
- key_data_list,
- aes_iv,
- self._crypto_type,
- self.logger)
- else:
- raise CertCreationError("invalid aes-ce-id for image encryption flag in image of images-table - "
- "must have aes-enc-key for images to be encrypted")
- else:
- # do only hash
- with open(item["image_filename"], "rb") as input_file:
- plaintext = input_file.read()
- actual_image_size = len(plaintext)
- hash_of_image = cryptolayer.HashCrypto.calculate_sha256_hash(plaintext)
- # image_hash_and_size.append([hash_of_image, actual_image_size])
- self._sw_records.append([hash_of_image, item["mem_load_address"], item["image_max_size"], item["is_aes_code_enc_used"]])
- self._none_signed_info.append([item["flash_store_address"], actual_image_size])
-
- @property
- def num_images(self):
- return self._num_images
-
- @property
- def sw_version(self):
- return self._sw_version
-
- @property
- def signer_rsa_public_key(self):
- return self._signer_rsa_public_key
-
- @property
- def key_nonce(self):
- return self._key_nonce
-
- def serialize_to_bytes(self):
- data = (self._signer_rsa_public_key
- + struct.pack(' global_defines.AES_DECRYPT_KEY_SIZE_IN_BYTES:
+ self.logger.warning("key size in aes-enc-key file is too big - truncating parameter")
+ key_data_list = [int(item, 16) for item in str_key_data_bytes]
+ key_data_list = key_data_list[:global_defines.AES_DECRYPT_KEY_SIZE_IN_BYTES]
+
+ # combine nonce and address into iv (8 bytes nonce + 4 bytes address + 4 bytes of zeros)
+ aes_iv = self._key_nonce + bytes(item["mem_load_address_byte_list"]) + bytes(4)
+ # encrypt image
+ new_image_filename = item["image_filename"][:-4] + global_defines.SW_COMP_FILE_NAME_POSTFIX
+ hash_of_image, actual_image_size = cryptolayer.Common.encrypt_file_with_aes_ctr(item["image_filename"],
+ new_image_filename,
+ key_data_list,
+ aes_iv,
+ self._crypto_type,
+ self.logger)
+ else:
+ raise CertCreationError("invalid aes-ce-id for image encryption flag in image of images-table - "
+ "must have aes-enc-key for images to be encrypted")
+ else:
+ # do only hash
+ with open(item["image_filename"], "rb") as input_file:
+ plaintext = input_file.read()
+ actual_image_size = len(plaintext)
+ hash_of_image = cryptolayer.HashCrypto.calculate_sha256_hash(plaintext)
+ # image_hash_and_size.append([hash_of_image, actual_image_size])
+ self._sw_records.append([hash_of_image, item["mem_load_address"], item["image_max_size"], item["is_aes_code_enc_used"]])
+ self._none_signed_info.append([item["flash_store_address"], actual_image_size])
+
+ @property
+ def num_images(self):
+ return self._num_images
+
+ @property
+ def sw_version(self):
+ return self._sw_version
+
+ @property
+ def signer_rsa_public_key(self):
+ return self._signer_rsa_public_key
+
+ @property
+ def key_nonce(self):
+ return self._key_nonce
+
+ def serialize_to_bytes(self):
+ data = (self._signer_rsa_public_key
+ + struct.pack('>: ").encode("utf-8")
- private_key = rsa.generate_private_key(public_exponent=65537, key_size=3072, backend=default_backend())
- serialized_pem_key = private_key.private_bytes(
- encoding=serialization.Encoding.PEM,
- format=serialization.PrivateFormat.PKCS8,
- encryption_algorithm=serialization.BestAvailableEncryption(passphrase)
- )
- with open(pem_filename, "wb") as output_file:
- output_file.write(serialized_pem_key)
- if logger is not None:
- logger.info("Private key written to: %s" % pem_filename)
-
- return private_key
-
- @staticmethod
- def extract_public_rsa_pem_key(private_key, public_pem_filename, logger=None):
- public_key = private_key.public_key()
- serialized_public_key = public_key.public_bytes(encoding=serialization.Encoding.PEM,
- format=serialization.PublicFormat.SubjectPublicKeyInfo)
-
- with open(public_pem_filename, "wb") as output_file:
- output_file.write(serialized_public_key)
- if logger is not None:
- logger.info("Public key written to: %s" % public_pem_filename)
-
- @staticmethod
- def load_rsa_pem_key(pem_filename, is_key_private, keypair_passphrase_filename=None, logger=None):
- """
- Loads RSA private/public key encoded in PEM format
-
- :param pem_filename: input file in PEM format
- :param is_key_private: True for private keys, False for public keys
- :param keypair_passphrase_filename: filename containing passphrase for private key, left out in for public keys
- :param logger: initialized logging.logger instance
- :return: instance of RSAPublicKey/RSAPrivateKey depending on is_key_private
-
- Raises RsaKeyLoadingError in case of failure.
- """
- # opening PEM file
- try:
- with open(pem_filename) as key_file:
- pem_data = key_file.read()
- except OSError as e:
- if logger is not None:
- logger.warning("Could not open RSA key file %s" % pem_filename)
- raise RsaKeyLoadingError("Could not open RSA key file: %s" % e)
- # loading passphrase for private keys
- if is_key_private is True:
- if len(keypair_passphrase_filename) > 0:
- try:
- with open(keypair_passphrase_filename, "r") as pwd_file:
- passphrase = pwd_file.read()
- passphrase = passphrase.strip().encode("utf-8")
- except OSError as e:
- if logger is not None:
- logger.warning("Could not open keypair passphrase file %s" % keypair_passphrase_filename)
- raise RsaKeyLoadingError("Could not open keypair passphrase file: %s" % e)
- else:
- passphrase = getpass.getpass(prompt="Enter passphrase for RSA private key: ").encode("utf-8")
- # loading public/private key
- try:
- if is_key_private is True: # private key case
- key = load_pem_private_key(bytes(pem_data, encoding="utf-8"), passphrase, backend=default_backend())
- # check return value
- if isinstance(key, rsa.RSAPrivateKey) is False:
- if logger is not None:
- logger.warning("Could not parse key as an RSA Private key from file %s" % pem_filename)
- raise RsaKeyLoadingError("Could not parse PEM file as an RSAPrivateKey")
- else: # public key case
- key = load_pem_public_key(bytes(pem_data, encoding="utf-8"), backend=default_backend())
- # check return value
- if isinstance(key, rsa.RSAPublicKey) is False:
- if logger is not None:
- logger.warning("Could not parse key as an RSA Public key from file %s" % pem_filename)
- raise RsaKeyLoadingError("Could not parse PEM file as an RSAPublicKey")
- except ValueError or cryptography.exceptions.UnsupportedAlgorithm as e:
- # look for internal errors
- if logger is not None:
- logger.warning("Could not read RSA key from file %s" % pem_filename)
- raise RsaKeyLoadingError("Could load RSA key: %s" % e)
- else:
- return key
-
- @staticmethod
- def get_n_from_rsa_pem_private_key(rsa_key):
- """
- Get modulus (N) from RSA Private key
-
- :param rsa_key: instance of rsa.RSAPrivateKey
- :return: modulus (N) of the given key object
- """
- return rsa_key.public_key().public_numbers().n
-
- @staticmethod
- def get_n_from_rsa_pem_public_key(rsa_key):
- """
- Get modulus (N) from RSA Public key
-
- :param rsa_key: instance of rsa.RSAPublicKey
- :return: modulus (N) of the given key object
- """
- return rsa_key.public_numbers().n
-
- @staticmethod
- def calculate_np_from_n(n_as_modulus, logger=None):
- if not isinstance(n_as_modulus, int):
- if logger is not None:
- logger.warning("input parameter n_as_modulus expected to be integer")
- raise TypeError("input parameter n_as_modulus expected to be integer")
- param_np = (2 ** global_defines.SNP) // n_as_modulus
- return param_np
-
- @staticmethod
- def concatenate_n_and_np(n_as_modulus, param_np, logger=None):
- if not isinstance(n_as_modulus, int):
- if logger is not None:
- logger.warning("input parameter n_as_modulus expected to be integer")
- raise TypeError("input parameter n_as_modulus expected to be integer")
- if not isinstance(param_np, int):
- if logger is not None:
- logger.warning("input parameter param_np expected to be integer")
- raise TypeError("input parameter param_np expected to be integer")
- n_in_bytes = n_as_modulus.to_bytes(global_defines.SB_CERT_RSA_KEY_SIZE_IN_BYTES, 'big')
- np_in_bytes = param_np.to_bytes(global_defines.NP_SIZE_IN_BYTES, 'big')
- n_and_np_in_bytes = n_in_bytes + np_in_bytes
- return n_and_np_in_bytes
-
- @staticmethod
- def sign_pkcs_v21(prehashed_data_to_sign, rsa_key, logger=None):
- signature = rsa_key.sign(prehashed_data_to_sign,
- padding.PSS(mgf=padding.MGF1(hashes.SHA256()),
- salt_length=global_defines.RSA_SALT_LEN
- ),
- utils.Prehashed(hashes.SHA256()))
- return signature
-
- @staticmethod
- def verify_signature_pkcs_v21(signature, prehashed_message, public_key, logger=None):
- """
- Verifies signature on prehashed message. Raises InvalidSignature if it does not match.
- """
- public_key.verify(signature,
- prehashed_message,
- padding.PSS(mgf=padding.MGF1(hashes.SHA256()),
- salt_length=global_defines.RSA_SALT_LEN
- ),
- utils.Prehashed(hashes.SHA256()))
-
- @staticmethod
- def decrypt_oaep(ciphertext, private_key):
- decrypted_text = private_key.decrypt(
- ciphertext,
- padding.OAEP(
- mgf=padding.MGF1(algorithm=hashes.SHA256()),
- algorithm=hashes.SHA256(),
- label=None
- )
- )
- return decrypted_text
-
- @staticmethod
- def encrypt_oaep(message, public_key):
- ciphertext = public_key.encrypt(
- message,
- padding.OAEP(
- mgf=padding.MGF1(algorithm=hashes.SHA256()),
- algorithm=hashes.SHA256(),
- label=None
- )
- )
- return ciphertext
-
- @staticmethod
- def load_rsa_public_key_from_n(n_as_modulus):
- # todo: check for param type is integer
- rsa_params = rsa.RSAPublicNumbers(65537, n_as_modulus)
- return rsa_params.public_key(default_backend())
-
-
-class HashCrypto:
- @staticmethod
- def calculate_sha256_hash(input_bytes):
- hash_function = hashes.Hash(hashes.SHA256(), backend=default_backend())
- hash_function.update(input_bytes)
- message_digest = hash_function.finalize()
- return message_digest
-
- @staticmethod
- def calculate_md5_hash(input_bytes):
- hash_function = hashes.Hash(hashes.MD5(), backend=default_backend())
- hash_function.update(input_bytes)
- message_digest = hash_function.finalize()
- return message_digest
-
-
-class AesCrypto:
- @staticmethod
- def encrypt_aes_ctr(message, aes_key, iv):
- """
- :param message: message as bytes object
- :param aes_key: bytes-like aes key used for encryption
- :param iv: bytes-like initialization vector
- :return: ciphertext
- """
- aes_cipher = Cipher(algorithms.AES(aes_key), modes.CTR(iv), backend=default_backend())
- aes_encryptor = aes_cipher.encryptor()
- ciphertext = aes_encryptor.update(message) + aes_encryptor.finalize()
- return ciphertext
-
- @staticmethod
- def encrypt_aes_cbc(message, aes_key, aes_iv):
- """
- :param message: message as bytes object
- :param aes_key: bytes-like aes key used for encryption
- :param aes_iv: bytes-like initialization vector
- :return: ciphertext
- """
- aes_cipher = Cipher(algorithms.AES(aes_key), modes.CBC(aes_iv), backend=default_backend())
- aes_encryptor = aes_cipher.encryptor()
- ciphertext = aes_encryptor.update(message) + aes_encryptor.finalize()
- return ciphertext
-
- @staticmethod
- def decrypt_aes_cbc(ciphertext, aes_key, aes_iv):
- aes_cipher = Cipher(algorithms.AES(aes_key), modes.CBC(aes_iv), backend=default_backend())
- aes_decryptor = aes_cipher.decryptor()
- return aes_decryptor.update(ciphertext) + aes_decryptor.finalize()
-
- @staticmethod
- def calc_aes_cmac(message, key):
- aes_cmac = cmac.CMAC(algorithms.AES(key), backend=default_backend())
- aes_cmac.update(message)
- return aes_cmac.finalize()
-
- @staticmethod
- def encrypt_aes_ccm(key, nonce, associated_data, message):
- aes_ccm = aead.AESCCM(key, 16) # tag length = 16 bytes
- ciphertext = aes_ccm.encrypt(nonce, message, associated_data)
- return ciphertext
-
-
-class Common:
- @staticmethod
- def get_n_and_np_from_public_key(public_key_filename, logger=None):
- key = RsaCrypto.load_rsa_pem_key(public_key_filename, False, logger=logger)
- param_n = RsaCrypto.get_n_from_rsa_pem_public_key(key)
- param_np = RsaCrypto.calculate_np_from_n(param_n, logger)
- n_and_np_bytes = RsaCrypto.concatenate_n_and_np(param_n, param_np, logger)
- return n_and_np_bytes
-
- @staticmethod
- def get_hashed_n_and_np_from_public_key(public_key_filename, logger=None):
- n_and_np_bytes = Common.get_n_and_np_from_public_key(public_key_filename, logger)
- digest = HashCrypto.calculate_sha256_hash(n_and_np_bytes)
- return digest
-
- @staticmethod
- def get_n_and_np_from_keypair(keypair_filename, keypair_passphrase_file, logger=None):
- key = RsaCrypto.load_rsa_pem_key(keypair_filename, True, keypair_passphrase_file, logger=logger)
- param_n = RsaCrypto.get_n_from_rsa_pem_private_key(key)
- param_np = RsaCrypto.calculate_np_from_n(param_n, logger)
- n_and_np_bytes = RsaCrypto.concatenate_n_and_np(param_n, param_np, logger)
- return n_and_np_bytes
-
- @staticmethod
- def rsa_sign(data_to_sign, keypair_filename, keypair_passphrase_file, logger=None):
- key = RsaCrypto.load_rsa_pem_key(keypair_filename, True, keypair_passphrase_file, logger=logger)
- hashed_data_to_sign = HashCrypto.calculate_sha256_hash(data_to_sign)
- signature = RsaCrypto.sign_pkcs_v21(hashed_data_to_sign, key, logger)
- RsaCrypto.verify_signature_pkcs_v21(signature, hashed_data_to_sign, key.public_key(), logger)
- return signature
-
- @staticmethod
- def rsa_verify_with_pubkey_params(rsa_pubkey_n, signed_data, signature, logger=None):
- modulus_in_bytes = rsa_pubkey_n[0:global_defines.PUBKEY_SIZE_BYTES] # chop of np is input contains it
- modulus = int.from_bytes(modulus_in_bytes, "big")
- public_key = RsaCrypto.load_rsa_public_key_from_n(modulus)
- hashed_data_to_sign = HashCrypto.calculate_sha256_hash(signed_data)
- RsaCrypto.verify_signature_pkcs_v21(signature, hashed_data_to_sign, public_key, logger)
-
- @staticmethod
- def decrypt_data_with_rsa_keypair(keypair_filename, keypair_passphrase_file, ciphertext, logger=None):
- private_key = RsaCrypto.load_rsa_pem_key(keypair_filename, True, keypair_passphrase_file, logger=logger)
- message = RsaCrypto.decrypt_oaep(ciphertext, private_key)
- return message
-
- @staticmethod
- def encrypt_data_with_rsa_pubkey_params(rsa_pubkey_n_and_np, input_data):
- modulus_in_bytes = rsa_pubkey_n_and_np[0:global_defines.PUBKEY_SIZE_BYTES]
- modulus = int.from_bytes(modulus_in_bytes, "big")
- public_key = RsaCrypto.load_rsa_public_key_from_n(modulus)
- ciphertext = RsaCrypto.encrypt_oaep(input_data, public_key)
- return ciphertext
-
- @staticmethod
- def encrypt_file_with_aes_ctr(input_filename, output_filename, key_int_array, aes_iv, hash_type, logger=None):
- """
- Encrypts image and calculates SHA256 hash on it
- :param input_filename: filename of image to be encrypted
- :param output_filename: filename of encrypted image
- :param key_int_array: bytes of aes key in a list
- :param aes_iv: initialization vector
- :param hash_type: 0 for hash calculated on plain image, 1 for hash on encrypted image
- :param logger:
- :return: returns the hash digest and the image size in a tuple
- """
- with open(input_filename, "rb") as input_file:
- plaintext = input_file.read()
- image_actual_size = len(plaintext)
- if image_actual_size == 0 or image_actual_size % 4 != 0:
- raise ValueError("invalid images size")
- ciphertext = AesCrypto.encrypt_aes_ctr(plaintext, bytes(key_int_array), aes_iv)
- with open(output_filename, "wb") as output_file:
- output_file.write(ciphertext)
- if hash_type == 0:
- hash_digest = HashCrypto.calculate_sha256_hash(plaintext)
- elif hash_type == 1:
- hash_digest = HashCrypto.calculate_sha256_hash(ciphertext)
- else:
- raise ValueError("Invalid input value for hash_type (crypto_type)")
- return hash_digest, image_actual_size
-
- @staticmethod
- def derive_aes_key(enc_password_filename, logger=None):
- # get passphrase
- if len(enc_password_filename) > 0:
- try:
- with open(enc_password_filename, "r") as pwd_file:
- passphrase = pwd_file.read()
- passphrase = passphrase.strip().encode("utf-8")
- except OSError as e:
- if logger is not None:
- logger.warning("Could not open passphrase file %s" % enc_password_filename)
- raise ValueError("Could not open passphrase file: %s" % e)
- else:
- passphrase = getpass.getpass(prompt="Enter passphrase for encrypted key: ").encode("utf-8")
-
- # PBDF1 key and iv derivation with 1 round, no salt, MD5 hash for compatibility reasons:
- # "openssl enc -e -nosalt -md md5 -aes-128-cbc -in -out -pass file:"
- # and also with EVP_BytesToKey(cipher, dgst, NULL, (uint8_t *) pwdBuff, pwdBuffLen, 1, keyBuff, ivBuff);
- # in line 129 of common_crypto_sim.c of original scripts
- digest_round_1 = HashCrypto.calculate_md5_hash(passphrase)
- aes_key = digest_round_1
- aes_iv = HashCrypto.calculate_md5_hash(digest_round_1 + passphrase)
- return aes_key, aes_iv
-
- @staticmethod
- def encrypt_asset_with_aes_cbc(input_filename, output_filename, enc_password_filename, logger=None):
- aes_key, aes_iv = Common.derive_aes_key(enc_password_filename, logger)
-
- # encrypt asset with the derived key
- try:
- with open(input_filename, "rb") as asset_file:
- unencrypted_data = asset_file.read()
- except OSError as e:
- if logger is not None:
- logger.warning("Could not open asset file %s" % input_filename)
- raise ValueError("Could not open asset file: %s" % e)
- # add pkcs7 padding
- pkcs7_padder = sym_padding.PKCS7(128).padder()
- padded_unencrypted_data = pkcs7_padder.update(unencrypted_data)
- padded_unencrypted_data += pkcs7_padder.finalize()
- # encrypt
- encrypted_data = AesCrypto.encrypt_aes_cbc(padded_unencrypted_data, aes_key, aes_iv)
-
- # write encrypted key to output file
- with open(output_filename, "wb") as encrypted_outfile:
- encrypted_outfile.write(encrypted_data)
-
- @staticmethod
- def decrypt_asset_with_aes_cbc(ciphertext, password_filename, logger=None):
- aes_key, aes_iv = Common.derive_aes_key(password_filename, logger)
- decrypted_data_padded = AesCrypto.decrypt_aes_cbc(ciphertext, aes_key, aes_iv)
- # remove padding
- pkcs7_unpadder = sym_padding.PKCS7(128).unpadder()
- decrypted_data = pkcs7_unpadder.update(decrypted_data_padded)
- decrypted_data += pkcs7_unpadder.finalize()
- return decrypted_data
+# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
+#
+
+import getpass
+
+import cryptography.exceptions
+from cryptography.hazmat.primitives.serialization import load_pem_public_key, load_pem_private_key
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import padding as sym_padding
+from cryptography.hazmat.primitives.asymmetric import rsa
+from cryptography.hazmat.primitives import hashes, serialization, cmac
+from cryptography.hazmat.primitives.asymmetric import padding, utils
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes, aead
+
+from utils.common import global_defines
+from utils.common.exceptions import RsaKeyLoadingError
+
+
+class RsaCrypto:
+ @staticmethod
+ def generate_rsa_pem_key(pem_filename, password_filename=None, logger=None):
+ if password_filename is not None:
+ try:
+ with open(password_filename, "r") as pwd_file:
+ passphrase = pwd_file.read()
+ passphrase = passphrase.strip().encode("utf-8")
+ except OSError as e:
+ if logger is not None:
+ logger.warning("Could not open passphrase file %s" % password_filename)
+ raise ValueError("Could not open passphrase file: %s" % e)
+ else:
+ passphrase = getpass.getpass(prompt="Enter passphrase for creating RSA key <<" + pem_filename + ">>: ").encode("utf-8")
+ private_key = rsa.generate_private_key(public_exponent=65537, key_size=3072, backend=default_backend())
+ serialized_pem_key = private_key.private_bytes(
+ encoding=serialization.Encoding.PEM,
+ format=serialization.PrivateFormat.PKCS8,
+ encryption_algorithm=serialization.BestAvailableEncryption(passphrase)
+ )
+ with open(pem_filename, "wb") as output_file:
+ output_file.write(serialized_pem_key)
+ if logger is not None:
+ logger.info("Private key written to: %s" % pem_filename)
+
+ return private_key
+
+ @staticmethod
+ def extract_public_rsa_pem_key(private_key, public_pem_filename, logger=None):
+ public_key = private_key.public_key()
+ serialized_public_key = public_key.public_bytes(encoding=serialization.Encoding.PEM,
+ format=serialization.PublicFormat.SubjectPublicKeyInfo)
+
+ with open(public_pem_filename, "wb") as output_file:
+ output_file.write(serialized_public_key)
+ if logger is not None:
+ logger.info("Public key written to: %s" % public_pem_filename)
+
+ @staticmethod
+ def load_rsa_pem_key(pem_filename, is_key_private, keypair_passphrase_filename=None, logger=None):
+ """
+ Loads RSA private/public key encoded in PEM format
+
+ :param pem_filename: input file in PEM format
+ :param is_key_private: True for private keys, False for public keys
+ :param keypair_passphrase_filename: filename containing passphrase for private key, left out in for public keys
+ :param logger: initialized logging.logger instance
+ :return: instance of RSAPublicKey/RSAPrivateKey depending on is_key_private
+
+ Raises RsaKeyLoadingError in case of failure.
+ """
+ # opening PEM file
+ try:
+ with open(pem_filename) as key_file:
+ pem_data = key_file.read()
+ except OSError as e:
+ if logger is not None:
+ logger.warning("Could not open RSA key file %s" % pem_filename)
+ raise RsaKeyLoadingError("Could not open RSA key file: %s" % e)
+ # loading passphrase for private keys
+ if is_key_private is True:
+ if len(keypair_passphrase_filename) > 0:
+ try:
+ with open(keypair_passphrase_filename, "r") as pwd_file:
+ passphrase = pwd_file.read()
+ passphrase = passphrase.strip().encode("utf-8")
+ except OSError as e:
+ if logger is not None:
+ logger.warning("Could not open keypair passphrase file %s" % keypair_passphrase_filename)
+ raise RsaKeyLoadingError("Could not open keypair passphrase file: %s" % e)
+ else:
+ passphrase = getpass.getpass(prompt="Enter passphrase for RSA private key: ").encode("utf-8")
+ # loading public/private key
+ try:
+ if is_key_private is True: # private key case
+ key = load_pem_private_key(bytes(pem_data, encoding="utf-8"), passphrase, backend=default_backend())
+ # check return value
+ if isinstance(key, rsa.RSAPrivateKey) is False:
+ if logger is not None:
+ logger.warning("Could not parse key as an RSA Private key from file %s" % pem_filename)
+ raise RsaKeyLoadingError("Could not parse PEM file as an RSAPrivateKey")
+ else: # public key case
+ key = load_pem_public_key(bytes(pem_data, encoding="utf-8"), backend=default_backend())
+ # check return value
+ if isinstance(key, rsa.RSAPublicKey) is False:
+ if logger is not None:
+ logger.warning("Could not parse key as an RSA Public key from file %s" % pem_filename)
+ raise RsaKeyLoadingError("Could not parse PEM file as an RSAPublicKey")
+ except ValueError or cryptography.exceptions.UnsupportedAlgorithm as e:
+ # look for internal errors
+ if logger is not None:
+ logger.warning("Could not read RSA key from file %s" % pem_filename)
+ raise RsaKeyLoadingError("Could load RSA key: %s" % e)
+ else:
+ return key
+
+ @staticmethod
+ def get_n_from_rsa_pem_private_key(rsa_key):
+ """
+ Get modulus (N) from RSA Private key
+
+ :param rsa_key: instance of rsa.RSAPrivateKey
+ :return: modulus (N) of the given key object
+ """
+ return rsa_key.public_key().public_numbers().n
+
+ @staticmethod
+ def get_n_from_rsa_pem_public_key(rsa_key):
+ """
+ Get modulus (N) from RSA Public key
+
+ :param rsa_key: instance of rsa.RSAPublicKey
+ :return: modulus (N) of the given key object
+ """
+ return rsa_key.public_numbers().n
+
+ @staticmethod
+ def calculate_np_from_n(n_as_modulus, logger=None):
+ if not isinstance(n_as_modulus, int):
+ if logger is not None:
+ logger.warning("input parameter n_as_modulus expected to be integer")
+ raise TypeError("input parameter n_as_modulus expected to be integer")
+ param_np = (2 ** global_defines.SNP) // n_as_modulus
+ return param_np
+
+ @staticmethod
+ def concatenate_n_and_np(n_as_modulus, param_np, logger=None):
+ if not isinstance(n_as_modulus, int):
+ if logger is not None:
+ logger.warning("input parameter n_as_modulus expected to be integer")
+ raise TypeError("input parameter n_as_modulus expected to be integer")
+ if not isinstance(param_np, int):
+ if logger is not None:
+ logger.warning("input parameter param_np expected to be integer")
+ raise TypeError("input parameter param_np expected to be integer")
+ n_in_bytes = n_as_modulus.to_bytes(global_defines.SB_CERT_RSA_KEY_SIZE_IN_BYTES, 'big')
+ np_in_bytes = param_np.to_bytes(global_defines.NP_SIZE_IN_BYTES, 'big')
+ n_and_np_in_bytes = n_in_bytes + np_in_bytes
+ return n_and_np_in_bytes
+
+ @staticmethod
+ def sign_pkcs_v21(prehashed_data_to_sign, rsa_key, logger=None):
+ signature = rsa_key.sign(prehashed_data_to_sign,
+ padding.PSS(mgf=padding.MGF1(hashes.SHA256()),
+ salt_length=global_defines.RSA_SALT_LEN
+ ),
+ utils.Prehashed(hashes.SHA256()))
+ return signature
+
+ @staticmethod
+ def verify_signature_pkcs_v21(signature, prehashed_message, public_key, logger=None):
+ """
+ Verifies signature on prehashed message. Raises InvalidSignature if it does not match.
+ """
+ public_key.verify(signature,
+ prehashed_message,
+ padding.PSS(mgf=padding.MGF1(hashes.SHA256()),
+ salt_length=global_defines.RSA_SALT_LEN
+ ),
+ utils.Prehashed(hashes.SHA256()))
+
+ @staticmethod
+ def decrypt_oaep(ciphertext, private_key):
+ decrypted_text = private_key.decrypt(
+ ciphertext,
+ padding.OAEP(
+ mgf=padding.MGF1(algorithm=hashes.SHA256()),
+ algorithm=hashes.SHA256(),
+ label=None
+ )
+ )
+ return decrypted_text
+
+ @staticmethod
+ def encrypt_oaep(message, public_key):
+ ciphertext = public_key.encrypt(
+ message,
+ padding.OAEP(
+ mgf=padding.MGF1(algorithm=hashes.SHA256()),
+ algorithm=hashes.SHA256(),
+ label=None
+ )
+ )
+ return ciphertext
+
+ @staticmethod
+ def load_rsa_public_key_from_n(n_as_modulus):
+ # todo: check for param type is integer
+ rsa_params = rsa.RSAPublicNumbers(65537, n_as_modulus)
+ return rsa_params.public_key(default_backend())
+
+
+class HashCrypto:
+ @staticmethod
+ def calculate_sha256_hash(input_bytes):
+ hash_function = hashes.Hash(hashes.SHA256(), backend=default_backend())
+ hash_function.update(input_bytes)
+ message_digest = hash_function.finalize()
+ return message_digest
+
+ @staticmethod
+ def calculate_md5_hash(input_bytes):
+ hash_function = hashes.Hash(hashes.MD5(), backend=default_backend())
+ hash_function.update(input_bytes)
+ message_digest = hash_function.finalize()
+ return message_digest
+
+
+class AesCrypto:
+ @staticmethod
+ def encrypt_aes_ctr(message, aes_key, iv):
+ """
+ :param message: message as bytes object
+ :param aes_key: bytes-like aes key used for encryption
+ :param iv: bytes-like initialization vector
+ :return: ciphertext
+ """
+ aes_cipher = Cipher(algorithms.AES(aes_key), modes.CTR(iv), backend=default_backend())
+ aes_encryptor = aes_cipher.encryptor()
+ ciphertext = aes_encryptor.update(message) + aes_encryptor.finalize()
+ return ciphertext
+
+ @staticmethod
+ def encrypt_aes_cbc(message, aes_key, aes_iv):
+ """
+ :param message: message as bytes object
+ :param aes_key: bytes-like aes key used for encryption
+ :param aes_iv: bytes-like initialization vector
+ :return: ciphertext
+ """
+ aes_cipher = Cipher(algorithms.AES(aes_key), modes.CBC(aes_iv), backend=default_backend())
+ aes_encryptor = aes_cipher.encryptor()
+ ciphertext = aes_encryptor.update(message) + aes_encryptor.finalize()
+ return ciphertext
+
+ @staticmethod
+ def decrypt_aes_cbc(ciphertext, aes_key, aes_iv):
+ aes_cipher = Cipher(algorithms.AES(aes_key), modes.CBC(aes_iv), backend=default_backend())
+ aes_decryptor = aes_cipher.decryptor()
+ return aes_decryptor.update(ciphertext) + aes_decryptor.finalize()
+
+ @staticmethod
+ def calc_aes_cmac(message, key):
+ aes_cmac = cmac.CMAC(algorithms.AES(key), backend=default_backend())
+ aes_cmac.update(message)
+ return aes_cmac.finalize()
+
+ @staticmethod
+ def encrypt_aes_ccm(key, nonce, associated_data, message):
+ aes_ccm = aead.AESCCM(key, 16) # tag length = 16 bytes
+ ciphertext = aes_ccm.encrypt(nonce, message, associated_data)
+ return ciphertext
+
+
+class Common:
+ @staticmethod
+ def get_n_and_np_from_public_key(public_key_filename, logger=None):
+ key = RsaCrypto.load_rsa_pem_key(public_key_filename, False, logger=logger)
+ param_n = RsaCrypto.get_n_from_rsa_pem_public_key(key)
+ param_np = RsaCrypto.calculate_np_from_n(param_n, logger)
+ n_and_np_bytes = RsaCrypto.concatenate_n_and_np(param_n, param_np, logger)
+ return n_and_np_bytes
+
+ @staticmethod
+ def get_hashed_n_and_np_from_public_key(public_key_filename, logger=None):
+ n_and_np_bytes = Common.get_n_and_np_from_public_key(public_key_filename, logger)
+ digest = HashCrypto.calculate_sha256_hash(n_and_np_bytes)
+ return digest
+
+ @staticmethod
+ def get_n_and_np_from_keypair(keypair_filename, keypair_passphrase_file, logger=None):
+ key = RsaCrypto.load_rsa_pem_key(keypair_filename, True, keypair_passphrase_file, logger=logger)
+ param_n = RsaCrypto.get_n_from_rsa_pem_private_key(key)
+ param_np = RsaCrypto.calculate_np_from_n(param_n, logger)
+ n_and_np_bytes = RsaCrypto.concatenate_n_and_np(param_n, param_np, logger)
+ return n_and_np_bytes
+
+ @staticmethod
+ def rsa_sign(data_to_sign, keypair_filename, keypair_passphrase_file, logger=None):
+ key = RsaCrypto.load_rsa_pem_key(keypair_filename, True, keypair_passphrase_file, logger=logger)
+ hashed_data_to_sign = HashCrypto.calculate_sha256_hash(data_to_sign)
+ signature = RsaCrypto.sign_pkcs_v21(hashed_data_to_sign, key, logger)
+ RsaCrypto.verify_signature_pkcs_v21(signature, hashed_data_to_sign, key.public_key(), logger)
+ return signature
+
+ @staticmethod
+ def rsa_verify_with_pubkey_params(rsa_pubkey_n, signed_data, signature, logger=None):
+ modulus_in_bytes = rsa_pubkey_n[0:global_defines.PUBKEY_SIZE_BYTES] # chop of np is input contains it
+ modulus = int.from_bytes(modulus_in_bytes, "big")
+ public_key = RsaCrypto.load_rsa_public_key_from_n(modulus)
+ hashed_data_to_sign = HashCrypto.calculate_sha256_hash(signed_data)
+ RsaCrypto.verify_signature_pkcs_v21(signature, hashed_data_to_sign, public_key, logger)
+
+ @staticmethod
+ def decrypt_data_with_rsa_keypair(keypair_filename, keypair_passphrase_file, ciphertext, logger=None):
+ private_key = RsaCrypto.load_rsa_pem_key(keypair_filename, True, keypair_passphrase_file, logger=logger)
+ message = RsaCrypto.decrypt_oaep(ciphertext, private_key)
+ return message
+
+ @staticmethod
+ def encrypt_data_with_rsa_pubkey_params(rsa_pubkey_n_and_np, input_data):
+ modulus_in_bytes = rsa_pubkey_n_and_np[0:global_defines.PUBKEY_SIZE_BYTES]
+ modulus = int.from_bytes(modulus_in_bytes, "big")
+ public_key = RsaCrypto.load_rsa_public_key_from_n(modulus)
+ ciphertext = RsaCrypto.encrypt_oaep(input_data, public_key)
+ return ciphertext
+
+ @staticmethod
+ def encrypt_file_with_aes_ctr(input_filename, output_filename, key_int_array, aes_iv, hash_type, logger=None):
+ """
+ Encrypts image and calculates SHA256 hash on it
+ :param input_filename: filename of image to be encrypted
+ :param output_filename: filename of encrypted image
+ :param key_int_array: bytes of aes key in a list
+ :param aes_iv: initialization vector
+ :param hash_type: 0 for hash calculated on plain image, 1 for hash on encrypted image
+ :param logger:
+ :return: returns the hash digest and the image size in a tuple
+ """
+ with open(input_filename, "rb") as input_file:
+ plaintext = input_file.read()
+ image_actual_size = len(plaintext)
+ if image_actual_size == 0 or image_actual_size % 4 != 0:
+ raise ValueError("invalid images size")
+ ciphertext = AesCrypto.encrypt_aes_ctr(plaintext, bytes(key_int_array), aes_iv)
+ with open(output_filename, "wb") as output_file:
+ output_file.write(ciphertext)
+ if hash_type == 0:
+ hash_digest = HashCrypto.calculate_sha256_hash(plaintext)
+ elif hash_type == 1:
+ hash_digest = HashCrypto.calculate_sha256_hash(ciphertext)
+ else:
+ raise ValueError("Invalid input value for hash_type (crypto_type)")
+ return hash_digest, image_actual_size
+
+ @staticmethod
+ def derive_aes_key(enc_password_filename, logger=None):
+ # get passphrase
+ if len(enc_password_filename) > 0:
+ try:
+ with open(enc_password_filename, "r") as pwd_file:
+ passphrase = pwd_file.read()
+ passphrase = passphrase.strip().encode("utf-8")
+ except OSError as e:
+ if logger is not None:
+ logger.warning("Could not open passphrase file %s" % enc_password_filename)
+ raise ValueError("Could not open passphrase file: %s" % e)
+ else:
+ passphrase = getpass.getpass(prompt="Enter passphrase for encrypted key: ").encode("utf-8")
+
+ # PBDF1 key and iv derivation with 1 round, no salt, MD5 hash for compatibility reasons:
+ # "openssl enc -e -nosalt -md md5 -aes-128-cbc -in -out -pass file:"
+ # and also with EVP_BytesToKey(cipher, dgst, NULL, (uint8_t *) pwdBuff, pwdBuffLen, 1, keyBuff, ivBuff);
+ # in line 129 of common_crypto_sim.c of original scripts
+ digest_round_1 = HashCrypto.calculate_md5_hash(passphrase)
+ aes_key = digest_round_1
+ aes_iv = HashCrypto.calculate_md5_hash(digest_round_1 + passphrase)
+ return aes_key, aes_iv
+
+ @staticmethod
+ def encrypt_asset_with_aes_cbc(input_filename, output_filename, enc_password_filename, logger=None):
+ aes_key, aes_iv = Common.derive_aes_key(enc_password_filename, logger)
+
+ # encrypt asset with the derived key
+ try:
+ with open(input_filename, "rb") as asset_file:
+ unencrypted_data = asset_file.read()
+ except OSError as e:
+ if logger is not None:
+ logger.warning("Could not open asset file %s" % input_filename)
+ raise ValueError("Could not open asset file: %s" % e)
+ # add pkcs7 padding
+ pkcs7_padder = sym_padding.PKCS7(128).padder()
+ padded_unencrypted_data = pkcs7_padder.update(unencrypted_data)
+ padded_unencrypted_data += pkcs7_padder.finalize()
+ # encrypt
+ encrypted_data = AesCrypto.encrypt_aes_cbc(padded_unencrypted_data, aes_key, aes_iv)
+
+ # write encrypted key to output file
+ with open(output_filename, "wb") as encrypted_outfile:
+ encrypted_outfile.write(encrypted_data)
+
+ @staticmethod
+ def decrypt_asset_with_aes_cbc(ciphertext, password_filename, logger=None):
+ aes_key, aes_iv = Common.derive_aes_key(password_filename, logger)
+ decrypted_data_padded = AesCrypto.decrypt_aes_cbc(ciphertext, aes_key, aes_iv)
+ # remove padding
+ pkcs7_unpadder = sym_padding.PKCS7(128).unpadder()
+ decrypted_data = pkcs7_unpadder.update(decrypted_data_padded)
+ decrypted_data += pkcs7_unpadder.finalize()
+ return decrypted_data
diff --git a/tools/alif/utils/common/exceptions.py b/tools/alif/utils/common/exceptions.py
index b9786e524..3d8491265 100755
--- a/tools/alif/utils/common/exceptions.py
+++ b/tools/alif/utils/common/exceptions.py
@@ -1,19 +1,19 @@
-# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
-#
-
-
-class RsaKeyLoadingError(Exception):
- """Raised when the function cannot load an Rsa key from a PEM file"""
- pass
-
-
-class ConfigParsingError(Exception):
- """Raised when trying to load a misconfigured CFG file"""
- pass
-
-
-class CertCreationError(Exception):
- """Raised when certificate creation fails"""
- pass
+# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
+#
+
+
+class RsaKeyLoadingError(Exception):
+ """Raised when the function cannot load an Rsa key from a PEM file"""
+ pass
+
+
+class ConfigParsingError(Exception):
+ """Raised when trying to load a misconfigured CFG file"""
+ pass
+
+
+class CertCreationError(Exception):
+ """Raised when certificate creation fails"""
+ pass
diff --git a/tools/alif/utils/common/flags_global_defines.py b/tools/alif/utils/common/flags_global_defines.py
index 756093edd..dc5f553c4 100755
--- a/tools/alif/utils/common/flags_global_defines.py
+++ b/tools/alif/utils/common/flags_global_defines.py
@@ -1,40 +1,40 @@
-####################################################################
-#
-# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
-#
-
-
-# Definition for RSA Np or H usage
-# ================================
-# This flag is set to 1 for Np usage in case H should be used set it to 0
-RSA_ALG_USE_Np = 1
-
-# This definition is for the secondary HASH of public key calculation. The calculation is done according to the
-# calculation of HASH of public key (as saved in the OTP) and is set according to platform type
-OTP_HASH_CALC_ON_N_AND_NP = 0
-OTP_HASH_CALC_ON_N = 1
-OTP_HASH_ON_E_AND_N = 2
-
-# This definition should be set according to platform and project
-SECONDARY_KEY_HASH_CALC = OTP_HASH_CALC_ON_N_AND_NP
-
-# Definitions for specific projects, should be set to 0 if no additional data is required
-SPECIAL_ADDITIONAL_DATA_USED = 1
-
-# Content certificate flag word definition
-# =========================================
-CODE_ENCRYPTION_SUPPORT_BIT_POS = 4
-
-LOAD_VERIFY_SCHEME_BIT_POS = 8
-
-CRYPTO_TYPE_BIT_POS = 12
-
-# Bit positions of signature offset and number of s/w components
-# ================================================================
-NUM_OF_SW_COMPS_BIT_POS = 16
-
-SIGNATURE_OFFSET_BIT_POS = 0
-
-
+####################################################################
+#
+# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
+#
+
+
+# Definition for RSA Np or H usage
+# ================================
+# This flag is set to 1 for Np usage in case H should be used set it to 0
+RSA_ALG_USE_Np = 1
+
+# This definition is for the secondary HASH of public key calculation. The calculation is done according to the
+# calculation of HASH of public key (as saved in the OTP) and is set according to platform type
+OTP_HASH_CALC_ON_N_AND_NP = 0
+OTP_HASH_CALC_ON_N = 1
+OTP_HASH_ON_E_AND_N = 2
+
+# This definition should be set according to platform and project
+SECONDARY_KEY_HASH_CALC = OTP_HASH_CALC_ON_N_AND_NP
+
+# Definitions for specific projects, should be set to 0 if no additional data is required
+SPECIAL_ADDITIONAL_DATA_USED = 1
+
+# Content certificate flag word definition
+# =========================================
+CODE_ENCRYPTION_SUPPORT_BIT_POS = 4
+
+LOAD_VERIFY_SCHEME_BIT_POS = 8
+
+CRYPTO_TYPE_BIT_POS = 12
+
+# Bit positions of signature offset and number of s/w components
+# ================================================================
+NUM_OF_SW_COMPS_BIT_POS = 16
+
+SIGNATURE_OFFSET_BIT_POS = 0
+
+
diff --git a/tools/alif/utils/common/global_defines.py b/tools/alif/utils/common/global_defines.py
index 69a1df07a..5d93fac28 100755
--- a/tools/alif/utils/common/global_defines.py
+++ b/tools/alif/utils/common/global_defines.py
@@ -1,124 +1,124 @@
-# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
-#
-
-BITS_WITHIN_WORD = 32
-
-# Definition of number of bits in a byte.
-CC_BITS_IN_BYTE = 8
-# Definition of number of bits in a 32-bits word.
-CC_BITS_IN_32BIT_WORD = 32
-# The size of the PKA engine word.
-CC_PKA_WORD_SIZE_IN_BITS = 64
-# The maximal supported size of modulus in bits.
-C_SRP_MAX_MODULUS_SIZE_IN_BITS = 3072
-# The maximal supported size of modulus in RSA in bits.
-CC_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS = 4096
-# The maximal supported size of key-generation in RSA in bits.
-CC_RSA_MAX_KEY_GENERATION_HW_SIZE_BITS = 3072
-# The maximal supported size of modulus in RSA in words.
-CC_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_WORDS = CC_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS / CC_BITS_IN_32BIT_WORD
-
-# The size of the RSA public modulus key of the Secure Boot or Secure Debug certificate in bits.
-SB_CERT_RSA_KEY_SIZE_IN_BITS = 3072
-# The size of the RSA public modulus key of the Secure Boot or Secure Debug certificate in bytes.
-SB_CERT_RSA_KEY_SIZE_IN_BYTES = int(SB_CERT_RSA_KEY_SIZE_IN_BITS / CC_BITS_IN_BYTE)
-# The size of the RSA public modulus key of the Secure Boot or Secure Debug certificate in words.
-SB_CERT_RSA_KEY_SIZE_IN_WORDS = SB_CERT_RSA_KEY_SIZE_IN_BITS / CC_BITS_IN_32BIT_WORD
-
-# The maximal count of extra bits in PKA operations.
-PKA_EXTRA_BITS = 8
-# The number of memory registers in PKA operations.
-PKA_MAX_COUNT_OF_PHYS_MEM_REGS = 32
-
-# Global defines from common_rsa_keypair
-RSA_PRIVATE_KEY_SIZE = SB_CERT_RSA_KEY_SIZE_IN_BITS
-NP_SIZE_IN_BYTES = 20
-NEW_PKA_WORD_SIZE_BITS = CC_PKA_WORD_SIZE_IN_BITS
-NEW_PAK_ADDITIONAL_BITS = 8
-SNP = SB_CERT_RSA_KEY_SIZE_IN_BITS + NEW_PKA_WORD_SIZE_BITS + NEW_PAK_ADDITIONAL_BITS - 1
-
-HASH_SHA256_DIGEST_SIZE_IN_BYTES = 32
-
-# Definitions for sw version legal values -
-#########################################
-SW_REVOCATION_MAX_NUM_OF_BITS_HBK0 = 64
-SW_REVOCATION_MAX_NUM_OF_BITS_HBK1 = 96
-SW_REVOCATION_MAX_NUM_OF_BITS_HBK2 = 160
-
-RSA_SALT_LEN = 32
-
-BYTES_WITHIN_WORD = 4
-PUBKEY_SIZE_BYTES = 384 #256 aligned with SB_CERT_RSA_KEY_SIZE_IN_BITS defined in cc_pka_hw_plat_defs.h
-PUBKEY_SIZE_WORDS = (PUBKEY_SIZE_BYTES//BYTES_WITHIN_WORD)
-NP_SIZE_IN_WORDS = (NP_SIZE_IN_BYTES//BYTES_WITHIN_WORD)
-SHA_256_HASH_SIZE_IN_BYTES = 32
-RSA_SIGNATURE_SIZE_BYTES = 384 #256 aligned with SB_CERT_RSA_KEY_SIZE_IN_BITS defined in cc_pka_hw_plat_defs.h
-
-CC_MNG_CHIP_MANUFACTURE_LCS = 0x0
-CC_MNG_DEVICE_MANUFACTURE_LCS = 0x1
-CC_MNG_SECURE_LCS = 0x5
-CC_MNG_RMA_LCS = 0x7
-
-# E value, in a string mode. for the HASh calculation
-E_VALUE_REVERSED = "00010001"
-# Memory unload flag
-MEM_ADDRESS_UNLOAD_FLAG = 0xFFFFFFFF
-
-RSA_SIGNATURE_SIZE_IN_BYTES = 384
-RSA_SIGNATURE_SIZE_IN_DOUBLE_BYTES = 768
-RSA_SIGNATURE_SIZE_IN_WORDS = 96
-# HASH size in SHA256 in bytes
-HASH_ALGORITHM_SHA256_SIZE_IN_WORDS = (SHA_256_HASH_SIZE_IN_BYTES//BYTES_WITHIN_WORD)
-
-# H size
-RSA_H_SIZE_IN_BYTES = RSA_SIGNATURE_SIZE_IN_BYTES
-RSA_H_SIZE_IN_WORDS = (RSA_SIGNATURE_SIZE_IN_BYTES//BYTES_WITHIN_WORD)
-
-# Size of SW versions
-SW_VERSION_OBJ_SIZE_IN_WORDS = 1
-
-# header size in bytes
-HEADER_SIZE_IN_WORDS = 4
-HEADER_SIZE_IN_BYTES = (HEADER_SIZE_IN_WORDS * BYTES_WITHIN_WORD)
-#size number of bytes in address
-NUM_OF_BYTES_IN_ADDRESS = 4
-
-SOC_ID_SIZE_IN_BYTES = 32
-
-#enabler certificate flag offset
-HBK_ID_FLAG_BIT_OFFSET = 0
-LCS_ID_FLAG_BIT_OFFSET = 4
-RMA_CERT_FLAG_BIT_OFFSET = 8
-
-
-# HASH output representation
-HASH_BINARY_REPRESENTATION = 1
-HASH_HEX_REPRESENTATION = 2
-
-
-# certificate output file prefix
-Cert_FileName = "Cert"
-# certificate output file suffix
-Cert_FileExtBin = ".bin"
-Cert_FileExtTxt = ".txt"
-
-# definitions for code encryption
-AES_IV_SIZE_IN_BYTES = 16
-AES_DECRYPT_KEY_SIZE_IN_BYTES = 16
-SW_COMP_FILE_NAME_POSTFIX = "_enc.bin"
-
-NONCE_SIZE_IN_WORDS = 2
-MAX_NUM_OF_IMAGES = 16
-
-SW_REC_ADDR32_SIGNED_DATA_SIZE_IN_WORDS = 3
-
-USE_AES_CE_ID_NONE = 0
-USE_AES_CE_ID_KCEICV = 1
-USE_AES_CE_ID_KCE = 2
-
-LOAD_AND_VERIFY_IMAGE = 0
-VERIFY_IMAGE_IN_FLASH = 1
-VERIFY_IMAGE_IN_MEM = 2
-LOADING_ONLY_IMAGE = 3
+# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
+#
+
+BITS_WITHIN_WORD = 32
+
+# Definition of number of bits in a byte.
+CC_BITS_IN_BYTE = 8
+# Definition of number of bits in a 32-bits word.
+CC_BITS_IN_32BIT_WORD = 32
+# The size of the PKA engine word.
+CC_PKA_WORD_SIZE_IN_BITS = 64
+# The maximal supported size of modulus in bits.
+C_SRP_MAX_MODULUS_SIZE_IN_BITS = 3072
+# The maximal supported size of modulus in RSA in bits.
+CC_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS = 4096
+# The maximal supported size of key-generation in RSA in bits.
+CC_RSA_MAX_KEY_GENERATION_HW_SIZE_BITS = 3072
+# The maximal supported size of modulus in RSA in words.
+CC_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_WORDS = CC_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS / CC_BITS_IN_32BIT_WORD
+
+# The size of the RSA public modulus key of the Secure Boot or Secure Debug certificate in bits.
+SB_CERT_RSA_KEY_SIZE_IN_BITS = 3072
+# The size of the RSA public modulus key of the Secure Boot or Secure Debug certificate in bytes.
+SB_CERT_RSA_KEY_SIZE_IN_BYTES = int(SB_CERT_RSA_KEY_SIZE_IN_BITS / CC_BITS_IN_BYTE)
+# The size of the RSA public modulus key of the Secure Boot or Secure Debug certificate in words.
+SB_CERT_RSA_KEY_SIZE_IN_WORDS = SB_CERT_RSA_KEY_SIZE_IN_BITS / CC_BITS_IN_32BIT_WORD
+
+# The maximal count of extra bits in PKA operations.
+PKA_EXTRA_BITS = 8
+# The number of memory registers in PKA operations.
+PKA_MAX_COUNT_OF_PHYS_MEM_REGS = 32
+
+# Global defines from common_rsa_keypair
+RSA_PRIVATE_KEY_SIZE = SB_CERT_RSA_KEY_SIZE_IN_BITS
+NP_SIZE_IN_BYTES = 20
+NEW_PKA_WORD_SIZE_BITS = CC_PKA_WORD_SIZE_IN_BITS
+NEW_PAK_ADDITIONAL_BITS = 8
+SNP = SB_CERT_RSA_KEY_SIZE_IN_BITS + NEW_PKA_WORD_SIZE_BITS + NEW_PAK_ADDITIONAL_BITS - 1
+
+HASH_SHA256_DIGEST_SIZE_IN_BYTES = 32
+
+# Definitions for sw version legal values -
+#########################################
+SW_REVOCATION_MAX_NUM_OF_BITS_HBK0 = 64
+SW_REVOCATION_MAX_NUM_OF_BITS_HBK1 = 96
+SW_REVOCATION_MAX_NUM_OF_BITS_HBK2 = 160
+
+RSA_SALT_LEN = 32
+
+BYTES_WITHIN_WORD = 4
+PUBKEY_SIZE_BYTES = 384 #256 aligned with SB_CERT_RSA_KEY_SIZE_IN_BITS defined in cc_pka_hw_plat_defs.h
+PUBKEY_SIZE_WORDS = (PUBKEY_SIZE_BYTES//BYTES_WITHIN_WORD)
+NP_SIZE_IN_WORDS = (NP_SIZE_IN_BYTES//BYTES_WITHIN_WORD)
+SHA_256_HASH_SIZE_IN_BYTES = 32
+RSA_SIGNATURE_SIZE_BYTES = 384 #256 aligned with SB_CERT_RSA_KEY_SIZE_IN_BITS defined in cc_pka_hw_plat_defs.h
+
+CC_MNG_CHIP_MANUFACTURE_LCS = 0x0
+CC_MNG_DEVICE_MANUFACTURE_LCS = 0x1
+CC_MNG_SECURE_LCS = 0x5
+CC_MNG_RMA_LCS = 0x7
+
+# E value, in a string mode. for the HASh calculation
+E_VALUE_REVERSED = "00010001"
+# Memory unload flag
+MEM_ADDRESS_UNLOAD_FLAG = 0xFFFFFFFF
+
+RSA_SIGNATURE_SIZE_IN_BYTES = 384
+RSA_SIGNATURE_SIZE_IN_DOUBLE_BYTES = 768
+RSA_SIGNATURE_SIZE_IN_WORDS = 96
+# HASH size in SHA256 in bytes
+HASH_ALGORITHM_SHA256_SIZE_IN_WORDS = (SHA_256_HASH_SIZE_IN_BYTES//BYTES_WITHIN_WORD)
+
+# H size
+RSA_H_SIZE_IN_BYTES = RSA_SIGNATURE_SIZE_IN_BYTES
+RSA_H_SIZE_IN_WORDS = (RSA_SIGNATURE_SIZE_IN_BYTES//BYTES_WITHIN_WORD)
+
+# Size of SW versions
+SW_VERSION_OBJ_SIZE_IN_WORDS = 1
+
+# header size in bytes
+HEADER_SIZE_IN_WORDS = 4
+HEADER_SIZE_IN_BYTES = (HEADER_SIZE_IN_WORDS * BYTES_WITHIN_WORD)
+#size number of bytes in address
+NUM_OF_BYTES_IN_ADDRESS = 4
+
+SOC_ID_SIZE_IN_BYTES = 32
+
+#enabler certificate flag offset
+HBK_ID_FLAG_BIT_OFFSET = 0
+LCS_ID_FLAG_BIT_OFFSET = 4
+RMA_CERT_FLAG_BIT_OFFSET = 8
+
+
+# HASH output representation
+HASH_BINARY_REPRESENTATION = 1
+HASH_HEX_REPRESENTATION = 2
+
+
+# certificate output file prefix
+Cert_FileName = "Cert"
+# certificate output file suffix
+Cert_FileExtBin = ".bin"
+Cert_FileExtTxt = ".txt"
+
+# definitions for code encryption
+AES_IV_SIZE_IN_BYTES = 16
+AES_DECRYPT_KEY_SIZE_IN_BYTES = 16
+SW_COMP_FILE_NAME_POSTFIX = "_enc.bin"
+
+NONCE_SIZE_IN_WORDS = 2
+MAX_NUM_OF_IMAGES = 16
+
+SW_REC_ADDR32_SIGNED_DATA_SIZE_IN_WORDS = 3
+
+USE_AES_CE_ID_NONE = 0
+USE_AES_CE_ID_KCEICV = 1
+USE_AES_CE_ID_KCE = 2
+
+LOAD_AND_VERIFY_IMAGE = 0
+VERIFY_IMAGE_IN_FLASH = 1
+VERIFY_IMAGE_IN_MEM = 2
+LOADING_ONLY_IMAGE = 3
diff --git a/tools/alif/utils/common/util_logger.py b/tools/alif/utils/common/util_logger.py
index 7789845af..5d07f5ede 100755
--- a/tools/alif/utils/common/util_logger.py
+++ b/tools/alif/utils/common/util_logger.py
@@ -1,39 +1,39 @@
-# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
-#
-
-import sys
-import logging
-
-#from utils.printInfo import *
-
-class UtilLogger:
- def __init__(self, log_filename, utility_name):
- self.log_filename = log_filename
- self.root_logger = logging.getLogger()
- self.log_formatter = logging.Formatter("%(asctime)s - %(message)s")
- self.log_file_handler = logging.FileHandler(self.log_filename)
- self.log_file_handler.setFormatter(self.log_formatter)
- # Added if condition to avoid duplicate meessages or instances
- if not self.root_logger.handlers:
- log_console_handler = logging.StreamHandler(sys.stdout)
- log_console_handler.setFormatter(self.log_formatter)
- self.root_logger.addHandler(log_console_handler)
-
- self.root_logger.addHandler(self.log_file_handler)
- self.root_logger.setLevel(logging.INFO)
- #if verboseModeGet():
- self.root_logger.info(utility_name + " Utility started (Logging to " + self.log_filename + ")")
-
- def info(self, message):
- self.root_logger.info(message)
-
- def warning(self, message):
- self.root_logger.warning(message)
-
- def error(self, message):
- self.root_logger.error(message)
-
- def critical(self, message):
- self.root_logger.critical(message)
+# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
+#
+
+import sys
+import logging
+
+#from utils.printInfo import *
+
+class UtilLogger:
+ def __init__(self, log_filename, utility_name):
+ self.log_filename = log_filename
+ self.root_logger = logging.getLogger()
+ self.log_formatter = logging.Formatter("%(asctime)s - %(message)s")
+ self.log_file_handler = logging.FileHandler(self.log_filename)
+ self.log_file_handler.setFormatter(self.log_formatter)
+ # Added if condition to avoid duplicate meessages or instances
+ if not self.root_logger.handlers:
+ log_console_handler = logging.StreamHandler(sys.stdout)
+ log_console_handler.setFormatter(self.log_formatter)
+ self.root_logger.addHandler(log_console_handler)
+
+ self.root_logger.addHandler(self.log_file_handler)
+ self.root_logger.setLevel(logging.INFO)
+ #if verboseModeGet():
+ self.root_logger.info(utility_name + " Utility started (Logging to " + self.log_filename + ")")
+
+ def info(self, message):
+ self.root_logger.info(message)
+
+ def warning(self, message):
+ self.root_logger.warning(message)
+
+ def error(self, message):
+ self.root_logger.error(message)
+
+ def critical(self, message):
+ self.root_logger.critical(message)
diff --git a/tools/alif/utils/common_cert_lib/contentcertificateconfig.py b/tools/alif/utils/common_cert_lib/contentcertificateconfig.py
index 6a16910c5..8c724ac04 100755
--- a/tools/alif/utils/common_cert_lib/contentcertificateconfig.py
+++ b/tools/alif/utils/common_cert_lib/contentcertificateconfig.py
@@ -1,234 +1,234 @@
-# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
-#
-
-import configparser
-
-from utils.common.util_logger import UtilLogger
-from utils.common.exceptions import ConfigParsingError
-from utils.common import global_defines
-
-from printInfo import *
-
-class ContentCertificateConfig:
- CFG_SECTION_NAME = "CNT-CFG"
-
- def __init__(self, config_filename, app_logger=None):
- """
- Parses the CNT-CFG content certificate cfg file.
- Raises ConfigParsingError when cfg has been written incorrectly.
- Raises TypeError or ValueError when a cfg value is incorrect on its own.
-
- :param str config_filename: name of cfg file to parse
- :param UtilLogger app_logger: instance of the application logger
- """
- self._config_filename = config_filename
- self._logger = app_logger
- self._parser = configparser.ConfigParser()
-
- self._cert_keypair = None
- self._cert_keypair_pwd = None
- self._load_verify_scheme = None
- self._crypto_type = None
- self._aes_ce_id = None
- self._aes_enc_key = None
- self._images_table = None
- self._nvcounter_val = None
- self._cert_pkg = None
- self._parse_config()
-
- @property
- def section_name(self):
- return self.CFG_SECTION_NAME
-
- @property
- def cert_keypair(self):
- return self._cert_keypair
-
- @cert_keypair.setter
- def cert_keypair(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter cert-keypair must be a string")
- elif value == "":
- raise ValueError("Config parameter cert-keypair cannot be an empty string!")
- else:
- self._cert_keypair = value
-
- @property
- def cert_keypair_pwd(self):
- return self._cert_keypair_pwd
-
- @cert_keypair_pwd.setter
- def cert_keypair_pwd(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter cert-keypair-pwd must be a string")
- else:
- self._cert_keypair_pwd = value
-
- @property
- def load_verify_scheme(self):
- return self._load_verify_scheme
-
- @load_verify_scheme.setter
- def load_verify_scheme(self, value):
- if isinstance(value, int) is False:
- raise TypeError("Config parameter load_verify_scheme must be an integer")
- elif value not in [0, 1, 2, 3]:
- raise ValueError("invalid input value for config parameter load_verify_scheme")
- else:
- self._load_verify_scheme = value
-
- @property
- def crypto_type(self):
- return self._crypto_type
-
- @crypto_type.setter
- def crypto_type(self, value):
- if isinstance(value, int) is False:
- raise TypeError("Config parameter crypto_type must be an integer")
- elif value not in [0, 1]:
- raise ValueError("invalid input value for config parameter crypto_type")
- else:
- self._crypto_type = value
-
- @property
- def aes_ce_id(self):
- return self._aes_ce_id
-
- @aes_ce_id.setter
- def aes_ce_id(self, value):
- if isinstance(value, int) is False:
- raise TypeError("Config parameter aes_ce_id must be an integer")
- elif value not in [0, 1, 2]:
- raise ValueError("invalid input value for config parameter aes_ce_id")
- else:
- self._aes_ce_id = value
-
- @property
- def aes_enc_key(self):
- return self._aes_enc_key
-
- @aes_enc_key.setter
- def aes_enc_key(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter aes_enc_key must be a string")
- else:
- self._aes_enc_key = value
-
- @property
- def images_table(self):
- return self._images_table
-
- @images_table.setter
- def images_table(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter images_table must be a string")
- elif value == "":
- raise ValueError("Config parameter images_table cannot be an empty string!")
- else:
- self._images_table = value
-
- @property
- def nvcounter_val(self):
- return self._nvcounter_val
-
- @nvcounter_val.setter
- def nvcounter_val(self, value):
- if isinstance(value, int) is False:
- raise TypeError("Config parameter nvcounter_val must be an integer")
- elif value not in range(global_defines.SW_REVOCATION_MAX_NUM_OF_BITS_HBK2 + 1):
- raise ValueError("invalid input value for config parameter nvcounter_val")
- else:
- self._nvcounter_val = value
-
- @property
- def cert_pkg(self):
- return self._cert_pkg
-
- @cert_pkg.setter
- def cert_pkg(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter cert_pkg must be a string")
- elif value == "":
- raise ValueError("Config parameter cert_pkg cannot be an empty string!")
- else:
- self._cert_pkg = value
-
- def _parse_config(self):
- if self._logger is not None:
- if verboseModeGet():
- self._logger.info("Parsing config file: " + self._config_filename)
- self._parser.read(self._config_filename, encoding='cp1250')
-
- if not self._parser.has_section(self.section_name):
- if self._logger is not None:
- self._logger.error("section [" + self.section_name + "] wasn't found in cfg file")
- raise ConfigParsingError
-
- if not self._parser.has_option(self.section_name, 'cert-keypair'):
- if self._logger is not None:
- self._logger.error("parameter cert-keypair not found in cfg file")
- raise ConfigParsingError
- else:
- self.cert_keypair = self._parser.get(self.section_name, 'cert-keypair')
-
- if self._parser.has_option(self.section_name, 'cert-keypair-pwd'): # used for testing
- self.cert_keypair_pwd = self._parser.get(self.section_name, 'cert-keypair-pwd')
- else:
- self.cert_keypair_pwd = ''
-
- if not self._parser.has_option(self.section_name, 'load-verify-scheme'):
- if self._logger is not None:
- self._logger.error("parameter load-verify-scheme not found in cfg file")
- raise ConfigParsingError
- else:
- self.load_verify_scheme = self._parser.getint(self.section_name, 'load-verify-scheme')
-
- if not self._parser.has_option(self.section_name, 'crypto-type'):
- if self._logger is not None:
- self._logger.error("parameter crypto-type not found in cfg file")
- raise ConfigParsingError
- else:
- self.crypto_type = self._parser.getint(self.section_name, 'crypto-type')
-
- if not self._parser.has_option(self.section_name, 'aes-ce-id'):
- if self._logger is not None:
- self._logger.error("parameter aes-ce-id not found in cfg file")
- raise ConfigParsingError
- else:
- self.aes_ce_id = self._parser.getint(self.section_name, 'aes-ce-id')
-
- if self._parser.has_option(self.section_name, 'aes-enc-key'):
- self.aes_enc_key = self._parser.get(self.section_name, 'aes-enc-key')
- else:
- self.aes_enc_key = ""
-
- if not self._parser.has_option(self.section_name, 'images-table'):
- if self._logger is not None:
- self._logger.error("parameter images-table not found in cfg file")
- raise ConfigParsingError
- else:
- self.images_table = self._parser.get(self.section_name, 'images-table')
-
- if not self._parser.has_option(self.section_name, 'nvcounter-val'):
- if self._logger is not None:
- self._logger.error("parameter nvcounter-val not found in cfg file")
- raise ConfigParsingError
- else:
- self.nvcounter_val = self._parser.getint(self.section_name, 'nvcounter-val')
-
- if not self._parser.has_option(self.section_name, 'cert-pkg'):
- if self._logger is not None:
- self._logger.error("parameter cert_pkg not found in cfg file")
- raise ConfigParsingError
- else:
- self.cert_pkg = self._parser.get(self.section_name, 'cert-pkg')
-
- # SB does not support encrypted images in case of "loading only" and "verify only in flash" modes
- if self.aes_ce_id != global_defines.USE_AES_CE_ID_NONE and (
- self.load_verify_scheme == global_defines.VERIFY_IMAGE_IN_FLASH or
- self.load_verify_scheme == global_defines.LOADING_ONLY_IMAGE):
- if self._logger is not None:
- self._logger.error("invalid parameter combination for aes-ce-id and load-verify-scheme")
- raise ConfigParsingError
+# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
+#
+
+import configparser
+
+from utils.common.util_logger import UtilLogger
+from utils.common.exceptions import ConfigParsingError
+from utils.common import global_defines
+
+from printInfo import *
+
+class ContentCertificateConfig:
+ CFG_SECTION_NAME = "CNT-CFG"
+
+ def __init__(self, config_filename, app_logger=None):
+ """
+ Parses the CNT-CFG content certificate cfg file.
+ Raises ConfigParsingError when cfg has been written incorrectly.
+ Raises TypeError or ValueError when a cfg value is incorrect on its own.
+
+ :param str config_filename: name of cfg file to parse
+ :param UtilLogger app_logger: instance of the application logger
+ """
+ self._config_filename = config_filename
+ self._logger = app_logger
+ self._parser = configparser.ConfigParser()
+
+ self._cert_keypair = None
+ self._cert_keypair_pwd = None
+ self._load_verify_scheme = None
+ self._crypto_type = None
+ self._aes_ce_id = None
+ self._aes_enc_key = None
+ self._images_table = None
+ self._nvcounter_val = None
+ self._cert_pkg = None
+ self._parse_config()
+
+ @property
+ def section_name(self):
+ return self.CFG_SECTION_NAME
+
+ @property
+ def cert_keypair(self):
+ return self._cert_keypair
+
+ @cert_keypair.setter
+ def cert_keypair(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter cert-keypair must be a string")
+ elif value == "":
+ raise ValueError("Config parameter cert-keypair cannot be an empty string!")
+ else:
+ self._cert_keypair = value
+
+ @property
+ def cert_keypair_pwd(self):
+ return self._cert_keypair_pwd
+
+ @cert_keypair_pwd.setter
+ def cert_keypair_pwd(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter cert-keypair-pwd must be a string")
+ else:
+ self._cert_keypair_pwd = value
+
+ @property
+ def load_verify_scheme(self):
+ return self._load_verify_scheme
+
+ @load_verify_scheme.setter
+ def load_verify_scheme(self, value):
+ if isinstance(value, int) is False:
+ raise TypeError("Config parameter load_verify_scheme must be an integer")
+ elif value not in [0, 1, 2, 3]:
+ raise ValueError("invalid input value for config parameter load_verify_scheme")
+ else:
+ self._load_verify_scheme = value
+
+ @property
+ def crypto_type(self):
+ return self._crypto_type
+
+ @crypto_type.setter
+ def crypto_type(self, value):
+ if isinstance(value, int) is False:
+ raise TypeError("Config parameter crypto_type must be an integer")
+ elif value not in [0, 1]:
+ raise ValueError("invalid input value for config parameter crypto_type")
+ else:
+ self._crypto_type = value
+
+ @property
+ def aes_ce_id(self):
+ return self._aes_ce_id
+
+ @aes_ce_id.setter
+ def aes_ce_id(self, value):
+ if isinstance(value, int) is False:
+ raise TypeError("Config parameter aes_ce_id must be an integer")
+ elif value not in [0, 1, 2]:
+ raise ValueError("invalid input value for config parameter aes_ce_id")
+ else:
+ self._aes_ce_id = value
+
+ @property
+ def aes_enc_key(self):
+ return self._aes_enc_key
+
+ @aes_enc_key.setter
+ def aes_enc_key(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter aes_enc_key must be a string")
+ else:
+ self._aes_enc_key = value
+
+ @property
+ def images_table(self):
+ return self._images_table
+
+ @images_table.setter
+ def images_table(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter images_table must be a string")
+ elif value == "":
+ raise ValueError("Config parameter images_table cannot be an empty string!")
+ else:
+ self._images_table = value
+
+ @property
+ def nvcounter_val(self):
+ return self._nvcounter_val
+
+ @nvcounter_val.setter
+ def nvcounter_val(self, value):
+ if isinstance(value, int) is False:
+ raise TypeError("Config parameter nvcounter_val must be an integer")
+ elif value not in range(global_defines.SW_REVOCATION_MAX_NUM_OF_BITS_HBK2 + 1):
+ raise ValueError("invalid input value for config parameter nvcounter_val")
+ else:
+ self._nvcounter_val = value
+
+ @property
+ def cert_pkg(self):
+ return self._cert_pkg
+
+ @cert_pkg.setter
+ def cert_pkg(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter cert_pkg must be a string")
+ elif value == "":
+ raise ValueError("Config parameter cert_pkg cannot be an empty string!")
+ else:
+ self._cert_pkg = value
+
+ def _parse_config(self):
+ if self._logger is not None:
+ if verboseModeGet():
+ self._logger.info("Parsing config file: " + self._config_filename)
+ self._parser.read(self._config_filename, encoding='cp1250')
+
+ if not self._parser.has_section(self.section_name):
+ if self._logger is not None:
+ self._logger.error("section [" + self.section_name + "] wasn't found in cfg file")
+ raise ConfigParsingError
+
+ if not self._parser.has_option(self.section_name, 'cert-keypair'):
+ if self._logger is not None:
+ self._logger.error("parameter cert-keypair not found in cfg file")
+ raise ConfigParsingError
+ else:
+ self.cert_keypair = self._parser.get(self.section_name, 'cert-keypair')
+
+ if self._parser.has_option(self.section_name, 'cert-keypair-pwd'): # used for testing
+ self.cert_keypair_pwd = self._parser.get(self.section_name, 'cert-keypair-pwd')
+ else:
+ self.cert_keypair_pwd = ''
+
+ if not self._parser.has_option(self.section_name, 'load-verify-scheme'):
+ if self._logger is not None:
+ self._logger.error("parameter load-verify-scheme not found in cfg file")
+ raise ConfigParsingError
+ else:
+ self.load_verify_scheme = self._parser.getint(self.section_name, 'load-verify-scheme')
+
+ if not self._parser.has_option(self.section_name, 'crypto-type'):
+ if self._logger is not None:
+ self._logger.error("parameter crypto-type not found in cfg file")
+ raise ConfigParsingError
+ else:
+ self.crypto_type = self._parser.getint(self.section_name, 'crypto-type')
+
+ if not self._parser.has_option(self.section_name, 'aes-ce-id'):
+ if self._logger is not None:
+ self._logger.error("parameter aes-ce-id not found in cfg file")
+ raise ConfigParsingError
+ else:
+ self.aes_ce_id = self._parser.getint(self.section_name, 'aes-ce-id')
+
+ if self._parser.has_option(self.section_name, 'aes-enc-key'):
+ self.aes_enc_key = self._parser.get(self.section_name, 'aes-enc-key')
+ else:
+ self.aes_enc_key = ""
+
+ if not self._parser.has_option(self.section_name, 'images-table'):
+ if self._logger is not None:
+ self._logger.error("parameter images-table not found in cfg file")
+ raise ConfigParsingError
+ else:
+ self.images_table = self._parser.get(self.section_name, 'images-table')
+
+ if not self._parser.has_option(self.section_name, 'nvcounter-val'):
+ if self._logger is not None:
+ self._logger.error("parameter nvcounter-val not found in cfg file")
+ raise ConfigParsingError
+ else:
+ self.nvcounter_val = self._parser.getint(self.section_name, 'nvcounter-val')
+
+ if not self._parser.has_option(self.section_name, 'cert-pkg'):
+ if self._logger is not None:
+ self._logger.error("parameter cert_pkg not found in cfg file")
+ raise ConfigParsingError
+ else:
+ self.cert_pkg = self._parser.get(self.section_name, 'cert-pkg')
+
+ # SB does not support encrypted images in case of "loading only" and "verify only in flash" modes
+ if self.aes_ce_id != global_defines.USE_AES_CE_ID_NONE and (
+ self.load_verify_scheme == global_defines.VERIFY_IMAGE_IN_FLASH or
+ self.load_verify_scheme == global_defines.LOADING_ONLY_IMAGE):
+ if self._logger is not None:
+ self._logger.error("invalid parameter combination for aes-ce-id and load-verify-scheme")
+ raise ConfigParsingError
diff --git a/tools/alif/utils/common_cert_lib/developercertificateconfig.py b/tools/alif/utils/common_cert_lib/developercertificateconfig.py
index 4c6fb55fa..06c353eba 100755
--- a/tools/alif/utils/common_cert_lib/developercertificateconfig.py
+++ b/tools/alif/utils/common_cert_lib/developercertificateconfig.py
@@ -1,173 +1,173 @@
-# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
-#
-
-import configparser
-
-from common.util_logger import UtilLogger
-from common.exceptions import ConfigParsingError
-
-
-class DeveloperDebugCertificateConfig:
- CFG_SECTION_NAME = "DEVELOPER-DBG-CFG"
-
- def __init__(self, config_filename, app_logger=None):
- """
- Parses the DEVELOPER-DBG-CFG developer debug certificate cfg file.
- Raises ConfigParsingError when cfg has been written incorrectly.
- Raises TypeError or ValueError when a cfg value is incorrect on its own.
-
- :param str config_filename: name of cfg file to parse
- :param UtilLogger app_logger: instance of the application logger
- """
- self._config_filename = config_filename
- self._logger = app_logger
- self._parser = configparser.ConfigParser()
-
- self._cert_keypair = None
- self._cert_keypair_pwd = None
- self._soc_id = None
- self._debug_masks = [0, 0, 0, 0]
- self._enabler_cert_pkg = None
- self._cert_pkg = None
- self._parse_config()
-
- @property
- def section_name(self):
- return self.CFG_SECTION_NAME
-
- @property
- def cert_keypair(self):
- return self._cert_keypair
-
- @cert_keypair.setter
- def cert_keypair(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter cert-keypair must be a string")
- elif value == "":
- raise ValueError("Config parameter cert-keypair cannot be an empty string!")
- else:
- self._cert_keypair = value
-
- @property
- def cert_keypair_pwd(self):
- return self._cert_keypair_pwd
-
- @cert_keypair_pwd.setter
- def cert_keypair_pwd(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter cert-keypair-pwd must be a string")
- else:
- self._cert_keypair_pwd = value
-
- @property
- def soc_id(self):
- return self._soc_id
-
- @soc_id.setter
- def soc_id(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter soc_id must be a string")
- else:
- self._soc_id = value
-
- @property
- def debug_masks(self):
- return self._debug_masks
-
- @debug_masks.setter
- def debug_masks(self, value):
- if isinstance(value, list) is False:
- raise TypeError("Config parameter debug_masks must be a list")
- elif len(value) != 4 or isinstance(value[0], int) is False or isinstance(value[1], int) is False or \
- isinstance(value[2], int) is False or isinstance(value[3], int) is False:
- raise TypeError("Config parameter debug_masks must be a list of 4 integers")
- else:
- for item in value:
- if not 0 <= item <= 0xFFFFFFFF:
- raise ValueError("invalid input value for config parameter debug_masks")
- self._debug_masks = value
-
- @property
- def enabler_cert_pkg(self):
- return self._enabler_cert_pkg
-
- @enabler_cert_pkg.setter
- def enabler_cert_pkg(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter enabler_cert_pkg must be a string")
- elif value == "":
- raise ValueError("Config parameter enabler_cert_pkg cannot be an empty string!")
- else:
- self._enabler_cert_pkg = value
-
- @property
- def cert_pkg(self):
- return self._cert_pkg
-
- @cert_pkg.setter
- def cert_pkg(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter cert_pkg must be a string")
- elif value == "":
- raise ValueError("Config parameter cert_pkg cannot be an empty string!")
- else:
- self._cert_pkg = value
-
- def _parse_config(self):
- if self._logger is not None:
- self._logger.info("Parsing config file: " + self._config_filename)
- self._parser.read(self._config_filename, encoding='cp1250')
- self._logger.info("Parsed items:\n" + str(self._parser.items(self.CFG_SECTION_NAME)))
- with open(self._config_filename, "r") as config_file:
- raw_data = config_file.read()
- self._logger.info("Raw content of config file:\n" + raw_data)
-
- if not self._parser.has_section(self.section_name):
- if self._logger is not None:
- self._logger.warning("section [" + self.section_name + "] wasn't found in cfg file")
- raise ConfigParsingError
-
- if not self._parser.has_option(self.section_name, 'cert-keypair'):
- if self._logger is not None:
- self._logger.error("parameter cert-keypair not found in cfg file")
- raise ConfigParsingError
- else:
- self.cert_keypair = self._parser.get(self.section_name, 'cert-keypair')
-
- if self._parser.has_option(self.section_name, 'cert-keypair-pwd'): # used for testing
- self.cert_keypair_pwd = self._parser.get(self.section_name, 'cert-keypair-pwd')
- else:
- self.cert_keypair_pwd = ''
-
- if not self._parser.has_option(self.section_name, 'soc-id'):
- if self._logger is not None:
- self._logger.error("parameter soc-id not found in cfg file")
- raise ConfigParsingError
- else:
- self.soc_id = self._parser.get(self.section_name, 'soc-id')
-
- if (self._parser.has_option(self.section_name, 'debug-mask[0-31]')
- and self._parser.has_option(self.section_name, 'debug-mask[32-63]')
- and self._parser.has_option(self.section_name, 'debug-mask[64-95]')
- and self._parser.has_option(self.section_name, 'debug-mask[96-127]')):
- debug_masks = [int(self._parser.get(self.section_name, 'debug-mask[0-31]'), 16),
- int(self._parser.get(self.section_name, 'debug-mask[32-63]'), 16),
- int(self._parser.get(self.section_name, 'debug-mask[64-95]'), 16),
- int(self._parser.get(self.section_name, 'debug-mask[96-127]'), 16)]
- self.debug_masks = debug_masks
-
- if not self._parser.has_option(self.section_name, 'enabler-cert-pkg'):
- if self._logger is not None:
- self._logger.error("parameter enabler_cert_pkg not found in cfg file")
- raise ConfigParsingError
- else:
- self.enabler_cert_pkg = self._parser.get(self.section_name, 'enabler-cert-pkg')
-
- if not self._parser.has_option(self.section_name, 'cert-pkg'):
- if self._logger is not None:
- self._logger.error("parameter cert_pkg not found in cfg file")
- raise ConfigParsingError
- else:
- self.cert_pkg = self._parser.get(self.section_name, 'cert-pkg')
+# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
+#
+
+import configparser
+
+from common.util_logger import UtilLogger
+from common.exceptions import ConfigParsingError
+
+
+class DeveloperDebugCertificateConfig:
+ CFG_SECTION_NAME = "DEVELOPER-DBG-CFG"
+
+ def __init__(self, config_filename, app_logger=None):
+ """
+ Parses the DEVELOPER-DBG-CFG developer debug certificate cfg file.
+ Raises ConfigParsingError when cfg has been written incorrectly.
+ Raises TypeError or ValueError when a cfg value is incorrect on its own.
+
+ :param str config_filename: name of cfg file to parse
+ :param UtilLogger app_logger: instance of the application logger
+ """
+ self._config_filename = config_filename
+ self._logger = app_logger
+ self._parser = configparser.ConfigParser()
+
+ self._cert_keypair = None
+ self._cert_keypair_pwd = None
+ self._soc_id = None
+ self._debug_masks = [0, 0, 0, 0]
+ self._enabler_cert_pkg = None
+ self._cert_pkg = None
+ self._parse_config()
+
+ @property
+ def section_name(self):
+ return self.CFG_SECTION_NAME
+
+ @property
+ def cert_keypair(self):
+ return self._cert_keypair
+
+ @cert_keypair.setter
+ def cert_keypair(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter cert-keypair must be a string")
+ elif value == "":
+ raise ValueError("Config parameter cert-keypair cannot be an empty string!")
+ else:
+ self._cert_keypair = value
+
+ @property
+ def cert_keypair_pwd(self):
+ return self._cert_keypair_pwd
+
+ @cert_keypair_pwd.setter
+ def cert_keypair_pwd(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter cert-keypair-pwd must be a string")
+ else:
+ self._cert_keypair_pwd = value
+
+ @property
+ def soc_id(self):
+ return self._soc_id
+
+ @soc_id.setter
+ def soc_id(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter soc_id must be a string")
+ else:
+ self._soc_id = value
+
+ @property
+ def debug_masks(self):
+ return self._debug_masks
+
+ @debug_masks.setter
+ def debug_masks(self, value):
+ if isinstance(value, list) is False:
+ raise TypeError("Config parameter debug_masks must be a list")
+ elif len(value) != 4 or isinstance(value[0], int) is False or isinstance(value[1], int) is False or \
+ isinstance(value[2], int) is False or isinstance(value[3], int) is False:
+ raise TypeError("Config parameter debug_masks must be a list of 4 integers")
+ else:
+ for item in value:
+ if not 0 <= item <= 0xFFFFFFFF:
+ raise ValueError("invalid input value for config parameter debug_masks")
+ self._debug_masks = value
+
+ @property
+ def enabler_cert_pkg(self):
+ return self._enabler_cert_pkg
+
+ @enabler_cert_pkg.setter
+ def enabler_cert_pkg(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter enabler_cert_pkg must be a string")
+ elif value == "":
+ raise ValueError("Config parameter enabler_cert_pkg cannot be an empty string!")
+ else:
+ self._enabler_cert_pkg = value
+
+ @property
+ def cert_pkg(self):
+ return self._cert_pkg
+
+ @cert_pkg.setter
+ def cert_pkg(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter cert_pkg must be a string")
+ elif value == "":
+ raise ValueError("Config parameter cert_pkg cannot be an empty string!")
+ else:
+ self._cert_pkg = value
+
+ def _parse_config(self):
+ if self._logger is not None:
+ self._logger.info("Parsing config file: " + self._config_filename)
+ self._parser.read(self._config_filename, encoding='cp1250')
+ self._logger.info("Parsed items:\n" + str(self._parser.items(self.CFG_SECTION_NAME)))
+ with open(self._config_filename, "r") as config_file:
+ raw_data = config_file.read()
+ self._logger.info("Raw content of config file:\n" + raw_data)
+
+ if not self._parser.has_section(self.section_name):
+ if self._logger is not None:
+ self._logger.warning("section [" + self.section_name + "] wasn't found in cfg file")
+ raise ConfigParsingError
+
+ if not self._parser.has_option(self.section_name, 'cert-keypair'):
+ if self._logger is not None:
+ self._logger.error("parameter cert-keypair not found in cfg file")
+ raise ConfigParsingError
+ else:
+ self.cert_keypair = self._parser.get(self.section_name, 'cert-keypair')
+
+ if self._parser.has_option(self.section_name, 'cert-keypair-pwd'): # used for testing
+ self.cert_keypair_pwd = self._parser.get(self.section_name, 'cert-keypair-pwd')
+ else:
+ self.cert_keypair_pwd = ''
+
+ if not self._parser.has_option(self.section_name, 'soc-id'):
+ if self._logger is not None:
+ self._logger.error("parameter soc-id not found in cfg file")
+ raise ConfigParsingError
+ else:
+ self.soc_id = self._parser.get(self.section_name, 'soc-id')
+
+ if (self._parser.has_option(self.section_name, 'debug-mask[0-31]')
+ and self._parser.has_option(self.section_name, 'debug-mask[32-63]')
+ and self._parser.has_option(self.section_name, 'debug-mask[64-95]')
+ and self._parser.has_option(self.section_name, 'debug-mask[96-127]')):
+ debug_masks = [int(self._parser.get(self.section_name, 'debug-mask[0-31]'), 16),
+ int(self._parser.get(self.section_name, 'debug-mask[32-63]'), 16),
+ int(self._parser.get(self.section_name, 'debug-mask[64-95]'), 16),
+ int(self._parser.get(self.section_name, 'debug-mask[96-127]'), 16)]
+ self.debug_masks = debug_masks
+
+ if not self._parser.has_option(self.section_name, 'enabler-cert-pkg'):
+ if self._logger is not None:
+ self._logger.error("parameter enabler_cert_pkg not found in cfg file")
+ raise ConfigParsingError
+ else:
+ self.enabler_cert_pkg = self._parser.get(self.section_name, 'enabler-cert-pkg')
+
+ if not self._parser.has_option(self.section_name, 'cert-pkg'):
+ if self._logger is not None:
+ self._logger.error("parameter cert_pkg not found in cfg file")
+ raise ConfigParsingError
+ else:
+ self.cert_pkg = self._parser.get(self.section_name, 'cert-pkg')
diff --git a/tools/alif/utils/common_cert_lib/enablercertificateconfig.py b/tools/alif/utils/common_cert_lib/enablercertificateconfig.py
index 1fae2e3c1..afb09536e 100755
--- a/tools/alif/utils/common_cert_lib/enablercertificateconfig.py
+++ b/tools/alif/utils/common_cert_lib/enablercertificateconfig.py
@@ -1,282 +1,282 @@
-# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
-#
-
-import configparser
-
-from common.util_logger import UtilLogger
-from common.exceptions import ConfigParsingError
-
-
-class EnablerDebugCertificateConfig:
- CFG_SECTION_NAME = "ENABLER-DBG-CFG"
-
- def __init__(self, config_filename, app_logger=None):
- """
- Parses the ENABLER-DBG-CFG enabler debug certificate cfg file.
- Raises ConfigParsingError when cfg has been written incorrectly.
- Raises TypeError or ValueError when a cfg value is incorrect on its own.
-
- :param str config_filename: name of cfg file to parse
- :param UtilLogger app_logger: instance of the application logger
- """
- self._config_filename = config_filename
- self._logger = app_logger
- self._parser = configparser.ConfigParser()
-
- self._cert_keypair = None
- self._cert_keypair_pwd = None
- self._lcs = None
- self._rma_mode = None
- self._debug_masks = [0, 0, 0, 0]
- self._debug_locks = [0, 0, 0, 0]
- self._hbk_id = None
- self._key_cert_pkg = None
- self._next_cert_pubkey = None
- self._cert_pkg = None
- self._parse_config()
-
- @property
- def section_name(self):
- return self.CFG_SECTION_NAME
-
- @property
- def cert_keypair(self):
- return self._cert_keypair
-
- @cert_keypair.setter
- def cert_keypair(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter cert-keypair must be a string")
- elif value == "":
- raise ValueError("Config parameter cert-keypair cannot be an empty string!")
- else:
- self._cert_keypair = value
-
- @property
- def cert_keypair_pwd(self):
- return self._cert_keypair_pwd
-
- @cert_keypair_pwd.setter
- def cert_keypair_pwd(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter cert-keypair-pwd must be a string")
- else:
- self._cert_keypair_pwd = value
-
- @property
- def lcs(self):
- return self._lcs
-
- @lcs.setter
- def lcs(self, value):
- if isinstance(value, int) is False:
- raise TypeError("Config parameter lcs must be an integer")
- elif value not in [0, 1, 5, 7]:
- raise ValueError("invalid input value for config parameter lcs")
- else:
- self._lcs = value
-
- @property
- def rma_mode(self):
- return self._rma_mode
-
- @rma_mode.setter
- def rma_mode(self, value):
- if isinstance(value, int) is False:
- raise TypeError("Config parameter rma_mode must be an integer")
- elif value not in [0, 1]:
- raise ValueError("invalid input value for config parameter rma_mode")
- else:
- self._rma_mode = value
-
- @property
- def debug_masks(self):
- return self._debug_masks
-
- @debug_masks.setter
- def debug_masks(self, value):
- if isinstance(value, list) is False:
- raise TypeError("Config parameter debug_masks must be a list")
- elif len(value) != 4 or isinstance(value[0], int) is False or isinstance(value[1], int) is False or \
- isinstance(value[2], int) is False or isinstance(value[3], int) is False:
- raise TypeError("Config parameter debug_masks must be a list of 4 integers")
- else:
- for item in value:
- if not 0 <= item <= 0xFFFFFFFF:
- raise ValueError("invalid input value for config parameter debug_masks")
- self._debug_masks = value
-
- @property
- def debug_locks(self):
- return self._debug_locks
-
- @debug_locks.setter
- def debug_locks(self, value):
- if isinstance(value, list) is False:
- raise TypeError("Config parameter debug_locks must be a list")
- elif len(value) != 4 or isinstance(value[0], int) is False or isinstance(value[1], int) is False or \
- isinstance(value[2], int) is False or isinstance(value[3], int) is False:
- raise TypeError("Config parameter debug_locks must be a list of 4 integers")
- else:
- for item in value:
- if not 0 <= item <= 0xFFFFFFFF:
- raise ValueError("invalid input value for config parameter debug_locks")
- self._debug_locks = value
-
- @property
- def hbk_id(self):
- return self._hbk_id
-
- @hbk_id.setter
- def hbk_id(self, value):
- if isinstance(value, int) is False:
- raise TypeError("Config parameter hbk_id must be an integer")
- elif value not in [0, 1, 2, 0xF]:
- raise ValueError("invalid input value for config parameter hbk_id")
- else:
- self._hbk_id = value
-
- @property
- def key_cert_pkg(self):
- return self._key_cert_pkg
-
- @key_cert_pkg.setter
- def key_cert_pkg(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter key_cert_pkg must be a string")
- else:
- self._key_cert_pkg = value
-
- @property
- def next_cert_pubkey(self):
- return self._next_cert_pubkey
-
- @next_cert_pubkey.setter
- def next_cert_pubkey(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter next_cert_pubkey must be a string")
- elif value == "":
- raise ValueError("Config parameter next_cert_pubkey cannot be an empty string!")
- else:
- self._next_cert_pubkey = value
-
- @property
- def cert_pkg(self):
- return self._cert_pkg
-
- @cert_pkg.setter
- def cert_pkg(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter cert_pkg must be a string")
- elif value == "":
- raise ValueError("Config parameter cert_pkg cannot be an empty string!")
- else:
- self._cert_pkg = value
-
- def _parse_config(self):
- if self._logger is not None:
- self._logger.info("Parsing config file: " + self._config_filename)
- self._parser.read(self._config_filename, encoding='cp1250')
- self._logger.info("Parsed items:\n" + str(self._parser.items(self.CFG_SECTION_NAME)))
- with open(self._config_filename, "r") as config_file:
- raw_data = config_file.read()
- self._logger.info("Raw content of config file:\n" + raw_data)
-
- if not self._parser.has_section(self.section_name):
- if self._logger is not None:
- self._logger.error("section " + self.section_name + " wasn't found in cfg file")
- raise ConfigParsingError
-
- is_debug_exist = 0
- if (self._parser.has_option(self.section_name, 'debug-mask[0-31]')
- and self._parser.has_option(self.section_name, 'debug-mask[32-63]')
- and self._parser.has_option(self.section_name, 'debug-mask[64-95]')
- and self._parser.has_option(self.section_name, 'debug-mask[96-127]')
- and self._parser.has_option(self.section_name, 'debug-lock[0-31]')
- and self._parser.has_option(self.section_name, 'debug-lock[32-63]')
- and self._parser.has_option(self.section_name, 'debug-lock[64-95]')
- and self._parser.has_option(self.section_name, 'debug-lock[96-127]')):
- debug_masks = [int(self._parser.get(self.section_name, 'debug-mask[0-31]'), 16),
- int(self._parser.get(self.section_name, 'debug-mask[32-63]'), 16),
- int(self._parser.get(self.section_name, 'debug-mask[64-95]'), 16),
- int(self._parser.get(self.section_name, 'debug-mask[96-127]'), 16)]
- self.debug_masks = debug_masks
-
- debug_locks = [int(self._parser.get(self.section_name, 'debug-lock[0-31]'), 16),
- int(self._parser.get(self.section_name, 'debug-lock[32-63]'), 16),
- int(self._parser.get(self.section_name, 'debug-lock[64-95]'), 16),
- int(self._parser.get(self.section_name, 'debug-lock[96-127]'), 16)]
- self.debug_locks = debug_locks
- is_debug_exist = 1
-
- if self._parser.has_option(self.section_name, 'rma-mode'):
- self.rma_mode = self._parser.getint(self.section_name, 'rma-mode')
- else:
- self.rma_mode = 0
-
- is_hbk_exist = self._parser.has_option(self.section_name, 'hbk-id')
- if is_hbk_exist:
- self.hbk_id = self._parser.getint(self.section_name, 'hbk-id')
- else:
- self.hbk_id = 0xF # dummy value (from original) - certificate always need a value
-
- is_key_pkg_exist = 0
- if self._parser.has_option(self.section_name, 'key-cert-pkg'):
- self.key_cert_pkg = self._parser.get(self.section_name, 'key-cert-pkg')
- is_key_pkg_exist = 1
-
- if self.rma_mode == 1 and is_debug_exist == 1:
- if self._logger is not None:
- self._logger.error("Both RMA and debug mode are defined")
- raise ConfigParsingError
- if self.rma_mode == 0 and is_debug_exist == 0:
- if self._logger is not None:
- self._logger.error("Neither RMA nor Debug mode is defined")
- raise ConfigParsingError
- if is_key_pkg_exist == 0 and not is_hbk_exist:
- if self._logger is not None:
- self._logger.error("Neither hbk-id nor key-cert-pkg is defined")
- raise ConfigParsingError
- if is_key_pkg_exist == 1 and is_hbk_exist:
- if self._logger is not None:
- self._logger.error("Both hbk-id and key-cert-pkg is defined")
- raise ConfigParsingError
- if not is_hbk_exist and self.rma_mode == 1:
- if self._logger is not None:
- self._logger.error("hbk-id must exist if RMA mode is defined")
- raise ConfigParsingError
-
- if not self._parser.has_option(self.section_name, 'cert-keypair'):
- if self._logger is not None:
- self._logger.error("cert-keypair not found")
- raise ConfigParsingError
- else:
- self.cert_keypair = self._parser.get(self.section_name, 'cert-keypair')
-
- if self._parser.has_option(self.section_name, 'cert-keypair-pwd'): # used for testing
- self.cert_keypair_pwd = self._parser.get(self.section_name, 'cert-keypair-pwd')
- else:
- self.cert_keypair_pwd = ''
-
- if not self._parser.has_option(self.section_name, 'lcs'):
- if self._logger is not None:
- self._logger.error("no lcs parameter found")
- raise ConfigParsingError
- else:
- self.lcs = self._parser.getint(self.section_name, 'lcs')
-
- if not self._parser.has_option(self.section_name, 'next-cert-pubkey'):
- if self._logger is not None:
- self._logger.error("no next-cert-pubkey parameter found")
- raise ConfigParsingError
- else:
- self.next_cert_pubkey = self._parser.get(self.section_name, 'next-cert-pubkey')
-
- if not self._parser.has_option(self.section_name, 'cert-pkg'):
- if self._logger is not None:
- self._logger.error("no cert-pkg parameter found")
- raise ConfigParsingError
- else:
- self.cert_pkg = self._parser.get(self.section_name, 'cert-pkg')
+# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
+#
+
+import configparser
+
+from common.util_logger import UtilLogger
+from common.exceptions import ConfigParsingError
+
+
+class EnablerDebugCertificateConfig:
+ CFG_SECTION_NAME = "ENABLER-DBG-CFG"
+
+ def __init__(self, config_filename, app_logger=None):
+ """
+ Parses the ENABLER-DBG-CFG enabler debug certificate cfg file.
+ Raises ConfigParsingError when cfg has been written incorrectly.
+ Raises TypeError or ValueError when a cfg value is incorrect on its own.
+
+ :param str config_filename: name of cfg file to parse
+ :param UtilLogger app_logger: instance of the application logger
+ """
+ self._config_filename = config_filename
+ self._logger = app_logger
+ self._parser = configparser.ConfigParser()
+
+ self._cert_keypair = None
+ self._cert_keypair_pwd = None
+ self._lcs = None
+ self._rma_mode = None
+ self._debug_masks = [0, 0, 0, 0]
+ self._debug_locks = [0, 0, 0, 0]
+ self._hbk_id = None
+ self._key_cert_pkg = None
+ self._next_cert_pubkey = None
+ self._cert_pkg = None
+ self._parse_config()
+
+ @property
+ def section_name(self):
+ return self.CFG_SECTION_NAME
+
+ @property
+ def cert_keypair(self):
+ return self._cert_keypair
+
+ @cert_keypair.setter
+ def cert_keypair(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter cert-keypair must be a string")
+ elif value == "":
+ raise ValueError("Config parameter cert-keypair cannot be an empty string!")
+ else:
+ self._cert_keypair = value
+
+ @property
+ def cert_keypair_pwd(self):
+ return self._cert_keypair_pwd
+
+ @cert_keypair_pwd.setter
+ def cert_keypair_pwd(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter cert-keypair-pwd must be a string")
+ else:
+ self._cert_keypair_pwd = value
+
+ @property
+ def lcs(self):
+ return self._lcs
+
+ @lcs.setter
+ def lcs(self, value):
+ if isinstance(value, int) is False:
+ raise TypeError("Config parameter lcs must be an integer")
+ elif value not in [0, 1, 5, 7]:
+ raise ValueError("invalid input value for config parameter lcs")
+ else:
+ self._lcs = value
+
+ @property
+ def rma_mode(self):
+ return self._rma_mode
+
+ @rma_mode.setter
+ def rma_mode(self, value):
+ if isinstance(value, int) is False:
+ raise TypeError("Config parameter rma_mode must be an integer")
+ elif value not in [0, 1]:
+ raise ValueError("invalid input value for config parameter rma_mode")
+ else:
+ self._rma_mode = value
+
+ @property
+ def debug_masks(self):
+ return self._debug_masks
+
+ @debug_masks.setter
+ def debug_masks(self, value):
+ if isinstance(value, list) is False:
+ raise TypeError("Config parameter debug_masks must be a list")
+ elif len(value) != 4 or isinstance(value[0], int) is False or isinstance(value[1], int) is False or \
+ isinstance(value[2], int) is False or isinstance(value[3], int) is False:
+ raise TypeError("Config parameter debug_masks must be a list of 4 integers")
+ else:
+ for item in value:
+ if not 0 <= item <= 0xFFFFFFFF:
+ raise ValueError("invalid input value for config parameter debug_masks")
+ self._debug_masks = value
+
+ @property
+ def debug_locks(self):
+ return self._debug_locks
+
+ @debug_locks.setter
+ def debug_locks(self, value):
+ if isinstance(value, list) is False:
+ raise TypeError("Config parameter debug_locks must be a list")
+ elif len(value) != 4 or isinstance(value[0], int) is False or isinstance(value[1], int) is False or \
+ isinstance(value[2], int) is False or isinstance(value[3], int) is False:
+ raise TypeError("Config parameter debug_locks must be a list of 4 integers")
+ else:
+ for item in value:
+ if not 0 <= item <= 0xFFFFFFFF:
+ raise ValueError("invalid input value for config parameter debug_locks")
+ self._debug_locks = value
+
+ @property
+ def hbk_id(self):
+ return self._hbk_id
+
+ @hbk_id.setter
+ def hbk_id(self, value):
+ if isinstance(value, int) is False:
+ raise TypeError("Config parameter hbk_id must be an integer")
+ elif value not in [0, 1, 2, 0xF]:
+ raise ValueError("invalid input value for config parameter hbk_id")
+ else:
+ self._hbk_id = value
+
+ @property
+ def key_cert_pkg(self):
+ return self._key_cert_pkg
+
+ @key_cert_pkg.setter
+ def key_cert_pkg(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter key_cert_pkg must be a string")
+ else:
+ self._key_cert_pkg = value
+
+ @property
+ def next_cert_pubkey(self):
+ return self._next_cert_pubkey
+
+ @next_cert_pubkey.setter
+ def next_cert_pubkey(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter next_cert_pubkey must be a string")
+ elif value == "":
+ raise ValueError("Config parameter next_cert_pubkey cannot be an empty string!")
+ else:
+ self._next_cert_pubkey = value
+
+ @property
+ def cert_pkg(self):
+ return self._cert_pkg
+
+ @cert_pkg.setter
+ def cert_pkg(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter cert_pkg must be a string")
+ elif value == "":
+ raise ValueError("Config parameter cert_pkg cannot be an empty string!")
+ else:
+ self._cert_pkg = value
+
+ def _parse_config(self):
+ if self._logger is not None:
+ self._logger.info("Parsing config file: " + self._config_filename)
+ self._parser.read(self._config_filename, encoding='cp1250')
+ self._logger.info("Parsed items:\n" + str(self._parser.items(self.CFG_SECTION_NAME)))
+ with open(self._config_filename, "r") as config_file:
+ raw_data = config_file.read()
+ self._logger.info("Raw content of config file:\n" + raw_data)
+
+ if not self._parser.has_section(self.section_name):
+ if self._logger is not None:
+ self._logger.error("section " + self.section_name + " wasn't found in cfg file")
+ raise ConfigParsingError
+
+ is_debug_exist = 0
+ if (self._parser.has_option(self.section_name, 'debug-mask[0-31]')
+ and self._parser.has_option(self.section_name, 'debug-mask[32-63]')
+ and self._parser.has_option(self.section_name, 'debug-mask[64-95]')
+ and self._parser.has_option(self.section_name, 'debug-mask[96-127]')
+ and self._parser.has_option(self.section_name, 'debug-lock[0-31]')
+ and self._parser.has_option(self.section_name, 'debug-lock[32-63]')
+ and self._parser.has_option(self.section_name, 'debug-lock[64-95]')
+ and self._parser.has_option(self.section_name, 'debug-lock[96-127]')):
+ debug_masks = [int(self._parser.get(self.section_name, 'debug-mask[0-31]'), 16),
+ int(self._parser.get(self.section_name, 'debug-mask[32-63]'), 16),
+ int(self._parser.get(self.section_name, 'debug-mask[64-95]'), 16),
+ int(self._parser.get(self.section_name, 'debug-mask[96-127]'), 16)]
+ self.debug_masks = debug_masks
+
+ debug_locks = [int(self._parser.get(self.section_name, 'debug-lock[0-31]'), 16),
+ int(self._parser.get(self.section_name, 'debug-lock[32-63]'), 16),
+ int(self._parser.get(self.section_name, 'debug-lock[64-95]'), 16),
+ int(self._parser.get(self.section_name, 'debug-lock[96-127]'), 16)]
+ self.debug_locks = debug_locks
+ is_debug_exist = 1
+
+ if self._parser.has_option(self.section_name, 'rma-mode'):
+ self.rma_mode = self._parser.getint(self.section_name, 'rma-mode')
+ else:
+ self.rma_mode = 0
+
+ is_hbk_exist = self._parser.has_option(self.section_name, 'hbk-id')
+ if is_hbk_exist:
+ self.hbk_id = self._parser.getint(self.section_name, 'hbk-id')
+ else:
+ self.hbk_id = 0xF # dummy value (from original) - certificate always need a value
+
+ is_key_pkg_exist = 0
+ if self._parser.has_option(self.section_name, 'key-cert-pkg'):
+ self.key_cert_pkg = self._parser.get(self.section_name, 'key-cert-pkg')
+ is_key_pkg_exist = 1
+
+ if self.rma_mode == 1 and is_debug_exist == 1:
+ if self._logger is not None:
+ self._logger.error("Both RMA and debug mode are defined")
+ raise ConfigParsingError
+ if self.rma_mode == 0 and is_debug_exist == 0:
+ if self._logger is not None:
+ self._logger.error("Neither RMA nor Debug mode is defined")
+ raise ConfigParsingError
+ if is_key_pkg_exist == 0 and not is_hbk_exist:
+ if self._logger is not None:
+ self._logger.error("Neither hbk-id nor key-cert-pkg is defined")
+ raise ConfigParsingError
+ if is_key_pkg_exist == 1 and is_hbk_exist:
+ if self._logger is not None:
+ self._logger.error("Both hbk-id and key-cert-pkg is defined")
+ raise ConfigParsingError
+ if not is_hbk_exist and self.rma_mode == 1:
+ if self._logger is not None:
+ self._logger.error("hbk-id must exist if RMA mode is defined")
+ raise ConfigParsingError
+
+ if not self._parser.has_option(self.section_name, 'cert-keypair'):
+ if self._logger is not None:
+ self._logger.error("cert-keypair not found")
+ raise ConfigParsingError
+ else:
+ self.cert_keypair = self._parser.get(self.section_name, 'cert-keypair')
+
+ if self._parser.has_option(self.section_name, 'cert-keypair-pwd'): # used for testing
+ self.cert_keypair_pwd = self._parser.get(self.section_name, 'cert-keypair-pwd')
+ else:
+ self.cert_keypair_pwd = ''
+
+ if not self._parser.has_option(self.section_name, 'lcs'):
+ if self._logger is not None:
+ self._logger.error("no lcs parameter found")
+ raise ConfigParsingError
+ else:
+ self.lcs = self._parser.getint(self.section_name, 'lcs')
+
+ if not self._parser.has_option(self.section_name, 'next-cert-pubkey'):
+ if self._logger is not None:
+ self._logger.error("no next-cert-pubkey parameter found")
+ raise ConfigParsingError
+ else:
+ self.next_cert_pubkey = self._parser.get(self.section_name, 'next-cert-pubkey')
+
+ if not self._parser.has_option(self.section_name, 'cert-pkg'):
+ if self._logger is not None:
+ self._logger.error("no cert-pkg parameter found")
+ raise ConfigParsingError
+ else:
+ self.cert_pkg = self._parser.get(self.section_name, 'cert-pkg')
diff --git a/tools/alif/utils/common_cert_lib/keycertificateconfig.py b/tools/alif/utils/common_cert_lib/keycertificateconfig.py
index 3c4717dc3..b1cc8e607 100755
--- a/tools/alif/utils/common_cert_lib/keycertificateconfig.py
+++ b/tools/alif/utils/common_cert_lib/keycertificateconfig.py
@@ -1,180 +1,180 @@
-# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
-#
-
-import configparser
-
-from utils.common.util_logger import UtilLogger
-from utils.common.exceptions import ConfigParsingError
-from utils.common import global_defines
-
-
-class KeyCertificateConfig:
- CFG_SECTION_NAME = "KEY-CFG"
-
- def __init__(self, config_filename, app_logger=None):
- """
- Parses the KEY-CFG key certificate cfg file.
- Raises ConfigParsingError when cfg has been written incorrectly.
- Raises TypeError or ValueError when a cfg value is incorrect on its own.
-
- :param str config_filename: name of cfg file to parse
- :param UtilLogger app_logger: instance of the application logger
- """
- self._config_filename = config_filename
- self._logger = app_logger
- self._parser = configparser.ConfigParser()
-
- self._cert_keypair = None
- self._cert_keypair_pwd = None
- self._hbk_id = None
- self._nvcounter_val = None
- self._next_cert_pubkey = None
- self._cert_pkg = None
- self._parse_config()
-
- @property
- def section_name(self):
- return self.CFG_SECTION_NAME
-
- @property
- def cert_keypair(self):
- return self._cert_keypair
-
- @cert_keypair.setter
- def cert_keypair(self, value):
- if value == "":
- raise ValueError("Config parameter cert-keypair cannot be an empty string!")
- elif isinstance(value, str) is False:
- raise TypeError("Config parameter cert-keypair must be a string")
- else:
- self._cert_keypair = value
-
- @property
- def cert_keypair_pwd(self):
- return self._cert_keypair_pwd
-
- @cert_keypair_pwd.setter
- def cert_keypair_pwd(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter cert-keypair-pwd must be a string")
- else:
- self._cert_keypair_pwd = value
-
- @property
- def hbk_id(self):
- return self._hbk_id
-
- @hbk_id.setter
- def hbk_id(self, value):
- if isinstance(value, int) is False:
- raise TypeError("Config parameter hbk_id must be an integer")
- elif value not in [0, 1, 2]:
- raise ValueError("invalid input value for config parameter hbk_id")
- else:
- self._hbk_id = value
-
- @property
- def nvcounter_val(self):
- return self._nvcounter_val
-
- @nvcounter_val.setter
- def nvcounter_val(self, value):
- if isinstance(value, int) is False:
- raise TypeError("Config parameter nvcounter_val must be an integer")
- elif value not in range(global_defines.SW_REVOCATION_MAX_NUM_OF_BITS_HBK2 + 1):
- raise ValueError("invalid input value for config parameter nvcounter_val")
- else:
- self._nvcounter_val = value
-
- @property
- def next_cert_pubkey(self):
- return self._next_cert_pubkey
-
- @next_cert_pubkey.setter
- def next_cert_pubkey(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter next_cert_pubkey must be a string")
- elif value == "":
- raise ValueError("Config parameter next_cert_pubkey cannot be an empty string!")
- else:
- self._next_cert_pubkey = value
-
- @property
- def cert_pkg(self):
- return self._cert_pkg
-
- @cert_pkg.setter
- def cert_pkg(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter cert_pkg must be a string")
- elif value == "":
- raise ValueError("Config parameter cert_pkg cannot be an empty string!")
- else:
- self._cert_pkg = value
-
- def _parse_config(self):
- if self._logger is not None:
- self._logger.info("Parsing config file: " + self._config_filename)
- self._parser.read(self._config_filename, encoding='cp1250')
- self._logger.info("Parsed items:\n" + str(self._parser.items(self.CFG_SECTION_NAME)))
- with open(self._config_filename, "r") as config_file:
- raw_data = config_file.read()
- self._logger.info("Raw content of config file:\n" + raw_data)
-
- if not self._parser.has_section(self.section_name):
- if self._logger is not None:
- self._logger.error("section [" + self.section_name + "] wasn't found in cfg file")
- raise ConfigParsingError
-
- if not self._parser.has_option(self.section_name, 'cert-keypair'):
- if self._logger is not None:
- self._logger.error("cert-keypair not found")
- raise ConfigParsingError
- else:
- self.cert_keypair = self._parser.get(self.section_name, 'cert-keypair')
-
- if self._parser.has_option(self.section_name, 'cert-keypair-pwd'):
- self.cert_keypair_pwd = self._parser.get(self.section_name, 'cert-keypair-pwd')
- else:
- self.cert_keypair_pwd = ''
-
- if not self._parser.has_option(self.section_name, 'hbk-id'):
- if self._logger is not None:
- self._logger.error("hbk-id not found")
- raise ConfigParsingError
- else:
- self.hbk_id = self._parser.getint(self.section_name, 'hbk-id')
-
- if not self._parser.has_option(self.section_name, 'nvcounter-val'):
- if self._logger is not None:
- self._logger.error("nvcounter-val not found")
- raise ConfigParsingError
- else:
- self.nvcounter_val = self._parser.getint(self.section_name, 'nvcounter-val')
- # verify nvcounter_val according to HBK
- if self.hbk_id == 0:
- max_value_nvcounter = global_defines.SW_REVOCATION_MAX_NUM_OF_BITS_HBK0
- elif self.hbk_id == 1:
- max_value_nvcounter = global_defines.SW_REVOCATION_MAX_NUM_OF_BITS_HBK1
- else:
- max_value_nvcounter = global_defines.SW_REVOCATION_MAX_NUM_OF_BITS_HBK2
- if self.nvcounter_val > max_value_nvcounter:
- if self._logger is not None:
- self._logger.error("Invalid nvcounter-val based on given hbk-id")
- raise ConfigParsingError
-
- if not self._parser.has_option(self.section_name, 'next-cert-pubkey'):
- if self._logger is not None:
- self._logger.error("no next-cert-pubkey parameter found")
- raise ConfigParsingError
- else:
- self.next_cert_pubkey = self._parser.get(self.section_name, 'next-cert-pubkey')
-
- if not self._parser.has_option(self.section_name, 'cert-pkg'):
- if self._logger is not None:
- self._logger.error("no cert-pkg parameter found")
- raise ConfigParsingError
- else:
- self.cert_pkg = self._parser.get(self.section_name, 'cert-pkg')
+# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
+#
+
+import configparser
+
+from utils.common.util_logger import UtilLogger
+from utils.common.exceptions import ConfigParsingError
+from utils.common import global_defines
+
+
+class KeyCertificateConfig:
+ CFG_SECTION_NAME = "KEY-CFG"
+
+ def __init__(self, config_filename, app_logger=None):
+ """
+ Parses the KEY-CFG key certificate cfg file.
+ Raises ConfigParsingError when cfg has been written incorrectly.
+ Raises TypeError or ValueError when a cfg value is incorrect on its own.
+
+ :param str config_filename: name of cfg file to parse
+ :param UtilLogger app_logger: instance of the application logger
+ """
+ self._config_filename = config_filename
+ self._logger = app_logger
+ self._parser = configparser.ConfigParser()
+
+ self._cert_keypair = None
+ self._cert_keypair_pwd = None
+ self._hbk_id = None
+ self._nvcounter_val = None
+ self._next_cert_pubkey = None
+ self._cert_pkg = None
+ self._parse_config()
+
+ @property
+ def section_name(self):
+ return self.CFG_SECTION_NAME
+
+ @property
+ def cert_keypair(self):
+ return self._cert_keypair
+
+ @cert_keypair.setter
+ def cert_keypair(self, value):
+ if value == "":
+ raise ValueError("Config parameter cert-keypair cannot be an empty string!")
+ elif isinstance(value, str) is False:
+ raise TypeError("Config parameter cert-keypair must be a string")
+ else:
+ self._cert_keypair = value
+
+ @property
+ def cert_keypair_pwd(self):
+ return self._cert_keypair_pwd
+
+ @cert_keypair_pwd.setter
+ def cert_keypair_pwd(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter cert-keypair-pwd must be a string")
+ else:
+ self._cert_keypair_pwd = value
+
+ @property
+ def hbk_id(self):
+ return self._hbk_id
+
+ @hbk_id.setter
+ def hbk_id(self, value):
+ if isinstance(value, int) is False:
+ raise TypeError("Config parameter hbk_id must be an integer")
+ elif value not in [0, 1, 2]:
+ raise ValueError("invalid input value for config parameter hbk_id")
+ else:
+ self._hbk_id = value
+
+ @property
+ def nvcounter_val(self):
+ return self._nvcounter_val
+
+ @nvcounter_val.setter
+ def nvcounter_val(self, value):
+ if isinstance(value, int) is False:
+ raise TypeError("Config parameter nvcounter_val must be an integer")
+ elif value not in range(global_defines.SW_REVOCATION_MAX_NUM_OF_BITS_HBK2 + 1):
+ raise ValueError("invalid input value for config parameter nvcounter_val")
+ else:
+ self._nvcounter_val = value
+
+ @property
+ def next_cert_pubkey(self):
+ return self._next_cert_pubkey
+
+ @next_cert_pubkey.setter
+ def next_cert_pubkey(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter next_cert_pubkey must be a string")
+ elif value == "":
+ raise ValueError("Config parameter next_cert_pubkey cannot be an empty string!")
+ else:
+ self._next_cert_pubkey = value
+
+ @property
+ def cert_pkg(self):
+ return self._cert_pkg
+
+ @cert_pkg.setter
+ def cert_pkg(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter cert_pkg must be a string")
+ elif value == "":
+ raise ValueError("Config parameter cert_pkg cannot be an empty string!")
+ else:
+ self._cert_pkg = value
+
+ def _parse_config(self):
+ if self._logger is not None:
+ self._logger.info("Parsing config file: " + self._config_filename)
+ self._parser.read(self._config_filename, encoding='cp1250')
+ self._logger.info("Parsed items:\n" + str(self._parser.items(self.CFG_SECTION_NAME)))
+ with open(self._config_filename, "r") as config_file:
+ raw_data = config_file.read()
+ self._logger.info("Raw content of config file:\n" + raw_data)
+
+ if not self._parser.has_section(self.section_name):
+ if self._logger is not None:
+ self._logger.error("section [" + self.section_name + "] wasn't found in cfg file")
+ raise ConfigParsingError
+
+ if not self._parser.has_option(self.section_name, 'cert-keypair'):
+ if self._logger is not None:
+ self._logger.error("cert-keypair not found")
+ raise ConfigParsingError
+ else:
+ self.cert_keypair = self._parser.get(self.section_name, 'cert-keypair')
+
+ if self._parser.has_option(self.section_name, 'cert-keypair-pwd'):
+ self.cert_keypair_pwd = self._parser.get(self.section_name, 'cert-keypair-pwd')
+ else:
+ self.cert_keypair_pwd = ''
+
+ if not self._parser.has_option(self.section_name, 'hbk-id'):
+ if self._logger is not None:
+ self._logger.error("hbk-id not found")
+ raise ConfigParsingError
+ else:
+ self.hbk_id = self._parser.getint(self.section_name, 'hbk-id')
+
+ if not self._parser.has_option(self.section_name, 'nvcounter-val'):
+ if self._logger is not None:
+ self._logger.error("nvcounter-val not found")
+ raise ConfigParsingError
+ else:
+ self.nvcounter_val = self._parser.getint(self.section_name, 'nvcounter-val')
+ # verify nvcounter_val according to HBK
+ if self.hbk_id == 0:
+ max_value_nvcounter = global_defines.SW_REVOCATION_MAX_NUM_OF_BITS_HBK0
+ elif self.hbk_id == 1:
+ max_value_nvcounter = global_defines.SW_REVOCATION_MAX_NUM_OF_BITS_HBK1
+ else:
+ max_value_nvcounter = global_defines.SW_REVOCATION_MAX_NUM_OF_BITS_HBK2
+ if self.nvcounter_val > max_value_nvcounter:
+ if self._logger is not None:
+ self._logger.error("Invalid nvcounter-val based on given hbk-id")
+ raise ConfigParsingError
+
+ if not self._parser.has_option(self.section_name, 'next-cert-pubkey'):
+ if self._logger is not None:
+ self._logger.error("no next-cert-pubkey parameter found")
+ raise ConfigParsingError
+ else:
+ self.next_cert_pubkey = self._parser.get(self.section_name, 'next-cert-pubkey')
+
+ if not self._parser.has_option(self.section_name, 'cert-pkg'):
+ if self._logger is not None:
+ self._logger.error("no cert-pkg parameter found")
+ raise ConfigParsingError
+ else:
+ self.cert_pkg = self._parser.get(self.section_name, 'cert-pkg')
diff --git a/tools/alif/utils/common_cert_lib/x509certificateconfig.py b/tools/alif/utils/common_cert_lib/x509certificateconfig.py
index 6c470b9ec..e65b06596 100755
--- a/tools/alif/utils/common_cert_lib/x509certificateconfig.py
+++ b/tools/alif/utils/common_cert_lib/x509certificateconfig.py
@@ -1,108 +1,108 @@
-# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
-#
-
-import configparser
-import sys
-import os
-
-from common.util_logger import UtilLogger
-
-
-class X509CertificateConfig:
-
- def __init__(self, config_filename, config_section_name, app_logger=None):
- """
- Parses the X509 part of a certificate config file.
- Raises ConfigParsingError when cfg has been written incorrectly.
- Raises TypeError or ValueError when a cfg value is incorrect on its own.
-
- :param str config_filename: name of cfg file to parse
- :param str config_section_name: name of the section holding the values of the cfg file
- :param UtilLogger app_logger: instance of the application logger
- """
- self._config_filename = config_filename
- self._section_name = config_section_name
- self._logger = app_logger
- self._parser = configparser.ConfigParser()
-
- self._issuer_name = ""
- self._subject_name = ""
- self._not_before = 0
- self._not_after = 0
- self._serial_num = 0
- self._parse_config()
-
- @property
- def issuer_name(self):
- return self._issuer_name
-
- @issuer_name.setter
- def issuer_name(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter issuer-name must be a string")
- else:
- self._issuer_name = value
-
- @property
- def subject_name(self):
- return self._subject_name
-
- @subject_name.setter
- def subject_name(self, value):
- if isinstance(value, str) is False:
- raise TypeError("Config parameter subject-name must be a string")
- else:
- self._subject_name = value
-
- @property
- def not_before(self):
- return self._not_before
-
- @not_before.setter
- def not_before(self, value):
- if isinstance(value, int) is False:
- raise TypeError("Config parameter not-before must be an integer")
- else:
- self._not_before = value
-
- @property
- def not_after(self):
- return self._not_after
-
- @not_after.setter
- def not_after(self, value):
- if isinstance(value, int) is False:
- raise TypeError("Config parameter not-after must be an integer")
- else:
- self._not_after = value
-
- @property
- def serial_num(self):
- return self._serial_num
-
- @serial_num.setter
- def serial_num(self, value):
- if isinstance(value, int) is False:
- raise TypeError("Config parameter serial-num must be an integer")
- else:
- self._serial_num = value
-
- def _parse_config(self):
- self._parser.read(self._config_filename, encoding='cp1250')
-
- if self._parser.has_option(self._section_name, 'issuer-name'):
- self.issuer_name = self._parser.get(self._section_name, 'issuer-name')
-
- if self._parser.has_option(self._section_name, 'subject-name'):
- self.subject_name = self._parser.get(self._section_name, 'subject-name')
-
- if self._parser.has_option(self._section_name, 'not-before'):
- self.not_before = self._parser.getint(self._section_name, 'not-before')
-
- if self._parser.has_option(self._section_name, 'not-after'):
- self.not_after = self._parser.getint(self._section_name, 'not-after')
-
- if self._parser.has_option(self._section_name, 'serial-num'):
- self.serial_num = self._parser.getint(self._section_name, 'serial-num')
+# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
+#
+
+import configparser
+import sys
+import os
+
+from common.util_logger import UtilLogger
+
+
+class X509CertificateConfig:
+
+ def __init__(self, config_filename, config_section_name, app_logger=None):
+ """
+ Parses the X509 part of a certificate config file.
+ Raises ConfigParsingError when cfg has been written incorrectly.
+ Raises TypeError or ValueError when a cfg value is incorrect on its own.
+
+ :param str config_filename: name of cfg file to parse
+ :param str config_section_name: name of the section holding the values of the cfg file
+ :param UtilLogger app_logger: instance of the application logger
+ """
+ self._config_filename = config_filename
+ self._section_name = config_section_name
+ self._logger = app_logger
+ self._parser = configparser.ConfigParser()
+
+ self._issuer_name = ""
+ self._subject_name = ""
+ self._not_before = 0
+ self._not_after = 0
+ self._serial_num = 0
+ self._parse_config()
+
+ @property
+ def issuer_name(self):
+ return self._issuer_name
+
+ @issuer_name.setter
+ def issuer_name(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter issuer-name must be a string")
+ else:
+ self._issuer_name = value
+
+ @property
+ def subject_name(self):
+ return self._subject_name
+
+ @subject_name.setter
+ def subject_name(self, value):
+ if isinstance(value, str) is False:
+ raise TypeError("Config parameter subject-name must be a string")
+ else:
+ self._subject_name = value
+
+ @property
+ def not_before(self):
+ return self._not_before
+
+ @not_before.setter
+ def not_before(self, value):
+ if isinstance(value, int) is False:
+ raise TypeError("Config parameter not-before must be an integer")
+ else:
+ self._not_before = value
+
+ @property
+ def not_after(self):
+ return self._not_after
+
+ @not_after.setter
+ def not_after(self, value):
+ if isinstance(value, int) is False:
+ raise TypeError("Config parameter not-after must be an integer")
+ else:
+ self._not_after = value
+
+ @property
+ def serial_num(self):
+ return self._serial_num
+
+ @serial_num.setter
+ def serial_num(self, value):
+ if isinstance(value, int) is False:
+ raise TypeError("Config parameter serial-num must be an integer")
+ else:
+ self._serial_num = value
+
+ def _parse_config(self):
+ self._parser.read(self._config_filename, encoding='cp1250')
+
+ if self._parser.has_option(self._section_name, 'issuer-name'):
+ self.issuer_name = self._parser.get(self._section_name, 'issuer-name')
+
+ if self._parser.has_option(self._section_name, 'subject-name'):
+ self.subject_name = self._parser.get(self._section_name, 'subject-name')
+
+ if self._parser.has_option(self._section_name, 'not-before'):
+ self.not_before = self._parser.getint(self._section_name, 'not-before')
+
+ if self._parser.has_option(self._section_name, 'not-after'):
+ self.not_after = self._parser.getint(self._section_name, 'not-after')
+
+ if self._parser.has_option(self._section_name, 'serial-num'):
+ self.serial_num = self._parser.getint(self._section_name, 'serial-num')
diff --git a/tools/alif/utils/config.py b/tools/alif/utils/config.py
index d269767bd..a7f48ccd5 100755
--- a/tools/alif/utils/config.py
+++ b/tools/alif/utils/config.py
@@ -1,204 +1,204 @@
-import sys
-import json
-from json.decoder import JSONDecodeError
-
-# Define Version constant for each separate tool
-# 0.06.000 added package and offset params
-TOOL_VERSION = "0.07.000"
-
-# DB files
-CONFIG_FILE = 'utils/global-cfg.db'
-DEVICE_DB_FILE = 'utils/devicesDB.db'
-FEATURES_DB_FILE = 'utils/featuresDB.db'
-HASHES_DB_FILE = 'utils/hashesDB.db'
-
-
-EXIT_WITH_ERROR = 1
-
-# Device Part# and Revision
-DEVICE_PART_NUMBER = ''
-DEVICE_REVISION = ''
-DEVICE_FAMILY = ''
-DEVICE_FEATURE_SET = ''
-DEVICE_PACKAGE = ''
-DEVICE_REV_PACKAGE_EXT = ''
-DEVICE_REV_BAUD_RATE = ''
-DEVICE_OFFSET = ''
-
-# Hashes
-HASHES_DB = []
-
-# MRAM Access Interface
-MRAM_BURN_INTERFACE = ''
-
-# JTAG Adapter
-JTAG_ADAPTER = ''
-
-# memory defines for Alif/OEM MRAM Addresses
-MRAM_BASE_ADDRESS = 0x00
-ALIF_BASE_ADDRESS = 0x00
-APP_BASE_ADDRESS = 0x00
-# memory defines for Alif/OEM MRAM Sizes
-MRAM_SIZE = 0x00
-ALIF_MRAM_SIZE = 0x00
-APP_MRAM_SIZE = 0x00
-
-# Hardcoded values
-APP_OFFSET = 0x00
-
-# parameters by architecture
-SERAM_BANKS = 0
-
-# ALIF TOC POINTER SIZE (pointers to)
-ALIF_TOC_POINTER_SIZE = 16
-
-def read_global_config(file):
-
-# print("Opening file %s" % file);
- f = open(file, 'r')
- try:
- cfg = json.load(f)
-
- except JSONDecodeError as e:
- print("ERROR in JSON file.")
- print(str(e))
- sys.exit(EXIT_WITH_ERROR)
-
- except ValueError as v:
- print("ERROR in JSON file:")
- print(str(v))
- sys.exit(EXIT_WITH_ERROR)
-
- except:
- print("ERROR: Unknown error loading JSON file")
- sys.exit(EXIT_WITH_ERROR)
-
- f.close()
- return cfg
-
-def save_global_config(devDescription, devRevision):
- with open(CONFIG_FILE, 'r', encoding='utf-8') as f:
- cfg = json.load(f)
-
- with open(CONFIG_FILE, 'w', encoding='utf-8') as f:
- cfg['DEVICE']['Part#'] = devDescription
- cfg['DEVICE']['Revision'] = devRevision
- json.dump(cfg, f, ensure_ascii=False, indent=4)
-
-
-def checkAttribute(cfg, attribute):
- try:
- test = cfg[attribute]
-
- except KeyError as e:
- print('Parameter ' + str(e) + ' is not configured')
- sys.exit(EXIT_WITH_ERROR)
-
- except:
- print('General error checking attribute ' + attribute)
- sys.exit(EXIT_WITH_ERROR)
-
-def getPartDescription(devPartNumber):
- # read devices DB
- db = read_global_config(DEVICE_DB_FILE)
- partDescription = ''
- for desc in db:
- if devPartNumber in desc:
- partDescription = desc
- break
-
- if partDescription == '':
- print("We couldn't find the " + devPartNumber + " in the available parts")
- sys.exit(EXIT_WITH_ERROR)
-
- return partDescription
-
-def load_device_config(devDescription, devRevision):
- global DEVICE_PART_NUMBER
- global DEVICE_REVISION
- global DEVICE_FAMILY
- global DEVICE_FEATURE_SET
- global DEVICE_PACKAGE
- global DEVICE_REV_PACKAGE_EXT
- global DEVICE_REV_BAUD_RATE
- global DEVICE_OFFSET
- global MRAM_BASE_ADDRESS
- global ALIF_BASE_ADDRESS
- global APP_BASE_ADDRESS
- global MRAM_SIZE
- global ALIF_MRAM_SIZE
- global APP_MRAM_SIZE
- global SERAM_BANKS
-
- # assign Part#/Rev according detection
- DEVICE_PART_NUMBER = devDescription
- DEVICE_REVISION = devRevision
-
- # read devices DB
- db = read_global_config(DEVICE_DB_FILE)
-
- # read architectures DB
- features = read_global_config(FEATURES_DB_FILE)
-
- DEVICE_FAMILY = db[devDescription]['family']
- DEVICE_FEATURE_SET = db[devDescription]['featureSet']
- DEVICE_PACKAGE = db[devDescription]['package']
-
- MRAM_BASE_ADDRESS = int(features[db[devDescription]['featureSet']]['mram_base'],16)
- REVISIONS = features[db[devDescription]['featureSet']]['revisions']
- DEVICE_REV_PACKAGE_EXT = features[db[devDescription]['featureSet']]['rev_package_ext']
- DEVICE_REV_BAUD_RATE = features[db[devDescription]['featureSet']]['rev_baud_rate']
- DEVICE_OFFSET = db[devDescription]['offset']
-
- # validate configuration
- if devRevision not in REVISIONS:
- print('Revision is invalid!')
- sys.exit(EXIT_WITH_ERROR)
-
-
- # set MRAM Size (same for all revisions)
- MRAM_SIZE = int(features[db[devDescription]['featureSet']]['mram_total'], 16)
- SERAM_BANKS = features[db[devDescription]['featureSet']]['seram_banks']
-
- # relative addresses (offsets)
- alif_offset = int(db[devDescription]['alif_offset'], 16)
- app_size = int(db[devDescription]['app_size'], 16) - APP_OFFSET
-
- # calculate
- ALIF_BASE_ADDRESS = MRAM_BASE_ADDRESS + alif_offset
- APP_BASE_ADDRESS = MRAM_BASE_ADDRESS + APP_OFFSET
- ALIF_MRAM_SIZE = MRAM_SIZE - alif_offset - ALIF_TOC_POINTER_SIZE
- APP_MRAM_SIZE = app_size
-
-
-def load_global_config():
- global DEVICE_PART_NUMBER
- global DEVICE_REVISION
- global MRAM_BURN_INTERFACE
- global JTAG_ADAPTER
- global HASHES_DB
-
- cfg = read_global_config(CONFIG_FILE)
-
- # validate configuration parameters
- # check parameter is configured...
- checkAttribute(cfg['DEVICE'], 'Revision')
-
- # read hashes DB
- hashes = read_global_config(HASHES_DB_FILE)
-
- DEVICE_PART_NUMBER = cfg['DEVICE']['Part#']
- DEVICE_REVISION = cfg['DEVICE']['Revision']
-
- # load rest of config params
- load_device_config(DEVICE_PART_NUMBER, DEVICE_REVISION)
-
- # retrieve DEV Environments
- HASHES_DB = hashes
-
- # set MRAM BURNER Access Interface
- MRAM_BURN_INTERFACE = cfg['MRAM-BURNER']['Interface']
-
- # set JTAG Adapter
- JTAG_ADAPTER = cfg['MRAM-BURNER']['Jtag-adapter']
-
+import sys
+import json
+from json.decoder import JSONDecodeError
+
+# Define Version constant for each separate tool
+# 0.06.000 added package and offset params
+TOOL_VERSION = "0.07.000"
+
+# DB files
+CONFIG_FILE = 'utils/global-cfg.db'
+DEVICE_DB_FILE = 'utils/devicesDB.db'
+FEATURES_DB_FILE = 'utils/featuresDB.db'
+HASHES_DB_FILE = 'utils/hashesDB.db'
+
+
+EXIT_WITH_ERROR = 1
+
+# Device Part# and Revision
+DEVICE_PART_NUMBER = ''
+DEVICE_REVISION = ''
+DEVICE_FAMILY = ''
+DEVICE_FEATURE_SET = ''
+DEVICE_PACKAGE = ''
+DEVICE_REV_PACKAGE_EXT = ''
+DEVICE_REV_BAUD_RATE = ''
+DEVICE_OFFSET = ''
+
+# Hashes
+HASHES_DB = []
+
+# MRAM Access Interface
+MRAM_BURN_INTERFACE = ''
+
+# JTAG Adapter
+JTAG_ADAPTER = ''
+
+# memory defines for Alif/OEM MRAM Addresses
+MRAM_BASE_ADDRESS = 0x00
+ALIF_BASE_ADDRESS = 0x00
+APP_BASE_ADDRESS = 0x00
+# memory defines for Alif/OEM MRAM Sizes
+MRAM_SIZE = 0x00
+ALIF_MRAM_SIZE = 0x00
+APP_MRAM_SIZE = 0x00
+
+# Hardcoded values
+APP_OFFSET = 0x00
+
+# parameters by architecture
+SERAM_BANKS = 0
+
+# ALIF TOC POINTER SIZE (pointers to)
+ALIF_TOC_POINTER_SIZE = 16
+
+def read_global_config(file):
+
+# print("Opening file %s" % file);
+ f = open(file, 'r')
+ try:
+ cfg = json.load(f)
+
+ except JSONDecodeError as e:
+ print("ERROR in JSON file.")
+ print(str(e))
+ sys.exit(EXIT_WITH_ERROR)
+
+ except ValueError as v:
+ print("ERROR in JSON file:")
+ print(str(v))
+ sys.exit(EXIT_WITH_ERROR)
+
+ except:
+ print("ERROR: Unknown error loading JSON file")
+ sys.exit(EXIT_WITH_ERROR)
+
+ f.close()
+ return cfg
+
+def save_global_config(devDescription, devRevision):
+ with open(CONFIG_FILE, 'r', encoding='utf-8') as f:
+ cfg = json.load(f)
+
+ with open(CONFIG_FILE, 'w', encoding='utf-8') as f:
+ cfg['DEVICE']['Part#'] = devDescription
+ cfg['DEVICE']['Revision'] = devRevision
+ json.dump(cfg, f, ensure_ascii=False, indent=4)
+
+
+def checkAttribute(cfg, attribute):
+ try:
+ test = cfg[attribute]
+
+ except KeyError as e:
+ print('Parameter ' + str(e) + ' is not configured')
+ sys.exit(EXIT_WITH_ERROR)
+
+ except:
+ print('General error checking attribute ' + attribute)
+ sys.exit(EXIT_WITH_ERROR)
+
+def getPartDescription(devPartNumber):
+ # read devices DB
+ db = read_global_config(DEVICE_DB_FILE)
+ partDescription = ''
+ for desc in db:
+ if devPartNumber in desc:
+ partDescription = desc
+ break
+
+ if partDescription == '':
+ print("We couldn't find the " + devPartNumber + " in the available parts")
+ sys.exit(EXIT_WITH_ERROR)
+
+ return partDescription
+
+def load_device_config(devDescription, devRevision):
+ global DEVICE_PART_NUMBER
+ global DEVICE_REVISION
+ global DEVICE_FAMILY
+ global DEVICE_FEATURE_SET
+ global DEVICE_PACKAGE
+ global DEVICE_REV_PACKAGE_EXT
+ global DEVICE_REV_BAUD_RATE
+ global DEVICE_OFFSET
+ global MRAM_BASE_ADDRESS
+ global ALIF_BASE_ADDRESS
+ global APP_BASE_ADDRESS
+ global MRAM_SIZE
+ global ALIF_MRAM_SIZE
+ global APP_MRAM_SIZE
+ global SERAM_BANKS
+
+ # assign Part#/Rev according detection
+ DEVICE_PART_NUMBER = devDescription
+ DEVICE_REVISION = devRevision
+
+ # read devices DB
+ db = read_global_config(DEVICE_DB_FILE)
+
+ # read architectures DB
+ features = read_global_config(FEATURES_DB_FILE)
+
+ DEVICE_FAMILY = db[devDescription]['family']
+ DEVICE_FEATURE_SET = db[devDescription]['featureSet']
+ DEVICE_PACKAGE = db[devDescription]['package']
+
+ MRAM_BASE_ADDRESS = int(features[db[devDescription]['featureSet']]['mram_base'],16)
+ REVISIONS = features[db[devDescription]['featureSet']]['revisions']
+ DEVICE_REV_PACKAGE_EXT = features[db[devDescription]['featureSet']]['rev_package_ext']
+ DEVICE_REV_BAUD_RATE = features[db[devDescription]['featureSet']]['rev_baud_rate']
+ DEVICE_OFFSET = db[devDescription]['offset']
+
+ # validate configuration
+ if devRevision not in REVISIONS:
+ print('Revision is invalid!')
+ sys.exit(EXIT_WITH_ERROR)
+
+
+ # set MRAM Size (same for all revisions)
+ MRAM_SIZE = int(features[db[devDescription]['featureSet']]['mram_total'], 16)
+ SERAM_BANKS = features[db[devDescription]['featureSet']]['seram_banks']
+
+ # relative addresses (offsets)
+ alif_offset = int(db[devDescription]['alif_offset'], 16)
+ app_size = int(db[devDescription]['app_size'], 16) - APP_OFFSET
+
+ # calculate
+ ALIF_BASE_ADDRESS = MRAM_BASE_ADDRESS + alif_offset
+ APP_BASE_ADDRESS = MRAM_BASE_ADDRESS + APP_OFFSET
+ ALIF_MRAM_SIZE = MRAM_SIZE - alif_offset - ALIF_TOC_POINTER_SIZE
+ APP_MRAM_SIZE = app_size
+
+
+def load_global_config():
+ global DEVICE_PART_NUMBER
+ global DEVICE_REVISION
+ global MRAM_BURN_INTERFACE
+ global JTAG_ADAPTER
+ global HASHES_DB
+
+ cfg = read_global_config(CONFIG_FILE)
+
+ # validate configuration parameters
+ # check parameter is configured...
+ checkAttribute(cfg['DEVICE'], 'Revision')
+
+ # read hashes DB
+ hashes = read_global_config(HASHES_DB_FILE)
+
+ DEVICE_PART_NUMBER = cfg['DEVICE']['Part#']
+ DEVICE_REVISION = cfg['DEVICE']['Revision']
+
+ # load rest of config params
+ load_device_config(DEVICE_PART_NUMBER, DEVICE_REVISION)
+
+ # retrieve DEV Environments
+ HASHES_DB = hashes
+
+ # set MRAM BURNER Access Interface
+ MRAM_BURN_INTERFACE = cfg['MRAM-BURNER']['Interface']
+
+ # set JTAG Adapter
+ JTAG_ADAPTER = cfg['MRAM-BURNER']['Jtag-adapter']
+
diff --git a/tools/alif/utils/device_config.py b/tools/alif/utils/device_config.py
index bde507ce4..9c6578030 100755
--- a/tools/alif/utils/device_config.py
+++ b/tools/alif/utils/device_config.py
@@ -1,293 +1,293 @@
-#!/usr/bin/env python3
-
-import sys
-import os
-import struct
-from utils.config import read_global_config
-import utils.firewall
-from utils.firewall import firewall_json_to_bin
-import utils.pinmux
-from printInfo import *
-
-EXIT_WITH_ERROR = 1
-
-DEVICE_CONFIG_PIN_MUX = 0x01
-DEVICE_CONFIG_PIN_PROTECTION = 0x02
-DEVICE_CONFIG_EVENT_ROUTING = 0x03
-DEVICE_CONFIG_INTERRUPT_MAP = 0x04
-DEVICE_CONFIG_FIREWALL = 0x05
-DEVICE_CONFIG_WOUNDING = 0x06
-DEVICE_CONFIG_CLOCKS = 0x07
-DEVICE_CONFIG_REGISTER_SETTINGS = 0x08
-DEVICE_CONFIG_MISCELLANEOUS = 0x09
-DEVICE_CONFIG_METADATA = 0x0A
-DEVICE_CONFIG_END_OF_LIST = 0xFE
-
-HEADER_SIZE_MASK = 0x00FFFFFF
-
-VALID_SECTIONS = [
- "metadata",
- "firewall",
- "clocks",
- "pinmux",
- "wounding",
- "register_settings",
- "miscellaneous"
-]
-
-misc_settings_headers = {
- 'LFXO_CAP_CTRL' : '0x00000001', # <16 bits setting type> <16 bits setting size in words>
- 'LFXO_GM_CTRL' : '0x00010001',
- 'HFXO_CAP_CTRL' : '0x00020001',
- 'HFXO_PFET_GM_CTRL' : '0x00030001',
- 'HFXO_NFET_GM_CTRL' : '0x00040001',
- 'SE_BOOT_INFO' : '0x00050001'
-# 'ISP_MAINTENANCE_SUPPORT' : '0x00060001',
-# 'FW_RUNTIME_CFG' : '0x00070001',
-# 'PINMUX_RUNTIME_CFG' : '0x00080001',
-# 'CLOCK_RUNTIME_CFG' : '0x00090001'
-}
-
-metadata_settings_headers = {
- 'HFXO_PRESENT' : '0x00000001', # <16 bits setting type> <16 bits setting size in words>
- 'HFXO_FREQUENCY_CFG' : '0x00010001',
- 'LFXO_PRESENT' : '0x00020001',
- 'LFXO_FREQUENCY' : '0x00030001'
-}
-
-# HFXO frequency config data format:
-# 3 bits 0 (unsused)
-# 1 bit 'divider enable' flag
-# 1 bit 0 (unused)
-# 7 bits PLL multiplier integer (N) part
-# 20 bits PLL multiplier fractional (f) part
-#
-hfxo_frequency_cfg = {
- 38400000 : '0x17D00000',
- 32000000 : '0x04B00000',
- 25000000 : '0x06000000',
- 24000000 : '0x06400000',
-}
-
-hfxo_frequency_cfg_spark = {
- 38400000 : '0x11900000',
-}
-
-lfxo_frequency = {
- 32768 : 32768,
- 32000 : 32000
-}
-
-
-def validateSections(sections, file):
- for sec in sections:
- if sec not in VALID_SECTIONS:
- # Don't terminate the script, just print than an unsupported section was found
- print('[WARN] Unsupported section "' + sec + '" found in file ' + file)
- #sys.exit(EXIT_WITH_ERROR)
-
-def createBinary(file):
-
- try:
- f = open(file, 'wb')
- except:
- print(sys.exc_info()[0])
- print('[ERROR] creating Device Configuration binary')
- sys.exit(EXIT_WITH_ERROR)
-
- return f
-
-def closeBinary(f):
- f.close()
-
-def writeBinary(f, data):
- f.write(data)
-
-def processMetadata(configuration):
-
- data = bytearray()
- for sec in configuration:
- if sec != "external_clock_sources":
- continue
-
- for setting in configuration[sec]:
- if "id" not in setting:
- continue
-
- if setting["id"] == "OSC_HFXO":
- if "enabled" in setting:
- enabled = 0x1 if setting["enabled"] else 0x0
-
- header = metadata_settings_headers.get('HFXO_PRESENT')
- data += bytes(int(header, 16).to_bytes(4, 'little'))
- data += bytes(enabled.to_bytes(4, 'little'))
-
- if "frequency" in setting:
- if utils.config.DEVICE_FEATURE_SET == 'Spark':
- frequency_cfg = hfxo_frequency_cfg_spark.get(setting['frequency'])
- else:
- frequency_cfg = hfxo_frequency_cfg.get(setting['frequency'])
- if frequency_cfg is None:
- print("[ERROR] Unsupported HFXO frequency:", setting['frequency'])
- sys.exit(EXIT_WITH_ERROR)
-
- header = metadata_settings_headers.get('HFXO_FREQUENCY_CFG')
- data += bytes(int(header, 16).to_bytes(4, 'little'))
- printInfo("HFXO frequency config:", frequency_cfg)
- data += bytes(int(frequency_cfg, 16).to_bytes(4, 'little'))
-
- if setting["id"] == "OSC_LFXO":
- if "enabled" in setting:
- enabled = 0x1 if setting["enabled"] else 0x0
-
- header = metadata_settings_headers.get('LFXO_PRESENT')
- data += bytes(int(header, 16).to_bytes(4, 'little'))
- data += bytes(enabled.to_bytes(4, 'little'))
-
- if "frequency" in setting:
- frequency = lfxo_frequency.get(setting['frequency'])
- if frequency is None:
- print("[ERROR] Unsupported LFXO frequency:", setting['frequency'])
- sys.exit(EXIT_WITH_ERROR)
-
- header = metadata_settings_headers.get('LFXO_FREQUENCY')
- data += bytes(int(header, 16).to_bytes(4, 'little'))
- printInfo("LFXO frequency:", frequency)
- # LFXO frequency table is decimal
- data += bytes(frequency.to_bytes(4, 'little'))
-
- printInfo("XTAL data:", data)
- return data
-
-def processChangeSets(changeSets):
- printInfo('Processing ChangeSets')
- data = bytearray()
- for changeSet in changeSets:
- data += bytes(int(changeSet['address'], 16).to_bytes(4, 'little'))
- data += bytes(int(changeSet['mask'], 16).to_bytes(4, 'little'))
- data += bytes(int(changeSet['value'], 16).to_bytes(4, 'little'))
-
- return data
-
-def processRegisterSettings(configuration):
- printInfo("Process Register_Settings")
- data = bytearray()
- for sec in configuration:
- if sec == 'change_sets':
- data = processChangeSets(configuration[sec])
- printInfo("register_settings: ", data)
- return data
-
-def processClocks(configuration):
- printInfo("Process Clocks")
- data = bytearray()
- for sec in configuration:
- if sec == 'change_sets':
- data = processChangeSets(configuration[sec])
- # TODO: process other clock settings
- printInfo("clocks: ", data)
- return data
-
-def processPinMux(configuration):
- printInfo("Process PinMux")
- data = utils.pinmux.json_to_bin(configuration)
- return bytearray(data)
-
-def processFirewall(configuration, is_icv):
- printInfo("Process Firewall")
- utils.firewall.OUTPUT_FILE = 'build/images/fw_temp.bin'
- firewall_json_to_bin(configuration, is_icv)
-
-def processWounding(configuration):
- printInfo("Process Wounding")
-
- printInfo("Wounding Data: ", configuration)
-
- num = int(configuration, 0)
- data = num.to_bytes(4,byteorder='little')
-
- return bytearray(data)
-
-def processMiscellaneous(configuration):
- printInfo("Process Miscellaneous")
-
- data = bytearray()
- for sec in configuration:
- if ('id' not in sec) or ('value' not in sec):
- continue
- if not sec['id'] in misc_settings_headers:
- printInfo("[WARN] SE not supported: ", sec['id'])
- continue
- header = misc_settings_headers.get(sec['id'])
- data += bytes(int(header, 16).to_bytes(4, 'little'))
- data += bytes(int(sec['value']).to_bytes(4, 'little'))
-
- return data
-
-def gen_device_config(file, is_icv):
-
- cfg = read_global_config('build/config/' + file)
- validateSections(cfg, file) #request from SE-1938
- binFile = file[:-5] + '.bin'
- f = createBinary('build/images/' + binFile)
- for sec in cfg:
- printInfo("Create area for: " + sec)
-
- if sec == "metadata":
- obj = processMetadata(cfg[sec])
- header = (DEVICE_CONFIG_METADATA<<24) | (len(obj) & HEADER_SIZE_MASK)
- writeBinary(f, struct.pack("I", header))
- writeBinary(f, obj)
-
- if sec == "wounding":
- obj = processWounding(cfg[sec])
- header = (DEVICE_CONFIG_WOUNDING<<24) | (len(obj) & HEADER_SIZE_MASK)
- writeBinary(f, struct.pack("I", header))
- writeBinary(f, obj)
-
- if sec == "pinmux":
- obj = processPinMux(cfg[sec])
- header = (DEVICE_CONFIG_PIN_MUX<<24) | (len(obj) & HEADER_SIZE_MASK)
- writeBinary(f, struct.pack("I", header))
- writeBinary(f, obj)
-
- if sec == "clocks":
- obj = processClocks(cfg[sec])
- header = (DEVICE_CONFIG_CLOCKS<<24) | (len(obj) & HEADER_SIZE_MASK)
- writeBinary(f, struct.pack("I", header))
- writeBinary(f, obj)
-
- if sec == "register_settings":
- obj = processClocks(cfg[sec])
- header = (DEVICE_CONFIG_REGISTER_SETTINGS<<24) | (len(obj) & HEADER_SIZE_MASK)
- writeBinary(f, struct.pack("I", header))
- writeBinary(f, obj)
-
- if sec == "firewall":
- processFirewall(cfg[sec], is_icv)
-
- # checking the Alif TOC Package size
- try:
- fsize = os.path.getsize(utils.firewall.OUTPUT_FILE)
- printInfo("Firewall binary size: " + str(fsize) + " bytes")
- except:
- print(sys.exc_info()[0])
- print("[ERROR] Veryfing Firewall binary size")
- sys.exit(EXIT_WITH_ERROR)
-
- header = (DEVICE_CONFIG_FIREWALL<<24) | (fsize & HEADER_SIZE_MASK)
- writeBinary(f, struct.pack("I", header))
-
- # reading the file to include it in Device Config. binary
- with open(utils.firewall.OUTPUT_FILE, 'rb') as bin_file:
- writeBinary(f, bin_file.read())
-
- if sec == "miscellaneous":
- obj = processMiscellaneous(cfg[sec])
- header = (DEVICE_CONFIG_MISCELLANEOUS<<24) | (len(obj) & HEADER_SIZE_MASK)
- writeBinary(f, struct.pack("I", header))
- writeBinary(f, obj)
-
- tail = DEVICE_CONFIG_END_OF_LIST<<24
- writeBinary(f, struct.pack("I", tail))
- closeBinary(f)
+#!/usr/bin/env python3
+
+import sys
+import os
+import struct
+from utils.config import read_global_config
+import utils.firewall
+from utils.firewall import firewall_json_to_bin
+import utils.pinmux
+from printInfo import *
+
+EXIT_WITH_ERROR = 1
+
+DEVICE_CONFIG_PIN_MUX = 0x01
+DEVICE_CONFIG_PIN_PROTECTION = 0x02
+DEVICE_CONFIG_EVENT_ROUTING = 0x03
+DEVICE_CONFIG_INTERRUPT_MAP = 0x04
+DEVICE_CONFIG_FIREWALL = 0x05
+DEVICE_CONFIG_WOUNDING = 0x06
+DEVICE_CONFIG_CLOCKS = 0x07
+DEVICE_CONFIG_REGISTER_SETTINGS = 0x08
+DEVICE_CONFIG_MISCELLANEOUS = 0x09
+DEVICE_CONFIG_METADATA = 0x0A
+DEVICE_CONFIG_END_OF_LIST = 0xFE
+
+HEADER_SIZE_MASK = 0x00FFFFFF
+
+VALID_SECTIONS = [
+ "metadata",
+ "firewall",
+ "clocks",
+ "pinmux",
+ "wounding",
+ "register_settings",
+ "miscellaneous"
+]
+
+misc_settings_headers = {
+ 'LFXO_CAP_CTRL' : '0x00000001', # <16 bits setting type> <16 bits setting size in words>
+ 'LFXO_GM_CTRL' : '0x00010001',
+ 'HFXO_CAP_CTRL' : '0x00020001',
+ 'HFXO_PFET_GM_CTRL' : '0x00030001',
+ 'HFXO_NFET_GM_CTRL' : '0x00040001',
+ 'SE_BOOT_INFO' : '0x00050001'
+# 'ISP_MAINTENANCE_SUPPORT' : '0x00060001',
+# 'FW_RUNTIME_CFG' : '0x00070001',
+# 'PINMUX_RUNTIME_CFG' : '0x00080001',
+# 'CLOCK_RUNTIME_CFG' : '0x00090001'
+}
+
+metadata_settings_headers = {
+ 'HFXO_PRESENT' : '0x00000001', # <16 bits setting type> <16 bits setting size in words>
+ 'HFXO_FREQUENCY_CFG' : '0x00010001',
+ 'LFXO_PRESENT' : '0x00020001',
+ 'LFXO_FREQUENCY' : '0x00030001'
+}
+
+# HFXO frequency config data format:
+# 3 bits 0 (unsused)
+# 1 bit 'divider enable' flag
+# 1 bit 0 (unused)
+# 7 bits PLL multiplier integer (N) part
+# 20 bits PLL multiplier fractional (f) part
+#
+hfxo_frequency_cfg = {
+ 38400000 : '0x17D00000',
+ 32000000 : '0x04B00000',
+ 25000000 : '0x06000000',
+ 24000000 : '0x06400000',
+}
+
+hfxo_frequency_cfg_spark = {
+ 38400000 : '0x11900000',
+}
+
+lfxo_frequency = {
+ 32768 : 32768,
+ 32000 : 32000
+}
+
+
+def validateSections(sections, file):
+ for sec in sections:
+ if sec not in VALID_SECTIONS:
+ # Don't terminate the script, just print than an unsupported section was found
+ print('[WARN] Unsupported section "' + sec + '" found in file ' + file)
+ #sys.exit(EXIT_WITH_ERROR)
+
+def createBinary(file):
+
+ try:
+ f = open(file, 'wb')
+ except:
+ print(sys.exc_info()[0])
+ print('[ERROR] creating Device Configuration binary')
+ sys.exit(EXIT_WITH_ERROR)
+
+ return f
+
+def closeBinary(f):
+ f.close()
+
+def writeBinary(f, data):
+ f.write(data)
+
+def processMetadata(configuration):
+
+ data = bytearray()
+ for sec in configuration:
+ if sec != "external_clock_sources":
+ continue
+
+ for setting in configuration[sec]:
+ if "id" not in setting:
+ continue
+
+ if setting["id"] == "OSC_HFXO":
+ if "enabled" in setting:
+ enabled = 0x1 if setting["enabled"] else 0x0
+
+ header = metadata_settings_headers.get('HFXO_PRESENT')
+ data += bytes(int(header, 16).to_bytes(4, 'little'))
+ data += bytes(enabled.to_bytes(4, 'little'))
+
+ if "frequency" in setting:
+ if utils.config.DEVICE_FEATURE_SET == 'Spark':
+ frequency_cfg = hfxo_frequency_cfg_spark.get(setting['frequency'])
+ else:
+ frequency_cfg = hfxo_frequency_cfg.get(setting['frequency'])
+ if frequency_cfg is None:
+ print("[ERROR] Unsupported HFXO frequency:", setting['frequency'])
+ sys.exit(EXIT_WITH_ERROR)
+
+ header = metadata_settings_headers.get('HFXO_FREQUENCY_CFG')
+ data += bytes(int(header, 16).to_bytes(4, 'little'))
+ printInfo("HFXO frequency config:", frequency_cfg)
+ data += bytes(int(frequency_cfg, 16).to_bytes(4, 'little'))
+
+ if setting["id"] == "OSC_LFXO":
+ if "enabled" in setting:
+ enabled = 0x1 if setting["enabled"] else 0x0
+
+ header = metadata_settings_headers.get('LFXO_PRESENT')
+ data += bytes(int(header, 16).to_bytes(4, 'little'))
+ data += bytes(enabled.to_bytes(4, 'little'))
+
+ if "frequency" in setting:
+ frequency = lfxo_frequency.get(setting['frequency'])
+ if frequency is None:
+ print("[ERROR] Unsupported LFXO frequency:", setting['frequency'])
+ sys.exit(EXIT_WITH_ERROR)
+
+ header = metadata_settings_headers.get('LFXO_FREQUENCY')
+ data += bytes(int(header, 16).to_bytes(4, 'little'))
+ printInfo("LFXO frequency:", frequency)
+ # LFXO frequency table is decimal
+ data += bytes(frequency.to_bytes(4, 'little'))
+
+ printInfo("XTAL data:", data)
+ return data
+
+def processChangeSets(changeSets):
+ printInfo('Processing ChangeSets')
+ data = bytearray()
+ for changeSet in changeSets:
+ data += bytes(int(changeSet['address'], 16).to_bytes(4, 'little'))
+ data += bytes(int(changeSet['mask'], 16).to_bytes(4, 'little'))
+ data += bytes(int(changeSet['value'], 16).to_bytes(4, 'little'))
+
+ return data
+
+def processRegisterSettings(configuration):
+ printInfo("Process Register_Settings")
+ data = bytearray()
+ for sec in configuration:
+ if sec == 'change_sets':
+ data = processChangeSets(configuration[sec])
+ printInfo("register_settings: ", data)
+ return data
+
+def processClocks(configuration):
+ printInfo("Process Clocks")
+ data = bytearray()
+ for sec in configuration:
+ if sec == 'change_sets':
+ data = processChangeSets(configuration[sec])
+ # TODO: process other clock settings
+ printInfo("clocks: ", data)
+ return data
+
+def processPinMux(configuration):
+ printInfo("Process PinMux")
+ data = utils.pinmux.json_to_bin(configuration)
+ return bytearray(data)
+
+def processFirewall(configuration, is_icv):
+ printInfo("Process Firewall")
+ utils.firewall.OUTPUT_FILE = 'build/images/fw_temp.bin'
+ firewall_json_to_bin(configuration, is_icv)
+
+def processWounding(configuration):
+ printInfo("Process Wounding")
+
+ printInfo("Wounding Data: ", configuration)
+
+ num = int(configuration, 0)
+ data = num.to_bytes(4,byteorder='little')
+
+ return bytearray(data)
+
+def processMiscellaneous(configuration):
+ printInfo("Process Miscellaneous")
+
+ data = bytearray()
+ for sec in configuration:
+ if ('id' not in sec) or ('value' not in sec):
+ continue
+ if not sec['id'] in misc_settings_headers:
+ printInfo("[WARN] SE not supported: ", sec['id'])
+ continue
+ header = misc_settings_headers.get(sec['id'])
+ data += bytes(int(header, 16).to_bytes(4, 'little'))
+ data += bytes(int(sec['value']).to_bytes(4, 'little'))
+
+ return data
+
+def gen_device_config(file, is_icv):
+
+ cfg = read_global_config('build/config/' + file)
+ validateSections(cfg, file) #request from SE-1938
+ binFile = file[:-5] + '.bin'
+ f = createBinary('build/images/' + binFile)
+ for sec in cfg:
+ printInfo("Create area for: " + sec)
+
+ if sec == "metadata":
+ obj = processMetadata(cfg[sec])
+ header = (DEVICE_CONFIG_METADATA<<24) | (len(obj) & HEADER_SIZE_MASK)
+ writeBinary(f, struct.pack("I", header))
+ writeBinary(f, obj)
+
+ if sec == "wounding":
+ obj = processWounding(cfg[sec])
+ header = (DEVICE_CONFIG_WOUNDING<<24) | (len(obj) & HEADER_SIZE_MASK)
+ writeBinary(f, struct.pack("I", header))
+ writeBinary(f, obj)
+
+ if sec == "pinmux":
+ obj = processPinMux(cfg[sec])
+ header = (DEVICE_CONFIG_PIN_MUX<<24) | (len(obj) & HEADER_SIZE_MASK)
+ writeBinary(f, struct.pack("I", header))
+ writeBinary(f, obj)
+
+ if sec == "clocks":
+ obj = processClocks(cfg[sec])
+ header = (DEVICE_CONFIG_CLOCKS<<24) | (len(obj) & HEADER_SIZE_MASK)
+ writeBinary(f, struct.pack("I", header))
+ writeBinary(f, obj)
+
+ if sec == "register_settings":
+ obj = processClocks(cfg[sec])
+ header = (DEVICE_CONFIG_REGISTER_SETTINGS<<24) | (len(obj) & HEADER_SIZE_MASK)
+ writeBinary(f, struct.pack("I", header))
+ writeBinary(f, obj)
+
+ if sec == "firewall":
+ processFirewall(cfg[sec], is_icv)
+
+ # checking the Alif TOC Package size
+ try:
+ fsize = os.path.getsize(utils.firewall.OUTPUT_FILE)
+ printInfo("Firewall binary size: " + str(fsize) + " bytes")
+ except:
+ print(sys.exc_info()[0])
+ print("[ERROR] Veryfing Firewall binary size")
+ sys.exit(EXIT_WITH_ERROR)
+
+ header = (DEVICE_CONFIG_FIREWALL<<24) | (fsize & HEADER_SIZE_MASK)
+ writeBinary(f, struct.pack("I", header))
+
+ # reading the file to include it in Device Config. binary
+ with open(utils.firewall.OUTPUT_FILE, 'rb') as bin_file:
+ writeBinary(f, bin_file.read())
+
+ if sec == "miscellaneous":
+ obj = processMiscellaneous(cfg[sec])
+ header = (DEVICE_CONFIG_MISCELLANEOUS<<24) | (len(obj) & HEADER_SIZE_MASK)
+ writeBinary(f, struct.pack("I", header))
+ writeBinary(f, obj)
+
+ tail = DEVICE_CONFIG_END_OF_LIST<<24
+ writeBinary(f, struct.pack("I", tail))
+ closeBinary(f)
diff --git a/tools/alif/utils/devicesDB.db b/tools/alif/utils/devicesDB.db
index 6e60f027b..b2c727230 100755
--- a/tools/alif/utils/devicesDB.db
+++ b/tools/alif/utils/devicesDB.db
@@ -1,310 +1,310 @@
-{
- "E7 (AE722F80F55D5LS) - 5.5 MRAM / 13.5 SRAM":{
- "featureSet" : "Fusion",
- "family" : "Ensemble",
- "alif_offset" : "0x580000",
- "app_size" : "0x580000",
- "mram_size" : "5.5",
- "sram_size" : "13.5",
- "wounding" : "0x00C0FFFB",
- "package" : "SP-AE722F80F55D5LS",
- "offset" : "offset-58"
- },
- "E7 (AE722F80F55D5AS) - 5.5 MRAM / 13.5 SRAM":{
- "featureSet" : "Fusion",
- "family" : "Ensemble",
- "alif_offset" : "0x580000",
- "app_size" : "0x580000",
- "mram_size" : "5.5",
- "sram_size" : "13.5",
- "wounding" : "0x00C0FFFB",
- "package" : "SP-AE722F80F55D5AS",
- "offset" : "offset-58"
- },
- "E5 (AE512F80F55D5LS) - 5.5 MRAM / 13.5 SRAM":{
- "featureSet" : "Fusion",
- "family" : "Ensemble",
- "alif_offset" : "0x580000",
- "app_size" : "0x580000",
- "mram_size" : "5.5",
- "sram_size" : "13.5",
- "wounding" : "0x00D07FFB",
- "package" : "SP-AE512F80F55D5LS",
- "offset" : "offset-58"
- },
- "E5 (AE512F80F5582AS) - 5.5 MRAM / 8.25 SRAM":{
- "featureSet" : "Fusion",
- "family" : "Ensemble",
- "alif_offset" : "0x580000",
- "app_size" : "0x580000",
- "mram_size" : "5.5",
- "sram_size" : "8.25",
- "wounding" : "0x00D07FFB",
- "package" : "SP-AE512F80F5582AS",
- "offset" : "offset-58"
- },
- "E5 (AE512F80F55D5AS) - 5.5 MRAM / 13.5 SRAM":{
- "featureSet" : "Fusion",
- "family" : "Ensemble",
- "alif_offset" : "0x580000",
- "app_size" : "0x580000",
- "mram_size" : "5.5",
- "sram_size" : "13.5",
- "wounding" : "0x00D07FFB",
- "package" : "SP-AE512F80F55D5AS",
- "offset" : "offset-58"
- },
- "E5 (AE512F80F5582LS) - 5.5 MRAM / 8.25 SRAM":{
- "featureSet" : "Fusion",
- "family" : "Ensemble",
- "alif_offset" : "0x580000",
- "app_size" : "0x580000",
- "mram_size" : "5.5",
- "sram_size" : "8.25",
- "wounding" : "0x00D07FFB",
- "package" : "SP-AE512F80F5582LS",
- "offset" : "offset-58"
- },
- "E3 (AE302F80F55D5LE) - 5.5 MRAM / 13.5 SRAM":{
- "featureSet" : "Fusion",
- "family" : "Ensemble",
- "alif_offset" : "0x580000",
- "app_size" : "0x580000",
- "mram_size" : "5.5",
- "sram_size" : "13.5",
- "wounding" : "0x00D83FFB",
- "package" : "SP-AE302F80F55D5LE",
- "offset" : "offset-58"
- },
- "E3 (AE302F80F5582LE) - 5.5 MRAM / 8.25 SRAM":{
- "featureSet" : "Fusion",
- "family" : "Ensemble",
- "alif_offset" : "0x580000",
- "app_size" : "0x580000",
- "mram_size" : "5.5",
- "sram_size" : "8.25",
- "wounding" : "0x00D83FFB",
- "package" : "SP-AE302F80F5582LE",
- "offset" : "offset-58"
- },
- "E3 (AE302F80F55D5AE) - 5.5 MRAM / 13.5 SRAM":{
- "featureSet" : "Fusion",
- "family" : "Ensemble",
- "alif_offset" : "0x580000",
- "app_size" : "0x580000",
- "mram_size" : "5.5",
- "sram_size" : "13.5",
- "wounding" : "0x00D83FFB",
- "package" : "SP-AE302F80F55D5AE",
- "offset" : "offset-58"
- },
- "E3 (AE302F80F5582AE) - 5.5 MRAM / 8.25 SRAM":{
- "featureSet" : "Fusion",
- "family" : "Ensemble",
- "alif_offset" : "0x580000",
- "app_size" : "0x580000",
- "mram_size" : "5.5",
- "sram_size" : "8.25",
- "wounding" : "0x00D83FFB",
- "package" : "SP-AE302F80F5582AE",
- "offset" : "offset-58"
- },
- "E3 (AE302F80C1557LE) - 1.5 MRAM / 5.75 SRAM":{
- "featureSet" : "Fusion",
- "family" : "Ensemble",
- "alif_offset" : "0x180000",
- "app_size" : "0x180000",
- "mram_size" : "1.5",
- "sram_size" : "5.75",
- "wounding" : "0x00D83FEB",
- "package" : "SP-AE302F80C1557LE",
- "offset" : "offset-18"
- },
- "E3 (AE302F40C1537LE) - 1.5 MRAM / 3.75 SRAM":{
- "featureSet" : "Fusion",
- "family" : "Ensemble",
- "alif_offset" : "0x180000",
- "app_size" : "0x180000",
- "mram_size" : "1.5",
- "sram_size" : "3.75",
- "wounding" : "0x00D83FEA",
- "package" : "SP-AE302F40C1537LE",
- "offset" : "offset-18"
- },
- "E1 (AE101F4071542LH) - 1.5 MRAM / 4.5 SRAM":{
- "featureSet" : "Fusion",
- "family" : "Ensemble",
- "alif_offset" : "0x180000",
- "app_size" : "0x180000",
- "mram_size" : "1.5",
- "sram_size" : "4.5",
- "wounding" : "0x00F82B72",
- "package" : "SP-AE101F4071542LH",
- "offset" : "offset-18"
- },
- "E1C (AE1C1F4051920PH) - 1.86 MRAM / 2.0 SRAM":{
- "featureSet" : "Spark",
- "family" : "Ensemble",
- "alif_offset" : "0x1DD000",
- "app_size" : "0x1DD000",
- "mram_size" : "1.86",
- "sram_size" : "2.0",
- "wounding" : "0x00F80B12",
- "package" : "SP-AE1C1F4051920PH",
- "offset" : "offset-1D"
- },
- "E1C (AE1C1F4051920HH) - 1.86 MRAM / 2.0 SRAM":{
- "featureSet" : "Spark",
- "family" : "Ensemble",
- "alif_offset" : "0x1DD000",
- "app_size" : "0x1DD000",
- "mram_size" : "1.86",
- "sram_size" : "2.0",
- "wounding" : "0x00F80B12",
- "package" : "SP-AE1C1F4051920HH",
- "offset" : "offset-1D"
- },
- "E1C (AE1C1F40319205H) - 1.86 MRAM / 2.0 SRAM":{
- "featureSet" : "Spark",
- "family" : "Ensemble",
- "alif_offset" : "0x1DD000",
- "app_size" : "0x1DD000",
- "mram_size" : "1.86",
- "sram_size" : "2.0",
- "wounding" : "0x00F80212",
- "package" : "SP-AE1C1F40319205H",
- "offset" : "offset-1D"
- },
- "E1C (AE1C1F1041010PH) - 1.0 MRAM / 1.0 SRAM":{
- "featureSet" : "Spark",
- "family" : "Ensemble",
- "alif_offset" : "0x100000",
- "app_size" : "0x100000",
- "mram_size" : "1.0",
- "sram_size" : "1.0",
- "wounding" : "0x00F80000",
- "package" : "SP-AE1C1F1041010PH",
- "offset" : "offset-10"
- },
- "E1C (AE1C1F1041010HH) - 1.0 MRAM / 1.0 SRAM":{
- "featureSet" : "Spark",
- "family" : "Ensemble",
- "alif_offset" : "0x100000",
- "app_size" : "0x100000",
- "mram_size" : "1.0",
- "sram_size" : "1.0",
- "wounding" : "0x00F80000",
- "package" : "SP-AE1C1F1041010HH",
- "offset" : "offset-10"
- },
- "E1C (AE1C1F10410105H) - 1.0 MRAM / 1.0 SRAM":{
- "featureSet" : "Spark",
- "family" : "Ensemble",
- "alif_offset" : "0x100000",
- "app_size" : "0x100000",
- "mram_size" : "1.0",
- "sram_size" : "1.0",
- "wounding" : "0x00F80000",
- "package" : "SP-AE1C1F10410105H",
- "offset" : "offset-10"
- },
- "E1C (AE1C1F1040505PH) - 0.5 MRAM / 0.5 SRAM":{
- "featureSet" : "Spark",
- "family" : "Ensemble",
- "alif_offset" : "0x080000",
- "app_size" : "0x080000",
- "mram_size" : "0.5",
- "sram_size" : "0.5",
- "wounding" : "0x00F80000",
- "package" : "SP-AE1C1F1040505PH",
- "offset" : "offset-08"
- },
- "E1C (AE1C1F1040505HH) - 0.5 MRAM / 0.5 SRAM":{
- "featureSet" : "Spark",
- "family" : "Ensemble",
- "alif_offset" : "0x080000",
- "app_size" : "0x080000",
- "mram_size" : "0.5",
- "sram_size" : "0.5",
- "wounding" : "0x00F80000",
- "package" : "SP-AE1C1F1040505HH",
- "offset" : "offset-08"
- },
- "E1C (AE1C1F10405055H) - 0.5 MRAM / 0.5 SRAM":{
- "featureSet" : "Spark",
- "family" : "Ensemble",
- "alif_offset" : "0x080000",
- "app_size" : "0x080000",
- "mram_size" : "0.5",
- "sram_size" : "0.5",
- "wounding" : "0x00F80000",
- "package" : "SP-AE1C1F10405055H",
- "offset" : "offset-08"
- },
-"B1 (AB1C1F4M51820PH) - 1.8 MRAM / 2.0 SRAM":{
- "featureSet" : "Spark",
- "family" : "Balletto",
- "alif_offset" : "0x1CD000",
- "app_size" : "0x1CD000",
- "mram_size" : "1.8",
- "sram_size" : "2.0",
- "wounding" : "0x00F00B12",
- "package" : "SP-AB1C1F4M51820PH",
- "offset" : "offset-1C"
- },
- "B1 (AB1C1F4M51820HH) - 1.8 MRAM / 2.0 SRAM":{
- "featureSet" : "Spark",
- "family" : "Balletto",
- "alif_offset" : "0x1CD000",
- "app_size" : "0x1CD000",
- "mram_size" : "1.8",
- "sram_size" : "2.0",
- "wounding" : "0x00F00B12",
- "package" : "SP-AB1C1F4M51820HH",
- "offset" : "offset-1C"
- },
- "B1 (AB1C1F1M41820PH) - 1.8 MRAM / 2.0 SRAM":{
- "featureSet" : "Spark",
- "family" : "Balletto",
- "alif_offset" : "0x1CD000",
- "app_size" : "0x1CD000",
- "mram_size" : "1.8",
- "sram_size" : "2.0",
- "wounding" : "0x00F00000",
- "package" : "SP-AB1C1F1M41820PH",
- "offset" : "offset-1C"
- },
-"B1 (AB1C1F1M41820HH) - 1.8 MRAM / 2.0 SRAM":{
- "featureSet" : "Spark",
- "family" : "Balletto",
- "alif_offset" : "0x1CD000",
- "app_size" : "0x1CD000",
- "mram_size" : "1.8",
- "sram_size" : "2.0",
- "wounding" : "0x00F00000",
- "package" : "SP-AB1C1F1M41820HH",
- "offset" : "offset-1C"
- },
-"B1 (AB1C1F1M41010PH) - 1.0 MRAM / 1.0 SRAM":{
- "featureSet" : "Spark",
- "family" : "Balletto",
- "alif_offset" : "0x100000",
- "app_size" : "0x100000",
- "mram_size" : "1.0",
- "sram_size" : "1.0",
- "wounding" : "0x00F00000",
- "package" : "SP-AB1C1F1M41010PH",
- "offset" : "offset-10"
- },
-"B1 (AB1C1F1M41010HH) - 1.0 MRAM / 1.0 SRAM":{
- "featureSet" : "Spark",
- "family" : "Balletto",
- "alif_offset" : "0x100000",
- "app_size" : "0x100000",
- "mram_size" : "1.0",
- "sram_size" : "1.0",
- "wounding" : "0x00F00000",
- "package" : "SP-AB1C1F1M41010HH",
- "offset" : "offset-10"
- }
-}
+{
+ "E7 (AE722F80F55D5LS) - 5.5 MRAM / 13.5 SRAM":{
+ "featureSet" : "Fusion",
+ "family" : "Ensemble",
+ "alif_offset" : "0x580000",
+ "app_size" : "0x580000",
+ "mram_size" : "5.5",
+ "sram_size" : "13.5",
+ "wounding" : "0x00C0FFFB",
+ "package" : "SP-AE722F80F55D5LS",
+ "offset" : "offset-58"
+ },
+ "E7 (AE722F80F55D5AS) - 5.5 MRAM / 13.5 SRAM":{
+ "featureSet" : "Fusion",
+ "family" : "Ensemble",
+ "alif_offset" : "0x580000",
+ "app_size" : "0x580000",
+ "mram_size" : "5.5",
+ "sram_size" : "13.5",
+ "wounding" : "0x00C0FFFB",
+ "package" : "SP-AE722F80F55D5AS",
+ "offset" : "offset-58"
+ },
+ "E5 (AE512F80F55D5LS) - 5.5 MRAM / 13.5 SRAM":{
+ "featureSet" : "Fusion",
+ "family" : "Ensemble",
+ "alif_offset" : "0x580000",
+ "app_size" : "0x580000",
+ "mram_size" : "5.5",
+ "sram_size" : "13.5",
+ "wounding" : "0x00D07FFB",
+ "package" : "SP-AE512F80F55D5LS",
+ "offset" : "offset-58"
+ },
+ "E5 (AE512F80F5582AS) - 5.5 MRAM / 8.25 SRAM":{
+ "featureSet" : "Fusion",
+ "family" : "Ensemble",
+ "alif_offset" : "0x580000",
+ "app_size" : "0x580000",
+ "mram_size" : "5.5",
+ "sram_size" : "8.25",
+ "wounding" : "0x00D07FFB",
+ "package" : "SP-AE512F80F5582AS",
+ "offset" : "offset-58"
+ },
+ "E5 (AE512F80F55D5AS) - 5.5 MRAM / 13.5 SRAM":{
+ "featureSet" : "Fusion",
+ "family" : "Ensemble",
+ "alif_offset" : "0x580000",
+ "app_size" : "0x580000",
+ "mram_size" : "5.5",
+ "sram_size" : "13.5",
+ "wounding" : "0x00D07FFB",
+ "package" : "SP-AE512F80F55D5AS",
+ "offset" : "offset-58"
+ },
+ "E5 (AE512F80F5582LS) - 5.5 MRAM / 8.25 SRAM":{
+ "featureSet" : "Fusion",
+ "family" : "Ensemble",
+ "alif_offset" : "0x580000",
+ "app_size" : "0x580000",
+ "mram_size" : "5.5",
+ "sram_size" : "8.25",
+ "wounding" : "0x00D07FFB",
+ "package" : "SP-AE512F80F5582LS",
+ "offset" : "offset-58"
+ },
+ "E3 (AE302F80F55D5LE) - 5.5 MRAM / 13.5 SRAM":{
+ "featureSet" : "Fusion",
+ "family" : "Ensemble",
+ "alif_offset" : "0x580000",
+ "app_size" : "0x580000",
+ "mram_size" : "5.5",
+ "sram_size" : "13.5",
+ "wounding" : "0x00D83FFB",
+ "package" : "SP-AE302F80F55D5LE",
+ "offset" : "offset-58"
+ },
+ "E3 (AE302F80F5582LE) - 5.5 MRAM / 8.25 SRAM":{
+ "featureSet" : "Fusion",
+ "family" : "Ensemble",
+ "alif_offset" : "0x580000",
+ "app_size" : "0x580000",
+ "mram_size" : "5.5",
+ "sram_size" : "8.25",
+ "wounding" : "0x00D83FFB",
+ "package" : "SP-AE302F80F5582LE",
+ "offset" : "offset-58"
+ },
+ "E3 (AE302F80F55D5AE) - 5.5 MRAM / 13.5 SRAM":{
+ "featureSet" : "Fusion",
+ "family" : "Ensemble",
+ "alif_offset" : "0x580000",
+ "app_size" : "0x580000",
+ "mram_size" : "5.5",
+ "sram_size" : "13.5",
+ "wounding" : "0x00D83FFB",
+ "package" : "SP-AE302F80F55D5AE",
+ "offset" : "offset-58"
+ },
+ "E3 (AE302F80F5582AE) - 5.5 MRAM / 8.25 SRAM":{
+ "featureSet" : "Fusion",
+ "family" : "Ensemble",
+ "alif_offset" : "0x580000",
+ "app_size" : "0x580000",
+ "mram_size" : "5.5",
+ "sram_size" : "8.25",
+ "wounding" : "0x00D83FFB",
+ "package" : "SP-AE302F80F5582AE",
+ "offset" : "offset-58"
+ },
+ "E3 (AE302F80C1557LE) - 1.5 MRAM / 5.75 SRAM":{
+ "featureSet" : "Fusion",
+ "family" : "Ensemble",
+ "alif_offset" : "0x180000",
+ "app_size" : "0x180000",
+ "mram_size" : "1.5",
+ "sram_size" : "5.75",
+ "wounding" : "0x00D83FEB",
+ "package" : "SP-AE302F80C1557LE",
+ "offset" : "offset-18"
+ },
+ "E3 (AE302F40C1537LE) - 1.5 MRAM / 3.75 SRAM":{
+ "featureSet" : "Fusion",
+ "family" : "Ensemble",
+ "alif_offset" : "0x180000",
+ "app_size" : "0x180000",
+ "mram_size" : "1.5",
+ "sram_size" : "3.75",
+ "wounding" : "0x00D83FEA",
+ "package" : "SP-AE302F40C1537LE",
+ "offset" : "offset-18"
+ },
+ "E1 (AE101F4071542LH) - 1.5 MRAM / 4.5 SRAM":{
+ "featureSet" : "Fusion",
+ "family" : "Ensemble",
+ "alif_offset" : "0x180000",
+ "app_size" : "0x180000",
+ "mram_size" : "1.5",
+ "sram_size" : "4.5",
+ "wounding" : "0x00F82B72",
+ "package" : "SP-AE101F4071542LH",
+ "offset" : "offset-18"
+ },
+ "E1C (AE1C1F4051920PH) - 1.86 MRAM / 2.0 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Ensemble",
+ "alif_offset" : "0x1DD000",
+ "app_size" : "0x1DD000",
+ "mram_size" : "1.86",
+ "sram_size" : "2.0",
+ "wounding" : "0x00F80B12",
+ "package" : "SP-AE1C1F4051920PH",
+ "offset" : "offset-1D"
+ },
+ "E1C (AE1C1F4051920HH) - 1.86 MRAM / 2.0 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Ensemble",
+ "alif_offset" : "0x1DD000",
+ "app_size" : "0x1DD000",
+ "mram_size" : "1.86",
+ "sram_size" : "2.0",
+ "wounding" : "0x00F80B12",
+ "package" : "SP-AE1C1F4051920HH",
+ "offset" : "offset-1D"
+ },
+ "E1C (AE1C1F40319205H) - 1.86 MRAM / 2.0 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Ensemble",
+ "alif_offset" : "0x1DD000",
+ "app_size" : "0x1DD000",
+ "mram_size" : "1.86",
+ "sram_size" : "2.0",
+ "wounding" : "0x00F80212",
+ "package" : "SP-AE1C1F40319205H",
+ "offset" : "offset-1D"
+ },
+ "E1C (AE1C1F1041010PH) - 1.0 MRAM / 1.0 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Ensemble",
+ "alif_offset" : "0x100000",
+ "app_size" : "0x100000",
+ "mram_size" : "1.0",
+ "sram_size" : "1.0",
+ "wounding" : "0x00F80000",
+ "package" : "SP-AE1C1F1041010PH",
+ "offset" : "offset-10"
+ },
+ "E1C (AE1C1F1041010HH) - 1.0 MRAM / 1.0 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Ensemble",
+ "alif_offset" : "0x100000",
+ "app_size" : "0x100000",
+ "mram_size" : "1.0",
+ "sram_size" : "1.0",
+ "wounding" : "0x00F80000",
+ "package" : "SP-AE1C1F1041010HH",
+ "offset" : "offset-10"
+ },
+ "E1C (AE1C1F10410105H) - 1.0 MRAM / 1.0 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Ensemble",
+ "alif_offset" : "0x100000",
+ "app_size" : "0x100000",
+ "mram_size" : "1.0",
+ "sram_size" : "1.0",
+ "wounding" : "0x00F80000",
+ "package" : "SP-AE1C1F10410105H",
+ "offset" : "offset-10"
+ },
+ "E1C (AE1C1F1040505PH) - 0.5 MRAM / 0.5 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Ensemble",
+ "alif_offset" : "0x080000",
+ "app_size" : "0x080000",
+ "mram_size" : "0.5",
+ "sram_size" : "0.5",
+ "wounding" : "0x00F80000",
+ "package" : "SP-AE1C1F1040505PH",
+ "offset" : "offset-08"
+ },
+ "E1C (AE1C1F1040505HH) - 0.5 MRAM / 0.5 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Ensemble",
+ "alif_offset" : "0x080000",
+ "app_size" : "0x080000",
+ "mram_size" : "0.5",
+ "sram_size" : "0.5",
+ "wounding" : "0x00F80000",
+ "package" : "SP-AE1C1F1040505HH",
+ "offset" : "offset-08"
+ },
+ "E1C (AE1C1F10405055H) - 0.5 MRAM / 0.5 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Ensemble",
+ "alif_offset" : "0x080000",
+ "app_size" : "0x080000",
+ "mram_size" : "0.5",
+ "sram_size" : "0.5",
+ "wounding" : "0x00F80000",
+ "package" : "SP-AE1C1F10405055H",
+ "offset" : "offset-08"
+ },
+"B1 (AB1C1F4M51820PH) - 1.8 MRAM / 2.0 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Balletto",
+ "alif_offset" : "0x1CD000",
+ "app_size" : "0x1CD000",
+ "mram_size" : "1.8",
+ "sram_size" : "2.0",
+ "wounding" : "0x00F00B12",
+ "package" : "SP-AB1C1F4M51820PH",
+ "offset" : "offset-1C"
+ },
+ "B1 (AB1C1F4M51820HH) - 1.8 MRAM / 2.0 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Balletto",
+ "alif_offset" : "0x1CD000",
+ "app_size" : "0x1CD000",
+ "mram_size" : "1.8",
+ "sram_size" : "2.0",
+ "wounding" : "0x00F00B12",
+ "package" : "SP-AB1C1F4M51820HH",
+ "offset" : "offset-1C"
+ },
+ "B1 (AB1C1F1M41820PH) - 1.8 MRAM / 2.0 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Balletto",
+ "alif_offset" : "0x1CD000",
+ "app_size" : "0x1CD000",
+ "mram_size" : "1.8",
+ "sram_size" : "2.0",
+ "wounding" : "0x00F00000",
+ "package" : "SP-AB1C1F1M41820PH",
+ "offset" : "offset-1C"
+ },
+"B1 (AB1C1F1M41820HH) - 1.8 MRAM / 2.0 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Balletto",
+ "alif_offset" : "0x1CD000",
+ "app_size" : "0x1CD000",
+ "mram_size" : "1.8",
+ "sram_size" : "2.0",
+ "wounding" : "0x00F00000",
+ "package" : "SP-AB1C1F1M41820HH",
+ "offset" : "offset-1C"
+ },
+"B1 (AB1C1F1M41010PH) - 1.0 MRAM / 1.0 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Balletto",
+ "alif_offset" : "0x100000",
+ "app_size" : "0x100000",
+ "mram_size" : "1.0",
+ "sram_size" : "1.0",
+ "wounding" : "0x00F00000",
+ "package" : "SP-AB1C1F1M41010PH",
+ "offset" : "offset-10"
+ },
+"B1 (AB1C1F1M41010HH) - 1.0 MRAM / 1.0 SRAM":{
+ "featureSet" : "Spark",
+ "family" : "Balletto",
+ "alif_offset" : "0x100000",
+ "app_size" : "0x100000",
+ "mram_size" : "1.0",
+ "sram_size" : "1.0",
+ "wounding" : "0x00F00000",
+ "package" : "SP-AB1C1F1M41010HH",
+ "offset" : "offset-10"
+ }
+}
diff --git a/tools/alif/utils/discover.py b/tools/alif/utils/discover.py
index bb565c16f..6dbaf9d7b 100755
--- a/tools/alif/utils/discover.py
+++ b/tools/alif/utils/discover.py
@@ -1,196 +1,196 @@
-#!/usr/bin/env python3
-import os
-import sys
-import shutil
-import subprocess
-import utils.config
-from utils.config import *
-
-CONF_FILE = 'bin/ARMDS_dbg.cfg'
-Manufacturer = ""
-Platform = ""
-Connection = ""
-
-def getJlinkSN():
- """
- JLINK get the serial number
- """
- cmd = "pylink emulator -l usb"
-# DEBUG
-# print("CMD=",cmd)
-# which_pylink = shutil.which("pylink")
-# print("SHUTIL says ", which_pylink)
-
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,universal_newlines=True,shell=True)
- output, errors = p.communicate()
-
- if errors > '':
- print('Errors')
- print(errors)
-
- idx = output.find('Serial Number:')
-
- if idx == -1:
- return -1
-
- sn = output[idx+15:].splitlines()
- return sn[0]
-
-def discover_Manufacturer(extensionDB):
- """
- ARM ULINK discovery
- """
- global Manufacturer
-
- print("\nDiscovering Manufacturer...")
-
- cmd = 'armdbg --cdb-root-ignore-default --cdb-root "' + extensionDB + '" --cdb-entry "?"'
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True,shell=True)
- output, errors = p.communicate()
- options = errors.splitlines()
-
- selection = 0
- while selection == 0:
- print('\nAvailable options:')
- i = 0
- for line in options:
- if i == 0:
- i += 1
- continue
- print(str(i) + ". " + line)
- i += 1
-
- selection = int(input("\nPlease select an option: "))
- if int(selection) > len(options)-1:
- print('Please select a valid option!')
- selection = 0
-
- Manufacturer = options[selection]
- print('Manufacturer: ' + Manufacturer)
-
-
-def discover_Platform(extensionDB):
- global Manufacturer
- global Platform
-
- print("\nDiscovering Platform for " + Manufacturer + "...")
-
- cmd = 'armdbg --cdb-root-ignore-default --cdb-root "' + extensionDB + '" --cdb-entry "' + Manufacturer + '::?"'
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True,shell=True)
- output, errors = p.communicate()
- options = errors.splitlines()
-
- selection = 0
- while selection == 0:
- print('\nAvailable options:')
- i = 0
- for line in options:
- if i == 0:
- i += 1
- continue
- print(str(i) + ". " + line)
- i += 1
-
- selection = int(input("\nPlease select an option: "))
- if int(selection) > len(options)-1:
- print('Please select a valid option!')
- selection = 0
-
- Platform = options[selection]
- print('Platform: ' + Platform)
-
-
-def discover_Connection(extensionDB, jtag_adapter):
- global Manufacturer
- global Platform
- global Connection
-
- print("\nDiscovering Connection for " + Manufacturer + "::" + Platform + "...")
-
- cmd = 'armdbg --cdb-root "' + extensionDB + '" --cdb-entry "' + Manufacturer + '::' + Platform + '::Bare Metal Debug::Bare Metal Debug::Cortex-M0+::' + jtag_adapter + '" --cdb-entry-param "Connection=?" --browse '
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True,shell=True)
- output, errors = p.communicate()
- options = output.splitlines()
-
- selection = 0
- while selection == 0:
- print('\nAvailable options:')
- i = 0
- for line in options:
- if i == 0:
- i += 1
- continue
- print(str(i) + ". " + line.strip())
- i += 1
-
- selection = int(input("\nPlease select an option: "))
- if int(selection) > len(options)-1:
- print('Please select a valid option!')
- selection = 0
-
- Connection = options[selection].strip()
- print('Connection: ' + Connection)
-
-def discoverParameters():
- print("Please be sure the board is powered-on and ULINK Pro is connected!")
- input("Press any key to continue...")
- extensionDB = '%USERPROFILE%\\Development Studio Workspace\\ExtensionDB'
- if sys.platform == "linux":
- extensionDB = '$HOME/developmentstudio-workspace/ExtensionDB'
-
- # get JTAG Adatper from Global Configuration
- load_global_config()
- JTAG_ADAPTER = utils.config.JTAG_ADAPTER
-
- print('Writing MRAM with parameters:')
- print('Device Part# ' + DEVICE_PART_NUMBER + ' - Rev: ' + DEVICE_REVISION)
- print('- MRAM Base Address: ' + hex(ALIF_BASE_ADDRESS))
-
-
- discover_Manufacturer(extensionDB)
- discover_Platform(extensionDB)
- discover_Connection(extensionDB, JTAG_ADAPTER)
-
-def saveConfiguration():
- try:
- f = open(CONF_FILE, "w")
- f.write(Manufacturer + ',' + Platform + ',' + Connection)
- f.close()
-
- except:
- print("There was an error creating the configuration file!")
- return
-
-def getValues():
-
- if not os.path.exists(CONF_FILE):
- print("Configuration file doesn't exist. We will run the discovery process...")
- discoverParameters()
- saveConfiguration()
-
- try:
- f = open(CONF_FILE, 'r')
- Manufacturer, Platform, Connection = f.readline().split(',')
-
- except FileNotFoundError:
- print("The configuration file could not be created!")
- return
- except:
- print('There was an error reading the configuration file!')
- return
-
- return Manufacturer, Platform, Connection
-
-def main():
- if sys.version_info.major == 2:
- print("You need Python 3 for this application!")
- return 0
-
- Manuf, Plat, Conn = getValues()
- print('Configuration values:')
- print(Manuf)
- print(Plat)
- print(Conn)
-
-if __name__ == "__main__":
- main()
+#!/usr/bin/env python3
+import os
+import sys
+import shutil
+import subprocess
+import utils.config
+from utils.config import *
+
+CONF_FILE = 'bin/ARMDS_dbg.cfg'
+Manufacturer = ""
+Platform = ""
+Connection = ""
+
+def getJlinkSN():
+ """
+ JLINK get the serial number
+ """
+ cmd = "pylink emulator -l usb"
+# DEBUG
+# print("CMD=",cmd)
+# which_pylink = shutil.which("pylink")
+# print("SHUTIL says ", which_pylink)
+
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,universal_newlines=True,shell=True)
+ output, errors = p.communicate()
+
+ if errors > '':
+ print('Errors')
+ print(errors)
+
+ idx = output.find('Serial Number:')
+
+ if idx == -1:
+ return -1
+
+ sn = output[idx+15:].splitlines()
+ return sn[0]
+
+def discover_Manufacturer(extensionDB):
+ """
+ ARM ULINK discovery
+ """
+ global Manufacturer
+
+ print("\nDiscovering Manufacturer...")
+
+ cmd = 'armdbg --cdb-root-ignore-default --cdb-root "' + extensionDB + '" --cdb-entry "?"'
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True,shell=True)
+ output, errors = p.communicate()
+ options = errors.splitlines()
+
+ selection = 0
+ while selection == 0:
+ print('\nAvailable options:')
+ i = 0
+ for line in options:
+ if i == 0:
+ i += 1
+ continue
+ print(str(i) + ". " + line)
+ i += 1
+
+ selection = int(input("\nPlease select an option: "))
+ if int(selection) > len(options)-1:
+ print('Please select a valid option!')
+ selection = 0
+
+ Manufacturer = options[selection]
+ print('Manufacturer: ' + Manufacturer)
+
+
+def discover_Platform(extensionDB):
+ global Manufacturer
+ global Platform
+
+ print("\nDiscovering Platform for " + Manufacturer + "...")
+
+ cmd = 'armdbg --cdb-root-ignore-default --cdb-root "' + extensionDB + '" --cdb-entry "' + Manufacturer + '::?"'
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True,shell=True)
+ output, errors = p.communicate()
+ options = errors.splitlines()
+
+ selection = 0
+ while selection == 0:
+ print('\nAvailable options:')
+ i = 0
+ for line in options:
+ if i == 0:
+ i += 1
+ continue
+ print(str(i) + ". " + line)
+ i += 1
+
+ selection = int(input("\nPlease select an option: "))
+ if int(selection) > len(options)-1:
+ print('Please select a valid option!')
+ selection = 0
+
+ Platform = options[selection]
+ print('Platform: ' + Platform)
+
+
+def discover_Connection(extensionDB, jtag_adapter):
+ global Manufacturer
+ global Platform
+ global Connection
+
+ print("\nDiscovering Connection for " + Manufacturer + "::" + Platform + "...")
+
+ cmd = 'armdbg --cdb-root "' + extensionDB + '" --cdb-entry "' + Manufacturer + '::' + Platform + '::Bare Metal Debug::Bare Metal Debug::Cortex-M0+::' + jtag_adapter + '" --cdb-entry-param "Connection=?" --browse '
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True,shell=True)
+ output, errors = p.communicate()
+ options = output.splitlines()
+
+ selection = 0
+ while selection == 0:
+ print('\nAvailable options:')
+ i = 0
+ for line in options:
+ if i == 0:
+ i += 1
+ continue
+ print(str(i) + ". " + line.strip())
+ i += 1
+
+ selection = int(input("\nPlease select an option: "))
+ if int(selection) > len(options)-1:
+ print('Please select a valid option!')
+ selection = 0
+
+ Connection = options[selection].strip()
+ print('Connection: ' + Connection)
+
+def discoverParameters():
+ print("Please be sure the board is powered-on and ULINK Pro is connected!")
+ input("Press any key to continue...")
+ extensionDB = '%USERPROFILE%\\Development Studio Workspace\\ExtensionDB'
+ if sys.platform == "linux":
+ extensionDB = '$HOME/developmentstudio-workspace/ExtensionDB'
+
+ # get JTAG Adatper from Global Configuration
+ load_global_config()
+ JTAG_ADAPTER = utils.config.JTAG_ADAPTER
+
+ print('Writing MRAM with parameters:')
+ print('Device Part# ' + DEVICE_PART_NUMBER + ' - Rev: ' + DEVICE_REVISION)
+ print('- MRAM Base Address: ' + hex(ALIF_BASE_ADDRESS))
+
+
+ discover_Manufacturer(extensionDB)
+ discover_Platform(extensionDB)
+ discover_Connection(extensionDB, JTAG_ADAPTER)
+
+def saveConfiguration():
+ try:
+ f = open(CONF_FILE, "w")
+ f.write(Manufacturer + ',' + Platform + ',' + Connection)
+ f.close()
+
+ except:
+ print("There was an error creating the configuration file!")
+ return
+
+def getValues():
+
+ if not os.path.exists(CONF_FILE):
+ print("Configuration file doesn't exist. We will run the discovery process...")
+ discoverParameters()
+ saveConfiguration()
+
+ try:
+ f = open(CONF_FILE, 'r')
+ Manufacturer, Platform, Connection = f.readline().split(',')
+
+ except FileNotFoundError:
+ print("The configuration file could not be created!")
+ return
+ except:
+ print('There was an error reading the configuration file!')
+ return
+
+ return Manufacturer, Platform, Connection
+
+def main():
+ if sys.version_info.major == 2:
+ print("You need Python 3 for this application!")
+ return 0
+
+ Manuf, Plat, Conn = getValues()
+ print('Configuration values:')
+ print(Manuf)
+ print(Plat)
+ print(Conn)
+
+if __name__ == "__main__":
+ main()
diff --git a/tools/alif/utils/familiesDB.db b/tools/alif/utils/familiesDB.db
index 46b301e7b..30325d4ce 100755
--- a/tools/alif/utils/familiesDB.db
+++ b/tools/alif/utils/familiesDB.db
@@ -1,8 +1,8 @@
-{
- "Ensemble":{
-
- },
- "Balletto":{
-
- }
-}
+{
+ "Ensemble":{
+
+ },
+ "Balletto":{
+
+ }
+}
diff --git a/tools/alif/utils/featuresDB.db b/tools/alif/utils/featuresDB.db
index 9bfc6bcc6..17125008d 100755
--- a/tools/alif/utils/featuresDB.db
+++ b/tools/alif/utils/featuresDB.db
@@ -1,18 +1,18 @@
-{
- "Fusion":{
- "mram_total" : "0x600000",
- "mram_base" : "0x80000000",
- "revisions": ["B4","B3","B2"],
- "rev_package_ext": {"B2":"rev-b2","B3":"rev-b3","B4":"rev-b4"},
- "rev_baud_rate": {"B2":55000,"B3":55000,"B4":55000},
- "seram_banks" : 2
- },
- "Spark":{
- "mram_total" : "0x200000",
- "mram_base" : "0x80000000",
- "revisions": ["A0"],
- "rev_package_ext": {"A0":"rev-a0"},
- "rev_baud_rate": {"A0":56500},
- "seram_banks" : 2
- }
-}
+{
+ "Fusion":{
+ "mram_total" : "0x600000",
+ "mram_base" : "0x80000000",
+ "revisions": ["B4","B3","B2"],
+ "rev_package_ext": {"B2":"rev-b2","B3":"rev-b3","B4":"rev-b4"},
+ "rev_baud_rate": {"B2":55000,"B3":55000,"B4":55000},
+ "seram_banks" : 2
+ },
+ "Spark":{
+ "mram_total" : "0x200000",
+ "mram_base" : "0x80000000",
+ "revisions": ["A0","A5"],
+ "rev_package_ext": {"A0":"rev-a0","A5":"rev-a5"},
+ "rev_baud_rate": {"A0":56500,"A5":18000},
+ "seram_banks" : 2
+ }
+}
diff --git a/tools/alif/utils/firewall.py b/tools/alif/utils/firewall.py
index 3cb48ad16..8af70bfbf 100755
--- a/tools/alif/utils/firewall.py
+++ b/tools/alif/utils/firewall.py
@@ -1,267 +1,267 @@
-""" firewall """
-import json
-import ctypes
-
-# pylint: disable=too-few-public-methods
-# pylint: disable=too-many-instance-attributes
-# pylint: disable=invalid-name
-# pylint: disable=attribute-defined-outside-init
-
-INPUT_FILE = 'fw_cfg_cm.json'
-OUTPUT_FILE = 'fw_cfg.bin'
-
-c_uint32 = ctypes.c_uint32
-
-class firewall_controller(ctypes.LittleEndianStructure):
- """ firewall_controller """
- _fields_ = [
- ("err", c_uint32, 1),
- ("raz", c_uint32, 1),
- ("sr_pwr", c_uint32, 1),
- ("valid", c_uint32, 1)
- ]
-
- def init_from_cfg(self, cfg):
- """ Initialize from JSON configuration """
- if cfg['valid']:
- self.valid = 1
- self.err = cfg['err']
- self.raz = cfg['raz']
- self.sr_pwr = cfg['sr_pwr']
-
-class firewall_component(ctypes.LittleEndianStructure):
- """ firewall_component """
- _fields_ = [
- ("num_rgn_entries", c_uint32, 8),
-
- ("lock", c_uint32, 2),
- ("err", c_uint32, 1),
- ("raz", c_uint32, 1),
- ("flt_cfg", c_uint32, 2),
- ("fe_pwr", c_uint32, 2),
-
- ("me_ctrl", c_uint32, 3),
- ("int_msk", c_uint32, 5),
-
- ("enable", c_uint32, 1),
- ("valid", c_uint32, 1),
- ]
-
- def init_from_cfg(self, cfg, num_rgns):
- """ Initialize from JSON configuration """
- self.num_rgn_entries = num_rgns
- self.lock = 0
- self.err = cfg['err'] if 'err' in cfg else 1
- self.raz = cfg['raz'] if 'raz' in cfg else 0
- self.flt_cfg = int(cfg['flt_cfg'], 0) if 'flt_cfg' in cfg else 0x2
- self.fe_pwr = cfg['fe_pwr'] if 'fe_pwr' in cfg else 0
- self.me_ctrl = int(cfg['me_ctrl'], 0) if 'me_ctrl' in cfg else 0x0
- self.int_msk = int(cfg['int_msk'], 0) if 'int_msk' in cfg else 0x0
- self.enable = 1
- self.valid = 1
-
-class fw_rgn_cmn(ctypes.LittleEndianStructure):
- """ fw_rgn_cmn """
- _fields_ = [
- ("rgn_indx", c_uint32, 8),
- ("en", c_uint32, 1),
- ("lock", c_uint32, 1),
- ]
-
-class fw_rgn_mpe(ctypes.LittleEndianStructure):
- """ fw_rgn_mpe """
- _fields_ = [
- ("mid", c_uint32, 8),
- ("acc", c_uint32, 12),
- ("any_mst", c_uint32, 1),
- ("reserved", c_uint32, 3),
- ("enable", c_uint32, 1),
- ("valid", c_uint32, 1),
- ]
-
- def init_from_cfg(self, cfg):
- """ Initialize from JSON configuration """
- self.valid = 1
- self.reserved = 0
- self.enable = 1
- self.mid = cfg['master_id']
- self.acc = int(cfg['permissions'], 0)
- self.any_mst = cfg['any_master']
-
-class fw_rgn_pe2(ctypes.LittleEndianStructure):
- """ fw_rgn_pe2 """
- _fields_ = [
- ("size", c_uint32, 7),
- ("mul_n_po2", c_uint32, 1),
- ("addr_trans_en", c_uint32, 1),
- ("ma_trans_en", c_uint32, 1),
- ("reserved", c_uint32, 6),
- ("trans_flags", c_uint32, 16),
- ]
-
-class firewall_region(ctypes.LittleEndianStructure):
- """ firewall_region """
- _fields_ = [
- ("cmn", fw_rgn_cmn),
- ("mpe0", fw_rgn_mpe),
- ("mpe1", fw_rgn_mpe),
- ("mpe2", fw_rgn_mpe),
- ("mpe3", fw_rgn_mpe),
- ("base_addr", c_uint32),
- ("out_uppr_addr", c_uint32),
- ("pe2", fw_rgn_pe2),
- ]
-
- def init_from_cfg(self, cfg, rgn_idx):
- """ Initialize from JSON configuration """
- self.cmn.rgn_indx = rgn_idx
- self.cmn.en = 1
- self.cmn.lock = 0
-
- self.mpe0.valid = 0
- self.mpe1.valid = 0
- self.mpe2.valid = 0
- self.mpe3.valid = 0
- for j_mpe in cfg['mpe_list']:
- if j_mpe['mpe_id'] == 0:
- self.mpe0.init_from_cfg(j_mpe)
- elif j_mpe['mpe_id'] == 1:
- self.mpe1.init_from_cfg(j_mpe)
- elif j_mpe['mpe_id'] == 2:
- self.mpe2.init_from_cfg(j_mpe)
- elif j_mpe['mpe_id'] == 3:
- self.mpe3.init_from_cfg(j_mpe)
-
- self.base_addr = int(cfg['start_address'], 0)
-
- self.out_uppr_addr = int(cfg['end_address'], 0) if 'end_address' in cfg else 0xFFFFFFFF
- self.pe2.size = int(cfg['size'], 0) if 'size' in cfg else 0x0
- self.pe2.mul_n_po2 = cfg['mul_n_po2'] if 'mul_n_po2' in cfg else 0
- self.pe2.addr_trans_en = cfg['addr_trans_en'] if 'addr_trans_en' in cfg else 0
- self.pe2.ma_trans_en = cfg['ma_trans_en'] if 'ma_trans_en' in cfg else 0
- self.pe2.trans_flags = int(cfg['translation_flags'], 0) if 'translation_flags' in cfg else 0x4
-
-class protected_area(ctypes.LittleEndianStructure):
- """ protected_area """
- _fields_ = [
- ("component_id", c_uint32),
- ("base_addr", c_uint32),
- ("upper_addr", c_uint32)
- ]
-
- def init_from_cfg(self, cfg):
- """ Initialize from JSON configuration """
- self.component_id = cfg['component_id']
- self.base_addr = int(cfg['start_address'], 0)
- self.upper_addr = int(cfg['end_address'], 0)
-
-
-FW_COMP_NUM = 15
-FW_PROT_AREA_NUM = 16
-
-def process_components(cfg):
- """ process_components """
-
- # order the FC sections by the component_id
- ordered_cfg = [None for i in range(FW_COMP_NUM)]
- for j_comp in cfg:
- comp_id = int(j_comp['component_id'])
- if comp_id < 0 or comp_id >= FW_COMP_NUM:
- continue
- ordered_cfg[comp_id] = j_comp
-
- components = [firewall_component() for i in range(FW_COMP_NUM)]
- configured_regions = []
-
- for j_comp in ordered_cfg:
- if j_comp == None:
- continue
-
- rgn_count = 0
- for j_rgn in j_comp['configured_regions']:
- rgn_idx = int(j_rgn['region_index'])
- if rgn_idx < 0 or rgn_idx > 255:
- continue
-
- rgn = firewall_region()
- rgn.init_from_cfg(j_rgn, rgn_idx)
-
- rgn_count += 1
- configured_regions.append(rgn)
-
- comp_id = int(j_comp['component_id'])
- comp = components[comp_id]
- comp.init_from_cfg(j_comp, rgn_count)
-
- return components, configured_regions
-
-def firewall_json_to_bin(jsn, is_icv):
- """ Convert a JSON file into binary """
- #with open(INPUT_FILE, "r") as json_file:
- # jsn = json.load(json_file)
-
- # read the firewall components and configured regions
- components, configured_regions = process_components(jsn['firewall_components'])
-
- # read the firewall controller
- controller = firewall_controller()
- if 'firewall_controller' in jsn:
- controller.init_from_cfg(jsn['firewall_controller'])
-
- # read the protected areas
- protected_areas = []
- if is_icv and 'protected_areas' in jsn:
- protected_areas = [protected_area() for i in range(FW_PROT_AREA_NUM)]
- curr_area = 0
- for j_prot in jsn['protected_areas']:
- prot_area = protected_areas[curr_area]
- prot_area.init_from_cfg(j_prot)
-
- curr_area += 1
- if curr_area >= FW_PROT_AREA_NUM:
- break
- # end for loop over the protected areas
-
- with open(OUTPUT_FILE, 'wb') as bin_file:
- for comp in components:
- bin_file.write(comp)
- bin_file.write(controller)
- if is_icv:
- for prot_area in protected_areas:
- bin_file.write(prot_area)
- for rgn in configured_regions:
- bin_file.write(rgn)
-
-def bin_to_struct():
- """ Convert a binary file into Python structures """
- components = [firewall_component() for i in range(FW_COMP_NUM)]
- configured_regions = []
- ctrl = firewall_controller()
- protected_areas = [protected_area() for i in range(FW_PROT_AREA_NUM)]
-
- with open(OUTPUT_FILE, 'rb') as bin_file:
- for comp in components:
- # read the components section
- bin_file.readinto(comp)
- # create region entries for each configured region in this component
- for _ in range(comp.num_rgn_entries):
- configured_regions.append(firewall_region())
-
- # read the controller section
- bin_file.readinto(ctrl)
-
- # read the protected areas section
- for prot_area in protected_areas:
- bin_file.readinto(prot_area)
-
- # read the configured regions section
- for rgn in configured_regions:
- bin_file.readinto(rgn)
-
-def main():
- """ main """
- json_to_bin()
- return 0
-
-if __name__ == "__main__":
- main()
+""" firewall """
+import json
+import ctypes
+
+# pylint: disable=too-few-public-methods
+# pylint: disable=too-many-instance-attributes
+# pylint: disable=invalid-name
+# pylint: disable=attribute-defined-outside-init
+
+INPUT_FILE = 'fw_cfg_cm.json'
+OUTPUT_FILE = 'fw_cfg.bin'
+
+c_uint32 = ctypes.c_uint32
+
+class firewall_controller(ctypes.LittleEndianStructure):
+ """ firewall_controller """
+ _fields_ = [
+ ("err", c_uint32, 1),
+ ("raz", c_uint32, 1),
+ ("sr_pwr", c_uint32, 1),
+ ("valid", c_uint32, 1)
+ ]
+
+ def init_from_cfg(self, cfg):
+ """ Initialize from JSON configuration """
+ if cfg['valid']:
+ self.valid = 1
+ self.err = cfg['err']
+ self.raz = cfg['raz']
+ self.sr_pwr = cfg['sr_pwr']
+
+class firewall_component(ctypes.LittleEndianStructure):
+ """ firewall_component """
+ _fields_ = [
+ ("num_rgn_entries", c_uint32, 8),
+
+ ("lock", c_uint32, 2),
+ ("err", c_uint32, 1),
+ ("raz", c_uint32, 1),
+ ("flt_cfg", c_uint32, 2),
+ ("fe_pwr", c_uint32, 2),
+
+ ("me_ctrl", c_uint32, 3),
+ ("int_msk", c_uint32, 5),
+
+ ("enable", c_uint32, 1),
+ ("valid", c_uint32, 1),
+ ]
+
+ def init_from_cfg(self, cfg, num_rgns):
+ """ Initialize from JSON configuration """
+ self.num_rgn_entries = num_rgns
+ self.lock = 0
+ self.err = cfg['err'] if 'err' in cfg else 1
+ self.raz = cfg['raz'] if 'raz' in cfg else 0
+ self.flt_cfg = int(cfg['flt_cfg'], 0) if 'flt_cfg' in cfg else 0x2
+ self.fe_pwr = cfg['fe_pwr'] if 'fe_pwr' in cfg else 0
+ self.me_ctrl = int(cfg['me_ctrl'], 0) if 'me_ctrl' in cfg else 0x0
+ self.int_msk = int(cfg['int_msk'], 0) if 'int_msk' in cfg else 0x0
+ self.enable = 1
+ self.valid = 1
+
+class fw_rgn_cmn(ctypes.LittleEndianStructure):
+ """ fw_rgn_cmn """
+ _fields_ = [
+ ("rgn_indx", c_uint32, 8),
+ ("en", c_uint32, 1),
+ ("lock", c_uint32, 1),
+ ]
+
+class fw_rgn_mpe(ctypes.LittleEndianStructure):
+ """ fw_rgn_mpe """
+ _fields_ = [
+ ("mid", c_uint32, 8),
+ ("acc", c_uint32, 12),
+ ("any_mst", c_uint32, 1),
+ ("reserved", c_uint32, 3),
+ ("enable", c_uint32, 1),
+ ("valid", c_uint32, 1),
+ ]
+
+ def init_from_cfg(self, cfg):
+ """ Initialize from JSON configuration """
+ self.valid = 1
+ self.reserved = 0
+ self.enable = 1
+ self.mid = cfg['master_id']
+ self.acc = int(cfg['permissions'], 0)
+ self.any_mst = cfg['any_master']
+
+class fw_rgn_pe2(ctypes.LittleEndianStructure):
+ """ fw_rgn_pe2 """
+ _fields_ = [
+ ("size", c_uint32, 7),
+ ("mul_n_po2", c_uint32, 1),
+ ("addr_trans_en", c_uint32, 1),
+ ("ma_trans_en", c_uint32, 1),
+ ("reserved", c_uint32, 6),
+ ("trans_flags", c_uint32, 16),
+ ]
+
+class firewall_region(ctypes.LittleEndianStructure):
+ """ firewall_region """
+ _fields_ = [
+ ("cmn", fw_rgn_cmn),
+ ("mpe0", fw_rgn_mpe),
+ ("mpe1", fw_rgn_mpe),
+ ("mpe2", fw_rgn_mpe),
+ ("mpe3", fw_rgn_mpe),
+ ("base_addr", c_uint32),
+ ("out_uppr_addr", c_uint32),
+ ("pe2", fw_rgn_pe2),
+ ]
+
+ def init_from_cfg(self, cfg, rgn_idx):
+ """ Initialize from JSON configuration """
+ self.cmn.rgn_indx = rgn_idx
+ self.cmn.en = 1
+ self.cmn.lock = 0
+
+ self.mpe0.valid = 0
+ self.mpe1.valid = 0
+ self.mpe2.valid = 0
+ self.mpe3.valid = 0
+ for j_mpe in cfg['mpe_list']:
+ if j_mpe['mpe_id'] == 0:
+ self.mpe0.init_from_cfg(j_mpe)
+ elif j_mpe['mpe_id'] == 1:
+ self.mpe1.init_from_cfg(j_mpe)
+ elif j_mpe['mpe_id'] == 2:
+ self.mpe2.init_from_cfg(j_mpe)
+ elif j_mpe['mpe_id'] == 3:
+ self.mpe3.init_from_cfg(j_mpe)
+
+ self.base_addr = int(cfg['start_address'], 0)
+
+ self.out_uppr_addr = int(cfg['end_address'], 0) if 'end_address' in cfg else 0xFFFFFFFF
+ self.pe2.size = int(cfg['size'], 0) if 'size' in cfg else 0x0
+ self.pe2.mul_n_po2 = cfg['mul_n_po2'] if 'mul_n_po2' in cfg else 0
+ self.pe2.addr_trans_en = cfg['addr_trans_en'] if 'addr_trans_en' in cfg else 0
+ self.pe2.ma_trans_en = cfg['ma_trans_en'] if 'ma_trans_en' in cfg else 0
+ self.pe2.trans_flags = int(cfg['translation_flags'], 0) if 'translation_flags' in cfg else 0x4
+
+class protected_area(ctypes.LittleEndianStructure):
+ """ protected_area """
+ _fields_ = [
+ ("component_id", c_uint32),
+ ("base_addr", c_uint32),
+ ("upper_addr", c_uint32)
+ ]
+
+ def init_from_cfg(self, cfg):
+ """ Initialize from JSON configuration """
+ self.component_id = cfg['component_id']
+ self.base_addr = int(cfg['start_address'], 0)
+ self.upper_addr = int(cfg['end_address'], 0)
+
+
+FW_COMP_NUM = 15
+FW_PROT_AREA_NUM = 16
+
+def process_components(cfg):
+ """ process_components """
+
+ # order the FC sections by the component_id
+ ordered_cfg = [None for i in range(FW_COMP_NUM)]
+ for j_comp in cfg:
+ comp_id = int(j_comp['component_id'])
+ if comp_id < 0 or comp_id >= FW_COMP_NUM:
+ continue
+ ordered_cfg[comp_id] = j_comp
+
+ components = [firewall_component() for i in range(FW_COMP_NUM)]
+ configured_regions = []
+
+ for j_comp in ordered_cfg:
+ if j_comp == None:
+ continue
+
+ rgn_count = 0
+ for j_rgn in j_comp['configured_regions']:
+ rgn_idx = int(j_rgn['region_index'])
+ if rgn_idx < 0 or rgn_idx > 255:
+ continue
+
+ rgn = firewall_region()
+ rgn.init_from_cfg(j_rgn, rgn_idx)
+
+ rgn_count += 1
+ configured_regions.append(rgn)
+
+ comp_id = int(j_comp['component_id'])
+ comp = components[comp_id]
+ comp.init_from_cfg(j_comp, rgn_count)
+
+ return components, configured_regions
+
+def firewall_json_to_bin(jsn, is_icv):
+ """ Convert a JSON file into binary """
+ #with open(INPUT_FILE, "r") as json_file:
+ # jsn = json.load(json_file)
+
+ # read the firewall components and configured regions
+ components, configured_regions = process_components(jsn['firewall_components'])
+
+ # read the firewall controller
+ controller = firewall_controller()
+ if 'firewall_controller' in jsn:
+ controller.init_from_cfg(jsn['firewall_controller'])
+
+ # read the protected areas
+ protected_areas = []
+ if is_icv and 'protected_areas' in jsn:
+ protected_areas = [protected_area() for i in range(FW_PROT_AREA_NUM)]
+ curr_area = 0
+ for j_prot in jsn['protected_areas']:
+ prot_area = protected_areas[curr_area]
+ prot_area.init_from_cfg(j_prot)
+
+ curr_area += 1
+ if curr_area >= FW_PROT_AREA_NUM:
+ break
+ # end for loop over the protected areas
+
+ with open(OUTPUT_FILE, 'wb') as bin_file:
+ for comp in components:
+ bin_file.write(comp)
+ bin_file.write(controller)
+ if is_icv:
+ for prot_area in protected_areas:
+ bin_file.write(prot_area)
+ for rgn in configured_regions:
+ bin_file.write(rgn)
+
+def bin_to_struct():
+ """ Convert a binary file into Python structures """
+ components = [firewall_component() for i in range(FW_COMP_NUM)]
+ configured_regions = []
+ ctrl = firewall_controller()
+ protected_areas = [protected_area() for i in range(FW_PROT_AREA_NUM)]
+
+ with open(OUTPUT_FILE, 'rb') as bin_file:
+ for comp in components:
+ # read the components section
+ bin_file.readinto(comp)
+ # create region entries for each configured region in this component
+ for _ in range(comp.num_rgn_entries):
+ configured_regions.append(firewall_region())
+
+ # read the controller section
+ bin_file.readinto(ctrl)
+
+ # read the protected areas section
+ for prot_area in protected_areas:
+ bin_file.readinto(prot_area)
+
+ # read the configured regions section
+ for rgn in configured_regions:
+ bin_file.readinto(rgn)
+
+def main():
+ """ main """
+ json_to_bin()
+ return 0
+
+if __name__ == "__main__":
+ main()
diff --git a/tools/alif/utils/gen_fw_cfg.py b/tools/alif/utils/gen_fw_cfg.py
index 5873240ae..46b1b8ea1 100755
--- a/tools/alif/utils/gen_fw_cfg.py
+++ b/tools/alif/utils/gen_fw_cfg.py
@@ -1,187 +1,191 @@
-#!/usr/bin/env python3
-"""
- __author__ = ""
- __copyright__ = "ALIF Seminconductor"
- __version__ = "0.1.0"
- __status__ = "Dev"
-"""
-# pylint: disable=unused-argument, invalid-name, bare-except
-
-import sys
-import argparse
-import json
-import os
-import utils.toc_common
-
-TOOL_VERSION ="0.1.001" # Define Version constant for each separate tool
-
-EXIT_WITH_ERROR = 1
-
-FW_CFG_FILE = "build/fw_cfg.json"
-
-def mram_size_to_address(mram_size):
- mram_size_int = 0
- if mram_size == '1.8': # @todo this should be improved
- mram_size_int = int("0x001CD000", 16)
- elif mram_size == '1.86':
- mram_size_int = int("0x001DD000", 16)
- else:
- mram_size_int = int(float(mram_size) * 1024 * 1024)
- mram_base_int = int("0x80000000", 16)
- stoc_start = mram_base_int + mram_size_int
- atoc_end = stoc_start - 1
- atoc_end_str = "0x" + hex(atoc_end).lstrip("0x").upper()
- stoc_start_str = "0x" + hex(stoc_start).lstrip("0x").upper()
- return atoc_end_str, stoc_start_str
-
-def handle_sram(sram_size, firewall_components, protected_areas):
-
- if "13.5" == sram_size: # no SRAM wounding
- #print("**** no SRAM wounding")
- return
-
- # load the definitions for REV_B
- with open('firewall/sram_rev_b.json', "r") as json_file:
- sram_json = json.load(json_file)
-
- # Wound the Modem TCMs - FC #12
- firewall_components.append(sram_json["firewall_components"][0])
- protected_areas.append(sram_json["protected_areas"][0])
-
- if "8.25" == sram_size: # no other wounding
- #print("**** 8.25MB wounding")
- return
-
- if "5.75" == sram_size: # E3 with 5.75MB SRAM
- # Wound SRAM1 - FC #4 - XNVM
- firewall_components.append(sram_json["firewall_components"][1])
- protected_areas.append(sram_json["protected_areas"][1])
- #print("**** 5.75MB wounding")
- return
-
- if "4.5" == sram_size: # E1
- # Wound SRAM1 - FC #4 - XNVM
- firewall_components.append(sram_json["firewall_components"][1])
- protected_areas.append(sram_json["protected_areas"][1])
-
- # Wound M55-HP TCMs - 0x50000000-0x57FFFFFF
- firewall_components.append(sram_json["firewall_components"][4])
- protected_areas.append(sram_json["protected_areas"][4])
- #print("**** 4.5MB wounding")
- return
-
- if "3.75" == sram_size: #E3 with 3.75MB SRAM:
- # Wound SRAM0 - FC #5 - CVM
- firewall_components.append(sram_json["firewall_components"][3])
- protected_areas.append(sram_json["protected_areas"][3])
-
- # Wound SRAM1 to 2MB
- firewall_components.append(sram_json["firewall_components"][2])
- protected_areas.append(sram_json["protected_areas"][2])
- #print("**** 3.75MB wounding")
- return
-
- # Invalid sram_size - wound SRAM0, SRAM1, and the M55-HP TCMs
- firewall_components.append(sram_json["firewall_components"][1])
- protected_areas.append(sram_json["protected_areas"][1])
- firewall_components.append(sram_json["firewall_components"][3])
- protected_areas.append(sram_json["protected_areas"][3])
- firewall_components.append(sram_json["firewall_components"][4])
- protected_areas.append(sram_json["protected_areas"][4])
- print("**** Invalid SRAM size!")
-
-def write_json(json_content):
- out_file = FW_CFG_FILE
- if (os.path.exists(out_file)):
- os.remove(out_file)
-
- with open(out_file, 'w') as f:
- json.dump(json_content, f, indent=2)
-
-def gen_fw_cfg_icv(family, mram_size, sram_size, device_revision, featureSet):
-
- atoc_end_address, stoc_start_address = mram_size_to_address(mram_size)
- print(family)
- if family == "Ensemble" and featureSet == "Spark":
- # Ensemble E1C
- with open('firewall/fw_cfg_spark.json', "r") as json_file:
- spark_json = json.load(json_file)
- spark_json["firewall_components"][1]["configured_regions"][0]["end_address"] = atoc_end_address
- spark_json["protected_areas"][2]["start_address"] = stoc_start_address
-
- # Delete the sections for the BLE protected areas
- spark_json["firewall_components"].pop(0)
- spark_json["protected_areas"].pop(0)
- spark_json["protected_areas"].pop(0)
- write_json(spark_json)
- return;
-
- if family == "Balletto":
- # Balletto B1
- with open('firewall/fw_cfg_spark.json', "r") as json_file:
- spark_json = json.load(json_file)
- spark_json["firewall_components"][1]["configured_regions"][0]["end_address"] = atoc_end_address
- spark_json["protected_areas"][2]["start_address"] = stoc_start_address
- write_json(spark_json)
- return
-
- # MRAM
- # The following code is tightly coupled with the structure of the file mram.json.
- # Should we define the data structures in Python code instead of reading them from a JSON file?
- with open('firewall/mram.json', "r") as json_file:
- mram_json = json.load(json_file)
-
- mram_json["firewall_components"][0]["configured_regions"][0]["end_address"] = atoc_end_address
- mram_json["protected_areas"][0]["start_address"] = stoc_start_address
-
- # generate Slave FC configuration
- firewall_components = mram_json['firewall_components']
- protected_areas = mram_json['protected_areas']
-
- # SRAM
- handle_sram(sram_size, firewall_components, protected_areas)
-
- out_json = {}
- out_json['firewall_components'] = firewall_components
- out_json['protected_areas'] = protected_areas
-
- write_json(out_json)
-
-def update_fw_cfg_oem(file):
- filename = 'build/config/' + file
- with open(filename, "r") as json_file:
- json_text = json.load(json_file)
- with open(filename, "w") as json_file:
- json.dump(json_text, json_file, indent=2)
-
- # TODO: update/generate the Master FC sections
- #print("json_text: ", json_text)
- #json.dump("", json_file, indent=2)
-
-
-def main():
- """
- """
- if sys.version_info.major == 2:
- print("[ERROR] You need Python 3 for this application!")
- sys.exit(EXIT_WITH_ERROR)
-
- # Deal with Command Line
- parser = argparse.ArgumentParser(description=
- 'Generate STOC device configuration')
- parser.add_argument("-m", "--mram", type=str, default="5.5", help='MRAM size in MB, default 5.5')
- parser.add_argument("-s", "--sram", type=str, default="13.5", help="SRAM size in MB, default 13.5")
- parser.add_argument("-V" , "--version",
- help="Display Version Number", action="store_true")
- args = parser.parse_args()
- if args.version:
- print(TOOL_VERSION)
- sys.exit()
-
- mram_size = args.mram.rstrip('0').rstrip('.')
- sram_size = args.sram.rstrip('0').rstrip('.')
-
- gen_fw_cfg_icv("", mram_size, sram_size, "")
-
-if __name__ == "__main__":
- main()
+#!/usr/bin/env python3
+"""
+ __author__ = ""
+ __copyright__ = "ALIF Seminconductor"
+ __version__ = "0.1.0"
+ __status__ = "Dev"
+"""
+# pylint: disable=unused-argument, invalid-name, bare-except
+
+import sys
+import argparse
+import json
+import os
+import utils.toc_common
+
+TOOL_VERSION ="0.1.001" # Define Version constant for each separate tool
+
+EXIT_WITH_ERROR = 1
+
+FW_CFG_FILE = "build/fw_cfg.json"
+
+def mram_size_to_address(mram_size):
+ mram_size_int = 0
+ if mram_size == '1.8': # @todo this should be improved
+ mram_size_int = int("0x001CD000", 16)
+ elif mram_size == '1.86':
+ mram_size_int = int("0x001DD000", 16)
+ else:
+ mram_size_int = int(float(mram_size) * 1024 * 1024)
+ mram_base_int = int("0x80000000", 16)
+ stoc_start = mram_base_int + mram_size_int
+ atoc_end = stoc_start - 1
+ atoc_end_str = "0x" + hex(atoc_end).lstrip("0x").upper()
+ stoc_start_str = "0x" + hex(stoc_start).lstrip("0x").upper()
+ return atoc_end_str, stoc_start_str
+
+def handle_sram(sram_size, firewall_components, protected_areas):
+
+ if "13.5" == sram_size: # no SRAM wounding
+ #print("**** no SRAM wounding")
+ return
+
+ # load the definitions for REV_B
+ with open('firewall/sram_rev_b.json', "r") as json_file:
+ sram_json = json.load(json_file)
+
+ # Wound the Modem TCMs - FC #12
+ firewall_components.append(sram_json["firewall_components"][0])
+ protected_areas.append(sram_json["protected_areas"][0])
+
+ if "8.25" == sram_size: # no other wounding
+ #print("**** 8.25MB wounding")
+ return
+
+ if "5.75" == sram_size: # E3 with 5.75MB SRAM
+ # Wound SRAM1 - FC #4 - XNVM
+ firewall_components.append(sram_json["firewall_components"][1])
+ protected_areas.append(sram_json["protected_areas"][1])
+ #print("**** 5.75MB wounding")
+ return
+
+ if "4.5" == sram_size: # E1
+ # Wound SRAM1 - FC #4 - XNVM
+ firewall_components.append(sram_json["firewall_components"][1])
+ protected_areas.append(sram_json["protected_areas"][1])
+
+ # Wound M55-HP TCMs - 0x50000000-0x57FFFFFF
+ firewall_components.append(sram_json["firewall_components"][4])
+ protected_areas.append(sram_json["protected_areas"][4])
+ #print("**** 4.5MB wounding")
+ return
+
+ if "3.75" == sram_size: #E3 with 3.75MB SRAM:
+ # Wound SRAM0 - FC #5 - CVM
+ firewall_components.append(sram_json["firewall_components"][3])
+ protected_areas.append(sram_json["protected_areas"][3])
+
+ # Wound SRAM1 to 2MB
+ firewall_components.append(sram_json["firewall_components"][2])
+ protected_areas.append(sram_json["protected_areas"][2])
+ #print("**** 3.75MB wounding")
+ return
+
+ # Invalid sram_size - wound SRAM0, SRAM1, and the M55-HP TCMs
+ firewall_components.append(sram_json["firewall_components"][1])
+ protected_areas.append(sram_json["protected_areas"][1])
+ firewall_components.append(sram_json["firewall_components"][3])
+ protected_areas.append(sram_json["protected_areas"][3])
+ firewall_components.append(sram_json["firewall_components"][4])
+ protected_areas.append(sram_json["protected_areas"][4])
+ print("**** Invalid SRAM size!")
+
+def write_json(json_content):
+ out_file = FW_CFG_FILE
+ if (os.path.exists(out_file)):
+ os.remove(out_file)
+
+ with open(out_file, 'w') as f:
+ json.dump(json_content, f, indent=2)
+
+def gen_fw_cfg_icv(family, mram_size, sram_size, device_revision, featureSet):
+
+ atoc_end_address, stoc_start_address = mram_size_to_address(mram_size)
+ print(family)
+ if family == "Ensemble" and featureSet == "Spark":
+ # Ensemble E1C
+ with open('firewall/fw_cfg_spark.json', "r") as json_file:
+ spark_json = json.load(json_file)
+ spark_json["firewall_components"][1]["configured_regions"][0]["end_address"] = atoc_end_address
+ spark_json["protected_areas"][2]["start_address"] = stoc_start_address
+
+ # Delete the sections for the BLE protected areas
+ spark_json["firewall_components"].pop(0)
+ spark_json["protected_areas"].pop(0)
+ spark_json["protected_areas"].pop(0)
+ write_json(spark_json)
+ return;
+
+ if family == "Balletto":
+ # Balletto B1
+ with open('firewall/fw_cfg_spark.json', "r") as json_file:
+ spark_json = json.load(json_file)
+ spark_json["firewall_components"][1]["configured_regions"][0]["end_address"] = atoc_end_address
+ spark_json["protected_areas"][2]["start_address"] = stoc_start_address
+ write_json(spark_json)
+ return
+
+ # MRAM
+ # The following code is tightly coupled with the structure of the file mram.json.
+ # Should we define the data structures in Python code instead of reading them from a JSON file?
+ with open('firewall/mram.json', "r") as json_file:
+ mram_json = json.load(json_file)
+
+ if family != "Predator":
+ # Delete the OSPI mirrorred region at 0x20000000
+ mram_json["firewall_components"][0]["configured_regions"].pop(2)
+
+ mram_json["firewall_components"][0]["configured_regions"][0]["end_address"] = atoc_end_address
+ mram_json["protected_areas"][0]["start_address"] = stoc_start_address
+
+ # generate Slave FC configuration
+ firewall_components = mram_json['firewall_components']
+ protected_areas = mram_json['protected_areas']
+
+ # SRAM
+ handle_sram(sram_size, firewall_components, protected_areas)
+
+ out_json = {}
+ out_json['firewall_components'] = firewall_components
+ out_json['protected_areas'] = protected_areas
+
+ write_json(out_json)
+
+def update_fw_cfg_oem(file):
+ filename = 'build/config/' + file
+ with open(filename, "r") as json_file:
+ json_text = json.load(json_file)
+ with open(filename, "w") as json_file:
+ json.dump(json_text, json_file, indent=2)
+
+ # TODO: update/generate the Master FC sections
+ #print("json_text: ", json_text)
+ #json.dump("", json_file, indent=2)
+
+
+def main():
+ """
+ """
+ if sys.version_info.major == 2:
+ print("[ERROR] You need Python 3 for this application!")
+ sys.exit(EXIT_WITH_ERROR)
+
+ # Deal with Command Line
+ parser = argparse.ArgumentParser(description=
+ 'Generate STOC device configuration')
+ parser.add_argument("-m", "--mram", type=str, default="5.5", help='MRAM size in MB, default 5.5')
+ parser.add_argument("-s", "--sram", type=str, default="13.5", help="SRAM size in MB, default 13.5")
+ parser.add_argument("-V" , "--version",
+ help="Display Version Number", action="store_true")
+ args = parser.parse_args()
+ if args.version:
+ print(TOOL_VERSION)
+ sys.exit()
+
+ mram_size = args.mram.rstrip('0').rstrip('.')
+ sram_size = args.sram.rstrip('0').rstrip('.')
+
+ gen_fw_cfg_icv("", mram_size, sram_size, "")
+
+if __name__ == "__main__":
+ main()
diff --git a/tools/alif/utils/global-cfg.db b/tools/alif/utils/global-cfg.db
index 0e4811287..6ac442f7d 100755
--- a/tools/alif/utils/global-cfg.db
+++ b/tools/alif/utils/global-cfg.db
@@ -7,4 +7,4 @@
"Interface": "isp",
"Jtag-adapter": "J-Link"
}
-}
+}
\ No newline at end of file
diff --git a/tools/alif/utils/hashesDB.db b/tools/alif/utils/hashesDB.db
index 58fe2a922..6244afc7a 100755
--- a/tools/alif/utils/hashesDB.db
+++ b/tools/alif/utils/hashesDB.db
@@ -1,6 +1,6 @@
-{
- "c879a64b28100754b462589ae1f34d3b":"DEV",
- "7715fe1a57f193ef2a856f052aa24779":"DEV",
- "af9771e6f171ee6de39106bd812babf0":"DEV",
- "f049442ecc7900a838d34c31d71e62e6":"DEV"
+{
+ "c879a64b28100754b462589ae1f34d3b":"DEV",
+ "7715fe1a57f193ef2a856f052aa24779":"DEV",
+ "af9771e6f171ee6de39106bd812babf0":"DEV",
+ "f049442ecc7900a838d34c31d71e62e6":"DEV"
}
\ No newline at end of file
diff --git a/tools/alif/utils/hbk_gen_util.py b/tools/alif/utils/hbk_gen_util.py
index 4b67a9fbc..bee3250d3 100755
--- a/tools/alif/utils/hbk_gen_util.py
+++ b/tools/alif/utils/hbk_gen_util.py
@@ -1,178 +1,178 @@
-#!/usr/bin/env python3
-#
-# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
-#
-
-####################################################################
-# Filename - hbk_gen_util.py
-# Description - This file is responsible for creation of public key
-# HASH and its corresponding number of Zeroes
-# as it should be saved in the OTP/NVM
-####################################################################
-
-import optparse
-import sys
-import os
-from utils.common import util_logger
-from utils.common import cryptolayer
-
-# Prim key hash file name
-PRIM_KEY_HASH_FILE_NAME = "prim_key_hash.txt"
-ZEROS_NUM_FILES_NAME = "zero_bits_in_hash.txt"
-# Util's log file
-LOG_FILENAME = "gen_hbk_log.log"
-
-OUTPUT_SIZE_SHA_256 = 32
-OUTPUT_SIZE_SHA_256_TRUNC = int(OUTPUT_SIZE_SHA_256/2)
-BITS_WITHIN_WORD = 32
-BYTES_WITHIN_WORD = 4
-
-
-def create_word_list(byte_array, byte_array_word_count, endianness):
- """
- Creates a hexadecimal (32 bits) word list out of a byte array representation of an input number
- :param byte_array: input number represented as a list of the bytes it consists of
- :param byte_array_word_count: number of (32 bit) words in input array
- :param endianness: output byte order -> little endian 'L' or big endian 'B'
- :return: 32 bit word list
- """
- word_list = []
- if not isinstance(byte_array, list) or not isinstance(byte_array_word_count, int):
- raise TypeError("input parameter byte_array or byte_array_word_count has wrong type")
- if endianness != 'L' and endianness != 'B':
- raise ValueError("input parameter endianness has wrong value")
- else:
- for i in range(byte_array_word_count):
- if endianness == 'L':
- current_word = byte_array[i * 4]
- current_word = current_word + (byte_array[i * 4 + 1] << 8)
- current_word = current_word + (byte_array[i * 4 + 2] << 16)
- current_word = current_word + (byte_array[i * 4 + 3] << 24)
- else:
- current_word = byte_array[i * 4 + 3]
- current_word = current_word + (byte_array[i * 4 + 2] << 8)
- current_word = current_word + (byte_array[i * 4 + 1] << 16)
- current_word = current_word + (byte_array[i * 4] << 24)
- word_list.append(current_word)
- return word_list
-
-
-def count_zero_bits_in_bytes(bytes_input, bit_size):
- """
- Calculate the number of zero bits in a number given in a bytes representation.
-
- :param bytes_input: (bytes) input number
- :param bit_size: size of bytes_input in bits
- :return: (int) number of zero bits
-
- Returns TypeError if parameter bytes_input is not "bytes"
- Return TypeError if parameter bit_size is not int
- """
- # converting to str in binary representation - byteorder/endianness is irrelevant for this function
- binary_input = format(int.from_bytes(bytes_input, byteorder="big"), 'b').zfill(bit_size)
- return binary_input.count("0")
-
-
-class ArgumentParser:
- def __init__(self):
- self.key_filename = None
- self.output_endianness = None
- self.hash_format = None
- self.result_hash_filename = None
- self.result_zeros_filename = None
- self.log_filename = None
- self.parser = optparse.OptionParser()
- self.parser.add_option("-k", "--key", dest="key_filename",
- help="!Mandatory! The name of the PEM file holding the RSA public key")
- self.parser.add_option("-e", "--endian", dest="output_endianness", default="L",
- metavar="END",
- help="Sets the output endianness: END=B for Big Endian or END=L for Little Endian ["
- "default: %default]")
- self.parser.add_option("-f", "--format", dest="hash_format", default="SHA256",
- metavar="HASHMODE",
- help="Sets the hash format: HASHMODE=SHA256 for full SHA-256 hash (Hbk) or "
- "HASHMODE=SHA256_TRUNC for truncated SHA-256 hash (Hbk0 or Hbk1) [default: "
- "%default]")
- self.parser.add_option("-o", "--out-hash", dest="result_hash_filename", default=PRIM_KEY_HASH_FILE_NAME,
- metavar="FILE",
- help="Writes hash result to FILE [default: %default]")
- self.parser.add_option("-z", "--out-zeros", dest="result_zeros_filename", default=ZEROS_NUM_FILES_NAME,
- metavar="FILE",
- help="Writes number of zero bits in the hash result to FILE [default: %default]")
- self.parser.add_option("-l", "--log", dest="log_filename", default=LOG_FILENAME,
- metavar="FILE",
- help="Writes event log to FILE [default: %default]")
-
- def parse_arguments(self, args):
- (options, args) = self.parser.parse_args(args)
- if len(args) > 0:
- self.parser.error("incorrect number of positional arguments, use option -h for help")
-
- self.key_filename = options.key_filename
- if self.key_filename is None:
- self.parser.error("Option -k must be given, use option -h for help")
-
- self.output_endianness = options.output_endianness
- if self.output_endianness is not None and self.output_endianness != "B" and self.output_endianness != "L":
- self.parser.error("Illegal argument for output endianness (option -e)")
-
- self.hash_format = options.hash_format
- if self.hash_format is not None and self.hash_format != "SHA256" and self.hash_format != "SHA256_TRUNC":
- self.parser.error("Illegal argument for hash format (option -f)")
-
- self.result_hash_filename = options.result_hash_filename
- self.result_zeros_filename = options.result_zeros_filename
- self.log_filename = options.log_filename
-
-
-class HbkGenerator:
- def __init__(self, argument_parser, logger):
- self.argument_parser = argument_parser
- self.logger = logger
- self.hash_digest = None
- self.hash_word_list = None
- self.zero_bits = None
-
- # decide hash output size
- if self.argument_parser.hash_format == "SHA256":
- self.outputSize = OUTPUT_SIZE_SHA_256
- else:
- self.outputSize = OUTPUT_SIZE_SHA_256_TRUNC
- self.output_word_count = self.outputSize // BYTES_WITHIN_WORD
- self.output_bit_count = self.output_word_count * BITS_WITHIN_WORD
-
- def generate_hbk(self):
- self.logger.info("Step 1: Calculating hash")
- self.hash_digest = cryptolayer.Common.get_hashed_n_and_np_from_public_key(self.argument_parser.key_filename,
- self.logger)
- self.hash_digest = self.hash_digest[:self.outputSize]
- self.hash_word_list = create_word_list(list(self.hash_digest), self.output_word_count,
- self.argument_parser.output_endianness)
- self.logger.info("Step 2: Calculate num of zero bits over the hash")
- self.zero_bits = count_zero_bits_in_bytes(self.hash_digest, self.output_bit_count)
-
- def write_output_files(self):
- hex_list = [format(item, "#08x") for item in self.hash_word_list]
- hash_output_string = ", ".join(hex_list)
- with open(self.argument_parser.result_hash_filename, 'w') as hash_output_file:
- hash_output_file.write(hash_output_string)
- #with open(self.argument_parser.result_zeros_filename, 'w') as zeros_output_file:
- # zeros_output_file.write(hex(self.zero_bits))
-
-
-def main(args):
- if not (sys.version_info.major == 3 and sys.version_info.minor >= 5):
- print("The script requires Python3.5 or later!")
- sys.exit(-1)
- # parse arguments
- the_argument_parser = ArgumentParser()
- the_argument_parser.parse_arguments(args)
- # get logging up and running
- the_logger = util_logger.UtilLogger(the_argument_parser.log_filename, "HBK Generator")
- # perform main task
- generator = HbkGenerator(the_argument_parser, the_logger)
- generator.generate_hbk()
- generator.write_output_files()
- the_logger.info("Script completed successfully")
+#!/usr/bin/env python3
+#
+# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
+#
+
+####################################################################
+# Filename - hbk_gen_util.py
+# Description - This file is responsible for creation of public key
+# HASH and its corresponding number of Zeroes
+# as it should be saved in the OTP/NVM
+####################################################################
+
+import optparse
+import sys
+import os
+from utils.common import util_logger
+from utils.common import cryptolayer
+
+# Prim key hash file name
+PRIM_KEY_HASH_FILE_NAME = "prim_key_hash.txt"
+ZEROS_NUM_FILES_NAME = "zero_bits_in_hash.txt"
+# Util's log file
+LOG_FILENAME = "gen_hbk_log.log"
+
+OUTPUT_SIZE_SHA_256 = 32
+OUTPUT_SIZE_SHA_256_TRUNC = int(OUTPUT_SIZE_SHA_256/2)
+BITS_WITHIN_WORD = 32
+BYTES_WITHIN_WORD = 4
+
+
+def create_word_list(byte_array, byte_array_word_count, endianness):
+ """
+ Creates a hexadecimal (32 bits) word list out of a byte array representation of an input number
+ :param byte_array: input number represented as a list of the bytes it consists of
+ :param byte_array_word_count: number of (32 bit) words in input array
+ :param endianness: output byte order -> little endian 'L' or big endian 'B'
+ :return: 32 bit word list
+ """
+ word_list = []
+ if not isinstance(byte_array, list) or not isinstance(byte_array_word_count, int):
+ raise TypeError("input parameter byte_array or byte_array_word_count has wrong type")
+ if endianness != 'L' and endianness != 'B':
+ raise ValueError("input parameter endianness has wrong value")
+ else:
+ for i in range(byte_array_word_count):
+ if endianness == 'L':
+ current_word = byte_array[i * 4]
+ current_word = current_word + (byte_array[i * 4 + 1] << 8)
+ current_word = current_word + (byte_array[i * 4 + 2] << 16)
+ current_word = current_word + (byte_array[i * 4 + 3] << 24)
+ else:
+ current_word = byte_array[i * 4 + 3]
+ current_word = current_word + (byte_array[i * 4 + 2] << 8)
+ current_word = current_word + (byte_array[i * 4 + 1] << 16)
+ current_word = current_word + (byte_array[i * 4] << 24)
+ word_list.append(current_word)
+ return word_list
+
+
+def count_zero_bits_in_bytes(bytes_input, bit_size):
+ """
+ Calculate the number of zero bits in a number given in a bytes representation.
+
+ :param bytes_input: (bytes) input number
+ :param bit_size: size of bytes_input in bits
+ :return: (int) number of zero bits
+
+ Returns TypeError if parameter bytes_input is not "bytes"
+ Return TypeError if parameter bit_size is not int
+ """
+ # converting to str in binary representation - byteorder/endianness is irrelevant for this function
+ binary_input = format(int.from_bytes(bytes_input, byteorder="big"), 'b').zfill(bit_size)
+ return binary_input.count("0")
+
+
+class ArgumentParser:
+ def __init__(self):
+ self.key_filename = None
+ self.output_endianness = None
+ self.hash_format = None
+ self.result_hash_filename = None
+ self.result_zeros_filename = None
+ self.log_filename = None
+ self.parser = optparse.OptionParser()
+ self.parser.add_option("-k", "--key", dest="key_filename",
+ help="!Mandatory! The name of the PEM file holding the RSA public key")
+ self.parser.add_option("-e", "--endian", dest="output_endianness", default="L",
+ metavar="END",
+ help="Sets the output endianness: END=B for Big Endian or END=L for Little Endian ["
+ "default: %default]")
+ self.parser.add_option("-f", "--format", dest="hash_format", default="SHA256",
+ metavar="HASHMODE",
+ help="Sets the hash format: HASHMODE=SHA256 for full SHA-256 hash (Hbk) or "
+ "HASHMODE=SHA256_TRUNC for truncated SHA-256 hash (Hbk0 or Hbk1) [default: "
+ "%default]")
+ self.parser.add_option("-o", "--out-hash", dest="result_hash_filename", default=PRIM_KEY_HASH_FILE_NAME,
+ metavar="FILE",
+ help="Writes hash result to FILE [default: %default]")
+ self.parser.add_option("-z", "--out-zeros", dest="result_zeros_filename", default=ZEROS_NUM_FILES_NAME,
+ metavar="FILE",
+ help="Writes number of zero bits in the hash result to FILE [default: %default]")
+ self.parser.add_option("-l", "--log", dest="log_filename", default=LOG_FILENAME,
+ metavar="FILE",
+ help="Writes event log to FILE [default: %default]")
+
+ def parse_arguments(self, args):
+ (options, args) = self.parser.parse_args(args)
+ if len(args) > 0:
+ self.parser.error("incorrect number of positional arguments, use option -h for help")
+
+ self.key_filename = options.key_filename
+ if self.key_filename is None:
+ self.parser.error("Option -k must be given, use option -h for help")
+
+ self.output_endianness = options.output_endianness
+ if self.output_endianness is not None and self.output_endianness != "B" and self.output_endianness != "L":
+ self.parser.error("Illegal argument for output endianness (option -e)")
+
+ self.hash_format = options.hash_format
+ if self.hash_format is not None and self.hash_format != "SHA256" and self.hash_format != "SHA256_TRUNC":
+ self.parser.error("Illegal argument for hash format (option -f)")
+
+ self.result_hash_filename = options.result_hash_filename
+ self.result_zeros_filename = options.result_zeros_filename
+ self.log_filename = options.log_filename
+
+
+class HbkGenerator:
+ def __init__(self, argument_parser, logger):
+ self.argument_parser = argument_parser
+ self.logger = logger
+ self.hash_digest = None
+ self.hash_word_list = None
+ self.zero_bits = None
+
+ # decide hash output size
+ if self.argument_parser.hash_format == "SHA256":
+ self.outputSize = OUTPUT_SIZE_SHA_256
+ else:
+ self.outputSize = OUTPUT_SIZE_SHA_256_TRUNC
+ self.output_word_count = self.outputSize // BYTES_WITHIN_WORD
+ self.output_bit_count = self.output_word_count * BITS_WITHIN_WORD
+
+ def generate_hbk(self):
+ self.logger.info("Step 1: Calculating hash")
+ self.hash_digest = cryptolayer.Common.get_hashed_n_and_np_from_public_key(self.argument_parser.key_filename,
+ self.logger)
+ self.hash_digest = self.hash_digest[:self.outputSize]
+ self.hash_word_list = create_word_list(list(self.hash_digest), self.output_word_count,
+ self.argument_parser.output_endianness)
+ self.logger.info("Step 2: Calculate num of zero bits over the hash")
+ self.zero_bits = count_zero_bits_in_bytes(self.hash_digest, self.output_bit_count)
+
+ def write_output_files(self):
+ hex_list = [format(item, "#08x") for item in self.hash_word_list]
+ hash_output_string = ", ".join(hex_list)
+ with open(self.argument_parser.result_hash_filename, 'w') as hash_output_file:
+ hash_output_file.write(hash_output_string)
+ #with open(self.argument_parser.result_zeros_filename, 'w') as zeros_output_file:
+ # zeros_output_file.write(hex(self.zero_bits))
+
+
+def main(args):
+ if not (sys.version_info.major == 3 and sys.version_info.minor >= 5):
+ print("The script requires Python3.5 or later!")
+ sys.exit(-1)
+ # parse arguments
+ the_argument_parser = ArgumentParser()
+ the_argument_parser.parse_arguments(args)
+ # get logging up and running
+ the_logger = util_logger.UtilLogger(the_argument_parser.log_filename, "HBK Generator")
+ # perform main task
+ generator = HbkGenerator(the_argument_parser, the_logger)
+ generator.generate_hbk()
+ generator.write_output_files()
+ the_logger.info("Script completed successfully")
diff --git a/tools/alif/utils/jtag-adapters.db b/tools/alif/utils/jtag-adapters.db
index 97f334b14..97d7edcbf 100755
--- a/tools/alif/utils/jtag-adapters.db
+++ b/tools/alif/utils/jtag-adapters.db
@@ -1,2 +1,2 @@
-J-Link
-
+J-Link
+
diff --git a/tools/alif/utils/key/OEMRoT.pem b/tools/alif/utils/key/OEMRoT.pem
index 029965632..802f1ce4a 100755
--- a/tools/alif/utils/key/OEMRoT.pem
+++ b/tools/alif/utils/key/OEMRoT.pem
@@ -1,42 +1,42 @@
------BEGIN ENCRYPTED PRIVATE KEY-----
-MIIHbTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIwzEe5UOoVsYCAggA
-MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBB5WgZjHz4EBbUisNB0c5gqBIIH
-EKUWBTX0eZYKjYt5kwqHzt16B2jU45ELi3RiMl4Fv7nQwcvkGJWs+j+Ph9RY/1zh
-No6ZWmgzjVPFgSozvsU7GHX4zANXxgShUXln598NCkqq2h7FigVV2CcibezX6TxN
-Y6YqFVu8LRqzKk/7biThz7l5zXyRC8OXzPTV2PR9puOAjsw9gdgzhJlz883dxgO8
-9ZumvhyzACtkCzkG7hGQcsoJXgFReGFjqaTB01k6V7g/06qKoJu69nw9AXaJ18ho
-v12gDYSwpHk+dex4URTuEMi6Mw31FouJoQLY5PJmh8PvWbz7pJ2kPrrwD6SaKqhW
-TO9DYmnXdm7oovdu+2QOJLwWjORaK/11HXI2smWOLpZ8Jl5LNigeu/DXCWFk5PQO
-p1vuAQYHeQDuSQTWkvJSNZ0WJ2EcgJjd/uRn2QjtNywOhhbnSlCSAVWOFfNzAL4Y
-Rci3UQllRuzozQ1X/gZKgLfPFv1FqUtz21fvhDmFH2tBaOgqHgW/NhMBpFGEqo6s
-b0/Ab6QvZ1BnjQcRve8yalnEIjcInv+KJsRoYvaG6sww0XjT3/sA47EHBH7o3sjM
-5+YFqB1+dpgaTi+VFvnRgYWSNf0YDb2xUX53WrZSMCie5dZX21RlJLC8A02csKlD
-dhYOaVr/zjO99jWMyb6/T+vxsko0hvhtjgezm7Q+vHHWyMYsoPKyOGmht6ppZqUb
-TIxz0cWMQsFaIiOo53FguqacIRpxOInHUC//1syPxB5RbW+fuklJsZplGA60W2L7
-/MzuSWyFUypuTAbpzDqqDtg/2fxD56/Qzi4bhLa9OLBz70flQZAk5UN/+Ob8JUel
-BYrToW7H5K7Prj6S3A6LPs98D0aRGmu3SC5tbQKzCsvnBZvZllSVQZp0h5+4SIQS
-ZIv3wDsSGDaKndXgspsp3h1VswVRggHV5O6jps0+BvWPIZEsKU4JxQd9fr4ekRrb
-j6ZlxGiMGDQES1fTpoV78usK91LMyFKHRSRl+QjD6ewdhnZtUN+lccEP9wv908fR
-Or/iRqoAfvmn4ezUTPVH2h13tIEVs/Kh3IMoqlhntwJd4uCZbdr525T+CRtywutm
-ac/P8t1dmSwuNxXe+kcJp62S/wRAT1jgyRRlfPn1GFsFex92bg9DgQimKmNCadfX
-Jms0bXLuAb1XZcEXBOglzmwvut5TKMEKcEwdW5gJ7yNih1fJ0p0FOD/pXcDnnncC
-pGqltRuIo087CJElk2XCuubiihGPKSSdFCId07K24t/IM1ZI9S/NCJiqAXR+qKaQ
-384AoTSnuBiRKKWgqD+jTrEMqaKEFcU/s5HuU6d/9ujkAEaf1MkxyjyRt3dsowB9
-sPLEFd9eQoHVnGAg3i/xfkLiwhH+Ok67L41Wcna70A42g8O5HZJCRh3wdL2Gnqso
-is9LqXSZzwEQcmDIw44C73SW4C7XvJJs7BGj3xb33+pL4bZnmsgTgKzyN8toaFY4
-uPqjMryX9S2Mi3NH/k+OJ9j3fVK/dad6eJYNQAm/YnP75C1gKexksk0cA6ZF5trs
-RuSBB9JmgMFdaa/3ZblFL0REW1BQANkN7D9tOXV9+YReaxfDZ10DXwK0Zapgp4vo
-n1E+IgAg8E2+8tXzyeGXDuvoegWkIDEyvmLXc9JH+iyEazue07A8JlCXZxZ0Rms4
-spYEKg+pim3rhrpO33F+4f/2iz1W9TQGIxO/1ZCZcVKAFiuhqSApA66F2FI4QXFw
-FKlelbbULrbZBPj/pmTLj7GMSdxhiycmDHiXEbdqCjLdhG1W0cWMc2o2mBjtlc1W
-Zj/ujMlz4IXQvY/qo4tdXtjmSEQul4u4Ekr3/NobiKe5Hv40MK1V6vKiA5Ib+vyR
-7ZnRGi8rV9RSR2ko8K1TY8W0zFMFXiPGmmW5j/hT+58/6YUk5AsFI0QcHxqtIYyp
-6LjqsgNpzGkuu+DWoJ/bEgPCYagEWZ4u/RM9Fqg5+NAn6ZDEeiZdHgpjOOVyfyvT
-u6Va9cXRPkSH0PSX/RHyZRBk2FcHweTu3dvJ8BInKxsR6uSeN/0sE/ZLowGdeQ8M
-bxcmZoqCETbWUZ3/Kg4dc+kM8rD3/Ap1sZlfOe16sHrVxMg01Z5D65yLpCL8lO3k
-5k9l8jnA9QzQXow241X4b2c+jzQ2rQkQ+Lut626iq65WhtK6MJboOGVDNbZh6LJB
-jR/ybeN1Qb1N18kdXK9LP8+6GiFhEogVBNtqlr6td87YXe9cnV6OOhjyL5kpX453
-reHk5nChOdEgzhgzrwOV9O9IzyCFdh+Un2eIG3YUWSmvyz1nhFgIC3OH0mKoxUxB
-OzLcUDb+aWJFN6FJYl4/u+RfVuK8ji4pcdIvL4ysbUlH4oXRqIpVAeEXV3KR+WrX
-9MqF1nfn3n+FZYpUFajeVPuuf8logIKYP/UZTqMJSzmk
------END ENCRYPTED PRIVATE KEY-----
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIHbTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIwzEe5UOoVsYCAggA
+MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBB5WgZjHz4EBbUisNB0c5gqBIIH
+EKUWBTX0eZYKjYt5kwqHzt16B2jU45ELi3RiMl4Fv7nQwcvkGJWs+j+Ph9RY/1zh
+No6ZWmgzjVPFgSozvsU7GHX4zANXxgShUXln598NCkqq2h7FigVV2CcibezX6TxN
+Y6YqFVu8LRqzKk/7biThz7l5zXyRC8OXzPTV2PR9puOAjsw9gdgzhJlz883dxgO8
+9ZumvhyzACtkCzkG7hGQcsoJXgFReGFjqaTB01k6V7g/06qKoJu69nw9AXaJ18ho
+v12gDYSwpHk+dex4URTuEMi6Mw31FouJoQLY5PJmh8PvWbz7pJ2kPrrwD6SaKqhW
+TO9DYmnXdm7oovdu+2QOJLwWjORaK/11HXI2smWOLpZ8Jl5LNigeu/DXCWFk5PQO
+p1vuAQYHeQDuSQTWkvJSNZ0WJ2EcgJjd/uRn2QjtNywOhhbnSlCSAVWOFfNzAL4Y
+Rci3UQllRuzozQ1X/gZKgLfPFv1FqUtz21fvhDmFH2tBaOgqHgW/NhMBpFGEqo6s
+b0/Ab6QvZ1BnjQcRve8yalnEIjcInv+KJsRoYvaG6sww0XjT3/sA47EHBH7o3sjM
+5+YFqB1+dpgaTi+VFvnRgYWSNf0YDb2xUX53WrZSMCie5dZX21RlJLC8A02csKlD
+dhYOaVr/zjO99jWMyb6/T+vxsko0hvhtjgezm7Q+vHHWyMYsoPKyOGmht6ppZqUb
+TIxz0cWMQsFaIiOo53FguqacIRpxOInHUC//1syPxB5RbW+fuklJsZplGA60W2L7
+/MzuSWyFUypuTAbpzDqqDtg/2fxD56/Qzi4bhLa9OLBz70flQZAk5UN/+Ob8JUel
+BYrToW7H5K7Prj6S3A6LPs98D0aRGmu3SC5tbQKzCsvnBZvZllSVQZp0h5+4SIQS
+ZIv3wDsSGDaKndXgspsp3h1VswVRggHV5O6jps0+BvWPIZEsKU4JxQd9fr4ekRrb
+j6ZlxGiMGDQES1fTpoV78usK91LMyFKHRSRl+QjD6ewdhnZtUN+lccEP9wv908fR
+Or/iRqoAfvmn4ezUTPVH2h13tIEVs/Kh3IMoqlhntwJd4uCZbdr525T+CRtywutm
+ac/P8t1dmSwuNxXe+kcJp62S/wRAT1jgyRRlfPn1GFsFex92bg9DgQimKmNCadfX
+Jms0bXLuAb1XZcEXBOglzmwvut5TKMEKcEwdW5gJ7yNih1fJ0p0FOD/pXcDnnncC
+pGqltRuIo087CJElk2XCuubiihGPKSSdFCId07K24t/IM1ZI9S/NCJiqAXR+qKaQ
+384AoTSnuBiRKKWgqD+jTrEMqaKEFcU/s5HuU6d/9ujkAEaf1MkxyjyRt3dsowB9
+sPLEFd9eQoHVnGAg3i/xfkLiwhH+Ok67L41Wcna70A42g8O5HZJCRh3wdL2Gnqso
+is9LqXSZzwEQcmDIw44C73SW4C7XvJJs7BGj3xb33+pL4bZnmsgTgKzyN8toaFY4
+uPqjMryX9S2Mi3NH/k+OJ9j3fVK/dad6eJYNQAm/YnP75C1gKexksk0cA6ZF5trs
+RuSBB9JmgMFdaa/3ZblFL0REW1BQANkN7D9tOXV9+YReaxfDZ10DXwK0Zapgp4vo
+n1E+IgAg8E2+8tXzyeGXDuvoegWkIDEyvmLXc9JH+iyEazue07A8JlCXZxZ0Rms4
+spYEKg+pim3rhrpO33F+4f/2iz1W9TQGIxO/1ZCZcVKAFiuhqSApA66F2FI4QXFw
+FKlelbbULrbZBPj/pmTLj7GMSdxhiycmDHiXEbdqCjLdhG1W0cWMc2o2mBjtlc1W
+Zj/ujMlz4IXQvY/qo4tdXtjmSEQul4u4Ekr3/NobiKe5Hv40MK1V6vKiA5Ib+vyR
+7ZnRGi8rV9RSR2ko8K1TY8W0zFMFXiPGmmW5j/hT+58/6YUk5AsFI0QcHxqtIYyp
+6LjqsgNpzGkuu+DWoJ/bEgPCYagEWZ4u/RM9Fqg5+NAn6ZDEeiZdHgpjOOVyfyvT
+u6Va9cXRPkSH0PSX/RHyZRBk2FcHweTu3dvJ8BInKxsR6uSeN/0sE/ZLowGdeQ8M
+bxcmZoqCETbWUZ3/Kg4dc+kM8rD3/Ap1sZlfOe16sHrVxMg01Z5D65yLpCL8lO3k
+5k9l8jnA9QzQXow241X4b2c+jzQ2rQkQ+Lut626iq65WhtK6MJboOGVDNbZh6LJB
+jR/ybeN1Qb1N18kdXK9LP8+6GiFhEogVBNtqlr6td87YXe9cnV6OOhjyL5kpX453
+reHk5nChOdEgzhgzrwOV9O9IzyCFdh+Un2eIG3YUWSmvyz1nhFgIC3OH0mKoxUxB
+OzLcUDb+aWJFN6FJYl4/u+RfVuK8ji4pcdIvL4ysbUlH4oXRqIpVAeEXV3KR+WrX
+9MqF1nfn3n+FZYpUFajeVPuuf8logIKYP/UZTqMJSzmk
+-----END ENCRYPTED PRIVATE KEY-----
diff --git a/tools/alif/utils/key/OEMRoTPublic.pem b/tools/alif/utils/key/OEMRoTPublic.pem
index fc03ffd5e..9e9955b21 100755
--- a/tools/alif/utils/key/OEMRoTPublic.pem
+++ b/tools/alif/utils/key/OEMRoTPublic.pem
@@ -1,11 +1,11 @@
------BEGIN PUBLIC KEY-----
-MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAyhcTU6X4XO+guLUUoUzF
-LnTPm0Wd2HBoX+D8AHAE5dcggCp8s18TfRBlzM3hMEWgPylB9Wc8lNPGihgGeG3j
-PyrCDAlkJzSzW+Q/Um7kP7OradtZQlsi4OMzSoluv7asemCJ9aL5JWUKyfy8vleW
-Kx4ihnkKgfrfodfB0xnKtffV+QorpRZldNjq4itItPbs7+AykKWyb8+Jr8Q+Angg
-3olgoitIZfQ+1cMFI/9tv442jGInpLl//JAz8aZiZAb4PLWUX2B/C96u1A0rXuDg
-uBGQyLoM55by0YQve7A45wwf2NMQ5N9h0OygaQ9AReJV1sy8I3RQqiw2YZCV7eQB
-l3u+2mS2alqnImT7Wd+pLk5URlDlTxy/ktAS37K91UJtyPt/gBDnyxbLNW3y3H8T
-RFTLtgPbLswlePdeaG9IxliSCBweodW56ug2+SYQqMU/r6XeDDKK/dtbAz8SFdAH
-UXGfFyycO8Fj6XcIsMAnaPdi2yzxsMKzQp4QXVois5m3AgMBAAE=
------END PUBLIC KEY-----
+-----BEGIN PUBLIC KEY-----
+MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAyhcTU6X4XO+guLUUoUzF
+LnTPm0Wd2HBoX+D8AHAE5dcggCp8s18TfRBlzM3hMEWgPylB9Wc8lNPGihgGeG3j
+PyrCDAlkJzSzW+Q/Um7kP7OradtZQlsi4OMzSoluv7asemCJ9aL5JWUKyfy8vleW
+Kx4ihnkKgfrfodfB0xnKtffV+QorpRZldNjq4itItPbs7+AykKWyb8+Jr8Q+Angg
+3olgoitIZfQ+1cMFI/9tv442jGInpLl//JAz8aZiZAb4PLWUX2B/C96u1A0rXuDg
+uBGQyLoM55by0YQve7A45wwf2NMQ5N9h0OygaQ9AReJV1sy8I3RQqiw2YZCV7eQB
+l3u+2mS2alqnImT7Wd+pLk5URlDlTxy/ktAS37K91UJtyPt/gBDnyxbLNW3y3H8T
+RFTLtgPbLswlePdeaG9IxliSCBweodW56ug2+SYQqMU/r6XeDDKK/dtbAz8SFdAH
+UXGfFyycO8Fj6XcIsMAnaPdi2yzxsMKzQp4QXVois5m3AgMBAAE=
+-----END PUBLIC KEY-----
diff --git a/tools/alif/utils/key/OEMSBContent.pem b/tools/alif/utils/key/OEMSBContent.pem
index a596cc35c..6ee9c649e 100755
--- a/tools/alif/utils/key/OEMSBContent.pem
+++ b/tools/alif/utils/key/OEMSBContent.pem
@@ -1,42 +1,42 @@
------BEGIN ENCRYPTED PRIVATE KEY-----
-MIIHbTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIGbczFX0cty4CAggA
-MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBBlskH16EZh6ZjBPJdkKE2CBIIH
-ENBB2r0djbJYsncwmGCluBhlJ/FC7CEmcq54z4FadSvJE1bF5OQo8vsRWJC5fZHx
-Q+/+kpNKBZT+8en3NQO+7DIvixoWHR/L2D7e0QYMbvQfJ17QVLE+wcqyDpk+D/hK
-HRSvaHv3wTp9sc88jphH5DzXyrHmOHVHaZHzYQC3/mHRgliEM2ghxPsLwDAfbK1c
-P9SZA0eiH7z9vttL6HSji+gx9UvxNIXWy+NiFhiycDFtLlulrtWmc73m3I5MgCMO
-6OGvUpG7in3qDnTA2YbC5KZVjGZlmixPbrtsFPm0blWwms6/upczEej+NLXgGaDG
-7Jgwsg9TjAZiQHRJ4qbXMiGnfsw6LMlIs9wS1jqW8D/tKIxR6cJ4KyGUFIBQXCox
-krJZoNRE9DaiGNaQEFoTsbqAGSjn4qYj7hUuDI73Ep8wFeqaigxP/JxL6X+FKbng
-v+68FPYTfe0x3RuNgTNEjETVKuZwtjjJMRZaFzm6OWwV92IvjBSkhMBwq6nHKzZG
-7CiCDtZjLdO+ny0AStHrvHyXC60IfPTCJuW4z/0uJjP7+jGRX0FxdBhc3PgBNW/4
-B4vZ6nbP/Z6+06F1Z1Crl22pVuMDCqdA0Z0CHtYJXF266HFXU5oVE9J+w2hKNgMe
-U2lsG/EYbIx4suSokdtUTYWQeLdnGx8TwA6m1CKnAZ+pIr6Vw+tFeOa20oAlq0ac
-4R+mS6MIS8DeFKrSpxWSsGaIBKuduDIZDTTJMJZuQLUAkVCKnPqltw56/VLmZmcV
-r4BfWfGqPNTdBoZh+LwhoPc3uPY7BMy8kdEHfxzwGFY3Ngdskq7goQ/V8HXErxjI
-xvYxGNwFAYCy6Yg/PBtLXeJyrko1Ww9kZ9Dc7IlDa6NExkm99ct+b5zlvXqnT0Z/
-kpqHmqfQgBXlOXS9Iaf/PSvvtTrF2biMyFDWkLUy60cwzNoCAR1oNn9EylQ0d16y
-9kFnIauVmGjSyWizZOONq3CgHpvGr9gKjegnqsHkFizemz/sPJzNaAlnKfN47Y9u
-ZBIVzQLmnDaQo04BwwCNlJo9+thYRR8Jz6YVuDRUNvite2L2urHAnat1/5S6X6od
-37eP87l9OpHl0hG76LtSDioBELR+pqiNDZMc20slmivqYyPCLFjVkbqGDoeYNhiA
-9T3SsF2S+kdXBNpyV2AzSWZKE9KwJvc63iiRVAGe11fABpkJvS0DbwtpZeHcAHCd
-6TlL0nbnr3f5zQBLyHAGypJ8nwBcVjwq8GaiIRQgmsgXBY25wyz8xCpNBE3DEPFv
-3SQqUTmFOgiBYHLyaIAvScI9moDrmm3nLtel7JiTyhyNjgTPz6TbKGGNo8umilKD
-R7oq+nkyF7/Zx2ddge50IHyx4q0MK79VLOAzr1xR9nLW6HA8XEdq0+JezwSEnFxT
-87cATY7omYN1/WN6xPjTVfM4sdsEWTUTBYfwtBSNhmXyPjIdCfgseqx3EszuwKpG
-2/b31eKVI+IFoYvs6rZR+z7MAzWMQRtmtO0hAbzn05GVv/U6yUbyd77Iqq29YZKS
-cBlNXZVz51d08PPD1XstHQd5BEXJEjxVhYx4fREBc+oBBoOGBA52de+ciOJRcg0d
-2/MB5TNsGNA3vIcGjPucIJpNNpFd3fNSCm9oCKV07jaW2ACcLZ1Fxe8cdueXCkxi
-6anZ/7S6TCW3rBJY8yOTt/xQRAJfAbeWqKM9RxkWYh54RCGTZRjmNGkYvSBexOch
-0iIcl5W5lSLcRJqaquuenl0bYRzSP+d/qWb2mk9Xe2i+WLe5Lomefn+Dld06944g
-bNhe1k6/geU6dWCITbzlMuWnEO+LrkQF1pu1YW5FqXhEGF7j+tiIL7byL3tEkkbg
-7d5Z/0C/r+hJZZEB3PzOnwU2kcrS4iahKATbb75jHE1qsrJqgqZ6e4hc6OWNx0gG
-DzEEss5OU3hb/B3jXq7wwzHXdZ1Acrg1S1U267yheSumuHjVrIGZLmCUx1adfzhj
-15eWuefpZDj0SM7XrTxNAqt4ITo8S8ONab76R93yU1Vu6256QpGlmMGRKIhO+Oq3
-GB4ox/erSl3VjqarA8OZuXEjek2wt5yqdoviTTHpeu5NAlLXeAF3oYxX5vCTT0BQ
-3+r5SLtzPsoMTZO1/+tXFTRsts+sSn3C4VUHQlVMBiCnxCWDlcsFEhCeFlWv51lt
-tKZfJzCC760OdfgFu3YBkEwRaE2WuigYcHt0A2mMU22D2GPjUCQb4oZYLRZHypS5
-WCstrv2Nv262Ri2TA2f6DtG6fIc06gqlaDTRkA00APTxj7HFPA31sg8MrGSaoF6g
-Og30R2Fky+ABP534RNXy0aWYoqSSG4TKh0aEI+joH/VMUTD2V3+hec91bc6gfnnf
-EoexVDODgVSETm7CP3aCiSuoBv6GRbudS3xor5n1qRVZ
------END ENCRYPTED PRIVATE KEY-----
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIHbTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIGbczFX0cty4CAggA
+MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBBlskH16EZh6ZjBPJdkKE2CBIIH
+ENBB2r0djbJYsncwmGCluBhlJ/FC7CEmcq54z4FadSvJE1bF5OQo8vsRWJC5fZHx
+Q+/+kpNKBZT+8en3NQO+7DIvixoWHR/L2D7e0QYMbvQfJ17QVLE+wcqyDpk+D/hK
+HRSvaHv3wTp9sc88jphH5DzXyrHmOHVHaZHzYQC3/mHRgliEM2ghxPsLwDAfbK1c
+P9SZA0eiH7z9vttL6HSji+gx9UvxNIXWy+NiFhiycDFtLlulrtWmc73m3I5MgCMO
+6OGvUpG7in3qDnTA2YbC5KZVjGZlmixPbrtsFPm0blWwms6/upczEej+NLXgGaDG
+7Jgwsg9TjAZiQHRJ4qbXMiGnfsw6LMlIs9wS1jqW8D/tKIxR6cJ4KyGUFIBQXCox
+krJZoNRE9DaiGNaQEFoTsbqAGSjn4qYj7hUuDI73Ep8wFeqaigxP/JxL6X+FKbng
+v+68FPYTfe0x3RuNgTNEjETVKuZwtjjJMRZaFzm6OWwV92IvjBSkhMBwq6nHKzZG
+7CiCDtZjLdO+ny0AStHrvHyXC60IfPTCJuW4z/0uJjP7+jGRX0FxdBhc3PgBNW/4
+B4vZ6nbP/Z6+06F1Z1Crl22pVuMDCqdA0Z0CHtYJXF266HFXU5oVE9J+w2hKNgMe
+U2lsG/EYbIx4suSokdtUTYWQeLdnGx8TwA6m1CKnAZ+pIr6Vw+tFeOa20oAlq0ac
+4R+mS6MIS8DeFKrSpxWSsGaIBKuduDIZDTTJMJZuQLUAkVCKnPqltw56/VLmZmcV
+r4BfWfGqPNTdBoZh+LwhoPc3uPY7BMy8kdEHfxzwGFY3Ngdskq7goQ/V8HXErxjI
+xvYxGNwFAYCy6Yg/PBtLXeJyrko1Ww9kZ9Dc7IlDa6NExkm99ct+b5zlvXqnT0Z/
+kpqHmqfQgBXlOXS9Iaf/PSvvtTrF2biMyFDWkLUy60cwzNoCAR1oNn9EylQ0d16y
+9kFnIauVmGjSyWizZOONq3CgHpvGr9gKjegnqsHkFizemz/sPJzNaAlnKfN47Y9u
+ZBIVzQLmnDaQo04BwwCNlJo9+thYRR8Jz6YVuDRUNvite2L2urHAnat1/5S6X6od
+37eP87l9OpHl0hG76LtSDioBELR+pqiNDZMc20slmivqYyPCLFjVkbqGDoeYNhiA
+9T3SsF2S+kdXBNpyV2AzSWZKE9KwJvc63iiRVAGe11fABpkJvS0DbwtpZeHcAHCd
+6TlL0nbnr3f5zQBLyHAGypJ8nwBcVjwq8GaiIRQgmsgXBY25wyz8xCpNBE3DEPFv
+3SQqUTmFOgiBYHLyaIAvScI9moDrmm3nLtel7JiTyhyNjgTPz6TbKGGNo8umilKD
+R7oq+nkyF7/Zx2ddge50IHyx4q0MK79VLOAzr1xR9nLW6HA8XEdq0+JezwSEnFxT
+87cATY7omYN1/WN6xPjTVfM4sdsEWTUTBYfwtBSNhmXyPjIdCfgseqx3EszuwKpG
+2/b31eKVI+IFoYvs6rZR+z7MAzWMQRtmtO0hAbzn05GVv/U6yUbyd77Iqq29YZKS
+cBlNXZVz51d08PPD1XstHQd5BEXJEjxVhYx4fREBc+oBBoOGBA52de+ciOJRcg0d
+2/MB5TNsGNA3vIcGjPucIJpNNpFd3fNSCm9oCKV07jaW2ACcLZ1Fxe8cdueXCkxi
+6anZ/7S6TCW3rBJY8yOTt/xQRAJfAbeWqKM9RxkWYh54RCGTZRjmNGkYvSBexOch
+0iIcl5W5lSLcRJqaquuenl0bYRzSP+d/qWb2mk9Xe2i+WLe5Lomefn+Dld06944g
+bNhe1k6/geU6dWCITbzlMuWnEO+LrkQF1pu1YW5FqXhEGF7j+tiIL7byL3tEkkbg
+7d5Z/0C/r+hJZZEB3PzOnwU2kcrS4iahKATbb75jHE1qsrJqgqZ6e4hc6OWNx0gG
+DzEEss5OU3hb/B3jXq7wwzHXdZ1Acrg1S1U267yheSumuHjVrIGZLmCUx1adfzhj
+15eWuefpZDj0SM7XrTxNAqt4ITo8S8ONab76R93yU1Vu6256QpGlmMGRKIhO+Oq3
+GB4ox/erSl3VjqarA8OZuXEjek2wt5yqdoviTTHpeu5NAlLXeAF3oYxX5vCTT0BQ
+3+r5SLtzPsoMTZO1/+tXFTRsts+sSn3C4VUHQlVMBiCnxCWDlcsFEhCeFlWv51lt
+tKZfJzCC760OdfgFu3YBkEwRaE2WuigYcHt0A2mMU22D2GPjUCQb4oZYLRZHypS5
+WCstrv2Nv262Ri2TA2f6DtG6fIc06gqlaDTRkA00APTxj7HFPA31sg8MrGSaoF6g
+Og30R2Fky+ABP534RNXy0aWYoqSSG4TKh0aEI+joH/VMUTD2V3+hec91bc6gfnnf
+EoexVDODgVSETm7CP3aCiSuoBv6GRbudS3xor5n1qRVZ
+-----END ENCRYPTED PRIVATE KEY-----
diff --git a/tools/alif/utils/key/OEMSBContentPublic.pem b/tools/alif/utils/key/OEMSBContentPublic.pem
index 8e9f117f8..fd6b11c70 100755
--- a/tools/alif/utils/key/OEMSBContentPublic.pem
+++ b/tools/alif/utils/key/OEMSBContentPublic.pem
@@ -1,11 +1,11 @@
------BEGIN PUBLIC KEY-----
-MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA4IMCIc+X8Anx9Rc5oVHK
-H1kjOmRUtbNLEdEaOEcCjEhtXtO49JzVxxwVnB/D7ACWU3LHNlhyh9p4ln5Mzovb
-bMRptcJ0rEWIv3cs2D2MDdfsxcfNYR5E9FeepES9ImMMIRu5hhquFsTeTm8yAwzQ
-0LuxJ3uq/Vxesbq05k4QXyvGfBWu8+w1q/vIeRrWme+4ppjnq61r++wFW83CPluF
-K5hhMyrOSU5KE9pZ0eWJP8z9XvAwdE97gd0agwjqRuBy68gto6mD04Pm6R3d8OGI
-KO3XAE4l+u3hKXbCHbWa8ZhbLWOwt5jb44MzvivKT9d+brPtiG1PCAEkqoTJM/Q+
-dorKHIl4Jcu+86+cGgcotzhTL9fv1+7Gi/9QiMdSAoL1xoJd3hRLb2wWZbkBNVA+
-RNjYXhTe7p84RVoP6BWgpv1duT39Gko3RnU4fq6CM9vYUxgCCss4VMwJHOukYqrW
-ZY0Rnohv0n9q4WlcZP+/vSRoMucmeaV0cW+JEUyotgyzAgMBAAE=
------END PUBLIC KEY-----
+-----BEGIN PUBLIC KEY-----
+MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA4IMCIc+X8Anx9Rc5oVHK
+H1kjOmRUtbNLEdEaOEcCjEhtXtO49JzVxxwVnB/D7ACWU3LHNlhyh9p4ln5Mzovb
+bMRptcJ0rEWIv3cs2D2MDdfsxcfNYR5E9FeepES9ImMMIRu5hhquFsTeTm8yAwzQ
+0LuxJ3uq/Vxesbq05k4QXyvGfBWu8+w1q/vIeRrWme+4ppjnq61r++wFW83CPluF
+K5hhMyrOSU5KE9pZ0eWJP8z9XvAwdE97gd0agwjqRuBy68gto6mD04Pm6R3d8OGI
+KO3XAE4l+u3hKXbCHbWa8ZhbLWOwt5jb44MzvivKT9d+brPtiG1PCAEkqoTJM/Q+
+dorKHIl4Jcu+86+cGgcotzhTL9fv1+7Gi/9QiMdSAoL1xoJd3hRLb2wWZbkBNVA+
+RNjYXhTe7p84RVoP6BWgpv1duT39Gko3RnU4fq6CM9vYUxgCCss4VMwJHOukYqrW
+ZY0Rnohv0n9q4WlcZP+/vSRoMucmeaV0cW+JEUyotgyzAgMBAAE=
+-----END PUBLIC KEY-----
diff --git a/tools/alif/utils/key/OEMSBKey.pem b/tools/alif/utils/key/OEMSBKey.pem
index 64130a332..89ba675ec 100755
--- a/tools/alif/utils/key/OEMSBKey.pem
+++ b/tools/alif/utils/key/OEMSBKey.pem
@@ -1,42 +1,42 @@
------BEGIN ENCRYPTED PRIVATE KEY-----
-MIIHbTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIth9PNLaEdl4CAggA
-MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBDa49PQbSc6r+xLeI2oQzvIBIIH
-ELT56F2p+CjBXZrM7rWh0+R/2hxZv2lVPqc8L2n71RAw2QyMVBh9HHJ9LRQMrQOB
-3JDn7ePh8NiA5kMRKh3FBs6hcOCcbkbVfSeYJmtCPoDNK4QPfvAt5BKpSKoslYj4
-mPPlewpzDs8Xh9I6kroq7ueD/VpiG/aCmPvSZc1CWKCVpse85/n/V3x1p1/S4506
-rHaxw3H8fmQABQ1QgqCFotOjGnO9pMbYEbHkwPMBov82uoW31RnFP99ulTd8rwuo
-fW7e2iaSqe7cf5gReUCQvL5T74k/q9x2m9agnI1x4sUpPlctEPcREhet2hBAr1vv
-McWXwQ0h9hYbCBveQ31PEhkWLlrbhVZzfjGlujrSC8sKsGv9YacB5R6vsBqEer3j
-YTXNxfFwwqKyu7+gK5hy9s7oh0uaz0K1x7M/en9NDsouS3/W3xrkzG12Xwha+QcG
-C1X23VedsmMwsPP8lAfJljZ6LlPJouzplbjniKdgpEXplQspfkoOGdDQeadH5eyd
-xMyCD4JPnsLmCgWigxGLeYTPfQM3XxNjv3hqwE8gp+eO1m0rJvSixgR7u2uF4HOc
-WkaIeCrnH4j8dUa9eZI+J8s4G4QRupw/dqaXeiDvpzPGDA1nGfJQFhAQk1964IL0
-LRUzmvR6lQBEnwwVowvtHN0ll6i8hhNH5eG8auP3XL1hEUUfjoE/MsCRJLCahnlH
-SJ/h1o2eW2FESHIRTX+poNZjY3maDkn7p2h7lD7fa37A3g/TIG67fAb0vPKQuWI8
-bGXLhz+9jP4Mx6y2A3JrDIMcAiYIJnHzCR8SnXKqUXYVwUzYiF3fz62knLNi48Iz
-J+svT7WLuY6utpGYs9qdueSBj/cQX4q0K3nPY5rllhWKH31W+PTjc35X0vt1zVSi
-uxQpzrDJZ38zohFomUkDsRteQdXC7BUjkyGU9myKRQLhtUE32hI4B8gNWiz4p4+X
-XPzpPbM9PxcC+wZyCRMrfAprgkRoCi0mOv5dCBeNCV8Cy8iEKZsX45GZ0MJXTlQ2
-1LfKtZSwIc/O4p4Y0zfO5gPUPela6WshKjFiDwNVO+d0MK2RxCxC9JNkuvU6ezxj
-8hXDcMLmGman2XgogwcvtELDDtaGRhM5+RFCU6iWfwdvQZIC3owitTW6AAqoOG28
-LNU9AJ1asPH4XyU0rYdLwLquu+MaWCscT1ZterGAM6QKTKFB3dup4V7QK8e4hTQE
-xl+WmVjyHnx4h4+Qk46wBfPzl2tyQV+tKFp6SECkrlooQvOsMVCKF4De0/7zhwzk
-0UtmQYvp4grfm4dMYFw7S5VRHRJDyvjYMs+l57TlGKPBLNsmFtuHdlB99tPY6+Rg
-C2T1CHPTcUEGQrYYbzhej7dz0nPbJGcjg2b7Dpx4dcK9TyLKQaghweV8J5XsFDwh
-uRS274Prr9L0Oeq2ay59ZVzoQpmeJr8ZVp00VfMfn94IMVTc4Ng434hKkFDTMrWZ
-+Dgaf31/o8UW5MD2EkXjY0b9L8JFzVDpAN4QpwfTXsnZSezFDs/1Z73gKeVwv3x0
-6URoOM9A/QFT5Vf6VRjqHpdBjDNG0U2O51YiwCPJZSNnqyPF4g4lgYknbWhOhMYg
-3tqMq3O/R8nDqW2HQzT2498thGWygndXMV2fiQY4z8MqaemmR2txYLgPhqypilc8
-PPOoy81pDQ3bYMLDjLHlFD3YgyeztE4j1Gp02F88f7fGCGmx4HLLeF12ED6gKHYU
-Vaz/f2h+PwkvsdgEoJ+lcYi7AupoIdXWqGctthqIfgbIll9nbznGnL0VhW1DlDZg
-D9DAKduw/jT6m7Wvb8JGfgXvUOnq4JDUr39gVdPj5km2KgKqI9clhx7uW7Bl8VhG
-B8wwoNvNG3E1MCwDL99bwkj3WMnA0/U7Bz9YH8W/WoX8B+c2rlxJkDA6BNOvvSYL
-KvJq27Ld4CWgsPP4cNoSrCkg21q+/9MWNDwXAubUUtTgv1Js18FBPhqe3aqvcHaU
-V1rN0ZJYHFH96n7DnRzQbh6abmEyApiGDmRV33J1CowlVmR9y80CJOB3J8EpbnAx
-rCWPgch3LujG34jQAemNDcSYTRcvR2G2EbI1GNVmrbCVRL3BwaHEdfEYzFcLS7YD
-LrmUMZpKYdmzyifHt9Y3JVDjlHIXwrUgIK2jjrSMzNLt6ArSNyMnJvdu4DEVNoVE
-u2HfF2AplGQMmXf1Up+/mePOgXOT8LX+n2qRS9K37PC37CKEPpOOnTa/71+zl/op
-O3viB0CijaJQBe39PvDx/ZxDicbXVpCoa++LJkAV8LFSdkc8qSH9uZZUsR9o4XOl
-BWh+41TiTHp8c3Zc5gdRURbe2INhmoPHWpcl30vriCWOmmK63AoSqvirHEPEEu3w
-6ong+3q7csBRxXorza2sT7F9ckKtFEAeTedNH8KV0Awu
------END ENCRYPTED PRIVATE KEY-----
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIHbTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIth9PNLaEdl4CAggA
+MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBDa49PQbSc6r+xLeI2oQzvIBIIH
+ELT56F2p+CjBXZrM7rWh0+R/2hxZv2lVPqc8L2n71RAw2QyMVBh9HHJ9LRQMrQOB
+3JDn7ePh8NiA5kMRKh3FBs6hcOCcbkbVfSeYJmtCPoDNK4QPfvAt5BKpSKoslYj4
+mPPlewpzDs8Xh9I6kroq7ueD/VpiG/aCmPvSZc1CWKCVpse85/n/V3x1p1/S4506
+rHaxw3H8fmQABQ1QgqCFotOjGnO9pMbYEbHkwPMBov82uoW31RnFP99ulTd8rwuo
+fW7e2iaSqe7cf5gReUCQvL5T74k/q9x2m9agnI1x4sUpPlctEPcREhet2hBAr1vv
+McWXwQ0h9hYbCBveQ31PEhkWLlrbhVZzfjGlujrSC8sKsGv9YacB5R6vsBqEer3j
+YTXNxfFwwqKyu7+gK5hy9s7oh0uaz0K1x7M/en9NDsouS3/W3xrkzG12Xwha+QcG
+C1X23VedsmMwsPP8lAfJljZ6LlPJouzplbjniKdgpEXplQspfkoOGdDQeadH5eyd
+xMyCD4JPnsLmCgWigxGLeYTPfQM3XxNjv3hqwE8gp+eO1m0rJvSixgR7u2uF4HOc
+WkaIeCrnH4j8dUa9eZI+J8s4G4QRupw/dqaXeiDvpzPGDA1nGfJQFhAQk1964IL0
+LRUzmvR6lQBEnwwVowvtHN0ll6i8hhNH5eG8auP3XL1hEUUfjoE/MsCRJLCahnlH
+SJ/h1o2eW2FESHIRTX+poNZjY3maDkn7p2h7lD7fa37A3g/TIG67fAb0vPKQuWI8
+bGXLhz+9jP4Mx6y2A3JrDIMcAiYIJnHzCR8SnXKqUXYVwUzYiF3fz62knLNi48Iz
+J+svT7WLuY6utpGYs9qdueSBj/cQX4q0K3nPY5rllhWKH31W+PTjc35X0vt1zVSi
+uxQpzrDJZ38zohFomUkDsRteQdXC7BUjkyGU9myKRQLhtUE32hI4B8gNWiz4p4+X
+XPzpPbM9PxcC+wZyCRMrfAprgkRoCi0mOv5dCBeNCV8Cy8iEKZsX45GZ0MJXTlQ2
+1LfKtZSwIc/O4p4Y0zfO5gPUPela6WshKjFiDwNVO+d0MK2RxCxC9JNkuvU6ezxj
+8hXDcMLmGman2XgogwcvtELDDtaGRhM5+RFCU6iWfwdvQZIC3owitTW6AAqoOG28
+LNU9AJ1asPH4XyU0rYdLwLquu+MaWCscT1ZterGAM6QKTKFB3dup4V7QK8e4hTQE
+xl+WmVjyHnx4h4+Qk46wBfPzl2tyQV+tKFp6SECkrlooQvOsMVCKF4De0/7zhwzk
+0UtmQYvp4grfm4dMYFw7S5VRHRJDyvjYMs+l57TlGKPBLNsmFtuHdlB99tPY6+Rg
+C2T1CHPTcUEGQrYYbzhej7dz0nPbJGcjg2b7Dpx4dcK9TyLKQaghweV8J5XsFDwh
+uRS274Prr9L0Oeq2ay59ZVzoQpmeJr8ZVp00VfMfn94IMVTc4Ng434hKkFDTMrWZ
++Dgaf31/o8UW5MD2EkXjY0b9L8JFzVDpAN4QpwfTXsnZSezFDs/1Z73gKeVwv3x0
+6URoOM9A/QFT5Vf6VRjqHpdBjDNG0U2O51YiwCPJZSNnqyPF4g4lgYknbWhOhMYg
+3tqMq3O/R8nDqW2HQzT2498thGWygndXMV2fiQY4z8MqaemmR2txYLgPhqypilc8
+PPOoy81pDQ3bYMLDjLHlFD3YgyeztE4j1Gp02F88f7fGCGmx4HLLeF12ED6gKHYU
+Vaz/f2h+PwkvsdgEoJ+lcYi7AupoIdXWqGctthqIfgbIll9nbznGnL0VhW1DlDZg
+D9DAKduw/jT6m7Wvb8JGfgXvUOnq4JDUr39gVdPj5km2KgKqI9clhx7uW7Bl8VhG
+B8wwoNvNG3E1MCwDL99bwkj3WMnA0/U7Bz9YH8W/WoX8B+c2rlxJkDA6BNOvvSYL
+KvJq27Ld4CWgsPP4cNoSrCkg21q+/9MWNDwXAubUUtTgv1Js18FBPhqe3aqvcHaU
+V1rN0ZJYHFH96n7DnRzQbh6abmEyApiGDmRV33J1CowlVmR9y80CJOB3J8EpbnAx
+rCWPgch3LujG34jQAemNDcSYTRcvR2G2EbI1GNVmrbCVRL3BwaHEdfEYzFcLS7YD
+LrmUMZpKYdmzyifHt9Y3JVDjlHIXwrUgIK2jjrSMzNLt6ArSNyMnJvdu4DEVNoVE
+u2HfF2AplGQMmXf1Up+/mePOgXOT8LX+n2qRS9K37PC37CKEPpOOnTa/71+zl/op
+O3viB0CijaJQBe39PvDx/ZxDicbXVpCoa++LJkAV8LFSdkc8qSH9uZZUsR9o4XOl
+BWh+41TiTHp8c3Zc5gdRURbe2INhmoPHWpcl30vriCWOmmK63AoSqvirHEPEEu3w
+6ong+3q7csBRxXorza2sT7F9ckKtFEAeTedNH8KV0Awu
+-----END ENCRYPTED PRIVATE KEY-----
diff --git a/tools/alif/utils/key/OEMSBKeyPublic.pem b/tools/alif/utils/key/OEMSBKeyPublic.pem
index 26e426b89..84cc8b1d7 100755
--- a/tools/alif/utils/key/OEMSBKeyPublic.pem
+++ b/tools/alif/utils/key/OEMSBKeyPublic.pem
@@ -1,11 +1,11 @@
------BEGIN PUBLIC KEY-----
-MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA1F/dTkBwYPY4psalLLBP
-SVbHhuOsRJGN/DFRt/0qtZIheb3JA1BhMllR40EHFZbW53p/n4/+8jYNMeqrkACE
-I3FImXbd39yiaeCFH0E2nCElabVR/+MysAnogzEfVy32z+Dmd1m83b28MogJ988P
-XZOkxck2PLTEbphkuEj0tYoh2mgCy7Xply5ELD+Lw/usLKtf2M+IYqbiaY98OIM6
-Kr9/HtRZhqutiBwrhSYtSZTZzC0Bl0mzUKCxAQLlJYmbT0L1fjf+V28iXgQx1pYv
-LqFQwEiF6eS5DL2Lt5H6hC2xJmP9MaA6YLL3AEMT7dy9+zoDjk/J74g33kLnqTp2
-Pr8XfHfKnxSdbfCvX9wll8KDDnWVCq9U3Ol/UKCYaFnnsjrXCgqVnQ6ScN1R9314
-XnWBZ+y3VfnWi51CTE0lu7E4k0mGT6k7wmpSvnBXwbuFeM+O7en2QgHMAeNWE638
-0V+Lkwt8s6A2jhGX0GAh9iYZgOvfS7DBGXXJ/JhXa8yDAgMBAAE=
------END PUBLIC KEY-----
+-----BEGIN PUBLIC KEY-----
+MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA1F/dTkBwYPY4psalLLBP
+SVbHhuOsRJGN/DFRt/0qtZIheb3JA1BhMllR40EHFZbW53p/n4/+8jYNMeqrkACE
+I3FImXbd39yiaeCFH0E2nCElabVR/+MysAnogzEfVy32z+Dmd1m83b28MogJ988P
+XZOkxck2PLTEbphkuEj0tYoh2mgCy7Xply5ELD+Lw/usLKtf2M+IYqbiaY98OIM6
+Kr9/HtRZhqutiBwrhSYtSZTZzC0Bl0mzUKCxAQLlJYmbT0L1fjf+V28iXgQx1pYv
+LqFQwEiF6eS5DL2Lt5H6hC2xJmP9MaA6YLL3AEMT7dy9+zoDjk/J74g33kLnqTp2
+Pr8XfHfKnxSdbfCvX9wll8KDDnWVCq9U3Ol/UKCYaFnnsjrXCgqVnQ6ScN1R9314
+XnWBZ+y3VfnWi51CTE0lu7E4k0mGT6k7wmpSvnBXwbuFeM+O7en2QgHMAeNWE638
+0V+Lkwt8s6A2jhGX0GAh9iYZgOvfS7DBGXXJ/JhXa8yDAgMBAAE=
+-----END PUBLIC KEY-----
diff --git a/tools/alif/utils/maint-recoveryDB.db b/tools/alif/utils/maint-recoveryDB.db
new file mode 100755
index 000000000..4b398e3d9
--- /dev/null
+++ b/tools/alif/utils/maint-recoveryDB.db
@@ -0,0 +1,20 @@
+{
+ "groups" : {
+ "ROM" : "rom",
+ "Device Information" : "info",
+ "Utilities" : "utils"
+ },
+ "info" : {
+ "Device enquiry" : "get_enquiry_action",
+ "Get revision info" : "get_revision_action",
+ "Get SEROM trace data": "get_trace_buffer"
+ },
+ "utils" : {
+ "Terminal mode" : "terminal_mode"
+ },
+ "rom" : {
+ "Recovery" : "recovery_action",
+ "Recovery (No Reset)" : "recovery_action_no_reset"
+ }
+}
+
diff --git a/tools/alif/utils/maintDB.db b/tools/alif/utils/maintDB.db
index 30c91c995..1a03f9d15 100755
--- a/tools/alif/utils/maintDB.db
+++ b/tools/alif/utils/maintDB.db
@@ -1,51 +1,46 @@
-{
- "groups" : {
- "Device Control" : "control",
- "Device Information" : "info",
- "MRAM" : "mram",
- "Utilities" : "utils",
- "Setting capabilities" : "setting",
- "ROM" : "rom"
- },
- "control" : {
- "Hard maintenance mode" : "maintenance_mode",
- "Soft maintenance mode" : "soft_maintenance_mode",
- "Device reset" : "reset_action"
- },
- "info" : {
- "Get TOC info" : "get_toc_action",
- "Get SES Banner" : "get_banner_action",
- "Get CPU boot info" : "get_cpu_status_action",
- "Device enquiry" : "get_enquiry_action",
- "Get revision info" : "get_revision_action",
- "Get OTP data" : "get_otp_read",
- "Get MRAM data" : "get_mram_read_action",
- "Get log data" : "get_log_data_action",
- "Get SEROM trace data": "get_trace_buffer",
- "Get SERAM trace data": "get_seram_trace_buffer",
- "Get power data": "get_power_action",
- "Get clock data": "get_clock_action"
- },
- "mram" : {
- "Erase Application Mram" : "full_erase_application_mram_action",
- "Fast Erase Application Mram" : "fast_erase_application_mram_action",
- "Fast Erase App. Mram (include NTOC)" : "fast_erase_app_include_start_mram_action",
- "Get MRAM info" : "get_mram_info_action"
- },
- "utils" : {
- "Terminal mode" : "terminal_mode",
- "Get SERAM metrics" : "get_seram_info_action",
- "Get ECC key" : "get_ecc_key",
- "Get Firewall configuration" : "get_firewall_config"
- },
- "rom" : {
- "Recovery" : "recovery_action",
- "Recovery (No Reset)" : "recovery_action_no_reset"
- },
- "setting" : {
- "Enable LOGGING" : "set_logger_enable_action",
- "Disable LOGGING" : "set_logger_disable_action",
- "Enable PRINTING" : "set_print_enable_action",
- "Disable PRINTING" : "set_print_disable_action"
- }
-}
+{
+ "groups" : {
+ "Device Control" : "control",
+ "Device Information" : "info",
+ "MRAM" : "mram",
+ "Utilities" : "utils",
+ "Setting capabilities" : "setting"
+ },
+ "control" : {
+ "Hard maintenance mode" : "maintenance_mode",
+ "Soft maintenance mode" : "soft_maintenance_mode",
+ "Device reset" : "reset_action"
+ },
+ "info" : {
+ "Get TOC info" : "get_toc_action",
+ "Get SES Banner" : "get_banner_action",
+ "Get CPU boot info" : "get_cpu_status_action",
+ "Device enquiry" : "get_enquiry_action",
+ "Get revision info" : "get_revision_action",
+ "Get OTP data" : "get_otp_read",
+ "Get MRAM data" : "get_mram_read_action",
+ "Get log data" : "get_log_data_action",
+ "Get SEROM trace data": "get_trace_buffer",
+ "Get SERAM trace data": "get_seram_trace_buffer",
+ "Get power data": "get_power_action",
+ "Get clock data": "get_clock_action"
+ },
+ "mram" : {
+ "Erase Application Mram" : "full_erase_application_mram_action",
+ "Fast Erase Application Mram" : "fast_erase_application_mram_action",
+ "Fast Erase App. Mram (include NTOC)" : "fast_erase_app_include_start_mram_action",
+ "Get MRAM info" : "get_mram_info_action"
+ },
+ "utils" : {
+ "Terminal mode" : "terminal_mode",
+ "Get SERAM metrics" : "get_seram_info_action",
+ "Get ECC key" : "get_ecc_key",
+ "Get Firewall configuration" : "get_firewall_config"
+ },
+ "setting" : {
+ "Enable LOGGING" : "set_logger_enable_action",
+ "Disable LOGGING" : "set_logger_disable_action",
+ "Enable PRINTING" : "set_print_enable_action",
+ "Disable PRINTING" : "set_print_disable_action"
+ }
+}
diff --git a/tools/alif/utils/menuconfDB.db b/tools/alif/utils/menuconfDB.db
index 49729d3b7..dde6e658a 100755
--- a/tools/alif/utils/menuconfDB.db
+++ b/tools/alif/utils/menuconfDB.db
@@ -1,13 +1,13 @@
-{
- "get_mram_read_action" : {
- "DEVICE_FEATURE_SET_REVISION": [
- "Fusion_A0"
- ]
- },
- "get_power_action" : {
- "DEVICE_FEATURE_SET_REVISION": [
- "Fusion_A1"
- ]
- }
-
-}
+{
+ "get_mram_read_action" : {
+ "DEVICE_FEATURE_SET_REVISION": [
+ "Fusion_A0"
+ ]
+ },
+ "get_power_action" : {
+ "DEVICE_FEATURE_SET_REVISION": [
+ "Fusion_A1"
+ ]
+ }
+
+}
diff --git a/tools/alif/utils/pinmux.py b/tools/alif/utils/pinmux.py
index 2b64adc39..f4f4aea71 100755
--- a/tools/alif/utils/pinmux.py
+++ b/tools/alif/utils/pinmux.py
@@ -1,75 +1,75 @@
-""" pinmuxing """
-import json
-import ctypes
-import struct
-
-# pylint: disable=too-few-public-methods
-# pylint: disable=too-many-instance-attributes
-# pylint: disable=invalid-name
-# pylint: disable=attribute-defined-outside-init
-
-c_uint32 = ctypes.c_uint32
-c_uint8 = ctypes.c_uint8
-
-class pad_configuration_bits(ctypes.LittleEndianStructure):
- """ fw_rgn_mpe """
- _fields_ = [
- ("port", c_uint32, 8),
- ("pin", c_uint32, 8),
- ("mux_mode", c_uint32, 7),
- ("pad_control_valid", c_uint32, 1),
- ("pad_control", c_uint32, 8)
- ]
-
- def init_from_cfg(self, cfg):
- """ Initialize from JSON configuration """
- self.port = cfg['port']
- self.pin = cfg['pin']
- self.mux_mode = cfg['mux_mode']
- self.pad_control_valid = 1
- self.pad_control = int(cfg['pad_config'], 0)
-
-class pad_configuration_bytes(ctypes.LittleEndianStructure):
- """ fw_rgn_mpe """
- _fields_ = [
- ("b1", c_uint8),
- ("b2", c_uint8),
- ("b3", c_uint8),
- ("b4", c_uint8)
- ]
-
-class pad_configuration(ctypes.Union):
- _fields_ = [
- ("bits", pad_configuration_bits),
- ("bytes", pad_configuration_bytes)
- ]
-
- def init_from_cfg(self, cfg):
- """ Initialize from JSON configuration """
- self.bits.port = cfg['port']
- self.bits.pin = cfg['pin']
- self.bits.mux_mode = cfg['mux_mode']
- self.bits.pad_control_valid = 1
- self.bits.pad_control = int(cfg['pad_config'], 0)
-
-def json_to_bin(jsn):
- """ Convert a JSON object into binary """
- data = []
- pads = jsn
- for pad in pads:
- pad_cfg = pad_configuration()
- pad_cfg.init_from_cfg(pad)
- data.append(pad_cfg.bytes.b1)
- data.append(pad_cfg.bytes.b2)
- data.append(pad_cfg.bytes.b3)
- data.append(pad_cfg.bytes.b4)
-
- return data
-
-def main():
- """ main """
- json_to_bin()
- return 0
-
-if __name__ == "__main__":
- main()
+""" pinmuxing """
+import json
+import ctypes
+import struct
+
+# pylint: disable=too-few-public-methods
+# pylint: disable=too-many-instance-attributes
+# pylint: disable=invalid-name
+# pylint: disable=attribute-defined-outside-init
+
+c_uint32 = ctypes.c_uint32
+c_uint8 = ctypes.c_uint8
+
+class pad_configuration_bits(ctypes.LittleEndianStructure):
+ """ fw_rgn_mpe """
+ _fields_ = [
+ ("port", c_uint32, 8),
+ ("pin", c_uint32, 8),
+ ("mux_mode", c_uint32, 7),
+ ("pad_control_valid", c_uint32, 1),
+ ("pad_control", c_uint32, 8)
+ ]
+
+ def init_from_cfg(self, cfg):
+ """ Initialize from JSON configuration """
+ self.port = cfg['port']
+ self.pin = cfg['pin']
+ self.mux_mode = cfg['mux_mode']
+ self.pad_control_valid = 1
+ self.pad_control = int(cfg['pad_config'], 0)
+
+class pad_configuration_bytes(ctypes.LittleEndianStructure):
+ """ fw_rgn_mpe """
+ _fields_ = [
+ ("b1", c_uint8),
+ ("b2", c_uint8),
+ ("b3", c_uint8),
+ ("b4", c_uint8)
+ ]
+
+class pad_configuration(ctypes.Union):
+ _fields_ = [
+ ("bits", pad_configuration_bits),
+ ("bytes", pad_configuration_bytes)
+ ]
+
+ def init_from_cfg(self, cfg):
+ """ Initialize from JSON configuration """
+ self.bits.port = cfg['port']
+ self.bits.pin = cfg['pin']
+ self.bits.mux_mode = cfg['mux_mode']
+ self.bits.pad_control_valid = 1
+ self.bits.pad_control = int(cfg['pad_config'], 0)
+
+def json_to_bin(jsn):
+ """ Convert a JSON object into binary """
+ data = []
+ pads = jsn
+ for pad in pads:
+ pad_cfg = pad_configuration()
+ pad_cfg.init_from_cfg(pad)
+ data.append(pad_cfg.bytes.b1)
+ data.append(pad_cfg.bytes.b2)
+ data.append(pad_cfg.bytes.b3)
+ data.append(pad_cfg.bytes.b4)
+
+ return data
+
+def main():
+ """ main """
+ json_to_bin()
+ return 0
+
+if __name__ == "__main__":
+ main()
diff --git a/tools/alif/utils/printInfo.py b/tools/alif/utils/printInfo.py
index b43513dcd..dcd0f91e3 100755
--- a/tools/alif/utils/printInfo.py
+++ b/tools/alif/utils/printInfo.py
@@ -1,28 +1,28 @@
-#!/usr/bin/env python3
-#pylint: disable=invalid-name,superfluous-parens,anomalous-unicode-escape-in-string
-
-"""
- __author__ = ""
- __copyright__ =Copyright 2021, ALIF Semiconductor"
-"""
-
-verboseMode = False
-
-def verboseModeSet(flag):
- global verboseMode
- verboseMode = flag
-
-def verboseModeGet():
- return verboseMode
-
-def printInfo(*args):
- if verboseMode:
- msj = ''
- for item in args:
- if type(item).__name__ == 'str':
- msj += item
- else:
- msj += str(item)
- msj += ' '
- print('[INFO] ' + msj)
+#!/usr/bin/env python3
+#pylint: disable=invalid-name,superfluous-parens,anomalous-unicode-escape-in-string
+
+"""
+ __author__ = ""
+ __copyright__ =Copyright 2021, ALIF Semiconductor"
+"""
+
+verboseMode = False
+
+def verboseModeSet(flag):
+ global verboseMode
+ verboseMode = flag
+
+def verboseModeGet():
+ return verboseMode
+
+def printInfo(*args):
+ if verboseMode:
+ msj = ''
+ for item in args:
+ if type(item).__name__ == 'str':
+ msj += item
+ else:
+ msj += str(item)
+ msj += ' '
+ print('[INFO] ' + msj)
\ No newline at end of file
diff --git a/tools/alif/utils/proj.cfg b/tools/alif/utils/proj.cfg
index 7a5733242..151644444 100755
--- a/tools/alif/utils/proj.cfg
+++ b/tools/alif/utils/proj.cfg
@@ -1,6 +1,6 @@
-# certificate version
-CERT_VERSION_MAJOR = 1
-CERT_VERSION_MINOR = 0
-
-
-
+# certificate version
+CERT_VERSION_MAJOR = 1
+CERT_VERSION_MINOR = 0
+
+
+
diff --git a/tools/alif/utils/rsa_keygen.py b/tools/alif/utils/rsa_keygen.py
index 336480483..0fbb3d0e6 100755
--- a/tools/alif/utils/rsa_keygen.py
+++ b/tools/alif/utils/rsa_keygen.py
@@ -1,76 +1,76 @@
-#!/usr/bin/env python3
-#
-# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
-#
-
-import optparse
-import sys
-from utils.common import util_logger
-from utils.common import cryptolayer
-
-# Util's log file
-LOG_FILENAME = "key_gen_log.log"
-
-
-class ArgumentParser:
- def __init__(self):
- self.private_key_filename = None
- self.private_key_pwd_filename = None
- self.public_key_filename = None
- self.log_filename = None
- #self.parser = optparse.OptionParser(usage="usage: %prog [options]",
- # description="%prog generates a PEM encoded RSA private key and writes it "
- # "to the file specified by parameter . "
- # "Optionally it can also generate the corresponding public key "
- # "to the file specified by option -k.")
- # Removed above line of code and added below line ---------------------- Swathi
- self.parser = optparse.OptionParser()
- self.parser.add_option("-p", "--pass_file", dest="private_key_pwd_filename",
- help="Filename containing the passphrase for creating the private key, "
- "in plaintext format. For security considerations, this parameter can be omitted, "
- "in which case this utility will prompt for direct input.")
- self.parser.add_option("-k", "--pubkey", dest="public_key_filename",
- help="If given, the public key will be also extracted into the PEM file specified "
- "by this parameter")
- self.parser.add_option("-l", "--log", dest="log_filename", default=LOG_FILENAME,
- metavar="FILE",
- help="Writes event log to FILE [default: %default]")
-
- def parse_arguments(self, args):
- (options, args) = self.parser.parse_args(args)
- if len(args) != 1:
- self.parser.error("incorrect number of positional arguments, use option -h for help")
- self.private_key_filename = args[0]
- self.private_key_pwd_filename = options.private_key_pwd_filename
- self.public_key_filename = options.public_key_filename
- self.log_filename = options.log_filename
-
-
-class KeyGenerator:
- def __init__(self, argument_parser, logger):
- self.argument_parser = argument_parser
- self.logger = logger
-
- def generate_key(self):
- key = cryptolayer.RsaCrypto.generate_rsa_pem_key(self.argument_parser.private_key_filename,
- self.argument_parser.private_key_pwd_filename,
- self.logger)
- if self.argument_parser.public_key_filename is not None:
- cryptolayer.RsaCrypto.extract_public_rsa_pem_key(key, self.argument_parser.public_key_filename, self.logger)
-
-
-def main(args):
- if not (sys.version_info.major == 3 and sys.version_info.minor >= 5):
- print("The script requires Python3.5 or later!")
- sys.exit(-1)
- # parse arguments
- the_argument_parser = ArgumentParser()
- the_argument_parser.parse_arguments(args)
- # get logging up and running
- the_logger = util_logger.UtilLogger(the_argument_parser.log_filename, "RSA Key Generator")
- # perform main task
- generator = KeyGenerator(the_argument_parser, the_logger)
- generator.generate_key()
- the_logger.info("Script completed successfully")
+#!/usr/bin/env python3
+#
+# Copyright (c) 2001-2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license
+#
+
+import optparse
+import sys
+from utils.common import util_logger
+from utils.common import cryptolayer
+
+# Util's log file
+LOG_FILENAME = "key_gen_log.log"
+
+
+class ArgumentParser:
+ def __init__(self):
+ self.private_key_filename = None
+ self.private_key_pwd_filename = None
+ self.public_key_filename = None
+ self.log_filename = None
+ #self.parser = optparse.OptionParser(usage="usage: %prog [options]",
+ # description="%prog generates a PEM encoded RSA private key and writes it "
+ # "to the file specified by parameter . "
+ # "Optionally it can also generate the corresponding public key "
+ # "to the file specified by option -k.")
+ # Removed above line of code and added below line ---------------------- Swathi
+ self.parser = optparse.OptionParser()
+ self.parser.add_option("-p", "--pass_file", dest="private_key_pwd_filename",
+ help="Filename containing the passphrase for creating the private key, "
+ "in plaintext format. For security considerations, this parameter can be omitted, "
+ "in which case this utility will prompt for direct input.")
+ self.parser.add_option("-k", "--pubkey", dest="public_key_filename",
+ help="If given, the public key will be also extracted into the PEM file specified "
+ "by this parameter")
+ self.parser.add_option("-l", "--log", dest="log_filename", default=LOG_FILENAME,
+ metavar="FILE",
+ help="Writes event log to FILE [default: %default]")
+
+ def parse_arguments(self, args):
+ (options, args) = self.parser.parse_args(args)
+ if len(args) != 1:
+ self.parser.error("incorrect number of positional arguments, use option -h for help")
+ self.private_key_filename = args[0]
+ self.private_key_pwd_filename = options.private_key_pwd_filename
+ self.public_key_filename = options.public_key_filename
+ self.log_filename = options.log_filename
+
+
+class KeyGenerator:
+ def __init__(self, argument_parser, logger):
+ self.argument_parser = argument_parser
+ self.logger = logger
+
+ def generate_key(self):
+ key = cryptolayer.RsaCrypto.generate_rsa_pem_key(self.argument_parser.private_key_filename,
+ self.argument_parser.private_key_pwd_filename,
+ self.logger)
+ if self.argument_parser.public_key_filename is not None:
+ cryptolayer.RsaCrypto.extract_public_rsa_pem_key(key, self.argument_parser.public_key_filename, self.logger)
+
+
+def main(args):
+ if not (sys.version_info.major == 3 and sys.version_info.minor >= 5):
+ print("The script requires Python3.5 or later!")
+ sys.exit(-1)
+ # parse arguments
+ the_argument_parser = ArgumentParser()
+ the_argument_parser.parse_arguments(args)
+ # get logging up and running
+ the_logger = util_logger.UtilLogger(the_argument_parser.log_filename, "RSA Key Generator")
+ # perform main task
+ generator = KeyGenerator(the_argument_parser, the_logger)
+ generator.generate_key()
+ the_logger.info("Script completed successfully")
diff --git a/tools/alif/utils/sign_image_util.py b/tools/alif/utils/sign_image_util.py
index 734fc5d41..cd40629b0 100755
--- a/tools/alif/utils/sign_image_util.py
+++ b/tools/alif/utils/sign_image_util.py
@@ -1,150 +1,150 @@
-#!/usr/bin/env python3
-"""
- Perform Image signing
-
- __author__ = ""
- __copyright__ = "ALIF Seminconductor"
- __version__ = "0.1.0"
- __status__ = "Dev"
-"""
-# pylint: disable=unused-argument, invalid-name, bare-except
-from pathlib import Path
-from utils.toc_common import *
-from utils.common.certificates import getKeyCertificatePath
-
-# 0.3.000 - added support for Azure Storage (Public Keys and Certs)
-# 0.4.000 - split image signature functionality
-# 0.5.000 - remove folders restriction
-TOOL_VERSION ="0.5.000" # Define Version constant for each separate tool
-
-#EXIT_WITH_ERROR = 1
-
-certPath = Path("cert/")
-imagePath = Path("build/images")
-
-# A simplified copy of createContentCerts (in toc_common.py) with some modified paths
-def create_content_certs(sec, prefix, config_file):
- """
- create a content certificate for an image
- """
- print('Creating Signature...')
- try:
- file = open(imagePath / "images.txt", "w")
- except:
- print(sys.exc_info()[0])
- print("ERROR creating template file for Content Certificates")
- sys.exit(EXIT_WITH_ERROR)
-
- configFile = prefix + config_file
-
- fsize = sec['size']
- encrypt = '0'
-
- binfile = sec['binary']
- binfile = "../" + binfile
- print("Binary File: ", binfile)
- file.write(binfile + \
- " " + str(sec['loadAddress']) + \
- " " + str(sec['mramAddress']) + \
- " " + str(fsize) + \
- " " + encrypt)
- file.close()
-
- os.chdir(os.getcwd() + '/utils/')
- cert_sb_content_util.main(["-c", 'cfg/'+configFile, "-l", '../build/logs/SBContent.log'])
- os.chdir(os.getcwd() + '/../')
-
- # check if file exists (and remove it) before renaming it
- #certFile = "SB" + sec['binary'] + ".crt"
- certFile = sec['binary'] + ".crt"
- if os.path.exists(certFile):
- os.remove(certFile)
-
- fileName = prefix + "SBContent.crt"
- os.rename(certPath / fileName, certFile)
- # save cert. name in images list
- sec['cert'] = certFile
-
- # remove ICVSBContent_Cert.txt file (not used)
- textFile = prefix + "SBContent_Cert.txt"
- if os.path.exists(certPath / textFile):
- os.remove(certPath / textFile)
- # remove images.txt (not used)
- textFile = "images.txt"
- if os.path.exists(imagePath / textFile):
- os.remove(imagePath / textFile)
-
-def is_seram_address(address):
- # TODO: the end address should be configurable (for SPARK it is 0x30020000)
- if address >= 0x30000000 and address < 0x30040000:
- return True
- else:
- return False
-
-def sign_image(fileName, destAddress, loadAddress, signature_type):
- key1_cert = ""
- key2_cert = ""
-
- if signature_type == "ICV":
- #key1_cert = "cert/ICVSBKey1.crt"
- key1_cert = getKeyCertificatePath() + '/ICVSBKey1.crt'
- #key2_cert = "cert/ICVSBKey2.crt"
- key2_cert = getKeyCertificatePath() + '/ICVSBKey2.crt'
- elif signature_type == "OEM":
- key1_cert = "cert/OEMSBKey1.crt"
- key2_cert = "cert/OEMSBKey2.crt"
- else:
- print("Auth Host can only be 'ICV' or 'OEM'")
- sys.exit(EXIT_WITH_ERROR)
-
- sec = {}
- sec['disabled'] = False
- sec['binary'] = fileName
- fsize, padlen = getImageSize(sec['binary'])
- sec['size'] = fsize
- sec['padlen'] = padlen
- if is_seram_address(destAddress):
- sec['mramAddress'] = hex(destAddress)
- else:
- sec['mramAddress'] = globalToLocalAddress(hex(destAddress))
- sec['identifier'] = 'image'
- sec['flags'] = {}
-
- if loadAddress == 0xFFFFFFFF:
- # Signing content that is downloaded to 'destAddress' before verification.
- # The address is specified in the sec['mramAddress'] field.
- sec['loadAddress'] = hex(loadAddress)
- #load-verify-scheme = 1
- config_file = 'SBContent_lvs_1.cfg'
- elif is_seram_address(loadAddress):
- # signing SERAM images for packaging them as single-image STOC updates
- # SERAM images require 'load-verify-scheme = 0'
- sec['loadAddress'] = hex(loadAddress)
- #load-verify-scheme = 0
- config_file = 'SBContent_lvs_0.cfg'
- else:
- # this section is not used currently
- sec['loadAddress'] = globalToLocalAddress(hex(loadAddress))
- #load-verify-scheme = 0
- config_file = 'SBContent_lvs_0.cfg'
- create_content_certs(sec, signature_type.upper(), config_file)
-
- content_cert = sec["cert"]
- print("Content Certificate File: ", content_cert)
-
- sigfile = fileName + ".sign"
- print("Signature File: ", sigfile)
- with open(sigfile, "wb") as outf:
- with open(key1_cert, 'rb') as inf:
- outf.write(inf.read())
- with open(key2_cert, 'rb') as inf:
- outf.write(inf.read())
- with open(content_cert, 'rb') as inf:
- outf.write(inf.read())
- # add the 12-byte padding required for content certificate chains
- outf.write(('\0' * 12).encode('utf8'))
-
- if os.path.exists(content_cert):
- os.remove(content_cert)
-
- return sigfile
+#!/usr/bin/env python3
+"""
+ Perform Image signing
+
+ __author__ = ""
+ __copyright__ = "ALIF Seminconductor"
+ __version__ = "0.1.0"
+ __status__ = "Dev"
+"""
+# pylint: disable=unused-argument, invalid-name, bare-except
+from pathlib import Path
+from utils.toc_common import *
+from utils.common.certificates import getKeyCertificatePath
+
+# 0.3.000 - added support for Azure Storage (Public Keys and Certs)
+# 0.4.000 - split image signature functionality
+# 0.5.000 - remove folders restriction
+TOOL_VERSION ="0.5.000" # Define Version constant for each separate tool
+
+#EXIT_WITH_ERROR = 1
+
+certPath = Path("cert/")
+imagePath = Path("build/images")
+
+# A simplified copy of createContentCerts (in toc_common.py) with some modified paths
+def create_content_certs(sec, prefix, config_file):
+ """
+ create a content certificate for an image
+ """
+ print('Creating Signature...')
+ try:
+ file = open(imagePath / "images.txt", "w")
+ except:
+ print(sys.exc_info()[0])
+ print("ERROR creating template file for Content Certificates")
+ sys.exit(EXIT_WITH_ERROR)
+
+ configFile = prefix + config_file
+
+ fsize = sec['size']
+ encrypt = '0'
+
+ binfile = sec['binary']
+ binfile = "../" + binfile
+ print("Binary File: ", binfile)
+ file.write(binfile + \
+ " " + str(sec['loadAddress']) + \
+ " " + str(sec['mramAddress']) + \
+ " " + str(fsize) + \
+ " " + encrypt)
+ file.close()
+
+ os.chdir(os.getcwd() + '/utils/')
+ cert_sb_content_util.main(["-c", 'cfg/'+configFile, "-l", '../build/logs/SBContent.log'])
+ os.chdir(os.getcwd() + '/../')
+
+ # check if file exists (and remove it) before renaming it
+ #certFile = "SB" + sec['binary'] + ".crt"
+ certFile = sec['binary'] + ".crt"
+ if os.path.exists(certFile):
+ os.remove(certFile)
+
+ fileName = prefix + "SBContent.crt"
+ os.rename(certPath / fileName, certFile)
+ # save cert. name in images list
+ sec['cert'] = certFile
+
+ # remove ICVSBContent_Cert.txt file (not used)
+ textFile = prefix + "SBContent_Cert.txt"
+ if os.path.exists(certPath / textFile):
+ os.remove(certPath / textFile)
+ # remove images.txt (not used)
+ textFile = "images.txt"
+ if os.path.exists(imagePath / textFile):
+ os.remove(imagePath / textFile)
+
+def is_seram_address(address):
+ # TODO: the end address should be configurable (for SPARK it is 0x30020000)
+ if address >= 0x30000000 and address < 0x30040000:
+ return True
+ else:
+ return False
+
+def sign_image(fileName, destAddress, loadAddress, signature_type):
+ key1_cert = ""
+ key2_cert = ""
+
+ if signature_type == "ICV":
+ #key1_cert = "cert/ICVSBKey1.crt"
+ key1_cert = getKeyCertificatePath() + '/ICVSBKey1.crt'
+ #key2_cert = "cert/ICVSBKey2.crt"
+ key2_cert = getKeyCertificatePath() + '/ICVSBKey2.crt'
+ elif signature_type == "OEM":
+ key1_cert = "cert/OEMSBKey1.crt"
+ key2_cert = "cert/OEMSBKey2.crt"
+ else:
+ print("Auth Host can only be 'ICV' or 'OEM'")
+ sys.exit(EXIT_WITH_ERROR)
+
+ sec = {}
+ sec['disabled'] = False
+ sec['binary'] = fileName
+ fsize, padlen = getImageSize(sec['binary'])
+ sec['size'] = fsize
+ sec['padlen'] = padlen
+ if is_seram_address(destAddress):
+ sec['mramAddress'] = hex(destAddress)
+ else:
+ sec['mramAddress'] = globalToLocalAddress(hex(destAddress))
+ sec['identifier'] = 'image'
+ sec['flags'] = {}
+
+ if loadAddress == 0xFFFFFFFF:
+ # Signing content that is downloaded to 'destAddress' before verification.
+ # The address is specified in the sec['mramAddress'] field.
+ sec['loadAddress'] = hex(loadAddress)
+ #load-verify-scheme = 1
+ config_file = 'SBContent_lvs_1.cfg'
+ elif is_seram_address(loadAddress):
+ # signing SERAM images for packaging them as single-image STOC updates
+ # SERAM images require 'load-verify-scheme = 0'
+ sec['loadAddress'] = hex(loadAddress)
+ #load-verify-scheme = 0
+ config_file = 'SBContent_lvs_0.cfg'
+ else:
+ # this section is not used currently
+ sec['loadAddress'] = globalToLocalAddress(hex(loadAddress))
+ #load-verify-scheme = 0
+ config_file = 'SBContent_lvs_0.cfg'
+ create_content_certs(sec, signature_type.upper(), config_file)
+
+ content_cert = sec["cert"]
+ print("Content Certificate File: ", content_cert)
+
+ sigfile = fileName + ".sign"
+ print("Signature File: ", sigfile)
+ with open(sigfile, "wb") as outf:
+ with open(key1_cert, 'rb') as inf:
+ outf.write(inf.read())
+ with open(key2_cert, 'rb') as inf:
+ outf.write(inf.read())
+ with open(content_cert, 'rb') as inf:
+ outf.write(inf.read())
+ # add the 12-byte padding required for content certificate chains
+ outf.write(('\0' * 12).encode('utf8'))
+
+ if os.path.exists(content_cert):
+ os.remove(content_cert)
+
+ return sigfile
diff --git a/tools/alif/utils/toc_common.py b/tools/alif/utils/toc_common.py
index e2536743c..71a8580ac 100755
--- a/tools/alif/utils/toc_common.py
+++ b/tools/alif/utils/toc_common.py
@@ -1,626 +1,626 @@
-import sys
-import os
-import glob
-from pathlib import Path
-import json
-from json.decoder import JSONDecodeError
-from utils import cert_sb_content_util
-import utils.toc_common
-from printInfo import *
-
-EXIT_WITH_ERROR = 1
-
-certPath = Path("cert/")
-imagePath = Path("build/images/")
-
-
-# we need to pad 12 bytes to put the image into a 16-byte aligned address
-CERT_CHAIN_SIZE = (840 * 2) + 868 + 12 # 2560 bytes (0xA00)
-# we pad out to have 16-byte aligned sizes = 880 total size
-CONT_CERT_SIZE = 868 + 12
-# we need to pad 12 bytes to put the image into a 16-byte aligned address
-CERT_CHAIN_SIZE = (840 * 2) + 868 + 12
-
-def getImageSize(file):
- """
- find the image size
- """
-
- try:
- fsize = os.path.getsize(file)
-
- except FileNotFoundError:
- print("ERROR: The file " + file + " was not found in build/ directory!")
- print("Please check the file and try again")
- sys.exit(EXIT_WITH_ERROR)
-
- except:
- print(sys.exc_info()[0])
- print("ERROR: getting the image size for file " + file)
- sys.exit(EXIT_WITH_ERROR)
-
- #print("OS file size: " + str(fsize))
-
- padlen = 0
-
- if fsize % 16:
- # If we have to pad out
- newsize = fsize + (16 - (fsize % 16))
- #print("Size should be " + str(newsize))
- padlen = (16 - (fsize % 16))
-
- return fsize, padlen
-
-
-def validateHexAddress(address, param, image):
- """
- check address
- """
- if (address[0:2].lower() != '0x'):
- print(param + ' for image ' + image + ' should in in hex!')
- sys.exit(EXIT_WITH_ERROR)
-
- try:
- val = int(address, 0)
-
- except ValueError:
- print('Invalid address in ' + param + ' for image ' + image)
- sys.exit(EXIT_WITH_ERROR)
-
-
-
-
-def globalToLocalAddress(globalAddress):
- """
- convert addresses
- """
- # Global to Local Addresses Convertion is based on this table
- #Rgn SE Address Region (CM0+) RegSize Global add Region Coverage
- # EXAMPLE FOR REV_A0 DEVICES
- #1 0x6000_0000 - 0x8000_0000 512MB 0x0000_0000 - 0x2000_0000 Boot register, CVM, XNVM, Host Peripherals, Power, Firewall, MHU
- #2 0x8000_0000 - 0x8200_0000 32MB 0x4800_0000 - 0x4A00_0000 EXPMST0 Shared Peripherals
- #3 0x8800_0000 - 0x8900_0000 16MB 0x5000_0000 - 0x5100_0000 EXTSYS0 HP-CM55 TCM
- #4 0x9000_0000 - 0x9800_0000 128MB 0x6000_0000 - 0x6800_0000 EXTSYS1 TCMs
- #5 0x9800_0000 - 0x9C00_0000 64MB 0x7000_0000 - 0x7400_0000 Low Power Peripherals (VBAT at 0x7000 and LPAON at 0x7100)
- #6 0xA000_0000 - 0xA800_0000 128MB 0x8000_0000 - 0x8800-0000 OCVM
- #7 0xC000_0000 – 0xE000_0000 512MB 0xD000_0000 – 0xF000_0000 OctalSPI0 and OctalSPI1
- #
- #The upper region addresses are exclusive for the purpose of readability
- #(e.g. instead of 0x7FFF_FFFF the upper address is listed as 0x8000_0000)
-
- # Steps for the conversion"
- # 1. Check if provided global address is in one of the above regions
- # 2. if in region, apply the corresponding Delta to convert to a Local address
- # 3. If NOT in region, we exit with error and terminate the program
-
- #Rgn Delta
- #1 + 0x6000-0000
- #2 + 0x3800-0000
- #3 + 0x3800-0000
- #4 + 0x3000-0000
- #5 + 0x2800-0000
- #6 + 0x2000-0000
- #7 - 0x1000-0000
-
-
- # Global addresses definition for REV_Ax devices
- regions_Ax = [
- ['0x00000000','0x20000000'],
- ['0x48000000','0x4A000000'],
- ['0x50000000','0x51000000'],
- ['0x60000000','0x68000000'],
- ['0x70000000','0x74000000'],
- ['0x80000000','0x88000000'],
- ['0xD0000000','0xF0000000']
- ]
-
- deltas_Ax = [
- ['+','0x60000000'],
- ['+','0x38000000'],
- ['+','0x38000000'],
- ['+','0x30000000'],
- ['+','0x28000000'],
- ['+','0x20000000'],
- ['-','0x10000000']
- ]
-
- # Global addresses definition for REV_B0 devices
- regions_B0 = [
- ['0x02000000','0x02400000'], # SRAM0_BASE
- ['0x08000000','0x08280000'], # SRAM1_BASE
- ['0x50000000','0x50040000'], # M55_HP_ITCM_BASE
- ['0x50800000','0x50900000'], # M55_HP_DTCM_BASE
- ['0x58000000','0x58040000'], # M55_HE_ITCM_BASE
- ['0x58800000','0x58840000'], # M55_HE_DTCM_BASE
- ['0x62000000','0x62100000'], # MODEM_ITCM_BASE
- ['0x62100000','0x62200000'], # MODEM_DTCM_BASE
- ['0x63000000','0x63080000'], # DSP_ITCM_BASE
- ['0x63100000','0x63300000'], # DSP_DTCM_BASE
- ['0x60000000','0x60040000'], # GNSS_ITCM_BASE
- ['0x60040000','0x600C0000'], # GNSS_DTCM_BASE
- ['0x80000000','0x80600000'] # MRAM_BASE
- ]
-
- deltas_B0 = [
- ['+','0x60000000'],
- ['+','0x60000000'],
- ['+','0x44000000'],
- ['+','0x44000000'],
- ['+','0x40000000'],
- ['+','0x40000000'],
- ['+','0x3C000000'],
- ['+','0x3C000000'],
- ['+','0x3C000000'],
- ['+','0x3C000000'],
- ['+','0x3C000000'],
- ['+','0x3C000000'],
- ['+','0x10000000']
- ]
-
- # Global addresses definition for Spark devices
- regions_Spark = [
- ['0x00000000','0x20000000'],
- ['0x40000000','0x50000000'],
- ['0x50000000','0x501E0000'],
- ['0x58000000','0x5C000000'],
- ['0x60000000','0x64000000'],
- ['0x80000000','0x84000000'],
- ['0xA0000000','0xE0000000']
- ]
-
- deltas_Spark = [
- ['+','0x60000000'],
- ['+','0x40000000'],
- ['+','0x44000000'],
- ['+','0x40000000'],
- ['+','0x3C000000'],
- ['+','0x10000000'],
- ['+','0x00000000']
- ]
-
- # Global addresses definition for REV_B0 devices
- regions_Eagle = [
- ['0x02000000','0x02400000'], # SRAM0_BASE
- ['0x08000000','0x08280000'], # SRAM1_BASE
- ['0x50000000','0x50040000'], # M55_HP_ITCM_BASE
- ['0x50800000','0x50900000'], # M55_HP_DTCM_BASE
- ['0x58000000','0x58040000'], # M55_HE_ITCM_BASE
- ['0x58800000','0x58840000'], # M55_HE_DTCM_BASE
- ['0x62000000','0x62100000'], # MODEM_ITCM_BASE
- ['0x62100000','0x62200000'], # MODEM_DTCM_BASE
- ['0x63000000','0x63080000'], # DSP_ITCM_BASE
- ['0x63100000','0x63300000'], # DSP_DTCM_BASE
- ['0x60000000','0x60040000'], # GNSS_ITCM_BASE
- ['0x60040000','0x600C0000'], # GNSS_DTCM_BASE
- ['0x80000000','0x80600000'] # MRAM_BASE
- ]
-
- deltas_Eagle = [
- ['+','0x60000000'],
- ['+','0x60000000'],
- ['+','0x44000000'],
- ['+','0x44000000'],
- ['+','0x40000000'],
- ['+','0x40000000'],
- ['+','0x3C000000'],
- ['+','0x3C000000'],
- ['+','0x3C000000'],
- ['+','0x3C000000'],
- ['+','0x3C000000'],
- ['+','0x3C000000'],
- ['+','0x10000000']
- ]
-
- # create a list of valid global regions
- #print(utils.config.DEVICE_REVISION)
- if utils.config.DEVICE_FEATURE_SET == 'Fusion':
- if utils.config.DEVICE_REVISION == 'A1':
- regions = regions_Ax
- deltas = deltas_Ax
- else:
- regions = regions_B0
- deltas = deltas_B0
-
- elif utils.config.DEVICE_FEATURE_SET == 'Spark':
- regions = regions_Spark
- deltas = deltas_Spark
- elif utils.config.DEVICE_FEATURE_SET == 'Eagle':
- regions = regions_Eagle
- deltas = deltas_Eagle
- else:
- print('ERROR: Invalid Device type!')
- sys.exit(EXIT_WITH_ERROR)
-
-
- #print(globalAddress)
- localAddress = int(globalAddress, 16)
- notFound = True
- idx = 0
- for address in regions:
- LOWER = int(address[0], 16)
- UPPER = int(address[1], 16)
- if localAddress >= LOWER and localAddress < UPPER:
- #print('Address inside boundaries - region ' + str(idx))
- notFound = False
- break
- idx += 1
-
- if notFound:
- print('ERROR: Invalid Global Address. Please check!')
- sys.exit(EXIT_WITH_ERROR)
-
- delta = int(deltas[idx][1], 16)
- if deltas[idx][0] == '+':
- localAddress += delta
- elif deltas[idx][0] == '-':
- localAddress -= delta
- else:
- print('ERROR in determining the right operation in global address conversion!')
- sys.exit(EXIT_WITH_ERROR)
-
- #print(hex(localAddress))
- return hex(localAddress)
-
-def initCfgOptions(keys):
- """
- CFG options
- """
- options = {}
-
- for i in keys:
- options[i] = 'none'
-
- return options
-
-def dict_raise_on_duplicates(ordered_pairs):
- """
- Reject duplicate keys.
- """
- d = {}
- for k, v in ordered_pairs:
- if k in d:
- raise ValueError("Duplicate key: %r" % (k,))
- else:
- d[k] = v
- return d
-
-def read_json_file(file, attributes, flags, cpus):
- """
- read the json file
- """
- global numImages
-
- try:
- f = open(file, 'r')
-
- except FileNotFoundError:
- print('ERROR: file ' + file + ' does not exist!')
- sys.exit(EXIT_WITH_ERROR)
-
- except:
- print('ERROR opening configuration file')
- sys.exit(EXIT_WITH_ERROR)
-
-
- try:
- cfg = json.load(f, object_pairs_hook=dict_raise_on_duplicates)
-
- except JSONDecodeError as e:
- print("ERROR in JSON file.")
- print(str(e))
- sys.exit(EXIT_WITH_ERROR)
-
- except ValueError as v:
- print("ERROR in JSON file:")
- print(str(v))
- sys.exit(EXIT_WITH_ERROR)
-
- except:
- print("ERROR: Unknown error loading JSON file")
- sys.exit(EXIT_WITH_ERROR)
-
- f.close()
-
- images = []
- for image in cfg:
- #print('IMAGE:')
- #print(image, cfg[image])
- if len(image) == 0:
- print("ERROR: image description can't be empty!","Please correct it in configuration file")
- sys.exit(EXIT_WITH_ERROR)
-
- # ensure the image descriptor is 8 characters (complete with '\0' otherwise)
- n = 8 - len(image)
- imgDesc = image.ljust(n + len(image), '\0')
- imgOptions = initCfgOptions(attributes)
- userOptions = cfg[image]
- imgOptions['identifier'] = imgDesc[:8]
- #print('Analyze options')
- for opt in userOptions:
- #print(opt, userOptions[opt])
- if imgOptions.get(opt) is None:
- print('ERROR: Invalid key: "' + opt + \
- '" in configuration file, image: ' + image)
- sys.exit(EXIT_WITH_ERROR)
- else:
- if isinstance(userOptions[opt], list):
- for s in userOptions[opt]:
- if s.upper() not in flags:
- print('ERROR: flag "' + s + '" in image '
- + image + ' is not supported')
- sys.exit(EXIT_WITH_ERROR)
-
- imgOptions[opt] = [s.upper() for s in userOptions[opt]]
- else:
- if opt in ['loadAddress','mramAddress']:
- validateHexAddress(userOptions[opt], opt, image)
- if opt == 'loadAddress':
- if userOptions[opt][0:3] == '0x8':
- print('ERROR: An MRAM address can not be used in loadAddress attribute')
- sys.exit(EXIT_WITH_ERROR)
-
- if opt == 'cpu_id':
- if userOptions[opt] not in cpus:
- print('ERROR: cpu_id "' + userOptions[opt] + '" in image ' + image + ' is not supported')
- sys.exit(EXIT_WITH_ERROR)
-
- imgOptions[opt] = userOptions[opt]
-
- images.append(imgOptions)
-
- return images
-
-def compressImage(file):
- """
- compression
- """
- print('Compressing image: ' + file)
- if sys.platform == "linux":
- os.system('chmod +x ./utils/lzf-lnx')
- os.system('./utils/lzf-lnx -cfb 4096 ' + file)
- else:
- os.system('utils\\lzf.exe -cfb 4096 ' + file)
-
-def addContentCertificate(file, binary):
- """
- addContentCertificate
- """
- certFile = "SB" + binary + ".crt"
- certFile = certPath / certFile
- #print("Copying Cont.Cert: " + str(certFile))
- file.write(getBlob(certFile))
- # pad 12 bytes to put the image in a 16-byte aligned address
- file.write(b'\x00' * 12)
-
-
-def createContentCerts(fwsections, prefix):
- """
- create content certificates
- """
- print('Creating Content Certificates...')
- for sec in fwsections:
-
- if sec['disabled'] is True:
- continue
-
- #print(sec)
- #print(imagePath)
-
- try:
- file = open(imagePath / "images.txt", "w")
- except:
- print(sys.exc_info()[0])
- print("[ERROR] creating template file for Content Certificates")
- sys.exit(EXIT_WITH_ERROR)
-
-
- # create the ContentCertificate
- #
- # swLoadVerifyScheme values in Content Certificates:
- #
- # SERAMX : 0 - load and verify
- # XIP (verify in flash) : 1 - (Encryption Not Allowed)
- # IMAGE : 2 - verify in memory (LOAD flag set) (Encryption is allowed and optional)
- #
-
- encrypt = '0'
- # Content Certificate for SERAM needs to have Local Addresses
- sec['mramAddress'] = globalToLocalAddress(sec['mramAddress'])
- if sec['identifier'].upper()[:5] == 'SERAM':
- configFile = prefix + 'SBContent_lvs_0.cfg'
- mem_load_address = sec['loadAddress']
- # Encryption allowed if load-verify-scheme = 0
- if 'ENCRYPT' in sec['flags']:
- encrypt = '1'
-
- else:
- if 'LOAD' in sec['flags']:
- # use
- # load-verify-scheme = 2
- # aes-ce-id = 2
- configFile = prefix + 'SBContent_lvs_2.cfg'
- mem_load_address = globalToLocalAddress(sec['loadAddress'])
- # Encryption ONLY allowed if load-verify-scheme = 2 (LOAD flag set)
- if 'ENCRYPT' in sec['flags']:
- encrypt = '1'
- else:
- # use
- # load-verify-scheme = 1
- # aes-ce-id = 0 (no encryption allowed if verify in flash)
- configFile = prefix + 'SBContent_lvs_1.cfg'
- mem_load_address = '0xFFFFFFFF'
-
- fsize = sec['size']
- if 'COMPRESS' in sec['flags']:
- fsize = sec['uncompressedSize']
-
- printInfo('Content Certificate1:')
- #print("../build/" + sec['binary'] + " " + str(mem_load_address) + " " + \
- # str(sec['mramAddress']) + " " + str(fsize) + " " + encrypt)
- file.write("../build/images/" + sec['binary'] + \
- " " + str(mem_load_address) + \
- " " + str(sec['mramAddress']) + \
- " " + str(fsize) + \
- " " + encrypt)
- file.close()
-
- os.chdir(os.getcwd() + '/utils/')
- cert_sb_content_util.main(["-c", 'cfg/'+configFile, "-l", '../build/logs/SBContent.log'])
- os.chdir(os.getcwd() + '/../')
-
- # check if file exists (and remove it) before renaming it
- #certFile = "SB" + sec['binary'] + ".crt"
- certFile = "SB" + sec['binary'] + "_" + str(sec['mramAddress']) + ".crt"
- printInfo(certFile)
- if (os.path.exists(certPath / certFile)):
- os.remove(certPath / certFile)
-
- fileName = prefix + "SBContent.crt"
- os.rename(certPath / fileName, certPath / certFile)
- # save cert. name in images list
- sec['cert'] = certFile
-
- # remove ICVSBContent_Cert.txt file (not used)
- textFile = prefix + "SBContent_Cert.txt"
- if (os.path.exists(certPath / textFile)):
- os.remove(certPath / textFile)
-
- # remove images.txt - temporal template file (not used)
- textFile = "images.txt"
- if (os.path.exists(imagePath / textFile)):
- os.remove(imagePath / textFile)
-
-
-def getObjectType(objType, switcher):
- """
- get object type
- """
- return switcher.get(objType.strip(), 4)
-
-def getCPUID(objCPU, switcher):
- """
- fet CPU ID
- """
-
- return switcher.get(objCPU, 0xF)
-
-
-def getObjectFlags(objFlags):
- """
- getObjectFlags
- """
- flagInt = 0
- for f in objFlags:
- if f == 'COMPRESS':
- flagInt += 0x10
- elif f == 'LOAD':
- flagInt += 0x20
- elif f == 'BOOT':
- flagInt += 0x40
- elif f == 'ENCRYPT':
- flagInt += 0x80
- elif f == 'DEFERRED':
- flagInt += 0x100
-
- return flagInt
-
-def getObjectVersion(objVersion):
- """
- """
- if objVersion == 'none':
- return 0
-
- ver = objVersion.split('.')
- res = 0
- idx = 3
- for n in ver:
- if idx < 1:
- break
- res += (int(n) * (256 ** idx))
- idx -= 1
- return res
-
-def getBlob(file):
- """
- get the Blob
- """
- f = open(file, 'rb') # TODO: This needs to check for open fail
- blob = f.read()
- f.close()
- return blob
-
-def scanFiles(fileList, action):
- """
- scanFiles
- """
- filesProcesed = 0
- for i in range(len(fileList)):
- files = glob.glob(fileList[i])
- for file in files:
- if action == 'list':
- if i == 0:
- print('\nThe following files will be deleted:\n')
- print('\t' + file)
- elif action == 'delete':
- os.remove(file)
- filesProcesed += 1
-
- return filesProcesed
-
-def cleanBuild(fileList):
- """
- cleanBuild
- """
-
- files = scanFiles(fileList, 'list')
-
- if files == 0:
- print('\nThere were no files to delete')
- sys.exit()
-
- print('\nPress Y to confirm, or any other key to exit')
- confirmResponse = input('> ')
- if confirmResponse.upper() == 'Y' or confirmResponse.upper() == 'YES':
- print('Deleting files...')
- scanFiles(fileList, 'delete')
- print('\nThe build workspace was cleaned!', '(' + str(files) + ' files were deleted)')
- else:
- print('The operation was aborted!')
-
-def validateOptions(fwsections):
- # validate options in fwsections - exit if errors
- for sec in fwsections:
- if 'COMPRESS' in sec['flags']:
- # enforce compression is not allowed encryption is used
- if 'ENCRYPT' in sec['flags']:
- print('[ERROR] Compression is not allowed for encrypted images!')
- print('[ERROR] Please correct the configuration: '
- + str(sec['flags'])
- + ' in image '
- + sec['identifier'])
- sys.exit(EXIT_WITH_ERROR)
-
- # enforce compression is not allowed for XIP use case
- if 'LOAD' not in sec['flags'] and sec['cpu_id'] != 'none':
- print('[ERROR] Compression is not allowed for XIP images!')
- print('[ERROR] Please correct the configuration: '
- + str(sec['flags'])
- + ' in image '
- + sec['identifier'])
- sys.exit(EXIT_WITH_ERROR)
-
- # if LOAD flag is used, loadAddress should be valid
- if 'LOAD' in sec['flags']:
- if sec['loadAddress'] == 'none':
- print('[ERROR] if LOAD flag is used, a loadAddress must be specified!')
- print('[ERROR] Please correct the configuration in image '
- + sec['identifier'])
- sys.exit(EXIT_WITH_ERROR)
-
- # if BOOT flag is used, CPU_ID should be valid
- if 'BOOT' in sec['flags']:
- if sec['cpu_id'] == 'none':
- print('[ERROR] if BOOT flag is used, a cpu_id must be specified!')
- print('[ERROR] Please correct the configuration in image '
- + sec['identifier'])
- sys.exit(EXIT_WITH_ERROR)
+import sys
+import os
+import glob
+from pathlib import Path
+import json
+from json.decoder import JSONDecodeError
+from utils import cert_sb_content_util
+import utils.toc_common
+from printInfo import *
+
+EXIT_WITH_ERROR = 1
+
+certPath = Path("cert/")
+imagePath = Path("build/images/")
+
+
+# we need to pad 12 bytes to put the image into a 16-byte aligned address
+CERT_CHAIN_SIZE = (840 * 2) + 868 + 12 # 2560 bytes (0xA00)
+# we pad out to have 16-byte aligned sizes = 880 total size
+CONT_CERT_SIZE = 868 + 12
+# we need to pad 12 bytes to put the image into a 16-byte aligned address
+CERT_CHAIN_SIZE = (840 * 2) + 868 + 12
+
+def getImageSize(file):
+ """
+ find the image size
+ """
+
+ try:
+ fsize = os.path.getsize(file)
+
+ except FileNotFoundError:
+ print("ERROR: The file " + file + " was not found in build/ directory!")
+ print("Please check the file and try again")
+ sys.exit(EXIT_WITH_ERROR)
+
+ except:
+ print(sys.exc_info()[0])
+ print("ERROR: getting the image size for file " + file)
+ sys.exit(EXIT_WITH_ERROR)
+
+ #print("OS file size: " + str(fsize))
+
+ padlen = 0
+
+ if fsize % 16:
+ # If we have to pad out
+ newsize = fsize + (16 - (fsize % 16))
+ #print("Size should be " + str(newsize))
+ padlen = (16 - (fsize % 16))
+
+ return fsize, padlen
+
+
+def validateHexAddress(address, param, image):
+ """
+ check address
+ """
+ if (address[0:2].lower() != '0x'):
+ print(param + ' for image ' + image + ' should in in hex!')
+ sys.exit(EXIT_WITH_ERROR)
+
+ try:
+ val = int(address, 0)
+
+ except ValueError:
+ print('Invalid address in ' + param + ' for image ' + image)
+ sys.exit(EXIT_WITH_ERROR)
+
+
+
+
+def globalToLocalAddress(globalAddress):
+ """
+ convert addresses
+ """
+ # Global to Local Addresses Convertion is based on this table
+ #Rgn SE Address Region (CM0+) RegSize Global add Region Coverage
+ # EXAMPLE FOR REV_A0 DEVICES
+ #1 0x6000_0000 - 0x8000_0000 512MB 0x0000_0000 - 0x2000_0000 Boot register, CVM, XNVM, Host Peripherals, Power, Firewall, MHU
+ #2 0x8000_0000 - 0x8200_0000 32MB 0x4800_0000 - 0x4A00_0000 EXPMST0 Shared Peripherals
+ #3 0x8800_0000 - 0x8900_0000 16MB 0x5000_0000 - 0x5100_0000 EXTSYS0 HP-CM55 TCM
+ #4 0x9000_0000 - 0x9800_0000 128MB 0x6000_0000 - 0x6800_0000 EXTSYS1 TCMs
+ #5 0x9800_0000 - 0x9C00_0000 64MB 0x7000_0000 - 0x7400_0000 Low Power Peripherals (VBAT at 0x7000 and LPAON at 0x7100)
+ #6 0xA000_0000 - 0xA800_0000 128MB 0x8000_0000 - 0x8800-0000 OCVM
+ #7 0xC000_0000 – 0xE000_0000 512MB 0xD000_0000 – 0xF000_0000 OctalSPI0 and OctalSPI1
+ #
+ #The upper region addresses are exclusive for the purpose of readability
+ #(e.g. instead of 0x7FFF_FFFF the upper address is listed as 0x8000_0000)
+
+ # Steps for the conversion"
+ # 1. Check if provided global address is in one of the above regions
+ # 2. if in region, apply the corresponding Delta to convert to a Local address
+ # 3. If NOT in region, we exit with error and terminate the program
+
+ #Rgn Delta
+ #1 + 0x6000-0000
+ #2 + 0x3800-0000
+ #3 + 0x3800-0000
+ #4 + 0x3000-0000
+ #5 + 0x2800-0000
+ #6 + 0x2000-0000
+ #7 - 0x1000-0000
+
+
+ # Global addresses definition for REV_Ax devices
+ regions_Ax = [
+ ['0x00000000','0x20000000'],
+ ['0x48000000','0x4A000000'],
+ ['0x50000000','0x51000000'],
+ ['0x60000000','0x68000000'],
+ ['0x70000000','0x74000000'],
+ ['0x80000000','0x88000000'],
+ ['0xD0000000','0xF0000000']
+ ]
+
+ deltas_Ax = [
+ ['+','0x60000000'],
+ ['+','0x38000000'],
+ ['+','0x38000000'],
+ ['+','0x30000000'],
+ ['+','0x28000000'],
+ ['+','0x20000000'],
+ ['-','0x10000000']
+ ]
+
+ # Global addresses definition for REV_B0 devices
+ regions_B0 = [
+ ['0x02000000','0x02400000'], # SRAM0_BASE
+ ['0x08000000','0x08280000'], # SRAM1_BASE
+ ['0x50000000','0x50040000'], # M55_HP_ITCM_BASE
+ ['0x50800000','0x50900000'], # M55_HP_DTCM_BASE
+ ['0x58000000','0x58040000'], # M55_HE_ITCM_BASE
+ ['0x58800000','0x58840000'], # M55_HE_DTCM_BASE
+ ['0x62000000','0x62100000'], # MODEM_ITCM_BASE
+ ['0x62100000','0x62200000'], # MODEM_DTCM_BASE
+ ['0x63000000','0x63080000'], # DSP_ITCM_BASE
+ ['0x63100000','0x63300000'], # DSP_DTCM_BASE
+ ['0x60000000','0x60040000'], # GNSS_ITCM_BASE
+ ['0x60040000','0x600C0000'], # GNSS_DTCM_BASE
+ ['0x80000000','0x80600000'] # MRAM_BASE
+ ]
+
+ deltas_B0 = [
+ ['+','0x60000000'],
+ ['+','0x60000000'],
+ ['+','0x44000000'],
+ ['+','0x44000000'],
+ ['+','0x40000000'],
+ ['+','0x40000000'],
+ ['+','0x3C000000'],
+ ['+','0x3C000000'],
+ ['+','0x3C000000'],
+ ['+','0x3C000000'],
+ ['+','0x3C000000'],
+ ['+','0x3C000000'],
+ ['+','0x10000000']
+ ]
+
+ # Global addresses definition for Spark devices
+ regions_Spark = [
+ ['0x00000000','0x20000000'],
+ ['0x40000000','0x50000000'],
+ ['0x50000000','0x501E0000'],
+ ['0x58000000','0x5C000000'],
+ ['0x60000000','0x64000000'],
+ ['0x80000000','0x84000000'],
+ ['0xA0000000','0xE0000000']
+ ]
+
+ deltas_Spark = [
+ ['+','0x60000000'],
+ ['+','0x40000000'],
+ ['+','0x44000000'],
+ ['+','0x40000000'],
+ ['+','0x3C000000'],
+ ['+','0x10000000'],
+ ['+','0x00000000']
+ ]
+
+ # Global addresses definition for REV_B0 devices
+ regions_Eagle = [
+ ['0x02000000','0x02400000'], # SRAM0_BASE
+ ['0x08000000','0x08280000'], # SRAM1_BASE
+ ['0x50000000','0x50040000'], # M55_HP_ITCM_BASE
+ ['0x50800000','0x50900000'], # M55_HP_DTCM_BASE
+ ['0x58000000','0x58040000'], # M55_HE_ITCM_BASE
+ ['0x58800000','0x58840000'], # M55_HE_DTCM_BASE
+ ['0x62000000','0x62100000'], # MODEM_ITCM_BASE
+ ['0x62100000','0x62200000'], # MODEM_DTCM_BASE
+ ['0x63000000','0x63080000'], # DSP_ITCM_BASE
+ ['0x63100000','0x63300000'], # DSP_DTCM_BASE
+ ['0x60000000','0x60040000'], # GNSS_ITCM_BASE
+ ['0x60040000','0x600C0000'], # GNSS_DTCM_BASE
+ ['0x80000000','0x80600000'] # MRAM_BASE
+ ]
+
+ deltas_Eagle = [
+ ['+','0x60000000'],
+ ['+','0x60000000'],
+ ['+','0x44000000'],
+ ['+','0x44000000'],
+ ['+','0x40000000'],
+ ['+','0x40000000'],
+ ['+','0x3C000000'],
+ ['+','0x3C000000'],
+ ['+','0x3C000000'],
+ ['+','0x3C000000'],
+ ['+','0x3C000000'],
+ ['+','0x3C000000'],
+ ['+','0x10000000']
+ ]
+
+ # create a list of valid global regions
+ #print(utils.config.DEVICE_REVISION)
+ if utils.config.DEVICE_FEATURE_SET == 'Fusion':
+ if utils.config.DEVICE_REVISION == 'A1':
+ regions = regions_Ax
+ deltas = deltas_Ax
+ else:
+ regions = regions_B0
+ deltas = deltas_B0
+
+ elif utils.config.DEVICE_FEATURE_SET == 'Spark':
+ regions = regions_Spark
+ deltas = deltas_Spark
+ elif utils.config.DEVICE_FEATURE_SET == 'Eagle':
+ regions = regions_Eagle
+ deltas = deltas_Eagle
+ else:
+ print('ERROR: Invalid Device type!')
+ sys.exit(EXIT_WITH_ERROR)
+
+
+ #print(globalAddress)
+ localAddress = int(globalAddress, 16)
+ notFound = True
+ idx = 0
+ for address in regions:
+ LOWER = int(address[0], 16)
+ UPPER = int(address[1], 16)
+ if localAddress >= LOWER and localAddress < UPPER:
+ #print('Address inside boundaries - region ' + str(idx))
+ notFound = False
+ break
+ idx += 1
+
+ if notFound:
+ print('ERROR: Invalid Global Address. Please check!')
+ sys.exit(EXIT_WITH_ERROR)
+
+ delta = int(deltas[idx][1], 16)
+ if deltas[idx][0] == '+':
+ localAddress += delta
+ elif deltas[idx][0] == '-':
+ localAddress -= delta
+ else:
+ print('ERROR in determining the right operation in global address conversion!')
+ sys.exit(EXIT_WITH_ERROR)
+
+ #print(hex(localAddress))
+ return hex(localAddress)
+
+def initCfgOptions(keys):
+ """
+ CFG options
+ """
+ options = {}
+
+ for i in keys:
+ options[i] = 'none'
+
+ return options
+
+def dict_raise_on_duplicates(ordered_pairs):
+ """
+ Reject duplicate keys.
+ """
+ d = {}
+ for k, v in ordered_pairs:
+ if k in d:
+ raise ValueError("Duplicate key: %r" % (k,))
+ else:
+ d[k] = v
+ return d
+
+def read_json_file(file, attributes, flags, cpus):
+ """
+ read the json file
+ """
+ global numImages
+
+ try:
+ f = open(file, 'r')
+
+ except FileNotFoundError:
+ print('ERROR: file ' + file + ' does not exist!')
+ sys.exit(EXIT_WITH_ERROR)
+
+ except:
+ print('ERROR opening configuration file')
+ sys.exit(EXIT_WITH_ERROR)
+
+
+ try:
+ cfg = json.load(f, object_pairs_hook=dict_raise_on_duplicates)
+
+ except JSONDecodeError as e:
+ print("ERROR in JSON file.")
+ print(str(e))
+ sys.exit(EXIT_WITH_ERROR)
+
+ except ValueError as v:
+ print("ERROR in JSON file:")
+ print(str(v))
+ sys.exit(EXIT_WITH_ERROR)
+
+ except:
+ print("ERROR: Unknown error loading JSON file")
+ sys.exit(EXIT_WITH_ERROR)
+
+ f.close()
+
+ images = []
+ for image in cfg:
+ #print('IMAGE:')
+ #print(image, cfg[image])
+ if len(image) == 0:
+ print("ERROR: image description can't be empty!","Please correct it in configuration file")
+ sys.exit(EXIT_WITH_ERROR)
+
+ # ensure the image descriptor is 8 characters (complete with '\0' otherwise)
+ n = 8 - len(image)
+ imgDesc = image.ljust(n + len(image), '\0')
+ imgOptions = initCfgOptions(attributes)
+ userOptions = cfg[image]
+ imgOptions['identifier'] = imgDesc[:8]
+ #print('Analyze options')
+ for opt in userOptions:
+ #print(opt, userOptions[opt])
+ if imgOptions.get(opt) is None:
+ print('ERROR: Invalid key: "' + opt + \
+ '" in configuration file, image: ' + image)
+ sys.exit(EXIT_WITH_ERROR)
+ else:
+ if isinstance(userOptions[opt], list):
+ for s in userOptions[opt]:
+ if s.upper() not in flags:
+ print('ERROR: flag "' + s + '" in image '
+ + image + ' is not supported')
+ sys.exit(EXIT_WITH_ERROR)
+
+ imgOptions[opt] = [s.upper() for s in userOptions[opt]]
+ else:
+ if opt in ['loadAddress','mramAddress']:
+ validateHexAddress(userOptions[opt], opt, image)
+ if opt == 'loadAddress':
+ if userOptions[opt][0:3] == '0x8':
+ print('ERROR: An MRAM address can not be used in loadAddress attribute')
+ sys.exit(EXIT_WITH_ERROR)
+
+ if opt == 'cpu_id':
+ if userOptions[opt] not in cpus:
+ print('ERROR: cpu_id "' + userOptions[opt] + '" in image ' + image + ' is not supported')
+ sys.exit(EXIT_WITH_ERROR)
+
+ imgOptions[opt] = userOptions[opt]
+
+ images.append(imgOptions)
+
+ return images
+
+def compressImage(file):
+ """
+ compression
+ """
+ print('Compressing image: ' + file)
+ if sys.platform == "linux":
+ os.system('chmod +x ./utils/lzf-lnx')
+ os.system('./utils/lzf-lnx -cfb 4096 ' + file)
+ else:
+ os.system('utils\\lzf.exe -cfb 4096 ' + file)
+
+def addContentCertificate(file, binary):
+ """
+ addContentCertificate
+ """
+ certFile = "SB" + binary + ".crt"
+ certFile = certPath / certFile
+ #print("Copying Cont.Cert: " + str(certFile))
+ file.write(getBlob(certFile))
+ # pad 12 bytes to put the image in a 16-byte aligned address
+ file.write(b'\x00' * 12)
+
+
+def createContentCerts(fwsections, prefix):
+ """
+ create content certificates
+ """
+ print('Creating Content Certificates...')
+ for sec in fwsections:
+
+ if sec['disabled'] is True:
+ continue
+
+ #print(sec)
+ #print(imagePath)
+
+ try:
+ file = open(imagePath / "images.txt", "w")
+ except:
+ print(sys.exc_info()[0])
+ print("[ERROR] creating template file for Content Certificates")
+ sys.exit(EXIT_WITH_ERROR)
+
+
+ # create the ContentCertificate
+ #
+ # swLoadVerifyScheme values in Content Certificates:
+ #
+ # SERAMX : 0 - load and verify
+ # XIP (verify in flash) : 1 - (Encryption Not Allowed)
+ # IMAGE : 2 - verify in memory (LOAD flag set) (Encryption is allowed and optional)
+ #
+
+ encrypt = '0'
+ # Content Certificate for SERAM needs to have Local Addresses
+ sec['mramAddress'] = globalToLocalAddress(sec['mramAddress'])
+ if sec['identifier'].upper()[:5] == 'SERAM':
+ configFile = prefix + 'SBContent_lvs_0.cfg'
+ mem_load_address = sec['loadAddress']
+ # Encryption allowed if load-verify-scheme = 0
+ if 'ENCRYPT' in sec['flags']:
+ encrypt = '1'
+
+ else:
+ if 'LOAD' in sec['flags']:
+ # use
+ # load-verify-scheme = 2
+ # aes-ce-id = 2
+ configFile = prefix + 'SBContent_lvs_2.cfg'
+ mem_load_address = globalToLocalAddress(sec['loadAddress'])
+ # Encryption ONLY allowed if load-verify-scheme = 2 (LOAD flag set)
+ if 'ENCRYPT' in sec['flags']:
+ encrypt = '1'
+ else:
+ # use
+ # load-verify-scheme = 1
+ # aes-ce-id = 0 (no encryption allowed if verify in flash)
+ configFile = prefix + 'SBContent_lvs_1.cfg'
+ mem_load_address = '0xFFFFFFFF'
+
+ fsize = sec['size']
+ if 'COMPRESS' in sec['flags']:
+ fsize = sec['uncompressedSize']
+
+ printInfo('Content Certificate1:')
+ #print("../build/" + sec['binary'] + " " + str(mem_load_address) + " " + \
+ # str(sec['mramAddress']) + " " + str(fsize) + " " + encrypt)
+ file.write("../build/images/" + sec['binary'] + \
+ " " + str(mem_load_address) + \
+ " " + str(sec['mramAddress']) + \
+ " " + str(fsize) + \
+ " " + encrypt)
+ file.close()
+
+ os.chdir(os.getcwd() + '/utils/')
+ cert_sb_content_util.main(["-c", 'cfg/'+configFile, "-l", '../build/logs/SBContent.log'])
+ os.chdir(os.getcwd() + '/../')
+
+ # check if file exists (and remove it) before renaming it
+ #certFile = "SB" + sec['binary'] + ".crt"
+ certFile = "SB" + sec['binary'] + "_" + str(sec['mramAddress']) + ".crt"
+ printInfo(certFile)
+ if (os.path.exists(certPath / certFile)):
+ os.remove(certPath / certFile)
+
+ fileName = prefix + "SBContent.crt"
+ os.rename(certPath / fileName, certPath / certFile)
+ # save cert. name in images list
+ sec['cert'] = certFile
+
+ # remove ICVSBContent_Cert.txt file (not used)
+ textFile = prefix + "SBContent_Cert.txt"
+ if (os.path.exists(certPath / textFile)):
+ os.remove(certPath / textFile)
+
+ # remove images.txt - temporal template file (not used)
+ textFile = "images.txt"
+ if (os.path.exists(imagePath / textFile)):
+ os.remove(imagePath / textFile)
+
+
+def getObjectType(objType, switcher):
+ """
+ get object type
+ """
+ return switcher.get(objType.strip(), 4)
+
+def getCPUID(objCPU, switcher):
+ """
+ fet CPU ID
+ """
+
+ return switcher.get(objCPU, 0xF)
+
+
+def getObjectFlags(objFlags):
+ """
+ getObjectFlags
+ """
+ flagInt = 0
+ for f in objFlags:
+ if f == 'COMPRESS':
+ flagInt += 0x10
+ elif f == 'LOAD':
+ flagInt += 0x20
+ elif f == 'BOOT':
+ flagInt += 0x40
+ elif f == 'ENCRYPT':
+ flagInt += 0x80
+ elif f == 'DEFERRED':
+ flagInt += 0x100
+
+ return flagInt
+
+def getObjectVersion(objVersion):
+ """
+ """
+ if objVersion == 'none':
+ return 0
+
+ ver = objVersion.split('.')
+ res = 0
+ idx = 3
+ for n in ver:
+ if idx < 1:
+ break
+ res += (int(n) * (256 ** idx))
+ idx -= 1
+ return res
+
+def getBlob(file):
+ """
+ get the Blob
+ """
+ f = open(file, 'rb') # TODO: This needs to check for open fail
+ blob = f.read()
+ f.close()
+ return blob
+
+def scanFiles(fileList, action):
+ """
+ scanFiles
+ """
+ filesProcesed = 0
+ for i in range(len(fileList)):
+ files = glob.glob(fileList[i])
+ for file in files:
+ if action == 'list':
+ if i == 0:
+ print('\nThe following files will be deleted:\n')
+ print('\t' + file)
+ elif action == 'delete':
+ os.remove(file)
+ filesProcesed += 1
+
+ return filesProcesed
+
+def cleanBuild(fileList):
+ """
+ cleanBuild
+ """
+
+ files = scanFiles(fileList, 'list')
+
+ if files == 0:
+ print('\nThere were no files to delete')
+ sys.exit()
+
+ print('\nPress Y to confirm, or any other key to exit')
+ confirmResponse = input('> ')
+ if confirmResponse.upper() == 'Y' or confirmResponse.upper() == 'YES':
+ print('Deleting files...')
+ scanFiles(fileList, 'delete')
+ print('\nThe build workspace was cleaned!', '(' + str(files) + ' files were deleted)')
+ else:
+ print('The operation was aborted!')
+
+def validateOptions(fwsections):
+ # validate options in fwsections - exit if errors
+ for sec in fwsections:
+ if 'COMPRESS' in sec['flags']:
+ # enforce compression is not allowed encryption is used
+ if 'ENCRYPT' in sec['flags']:
+ print('[ERROR] Compression is not allowed for encrypted images!')
+ print('[ERROR] Please correct the configuration: '
+ + str(sec['flags'])
+ + ' in image '
+ + sec['identifier'])
+ sys.exit(EXIT_WITH_ERROR)
+
+ # enforce compression is not allowed for XIP use case
+ if 'LOAD' not in sec['flags'] and sec['cpu_id'] != 'none':
+ print('[ERROR] Compression is not allowed for XIP images!')
+ print('[ERROR] Please correct the configuration: '
+ + str(sec['flags'])
+ + ' in image '
+ + sec['identifier'])
+ sys.exit(EXIT_WITH_ERROR)
+
+ # if LOAD flag is used, loadAddress should be valid
+ if 'LOAD' in sec['flags']:
+ if sec['loadAddress'] == 'none':
+ print('[ERROR] if LOAD flag is used, a loadAddress must be specified!')
+ print('[ERROR] Please correct the configuration in image '
+ + sec['identifier'])
+ sys.exit(EXIT_WITH_ERROR)
+
+ # if BOOT flag is used, CPU_ID should be valid
+ if 'BOOT' in sec['flags']:
+ if sec['cpu_id'] == 'none':
+ print('[ERROR] if BOOT flag is used, a cpu_id must be specified!')
+ print('[ERROR] Please correct the configuration in image '
+ + sec['identifier'])
+ sys.exit(EXIT_WITH_ERROR)
diff --git a/tools/alif/utils/user_validations.py b/tools/alif/utils/user_validations.py
index d6a8c20d6..8ffc3c5a6 100755
--- a/tools/alif/utils/user_validations.py
+++ b/tools/alif/utils/user_validations.py
@@ -1,145 +1,145 @@
-#!/usr/bin/env python3
-import os
-import sys
-
-EXIT_WITH_ERROR = 1
-
-def validateNumber(number, alignment):
- #validate a number (to be used as an Address, Size or Pattern)
- # 1. check number is valid (positive integer <= 32bits)
- # 2. if address is in decimal, check for negative values
- # 3. check for 16-byte alignment if requested
- if number[:2].lower() == '0x':
- base = 16
- else:
- base = 10
-
- try:
- val = int(number,base)
- if val < 0:
- raise Exception
-
- except:
- print('Error in parameter ' + number + ' - Please check')
- sys.exit(EXIT_WITH_ERROR)
-
- if alignment == True:
- if val%16:
- print('Error: parameter ' + number + ' must be multiple of 16')
- print('Please correct and retry')
- sys.exit(EXIT_WITH_ERROR)
-
- if len(hex(val)) > 10:
- print("Error: parameter " + number + " can't be larger than a 32-bit value")
- print('Please correct and retry')
- sys.exit(EXIT_WITH_ERROR)
-
- return val
-
-def validateItems(items, pad):
- # we get a list of dictionaries
- for item in items:
- for key in item:
- if key == 'file':
- # validate file
- # get file size to check existance
- try:
- # mram_burner runs in bin/ folder so all references would
- # have '../' to land into tools root directory and describe the path from there...
- # GUI will solve all these limitations.
- fPath = item[key][3:]
- fSize = os.path.getsize(fPath)
- if (fSize % 16) != 0:
- print("File size = %d" % fSize)
- print('!!!WARNING: the SIZE of ' + fPath + ' is NOT multiple of 16 bytes as required by MRAM')
- if pad:
- padlen = (16 - (fSize % 16))
- print('Since the -p option was invoked, the binary will be padded with ' + str(padlen) + ' bytes')
- with open(fPath, 'ab') as f:
- f.write(('\0' * padlen).encode('utf8'))
-
- else:
- print('Please correct the image or use the -p option to pad the binary')
- os._exit(1)
-
- except:
- print(sys.exc_info()[0])
- print("Error: there is a problem with the image " + item[key])
- print('Please check it exists and retry')
- sys.exit(EXIT_WITH_ERROR)
-
- elif key == 'address':
- # validate address is valid
- validateNumber(item[key], False)
-
- elif key == 'addressX16':
- # validate address is valid and 16-byte aligned
- validateNumber(item[key], True)
-
- elif key == 'sizeX16':
- #validate size
- validateNumber(item[key], True)
-
- elif key == 'pattern':
- # validate pattern
- validateNumber(item[key], False)
-
-
-def convertToHex(item):
- # item could be a file (returned as it is) or a number
- # if decimal number, it will be converted to hex and returned
- # if hexadecimal number, it will be returned as it is
- if item[:2].lower() != '0x':
- try:
- return hex(int(item, 10))
-
- except:
- return item
-
- return item
-
-
-def validateArgList(action, argList, pad=False):
- items = []
- if action == 'Burning: ':
- # we should have a pair of parameters (file and MRAM_Address)
- pairList = argList.split(' ')
- if len(pairList)%2:
- print('Error in parameters: check the help using -h option')
- sys.exit(EXIT_WITH_ERROR)
-
- tmp = {}
- for i in range(0, len(pairList), 2):
- tmp["file"] = pairList[i]
- tmp["address"] = pairList[i+1]
- items.append(tmp.copy())
-
- elif action == 'Erasing: ':
- # we should have a pair of parameters (file and MRAM_Address)
- params = argList.split(' ')
- if len(params)<3 or len(params)>4:
- print('Error in parameters: check the help using -h option')
- sys.exit(EXIT_WITH_ERROR)
-
- tmp = {}
- tmp["addressX16"] = params[1]
- tmp["sizeX16"] = params[2]
- if len(params)==4:
- tmp["pattern"] = params[3]
-
- items.append(tmp)
-
- else:
- # we can't validate arguments as we don't recognize the action
- print('Unknown option in argument validation: ' + action)
- sys.exit(EXIT_WITH_ERROR)
-
- # validate the list of items to validate
- validateItems(items, pad)
-
- newArgList = ''
- for item in argList.split(' '):
- newArgList += convertToHex(item) + ' '
-
- return newArgList
-
+#!/usr/bin/env python3
+import os
+import sys
+
+EXIT_WITH_ERROR = 1
+
+def validateNumber(number, alignment):
+ #validate a number (to be used as an Address, Size or Pattern)
+ # 1. check number is valid (positive integer <= 32bits)
+ # 2. if address is in decimal, check for negative values
+ # 3. check for 16-byte alignment if requested
+ if number[:2].lower() == '0x':
+ base = 16
+ else:
+ base = 10
+
+ try:
+ val = int(number,base)
+ if val < 0:
+ raise Exception
+
+ except:
+ print('Error in parameter ' + number + ' - Please check')
+ sys.exit(EXIT_WITH_ERROR)
+
+ if alignment == True:
+ if val%16:
+ print('Error: parameter ' + number + ' must be multiple of 16')
+ print('Please correct and retry')
+ sys.exit(EXIT_WITH_ERROR)
+
+ if len(hex(val)) > 10:
+ print("Error: parameter " + number + " can't be larger than a 32-bit value")
+ print('Please correct and retry')
+ sys.exit(EXIT_WITH_ERROR)
+
+ return val
+
+def validateItems(items, pad):
+ # we get a list of dictionaries
+ for item in items:
+ for key in item:
+ if key == 'file':
+ # validate file
+ # get file size to check existance
+ try:
+ # mram_burner runs in bin/ folder so all references would
+ # have '../' to land into tools root directory and describe the path from there...
+ # GUI will solve all these limitations.
+ fPath = item[key][3:]
+ fSize = os.path.getsize(fPath)
+ if (fSize % 16) != 0:
+ print("File size = %d" % fSize)
+ print('!!!WARNING: the SIZE of ' + fPath + ' is NOT multiple of 16 bytes as required by MRAM')
+ if pad:
+ padlen = (16 - (fSize % 16))
+ print('Since the -p option was invoked, the binary will be padded with ' + str(padlen) + ' bytes')
+ with open(fPath, 'ab') as f:
+ f.write(('\0' * padlen).encode('utf8'))
+
+ else:
+ print('Please correct the image or use the -p option to pad the binary')
+ os._exit(1)
+
+ except:
+ print(sys.exc_info()[0])
+ print("Error: there is a problem with the image " + item[key])
+ print('Please check it exists and retry')
+ sys.exit(EXIT_WITH_ERROR)
+
+ elif key == 'address':
+ # validate address is valid
+ validateNumber(item[key], False)
+
+ elif key == 'addressX16':
+ # validate address is valid and 16-byte aligned
+ validateNumber(item[key], True)
+
+ elif key == 'sizeX16':
+ #validate size
+ validateNumber(item[key], True)
+
+ elif key == 'pattern':
+ # validate pattern
+ validateNumber(item[key], False)
+
+
+def convertToHex(item):
+ # item could be a file (returned as it is) or a number
+ # if decimal number, it will be converted to hex and returned
+ # if hexadecimal number, it will be returned as it is
+ if item[:2].lower() != '0x':
+ try:
+ return hex(int(item, 10))
+
+ except:
+ return item
+
+ return item
+
+
+def validateArgList(action, argList, pad=False):
+ items = []
+ if action == 'Burning: ':
+ # we should have a pair of parameters (file and MRAM_Address)
+ pairList = argList.split(' ')
+ if len(pairList)%2:
+ print('Error in parameters: check the help using -h option')
+ sys.exit(EXIT_WITH_ERROR)
+
+ tmp = {}
+ for i in range(0, len(pairList), 2):
+ tmp["file"] = pairList[i]
+ tmp["address"] = pairList[i+1]
+ items.append(tmp.copy())
+
+ elif action == 'Erasing: ':
+ # we should have a pair of parameters (file and MRAM_Address)
+ params = argList.split(' ')
+ if len(params)<3 or len(params)>4:
+ print('Error in parameters: check the help using -h option')
+ sys.exit(EXIT_WITH_ERROR)
+
+ tmp = {}
+ tmp["addressX16"] = params[1]
+ tmp["sizeX16"] = params[2]
+ if len(params)==4:
+ tmp["pattern"] = params[3]
+
+ items.append(tmp)
+
+ else:
+ # we can't validate arguments as we don't recognize the action
+ print('Unknown option in argument validation: ' + action)
+ sys.exit(EXIT_WITH_ERROR)
+
+ # validate the list of items to validate
+ validateItems(items, pad)
+
+ newArgList = ''
+ for item in argList.split(' '):
+ newArgList += convertToHex(item) + ' '
+
+ return newArgList
+