yjdwbj opened a new issue #2276:
URL: https://github.com/apache/incubator-nuttx/issues/2276


   
   Hi, guys , I have one Atmel sam4s-xplained-pro board, when I using the nuttx 
os find some issues. the built-in
   
![396333136](https://user-images.githubusercontent.com/321919/98649579-ba134100-2372-11eb-8927-769381ffb72c.jpg)
   
![72517149](https://user-images.githubusercontent.com/321919/98649589-bc759b00-2372-11eb-89e4-faa69cbc5e10.jpg)
   
    MMCSD can't work. following is my testing steps.
   
   ```sh
   ~$ tools/configure.sh sam4s-xplained-pro:nsh
   
   ~$ make && openocd -f board/atmel_sam4s_xplained_pro.cfg -c init -c "reset 
halt" -c "flash write_image erase nuttx.bin 0x00400000" -c "reset"
   
   Open On-Chip Debugger 0.10.0+dev-01447-g91c4c83f4-dirty (2020-11-04-12:11)
   Licensed under GNU GPL v2
   For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
   Info : auto-selecting first available session transport "swd". To override 
use 'transport select <transport>'.
   Info : CMSIS-DAP: SWD  Supported
   Info : CMSIS-DAP: JTAG Supported
   Info : CMSIS-DAP: FW Version = 1.0
   Info : CMSIS-DAP: Serial# = ATML1803040200001055
   Info : CMSIS-DAP: Interface Initialised (SWD)
   Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
   Info : CMSIS-DAP: Interface ready
   Info : clock speed 500 kHz
   Info : SWD DPIDR 0x2ba01477
   Info : ATSAM4SD32C.cpu: hardware has 6 breakpoints, 4 watchpoints
   Info : starting gdb server for ATSAM4SD32C.cpu on 3333
   Info : Listening on port 3333 for gdb connections
   target halted due to debug-request, current mode: Thread 
   xPSR: 0x01000000 pc: 0x004000cc msp: 0x20001d00
   Info : sam4 does not auto-erase while programming (Erasing relevant sectors)
   Info : sam4 First: 0x00000000 Last: 0x0000000d
   Info : Erasing sector: 0x00000000
   Info : Erasing sector: 0x00000001
   Info : Erasing sector: 0x00000002
   Info : Erasing sector: 0x00000003
   Info : Erasing sector: 0x00000004
   Info : Erasing sector: 0x00000005
   Info : Erasing sector: 0x00000006
   Info : Erasing sector: 0x00000007
   Info : Erasing sector: 0x00000008
   Info : Erasing sector: 0x00000009
   Info : Erasing sector: 0x0000000a
   Info : Erasing sector: 0x0000000b
   Info : Erasing sector: 0x0000000c
   Info : Erasing sector: 0x0000000d
   auto erase enabled
   wrote 114688 bytes from file nuttx.bin in 5.806748s (19.288 KiB/s)
   
   Info : Listening on port 6666 for tcl connections
   Info : Listening on port 4444 for telnet connections
   Info : ATSAM4SD32C.cpu: external reset detected
   Info : ATSAM4SD32C.cpu: external reset detected
   ```
   Don't have any errors  during  did above steps. but the board reset each 5 
seconds. Then I review the .config find content like a s below:
   
   ```sh
   ~$ grep "WDT" .config
   CONFIG_SAM34_WDT=y
   CONFIG_WDT_ENABLED_ON_RESET=y
   # CONFIG_WDT_DISABLE_ON_RESET is not set
   CONFIG_WDT_TIMEOUT=5000
   CONFIG_WDT_MINTIME=2500
   CONFIG_WDT_THREAD=y
   CONFIG_WDT_THREAD_NAME="wdog"
   CONFIG_WDT_THREAD_INTERVAL=2500
   CONFIG_WDT_THREAD_PRIORITY=200
   CONFIG_WDT_THREAD_STACKSIZE=512
   ```
   And, I changed the config and then rebuild it.
   
   ```sh
   grep "WDT" .config
   CONFIG_SAM34_WDT=y
   CONFIG_WDT_ENABLED_ON_RESET=y
   CONFIG_WDT_DISABLE_ON_RESET=y
   ```
   
   reset problem is disappeared. If reset before had have insert the SD Card, 
the system likely to stuck or freeze, nsh shell can't allow input anything.
   
   ```
   BD                                                                           
                                                                                
                                 
   Registering CDC/ACM serial driver                                            
                                                                                
                                 
   initializing HSMCI                                                           
                                                                                
                                 
   sam_waitresponse: ERROR: cmd: 00008101 events: 009b0001 SR: 0410c0e4         
                                                                                
                                 
   mmcsd_sendcmdpoll: ERROR: Wait for response to cmd: 00008101 failed: -116    
                                                                                
                                 
   mmcsd_cardidentify: ERROR: CMD1 RECVR3: -22                                  
                                                                                
                                 
   sam_waitresponse: ERROR: cmd: 00000208 events: 009b0001 SR: 0410c0e4         
                                                                                
                                 
   mmcsd_sendcmdpoll: ERROR: Wait for response to cmd: 00000208 failed: -116    
                                                                                
                                 
   mmsd_recv_r1: ERROR: R1=00400120                                             
                                                                                
                                 
   mmcsd_cardidentify: ERROR: mmsd_recv_r1(CMD55) failed: -5                    
                                                                                
                                 
   BD                                                                           
                                                                                
                                 
   Registering CDC/ACM serial driver                                            
                                                                                
                                 
   initializing HSMCI                                                           
                                                                                
                                 
   sam_waitresponse: ERROR: cmd: 00008101 events: 009b0001 SR: 0410c0e4         
                                                                                
                                 
   mmcsd_sendcmdpoll: ERROR: Wait for response to cmd: 00008101 failed: -116    
                                                                                
                                 
   mmcsd_cardidentify: ERROR: CMD1 RECVR3: -22                                  
                                                                                
                                 
   sam_waitresponse: ERROR: cmd: 00000208 events: 009b0001 SR: 0410c0e4         
                                                                                
                                 
   mmcsd_sendcmdpoll: ERROR: Wait for response to cmd: 00000208 failed: -116    
                                                                                
                                 
   mmsd_recv_r1: ERROR: R1=00400120                                             
                                                                                
                                 
   mmcsd_cardidentify: ERROR: mmsd_recv_r1(CMD55) failed: -5         
   ```
   
   reset board before not have insert SD Card. 
   
   ```sh
   nsh> BD                                                                      
                                                                                
                                 
   Registering CDC/ACM serial driver                                            
                                                                                
                                 
   initializing HSMCI                                                           
                                                                                
                                 
   Mounting procfs to /proc                                                     
                                                                                
                                 
   Mounting /dev/mmcsd0 to /fat                                                 
                                                                                
                                 
   nx_mount: ERROR: Bind method failed: -19                                     
                                                                                
                                 
   ERROR: Failed to mount the FAT filesystem: -1 (19)                           
                                                                                
                                 
                                                                                
                                                                                
                                 
   NuttShell (NSH) NuttX-9.1.0                                                  
                                                                                
                                 
   nsh> BD                                                                      
                                                                                
                                 
   Registering CDC/ACM serial driver                                            
                                                                                
                                 
   initializing HSMCI                                                           
                                                                                
                                 
   Mounting procfs to /proc                                                     
                                                                                
                                 
   Mounting /dev/mmcsd0 to /fat                                                 
                                                                                
                                 
   nx_mount: ERROR: Bind method failed: -19                                     
                                                                                
                                 
   ERROR: Failed to mount the FAT filesystem: -1 (19)                           
                                                                                
                                 
                                                                                
                                                                                
                                 
   NuttShell (NSH) NuttX-9.1.0                                                  
                                                                                
                                 
   nsh> 
   ```
   following is  more detail debug output.
   reset board before not have insert SD Card. when `nsh shell` has ready  and 
then insert a SD card .
   
   ```sh
   BD                                                                           
                                                                                
                                 
   Registering CDC/ACM serial driver                                            
                                                                                
                                 
   initializing HSMCI                                                           
                                                                                
                                 
   sam_hsmci_initialize: Initializing SDIO                                      
                                                                                
                                 
   mmcsd_slotinitialize: minor: 0                                               
                                                                                
                                 
   mmcsd_hwinitialize: DMA supported: 1                                         
                                                                                
                                 
   mmcsd_hwinitialize: Attached MMC/SD interrupts                               
                                                                                
                                 
   mmcsd_slotinitialize: MMC/SD slot is empty                                   
                                                                                
                                 
   sam_cardinserted: Slot 0 inserted: NO                                        
                                                                                
                                 
   Mounting procfs to /proc                                                     
                                                                                
                                 
   Mounting /dev/mmcsd0 to /fat                                                 
                                                                                
                                 
   find_blockdriver: pathname="/dev/mmcsd0"                                     
                                                                                
                                 
   mmcsd_open: Entry                                                            
                                                                                
                                 
   mmcsd_geometry: Entry                                                        
                                                                                
                                 
   mmcsd_geometry: IS_EMPTY                                                     
                                                                                
                                 
   nx_mount: ERROR: Bind method failed: -19                                     
                                                                                
                                 
   ERROR: Failed to mount the FAT filesystem: -1 (19)                           
                                                                                
                                 
                                                                                
                                                                                
                                 
   NuttShell (NSH) NuttX-9.1.0                                                  
                                                                                
                                 
   nsh> sam_cardinserted: Slot 0 inserted: YES                                  
                                                                                
                                 
   sam_cardinserted: Slot 0 inserted: YES                                       
                                                                                
                                 
   mmcsd_mediachange: arg: 0x200051c0                                           
                                                                                
                                 
   mmcsd_probe: type: 0 probed: 0                                               
                                                                                
                                 
   mmcsd_removed: type: 0 present: 1                                            
                                                                                
                                 
   sam_waitresponse: ERROR: cmd: 00008101 events: 009b0001 SR: 0410c0e4         
                                                                                
                                 
   mmcsd_sendcmdpoll: ERROR: Wait for response to cmd: 00008101 failed: -116    
                                                                                
                                 
   mmcsd_cardidentify: ERROR: CMD1 RECVR3: -22                                  
                                                                                
                                 
   mmcsd_cardidentify: SD V2.x card         
   mmcsd_cardidentify: R3: 00ff8000                                             
                                                                                
                           
    [.... a lot of repeat  here .....]                                          
                                                  
   mmcsd_cardidentify: R3: 00ff8000                                             
                                                                                
                                 
   mmcsd_cardidentify: R3: c0ff8000                                             
                                                                                
                                 
   mmcsd_cardidentify: SD V2.x card with block addressing                       
                                                                                
                                 
   mmcsd_decode_cid: mid: 02 oid: 544d pnm: SA08G prv: 7 psn: 1107393314 mdt: 
c6 crc: 7e                                                                      
                                   
   mmcsd_sdinitialize: RCA: 1234                                                
                                                                                
                                 
   mmcsd_decode_csd: CSD:                                                       
                                                                                
                                 
   mmcsd_decode_csd:   CSD_STRUCTURE: 1 SPEC_VERS: 0 (MMC)                      
                                                                                
                                 
   mmcsd_decode_csd:   TAAC {TIME_UNIT: 6 TIME_VALUE: 1} NSAC: 0                
                                                                                
                                 
   mmcsd_decode_csd:   TRAN_SPEED {TRANSFER_RATE_UNIT: 2 TIME_VALUE: 6}         
                                                                                
                                 
   mmcsd_decode_csd:   CCC: 1461                                                
                                                                                
                                 
   mmcsd_decode_csd:   READ_BL_LEN: 9 READ_BL_PARTIAL: 0                        
                                                                                
                                 
   mmcsd_decode_csd:   WRITE_BLK_MISALIGN: 0 READ_BLK_MISALIGN: 0               
                                                                                
                                 
   mmcsd_decode_csd:   DSR_IMP: 0                                               
                                                                                
                                 
   mmcsd_decode_csd:   SD Block Addressing:                                     
                                                                                
                                 
   mmcsd_decode_csd:     C_SIZE: 15199 SD_ER_BLK_EN: 1                          
                                                                                
                                 
   mmcsd_decode_csd:     SD_SECTOR_SIZE: 127 SD_WP_GRP_SIZE: 0                  
                                                                                
                                 
   mmcsd_decode_csd:   WP_GRP_EN: 0 MMC DFLT_ECC: 0 (MMC) R2W_FACTOR: 2         
                                                                                
                                 
   mmcsd_decode_csd:   WRITE_BL_LEN: 9 WRITE_BL_PARTIAL: 0                      
                                                                                
                                 
   mmcsd_decode_csd:   FILE_FORMAT_GROUP: 0 COPY: 0                             
                                                                                
                                 
   mmcsd_decode_csd:   PERM_WRITE_PROTECT: 0 TMP_WRITE_PROTECT: 0               
                                                                                
                                 
   mmcsd_decode_csd:   FILE_FORMAT: 0 ECC: 0 (MMC) CRC: 58                      
                                                                                
                                 
   mmcsd_decode_csd: Capacity: 7782400Kb, Block size: 512b, nblocks: 15564800 
wrprotect: 0                                                                    
                                   
   mmsd_decode_scr: SCR:                                                        
                                                                                
                                 
   mmsd_decode_scr:   SCR_STRUCTURE: 0 SD_VERSION: 2                            
                                                                                
                                 
   mmsd_decode_scr:   DATA_STATE_AFTER_ERASE: 0 SD_SECURITY: 3 SD_BUS_WIDTHS: 5 
                                                                                
                                 
   mmsd_decode_scr:   Manufacturing data: 00000001                              
                                                                                
                                 
   mmcsd_widebus: Wide bus operation selected                                   
                                                                                
                                 
                                                                                
                                                                                
                                 
   nsh> ls /dev/mmcsd0                                                          
                                                                                
                                 
   mmcsd_geometry: Entry                                                        
                                                                                
                                 
     # freeze here , can't response any input unless reset it.
   ```
   now , when I access the device name of  `mmcsd0` which will be freeze unless 
reset. Also `mkfatfs` and `mount` command  can't use.
   
   ```sh
   mmcsd_cardidentify: SD V2.x card with block addressing                       
                                                                                
                                 
   mmcsd_decode_cid: mid: 02 oid: 544d pnm: SA08G prv: 7 psn: 1107393314 mdt: 
c6 crc: 7e                                                                      
                                   
   mmcsd_sdinitialize: RCA: 1234                                                
                                                                                
                                 
   mmcsd_decode_csd: CSD:                                                       
                                                                                
                                 
   mmcsd_decode_csd:   CSD_STRUCTURE: 1 SPEC_VERS: 0 (MMC)                      
                                                                                
                                 
   mmcsd_decode_csd:   TAAC {TIME_UNIT: 6 TIME_VALUE: 1} NSAC: 0                
                                                                                
                                 
   mmcsd_decode_csd:   TRAN_SPEED {TRANSFER_RATE_UNIT: 2 TIME_VALUE: 6}         
                                                                                
                                 
   mmcsd_decode_csd:   CCC: 1461                                                
                                                                                
                                 
   mmcsd_decode_csd:   READ_BL_LEN: 9 READ_BL_PARTIAL: 0                        
                                                                                
                                 
   mmcsd_decode_csd:   WRITE_BLK_MISALIGN: 0 READ_BLK_MISALIGN: 0               
                                                                                
                                 
   mmcsd_decode_csd:   DSR_IMP: 0                                               
                                                                                
                                 
   mmcsd_decode_csd:   SD Block Addressing:                                     
                                                                                
                                 
   mmcsd_decode_csd:     C_SIZE: 15199 SD_ER_BLK_EN: 1                          
                                                                                
                                 
   mmcsd_decode_csd:     SD_SECTOR_SIZE: 127 SD_WP_GRP_SIZE: 0                  
                                                                                
                                 
   mmcsd_decode_csd:   WP_GRP_EN: 0 MMC DFLT_ECC: 0 (MMC) R2W_FACTOR: 2         
                                                                                
                                 
   mmcsd_decode_csd:   WRITE_BL_LEN: 9 WRITE_BL_PARTIAL: 0                      
                                                                                
                                 
   mmcsd_decode_csd:   FILE_FORMAT_GROUP: 0 COPY: 0                             
                                                                                
                                 
   mmcsd_decode_csd:   PERM_WRITE_PROTECT: 0 TMP_WRITE_PROTECT: 0               
                                                                                
                                 
   mmcsd_decode_csd:   FILE_FORMAT: 0 ECC: 0 (MMC) CRC: 58                      
                                                                                
                                 
   mmcsd_decode_csd: Capacity: 7782400Kb, Block size: 512b, nblocks: 15564800 
wrprotect: 0                                                                    
                                   
   mmsd_decode_scr: SCR:                                                        
                                                                                
                                 
   mmsd_decode_scr:   SCR_STRUCTURE: 0 SD_VERSION: 2                            
                                                                                
                                 
   mmsd_decode_scr:   DATA_STATE_AFTER_ERASE: 0 SD_SECURITY: 3 SD_BUS_WIDTHS: 5 
                                                                                
                                 
   mmsd_decode_scr:   Manufacturing data: 00000001                              
                                                                                
                                 
   mmcsd_widebus: Wide bus operation selected                                   
                                                                                
                                 
                                                                                
                                                                                
                                 
   nsh>                                                                         
                                                                                
                                 
   nsh> mount -t vfat /dev/mmcsd0 /mnt                                          
                                                                                
                                 
   find_blockdriver: pathname="/dev/mmcsd0"                                     
                                                                                
                                 
   mmcsd_open: Entry                                                            
                                                                                
                                 
   
   ``


----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to