Skip to content

board: arduino-mega2560: use uart_stdio#3426

Merged
PeterKietzmann merged 3 commits intoRIOT-OS:masterfrom
kaspar030:make_arduino-mega2560_use_uart_stdio
Sep 3, 2015
Merged

board: arduino-mega2560: use uart_stdio#3426
PeterKietzmann merged 3 commits intoRIOT-OS:masterfrom
kaspar030:make_arduino-mega2560_use_uart_stdio

Conversation

@kaspar030
Copy link
Copy Markdown
Contributor

This removes uart0 support and makes the port use shared uart_stdio code instead.

I don't remember where, but someone reported this patch doesn't work correctly. I don't have the board, so I can't debug. Volunteers?

(I marked it "waiting for other PR" as this breaks all tests that use uart0 without #3402)

@kaspar030 kaspar030 added State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation State: waiting for other PR State: The PR requires another PR to be merged first labels Jul 16, 2015
@kaspar030 kaspar030 force-pushed the make_arduino-mega2560_use_uart_stdio branch from 7c44626 to b715d95 Compare July 16, 2015 07:42
@kaspar030
Copy link
Copy Markdown
Contributor Author

@PeterKietzmann
Copy link
Copy Markdown
Member

@ReneHerthel can you test this? I can give it a try tomorrow if Rene is not on it then.

@kaspar030
Copy link
Copy Markdown
Contributor Author

Someone said there was a problem with strings longer than "help". ;)

@PeterKietzmann
Copy link
Copy Markdown
Member

Really :-) ?

@PeterKietzmann
Copy link
Copy Markdown
Member

Still no success on mega2560. Seems to be the same problem like described in #3187. From tests/shell I get:

2015-07-20 09:46:53,567 - INFO # kernel_init(): This is RIOT! (Version: 2014.12-2372-g06c18-kaspar_mega2560_uart)
2015-07-20 09:46:53,579 - INFO # kernel_init(): jumping into first task...
2015-07-20 09:46:53,583 - INFO # test_shell.
help
2015-07-20 09:46:58,331 - INFO # > help
2015-07-20 09:46:58,339 - INFO # Command              Description
2015-07-20 09:46:58,351 - INFO # ---------------------------------------
2015-07-20 09:46:58,359 - INFO # start_test           starts a test
2015-07-20 09:46:58,367 - INFO # end_test             ends a test
2015-07-20 09:46:58,380 - INFO # echo                 prints the input command
2015-07-20 09:46:58,392 - INFO # reboot               Reboot the node
2015-07-20 09:46:58,408 - INFO # ps                   Prints information about running threads.
start_test hello



2015-07-20 09:47:20,450 - INFO # > star> E> > > > hY> > K> sW> > }> > > > > hello> sta.> E> > > > hello
2015-07-20 09:47:20,458 - INFO # shell: command not found:
2015-07-20 09:47:20,459 - INFO # hello

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

shell_commands

@PeterKietzmann
Copy link
Copy Markdown
Member

PR looks reasonable as far as I can evaluate this. The Atmega has the same problems than before. On the stm32f4discovery everything seems to be fine

@OlegHahm OlegHahm added the Platform: AVR Platform: This PR/issue effects AVR-based platforms label Jul 20, 2015
@kaspar030
Copy link
Copy Markdown
Contributor Author

@PeterKietzmann could you try not using pyterm? Maybe pyterm sends the characters too fast...

edit or try a very low baudrate, e.g. 9600?

@PeterKietzmann
Copy link
Copy Markdown
Member

@kaspar030 with minicom @38400 baud it looks fine. With pyterm @9600 baud it looks also fine. Pyterm @38400 baud is still "buggy"

@kaspar030
Copy link
Copy Markdown
Contributor Author

Well, our current design issues one interrupt per character, which might be too much for the little AVR. I'll change to 9600 for now, until we come up with a more efficient solution.

@kaspar030
Copy link
Copy Markdown
Contributor Author

@PeterKietzmann Could you try one thing:

Add while (!UART0_DTREG_EMPTY) before line 279 in cpu/atmega2560/periph/uart.c, so the callback gets called as long as there's data available?

Maybe the UART has a buffer, so reading in a loop might fix the issue.

@kaspar030
Copy link
Copy Markdown
Contributor Author

The datasheet states the Atmel has a two-byte buffer, so this might actually help.

@kaspar030
Copy link
Copy Markdown
Contributor Author

@PeterKietzmann Sorry, wrong flag, correct is
while (!UART0_RECEIVED_DATA).

@9600
Copy link
Copy Markdown

9600 commented Jul 31, 2015

@PeterKietzmann hey, thanks for letting me know!

@kaspar030
Copy link
Copy Markdown
Contributor Author

:)

@PeterKietzmann
Copy link
Copy Markdown
Member

@kaspar030 sorry, I don't want to get into the datasheet right now. When exactly is this flag set? Calling the callback until the flag is unset brings no inputs to pyterm anymore. Again, with minicom 38400 baud worked. In general I'd be also fine with a default of 9600 baud on that platform.
@9600 thanks for letting you know what exactly :-) ?

@9600
Copy link
Copy Markdown

9600 commented Jul 31, 2015

@PeterKietzmann about this discussion. You AT'ed me.

@kaspar030
Copy link
Copy Markdown
Contributor Author

@PeterKietzmann Sorry again, my logic was wrong. Please try again with
while (UART0_RECEIVED_DATA) (without the !).
That flag should be set as long as there's a byte available.

