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

UART RX implementation on PIC32 devices #13094

Merged
merged 24 commits into from
Mar 31, 2020

Conversation

francois-berder
Copy link
Contributor

@francois-berder francois-berder commented Jan 11, 2020

Contribution description

This PR finally implements UART RX on PIC32 devices and makes it possible to run examples/default on pic32-clicker and pic32-wifire.

GPIO

Have a look at PR #12475. GPIOs are now working very similarly that on STM32.

Interrupts

Interrupts were refactored: we assume devices use EIC (that is true since Malta board was removed from RIOT) and the implementation is similar to RISCV FE310 CPU EIC.
I also found out that updating the MIPS toolchain completely broke interrupts due to a missing file (mips_excpt_isr.S) in 2018.09-03 that used to be present in 2016.05-03 version. So mips_excpt_isr.S is now present in cpu/misp32r2_common.

UART

UART peripheral driver was also refactored to make it more similar to STM32 UART driver implementation. UART configuration is now defined in board periph_conf.h file.
The major novelty of this PR is that is now possible to receive data over serial.

miscellaneous

pm_reboot was implemented in cpu/mips_pic32_common such that all commands available when running examples/default are now working on pic32-clicker and pic32-wifire.

Testing procedure

I ran examples/default and checked that I could execute commands on pic32-clicker and pic32-wifire.

Issues/PRs references

Depends on #12475.

@aabadie aabadie added Area: cpu Area: CPU/MCU ports Platform: MIPS Platform: This PR/issue effects MIPS-based platforms Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Jan 11, 2020
@fjmolinas fjmolinas requested a review from kaspar030 January 13, 2020 08:44
@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR State: waiting for other PR State: The PR requires another PR to be merged first and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jan 30, 2020
@francois-berder francois-berder force-pushed the pic32-uart-3 branch 2 times, most recently from 1d88f20 to dd77b56 Compare January 31, 2020 21:33
@francois-berder
Copy link
Contributor Author

This PR is now ready for review.
@benpicco Could you remove the "waiting for other PR" label ?

@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed State: waiting for other PR State: The PR requires another PR to be merged first labels Feb 6, 2020
@francois-berder
Copy link
Contributor Author

francois-berder commented Feb 8, 2020

Interestingly, a previous murdock build revealed that MIPS toolchain uses a different type for size_t than other embedded toolchains.

$ echo | gcc -E -xc -include 'stddef.h' - | grep size_t
typedef long unsigned int size_t;
$ echo | arm-none-eabi-gcc -E -xc -include 'stddef.h' - | grep size_t
typedef unsigned int size_t;
$ echo | avr-gcc -E -xc -include 'stddef.h' - | grep size_t
typedef unsigned int size_t;
$ echo | mips-mti-elf-gcc -E -xc -include 'stddef.h' - | grep size_t
typedef long unsigned int size_t;
$ echo | msp430-gcc -E -xc -include 'stddef.h' - | grep size_t
typedef unsigned int size_t;
$ echo | riscv-none-embed-gcc -E -xc -include 'stddef.h' - | grep size_t
typedef unsigned int size_t;
$ echo | xtensa-esp32-elf-gcc -E -xc -include 'stddef.h' - | grep size_t
typedef unsigned int size_t;
$ echo | xtensa-esp8266-elf-gcc -E -xc -include 'stddef.h' - | grep size_t
typedef unsigned int size_t;
$ echo | clang -E -xc -include 'stddef.h' - | grep size_t
typedef long unsigned int size_t;
Operating System Environment
-----------------------------
         Operating System: "Ubuntu" "18.04.4 LTS (Bionic Beaver)"
                   Kernel: Linux 5.3.0-28-generic x86_64 x86_64
             System shell: /bin/dash (probably dash)
             make's shell: /bin/dash (probably dash)

Installed compiler toolchains
-----------------------------
               native gcc: gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
        arm-none-eabi-gcc: arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 8-2019-q3-update) 8.3.1 20190703 (release) [gcc-8-branch revision 273027]
                  avr-gcc: avr-gcc (GCC) 5.4.0
         mips-mti-elf-gcc: mips-mti-elf-gcc (Codescape GNU Tools 2018.09-03 for MIPS MTI Bare Metal) 6.3.0
               msp430-gcc: msp430-gcc (GCC) 4.6.3 20120301 (mspgcc LTS 20120406 unpatched)
     riscv-none-embed-gcc: riscv-none-embed-gcc (GNU MCU Eclipse RISC-V Embedded GCC, 64-bit) 8.2.0
     xtensa-esp32-elf-gcc: xtensa-esp32-elf-gcc (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a5) 5.2.0
   xtensa-esp8266-elf-gcc: xtensa-esp8266-elf-gcc (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a5) 5.2.0
                    clang: clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)

Installed compiler libs
-----------------------
     arm-none-eabi-newlib: "3.1.0"
      mips-mti-elf-newlib: "2.5.0"
  riscv-none-embed-newlib: "3.0.0"
  xtensa-esp32-elf-newlib: "2.2.0"
xtensa-esp8266-elf-newlib: "2.2.0"
                 avr-libc: "2.0.0" ("20150208")

Installed development tools
---------------------------
                   ccache: ccache version 3.4.1
                    cmake: cmake version 3.10.2
                 cppcheck: Cppcheck 1.82
                  doxygen: 1.8.13
                      git: git version 2.17.1
                     make: GNU Make 4.1
                  openocd: Open On-Chip Debugger 0.10.0
                   python: Python 2.7.17
                  python2: Python 2.7.17
                  python3: Python 3.6.9
                   flake8: 3.5.0 (mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.6.0) CPython 3.6.9 on Linux
               coccinelle: spatch version 1.0.4 with Python support and with PCRE support

@francois-berder
Copy link
Contributor Author

In the last Murdock build, all lwip related tests failed because it could not clone lwip repository. However, I was able to do it on my machine.

@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Feb 9, 2020
Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

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

This is a major refactoring and unfortunately, I don't have the hardware to test this.

I have a couple of comments regarding the changes related to the build system.

@francois-berder
Copy link
Contributor Author

This is a major refactoring and unfortunately, I don't have the hardware to test this.

Indeed but I could split this PR in several parts:

  1. EIC refactoring
  2. UART refactoring
  3. pm_reboot implementation for PIC32 devices

Let me know what is preferred.

Concerning the lack of hardware, I do have a spare WiFire board. Send me an email if you are interested.

Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
This file used to be part of the toolchain (at least in 2016.05-03
version) but is not part of the current MIPS toolchain (2018-09-03).

Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
@aabadie
Copy link
Contributor

aabadie commented Mar 26, 2020

@francois-berder, I can't test this PR and I don't who is able to test except you. If you could paste the output of the build/flash/term of example/default, call help, reboot, that would be enough for me to merge this PR.

@francois-berder
Copy link
Contributor Author

In this case, here are some logs for both clicker and wifire:
build-clicker.log
build-wifire.log
term-clicker.log
term-wifire.log

@aabadie aabadie self-assigned this Mar 31, 2020
Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

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

All good from my side. Thanks for providing the output @francois-berder !

ACK and go!

@aabadie aabadie merged commit 934f68e into RIOT-OS:master Mar 31, 2020
@francois-berder francois-berder deleted the pic32-uart-3 branch April 2, 2020 17:34
@leandrolanzieri leandrolanzieri added this to the Release 2020.04 milestone Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: MIPS Platform: This PR/issue effects MIPS-based platforms Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants