Jump to content
Mr.RC-Cam

Marlin RepRap with Toshiba FlashAir WiFi (Firmware Patch)

Recommended Posts

Using a Toshiba FlashAir Wi-Fi SD flash memory card in your 3D printer is a cool way to wirelessly transfer g-code files. I recently installed a 8GB card in my daVinci 1.0 (which had been upgraded with repetier firmware). I configured the FlashAir to operate in client mode and had success without any hassle. Any web browser can be used to upload files (no special software required).

flash_air_200.jpg.89e484d62530f0d889fdc6

But my luck ran out when I tried to use the FlashAir in my Geeetech i3 Prusa printer (which uses Marlin RepRap firmware). I could read/write files to it in the usual way, but it refused to establish a WiFi connection. I discovered that when Marlin reads the SD card it turns Off the WiFi function. But when it writes to the card it turns the WiFi On. It's a very strange bug indeed.

Fortunately Marlin is Open Source software. Buried deep in the SD card code I found the culprit and created a firmware patch that solves the problem.


NOV-18-2015 EDIT: This is a revised Marlin patch. If you have installed the original work-around firmware patch then remove the edits from the cardreader.cpp file before applying the new patch. The configuration.h edits can remain as-is since they are still needed in this revised patch.


Here's the patch instructions for the Marlin reprap Firmware:

1. Two files need to be edited. Start by loading Marlin's sketch (source) code into the Arduino IDE. Or use your favorite text editor.

2. Open file "configuration.h"

3. In any convenient place under the BAUDRATE section, add the following code:

// FLASH_AIR_WIFI must be defined if a Toshiba FlashAir card's WiFi is used.
// The FlashAir card will broadcast approx 6 seconds after Mounting.
// If a WiFi link is not established within 1 minute the FlashAir's WiFi will
// hibernate (must re-Mount card to retry WiFi linking).
#define FLASH_AIR_WIFI // Uncomment this if Toshiba FlashAir WiFi is used.

Save the file.

4. Open file "Sd2Card.cpp"

5. Find the Sd2Card::readData() function.

6. At the bottom of the function, find this text:

  // discard CRC
  spiRec();
  spiRec();
  chipSelectHigh();
  return true;

 fail:
  chipSelectHigh();
  return false;


7. Replace it with this:

  // discard CRC
  spiRec();
  spiRec();
  // <--- IF YOUR VERSION HAS A #endif ON THIS LINE THEN YOU MUST INCLUDE IT HERE TOO.
  chipSelectHigh();
  #ifdef FLASH_AIR_WIFI // Toshiba FlashAir Patch.
   spiSend(0XFF);       // Purge pending status byte.
  #endif
  return true;

 fail:
  chipSelectHigh();
  #ifdef FLASH_AIR_WIFI // Toshiba FlashAir Patch.
   spiSend(0XFF);       // Purge pending status byte.
  #endif
  return false;

Save the File.

8. Use the Arduino IDE and upload (re-flash) your printer. Done!
 


 

BTW, the FlashAir card ships with a host program for your PC. Do NOT install it. Instead, setup the card for client (station) mode so you can use any web browser for uploads. Instructions are here:
http://www.extrud3d.com/flashair
https://flashair-developers.com/en/documents/tutorials/advanced/1/

You can also replace the SD card's default web based uploader with one that has a better interface. Get it here:
http://www.extrud3d.com/fashairui

Lastly, the newer FlashAir W03 version supports long file names, whereas the W02 version is 8.3 format. The 8GB W03 Class 10 card is under $25 USD on eBay. But if you find a much lower price for the 8GB W02 Class 6, and money is tight, then save some cash and go for it instead. I have both card types and they work well.

Edited by Mr.RC-Cam
Added important #endif comment to code.

Share this post


Link to post
Share on other sites

Lol....how did I miss this little gem?

Love this idea. I was wondering how many more times my SD card would handle being pulled in and out of my card reader.

Just ordered the W03 from Amazon for $23 free shipping.

Thank you!

Share this post


Link to post
Share on other sites

So...Im getting an Error compiling message:  

This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
Arduino: 1.0.6 (Windows NT (unknown)), Board: "Arduino Mega 2560 or Mega ADK"
Sd2Card.cpp:22:1: error: unterminated #ifdef

Share this post


Link to post
Share on other sites

If you are sure the edits are correct then post your original file *and* the modified file. I will compare them and find the broken #ifdef.

Share this post


Link to post
Share on other sites

Your printer's Sd2Card.cpp file has minor differences and the edits have broken a #def. To fix this go to the two spiRec() at the edited area. Immediately after the second spiRec() add a new line and restore the missing #endif. It should look like this:

// discard CRC
  spiRec();
  spiRec();
#endif  // Some Marlin versions will need this #endif!

All the other edits remain the same. Only need to add the missing #endif.

Share this post


Link to post
Share on other sites

Glad to hear it is sorted out.

There's a Marlin file on the SD card that keeps track of printer usage. If you want to retain the realtime data then just copy all the old card's contents to the new FlashAir. If you don't do this then the printer will recreate the file with reset values.

Edit: Ignore the comment about the printer usage file. It's a feature found in Repetier, not Marlin. I have both software variants and was confused there for a moment. :)

 

Edited by Mr.RC-Cam
Ignore file copy suggestion, not applicable.

Share this post


Link to post
Share on other sites

I found this thread and decided to try this out. I modified Marlin 1.1.0.RC3. I have a 8gb W03. Configured the card in STA mode. Put it in a Ramps 1.4 board config with a full graphics smart controller. The card starts up and you can ping the card but the card dies as soon as you try to open the cards web server. Got any idea why that might happen?

Edited by Marlark

Share this post


Link to post
Share on other sites

Sorry, but I have not experienced that issue. If I had to guess, I would suspect the card's config file is incorrect. Or maybe the SD socket's 5V supply drops too low with the FlashAir installed (it draws more current than a normal SD card).

I recommend temporarily installing the FlashAir into a camera or PC and check the WiFi functions. You should be able to read/write files from your web browser. This quick test would confirm the FlashAir's config file edits are OK.  If this is successful then move on to troubleshooting the printer.

 

 

Share this post


Link to post
Share on other sites

Did some more testing and i have also a Vellerman K8400 3d printer that have marlin custom v1.0.0 as a firmware in it also. It just uses a 3drag board wish pritty much is a atmega chip card with a ultimaker board display with a different pin assignment. I figured out as long as i only use the upload.cgi page there is no problems. If i try to use the list.htm page the wifi goes down on the card. When i noticed this i tested the same thing on the ramps board config i initially tested it on and it behave exactly the same way. Did you initially use the toshiba flashair tool to initialize the card. I didnt. Havent even installed it. I went directly for the config file on the card. Could that be part of the reason? if such what does the tool do that is important for it.

Share this post


Link to post
Share on other sites

Upgraded the firmware on the card to 3.00.01. Funny thing is that now the list.htm works like a charm on the k8400 but when you upload with the upload.cgi it uploads the file but then it crashes and on the ramps it totaly refuse to start the wifi on the card at all now and if you try to load the content on the card it gets the list and then crashes reading the card files.

 

Share this post


Link to post
Share on other sites
Quote

Did you initially use the toshiba flashair tool to initialize the card. I didnt. Havent even installed it. I went directly for the config file on the card. Could that be part of the reason? if such what does the tool do that is important for it.

Did it both ways: On my first card I ran the Toshiba Flashair tool on my PC. I uninstalled it after finding it useless for my printer application. On the second card I went straight to editing its config file.

 

Quote

Upgraded the firmware on the card to 3.00.01. Funny thing is that now the list.htm works like a charm on the k8400 but when you upload with the upload.cgi it uploads the file but then it crashes

When you say "it crashes" do you mean the printer's LCD gets full of garbage? If so, then this is a common complaint that is caused by "noise" on the ribbon cable when the CPU communicates with the display board and/or SD card.

 

Quote

on the ramps it totaly refuse to start the wifi on the card at all now ...

If your printer has the patched code then it is odd that the FlashAir upgrade has caused this. I don't recall there being a upgrade for the W02 card (but if there was I installed it). For sure I upgraded the W03 card and it still works fine for me.

 

Quote

... and if you try to load the content on the card it gets the list and then crashes reading the card files.

If the crashing issue is garbage on the LCD screen then as mentioned this is a common complaint. On some Marlin versions (not all) you can remove the card and then re-insert it to restore the screen. But even so this is not acceptable if a print job is running. My solution was to add some code that restored the LCD screen whenever I pressed the LCD's rotary menu knob.
 

