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/msp430: update to modern gcc/ELF/newlib toolchain #12457

Merged
merged 47 commits into from
Aug 5, 2020

Conversation

kaspar030
Copy link
Contributor

@kaspar030 kaspar030 commented Oct 15, 2019

Contribution description

This PR updates msp430 to a current gcc/newlib.

I used a self-compiled toolchain while developing this, but it turns out that the current TI gcc 8.3.0 toolchain works just fine. *Thus that's PR'ed at RIOT-OS/riotdocker#91.
Update: now using toolchains from https://github.com/RIOT-OS/toolchains/releases, which is also in our Docker container.

Until this is in riotdocker, the toolchain can be downloaded here. Only the gcc binary tarball is needed.

As expected, code size increases a lot. E.g., hello-world almost doubles (4k -> 8k ROM). That's probably mostly because newlibs stdio is much larger than the old TI one. Let's hope that picolibc will mitigate this...

The upside is that now msp430 can use C11, is re-using unmodified newlib-syscalls-default, and generally gets some support from upstream. Generally, many msp430 specific hacks are made obsolete.

The PR reverts some of the recent malloc updates to msp430, as they're not needed anymore.
This also includes a script to download the msp430-support-files (including headers and linkerscripts for every msp430 variant) that then removes all but the actually currently used files. That script should make adding more msp430 boards, or updating the support files, quite easy.

The PR does not yet remove all the blacklists that might not be necessary anymore, and it does not yet update insufficient memory lists that will probably get longer due to increased code size. I'm waiting for CI support to tackle those. done, all blacklists are updated.

Testing procedure

Test the shit out of any msp430 board.

Issues/PRs references

RIOT-OS/riotdocker#91
Partly fixes #3355
Fixes #8408.
Fixes all compilation errors and most tests found in #13267.

@kaspar030 kaspar030 added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Platform: MSP Platform: This PR/issue effects MSP-based platforms Impact: major The PR changes a significant part of the code base. It should be reviewed carefully State: waiting for other PR State: The PR requires another PR to be merged first labels Oct 15, 2019
@aabadie
Copy link
Contributor

aabadie commented Oct 15, 2019

Test the shit out of any msp430 board.

Can you give more details ?

@gschorcht
Copy link
Contributor

gschorcht commented Oct 17, 2019

The compilation of following tests failed with new gcc version in RIOT-OS/riotdocker#91 and this PR:

tests/gnrc_sock_udp
tests/heap_cmd
tests/libc_newlib
tests/nanocoap_cli
tests/pkg_fatfs
tests/pkg_microcoap

I tried it for wsn430-v1_3b.

cpu/msp430_common/malloc.c Show resolved Hide resolved
cpu/msp430_common/malloc.c Show resolved Hide resolved
@gschorcht
Copy link
Contributor

tests/gnrc_sock_udp, tests/nanocoap_cli and tests/pkg_microcoap seem no to fit into the memory. MSP430 boards would have to be blacklisted for these tests.

@kaspar030
Copy link
Contributor Author

tests/gnrc_sock_udp, tests/nanocoap_cli and tests/pkg_microcoap seem no to fit into the memory. MSP430 boards would have to be blacklisted for these tests.

Done. I've rebased to make use of the new Makefile.ci. @maribu, the flattened BOARD_INSUFFICIENT_MEMORY lists are so much nicer. 😉

@kaspar030
Copy link
Contributor Author

tests/pkg_fatfs

This failes to compile here because of an sprintf overflow error. Fix in #12503.

@gschorcht
Copy link
Contributor

tests/pkg_fatfs

This failes to compile here because of an sprintf overflow error. Fix in #12503.

Even it compiles now, I get the following error on linking:

/opt/msp430-gcc-8.3.0.16_linux64/bin/../lib/gcc/msp430-elf/8.3.0/../../../../msp430-elf/bin/ld: error: /data/riotbuild/tests/pkg_fatfs/bin/wsn430-v1_3b/cpu/msp430_stdio.o uses unknown instructions but /opt/msp430-gcc-8.3.0.16_linux64/bin/../lib/gcc/msp430-elf/8.3.0/../../../../msp430-elf/lib/430/crt0.o uses MSP430
/opt/msp430-gcc-8.3.0.16_linux64/bin/../lib/gcc/msp430-elf/8.3.0/../../../../msp430-elf/bin/ld: error: /data/riotbuild/tests/pkg_fatfs/bin/wsn430-v1_3b/cpu/msp430_stdio.o uses the unknown code model whereas /opt/msp430-gcc-8.3.0.16_linux64/bin/../lib/gcc/msp430-elf/8.3.0/../../../../msp430-elf/lib/430/crt0.o uses the small code model
/opt/msp430-gcc-8.3.0.16_linux64/bin/../lib/gcc/msp430-elf/8.3.0/../../../../msp430-elf/bin/ld: error: /data/riotbuild/tests/pkg_fatfs/bin/wsn430-v1_3b/cpu/msp430_stdio.o uses the unknown data model whereas /opt/msp430-gcc-8.3.0.16_linux64/bin/../lib/gcc/msp430-elf/8.3.0/../../../../msp430-elf/lib/430/crt0.o uses the small data model

Any idea? I have seen this for other tests too.

@kaspar030
Copy link
Contributor Author

Even it compiles now, I get the following error on linking:

Now that's weird, I don't get that error with the same toolchain!?

@kaspar030
Copy link
Contributor Author

Now that's weird, I don't get that error with the same toolchain!?

I tried building using a freshly built RIOT-OS/riotdocker#91, that also builds fine. Something is weird. I've seen that linking error, too, but don't remember where.

@gschorcht
Copy link
Contributor

Now that's weird, I don't get that error with the same toolchain!?

I tried building using a freshly built RIOT-OS/riotdocker#91, that also builds fine. Something is weird. I've seen that linking error, too, but don't remember where.

I have build riotdocker from scratch and try to recompile now completely with your last force-pushed branch.

@kaspar030
Copy link
Contributor Author

your last force-pushed branch.

sorry, I rebased to get #12503.

@gschorcht
Copy link
Contributor

That's ok, I had to cherr pick PR #12503 before. I started complete recompilation by intention to see in which other tests I got this linking error.

@gschorcht
Copy link
Contributor

Great, the complete rerun of compilation test in a fresh environment worked. There are no compilation or linking errors anymore.

@kaspar030
Copy link
Contributor Author

I'm observing an issue with stdio.

The unittest "OK (N tests)" output doesn't show the N (number). Weirdly the number shows when adding printf("foo %d", 1234); (did that for testing). So something is wrong inside the syscalls.

@kaspar030
Copy link
Contributor Author

I'm observing an issue with stdio.

