nuttx-release/release-pinephone.sh

147 lines
3.7 KiB
Bash
Raw Permalink Normal View History

2024-05-20 09:08:50 +08:00
#!/usr/bin/env bash
## Validate NuttX Release for PinePhone
## Based on https://cwiki.apache.org/confluence/display/NUTTX/Validating+a+staged+Release
## Sample Output: https://gist.github.com/lupyuen/5760e0375d44a06b3c730a10614e4d24
2024-06-25 14:46:56 +08:00
## clear && ~/nuttx-release/release.sh pinephone
2024-05-20 09:08:50 +08:00
echo ----- Validate NuttX Release for PinePhone
2024-06-25 14:46:56 +08:00
echo release=$release
echo candidate=$candidate
echo hash=$hash
2024-06-25 14:52:12 +08:00
echo https://github.com/lupyuen/nuttx-release/blob/main/release-pinephone.sh
2024-05-20 09:08:50 +08:00
2024-05-20 09:36:59 +08:00
## TODO: Update PATH for Arm GNU Toolchain aarch64-none-elf
## export PATH="$HOME/arm-gnu-toolchain-13.2.Rel1-x86_64-aarch64-none-elf/bin:$PATH"
2024-05-20 09:08:50 +08:00
echo ----- Remove checkrelease folder
cd /tmp
rm -r checkrelease
set -e ## Exit when any command fails
set -x ## Echo commands
## Build NuttX
function build_nuttx {
## Go to NuttX Folder
pushd ../nuttx
## Build NuttX
2024-11-29 17:45:26 +08:00
make -j
2024-05-20 09:08:50 +08:00
## Return to previous folder
popd
}
neofetch
echo ----- download staged artifacts. Check their signature and hashes.
mkdir checkrelease
cd checkrelease
wget -r -nH --cut-dirs=100 --no-parent https://dist.apache.org/repos/dist/dev/nuttx/$release-$candidate/
## To import the keys: wget https://dist.apache.org/repos/dist/dev/nuttx/KEYS && gpg --import KEYS
## To trust the keys: gpg --edit-key 9208D2E4B800D66F749AD4E94137A71698C5E4DB
## Then enter "trust" and "5"
echo '----- [RM] verify the reported signature ("gpg: Good signature from ...")'
gpg --verify apache-nuttx-$release.tar.gz.asc apache-nuttx-$release.tar.gz
gpg --verify apache-nuttx-apps-$release.tar.gz.asc apache-nuttx-apps-$release.tar.gz
## For Linux: Use "sha512sum" instead of "shasum -a 512"
2024-05-20 09:31:46 +08:00
## For macOS: Use "shasum -a 512" instead of "sha512sum"
2024-05-20 09:08:50 +08:00
echo '----- [RM] verify the reported hashes:'
2024-05-20 09:31:46 +08:00
sha512sum -c apache-nuttx-$release.tar.gz.sha512
sha512sum -c apache-nuttx-apps-$release.tar.gz.sha512
## shasum -a 512 -c apache-nuttx-$release.tar.gz.sha512
## shasum -a 512 -c apache-nuttx-apps-$release.tar.gz.sha512
2024-05-20 09:08:50 +08:00
echo ----- extract src bundle
tar -xf apache-nuttx-$release.tar.gz
tar -xf apache-nuttx-apps-$release.tar.gz
echo ----- verify the existence of LICENSE, NOTICE, README.md files in the extracted source bundle in BOTH apps and nuttx
ls -l nuttx/LICENSE
ls -l nuttx/NOTICE
ls -l nuttx/README.md
ls -l apps/LICENSE
ls -l apps/NOTICE
ls -l apps/README.md
echo ----- Build Targets
cd nuttx
echo '===== PinePhone Compiler'
aarch64-none-elf-gcc -v
echo '===== PinePhone Configuration'
./tools/configure.sh pinephone:nsh
echo ----- Build NuttX
build_nuttx
2024-05-20 12:25:29 +08:00
echo ----- Copy the config
cp .config nuttx.config
echo ----- Compress the NuttX Image
cp nuttx.bin Image
rm -f Image.gz
gzip Image
2024-05-20 09:08:50 +08:00
echo '===== PinePhone Size'
aarch64-none-elf-size nuttx
echo ----- Dump the disassembly to nuttx.S
aarch64-none-elf-objdump \
-t -S --demangle --line-numbers --wide \
nuttx \
>nuttx.S \
2>&1 \
&
echo ----- Wait for microSD
2024-06-24 16:26:52 +08:00
microsd=/media/luppy/A993-6C26
2024-05-20 09:08:50 +08:00
set +x # Don't echo commands
echo "***** Insert microSD into computer"
while : ; do
2024-05-20 12:25:29 +08:00
if [ -d "$microsd" ]
2024-05-20 09:08:50 +08:00
then
break
fi
sleep 1
done
2024-05-20 12:25:29 +08:00
sleep 1
2024-05-20 09:08:50 +08:00
set -x # Echo commands
echo ----- Copy to microSD
2024-05-20 12:25:29 +08:00
cp Image.gz "$microsd/"
ls -l "$microsd/Image.gz"
2024-05-20 09:08:50 +08:00
echo ----- Unmount microSD
2024-05-20 12:25:29 +08:00
umount "$microsd"
## For macOS: diskutil unmountDisk /dev/disk2
## TODO: Verify that /dev/disk2 is microSD
2024-05-20 09:08:50 +08:00
echo ----- Wait for USB Serial to be connected
2024-05-20 12:25:29 +08:00
## sudo usermod -a -G dialout $USER
usbserial=/dev/ttyUSB0
2024-05-20 09:08:50 +08:00
set +x # Don't echo commands
echo "***** Insert microSD into PinePhone, connect PinePhone to USB"
while : ; do
2024-05-20 12:25:29 +08:00
if [ -c "$usbserial" ]
2024-05-20 09:08:50 +08:00
then
break
fi
sleep 1
done
set -x # Echo commands
2024-05-20 12:25:29 +08:00
2024-05-20 09:08:50 +08:00
echo ----- Run the firmware
echo Power on PinePhone, run "uname -a" and "free".
echo Press Enter to begin...
read
echo '===== PinePhone NSH Info and Free'
2024-06-24 16:27:29 +08:00
screen "$usbserial" 115200
2024-05-20 09:08:50 +08:00
echo ----- TODO: Verify hash from uname