BTW, I am not using the native Toshiba interface. Instead I am using this now:
http://www.extrud3d.com/fashairui

 

 

Share this post


Link to post
Share on other sites

Hi there!

I setup the latest marlin as you told, but it wont work.

The card got access to my wifi via STA Mode, I can mount it as a folder on Windows. It's showing that the transfere will happen, but nothing will.

As I put some files to my printer the Marlin wont recognize the SD Card files anymore.

Could you send me your SD_WLAN config? Maybe something went wrong here @ mine.

Currently I'm on mobile and can't send the files.

Regards

Kev0

Share this post


Link to post
Share on other sites

Attached is my CONFIG file for the 8GB W03 Class 10 card. You will need to edit it.

If your printer can no longer display .g or .gco print files then it seems unlikely that flashair's Config file will help. I suggest you try a standard flash card and see if it works. If it doesn't, then restore your original Marlin firmware and confirm your base code is functional.

The Marlin version I use has file name restrictions (and is limited to 8.3 name display). It will not show any files that use undefined extensions. My preference is .g as the extension on the gcode print files.

FlashAir Config file (8GB w03 card): CONFIG

 

 

Share this post


Link to post
Share on other sites

If I put the card into any other device its working like a charm, but on the printer it will crash or only will work spontanious. Seem to be a firmware issue

Share this post


Link to post
Share on other sites

1. Try a standard SD card that has ** several ** gcode files on it. I suggest checking this with at least a half dozen .g files on the card in order to exercise the card's I/O port. Does a standard SD card work correctly?

2. When you say your printer "crashes" what exactly does that mean? For example, do you mean you see garbage characters in the LCD? Or?

3. If you delete all the files you've written to the FlashAir's ROOT directory does the "crash" go away? Leave flashair's system file alone, just delete YOUR files.

Share this post


Link to post
Share on other sites

i needed a suitable sd cradreader to manage the card via the toshiba tool.

when I say crash I mean the sd card seems to be busy, the printer can't access the files and showing an empty folder. The card is unavailable via wifi.

The LCD is fine.

I'll now try to reset it and start all over..

Share this post


Link to post
Share on other sites

I cant get it to work.

Every other card is working fine, even the normal SD card feature is working with the toshiba, unless I try to connect somehow and send data to it. From this moment the printer wont show me the stored files anymore.

Any suggestions?

Share this post


Link to post
Share on other sites

1. The WiFi function draws extra current from the SD card port, so maybe the local 3.3V voltage regulator is being overloaded. Use a voltmeter and confirm the card's voltage is Ok when WiFi is enabled.

2. If the SD Card voltage is confirmed good then post your two edited files, both before and after editing. I'll review what you've done.

 

Share this post


Link to post
Share on other sites

The voltage is fine, straight 3.3V

I could get the card to connect to my router 

GEEETechSDCard 192.168.178.48 XX:XX:XX:XX:XX:XX 11 / 46 2,4 GHz / n / 20 MHz
WPA2

But I cant access it via browser while plugged into my Printer.

Every other device will be fine.

e.g. on my Camera I can connect via browser.

 

running latest Marlin RC5 so your patch is right implemented.

I can only think that the metal part of the sd card slot is blocking the signal an refuses a stable connection. 

 

CONFIG

CONFIG_old

Edited by Kev0

Share this post


Link to post
Share on other sites

Just so that I fully get the details right, the FlashAir SD card works just like a regular card while in your printer if you do not attempt to access it by WiFi. That is to say, you can see the files on the LCD panel and use the printer's keyboard to print them. But as soon as you WiFi connect to the FlashAir the printer can no longer see the files using the LCD panel (LCD shows empty directories) and the browser access fails (browser timeout).

However, your FlashAir SD works fine (including WiFi access) if it is in ANY other device (camera, etc.).

Is this all correct? Any other symptoms?

 

Quote

running latest Marlin RC5 so your patch is right implemented.

As mentioned, if you post your two edited files (both before and after the edits, 4 files total) then I will take the time to review them. You never know, maybe there is an issue with the way the new code was added.

 

Quote

I can only think that the metal part of the sd card slot is blocking the signal an refuses a stable connection.

Seems plausible. If it was me I would temporarily locate the printer next to the router and confirm that suspicion. If that solves the problem then use a SD card extender cable adapter to move the card out of the metal area.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×