Skip to content

Instantly share code, notes, and snippets.

@lupyuen
Last active July 2, 2024 07:12
Show Gist options
  • Save lupyuen/95873ad34633e701ba30dc4e143ef739 to your computer and use it in GitHub Desktop.
Save lupyuen/95873ad34633e701ba30dc4e143ef739 to your computer and use it in GitHub Desktop.
Prepare Local PR for Ox64 LED Driver

Prepare Local PR for Ox64 LED Driver

  1. For NuttX and NuttX Apps: Sync Fork > Update Branch

  2. Based on NuttX and NuttX Apps master branch: Create a new branch gpio3

  3. Copy from gpio to gpio3, ONLY the Ox64 LED Driver, not the BL808 GPIO Driver

    (Only 7 files, see below)

  4. Overwrite bl808_autoleds.c by this file:

    https://github.com/lupyuen2/wip-nuttx/blob/gpio6/boards/risc-v/bl808/ox64/src/bl808_autoleds.c

  5. Overwrite bl808_userleds.c by this file:

    https://github.com/lupyuen2/wip-nuttx/blob/gpio6/boards/risc-v/bl808/ox64/src/bl808_userleds.c

  6. Overwrite bl808_appinit.c by this file:

    https://github.com/lupyuen2/wip-nuttx/blob/gpio6/boards/risc-v/bl808/ox64/src/bl808_appinit.c

  7. In boards/risc-v/bl808/ox64/configs/nsh/defconfig: Remove these lines

    CONFIG_EXAMPLES_LEDS=y
    CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=65536
    CONFIG_TLS_LOG2_MAXSTACK=16
  8. boards/Kconfig will have conflicts, we need to merge the changes carefully. We will discuss at the Monday Meeting.

    (Note that Kconfig files have Tab Characters inside, please keep them intact!)

  9. The other 6 files may have conflicts, please merge them carefully.

    (We will discuss at the Monday Meeting)

  10. Copy the Rust Blinky to NuttX Apps gpio3 (see below)

  11. Compile and retest Rust Blinky on Ox64 Emulator

  12. Commit the files to gpio3

    (Be sure to commit only once. Otherwise we need to Squash the Commits into one single commit)

  13. Create a new Local PR for gpio3 in your repo (not upstream)

  14. Set PR to Draft Mode

  15. Fill in the PR Text

  16. Since henryrov has reverted the BL808 Courier Driver, don't we need to re-upstream bl808_glb.h?

    Actually henryrov is aware that we're using the GPIO Registers in bl808_glb.h, that's why bl808_glb.h wasn't reverted. See the Revert PR: apache/nuttx#12575

Copy Ox64 LED GPIO Driver from gpio to gpio3

How to copy from gpio to gpio3, ONLY the Ox64 LED Driver, not the BL808 GPIO LED Driver:

## Check out the Source Repo
mkdir -p /tmp/gpio
cd /tmp/gpio
git clone \
  https://github.com/rushabhvg/nuttx \
  nuttx \
  --branch gpio

## Check out the Dest Repo
mkdir -p /tmp/gpio3
cd /tmp/gpio3
git clone \
  https://github.com/rushabhvg/nuttx \
  nuttx \
  --branch gpio3

## Copy a file from `gpio` to `gpio3`
function copy_file {
  set -x  #  Echo commands
  cp \
    /tmp/gpio/nuttx/$1 \
    /tmp/gpio3/nuttx/$1
}

## Copy the Ox64 LED Driver to the new `gpio3` branch
copy_file boards/Kconfig
copy_file boards/risc-v/bl808/ox64/configs/nsh/defconfig
copy_file boards/risc-v/bl808/ox64/include/board.h
copy_file boards/risc-v/bl808/ox64/src/Makefile
copy_file boards/risc-v/bl808/ox64/src/bl808_appinit.c
copy_file boards/risc-v/bl808/ox64/src/bl808_autoleds.c
copy_file boards/risc-v/bl808/ox64/src/bl808_userleds.c

## Skip these files, we won't change the Linker Script (meant for Fully-Linked ELF Executables)
## copy_file boards/risc-v/bl808/ox64/scripts/gnu-elf.ld
## copy_file boards/risc-v/bl808/ox64/scripts/ld.script

## How we got the above files:
## pr=https://github.com/rushabhvg/nuttx/pull/1
## curl -L $pr.diff \
##   | grep "diff --git" \
##   | sort \
##   | cut -d" " -f3 \
##   | cut -c3-

## How I copy Rust Blinky to `nuttx-apps`
pushd ../apps/examples/hello_rust
rm hello_rust_main.rs
wget https://raw.githubusercontent.com/rushabhvg/nuttx-apps/gpio/examples/hello_rust/hello_rust_main.rs
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment