Skip to content

arch: Add support for RX GCC build #857

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

duynguyenxa
Copy link
Member

@duynguyenxa duynguyenxa commented Jan 24, 2025

Enable build for rx-zephyr-elf in Zephyr SDK to support the RX architecture port on ZephyrRTOS

@duynguyenxa duynguyenxa force-pushed the add_support_rx_gcc_build branch 2 times, most recently from d4ae9b0 to dcac855 Compare January 24, 2025 04:19
@duynguyenxa
Copy link
Member Author

hi @stephanosio , on this PR, I added build configuration to support GCC rx-zephyr-elf build target, can you help to review.
I've updated the the ci.yml to add the build on CI but it doesn't added in the CI run, is there any more step I need to do to enable the CI build for RX?

@KhiemNguyenT
Copy link

@kartben may you help to assign the suitable person as assignee ?

@keith-packard
Copy link
Collaborator

I'd be happy to help get the picolibc changes merged upstream and then into the Zephyr picolibc fork. For that, I would prefer to have the picolibc CI tests work on this target. That requires crt0 and semihost support sufficient to run tests under qemu.

@keith-packard
Copy link
Collaborator

keith-packard commented Feb 13, 2025

ok, I spent probably too much time having fun with this tonight.

I've got a toolchain building, binutils, gcc, qemu and picolibc and lots of picolibc tests are passing.

Floating point is a problem area still, which is not unexpected given the non-standard floating point support in this chip. The first thing that needs to happen for that to be usable is to tell GCC about the hardware limitations and expose them in the relevant pre-defined preprocessor symbols would at least tell picolibc to skip tests expecting conformance.

Something in the string instruction handling is quite broken; I don't know if it's the compiler or qemu, but I've had to skip these instructions in testing.

I have no idea what 'PID' support means; I assume it relates to position-independence? Is there a description of the RX ABI we can use to help sort this out?

gcc: (based off 14.2.0) https://github.com/keith-packard/gcc/tree/add_support_rx_gcc_build_zephyr
qemu: (based off 9.2.0) https://github.com/keith-packard/qemu/tree/rx-fixes
picolibc: (based off head) https://github.com/picolibc/picolibc/tree/add_support_rx_gcc_build_zephyr

The GCC patches were just rebased, so no real changes there. I was hoping the string instructions would work better, but alas no.

QEMU has a couple of small changes:

  1. Allow execution without a BIOS or kernel. I'm using --device loader,file= as that bypasses all of the rx-specific bits
  2. Fix the exception base address. For some reason QEMU was using 0xffffffc0 instead of 0xffffff80.
  3. Reset the CPUs each time QEMU resets the system.
  4. Load the reset vector from 0xfffffffc at each reset.

Once we're reasonably happy with things, I'll plan on upstreaming the QEMU and GCC patches.

Oh, please plan on submitting picolibc PRs to the picolibc upstream repo instead of the Zephyr-fork.

@duynguyenxa duynguyenxa force-pushed the add_support_rx_gcc_build branch 2 times, most recently from 7236933 to 7b966fd Compare February 18, 2025 05:12
@keith-packard
Copy link
Collaborator

This doesn't appear to include the RX fixes from picolibc? Or am I just looking in the wrong place?

@duynguyenxa duynguyenxa force-pushed the add_support_rx_gcc_build branch 2 times, most recently from de207c5 to 56dc716 Compare February 18, 2025 06:55
@duynguyenxa
Copy link
Member Author

@keith-packard , sorry, maybe I misunderstood you, I thought we are going to update the picolibC after the 1.8.9 get merged to the sdk-ng

@duynguyenxa duynguyenxa force-pushed the add_support_rx_gcc_build branch from 56dc716 to ae34c24 Compare February 18, 2025 11:11
@duynguyenxa
Copy link
Member Author

hello @stephanosio , @tejlmand , Can you help me on the CI job for RX target on this PR, I've added the rx-zephyr-elf target build on this but it seem that the github workflow does not run the new update.

@duynguyenxa duynguyenxa force-pushed the add_support_rx_gcc_build branch from b9b9a3a to b1afaa2 Compare February 24, 2025 08:57
.gitmodules Outdated
[submodule "gdb"]
path = gdb
url = https://github.com/zephyrproject-rtos/binutils-gdb.git
[submodule "picolibc"]
path = picolibc
url = https://github.com/zephyrproject-rtos/picolibc.git
url = https://github.com/renesas/picolibc.git
Copy link
Collaborator

