Skip to content

Instantly share code, notes, and snippets.

Last active April 12, 2023 12:15
Show Gist options
  • Save lupyuen/a08d3d478beefc5a492ed2dae39438f3 to your computer and use it in GitHub Desktop.
Save lupyuen/a08d3d478beefc5a492ed2dae39438f3 to your computer and use it in GitHub Desktop.
Validate NuttX Release for PinePhone
#!/usr/bin/env bash
## Validate NuttX Release for PinePhone
## Based on
## Sample Output:
## clear && cd /tmp && script release.log ~/PinePhone/wip-nuttx/
echo ----- Validate NuttX Release for PinePhone
## TODO: Update PATH
export PATH="$PATH:/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/bin"
echo ----- Remove checkrelease folder
rm -r checkrelease
set -e ## Exit when any command fails
set -x ## Echo commands
## TODO: Update release and candidate
## Build NuttX
function build_nuttx {
## Go to NuttX Folder
pushd ../nuttx
## Build NuttX
make -j
## Return to previous folder
echo ----- download staged artifacts. Check their signature and hashes.
mkdir checkrelease
cd checkrelease
wget -r -nH --cut-dirs=100 --no-parent$release-$candidate/
## To import the keys: wget && 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"
echo '----- [RM] verify the reported hashes:'
shasum -a 512 -c apache-nuttx-$release.tar.gz.sha512
shasum -a 512 -c apache-nuttx-apps-$release.tar.gz.sha512
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, files in the extracted source bundle in BOTH apps and nuttx
ls -l nuttx/LICENSE
ls -l nuttx/NOTICE
ls -l nuttx/
ls -l apps/LICENSE
ls -l apps/NOTICE
ls -l apps/
echo ----- Build Targets
cd nuttx
echo '===== Compiler'
aarch64-none-elf-gcc -v
echo '===== Configuration'
./tools/ pinephone:nsh
echo ----- Build NuttX
echo '===== 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 \
## Quit if microSD card not present
if [ ! -d "/Volumes/NO NAME" ]
echo ----- microSD Card not found
echo ----- Copy the config
cp .config nuttx.config
echo ----- Compress the NuttX Image
cp nuttx.bin Image
rm -f Image.gz
gzip Image
echo ----- Copy to microSD
cp Image.gz "/Volumes/NO NAME"
ls -l "/Volumes/NO NAME/Image.gz"
## TODO: Verify that /dev/disk2 is microSD
echo ----- Unmount microSD
diskutil unmountDisk /dev/disk2
echo ----- Run the firmware
echo Insert microSD into PinePhone, connect PinePhone to USB and press Enter. Power on, run "uname -a" and "free"...
echo '===== NSH Info and Free'
screen /dev/tty.usbserial-1410 115200
echo ----- TODO: Verify hash from uname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment