Skip to content

cpu: Moved stdio_init() prior to periph_init() for ARM targets#11367

Merged
kaspar030 merged 2 commits intoRIOT-OS:masterfrom
maribu:arm_early_stdio
Sep 9, 2019
Merged

cpu: Moved stdio_init() prior to periph_init() for ARM targets#11367
kaspar030 merged 2 commits intoRIOT-OS:masterfrom
maribu:arm_early_stdio

Conversation

@maribu
Copy link
Copy Markdown
Member

@maribu maribu commented Apr 10, 2019

Contribution description

In current RIOT master stdio_init() is called via newlib's _init(), which is way too late during boot up to allow DEBUG()ing during periph_init(). This PR moves stdio_init() into cpu_init() just before periph_init() is called.

Testing procedure

Flash and run examples/default and interact with the shell. Input and output should still work as expected.

Boards using these CPUs:

  • cc2538 (@dylad tested on firefly remotely on iotlab)
  • cc26x0 (@MrKevinWeiss tested on cc2650-launchpad)
  • efm32 (@MrKevinWeiss tested on slstk3402a)
  • ezr32wg
  • lm4f120
  • lpc1768 (@MrKevinWeiss tested on mbed-lpc1768)
  • nrf51 (@dylad tested on nrf51dk remotely on iotlab)
  • nrf52 (@maribu tested with nrf42840dk)
  • sam3
  • samd21 (@dylad tested on arduino-zero remotely on iotlab)
  • samd51 (@dylad tested with SAME54-XPRO)
  • saml1x(@dylad tested with SAML10-XPRO and SAML11-XPRO)
  • saml21(@dylad tested with SAML21-XPRO)
  • STM32-F1* (@MrKevinWeiss tested on nucleo-f103rb)
  • STM32-F2* (@MrKevinWeiss tested on nucleo-f207zg)
  • STM32-F3* (@maribu tested with nucleo-f303re)
  • STM32-F4* (@MrKevinWeiss tested on nucleo-f413zh)
  • STM32-F7* (@maribu tested with nucleo-f767zi)
  • STM32-L0* (@fjmolinas tested with b-l072z-lrwan1)
  • STM32-L1* (@MrKevinWeiss tested on nucleo-l152re)
  • STM32-L4* (@MrKevinWeiss tested on nucleo-l433rc)
  • KINETIS-KW (@fjmolinas tested with frdm-kw41z, pba-d-01-kw2x)
  • KINETIS-KW (@fjmolinas tested with frdm-k64f)
  • KINETIS-EA

Boards with custom/weird boot up sequence:

Issues/PRs references

Spun out of / partly replaces #10806

@maribu maribu added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Platform: ARM Platform: This PR/issue effects ARM-based platforms labels Apr 10, 2019
@dylad dylad added this to the Release 2019.07 milestone May 23, 2019
Copy link
Copy Markdown
Member

@dylad dylad left a comment

Choose a reason for hiding this comment

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

Missing changes in cpu/saml21/cpu.c

@maribu
Copy link
Copy Markdown
Member Author

maribu commented May 24, 2019

@dylad: Thanks for pointing that out. The latest fixup should address this :-)

@dylad
Copy link
Copy Markdown
Member

dylad commented May 24, 2019

@maribu
kinetis are also missing. I think this is the last missing family.

@maribu
Copy link
Copy Markdown
Member Author

maribu commented May 24, 2019

kinetis are also missing. I think this is the last missing family.

Done. Thanks for spotting that!

@dylad
Copy link
Copy Markdown
Member

dylad commented Jun 5, 2019

@kaspar030 @MrKevinWeiss @smlng @aabadie @basilfx
May I ask you some help with testing there ? I know you own some of the listed boards ;)
This should be pretty straightforward !

@MrKevinWeiss
Copy link
Copy Markdown
Contributor

I will add it to the list!

@MrKevinWeiss MrKevinWeiss self-requested a review June 6, 2019 08:12
@dylad
Copy link
Copy Markdown
Member

dylad commented Jun 6, 2019

@maribu Could you rebased this PR please ?
with #11305 merged, a new MCU has been introduce so this PR needs to adapt it.
I have the board so I'll be happy to test it with this PR !

@maribu maribu force-pushed the arm_early_stdio branch from 369a786 to adeef37 Compare June 6, 2019 15:35
@maribu
Copy link
Copy Markdown
Member Author

maribu commented Jun 6, 2019

@dylad: Thanks for pointing that out. I rebased and added the call to stdio_init() to samd5x initialization code as well :-)

@dylad
Copy link
Copy Markdown
Member

dylad commented Jun 6, 2019

@maribu Wow so fast thanks !
I can confirm this works on this new MCU.

@dylad
Copy link
Copy Markdown
Member

dylad commented Jun 19, 2019

ping
This would be a nice addition to the incoming release

@MrKevinWeiss
Copy link
Copy Markdown
Contributor

Hmmm, I am a bit busy now. I'll set a reminder for tomorrow morning.

@maribu
Copy link
Copy Markdown
Member Author

maribu commented Jun 19, 2019

@dylad: May I squash and rebase to solve the merge conflict?

@dylad
Copy link
Copy Markdown
Member

dylad commented Jun 19, 2019

@maribu I'm fine with that.