Choose a reason for hiding this comment

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

What changes do you need that aren't present in picolibc 1.8.9? You should be able to use the picolibc 1.8.9 bits in the zephyr repo already.

Copy link
Member Author

Choose a reason for hiding this comment

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

@keith-packard , the RX changes seem hasn't been included in the 1.8.9 in the Zephyr, or do I need to do something?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, I hadn't posted a PR for 1.8.9. Oops. It's now #872.

Copy link
Collaborator

Choose a reason for hiding this comment

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

right, the key RX fixes landed just after 1.8.9. I can do a 1.8.10 release to include that; that would do a bunch of testing beyond the usual CI so it might be better than just pulling Zephyr to some random commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hello @keith-packard , is it mean that you will pull in the RX support into main branch of Zephyr fork picolibC?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes. I'll plan on doing a picolibc release and then pulling that over to the SDK and Zephyr main. Do you have any particular schedule requirements beyond hitting the next Zephyr release target?

Copy link
Member

Choose a reason for hiding this comment

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

@keith-packard when will you be able to release a 1.8.10? Planning to do a 0.17.1 soon, ideally with RX and openrisc, new picolibc and the new host tools with newer poky.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I'll plan on doing a picolibc release and then pulling that over to the SDK and Zephyr main. Do you have any particular schedule requirements beyond hitting the next Zephyr release target?

@keith-packard , no, my main target is trying to get the RX architecture support available on Zephyr 4.2

Copy link
Collaborator

Choose a reason for hiding this comment

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

@keith-packard when will you be able to release a 1.8.10? Planning to do a 0.17.1 soon, ideally with RX and openrisc, new picolibc and the new host tools with newer poky.

awesome. I'm happy to do a release to suit your schedule; I'm currently merging in some header cleanups and testing those against Zephyr (and other picolibc consumers) will improve that a bunch. I'll get a topic branch started in the SDK before I do the 1.8.10 release so I can make sure 1.8.10 actually does what we want.

@duynguyenxa duynguyenxa force-pushed the add_support_rx_gcc_build branch 2 times, most recently from 9ab03ec to bc6a921 Compare April 10, 2025 07:29
@keith-packard
Copy link
Collaborator

We need to use a released version of picolibc with RX support, not an intermediate tag -- released versions get a lot more testing and validation than I can do in regular CI. That means waiting for picolibc 1.8.10.

Picolibc 1.8.10 release is blocked on zephyrproject-rtos/zephyr#87657 as I want to land the -Os/-O2 multilib bits in the SDK with that. If we get really stuck, we could skip that and just finish up the 1.8.10 release and merge that so that RX support can be included.

This commit only add minimal require part to enable Renesas
RX architecture gcc toolchain build on Zephyr SDK

Signed-off-by: Duy Nguyen <[email protected]>
@duynguyenxa duynguyenxa force-pushed the add_support_rx_gcc_build branch from bc6a921 to 7359bf6 Compare April 24, 2025 02:15
@keith-packard
Copy link
Collaborator

All of these changes should now be included in the picolibc-1.8.10 PR; please verify that and close this PR when you're happy.

@duynguyenxa
Copy link
Member Author

duynguyenxa commented Apr 25, 2025

All of these changes should now be included in the picolibc-1.8.10 PR; please verify that and close this PR when you're happy.

hello @keith-packard , Thank you very much for helping us, I've checkout to the topic-picolibc-1.8.10 but cannot get the build to be success on my local, I see that the CI run on that branch pass, do I need to update something in the build system for it to pass
below is the log.

[DEBUG]    Entering '/home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/build/build-picolibc-build-x86_64-build_pc-linux-gnu'
[EXTRA]    Configuring Picolibc library
[DEBUG]    ==> Executing:  'meson' '--cross-file' 'picolibc-cross.txt' '--prefix=/home/duyhoangnguyen/build-workspace/output/rx-zephyr-elf' '-Dincludedir=picolibc/include' '-Dlibdir=picolibc/rx-zephyr-elf/lib' '-Dspecsdir=/home/duyhoangnguyen/build-workspace/output/rx-zephyr-elf/rx-zephyr-elf/lib' '/home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/src/picolibc' '-Dio-c99-formats=true' '-Dio-long-long=false' '-Dnewlib-register-fini=false' '-Dnewlib-nano-malloc=true' '-Dnewlib-atexit-dynamic-alloc=false' '-Dnewlib-global-atexit=true' '-Dlite-exit=true' '-Dnewlib-multithread=true' '-Dnewlib-retargetable-locking=true' '-Dthread-local-storage=auto' '-Derrno-function=zephyr' '-Dsysroot-install=true' '-Dsysroot-install-skip-checks=true' '-Dassert-verbose=false'
[CFG  ]    DEPRECATION: c_args in the [properties] section of the machine file is deprecated, use the [built-in options] section.
[CFG  ]    The Meson build system
[CFG  ]    Version: 1.6.0
[CFG  ]    Source dir: /home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/src/picolibc
[CFG  ]    Build dir: /home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/build/build-picolibc-build-x86_64-build_pc-linux-gnu
[CFG  ]    Build type: cross build
[CFG  ]    
[CFG  ]    ../../src/picolibc/meson.build:35:0: ERROR: Unknown options: "lite-exit, newlib-multithread, newlib-retargetable-locking"

