Problems of using AI-deck and SD-card together

Discussions about the AI-deck
Post Reply
WendaZ
Beginner
Posts: 14
Joined: Sun Jul 14, 2019 10:35 pm

Problems of using AI-deck and SD-card together

Post by WendaZ »

Hello AI-deck team,

I plan to use AI-deck and SD-card together to collect some data. However, I think there might be some conflicts between the two decks.

The problem I encountered when using both decks is as follows.
Problem:
When attaching AI-deck and SD-card deck, setting the parameter "usd/logging" onboard doesn't log the data into the SD-card. Sometimes, the drone will restart by a failed assert in "/src/deck/drivers/src/usddeck.c:795", which indicates we cannot write into sd-card file. Sometimes, I can log data, but the LED on the AI-deck will stop blinking.

From the document (https://www.bitcraze.io/documentation/s ... allocation), the AI-deck and SD-card should be able to use together.

Does anyone have an idea about what would be the conflicts and how can I resolve this problem?

Thanks in advance!

Wenda
jonasdn
Expert
Posts: 132
Joined: Mon Mar 01, 2021 3:13 pm

Re: Problems of using AI-deck and SD-card together

Post by jonasdn »

Hi WendaZ!

So the conflict seem to be the IO_4 port. It is used in the AI deck to reset the GAP8 processor and in the SD deck as chip select for SPI. It seems we are a bit over optimistic in the compatibility matrix.

It _is_ possible to use the SD card deck and the AI deck together, but it seems you need to modify the SD card deck a bit, patching it to use IO1, IO2 or IO3 for CS instead.

And change the driver to use that pin, right now you have in usd_deck.c:

Code: Select all

#define USD_CS_PIN    DECK_GPIO_IO4
See pull-request for documentation update here: https://github.com/bitcraze/bitcraze-website/pull/108
WendaZ
Beginner
Posts: 14
Joined: Sun Jul 14, 2019 10:35 pm

Re: Problems of using AI-deck and SD-card together

Post by WendaZ »

Hi jonasdn,

Thanks for the reply! My question would be how exactly should I patch the SD-card deck?
In the document (https://www.bitcraze.io/documentation/s ... allocation) it says to connect "via solder bridges or 0 Ohm resistors". Then from my understanding, I should connect either IO1, IO2, or IO3 to IO4 on the SD-card deck and change the driver to that PIN.

Am I correct?
WendaZ
Beginner
Posts: 14
Joined: Sun Jul 14, 2019 10:35 pm

Re: Problems of using AI-deck and SD-card together

Post by WendaZ »

Hi jonasdn,

I tested the method you provide but I encountered an error.
I connected IO3 to IO4 on the sd-card and modified in the usddeck.c to use DECK_GPIO_IO3 (shown in the attached figure). The sd-card can log data with only sd-card deck is connected to CF.

However, I got an error when I connected both AI-deck and sd-card. The error is as follows.
"DECK_INFO: ERROR: Driver Gpio usage conflicts with a previously enumerated deck driver. No decks will be initialized!".

I tried to disconnect the pin of IO4 to SD-card so that IO4 is only used to AI-deck and IO3 is used to sd-card. However, this error still pops up.

I wonder if you can elaborate your solution for this issue.

Thanks!

Wenda
Attachments
sd-card.jpg
Selection_078.png
WendaZ
Beginner
Posts: 14
Joined: Sun Jul 14, 2019 10:35 pm

Re: Problems of using AI-deck and SD-card together

Post by WendaZ »

One more update.

I desoldered the IO4 and IO3 on the SD-Card. Instead, I connected the IO2 pin on STM to IO4 pin on SD-card and set the firmware to use IO2 for sd-card CS. Meanwhile, the IO4 pin on CF is only connected to the AI-deck.

The figures are attached.

However, the same problem still came up. Please let me know if I did something wrong.

Thanks
Attachments
Image from iOS (2).jpg
Image from iOS (1).jpg
jonasdn
Expert
Posts: 132
Joined: Mon Mar 01, 2021 3:13 pm

Re: Problems of using AI-deck and SD-card together

Post by jonasdn »

Hi WendaZ!

You are doing it correctly it seems, it is just one bit that needs fixing that I did not think of!

The firmware checks at startup that no pins are allocated by multiple drivers, the checks fails, as you see with the message:

Code: Select all

      DEBUG_PRINT("ERROR: Driver Gpio usage conflicts with a "
                  "previously enumerated deck driver. No decks will be "
                  "initialized!\n");
You need to modify usddeck.c, to reflect the change:

Code: Select all

static const DeckDriver usd_deck = {
    .vid = 0xBC,
    .pid = 0x08,
    .name = "bcUSD",
    .usedGpio = DECK_USING_IO_4,
    .usedPeriph = DECK_USING_SPI,
    .init = usdInit,
    .test = usdTest,
};
Need to become:

Code: Select all

static const DeckDriver usd_deck = {
    .vid = 0xBC,
    .pid = 0x08,
    .name = "bcUSD",
    .usedGpio = DECK_USING_IO_2,
    .usedPeriph = DECK_USING_SPI,
    .init = usdInit,
    .test = usdTest,
};
WendaZ
Beginner
Posts: 14
Joined: Sun Jul 14, 2019 10:35 pm

Re: Problems of using AI-deck and SD-card together

Post by WendaZ »

Hi jonasdn,

One follow-up. The solution you provided works out.

I provide a small summary as follows for others who wants to use ai-deck and sd-card.

(1) Hardware side:
Disconnect IO4 between CF and sd-card. Connect IO2 (or IO1, IO3) of CF to IO4 on sd-card deck.
(2) Software side:
change line 81 and 1059 of crazyflie firmware to the corresponding pin
(For IO2, change to "#define USD_CS_PIN DECK_GPIO_IO2", ".usedGpio = DECK_USING_IO_2")

With the above changes, I am able to use sd-card and AI-deck together onboard.


Wenda
Attachments
Image from iOS (1).jpg
Post Reply