Hm, with my self-compiled toolchain it works fine. Maybe we have to compile ourselves after all. :(

@gschorcht
Copy link
Contributor

I'm observing an issue with stdio.

Hm, with my self-compiled toolchain it works fine. Maybe we have to compile ourselves after all. :(

Sounds depressing 😟

1 similar comment
@gschorcht
Copy link
Contributor

I'm observing an issue with stdio.

Hm, with my self-compiled toolchain it works fine. Maybe we have to compile ourselves after all. :(

Sounds depressing 😟

@kaspar030
Copy link
Contributor Author

Sounds depressing worried

Yup. :)

embunit does this:

        stdimpl_print("\nOK (");                                                                                                   
        stdimpl_itoa(result_.runCount, buf, 10);                                                                                   
        stdimpl_print(buf);                                                                                                        
        stdimpl_print(" tests)\n");                                                                                                

stdimpl_print(x) is defined to printf("%s", x).

The resulting writes arrive re-ordered at newlib's _write_r(), even though they're from the same thread.

The only board with this chipset was the chronos, which has been
removed.
Both tests/pthread_tls and tests/prng_sha256prng fail without this, but
other platforms run fine with their defaults. Lets consider the higher
value a better default.
/* Port 1:
     *  P1.0 is not assigned by default
     *  P1.1 is the bootstrap-loader (BSL) TX pin -> input, special function, default to GND
     *       THIS PIN MUST *NEVER* BE USED IN NORMAL EXECUTION, SINCE IT INTERFERES WITH UART0 !!!
     *  P1.2 receives the FIFOP interrupt from CC2420 -> input, GPIO, default to GND
     *  P1.3 receives the FIFO/GIO0 interrupt from CC2420 -> input, GPIO, default to GND
     *  P1.4 receives the CCA/GIO1 signal from CC2420 -> input, GPIO, default to GND
     *  P1.5 is wired to Vcc -> input, GPIO, default to Vcc
     *  P1.6 receives interrupt INT1 from accelerometer -> input, GPIO, default to GND
     *  P1.7 receives interrupt INT2 from accelerometer -> input, GPIO, default to GND
     */

(test starts indexing at 0)
@kaspar030 kaspar030 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 CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable labels Aug 5, 2020
@kaspar030
Copy link
Contributor Author

all dependencies are in.

  • rebased, squashed (somewhat)

@maribu
Copy link
Member

maribu commented Aug 5, 2020

I don't really have hardware to test. But I honestly would argue to merge this as is, provided that everything compiles, as:

  • This fixes a lot of issues and is a big step in the right direction
  • It gets rid of many special cases / handling
  • It will make our life much easier, as this is the last platform without C11 support. (The AVR compiler installed in the docker is also not yet C11 ready, but I locally use a modern GCC compiler for AVR without any issues...)
  • This PR will not get easier to test and review over time. Instead, we should IMO just say this is a great step in the right direction and everything else can be easier addressed, reviewed and tested in follow up PRs.
  • The support for MSP430 platform in master is in a pretty bade shape. If there are any active MSP430 users, the are used to suffering anyway ;-P

@fjmolinas
Copy link
Contributor

I don't really have hardware to test. But I honestly would argue to merge this as is, provided that everything compiles, as:

  • This fixes a lot of issues and is a big step in the right direction
  • It gets rid of many special cases / handling
  • It will make our life much easier, as this is the last platform without C11 support. (The AVR compiler installed in the docker is also not yet C11 ready, but I locally use a modern GCC compiler for AVR without any issues...)
  • This PR will not get easier to test and review over time. Instead, we should IMO just say this is a great step in the right direction and everything else can be easier addressed, reviewed and tested in follow up PRs.
  • The support for MSP430 platform in master is in a pretty bade shape. If there are any active MSP430 users, the are used to suffering anyway ;-P

+1, let me run tests on z1 before merging though that that the issue listing failing tests can be updated (but I think Kaspar took care of most already.)

@fjmolinas
Copy link
Contributor

+1, let me run tests on z1 before merging though that that the issue listing failing tests can be updated (but I think Kaspar took care of most already.)

Results summary, and details

- [tests/driver_grove_ledbar](tests/driver_grove_ledbar/test.failed)
- [tests/driver_hd44780](tests/driver_hd44780/test.failed)
- [tests/driver_my9221](tests/driver_my9221/test.failed)
- [tests/periph_timer_short_relative_set](tests/periph_timer_short_relative_set/test.failed)

@fjmolinas
Copy link
Contributor

Huge improvement compared to #13267, nothing unexpected is failing now.

@fjmolinas fjmolinas added the Reviewed: 3-testing The PR was tested according to the maintainer guidelines label Aug 5, 2020
@fjmolinas
Copy link
Contributor

@maribu you have taken a closer look at the code do you want to tick the other labels and ACK?

@maribu maribu added Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines labels Aug 5, 2020
Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

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

ACK

RIOT Sprint Day automation moved this from Under Review to Waiting For Murdock Aug 5, 2020
@maribu maribu merged commit 90f5d21 into RIOT-OS:master Aug 5, 2020
RIOT Sprint Day automation moved this from Waiting For Murdock to Done Aug 5, 2020
@maribu
Copy link
Member

maribu commented Aug 5, 2020

Thanks @kaspar030! This was a big one :-)

@kaspar030 kaspar030 deleted the update_msp430 branch August 5, 2020 19:11
@kaspar030
Copy link
Contributor Author

Thanks a lot for reviewing!

@benpicco
Copy link
Contributor

benpicco commented Oct 7, 2020

fyi: Since msp430 has newlib support, adding support to picolibc should be rather straightforward.

That should bring the ROM size down again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Impact: major The PR changes a significant part of the code base. It should be reviewed carefully Platform: MSP Platform: This PR/issue effects MSP-based platforms Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
8 participants