ptka commented on a change in pull request #5249:
URL: https://github.com/apache/incubator-nuttx/pull/5249#discussion_r786301316



##########
File path: drivers/usbdev/cdcecm.c
##########
@@ -120,7 +120,7 @@ struct cdcecm_driver_s
   FAR struct usbdev_ep_s      *epbulkout;   /* Bulk OUT endpoint */
   uint8_t                      config;      /* Selected configuration number */
 
-  uint8_t                      pktbuf[CONFIG_NET_ETH_PKTSIZE +
+  aligned_data(2) uint8_t      pktbuf[CONFIG_NET_ETH_PKTSIZE +

Review comment:
       I double checked it on my target ...
   
   /1/ original code --> crash due to odd address of 'type' element
   
   NuttX  10.2.0 09be64bb1f-dirty Jan 17 2022 22:30:03 arm pimoroni-tiny2040
   nsh> conn
   self =0x200091f0 --> aligned address for allocated memory
   self-dev.d_buf =0x20009231 --> odd address for 'pktbuf'
   &(BUF->type) =0x2000923d --> odd address for 'type'
   conn_main: Exiting
   
   /2/ modified version using uint16_t ptkbuf --> working as 'type' is now 
16bit aligned
   
   NuttX  10.2.0 09be64bb1f-dirty Jan 17 2022 22:35:28 arm pimoroni-tiny2040
   nsh> conn
   conn_main: Performing architecture-specific initialization
   self =0x200091f0 --> aligned address for allocated memory
   self-dev.d_buf =0x20009232 --> even address for 'pktbuf'
   &(BUF->type) =0x2000923e --> even address for 'type'
   conn_main: Exiting
   
   /3/ your proposal --> crash
   
   NuttX  10.2.0 09be64bb1f-dirty Jan 17 2022 22:40:23 arm pimoroni-tiny2040
   nsh> conn
   conn_main: Performing architecture-specific initialization
   self =0x200091f0
   self-dev.d_buf =0x20009231
   &(BUF->type) =0x2000923d
   conn_main: Exiting
   
   Command used from 'make -j8' to compile cdcecm.c:
   
   CC:  usbdev/cdcecm.c
   arm-none-eabi-gcc -c -fno-builtin -Wall -Wstrict-prototypes -Wshadow -Wundef 
-g -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -isystem 
"/Users/piet/Projects/NuttX/tiny2040-composite/nuttx/include" -D__NuttX__ 
-D__KERNEL__  -pipe -I 
"/Users/piet/Projects/NuttX/tiny2040-composite/nuttx/drivers/bch" -I 
"/Users/piet/Projects/NuttX/tiny2040-composite/nuttx/drivers/crypto" -I 
"/Users/piet/Projects/NuttX/tiny2040-composite/nuttx/drivers/motor" -I 
"/Users/piet/Projects/NuttX/tiny2040-composite/nuttx/drivers/loop" -I 
"/Users/piet/Projects/NuttX/tiny2040-composite/nuttx/drivers/mmcsd"  -I 
"/Users/piet/Projects/NuttX/tiny2040-composite/nuttx/drivers/spi" -I 
"/Users/piet/Projects/NuttX/tiny2040-composite/nuttx/drivers/usbdev" -I 
"/Users/piet/Projects/NuttX/tiny2040-composite/nuttx/drivers/usbhost"   
usbdev/cdcecm.c -o  cdcecm.o
   




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

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


Reply via email to