PINE64
Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PinePhone (https://forum.pine64.org/forumdisplay.php?fid=120)
+--- Forum: PinePhone Software (https://forum.pine64.org/forumdisplay.php?fid=121)
+--- Thread: Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS (/showthread.php?tid=18236)

Pages: 1 2 3


Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - lupyuen - 05-16-2023

When we tilt our Smartphone from Portrait to Landscape... How does it know that we're tilting our phone?

That's because of the Accelerometer inside our Smartphone! To understand how it works, let's snoop the raw Accelerometer Data from PinePhone with Apache NuttX RTOS (Real-Time Operating System)...

Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS


RE: Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - WhiteHexagon - 05-17-2023

(05-16-2023, 09:16 PM)lupyuen Wrote: When we tilt our Smartphone from Portrait to Landscape... How does it know that we're tilting our phone?

I just started looking at NuttX yesterday Smile I am busy reading all your articles, and so far they have been great, and very educational, thanks!  but just to say I very much prefer the github.io format you have been using prior to this article.

Yesterday I was trying to setup the build environment for NuttX (I am running an older macos).  I had a couple issues with the instructions from the apache site, specifically getting kconfig-frontends installed.  (even the original site seemed to be down.)  Anyway I seem to have solved that one now, but hit another problem running 'make'.  The sub packages need a TOPDIR value that seemed to be blank on macos.  I ended up changing Unix.mk with:

Code:
TOPDIR := $(shell echo "$${PWD// /\\ }")

but that just shifted the error:

Code:
make[1]: *** No rule to make target 'context'.  Stop.
make: *** [tools/Unix.mk:445: libs/libm/.context] Error 2
so then I started to think maybe I downloaded the wrong build scripts (unix vs macos?)

The good news is I tried another of your tutorial type articles regarding the lvgl patching of 'jumpdrive' and this boots on the PinePhone! Smile and just to say: Wow! it is fast!  After holding the power button for a few seconds to turn the PP on, within a second lvgl interface is already up and running.  Very impressed, and more like what I was expecting from this hardware.  Great work!  It crashes after a few clicks, but I know it is early days.  Now I want to get the build environment up and running even more Smile  So suggestion would be to have each development environment with their own setup instructions.  Since in the prerequisites I am currently a bit lost to what tool-chain I need.  And the above lvgl sourcecode zip currently fails to build:

Code:
/bin/bash: aarch64-none-elf-gcc: command not found

but maybe the environment got confused trying to build two different downloads of nuttX.  Anyway looking forward to seeing more of your articles.  Any plans to investigate the OpenGL/OpenVG parts of the SoC?  Maybe I can try that when I am up and running.  I am also Zig based, so you gave me a good starting point Smile


RE: Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - lupyuen - 05-17-2023

Wow thanks @WhiteHexagon , that sounds awesome! I'm also using a very old MacBook Pro, macOS 10.15.7.

My Arm64 GCC version is 11.3.1, downloaded from here (look for "AArch64 Bare-Metal Target aarch64-none-elf")

Code:
→ aarch64-none-elf-gcc -v

Using built-in specs.
COLLECT_GCC=aarch64-none-elf-gcc
COLLECT_LTO_WRAPPER=/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/bin/../libexec/gcc/aarch64-none-elf/11.3.1/lto-wrapper
Target: aarch64-none-elf
Configured with: /Volumes/data/jenkins/workspace/GNU-toolchain/arm-11/src/gcc/configure --target=aarch64-none-elf --prefix=/Volumes/data/jenkins/workspace/GNU-toolchain/arm-11/build-aarch64-none-elf/install --with-gmp=/Volumes/data/jenkins/workspace/GNU-toolchain/arm-11/build-aarch64-none-elf/host-tools --with-mpfr=/Volumes/data/jenkins/workspace/GNU-toolchain/arm-11/build-aarch64-none-elf/host-tools --with-mpc=/Volumes/data/jenkins/workspace/GNU-toolchain/arm-11/build-aarch64-none-elf/host-tools --with-isl=/Volumes/data/jenkins/workspace/GNU-toolchain/arm-11/build-aarch64-none-elf/host-tools --disable-shared --disable-nls --disable-threads --disable-tls --enable-checking=release --enable-languages=c,c++,fortran --with-newlib --with-gnu-as --with-gnu-ld --with-sysroot=/Volumes/data/jenkins/workspace/GNU-toolchain/arm-11/build-aarch64-none-elf/install/aarch64-none-elf --with-pkgversion='Arm GNU Toolchain 11.3.Rel1' --with-bugurl=https://bugs.linaro.org/
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 11.3.1 20220712 (Arm GNU Toolchain 11.3.Rel1)

Remember to add Arm64 GCC to the PATH after installing the DMG:

Code:
export PATH="$PATH:/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/bin"

I used these steps to install kconfig-frontends: https://lupyuen.github.io/articles/nuttx#install-prerequisites

Code:
##  For macOS:
brew install automake
##  Build "kconfig-frontends" because the "brew install" version doesn't work
pushd /tmp
git clone https://bitbucket.org/nuttx/tools.git
cd tools/kconfig-frontends
patch < ../kconfig-macos.diff -p 1
./configure --enable-mconf --disable-shared --enable-static --disable-gconf --disable-qconf --disable-nconf
##  Needed because "make" requires "aclocal-1.15" and "automake-1.15"
sudo ln -s /usr/local/bin/aclocal /usr/local/bin/aclocal-1.15
sudo ln -s /usr/local/bin/automake /usr/local/bin/automake-1.15
make
##  Install "kconfig-frontends"
make install
popd

And I'm using a rather old version of Zig:

Code:
→ zig version
0.10.0-dev.2351+b64a1d5ab

Lemme know if this works for building NuttX on macOS. Thanks! :-)


RE: Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - traut - 05-17-2023

I am glad to see you using something that _isn’t_ github for this article.


RE: Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - walter1950 - 05-17-2023

Hello,
(05-17-2023, 05:07 AM)lupyuen Wrote: Wow thanks @WhiteHexagon , that sounds awesome! I'm also using a very old MacBook Pro, macOS 10.15.7.
...


https://medium.com/@ly.lee
"Error
410
This account is under investigation or was found in violation of the Medium Rules."
;-)

