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

at32uc3a0: Initial work for SimpleMachines' Mizar32-A #11709

Merged
merged 1 commit into from
Jul 15, 2024

Conversation

ramangopalan
Copy link
Contributor

Dear NuttX community, Greetings!

Summary

This is an initial working commit for the Mizar32-A platform. It is
powered by the AT32UC3A0512 microcontroller. I started with the same
Microchip Studio project I used to verify avr32dev1 (NuttX 6.0) to
also fix the build and initial functionality for Mizar32-A.

For Mizar32, I had to fix the NuttX low level abstraction layer for
the clock, the PLL0, the USART pins' alternate functions and finally,
the USART clock source.

Impact

This PR won't affect the functionality of any other target. It won't
also affect the build OR code for the existing avr32dev1 target.

Testing

I checked the NuttX build on GNU/Linux. I used dfu-programmer to
verify `nsh' on Mizar32-A. It works great! I am attaching a snip from
my hack sessions.

image

Please let me know if the PR is alright OR if there's something I have
missed. Many thanks. Have a great weekend!

arch/avr/src/at32uc3/at32uc3_gpio.c Outdated Show resolved Hide resolved
boards/Kconfig Outdated Show resolved Hide resolved
@xiaoxiang781216
Copy link
Contributor

xiaoxiang781216 commented Feb 18, 2024

@ramangopalan Please fix the following warning:

Error: /home/runner/work/nuttx/nuttx/nuttx/arch/avr/src/at32uc3/at32uc3_lowconsole.c:358:2: error: C comment opening on separate line
Error: /home/runner/work/nuttx/nuttx/nuttx/arch/avr/src/at32uc3/at32uc3_lowconsole.c:360:1: error: Missing blank line after comment
Warning: /home/runner/work/nuttx/nuttx/nuttx/arch/avr/src/at32uc3/chip.h:213:1: warning: #include outside of 'Included Files' section
Error: /home/runner/work/nuttx/nuttx/nuttx/boards/avr/at32uc3/mizar32a/src/avr32_buttons.c:2:1: error: Relative file path does not match actual file

to fix the ci error:

sh: 1: avr32-gcc: not found
sh: 1: avr32-gcc: not found
ERROR: avr32-gcc failed: 127
ERROR: avr32-gcc failed: 127

avr32-gcc need to be installed, please reference how avr-gcc install in:
https://github.com/apache/nuttx/blob/master/tools/ci/cibuild.sh#L125
https://github.com/apache/nuttx/blob/master/tools/ci/docker/linux/Dockerfile#L277

arch/avr/src/at32uc3/at32uc3_gpio.c Outdated Show resolved Hide resolved
arch/avr/src/at32uc3/at32uc3_lowconsole.c Outdated Show resolved Hide resolved
@ramangopalan
Copy link
Contributor Author

Dear @xiaoxiang781216, Dear @acassis, Greetings!

Many thanks for your suggestions. I have fixed them except the ones
pertaining to CI. I read the Dockerfile. It is easy to understand but I
don't have much experience with it.

Is there a way I can test the Dockerfile changes for avr32-gcc in a
sandbox before I squash my final commit? Can you please give me a hint
on this one? Can you also please check if the other changes are OK?

@xiaoxiang781216
Copy link
Contributor

xiaoxiang781216 commented Feb 18, 2024

Dear @xiaoxiang781216, Dear @acassis, Greetings!

Many thanks for your suggestions. I have fixed them except the ones pertaining to CI. I read the Dockerfile. It is easy to understand but I don't have much experience with it.

Is there a way I can test the Dockerfile changes for avr32-gcc in a sandbox before I squash my final commit? Can you please give me a hint on this one?

You can download the image from https://github.com/apache/nuttx/pkgs/container/nuttx%2Fapache-nuttx-ci-linux, and try various docker commands.

Can you also please check if the other changes are OK?

The change looks good, please squash them. But please fix the remain warning before update the pr:

Error: /home/runner/work/nuttx/nuttx/nuttx/arch/avr/src/at32uc3/at32uc3_lowconsole.c:358:1: error: Missing blank line after comment

@ramangopalan
Copy link
Contributor Author

Dear @pkarashchenko,

@ramangopalan where I can find avr32-gcc published?

The 32-bit variant is at 1 and the 64-bit at 2. I have used both
of them. Currently, I use 1 to compile NuttX for both the avr32dev1
and Mizar32-A targets.

@ramangopalan
Copy link
Contributor Author

Dear All,

I just implemented this but haven't tested it yet. Do you think this
will work?

diff --git a/tools/ci/cibuild.sh b/tools/ci/cibuild.sh
index 20c2858e..317b4211 100755
--- a/tools/ci/cibuild.sh
+++ b/tools/ci/cibuild.sh
@@ -138,6 +138,20 @@ function avr-gcc-toolchain {
   command avr-gcc --version
 }
 
+function avr32-gcc-toolchain {
+  if [ ! -d "${tools}/avr32-gnu-toolchain-linux_x86" ]; then
+    cd "${tools}"
+    git clone https://github.com/ramangopalan/avr32-gnu-toolchain-linux_x86
+  fi
+
+  case ${os} in
+    Linux)
+      add_path "${tools}"/avr32-gnu-toolchain-linux_x86/bin
+      command avr32-gcc --version
+      ;;
+  esac
+}
+

I still think I am missing an entry within linux/Dockerfile. I don't
think avr32-gcc can be obtained with apt-get (like avr-gcc). So,
perhaps something like this?

diff --git a/tools/ci/docker/linux/Dockerfile b/tools/ci/docker/linux/Dockerfile
index c1a3ff85..ec35132e 100644
--- a/tools/ci/docker/linux/Dockerfile
+++ b/tools/ci/docker/linux/Dockerfile
@@ -381,6 +381,10 @@ ENV PATH="/tools/gcc-arm-none-eabi/bin:$PATH"
 COPY --from=nuttx-toolchain-arm64 /tools/gcc-aarch64-none-elf/ gcc-aarch64-none-elf/
 ENV PATH="/tools/gcc-aarch64-none-elf/bin:$PATH"
 
+# AVR32 toolchain
+COPY --from=nuttx-toolchain-avr32 /tools/avr32-gnu-toolchain-linux_x86/bin/ avr32-gnu-toolchain-linux_x86/bin/
+ENV PATH="/tools/avr32-gnu-toolchain-linux_x86/bin:$PATH"
+

Please note: I haven't tested it. But can someone please help test
OR correct it? Many thanks.

@ramangopalan
Copy link
Contributor Author

Dear NuttX Community, Greetings!

So sorry about the delay in my response. I have squashed the review
commits. Can you please check if these changes are OK? Please let me
know if there's anything else I can help with.

@xiaoxiang781216
Copy link
Contributor

Dear All,

I just implemented this but haven't tested it yet. Do you think this will work?

diff --git a/tools/ci/cibuild.sh b/tools/ci/cibuild.sh
index 20c2858e..317b4211 100755
--- a/tools/ci/cibuild.sh
+++ b/tools/ci/cibuild.sh
@@ -138,6 +138,20 @@ function avr-gcc-toolchain {
   command avr-gcc --version
 }
 
+function avr32-gcc-toolchain {
+  if [ ! -d "${tools}/avr32-gnu-toolchain-linux_x86" ]; then
+    cd "${tools}"
+    git clone https://github.com/ramangopalan/avr32-gnu-toolchain-linux_x86
+  fi
+
+  case ${os} in
+    Linux)
+      add_path "${tools}"/avr32-gnu-toolchain-linux_x86/bin
+      command avr32-gcc --version
+      ;;
+  esac
+}
+

LGTM, let ci do the final check.

I still think I am missing an entry within linux/Dockerfile. I don't think avr32-gcc can be obtained with apt-get (like avr-gcc). So, perhaps something like this?

diff --git a/tools/ci/docker/linux/Dockerfile b/tools/ci/docker/linux/Dockerfile
index c1a3ff85..ec35132e 100644
--- a/tools/ci/docker/linux/Dockerfile
+++ b/tools/ci/docker/linux/Dockerfile
@@ -381,6 +381,10 @@ ENV PATH="/tools/gcc-arm-none-eabi/bin:$PATH"
 COPY --from=nuttx-toolchain-arm64 /tools/gcc-aarch64-none-elf/ gcc-aarch64-none-elf/
 ENV PATH="/tools/gcc-aarch64-none-elf/bin:$PATH"
 
+# AVR32 toolchain
+COPY --from=nuttx-toolchain-avr32 /tools/avr32-gnu-toolchain-linux_x86/bin/ avr32-gnu-toolchain-linux_x86/bin/
+ENV PATH="/tools/avr32-gnu-toolchain-linux_x86/bin:$PATH"
+

You can try the installed tool locally with the follow command:

https://github.com/apache/nuttx/blob/master/tools/ci/docker/linux/Dockerfile#L270-L277

Please note: I haven't tested it. But can someone please help test OR correct it? Many thanks.

You need split cibuild.sh/Dockerfile change into new patch. After it get merged, ci can verify the result with this patch.

@ramangopalan
Copy link
Contributor Author

Dear @xiaoxiang781216, Dear @acassis,

Greetings! I didn't have a chance to visit the NuttX code OR rebase
it for a while. I revisited the files pertaining to AVR32 today. I
noticed a couple of file changes within tools/ci.

You need split cibuild.sh/Dockerfile change into new patch. After it
get merged, ci can verify the result with this patch.

I have just made an initial commit with AVR32 specific changes within
Dockerfile and ubuntu.sh. I just hope the CI verifies it without much
trouble.

I could be wrong; I didn't verify these changes locally. If it goes
through, I can also touch tools/ci/platforms/linux.sh to have AVR32's
recipe there. If there's a problem, I thought I can squash the fix.

Would this be OK? Please let me know if I got something wrong. Many
thanks. Jolly good weekend.

@ramangopalan
Copy link
Contributor Author

I tried pushing another commit moments ago but this problem persists:

Error: buildx failed with: ERROR: failed to solve:
nuttx-toolchain-avr32: failed to resolve source metadata for
docker.io/library/nuttx-toolchain-avr32:latest: pull access denied,
repository does not exist or may require authorization: server
message: insufficient_scope: authorization failed

Can you please give me a hint on this one? I am unable to see the full
CI logs of what is happening after git clone for AVR32 from my
repository. OR perhaps I am missing a setting on Github?

@ramangopalan
Copy link
Contributor Author

Am I missing a similar step for AVR32 within Dockerfile? I am unable
to wrap my head around this part.

# Download the latest ARM GCC toolchain prebuilt by ARM
RUN mkdir gcc-arm-none-eabi && \
  curl -s -L  "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.Rel1/binrel/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi.tar.xz" \
  | tar -C gcc-arm-none-eabi --strip-components 1 -xJ

May I ask: A similar recipe exists within ubuntu.sh. i.e. to fetch a
toolchain using Git OR curl. How is that different from what is
happening in this file? I am unable to connect the dots. Can you please
give me your thoughts?

@acassis
Copy link
Contributor

acassis commented May 5, 2024

Am I missing a similar step for AVR32 within Dockerfile? I am unable to wrap my head around this part.

# Download the latest ARM GCC toolchain prebuilt by ARM
RUN mkdir gcc-arm-none-eabi && \
  curl -s -L  "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.Rel1/binrel/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi.tar.xz" \
  | tar -C gcc-arm-none-eabi --strip-components 1 -xJ

May I ask: A similar recipe exists within ubuntu.sh. i.e. to fetch a toolchain using Git OR curl. How is that different from what is happening in this file? I am unable to connect the dots. Can you please give me your thoughts?

Hi @ramangopalan seems like the issue is some authorization issue (or missing folder/directory)

#4 [internal] load metadata for docker.io/library/nuttx-toolchain-avr32:latest
#4 ERROR: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

#5 [internal] load metadata for docker.io/library/ubuntu:22.04
#5 CANCELED
------
 > [internal] load metadata for docker.io/library/nuttx-toolchain-avr32:latest:
------
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
Dockerfile:385
--------------------
 383 |     
 384 |     # AVR32 toolchain
 385 | >>> COPY --from=nuttx-toolchain-avr32 /tools/avr32-gnu-toolchain-linux_x86/ avr32-gnu-toolchain-linux_x86/
 386 |     ENV PATH="/tools/avr32-gnu-toolchain-linux_x86/bin:$PATH"
 387 |     
--------------------
ERROR: failed to solve: nuttx-toolchain-avr32: failed to resolve source metadata for docker.io/library/nuttx-toolchain-avr32:latest: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
Error: buildx failed with: ERROR: failed to solve: nuttx-toolchain-avr32: failed to resolve source metadata for docker.io/library/nuttx-toolchain-avr32:latest: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

@acassis
Copy link
Contributor

acassis commented May 5, 2024

@xiaoxiang781216 any idea why is it happening?

@xiaoxiang781216
Copy link
Contributor

@ramangopalan it's better to move the docker change to the new pr since ci still use the old docker image util the patch get merged.

@@ -381,6 +381,10 @@ ENV PATH="/tools/gcc-arm-none-eabi/bin:$PATH"
COPY --from=nuttx-toolchain-arm64 /tools/gcc-aarch64-none-elf/ gcc-aarch64-none-elf/
ENV PATH="/tools/gcc-aarch64-none-elf/bin:$PATH"

# AVR32 toolchain
COPY --from=nuttx-toolchain-avr32 /tools/avr32-gnu-toolchain-linux_x86/ avr32-gnu-toolchain-linux_x86/
Copy link
Contributor

Choose a reason for hiding this comment

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

where you download the toolchain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dear @xiaoxiang781216,

where you download the toolchain?

I intend to download the toolchain from [1]. In the code, where must I
add it so CI can see it? I have added some code in [2] which clones
the toolchain. Am I missing something? Here is a snip from [2]:

avr32_gcc_toolchain() {
  add_path "${NUTTXTOOLS}"/avr32-gnu-toolchain-linux_x86/bin

  if [ ! -f "${NUTTXTOOLS}/avr32-gnu-toolchain-linux_x86/bin/avr32-gcc" ]; then
    local basefile
    basefile=avr32-gnu-toolchain-linux_x86
    cd "${NUTTXTOOLS}"
    # Download the AVR32 GCC toolchain
    git clone https://github.com/ramangopalan/${basefile}
  fi

  command avr32-gcc --version
}

References:
[1]: https://github.com/ramangopalan/avr32-gnu-toolchain-linux_x86
[2]: tools/ci/platforms/ubuntu.sh

Copy link
Contributor

Choose a reason for hiding this comment

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

@xiaoxiang781216 could you please help here?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ramangopalan need to add in the Dockerfile:

###############################################################################
# Build image for tool required by AVR32 builds
###############################################################################
FROM nuttx-toolchain-base AS nuttx-toolchain-avr32
# Download the latest AVR32 GCC toolchain prebuilt by Raman
RUN mkdir -p gcc-avr32-gnu && \
  git clone https://github.com/ramangopalan/avr32-gnu-toolchain-linux_x86 gcc-avr32-gnu

# AVR32 toolchain
COPY --from=nuttx-toolchain-avr32 /tools/gcc-avr32-gnu/ gcc-avr32-gnu/
ENV PATH="/tools/gcc-avr32-gnu/bin:$PATH"

ln -sf `which ccache` /tools/ccache/bin/avr-g++ && \

  ln -sf `which ccache` /tools/ccache/bin/avr32-gcc && \
  ln -sf `which ccache` /tools/ccache/bin/avr32-g++ && \

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you very much @simbit18 !!!

@ramangopalan could you please include these suggestion? If it fixes the issue we could integrate this PR and get AVR32 tested in our CI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dear @simbit18, Dear @acassis,

Many thanks for your suggestion. I will give these a try in just a
jiffy and write back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  ln -sf `which ccache` /tools/ccache/bin/avr32-gcc && \
  ln -sf `which ccache` /tools/ccache/bin/avr32-g++ && \

Thank you @simbit18. Thank you @acassis. I have pushed these changes
for checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure why clone didn't go though. Did I miss something?
Could it be about a setting on Github?

--------------------
 125 |     # Download the prebuilt AVR32 GCC toolchain
 126 | >>> RUN mkdir -p gcc-avr32-gnu && \
 127 | >>>   git clone https://github.com/ramangopalan/avr32-gnu-toolchain-linux_x86 gcc-avr32-gnu
 128 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir -p gcc-avr32-gnu &&   git clone https://github.com/ramangopalan/avr32-gnu-toolchain-linux_x86 gcc-avr32-gnu" did not complete successfully: exit code: 127

Copy link
Contributor

Choose a reason for hiding this comment

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

@ramangopalan in the stage is missing git try this:

###############################################################################
# Build image for tool required by AVR32 builds
###############################################################################
FROM nuttx-toolchain-base AS nuttx-toolchain-avr32
# Download the prebuilt AVR32 GCC toolchain
RUN apt-get update -qq && DEBIAN_FRONTEND="noninteractive" apt-get install -y -qq \
  git
# Clone Main Repository 
RUN mkdir -p gcc-avr32-gnu && \
  git clone --depth 1 https://github.com/ramangopalan/avr32-gnu-toolchain-linux_x86 gcc-avr32-gnu

@ramangopalan ramangopalan force-pushed the master branch 2 times, most recently from e01e91a to 3565dab Compare June 5, 2024 15:26
@acassis
Copy link
Contributor

acassis commented Jun 6, 2024

@simbit18 even with your suggestion still failing with same error message:

ERROR: failed to solve: process "/bin/sh -c mkdir -p gcc-avr32-gnu &&   git clone https://github.com/ramangopalan/avr32-gnu-toolchain-linux_x86 gcc-avr32-gnu" did not complete successfully: exit code: 127
Error: buildx failed with: ERROR: failed to solve: process "/bin/sh -c mkdir -p gcc-avr32-gnu &&   git clone https://github.com/ramangopalan/avr32-gnu-toolchain-linux_x86 gcc-avr32-gnu" did not complete successfully: exit code: 127

@simbit18
Copy link
Contributor

simbit18 commented Jun 6, 2024

@acassis dockerfile does not have this

###############################################################################
# Build image for tool required by AVR32 builds
###############################################################################
FROM nuttx-toolchain-base AS nuttx-toolchain-avr32
# Download the prebuilt AVR32 GCC toolchain
RUN apt-get update -qq && DEBIAN_FRONTEND="noninteractive" apt-get install -y -qq \
  git
# Clone Main Repository 
RUN mkdir -p gcc-avr32-gnu && \
  git clone --depth 1 https://github.com/ramangopalan/avr32-gnu-toolchain-linux_x86 gcc-avr32-gnu

in the stage is missing git

RUN apt-get update -qq && DEBIAN_FRONTEND="noninteractive" apt-get install -y -qq
git

@simbit18
Copy link
Contributor

simbit18 commented Jun 7, 2024

@acassis @ramangopalan testing on my repository

docker image build process
https://github.com/simbit18/nuttx-testing-ci/actions/runs/9407488507/job/25913339810#step:7:1175

#22 [nuttx-toolchain-avr32 2/2] RUN mkdir -p gcc-avr32-gnu &&   git clone --depth 1 https://github.com/ramangopalan/avr32-gnu-toolchain-linux_x86 gcc-avr32-gnu
#22 0.157 Cloning into 'gcc-avr32-gnu'...
#22 4.883 Updating files:  17% (921/5330)

Dockerfile
https://github.com/simbit18/nuttx-testing-ci/blob/main/tools/Dockerfile

test the avr32 version in the docker image
https://github.com/simbit18/nuttx-testing-ci/actions/runs/9415734071/job/25937327129#step:4:21

avr32-gcc (AVR_32_bit_GNU_Toolchain_3.4.2_435) 4.4.7
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@acassis
Copy link
Contributor

acassis commented Jun 7, 2024

thank you @simbit18, so your Dockerfile looks very similar to that here, what you did different?

I compared your Dockerfile against mainline and there difference seem to exist in Raman docker as well:

###############################################################################
# Build image for tool required by AVR32 builds
###############################################################################
FROM nuttx-toolchain-base AS nuttx-toolchain-avr32
# Download the prebuilt AVR32 GCC toolchain
RUN apt-get update -qq && DEBIAN_FRONTEND="noninteractive" apt-get install -y -qq \
  git
# Clone Main Repository 
RUN mkdir -p gcc-avr32-gnu && \
  git clone --depth 1 https://github.com/ramangopalan/avr32-gnu-toolchain-linux_x86 gcc-avr32-gnu

###############################################################################

...

RUN mkdir -p cmake && \
  curl -s -L wget https://cmake.org/files/v3.26/cmake-3.26.0.tar.gz \
  | tar -C cmake --strip-components=1 -xz && \
  cd cmake && ./bootstrap && make && make install && rm -rf cmake


...

# AVR32 toolchain
COPY --from=nuttx-toolchain-avr32 /tools/gcc-avr32-gnu/ gcc-avr32-gnu/
ENV PATH="/tools/gcc-avr32-gnu/bin:$PATH"

...

  ln -sf `which ccache` /tools/ccache/bin/avr32-gcc && \
  ln -sf `which ccache` /tools/ccache/bin/avr32-g++ && \

@simbit18
Copy link
Contributor

simbit18 commented Jun 7, 2024

in the docker
https://github.com/apache/nuttx/blob/master/tools/ci/docker/linux/Dockerfile

it is necessary to add:

###############################################################################
# Build image for tool required by AVR32 builds
###############################################################################
FROM nuttx-toolchain-base AS nuttx-toolchain-avr32
# Download the prebuilt AVR32 GCC toolchain
RUN apt-get update -qq && DEBIAN_FRONTEND="noninteractive" apt-get install -y -qq \
  git
# Clone Main Repository 
RUN mkdir -p gcc-avr32-gnu && \
  git clone --depth 1 https://github.com/ramangopalan/avr32-gnu-toolchain-linux_x86 gcc-avr32-gnu

# AVR32 toolchain
COPY --from=nuttx-toolchain-avr32 /tools/gcc-avr32-gnu/ gcc-avr32-gnu/
ENV PATH="/tools/gcc-avr32-gnu/bin:$PATH"
  ln -sf `which ccache` /tools/ccache/bin/avr32-gcc && \
  ln -sf `which ccache` /tools/ccache/bin/avr32-g++ && \

@ramangopalan
Copy link
Contributor Author

Dear @simbit18, Dear @acassis, Greetings!

Firstly, so sorry about the delay in my response. Many thanks for your
suggestions. I have pushed another test commit which amends the
Dockerfile recipe to apt-install git. Thanks again. Jolly good weekend!

@ramangopalan
Copy link
Contributor Author

Dear @simbit18, Dear @acassis,

Aren't the tests for nsh and ostest for avr32dev1 performed by
default? Not sure why they are skipped. I notice that the tests are
not being skipped for the Mizar32-A target. I see the recipe also
appends avr32-gcc to the PATH. Is something missing for avr32dev1?

====================================================================================
Skipping: avr32dev1/nsh
Configuration/Tool: avr32dev1/nsh
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Normalize avr32dev1/nsh
====================================================================================
Skipping: avr32dev1/ostest
Configuration/Tool: avr32dev1/ostest
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Normalize avr32dev1/ostest
====================================================================================
Configuration/Tool: mizar32a/nsh
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Building NuttX...
sh: 1: avr32-gcc: not found
ERROR: avr32-gcc failed: 127
       command: avr32-gcc -MT ./dummy.c.github.workspace.sources.apps.platform.o  -M '-fno-pic' '-muse-rodata-section' '-fno-strict-aliasing' '-fomit-frame-pointer' '-mpart=uc3b0256' '-isystem' '/github/workspace/sources/nuttx/include' '-D__NuttX__' '-DNDEBUG' '-D__KERNEL__' '-Wno-cpp' '-Werror' '-pipe' '-I' '/github/workspace/sources/apps/include' ./board/dummy.c
sh: 1: avr32-gcc: not found
sh: 1: avr32-gcc: not found

Could something be wrong here? The paths look fine to me.

# AVR32 toolchain
COPY --from=nuttx-toolchain-avr32 /tools/gcc-avr32-gnu/ gcc-avr32-gnu/
ENV PATH="/tools/gcc-avr32-gnu/bin:$PATH"

I am trying to find the log entries pertaining to fetching avr32-gcc.

@ramangopalan
Copy link
Contributor Author

Dear @simbit18,

RUN apt-get update -qq && DEBIAN_FRONTEND="noninteractive" TZ=Etc/UTC apt-get install -y -qq --no-install-recommends \
  -o APT::Immediate-Configure=0 \
  avr-libc \
  ccache \
  clang \
  clang-tidy \
  g++-12-multilib \
  gcc-avr \
  gcc-12-multilib \
  genromfs \
  gettext \
  git \

I see apt-install git here too. Is fetching git necessary for AVR32
specific actions too?

@ramangopalan
Copy link
Contributor Author

Dear @acassis, Greetings,

@ramangopalan I think after PR #12520 get merged you can simplify this PR here, maybe just keeping the first commit

Sure. Understand. Also, do you think I should remove the following entries for avr32dev1?
From this file: tools/ci/testlist/other.dat:

# We do not have a toolchain for avr32 outside of Microchip login wall.
# The work was never upstreamed to GCC.
/avr
-avr32dev1:nsh
-avr32dev1:ostest

@xiaoxiang781216
Copy link
Contributor

@ramangopalan please rebase your patch to the last master

@ramangopalan ramangopalan force-pushed the master branch 2 times, most recently from 5e2d7f8 to 7338752 Compare June 19, 2024 15:09
@ramangopalan
Copy link
Contributor Author

Dear @xiaoxiang781216, Dear @acassis, Dear @simbit18,

@ramangopalan please rebase your patch to the last master

Many thanks for your suggestions. I have removed the avr32dev1 entry
from other.dat. Please let me know if there's anything else I can help
with. I look forward to furthering peripheral support for Mizar32.
Thanks once again.

Copy link
Contributor

@simbit18 simbit18 left a comment

Choose a reason for hiding this comment

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

Dear @xiaoxiang781216, Dear @acassis, Dear @simbit18,

@ramangopalan please rebase your patch to the last master

Many thanks for your suggestions. I have removed the avr32dev1 entry from other.dat. Please let me know if there's anything else I can help with. I look forward to furthering peripheral support for Mizar32. Thanks once again.

@ramangopalan leave in the file tools/ci/testlist/other.dat the entry

/avr

otherwise avr boards are not build !!!

https://github.com/apache/nuttx/actions/runs/9584486153/job/26428379693?pr=11709#step:7:73

@ramangopalan
Copy link
Contributor Author

Dear @simbit18,

/avr

otherwise avr boards are not build !!!

https://github.com/apache/nuttx/actions/runs/9584486153/job/26428379693?pr=11709#step:7:73

So sorry. I didn't realize this. I fully understand.

@ramangopalan
Copy link
Contributor Author

Dear @acassis, Greetings! I looked at the code to see what was
happening with the Mizar32's UART specific sections here:

#else

  /* In the case of Mizar32, enable all USART clocks. */

  regval |= PM_PBAMASK_USART0 | PM_PBAMASK_USART1 | PM_PBAMASK_USART2;
#endif

I used Mizar32A, the latest NuttX and dfu-programmer for checks.

I have allocated the UART pins and clock (from the datasheet [1], pin
allocations, page 45) correctly. I am using UART1 for Mizar32.

In Mizar32's case, the regval local from up_consoleinit() is supposed
to hold PM_PBAMASK_USART1. But the UART1 console for NuttX on
AT32UC3A0512 is expecting PM_PBAMASK_USART1 to be (1 << 9) instead of
(1 << 8) for its functionality.

Hence, it works when I enable PM_PBAMASK_USART2. I do understand
that enabling all UART clocks isn't the right fix.

Clearly, there are bit-position differences between avr32dev1 and
Mizar32 for console on UART1. I am thinking about how I can write
these differences within at32uc3_pm.h. Should there be an
at32uc3a_pm.h? I am planning to reserve significant parts of Sunday
for this activity. :)

Is there a way I can simplify this patch and fix these parts when I
touch the other peripherals for Mizar32?

Jolly good weekend.

References:
[1]: https://ww1.microchip.com/downloads/en/DeviceDoc/doc32058.pdf

@ramangopalan
Copy link
Contributor Author

Dear @acassis,

I am attaching a snap of the USART clock mask bit-positions. Is using
conditional compilation within at32uc3_pm.h fine?

image

@acassis
Copy link
Contributor

acassis commented Jun 22, 2024

Dear @acassis,

I am attaching a snap of the USART clock mask bit-positions. Is using conditional compilation within at32uc3_pm.h fine?

Dear Raman,
It seems like AT32UC3A UART bits are similar to arch/arm/src/sam34/hardware/sam4l_pm.h. Question: do you know if other registers bits are also different? Maybe we will need to separate arch/avr/src/at32uc3/at32uc3_pm.h into arch/avr/src/at32uc3/at32uc3a_pm.h and arch/avr/src/at32uc3/at32uc3b_pm.h. So arch/avr/src/at32uc3/at32uc3_pm.h will have just a #ifdef to select with file (at32uc3a_pm.h or at32uc3b_pm.h) to include.

@ramangopalan
Copy link
Contributor Author

Dear @acassis, Greetings!

I introduced at32uc3a_pm.h and at32uc3b_pm.h. The build works fine for
me. I am attaching a snap of my terminal session. Can you please check
if changes are OK? Many thanks for your suggestions.

image

@xiaoxiang781216
Copy link
Contributor

look like avr compiler doesn't support -Wno-cpp:

Error: ./avr32_bringup.c:54:4: error: #warning "Not Implemented"
cc1: warnings being treated as errors
cc1: error: unrecognized command line option "-Wno-cpp"
ERROR: avr32-gcc failed: 1

which is added here:
https://github.com/apache/nuttx/blob/master/tools/ci/cibuild.sh#L143
need find some way to remove it for avr.

@simbit18
Copy link
Contributor

simbit18 commented Jul 10, 2024

@xiaoxiang781216 At the moment I have seen that the problem only affects

boards/avr/at32uc3/mizar32a/src/avr32_bringup.c
boards/avr/at32uc3/avr32dev1/src/avr32_bringup.c

1) Simple solution to this error
Error: ./avr32_bringup.c:54:4: error: #warning "Not Implemented"

comment out directive '#warning'
/* #warning "Not Implemented" */

otherwise solutions are in the file tools/testbuild.sh

2) for microcontroller/System-on-Chip (at32uc3)

https://github.com/simbit18/nuttx/blob/16582dbf780d2b754383b8bd6627cb373e83f8c6/tools/testbuild.sh#L549

3) for boards (avr32dev1 and mizar32a)

https://github.com/simbit18/nuttx/blob/16582dbf780d2b754383b8bd6627cb373e83f8c6/tools/testbuild.sh#L527

Opinions?

@acassis
Copy link
Contributor

acassis commented Jul 10, 2024

Thank you @simbit18 for keeping eyes on it. Is there some way to avoid converting this #warning in error in our CI?
Maybe we can remove that warning, since it is not exactly a warning or an issue, the board boots correctly.

@simbit18
Copy link
Contributor

These are the two solutions I tested on my repository to edit extra c/c++ flags "-Wno-cpp -Werror"
and concern modifications tools/testbuild.sh file
for microcontroller/System-on-Chip (at32uc3)

https://github.com/simbit18/nuttx/blob/16582dbf780d2b754383b8bd6627cb373e83f8c6/tools/testbuild.sh#L549
or for boards
https://github.com/simbit18/nuttx/blob/16582dbf780d2b754383b8bd6627cb373e83f8c6/tools/testbuild.sh#L527

The tests I did showed an error in the file
arch/avr/src/avr32/avr_doirq.c
avr32/avr_doirq.c:117: error: assignment discards qualifiers from pointer target type
fix
regs = g_current_regs; -> regs = (uint32_t *)g_current_regs;

@simbit18
Copy link
Contributor

simbit18 commented Jul 11, 2024

@xiaoxiang781216 @acassis @ramangopalan add PR #12671

@ramangopalan remember to comment out the directive '#warning'
in the boards/avr/at32uc3/mizar32a/src/avr32_bringup.c file
/* #warning "Not Implemented" */

@acassis
Copy link
Contributor

acassis commented Jul 11, 2024

@simbit18 thank you very much!

@simbit18
Copy link
Contributor

@ramangopalan please comment out the directive '#warning' and rebase, since the CI should be fixed now

@ramangopalan
Copy link
Contributor Author

Dear @simbit18, Dear @acassis, Many thanks for your suggestion. I have commented out the warning from avr32_bringup.

@xiaoxiang781216 xiaoxiang781216 merged commit ef271b8 into apache:master Jul 15, 2024
26 checks passed
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