@maribu maribu force-pushed the arm_early_stdio branch from 150e41d to 40e72fc Compare June 19, 2019 12:58
@maribu maribu added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jun 19, 2019
@MrKevinWeiss
Copy link
Copy Markdown
Contributor

Tested on boards labeled above, I flashed default, asked for help, it replied. There have been some issues after the very first flash but a reset after seemed to fix all problems. I was not able to reproduce any issues after so it may be just the initial connection (a lot of fresh boards with manufacture firmware on them)

@MrKevinWeiss
Copy link
Copy Markdown
Contributor

I guess some work on kinetis cpus are still needed.

@dylad
Copy link
Copy Markdown
Member

dylad commented Jun 20, 2019

maybe @fjmolinas could help us with Kinetis there ?

@benemorius
Copy link
Copy Markdown
Member

benemorius commented Jun 20, 2019

Looks like Kinetis is just missing the include for stdio_base.h

@maribu
Copy link
Copy Markdown
Member Author

maribu commented Jun 20, 2019

I guess some work on kinetis cpus are still needed.

Done

Looks like Kinetis is just missing the include for stdio_base.h

Yes, I don't know why I forgot that :-/

@maribu maribu removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jun 20, 2019
@dylad dylad added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Sep 9, 2019
Copy link
Copy Markdown
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

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

ACK on my side.
Work on all (tested) platforms.
Changes look good for untested platforms (ezr32wg and lm4f120)
kinetis-ea shared the same code with others kinetis.
I think it is time to go.

Agree, ACK on my side too.

@kaspar030
Copy link
Copy Markdown
Contributor

This'll make not using stdio a bit more difficult. Before, not using the newlib module was enough to disable stdio. Now we'll have to add guards at multiple points.

Given the time this was waiting, I'm OK with dealing with that when we get there. ;)

@maribu
Copy link
Copy Markdown
Member Author

maribu commented Sep 9, 2019

This'll make not using stdio a bit more difficult. Before, not using the newlib module was enough to disable stdio. Now we'll have to add guards at multiple points.

Why not just overwrite stdio_init() with a nop?

@OYTIS
Copy link
Copy Markdown
Contributor

OYTIS commented Sep 9, 2019

@fjmolinas Sorry, I don't have the board at my disposal any more.

@smlng I believe you've ordered one S9KEAZ128 board for you haven't you?

@kaspar030
Copy link
Copy Markdown
Contributor

Why not just overwrite stdio_init() with a nop?

That's a good idea. Anyhow, unrelated!

@maribu
Copy link
Copy Markdown
Member Author

maribu commented Sep 9, 2019

Merge?

@kaspar030 kaspar030 merged commit 88e07c0 into RIOT-OS:master Sep 9, 2019
@maribu maribu deleted the arm_early_stdio branch September 9, 2019 13:53
@benpicco
Copy link
Copy Markdown
Contributor

benpicco commented Sep 13, 2019

This breaks stdio on esp32 & esp8266 😞
It's also pretty weird to have stdio_init() in boards/ for msba2.

msp430, fe310, atmega, mips… was forgotten by this PR too, I'd assume stdio is broken there too now.

@maribu
Copy link
Copy Markdown
Member Author

maribu commented Sep 14, 2019

If I remeber correctly, only the ESP32, the ESP8266, and RISC-V is also using newlib. I'll create PRs eith fixes for those three tonight.

maribu added a commit to maribu/RIOT that referenced this pull request Sep 14, 2019
- This guarantees that DEBUG() is available early in boot process
- Forgotten in RIOT-OS#11367, fixes broken stdio
maribu added a commit to maribu/RIOT that referenced this pull request Sep 14, 2019
- This guarantees that DEBUG() is available early in boot process
- Forgotten in RIOT-OS#11367, this fixes broken stdio
maribu added a commit to maribu/RIOT that referenced this pull request Sep 14, 2019
- This guarantees that DEBUG() is available early in boot process
- Forgotten in RIOT-OS#11367, this fixes broken i
  stdio
@maribu
Copy link
Copy Markdown
Member Author

maribu commented Sep 14, 2019

OK, the PRs with the fixes are online

maribu added a commit to maribu/RIOT that referenced this pull request Sep 14, 2019
maribu added a commit to maribu/RIOT that referenced this pull request Sep 14, 2019
@maribu
Copy link
Copy Markdown
Member Author

maribu commented Sep 14, 2019

OK, MIPS32 was the last user of newlib. That should be the last missing fix.

maribu added a commit to maribu/RIOT that referenced this pull request Sep 14, 2019
- This guarantees that DEBUG() is available early in boot process
- Forgotten in RIOT-OS#11367, this fixes broken stdio
francois-berder pushed a commit to francois-berder/RIOT that referenced this pull request Sep 14, 2019
- This guarantees that DEBUG() is available early in boot process
- Forgotten in RIOT-OS#11367, this fixes broken stdio
@kb2ma kb2ma added this to the Release 2019.10 milestone Sep 16, 2019
kaspar030 pushed a commit to kaspar030/RIOT that referenced this pull request Sep 16, 2019
- This guarantees that DEBUG() is available early in boot process
- Forgotten in RIOT-OS#11367, this fixes broken i
  stdio
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 CI: run tests If set, CI server will run tests on hardware for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-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.

10 participants