Ciao
Walter


RE: Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - lupyuen - 05-17-2023

Hi @traut : If it helps, my articles are mirrored to GitLab as well: https://gitlab.com/lupyuen/lupyuen-github-io/-/blob/master/src/lte2.md

UPDATE: I have mirrored my articles to Codeberg Pages, please use this instead: https://lupyuen.codeberg.page/


RE: Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - WhiteHexagon - 05-18-2023

Thanks @lupyuen  so I still managed to download the wrong toolkit two more times, oops!  Smile  but I think this is the correct one:


Code:
arm-gnu-toolchain-11.3.rel1-darwin-x86_64-aarch64-none-elf.tar.xz

but I get an error with that (added to PATH thanks):


Code:
dyld: Symbol not found: ____chkstk_darwin
Referenced from: /Users/peter/Development/ArmGNUToolchain/arm-gnu-toolchain-11.3.rel1-darwin-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc
Expected in: /usr/lib/libSystem.B.dylib


I think everything else is now configured correctly, apart from the toolchain.  As I mentioned, it is an older macos (10.12.4) and hence my Zig is also older version (0.8.1) not that I got that far yet Smile but just for context.


RE: Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - lupyuen - 05-18-2023

Sorry @WhiteHexagon I meant this PKG file:

arm-gnu-toolchain-11.3.rel1-darwin-x86_64-aarch64-none-elf.pkg

If it doesn't work, try this Arm64 Toolchain that I have zipped from my Mac:

https://github.com/lupyuen2/wip-pinephone-nuttx/releases/download/arm/ArmGNUToolchain-backup.zip


RE: Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - WhiteHexagon - 05-19-2023

@lupyuen Thanks, I tried both, but same error, so maybe my macos is too old. I tried the 11.2 release and same error. Earlier versions dont seem to support macos. Do you think it is possible to setup a complete build environment on a Raspberry Pi 4? Or maybe I should buy a Pinebook Pro Smile


RE: Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - lupyuen - 05-19-2023

(05-19-2023, 03:14 AM)WhiteHexagon Wrote: @lupyuen Thanks, I tried both, but same error, so maybe my macos is too old.  I tried the 11.2 release and same error.  Earlier versions dont seem to support macos.  Do you think it is possible to setup a complete build environment on a Raspberry Pi 4?  Or maybe I should buy a Pinebook Pro Smile

Yeah sorry about that. I was able to build NuttX on Pinebook Pro (Manjaro), so the same steps will probably work on any Arm64 SBC: https://gist.github.com/lupyuen/abca4d656ba0c93787e7705eec8707c8

Here's a wild idea: How about building NuttX for PinePhone... On PinePhone? Try the same steps from that link.

Or if we're doing a quick test, we could try building with GitHub Actions: https://lupyuen.github.io/articles/auto#appendix-build-nuttx-with-github-actions

UPDATE: Here's the GitHub Actions Workflow for building NuttX for PinePhone: https://github.com/lupyuen2/wip-pinephone-nuttx/blob/build/.github/workflows/pinephone.yml

I tried building on Android with Termux but it didn't work: https://gist.github.com/lupyuen/f59c681dde9ebac86b331f2577aa04ad