@keith-packard
Copy link
Collaborator

All of these changes should now be included in the picolibc-1.8.10 PR; please verify that and close this PR when you're happy.

hello @keith-packard , Thank you very much for helping us, I've checkout to the topic-picolibc-1.8.10 but cannot get the build to be success on my local, I see that the CI run on that branch pass, do I need to update something in the build system for it to pass below is the log.

[DEBUG]    Entering '/home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/build/build-picolibc-build-x86_64-build_pc-linux-gnu'
[EXTRA]    Configuring Picolibc library
[DEBUG]    ==> Executing:  'meson' '--cross-file' 'picolibc-cross.txt' '--prefix=/home/duyhoangnguyen/build-workspace/output/rx-zephyr-elf' '-Dincludedir=picolibc/include' '-Dlibdir=picolibc/rx-zephyr-elf/lib' '-Dspecsdir=/home/duyhoangnguyen/build-workspace/output/rx-zephyr-elf/rx-zephyr-elf/lib' '/home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/src/picolibc' '-Dio-c99-formats=true' '-Dio-long-long=false' '-Dnewlib-register-fini=false' '-Dnewlib-nano-malloc=true' '-Dnewlib-atexit-dynamic-alloc=false' '-Dnewlib-global-atexit=true' '-Dlite-exit=true' '-Dnewlib-multithread=true' '-Dnewlib-retargetable-locking=true' '-Dthread-local-storage=auto' '-Derrno-function=zephyr' '-Dsysroot-install=true' '-Dsysroot-install-skip-checks=true' '-Dassert-verbose=false'
[CFG  ]    DEPRECATION: c_args in the [properties] section of the machine file is deprecated, use the [built-in options] section.
[CFG  ]    The Meson build system
[CFG  ]    Version: 1.6.0
[CFG  ]    Source dir: /home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/src/picolibc
[CFG  ]    Build dir: /home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/build/build-picolibc-build-x86_64-build_pc-linux-gnu
[CFG  ]    Build type: cross build
[CFG  ]    
[CFG  ]    ../../src/picolibc/meson.build:35:0: ERROR: Unknown options: "lite-exit, newlib-multithread, newlib-retargetable-locking"

You need the crosstool-ng patches for picolibc-1.8.10 which are in the topic-picolibc-1.8.10 PR for sdk-ng.

@keith-packard
Copy link
Collaborator

All of these changes should now be included in the picolibc-1.8.10 PR; please verify that and close this PR when you're happy.

hello @keith-packard , Thank you very much for helping us, I've checkout to the topic-picolibc-1.8.10 but cannot get the build to be success on my local, I see that the CI run on that branch pass, do I need to update something in the build system for it to pass below is the log.

[DEBUG]    Entering '/home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/build/build-picolibc-build-x86_64-build_pc-linux-gnu'
[EXTRA]    Configuring Picolibc library
[DEBUG]    ==> Executing:  'meson' '--cross-file' 'picolibc-cross.txt' '--prefix=/home/duyhoangnguyen/build-workspace/output/rx-zephyr-elf' '-Dincludedir=picolibc/include' '-Dlibdir=picolibc/rx-zephyr-elf/lib' '-Dspecsdir=/home/duyhoangnguyen/build-workspace/output/rx-zephyr-elf/rx-zephyr-elf/lib' '/home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/src/picolibc' '-Dio-c99-formats=true' '-Dio-long-long=false' '-Dnewlib-register-fini=false' '-Dnewlib-nano-malloc=true' '-Dnewlib-atexit-dynamic-alloc=false' '-Dnewlib-global-atexit=true' '-Dlite-exit=true' '-Dnewlib-multithread=true' '-Dnewlib-retargetable-locking=true' '-Dthread-local-storage=auto' '-Derrno-function=zephyr' '-Dsysroot-install=true' '-Dsysroot-install-skip-checks=true' '-Dassert-verbose=false'
[CFG  ]    DEPRECATION: c_args in the [properties] section of the machine file is deprecated, use the [built-in options] section.
[CFG  ]    The Meson build system
[CFG  ]    Version: 1.6.0
[CFG  ]    Source dir: /home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/src/picolibc
[CFG  ]    Build dir: /home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/build/build-picolibc-build-x86_64-build_pc-linux-gnu
[CFG  ]    Build type: cross build
[CFG  ]    
[CFG  ]    ../../src/picolibc/meson.build:35:0: ERROR: Unknown options: "lite-exit, newlib-multithread, newlib-retargetable-locking"

You need the crosstool-ng patches for picolibc-1.8.10 which are in the topic-picolibc-1.8.10 PR for sdk-ng.

In fact, the topic-picolibc-1.8.10 branch should have everything the SDK needs to build the toolchain, and the only reason the build failed is because the tests, using Zephyr without RX patches, all failed.

@duynguyenxa
Copy link
Member Author

All of these changes should now be included in the picolibc-1.8.10 PR; please verify that and close this PR when you're happy.

hello @keith-packard , Thank you very much for helping us, I've checkout to the topic-picolibc-1.8.10 but cannot get the build to be success on my local, I see that the CI run on that branch pass, do I need to update something in the build system for it to pass below is the log.

[DEBUG]    Entering '/home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/build/build-picolibc-build-x86_64-build_pc-linux-gnu'
[EXTRA]    Configuring Picolibc library
[DEBUG]    ==> Executing:  'meson' '--cross-file' 'picolibc-cross.txt' '--prefix=/home/duyhoangnguyen/build-workspace/output/rx-zephyr-elf' '-Dincludedir=picolibc/include' '-Dlibdir=picolibc/rx-zephyr-elf/lib' '-Dspecsdir=/home/duyhoangnguyen/build-workspace/output/rx-zephyr-elf/rx-zephyr-elf/lib' '/home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/src/picolibc' '-Dio-c99-formats=true' '-Dio-long-long=false' '-Dnewlib-register-fini=false' '-Dnewlib-nano-malloc=true' '-Dnewlib-atexit-dynamic-alloc=false' '-Dnewlib-global-atexit=true' '-Dlite-exit=true' '-Dnewlib-multithread=true' '-Dnewlib-retargetable-locking=true' '-Dthread-local-storage=auto' '-Derrno-function=zephyr' '-Dsysroot-install=true' '-Dsysroot-install-skip-checks=true' '-Dassert-verbose=false'
[CFG  ]    DEPRECATION: c_args in the [properties] section of the machine file is deprecated, use the [built-in options] section.
[CFG  ]    The Meson build system
[CFG  ]    Version: 1.6.0
[CFG  ]    Source dir: /home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/src/picolibc
[CFG  ]    Build dir: /home/duyhoangnguyen/build-workspace/build-rx-zephyr-elf/.build/rx-zephyr-elf/build/build-picolibc-build-x86_64-build_pc-linux-gnu
[CFG  ]    Build type: cross build
[CFG  ]    
[CFG  ]    ../../src/picolibc/meson.build:35:0: ERROR: Unknown options: "lite-exit, newlib-multithread, newlib-retargetable-locking"

You need the crosstool-ng patches for picolibc-1.8.10 which are in the topic-picolibc-1.8.10 PR for sdk-ng.

In fact, the topic-picolibc-1.8.10 branch should have everything the SDK needs to build the toolchain, and the only reason the build failed is because the tests, using Zephyr without RX patches, all failed.

@keith-packard , Sorry it's my mistake, I used the sdk-ng topic-picolibc-1.8.10 but the crosstool-ng and build output folder was not clean properly.
I successfully built the SDK. thank you for your help.
When will you plan to create the PR for picolibc-1.8.10, I checked in the sdk-ng pull requests but it seem that you haven't create the PR yet.

@keith-packard
Copy link
Collaborator

When will you plan to create the PR for picolibc-1.8.10, I checked in the sdk-ng pull requests but it seem that you haven't create the PR yet.

topic-picolibc-1.8.10 is where that work is happening -- it's on a topic- branch because that makes CI build all of the toolchains instead of just the linux-x86 ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants