Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS
#1
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
  Reply
#2
(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
  Reply
#3
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...requisites

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! :-)
  Reply
#4
I am glad to see you using something that _isn’t_ github for this article.
  Reply
#5
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
  Reply
#6
Hi @traut : If it helps, my articles are mirrored to GitLab as well: https://gitlab.com/lupyuen/lupyuen-githu...rc/lte2.md

UPDATE: I have mirrored my articles to Codeberg Pages, please use this instead: https://lupyuen.codeberg.page/
  Reply
#7
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.
  Reply
#8
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-pinephon...backup.zip
  Reply
#9
@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
  Reply
#10
(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/abca4d65...5eec8707c8

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#...ub-actions

UPDATE: Here's the GitHub Actions Workflow for building NuttX for PinePhone: https://github.com/lupyuen2/wip-pinephon...ephone.yml

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Slarm64 on PinePhone [Unofficial Slackware ARM - 64 bit] acid andy 32 23,369 03-21-2024, 04:27 PM
Last Post: donchurch
Wink PINEPHONE not booting Touchwood 2 284 02-23-2024, 07:27 AM
Last Post: Touchwood
  Slack on PinePhone Adam Seline 5 5,159 12-20-2023, 07:20 AM
Last Post: nickolas
  Struggle to install LibreOffice on the PinePhone Peter Gamma 48 22,971 11-24-2023, 07:02 AM
Last Post: Peter Gamma
  Which word processor to choose for the Pinephone? Peter Gamma 8 1,718 11-23-2023, 01:06 AM
Last Post: Peter Gamma
  openSUSE for Pinephone Alefnode 75 100,011 11-17-2023, 08:37 AM
Last Post: Uturn
  Using Signal on PinePhone in mid-2023? dante404 45 11,774 11-17-2023, 04:23 AM
Last Post: Kevin Kofler
  Genode- Sculpt OS for the PinePhone (non Linux) Surehand53 1 820 11-04-2023, 07:23 PM
Last Post: tllim
  Abiword as a office mobile word processor for the Pinephone? Peter Gamma 11 1,846 10-24-2023, 08:57 AM
Last Post: Peter Gamma
  What File Manager Options Are There For The Pinephone? pinephoneuser22 7 2,123 10-18-2023, 08:37 AM
Last Post: luppivega

Forum Jump:


Users browsing this thread: 1 Guest(s)