You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2020/06/03 23:32:14 UTC

[GitHub] [mynewt-core] utzig opened a new pull request #2302: stm32: fix invalid uart access

utzig opened a new pull request #2302:
URL: https://github.com/apache/mynewt-core/pull/2302


   This fixes and invalid access when only UART_1, or UART_2 are enabled.
   
   The uarts structure in memory is allocated according to the number of uarts enabled. When only UART_2 is enabled for example, only 1 element of uarts is enabled, but when trying to access it the index 2 was being used. This commit adds a helper function that fixes the indexing.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on pull request #2302: stm32: fix invalid uart access

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on pull request #2302:
URL: https://github.com/apache/mynewt-core/pull/2302#issuecomment-638524110


   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on pull request #2302: stm32: fix invalid uart access

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on pull request #2302:
URL: https://github.com/apache/mynewt-core/pull/2302#issuecomment-638514736


   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-core] utzig commented on pull request #2302: stm32: fix invalid uart access

Posted by GitBox <gi...@apache.org>.
utzig commented on pull request #2302:
URL: https://github.com/apache/mynewt-core/pull/2302#issuecomment-638515126


   > anyway I believe the solution is correct! :-P
   
   Hmmm, maybe not, `if (port < 0 || port >= UART_CNT)`, this code will not allow it to work. Will fix and test tomorrow.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2302: stm32: fix invalid uart access

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on pull request #2302:
URL: https://github.com/apache/mynewt-core/pull/2302#issuecomment-638524110


   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-core] kasjer commented on a change in pull request #2302: stm32: fix invalid uart access

Posted by GitBox <gi...@apache.org>.
kasjer commented on a change in pull request #2302:
URL: https://github.com/apache/mynewt-core/pull/2302#discussion_r435527140



##########
File path: hw/mcu/stm/stm32_common/src/hal_uart.c
##########
@@ -38,6 +38,31 @@ struct hal_uart {
     const struct stm32_uart_cfg *u_cfg;
 };
 static struct hal_uart uarts[UART_CNT];
+static struct hal_uart *
+uart_index_by_port(int port)

Review comment:
       Function name is misleading, It does not return index.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-core] utzig commented on pull request #2302: stm32: fix invalid uart access

Posted by GitBox <gi...@apache.org>.
utzig commented on pull request #2302:
URL: https://github.com/apache/mynewt-core/pull/2302#issuecomment-640031011


   @kasjer @wes3 The reported issues were fixed, plus a few places where invalid accesses could happen. I added a new commit for the nucleo-f439zi which allows to use another UART and did some proper testing.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-core] kasjer commented on a change in pull request #2302: stm32: fix invalid uart access

Posted by GitBox <gi...@apache.org>.
kasjer commented on a change in pull request #2302:
URL: https://github.com/apache/mynewt-core/pull/2302#discussion_r435528721



##########
File path: hw/mcu/stm/stm32_common/src/hal_uart.c
##########
@@ -194,12 +216,9 @@ hal_uart_blocking_tx(int port, uint8_t data)
     struct hal_uart *u;
     USART_TypeDef *regs;
 
-    if (port < 0 || port >= UART_CNT) {
-        return;
-    }
-    u = &uarts[port];
-    if (!u->u_open) {
-        return;
+    u = uart_index_by_port(port);
+    if (!u || u->u_open) {
+        return -1;

Review comment:
       Original return did not have -1




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-core] wes3 commented on pull request #2302: stm32: fix invalid uart access

Posted by GitBox <gi...@apache.org>.
wes3 commented on pull request #2302:
URL: https://github.com/apache/mynewt-core/pull/2302#issuecomment-638563072


   @utzig Hey Fabio. I will wait for the changes to approve the PR. It looks good though but I do agree you should add the check that was deleted.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-core] utzig merged pull request #2302: stm32: fix invalid uart access

Posted by GitBox <gi...@apache.org>.
utzig merged pull request #2302:
URL: https://github.com/apache/mynewt-core/pull/2302


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2302: stm32: fix invalid uart access

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on pull request #2302:
URL: https://github.com/apache/mynewt-core/pull/2302#issuecomment-640030984


   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-core] utzig commented on pull request #2302: stm32: fix invalid uart access

Posted by GitBox <gi...@apache.org>.
utzig commented on pull request #2302:
URL: https://github.com/apache/mynewt-core/pull/2302#issuecomment-638514509


   This was first reported by @wes3. Unfortunately I am short on time to test it today, will try tomorrow (anyway I believe the solution is correct! :-P)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2302: stm32: fix invalid uart access

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on pull request #2302:
URL: https://github.com/apache/mynewt-core/pull/2302#issuecomment-638514736


   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org