@PeterKietzmann
Copy link
Copy Markdown
Member

@9600 sorry. I didn't realize what I did at first :-), sorry for the interruption.

@PeterKietzmann
Copy link
Copy Markdown
Member

@kaspar030 the your idea seems reasonable to me but still if have the problem, that longer strings don't work. E.g. ps works but the other commands don't

@kaspar030
Copy link
Copy Markdown
Contributor Author

@PeterKietzmann Ok, thanks for trying! Let's set to 9600baud for now.

@kaspar030 kaspar030 removed the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Jul 31, 2015
@PeterKietzmann PeterKietzmann mentioned this pull request Aug 27, 2015
10 tasks
@kaspar030 kaspar030 removed the State: waiting for other PR State: The PR requires another PR to be merged first label Sep 3, 2015
@kaspar030
Copy link
Copy Markdown
Contributor Author

  • rebased, all dependencies merged

@kaspar030
Copy link
Copy Markdown
Contributor Author

@PeterKietzmann Could you take another look?

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Sep 3, 2015

With master on default on arduino-mega2560 I get output, but input (shell) isn't working. With the current state of this PR, I get neither input nor output.

@kaspar030
Copy link
Copy Markdown
Contributor Author

Hm, too bad. I remember this was working in @PeterKietzmann's tests. We had to lower the baudrate to 9600 baud, but still.... Unfortunately I don't have a board to test.

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Sep 3, 2015

Ah, didn't read about the baudrate.

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Sep 3, 2015

With 9600 baud it's working indeed.

@PeterKietzmann
Copy link
Copy Markdown
Member

But the baudrate should be changed within the third commit?!

With the current state of this PR, I get neither input nor output.

@OlegHahm is this still current?

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Sep 3, 2015

As I said, with 9600 baud it's working, yes.

@kaspar030
Copy link
Copy Markdown
Contributor Author

Nice. Question would be, why is there no output at higher baudrate with this PR? Anyways, would you guys ACK this?

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Sep 3, 2015

Question would be, why is there no output at higher baudrate with this PR?

No, sorry, I was imprecise. This has been a case of PEBCAK: I called pyterm manually with the wrong baudrate.

Anyways, would you guys ACK this?

ACK - slow shell is better than no shell.

@PeterKietzmann
Copy link
Copy Markdown
Member

:-) @OlegHahm I agree. IIRC with other terminal programs (e.g. minicom) the higher baud rate worked, but not in pyterm. Anyway, I didn't re-test this PR but ACK for the state from some weeks ago

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Sep 3, 2015

Wait! Now you made me curious and I reverted the last commit. Still working. With 115200 baud and pyterm.

Edit: Just realized that the baudrate is 38400 then.

@kaspar030
Copy link
Copy Markdown
Contributor Author

@PeterKietzmann Do you think you could quickly test with 38400 and 115200 baud? fast shell is better than slow shell. :)

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Sep 3, 2015

115200 is not working.

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Sep 3, 2015

I still get the output, but shell isn't working.

@kaspar030
Copy link
Copy Markdown
Contributor Author

So I revert the 9600 baud commit? Whatever you're more likely to ACK.

@PeterKietzmann
Copy link
Copy Markdown
Member

Will do, moment

@PeterKietzmann
Copy link
Copy Markdown
Member

I see the same problems with 38400 baud as before. IMO you should not revert that commit

@PeterKietzmann
Copy link
Copy Markdown
Member

@OlegHahm pleas try tests/shell and use the commands start_test or echo hello oleg

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Sep 3, 2015

Works like charm:

`--> BOARD=arduino-mega2560 make term
/home/oleg/git/RIOT/dist/tools/pyterm/pyterm -b 38400 -p /dev/ttyACM0
2015-09-03 17:24:55,740 - INFO # Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.
start_test
2015-09-03 17:25:01,035 - INFO # > start_test
2015-09-03 17:25:01,039 - INFO # [TEST_START]
echo hello oleg
2015-09-03 17:25:06,307 - INFO # > echo hello oleg
2015-09-03 17:25:06,315 - INFO # “echo” “hello” “oleg” 
echo 123456789012345678901234567890
2015-09-03 17:25:21,066 - INFO # > echo 123456789012345678901234567890
2015-09-03 17:25:21,078 - INFO # “echo” “123456789012345678901234567890” 

@PeterKietzmann
Copy link
Copy Markdown
Member

Hm. Do you have an original arduino board or is yours also from Funduino?

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Sep 3, 2015

How do I figuret that out? Mine has printed SainSmart on the PCB.

@PeterKietzmann
Copy link
Copy Markdown
Member

Well, seems to be just an other supplier. Anyway, @ReneHerthel and me both have the Mega2560 by Funduino and both of us experienced problems with shell examples when initialized at 38400 baud. Is this reason enough to merge it with 9600 baud per default? Maybe one could add a comment in the peripheral configuration or elsewhere

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Sep 3, 2015

I'm fine with 9600 baud. ACK

@PeterKietzmann
Copy link
Copy Markdown
Member

And go

PeterKietzmann added a commit that referenced this pull request Sep 3, 2015
…t_stdio

board: arduino-mega2560: use uart_stdio
@PeterKietzmann PeterKietzmann merged commit ef000d4 into RIOT-OS:master Sep 3, 2015
@kaspar030 kaspar030 deleted the make_arduino-mega2560_use_uart_stdio branch February 7, 2017 22:11
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 Platform: AVR Platform: This PR/issue effects AVR-based platforms Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants