Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/sam4s: add initial support with SAM4S-XPRO board #21201

Merged
merged 4 commits into from
Feb 17, 2025

Conversation

dylad
Copy link
Member

@dylad dylad commented Feb 8, 2025

Contribution description

This PR adds initial support for SAM4s MCUs from Microchip (formerly Atmel) and its sam4s-xpro board.
There are a bit old already, but still produced by Microchip and their headers files are already in-tree.

This family is pretty close to SAM3 (which we already support through arduino-due) except that this is a Cortex-M4 which runs a little faster.

Since peripherals are the same, I've moved GPIOs, Timer and UART driver to cpu/sam_common.
I plan to move the remaining drivers (if relevant) in followup PRs.

Testing procedure

Get a sam4s-xpro and run any tests involving UART/Timers/GPIOs.

For the record here is the output of tests/sys/shell running on sam4s-xpro:

make BOARD=sam4s-xpro -C tests/sys/shell flash term                          INT ✘  1m 4s 
make: Entering directory '/home/dylan/work/RIOT/tests/sys/shell'
Building application "tests_shell" for "sam4s-xpro" with CPU "sam4s".

"make" -C /home/dylan/work/RIOT/pkg/cmsis/ 
"make" -C /home/dylan/work/RIOT/boards/common/init
"make" -C /home/dylan/work/RIOT/boards/sam4s-xpro
"make" -C /home/dylan/work/RIOT/core
"make" -C /home/dylan/work/RIOT/core/lib
"make" -C /home/dylan/work/RIOT/cpu/sam4s
"make" -C /home/dylan/work/RIOT/cpu/cortexm_common
"make" -C /home/dylan/work/RIOT/cpu/cortexm_common/periph
"make" -C /home/dylan/work/RIOT/cpu/sam4s/periph
"make" -C /home/dylan/work/RIOT/cpu/sam_common
"make" -C /home/dylan/work/RIOT/cpu/sam_common/periph
"make" -C /home/dylan/work/RIOT/drivers
"make" -C /home/dylan/work/RIOT/drivers/periph_common
"make" -C /home/dylan/work/RIOT/sys
"make" -C /home/dylan/work/RIOT/sys/app_metadata
"make" -C /home/dylan/work/RIOT/sys/auto_init
"make" -C /home/dylan/work/RIOT/sys/div
"make" -C /home/dylan/work/RIOT/sys/frac
"make" -C /home/dylan/work/RIOT/sys/isrpipe
"make" -C /home/dylan/work/RIOT/sys/libc
"make" -C /home/dylan/work/RIOT/sys/malloc_thread_safe
"make" -C /home/dylan/work/RIOT/sys/newlib_syscalls_default
"make" -C /home/dylan/work/RIOT/sys/preprocessor
"make" -C /home/dylan/work/RIOT/sys/ps
"make" -C /home/dylan/work/RIOT/sys/shell
"make" -C /home/dylan/work/RIOT/sys/shell/cmds
"make" -C /home/dylan/work/RIOT/sys/stdio
"make" -C /home/dylan/work/RIOT/sys/stdio_uart
"make" -C /home/dylan/work/RIOT/sys/test_utils/interactive_sync
"make" -C /home/dylan/work/RIOT/sys/test_utils/print_stack_usage
"make" -C /home/dylan/work/RIOT/sys/tsrb
"make" -C /home/dylan/work/RIOT/sys/ztimer
  text    data     bss     dec     hex filename
 13008     160    2820   15988    3e74 /home/dylan/work/RIOT/tests/sys/shell/bin/sam4s-xpro/tests_shell.elf
/home/dylan/work/RIOT/dist/tools/openocd/openocd.sh flash /home/dylan/work/RIOT/tests/sys/shell/bin/sam4s-xpro/tests_shell.elf
### Flashing Target ###
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
       http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : CMSIS-DAP: SWD supported
Info : CMSIS-DAP: FW Version = 02.01.0157
Info : CMSIS-DAP: Serial# = ATML1803040200000875
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 500 kHz
Info : SWD DPIDR 0x2ba01477
Info : [ATSAM4SD32C.cpu] Cortex-M4 r0p1 processor detected
Info : [ATSAM4SD32C.cpu] target has 6 breakpoints, 4 watchpoints
Info : starting gdb server for ATSAM4SD32C.cpu on 0
Info : Listening on port 46877 for gdb connections
   TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
0* ATSAM4SD32C.cpu    cortex_m   little ATSAM4SD32C.cpu    running

[ATSAM4SD32C.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00400784 msp: 0x20000200
Info : sam4 does not auto-erase while programming (Erasing relevant sectors)
Info : sam4 First: 0x00000000 Last: 0x00000001
Info : Erasing sector: 0x00000000
Info : Erasing sector: 0x00000001
auto erase enabled
wrote 16384 bytes from file /home/dylan/work/RIOT/tests/sys/shell/bin/sam4s-xpro/tests_shell.elf in 1.024621s (15.616 KiB/s)

verified 13168 bytes in 0.613142s (20.973 KiB/s)

shutdown command invoked
Done flashing
/home/dylan/work/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyACM0" -b "115200" -ln "/tmp/pyterm-dylan" -rn "2025-02-08_13.46.12-tests_shell-sam4s-xpro"  
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2025-02-08 13:46:12,211 # Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.
2025-02-08 13:46:13,730 # main(): This is RIOT! (Version: 2025.04-devel-89-g2f0cb-pr/cpu/sam4s/add_support)
2025-02-08 13:46:13,731 # test_shell.
> ps
2025-02-08 13:46:15,345 # ps
2025-02-08 13:46:15,347 #       pid | state    Q | pri 
2025-02-08 13:46:15,349 #         1 | running  Q |   7
> help
2025-02-08 13:46:17,646 # help
2025-02-08 13:46:17,649 # Command              Description
2025-02-08 13:46:17,652 # ---------------------------------------
2025-02-08 13:46:17,656 # bufsize              Get the shell's buffer size
2025-02-08 13:46:17,659 # start_test           starts a test
2025-02-08 13:46:17,662 # end_test             ends a test
2025-02-08 13:46:17,666 # echo                 prints the input command
2025-02-08 13:46:17,670 # empty                print nothing on command
2025-02-08 13:46:17,674 # periodic             periodically print command
2025-02-08 13:46:17,678 # xfa_test1            xfa test command 1
2025-02-08 13:46:17,682 # xfa_test2            xfa test command 2
2025-02-08 13:46:17,686 # app_metadata         Returns application metadata
2025-02-08 13:46:17,690 # pm                   interact with layered PM subsystem
2025-02-08 13:46:17,696 # ps                   Prints information about running threads.
2025-02-08 13:46:17,700 # version              Prints current RIOT_VERSION
2025-02-08 13:46:17,704 # reboot               Reboot the node
> periodic
2025-02-08 13:46:20,555 # periodic
> 2025-02-08 13:46:21,055 # test
2025-02-08 13:46:21,556 # test
2025-02-08 13:46:22,056 # test
2025-02-08 13:46:22,556 # test
2025-02-08 13:46:23,056 # test

Issues/PRs references

None.

@github-actions github-actions bot added Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: doc Area: Documentation Area: build system Area: Build system Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports Area: Kconfig Area: Kconfig integration labels Feb 8, 2025
Copy link
Contributor

@crasbe crasbe left a comment

Choose a reason for hiding this comment

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

I don't have the hardware to test this, but just two things I noticed while glancing over this.

@dylad dylad mentioned this pull request Feb 8, 2025
9 tasks
@mguetschow mguetschow added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Feb 10, 2025
@riot-ci
Copy link

riot-ci commented Feb 10, 2025

Murdock results

✔️ PASSED

363fb75 boards/sam4s-xpro: introduce initial board support

Success Failures Total Runtime
10271 0 10271 09m:03s

Artifacts

@dylad
Copy link
Member Author

dylad commented Feb 10, 2025

static-tests are happy !

Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

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

Looks good to me, feel free to squash!

Signed-off-by: dylad <dylan.laduranty@mesotic.com>
Signed-off-by: dylad <dylan.laduranty@mesotic.com>
@dylad dylad force-pushed the pr/cpu/sam4s/add_support branch from ba6bc9a to 9e920b2 Compare February 17, 2025 09:05
@dylad
Copy link
Member Author

dylad commented Feb 17, 2025

I've addressed @benpicco's comments and squashed.

@benpicco benpicco added this pull request to the merge queue Feb 17, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 17, 2025
@dylad
Copy link
Member Author

dylad commented Feb 17, 2025

Ah Murdock catches something.
I'll fix it later today.

This commit allows to share GPIO, Timers and UARTs driver across SAM3/SAM4s MCUs as they relies on the same IPs

Signed-off-by: dylad <dylan.laduranty@mesotic.com>
Signed-off-by: dylad <dylan.laduranty@mesotic.com>
@dylad dylad force-pushed the pr/cpu/sam4s/add_support branch from 9e920b2 to 363fb75 Compare February 17, 2025 15:29
@dylad dylad added this pull request to the merge queue Feb 17, 2025
Merged via the queue into RIOT-OS:master with commit cdceb08 Feb 17, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: build system Area: Build system Area: cpu Area: CPU/MCU ports Area: doc Area: Documentation Area: Kconfig Area: Kconfig integration CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants