Skip to content

arm64/am62x: add initial BeaglePlay and PocketBeagle2 bring-up#18907

Open
PiyushPatle26 wants to merge 6 commits into
apache:masterfrom
PiyushPatle26:am62x-beagleplay-bringup
Open

arm64/am62x: add initial BeaglePlay and PocketBeagle2 bring-up#18907
PiyushPatle26 wants to merge 6 commits into
apache:masterfrom
PiyushPatle26:am62x-beagleplay-bringup

Conversation

@PiyushPatle26
Copy link
Copy Markdown
Contributor

Note: Please adhere to Contributing Guidelines.

Summary

This PR adds initial NuttX bring-up support for TI AM62x boards and introduces board support for:

  • BeaglePlay
  • PocketBeagle2

The main goal is to make AM62x boot reliably into NuttX with a working serial console and interactive NSH on BeaglePlay.

What this PR adds:

  • common ARM64 EL2 handoff update so EL1 can use the GICv3 system-register interface
  • AM62x arch support under arch/arm64
  • AM62x low-level boot, memory map, IRQ definitions, low-level console, and 16550 lower-half serial support
  • 16550 driver fixes needed for AM62x console bring-up
  • BeaglePlay board support with:
    • beagleplay:nsh
    • beagleplay:ostest
  • PocketBeagle2 board support with matching AM62x integration
  • AM62x platform and board documentation

The 16550 changes are required because AM62x UART bring-up was not stable with the generic initialization sequence alone. This PR keeps the generic 16550 path, but adjusts it so the AM62x/TI K3 UART setup works correctly during both early console and runtime console use.

For BeaglePlay, the documented and validated boot flow is manual U-Boot boot from microSD:

mmc dev 1 0
fatload mmc 1:1 0x82000000 nuttx.bin
go 0x82000000

ostest was also validated on hardware using:

mmc dev 1 0
fatload mmc 1:1 0x82000000 nuttx-ostest.bin
go 0x82000000

Impact

Is a part towards completing this task #18666

Architecture / core:

  • adds AM62x support to arch/arm64
  • adds EL2-to-EL1 GICv3 handoff handling needed on this boot path

Drivers:

  • updates drivers/serial/uart_16550.c for AM62x-compatible FIFO setup
  • preserves bootloader-owned console state where required
  • fixes TX polling behavior needed for reliable console output

Boards:

  • adds BeaglePlay support
  • adds PocketBeagle2 support

Build / config:

  • adds new board defconfigs:
    • beagleplay:nsh
    • beagleplay:ostest
    • PocketBeagle2 configs

Testing

Ran Basic commands and OStest on beagleplay:
image

@github-actions github-actions Bot added Area: Build system Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. Board: arm64 labels May 20, 2026
@lupyuen
Copy link
Copy Markdown
Member

lupyuen commented May 20, 2026

@PiyushPatle26 Could you add "Signed-off-by" to your commits? And run nxstyle to fix the formatting errors below. Thanks :-)

https://github.com/apache/nuttx/actions/runs/26137295099/job/76875152946?pr=18907#step:3:91

❌ Missing Signed-off-by
Used config files:
    1: .codespellrc
Warning: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/beagleplay/include/board_memorymap.h:18:1: warning: #include outside of 'Included Files' section
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/beagleplay/src/beagleplay_autoleds.c:91:1: error: Missing blank line before comment found
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/beagleplay/src/beagleplay_autoleds.c:91:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/beagleplay/src/beagleplay_autoleds.c:95:1: error: Missing blank line before comment found
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/beagleplay/src/beagleplay_autoleds.c:95:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/beagleplay/src/beagleplay_autoleds.c:99:1: error: Missing blank line before comment found
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/beagleplay/src/beagleplay_autoleds.c:99:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/beagleplay/src/beagleplay_autoleds.c:103:1: error: Missing blank line before comment found
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/beagleplay/src/beagleplay_autoleds.c:103:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/beagleplay/src/beagleplay_autoleds.c:108:1: error: Missing blank line before comment found
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/beagleplay/src/beagleplay_autoleds.c:108:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/beagleplay/src/beagleplay_bringup.c:76:1: error: Too many blank lines
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_autoleds.c:91:1: error: Missing blank line before comment found
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_autoleds.c:91:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_autoleds.c:95:1: error: Missing blank line before comment found
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_autoleds.c:95:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_autoleds.c:99:1: error: Missing blank line before comment found
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_autoleds.c:99:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_autoleds.c:103:1: error: Missing blank line before comment found
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_autoleds.c:103:1: error: Missing blank line after comment
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_autoleds.c:108:1: error: Missing blank line before comment found
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_autoleds.c:108:1: error: Missing blank line after comment
Some checks failed. For contributing guidelines, see:
  https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md

AM62x enters NuttX through EL2 before dropping to EL1. Enable the
GICv3 system register interface for lower exception levels during the
EL2 handoff so EL1 can use the CPU interface without depending on
firmware state.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Adjust the generic 16550 driver for the AM62x console path. Preserve
the FIFO programming sequence needed by the TI UART, keep the bootloader
owned early console state when requested, and drain the transmit buffer
correctly when polling mode is enabled.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Add the AM62x architecture support needed to boot NuttX on TI K3
AM62x platforms. This includes the chip integration, memory map, IRQ
definitions, low-level console support, boot code, and the AM62x 16550
serial lower half.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Add initial board support for BeaglePlay and PocketBeagle2, including
defconfigs, linker scripts, board initialization, procfs bring-up, and
LED stubs. BeaglePlay provides the validated runtime target for this
bring-up series.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Document the AM62x platform and add board guides for BeaglePlay and
PocketBeagle2. The BeaglePlay guide includes the validated manual
U-Boot boot flow used for hardware testing.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
@PiyushPatle26 PiyushPatle26 force-pushed the am62x-beagleplay-bringup branch from d4dbf71 to 5e9c960 Compare May 20, 2026 02:33
Regenerate the BeaglePlay and PocketBeagle2 nsh and ostest defconfigs
with savedefconfig so the checked-in files match the CI refresh output.
This fixes the CI failure where refresh.sh rewrote the four AM62x
configs during the build.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
@PiyushPatle26 PiyushPatle26 force-pushed the am62x-beagleplay-bringup branch from fca7ac8 to cc74e93 Compare May 20, 2026 09:14
@lupyuen
Copy link
Copy Markdown
Member

lupyuen commented May 20, 2026

@nuttxpr test avaota-a1:nsh

@nuttxpr
Copy link
Copy Markdown

nuttxpr commented May 20, 2026

[Experimental Bot, please feedback here]

Build and Test Successful (avaota-a1:nsh)
https://gitlab.com/lupyuen/nuttx-build-log/-/snippets/5994003

$ git clone https://github.com/PiyushPatle26/nuttx nuttx --branch am62x-beagleplay-bringup
$ git clone https://github.com/apache/nuttx-apps apps --branch master
$ pushd nuttx
$ git reset --hard HEAD
HEAD is now at cc74e93d17 boards/arm64/am62x: normalize defconfigs
$ popd
$ pushd apps
$ git reset --hard HEAD
HEAD is now at 173e19cde apps/examples: Add path option to SPI Slave test
$ popd
NuttX Source: https://github.com/apache/nuttx/tree/cc74e93d17090703f842a839654807c2c6f089c9
NuttX Apps: https://github.com/apache/nuttx-apps/tree/173e19cde118546c5d3180e1a4b5c3c53a765142
$ cd nuttx
$ tools/configure.sh avaota-a1:nsh
$ make -j
$ make -j export
$ pushd ../apps
$ ./tools/mkimport.sh -z -x ../nuttx/nuttx-export-0.0.0.tar.gz
$ make -j import
$ popd
$ genromfs -f initrd -d ../apps/bin -V NuttXBootVol
$ head -c 65536 /dev/zero
$ cat nuttx.bin /tmp/nuttx.pad initrd
$ scp Image thinkcentre:/tmp/Image
$ ssh thinkcentre sudo /home/user/copy-image.sh
$ sd-mux-ctrl --device-serial=sd-wire_02-09 --ts
$ mkdir -p /tmp/sda1
$ mount /dev/sda1 /tmp/sda1
$ cp /tmp/Image /tmp/sda1/
$ rm /tmp/Image
$ umount /tmp/sda1
$ sd-mux-ctrl --device-serial=sd-wire_02-09 --dut
$ cd /home/luppy/nuttx-build-farm
$ ssh thinkcentre
nsh> uname -a
NuttX 0.0.0 cc74e93d17 May 20 2026 19:06:55 arm64 avaota-a1
nsh> ostest
arena        a000    26000
ordblks         2        4
mxordblk     6ff8    1aff8
uordblks     27d8     66f0
fordblks     7828    1f910
user_main: Exiting
ostest_main: Exiting with status 0
nsh> Now running https://github.com/lupyuen/nuttx-build-farm/blob/main/avaota-power.sh off
----- Power off Avaota-A1
[]

Copy link
Copy Markdown
Member

@lupyuen lupyuen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arm64 Changes tested OK with OSTest on Avaota-A1 Arm64 SBC (Allwinner A537) thanks :-)

Comment on lines +38 to +68
/****************************************************************************
* Name: board_app_initialize
*
* Description:
* Called indirectly through boardctl(BOARDIOC_INIT) from the NSH start-up
* code. This is the application-level initialisation hook — it runs in
* task context (not interrupt context) with the scheduler fully running.
*
* When CONFIG_BOARD_LATE_INITIALIZE is set, beagleplay_bringup() has
* already been called from board_late_initialize() so we return OK
* immediately. Otherwise we call it here.
*
* Input Parameters:
* arg - boardctl() argument (unused for BOARDIOC_INIT)
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure.
*
****************************************************************************/

int board_app_initialize(uintptr_t arg)
{
UNUSED(arg);

#ifndef CONFIG_BOARD_LATE_INITIALIZE
return beagleplay_bringup();
#else
return OK;
#endif
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface is deprecated; please test this on the latest main using board_late_initialize.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this deprecated interface. I switched the AM62x boards to use board_late_initialize() only and validated the updated branch on current main with local builds for beagleplay:{nsh,ostest} and pocketbeagle2:{nsh,ostest}. Will perform boot test and update the PR soon

break;

case LED_PANIC:
g_panic = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need global variables for this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it did not need to be global. I had originally introduced g_panic to preserve a panic/blink state across board_autoled_on() and board_autoled_off(), but in this stub implementation there was no actual GPIO toggle logic behind it, so the state was unnecessary. I removed it and simplified the LED hooks to stateless no-ops until real GPIO-backed LED support is added.

Comment on lines +124 to +126
if (g_panic)
{
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition does nothing.

Comment on lines +65 to +71
typedef enum
{
BOARD_LED_USR0 = 0,
BOARD_LED_USR1 = 1,
BOARD_LED_USR2 = 2,
BOARD_NLEDS,
} led_typedef_enum;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a typedef enum?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually no strong reason , we can use plain enum too

Comment on lines +124 to +127
if (g_panic)
{
}
break;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the template in Documentation/contributing/doc_templates/board.rst

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworked the page to follow the board documentation template more closely: features, buttons/LEDs, serial console, pin mapping, power, installation, build, flashing, and configurations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the template in Documentation/contributing/doc_templates/board.rst

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have done the same for pocket beagle 2 as well

return -EPERM;
}

/* Clear fifos */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it necessary to delete this? Could you explain what the issues were with the 16550 driver?

Copy link
Copy Markdown
Contributor Author

@PiyushPatle26 PiyushPatle26 May 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue was AM62x-specific bring-up rather than a generic 16550 functional bug. The AM62x UART required the FIFO setup to be programmed as separate writes, so the old standalone ‘Clear fifos’ comment no longer matched the actual sequence. I added a comment beside the new FIFO configuration block to explain why the setup is done that way.

@linguini1
Copy link
Copy Markdown
Contributor

Do you also have tests from the pocketbeagle you could attach?

@PiyushPatle26
Copy link
Copy Markdown
Contributor Author

Do you also have tests from the pocketbeagle you could attach?

Yeah will do it today and attach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm64 Issues related to ARM64 (64-bit) architecture Area: Build system Board: arm64 Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants