Let's run Apache #NuttX OS on RISC-V #BL602
https://nuttx.apache.org/docs/latest/platforms/risc-v/bl602/index.html
Apache #NuttX OS is super interesting because 1️⃣ It runs on all kinds of MCUs 2️⃣ Its APIs work like POSIX (Linux-lite)
https://nuttx.apache.org/docs/latest/introduction/about.html
#NuttX #BL602 builds easily on WSL Ubuntu ... Uses plain "make" with "kconfig"
https://nuttx.apache.org/docs/latest/platforms/risc-v/bl602/index.html
#NuttX boots OK on PineCone #BL602 ... Also on PineDio Stack #BL604! 🎉
https://nuttx.apache.org/docs/latest/platforms/risc-v/bl602/index.html
Default #BL602 #NuttX Firmware includes 2 Demo Apps: "hello" and "timer"
https://github.com/apache/incubator-nuttx-apps/tree/master/examples/hello
https://github.com/apache/incubator-nuttx-apps/tree/master/examples/timer
#NuttX Demo Apps are configured before build with "make menuconfig"
https://nuttx.apache.org/docs/latest/quickstart/configuring.html
#BL602 #NuttX "Hello World" ... Looks exactly like on Linux
https://github.com/apache/incubator-nuttx-apps/blob/master/examples/hello/hello_main.c
Timer Demo on #BL602 #NuttX opens "/dev/timer0" ... And controls it with "ioctl" and "sigaction" ... Looks like Linux
https://github.com/apache/incubator-nuttx-apps/blob/master/examples/timer/timer_main.c
Here are the #BL602 Peripherals supported by #NuttX OS
https://nuttx.apache.org/docs/latest/platforms/risc-v/bl602/index.html#bl602-peripheral-support
Though SPI with DMA is not yet supported on #BL602 #NuttX OS
https://github.com/apache/incubator-nuttx/blob/master/arch/risc-v/src/bl602/bl602_spi.c#L734-L761
Here are the Pin Definitions for #BL602 #NuttX ... We'll change this in a while
https://github.com/apache/incubator-nuttx/blob/master/boards/risc-v/bl602/bl602evb/include/board.h
Let's enable the "help" and "ls" Shell Commands in #BL602 #NuttX
https://nuttx.apache.org/docs/latest/quickstart/configuring.html
Let's test GPIO on #BL602 #NuttX ... By enabling the GPIO Driver
https://nuttx.apache.org/docs/latest/quickstart/configuring.html
After the GPIO Driver has been enabled, select the GPIO Demo in #BL602 #NuttX
https://nuttx.apache.org/docs/latest/quickstart/configuring.html
"help" shows the commands available on #BL602 #NuttX ... "ls /dev" reveals the GPIO Pins that we may control ... Yep everything looks like a file!
https://acassis.wordpress.com/2021/01/24/how-to-install-nuttx-on-bl602/
GPIO Demo calls "ioctl" to control the GPIO Pins on #BL602 #NuttX
https://github.com/apache/incubator-nuttx-apps/blob/master/examples/gpio/gpio_main.c
#NuttX writes correctly to the GPIO 11 Output Register at 0x40000188 (BL602_GPIO_CFGCTL32)
https://github.com/apache/incubator-nuttx/blob/master/arch/risc-v/src/bl602/bl602_gpio.c#L190-L209
#NuttX configures #BL602 GPIO 11 (0x40000114) with GPIO Input Disabled ... But it doesn't Enable GPIO Output 🤔
https://github.com/apache/incubator-nuttx/blob/master/arch/risc-v/src/bl602/bl602_gpio.c#L59-L133
#BL602 Reference Manual says we should set the GPIO Output Enable Register ... But it's missing from the docs ... Where is the register? 🤔
https://github.com/bouffalolab/bl_docs/tree/main/BL602_RM/en
Blinking the #BL602 LED ... Works on #NuttX BASIC too! 🎉
https://github.com/lupyuen/incubator-nuttx-apps/tree/master/interpreters/bas
As we've seen, #NuttX has its own HAL for #BL602 ... Which differs from BL602 IoT SDK ... So we expect some quirks
https://github.com/apache/incubator-nuttx/tree/master/arch/risc-v/src/bl602
How we enable "help" and "ls" in #NuttX #BL602
https://lupyuen.github.io/articles/nuttx?7#enable-help-and-ls
Enabling the GPIO Driver for #NuttX #BL602
https://lupyuen.github.io/articles/nuttx?8#enable-gpio-driver
Here's why GPIO Output doesn't work on #BL602 #NuttX ... And how we fixed it
https://lupyuen.github.io/articles/nuttx?24#appendix-fix-gpio-output
History of #NuttX on #BL602 ... How it started 1 year ago 👍
https://www.mail-archive.com/dev@nuttx.apache.org/msg05124.html
There's a glitch in the #NuttX #BL602 GPIO Driver ... Will submit a PR shortly 👍
https://lupyuen.github.io/articles/nuttx?15#gpio-glitch