Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:13 19 Feb 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : ArmMite H7 - Dual SD Cards?

Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1160
Posted: 06:31am 31 Jan 2026
Copy link to clipboard 
Print this post

I'm experimenting with an ArmMite H7 setup. I have a DevEBox plugged into carrier that also plugs into a 7 inch 800x480 LCD panel. Both the DevEBox and the LCD panel have SD card sockets, and both work with the appropriate OPTION SDCARD setting. But alas, only one can be used at a time. Is there any way to use both?

Ideally, I'd like to store program resources, such as graphic images, on the DevEBox uSD card. This will be inaccessible to the user. The SD card socket on the LCD panel will be user accessible and would allow the user to load data files. This way, the program will display correctly even if the user removes the SD card or the user's card doesn't contain the required support files.

Thoughts?
Visit Vegipete's *Mite Library for cool programs.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8564
Posted: 08:29am 31 Jan 2026
Copy link to clipboard 
Print this post

Electronically it's easy. Unfortunately MMBasic only supports a single CS line for a SD card. You can, in theory, use external logic to gate this to one of two different sockets but MMBasic will see both of them as B:/.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1730
Posted: 09:48am 31 Jan 2026
Copy link to clipboard 
Print this post

Although I have no need, ATM, I was recently musing about this very thing.
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1094
Posted: 10:04am 31 Jan 2026
Copy link to clipboard 
Print this post

It might be possible to do this. Would need a change to firmware.
The inbuilt SDCARD is always CS=79 and is bitbanged using the pins that are wired to the SDCARD.These pins are never available to MMBasic other than this internal bitbanging.

If CS<>79 then its just a standard SPI SDCARD using the nominated CS pin.

At start up either the SPI is opened or the Bitbang pins are configured in InitFileIO() function depending on value of the CS pin.
An extra parameter or even a -ve CS pin no could be used to tell it to initialise both SDCARD modes i.e. SPI and bitbang. It would default to the SPI SDCARD but the Bitbang pins would be configured as well.
i.e.
OPTION SDCARD [-]CS-Pin[,CD-Pin [,WP-Pin][,1]
(possibly the bitbang pins can be configure in any case without any adverse issues.)

OPTION SDCARD_CS would be allowed in a program and would changed the memory copy of Option.SDCard_CS so file operations would point to the desired card.(These are already sensitive to the value of Option.SDCARD_CS)
The SDCARDs would always be A:/ and programmer would be responsible for manipulating OPTION SDCARD_CS and keeping track of what SDCARD was being accessed.

Would this be useful.

Gerry
Edited 2026-01-31 20:07 by disco4now
F4 H7FotSF4xGT
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10965
Posted: 10:08am 31 Jan 2026
Copy link to clipboard 
Print this post

  Quote  Electronically it's easy. Unfortunately MMBasic only supports a single CS line for a SD card. You can, in theory, use external logic to gate this to one of two different sockets but MMBasic will see both of them as B:/.

Not the whole story. The firmware uses the SDcard in SPI mode. It initialises the card and sets it into this mode the first time it is used. With a second card the firmware wouldn't know that it hadn't been initialised. Also, the firmware uses read and write buffering, so the buffers have to be flushed before changing card.

The only way I can think to make it work is as follows:

LOOP:
Disable both CS pins electrically for 2 seconds.
The firmware will then decide there is no sdcard and will "eject" it.
Then enable the CS for the card you want to use.
As the firmware knows there is no initialised card it will do the init and then can use the card.
To switch card goto loop

The disable and enable could be done with two tri-state buffers controlled by two extra GPIO pins
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1160
Posted: 06:12pm 31 Jan 2026
Copy link to clipboard 
Print this post

Thank you for the ideas and details.

I was aware of the initialization code to prep an SD card. How long does the initialization remain in effect? I was pondering a small MCU to initialize the secondary SD card - then both would be available depending on the active CS. (Active low, right?)

[Edit]
This is probably pointless if the different SD cards are on different busses - ie one is bitbanged, the other is on an SPI port. Maybe I have to add an SD card on my carrier that uses the same pins as the one on the LCD.
[/Edit]

I wasn't aware of the buffering. What action flushes the buffers? If writing a file, is  'CLOSE' enough to do it?

---------
With regards firmware changes, the most amazing solution would be A: and B: drives but that's asking a heck of a lot. The OPTION SDCARD already has a bunch of parameters so adding even more gets confusing. Perhaps a second OPTION SDCARD2 could set up the second one? Are the CS pins available to MMBasic? Or would a special CHDIR "DriveID" make this easier?

I don't see a need to copy files between cards, but the FileManager authors might have different ideas.  ;-)

Thanks!
Edited 2026-02-01 04:25 by vegipete
Visit Vegipete's *Mite Library for cool programs.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8564
Posted: 06:42pm 31 Jan 2026
Copy link to clipboard 
Print this post

I've lost touch with the ArmMite. The PicoMite has a A:/ drive in flash but I don't know if that's available here.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1094
Posted: 08:56am 02 Feb 2026
Copy link to clipboard 
Print this post

  vegipete said  I'm experimenting with an ArmMite H7 setup. I have a DevEBox plugged into carrier that also plugs into a 7 inch 800x480 LCD panel. Both the DevEBox and the LCD panel have SD card sockets, and both work with the appropriate OPTION SDCARD setting. But alas, only one can be used at a time. Is there any way to use both?

Ideally, I'd like to store program resources, such as graphic images, on the DevEBox uSD card. This will be inaccessible to the user. The SD card socket on the LCD panel will be user accessible and would allow the user to load data files. This way, the program will display correctly even if the user removes the SD card or the user's card doesn't contain the required support files.

Thoughts?


See if this works.
It is specifically for the scenario above. It lets you swap the active SDCARD within in a program or at the commandline without a restart. You have no B:/ drive. You cannot directly copy between them, only one is available at a time. Works with the DevEBox and WeACT 100 pin built in bitbanged SDCARD and the System SPI SDCARD on the LCD. It should also work with two SDCards on the System SPI.
The Options below are modified/added to support this.

ArmmiteH743.zip

OPTION SDCARD CS-Pin[,CD-Pin [,WP-Pin]][,CS2-Pin]
CS2-Pin is the CS pin for the second SDCARD. (CD-Pin and WP-Pin not supported)

OPTION SDCARD1    - Switch to the first SDCARD   (allowed in program)
PAUSE 500
OPTION SDCARD2    - Switch to the second SDCARD  (allowed in program)
PAUSE 500

You must add the PAUSE if used in a program.
You would need to ensure all files are closed before swapping to the other SDCARD.
You can only use one at a time, and it will always be the  A:/ drive.

> option list
ARMmite H7 MMBasic Version 5.08.00b1
OPTION LCDPANEL SSD1963_7_16, RLANDSCAPE
BACKLIGHT 50,DEFAULT
OPTION SDCARD 78,,, 79


> run
SDCARD1 Active
Ready
SD1.BAS Size:    19
I am from SDCARD1
SDCARD2 Active
Ready
SD2.BAS Size:    19
I am from SDCARD2


> list
Option SDCARD1
Pause 500
Print "SDCARD1 Active"
If MM.Info(SDCARD)="Ready" Then
Print "Ready"
Open "sd1.BAS" For output As 1
Print #1,"I am from SDCARD1"
Close #1
Print "SD1.BAS Size:",MM.Info(FILESIZE "SD1.BAS")
List "SD1.BAS"
Else
Print "Not ready"
EndIf

Option SDCARD2
Pause 500
Print "SDCARD2 Active"
If MM.Info(SDCARD)="Ready" Then
Print "Ready"
Open "sd2.BAS" For output As 1
Print #1,"I am from SDCARD2"
Close #1
Print "SD2.BAS Size:",MM.Info(FILESIZE "SD2.BAS")
List "SD2.BAS"
Else
Print "Not Ready"
EndIf


F4 H7FotSF4xGT
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1160
Posted: 05:08pm 03 Feb 2026
Copy link to clipboard 
Print this post

Wow, looks promising. Thank you!

I had a quick test (mostly from the command prompt) with mixed results, but I must test more.

I used the same OPTION SDCARD 78,,,79  (same OPTION LCDPANEL too, and OPTION TOUCH 67,77)

An SD card (from a CMM2) inserted in the LCD wasn't recognized - maybe too small?
Switching to card 2, a uSD on the DevEBox, worked fine. Switching back to the first one, FILES kept displaying what was on the second card. Eventually it quit working with a "Not enough memory" (~ish) error. I will test more to see what I learn.
Visit Vegipete's *Mite Library for cool programs.
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1094
Posted: 03:54am 04 Feb 2026
Copy link to clipboard 
Print this post

I had not tested with Touch enabled, but on testing with touch enabled I am not getting the issues you see.

It handles the SDCARD not being inserted on the LCDPanel. I see no memory leak using ? MM.info(HEAP).
This is code I ran.
The first thing is probably to ensure the SDCARD on the LCDPanel works reliably when it is configured normally.



> list

Option SDCARD1
Pause 500
Print "SDCARD1 Active"
If MM.Info(SDCARD)="Ready" Then
Print "...Ready"
Open "sd1.BAS" For output As 1
Print #1,"I am from SDCARD1"
Close #1
verify 1
Print "...SD1.BAS Size:",MM.Info(FILESIZE "SD1.BAS")
'List "SD1.BAS"
Else
Print "Not ready"
EndIf

Option SDCARD2
Pause 500
Print "SDCARD2 Active"
If MM.Info(SDCARD)="Ready" Then
Print "...Ready"
Open "sd2.BAS" For output As 1
Print #1,"I am from SDCARD2"
Close #1
verify 2
Print "...SD2.BAS Size:",MM.Info(FILESIZE "SD2.BAS")
'List "SD2.BAS"
Else
Print "Not Ready"
EndIf
Option SDCARD1:Pause 500
Print MM.Info(HEAP)
Option SDCARD2:Pause 500
Print MM.Info(HEAP)
Option SDCARD1:Pause 500
Print MM.Info(HEAP)
Option SDCARD2:Pause 500
Print MM.Info(HEAP)
Option SDCARD1:Pause 500
Print MM.Info(HEAP)
Option SDCARD2:Pause 500
Print MM.Info(HEAP)
Option sdcard1:Pause 500

For x=1 To 100
  Option SDCARD1
  VERIFY 1
  Option SDCARD2
  VERIFY 2
  Print MM.Info(HEAP)
Next

Sub VERIFY(no)
file$="SD"+Str$(no)+".BAS"
Open file$ For INPUT As #1
a$=Input$(17,#1)
Close #1
If a$="I am from SDCARD"+Str$(no) Then
Print "...Read Verified SDCARD"+Str$(no)
Else
Print a$,"I am from SDCARD"+Str$(no)
EndIf
End Sub
>



F4 H7FotSF4xGT
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1160
Posted: 07:03pm 08 Feb 2026
Copy link to clipboard 
Print this post

So, a bit more testing with a different SD card. The uSD card in the DevEBox remains the same.

Following is from the command prompt.

Files works correctly if only one SD card is active, with option sdcard 78 -or- 79.

With both SD cards active with option sdcard 78,,,79 I can't seem to change cards. Here's a log of attemps:
> option list
ARMmite H7 MMBasic Version 5.08.00b1
OPTION LCDPANEL SSD1963_7_16, RLANDSCAPE
OPTION TOUCH 67, 77
GUI CALIBRATE 1, 3974, 3996, -2063, -1295
BACKLIGHT 50,DEFAULT
> option sdcard 78
> files
A:/
  <DIR>  DCIM
  <DIR>  MISC
  <DIR>  PRIVATE
  <DIR>  SD_VIDEO
4 directories, 0 files
> option sdcard2
Error : SD card not configured
> option sdcard 79
> files
A:/
  <DIR>  DCIM
    35277  Font09-13.bas
     2294  glyphs.bmp
    17388  MediumTank.jpg
1 directory, 3 files
> option sdcard 78
> files
A:/
  <DIR>  DCIM
  <DIR>  MISC
  <DIR>  PRIVATE
  <DIR>  SD_VIDEO
4 directories, 0 files
> option sdcard 78,,,79
Error : Pin 78 is reserved on startup
> option sdcard disable
> option sdcard 78,,,79
> option sdcard1
> files
A:/
  <DIR>  DCIM
  <DIR>  MISC
  <DIR>  PRIVATE
  <DIR>  SD_VIDEO
4 directories, 0 files
> option sdcard2
> files
A:/
  <DIR>  DCIM
  <DIR>  MISC
  <DIR>  PRIVATE
  <DIR>  SD_VIDEO
4 directories, 0 files
> option sdcard2:pause 500
> files
A:/
  <DIR>  DCIM
  <DIR>  MISC
  <DIR>  PRIVATE
  <DIR>  SD_VIDEO
4 directories, 0 files
> option sdcard1:pause 500
> files
A:/
  <DIR>  DCIM
  <DIR>  MISC
  <DIR>  PRIVATE
  <DIR>  SD_VIDEO
4 directories, 0 files
> option sdcard2
> files
A:/
  <DIR>  DCIM
  <DIR>  MISC
  <DIR>  PRIVATE
  <DIR>  SD_VIDEO
4 directories, 0 files
> option sdcard disable
> option sdcard 79
> files
A:/
  <DIR>  DCIM
    35277  Font09-13.bas
     2294  glyphs.bmp
    17388  MediumTank.jpg
1 directory, 3 files
>
> option sdcard disable
> option sdcard 78,,,79
> option sdcard2
> files
A:/
  <DIR>  DCIM
    35277  Font09-13.bas
     2294  glyphs.bmp
    17388  MediumTank.jpg
1 directory, 3 files
> option sdcard1
> files
A:/
  <DIR>  DCIM
    35277  Font09-13.bas
     2294  glyphs.bmp
    17388  MediumTank.jpg
1 directory, 3 files
>
> option SDCARD1:pause 500
> ? MM.Info(SDCARD)
Ready
> files
A:/
  <DIR>  DCIM
    35277  Font09-13.bas
     2294  glyphs.bmp
    17388  MediumTank.jpg
1 directory, 3 files
>
What can I test further to help find the problem?

Thank you for your efforts!
Visit Vegipete's *Mite Library for cool programs.
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1094
Posted: 01:53am 09 Feb 2026
Copy link to clipboard 
Print this post

I have not been able to duplicate what you are seeing but have made a couple of changes.

1. OPTION SDCARD xx  now requires OPTION SDCARD DISABLE if an SD Card is already enabled.
2. If an MMBasic error occurs then the first SD Card becomes the default.
3. OPTION SDCARD[1|2] are only allowed if dual SD cards are configured.

Previously an error when OPTION SDCARD1/2 was issued was suppressed. These should now give an error which may help tracking down your issue.
Are you powering from a USB source. I power with external 5v source.


ArmmiteH743.zip
F4 H7FotSF4xGT
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026