errors/warnings using datalogging shield with Metro M4 Express

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
adavid7
 
Posts: 120
Joined: Fri Jul 04, 2014 7:32 pm

errors/warnings using datalogging shield with Metro M4 Express

Post by adavid7 »

I am trying to use the Adafruit datalogging shield adafruit.com/product/1141 with a Metro M4 Express.

I am using the Arduino SD library (and the Adafruit RTC library)

Code: Select all

#include <SD.h>                      // SD card
#include <RTClib.h>                  // real-time clock
I am getting some warnings from the compiler from within the library, not my code:

Code: Select all

/Users/andy/Documents/Arduino/libraries/SD/src/utility/SdFile.cpp: In member function 'uint8_t SdFile::open(SdFile*, const char*, uint8_t)':
/Users/andy/Documents/Arduino/libraries/SD/src/utility/SdFile.cpp:532:15: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
  532 |     dateTime_(&p->creationDate, &p->creationTime);
      |               ^~~~~~~~~~~~~~~~
/Users/andy/Documents/Arduino/libraries/SD/src/utility/SdFile.cpp:532:15: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
/Users/andy/Documents/Arduino/libraries/SD/src/utility/SdFile.cpp:532:33: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
  532 |     dateTime_(&p->creationDate, &p->creationTime);
      |                                 ^~~~~~~~~~~~~~~~
/Users/andy/Documents/Arduino/libraries/SD/src/utility/SdFile.cpp:532:33: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
/Users/andy/Documents/Arduino/libraries/SD/src/utility/SdFile.cpp: In member function 'uint8_t SdFile::sync(uint8_t)':
/Users/andy/Documents/Arduino/libraries/SD/src/utility/SdFile.cpp:1155:17: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
 1155 |       dateTime_(&d->lastWriteDate, &d->lastWriteTime);
      |                 ^~~~~~~~~~~~~~~~~
/Users/andy/Documents/Arduino/libraries/SD/src/utility/SdFile.cpp:1155:17: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
/Users/andy/Documents/Arduino/libraries/SD/src/utility/SdFile.cpp:1155:36: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
 1155 |       dateTime_(&d->lastWriteDate, &d->lastWriteTime);
      |                                    ^~~~~~~~~~~~~~~~~
/Users/andy/Documents/Arduino/libraries/SD/src/utility/SdFile.cpp:1155:36: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
Sketch uses 43584 bytes (8%) of program storage space. Maximum is 507904 bytes.
Device       : ATSAMD51x19
Version      : v1.1 [Arduino:XYZ] Apr  8 2018 13:59:27
Address      : 0x0
Pages        : 1024
Page Size    : 512 bytes
Total Size   : 512KB
Planes       : 1
Lock Regions : 32
Locked       : none
Security     : false
BOD          : false
BOR          : true
Write 44272 bytes to flash (87 pages)

[                              ] 0% (0/87 pages)
[==                            ] 9% (8/87 pages)
[=====                         ] 18% (16/87 pages)
[========                      ] 27% (24/87 pages)
[===========                   ] 36% (32/87 pages)
[=============                 ] 45% (40/87 pages)
[================              ] 55% (48/87 pages)
[===================           ] 64% (56/87 pages)
[======================        ] 73% (64/87 pages)
[========================      ] 82% (72/87 pages)
[===========================   ] 91% (80/87 pages)
[==============================] 100% (87/87 pages)
Done in 0.662 seconds
Verify 44272 bytes of flash

[=                             ] 3% (3/87 pages)
[=                             ] 4% (4/87 pages)
[=                             ] 5% (5/87 pages)
[==                            ] 6% (6/87 pages)
[==                            ] 8% (7/87 pages)
[==                            ] 9% (8/87 pages)
[===                           ] 10% (9/87 pages)
[===                           ] 11% (10/87 pages)
[===                           ] 12% (11/87 pages)
[====                          ] 13% (12/87 pages)
[====                          ] 14% (13/87 pages)
[====                          ] 16% (14/87 pages)
[=====                         ] 17% (15/87 pages)
[=====                         ] 18% (16/87 pages)
[=====                         ] 19% (17/87 pages)
[======                        ] 20% (18/87 pages)
[======                        ] 21% (19/87 pages)
[======                        ] 22% (20/87 pages)
[=======                       ] 24% (21/87 pages)
[=======                       ] 25% (22/87 pages)
[=======                       ] 26% (23/87 pages)
[========                      ] 27% (24/87 pages)
[========                      ] 28% (25/87 pages)
[========                      ] 29% (26/87 pages)
[=========                     ] 31% (27/87 pages)
[=========                     ] 32% (28/87 pages)
[==========                    ] 33% (29/87 pages)
[==========                    ] 34% (30/87 pages)
[==========                    ] 35% (31/87 pages)
[===========                   ] 36% (32/87 pages)
[===========                   ] 37% (33/87 pages)
[===========                   ] 39% (34/87 pages)
[============                  ] 40% (35/87 pages)
[============                  ] 41% (36/87 pages)
[============                  ] 42% (37/87 pages)
[=============                 ] 43% (38/87 pages)
[=============                 ] 44% (39/87 pages)
[=============                 ] 45% (40/87 pages)
[==============                ] 47% (41/87 pages)
[==============                ] 48% (42/87 pages)
[==============                ] 49% (43/87 pages)
[===============               ] 50% (44/87 pages)
[===============               ] 51% (45/87 pages)
[===============               ] 52% (46/87 pages)
[================              ] 54% (47/87 pages)
[================              ] 55% (48/87 pages)
[================              ] 56% (49/87 pages)
[=================             ] 57% (50/87 pages)
[=================             ] 58% (51/87 pages)
[=================             ] 59% (52/87 pages)
[==================            ] 60% (53/87 pages)
[==================            ] 62% (54/87 pages)
[==================            ] 63% (55/87 pages)
[===================           ] 64% (56/87 pages)
[===================           ] 65% (57/87 pages)
[====================          ] 66% (58/87 pages)
[====================          ] 67% (59/87 pages)
[====================          ] 68% (60/87 pages)
[=====================         ] 70% (61/87 pages)
[=====================         ] 71% (62/87 pages)
[=====================         ] 72% (63/87 pages)
[======================        ] 73% (64/87 pages)
[======================        ] 74% (65/87 pages)
[======================        ] 75% (66/87 pages)
[=======================       ] 77% (67/87 pages)
[=======================       ] 78% (68/87 pages)
[=======================       ] 79% (69/87 pages)
[========================      ] 80% (70/87 pages)
[========================      ] 81% (71/87 pages)
[========================      ] 82% (72/87 pages)
[=========================     ] 83% (73/87 pages)
[=========================     ] 85% (74/87 pages)
[=========================     ] 86% (75/87 pages)
[==========================    ] 87% (76/87 pages)
[==========================    ] 88% (77/87 pages)
[==========================    ] 89% (78/87 pages)
[===========================   ] 90% (79/87 pages)
[===========================   ] 91% (80/87 pages)
[===========================   ] 93% (81/87 pages)
[============================  ] 94% (82/87 pages)
[============================  ] 95% (83/87 pages)
[============================  ] 96% (84/87 pages)
[============================= ] 97% (85/87 pages)
[============================= ] 98% (86/87 pages)
[==============================] 100% (87/87 pages)
Verify successful
Done in 1.046 seconds
and also the call to SD.begin(), using chip select = 10, fails.

I moved the shield to a plain Metro and used the Cardinfo example and, while there are no compile warnings, the SD.begin() call still fails with an "0X01,SD_CARD_ERROR_CMD0 - Card reset failed" error.

A side question is wondering why I am seeing the verbose reporting on compile and upload when I have those flags turned off in the IDE (2.0.4) ?
Untitled.png
Untitled.png (54.75 KiB) Viewed 504 times
Anyone have any suggestions?

Thanks,

.Andy

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: errors/warnings using datalogging shield with Metro M4 Express

Post by mikeysklar »

I don't see the Metro M4 being explicitly mentioned to work with the SD shield.
With this new version you can use it with:

Arduino UNO or ATmega328 compatible - 4 analog channels at 10 bit resolution, 6 if RTC is not used
Arduino Leonardo or ATmega32u4 compatible - 12 analog channels at 10 bit resolution
Arduino Mega or ATmega2560 compatible - 16 analog inputs (10-bit)
Arduino Zero or ATSAMD21 compatible - 6 analog inputs (12-bit)
Arduino Due compatible - 12 analog inputs (12-bit)
https://learn.adafruit.com/adafruit-dat ... es-1948795

Which version of the SD library are you using? The SdFat library is recommended.
this library fork is being archived - the Arduino SD lirbary has all these capabilities in it now

please use the SdFat Library instead for any advanced SD card needs! (its much better)
https://github.com/adafruit/SD

Had you upgraded from Arduino IDE 1.x? It might have pulled the verbose compile/upload settings from an old config. You can try checking them, saving exiting preferences and unchecking them again to see if the correct verbosity behavior follows.

User avatar
adavid7
 
Posts: 120
Joined: Fri Jul 04, 2014 7:32 pm

Re: errors/warnings using datalogging shield with Metro M4 Express

Post by adavid7 »

Oh wow, it didn't even dawn on me to check compatibility with the M4. I'm only using the M4 because my application uses a lot of devices, hence a lot of libraries, and lots of strings. I needed the extra memory, but I guess I should just move to a Mega instead of the Metro/Uno.

I will try the SDFat one also instead of the SD.

And thanks for the tip about the verbosity.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: errors/warnings using datalogging shield with Metro M4 Express

Post by mikeysklar »

Well, I wouldn't rule out the M4 from working either since the M0 board is supported. It just means there might be some surprises.

If you want to get things going do the following:

1) Start using SdFat and the examples that come with that. The SD world changed dramatically when 2.x was released so there is a lot of incompatible SD code floating around.

2) Stick with your old Metro 328 to get things going initially. You need to get passed CardInfo type examples where the card is recognized and can display the file contents.

3) Once the above is going you can try to move up to the Metro M4 and make the necesary CS pin adjustments.

User avatar
adavid7
 
Posts: 120
Joined: Fri Jul 04, 2014 7:32 pm

Re: errors/warnings using datalogging shield with Metro M4 Express

Post by adavid7 »

OK, I have reverted to the shield on a Metro 328, with nothing else connected to the shield. The RTC works fine.

When I try the Arduino SD 'Cardinfo' it fails. And with the SDfat - Arduino Fork's 'Sdinfo' it also fails, like this:

Code: Select all

 SdFat version: 2.2.0

Assuming the SD is the only SPI device.
Edit DISABLE_CS_PIN to disable an SPI device.

Assuming the SD chip select pin is: 10
Edit SD_CS_PIN to change the SD chip select pin.

type any character to start

SD initialization failed.
Do not reformat the card!
Is the card correctly inserted?
Is there a wiring/soldering problem?
Is SD_CS_PIN set to the correct value?
Does another SPI device need to be disabled?
SD errorCode: SD_CARD_ERROR_CMD0 = 0x1
SD errorData = 0x0
I reformatted the card with the SD Card Formatter app (not the MacOS DiskUtility). I tried a fresh card (adafruit.com/product/1294) right out the box.

All the same failures, as above.

This has worked before in this configuration, so I'm wondering what could have gone wrong?

???
Thx.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: errors/warnings using datalogging shield with Metro M4 Express

Post by mikeysklar »

What size card are you using?

Is this the SDInfo script you are running?

Can you show any soldering you have done?

User avatar
adavid7
 
Posts: 120
Joined: Fri Jul 04, 2014 7:32 pm

Re: errors/warnings using datalogging shield with Metro M4 Express

Post by adavid7 »

I'm using an 8GB card from Adafruit: adafruit.com/product/1294.
Yes, that is the exact program I ran.
Photos of the shield are attached. I used stacking headers for the shield, and just soldered two headers on the board for the L1/L2 connections.
IMG_5702.jpg
IMG_5702.jpg (990.74 KiB) Viewed 444 times
IMG_5701.jpg
IMG_5701.jpg (1013.26 KiB) Viewed 444 times

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: errors/warnings using datalogging shield with Metro M4 Express

Post by mikeysklar »

It looks as though you have not shorted the jumpers closed on the Metro 328. I believe this is required for any 328's without an ICSP header.
On the bottom of the Rev B shield, you can see that if you have an older Arduino where there is no ICSP 2x3 header, and no SDA/SCL pins, you can short the solder jumpers closed.
https://learn.adafruit.com/adafruit-dat ... ts-1948736

User avatar
adavid7
 
Posts: 120
Joined: Fri Jul 04, 2014 7:32 pm

Re: errors/warnings using datalogging shield with Metro M4 Express

Post by adavid7 »

The Metro 328 does have an ICSP header so I didn't short that jumper. But I realized when you mentioned it that I had not connected the ICSP pins on the shield to the Metro below. When I did that the Sdinfo program ran fine and the card is accessible.

But using the shield on the M4 still does not work, so perhaps that is because, as you said, it's not guaranteed. I'm still trying to figure out if it can be made to work.

Just one thought on that regarding the SdFat library and the examples -- those sample programs are pretty complex to understand and I think perhaps overly structured with flexibility with all of the conditional compilation pragmas (#ifdef, etc.).

I am developing applications to use in my teaching of physical computing and I find it really tedious to plow through all of that code. The earlier examples in the Arduino SD library are much simpler and would be much more digestible by my (university) students. I realize that the functionality is probably much improved, but for teaching and learning, it's tougher.

In trying to track down the M4 compatibility issue, I may have some more questions. In the meantime, since I mostly just need more memory, I ordered an Arduino Mega.

Thanks for the help.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: errors/warnings using datalogging shield with Metro M4 Express

Post by mikeysklar »

Congrats on getting it going. The ISP header for SPI pins is a common source of confusion.

Things were a little easier in the old days when it was pretty much Arduino UNO and maybe a mega. As more chips came out the ifdef's started being necessary for supporting all the new chips.

The modern solution really is to use the Adalogger FeatherWing on a Feather based board. This offers a lot in a tiny form factor.

Alternatively, the Micro SD SPI breakout is a good option.

User avatar
adavid7
 
Posts: 120
Joined: Fri Jul 04, 2014 7:32 pm

Re: errors/warnings using datalogging shield with Metro M4 Express

Post by adavid7 »

The FeatherWing logger looks like a great way to go, but I'm trying to stick to the Arduino platform for my teaching.

I could use the breakout board versions of the SD card and RTC. The RTCs are nice in that they use I2C, but the breakouts for the regular SD card and the Micro SD SPI or SDIO Card that you mentioned both use a lot of pins. I wish there were I2C versions for SD cards.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: errors/warnings using datalogging shield with Metro M4 Express

Post by mikeysklar »

i2c would be too slow, but SPI requires only three pins plus Vcc/Gnd. Example photo from the ItsyBitsy.
905C86B8-82E0-4DA4-8EF3-4E9C59922D2F.png
905C86B8-82E0-4DA4-8EF3-4E9C59922D2F.png (199.09 KiB) Viewed 290 times

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”