Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:52 29 Nov 2024 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 : Wattmon uPHP on PIC32

     Page 2 of 3    
Author Message
akashh
Senior Member

Joined: 19/01/2014
Location: India
Posts: 115
Posted: 03:35pm 03 Feb 2014
Copy link to clipboard 
Print this post

I am breaking my head trying to get my bootloader working on the duinomite. I reflashed the olimex bootloader and put back mmbasic just to make sure the sd card works and everything was smooth. The moment I install my custom bootloader which is almost identical to microchip's MDD bootloader, it recognises the sd card but returns all 0s when reading the MBR. I have properly modified everything to use SPI3 as required, but still nothing. I tried internal oscillator, external oscillator, slower frequencies, everything. It works fine by just changing the def file back to SPI4 and flashing it to my board.
Does anyone have any ideas? Could it be related to another peripheral that is hogging one of the IO lines required by SPI3?Edited by akashh 2014-02-05
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3816
Posted: 09:57pm 03 Feb 2014
Copy link to clipboard 
Print this post

I think you'd have to post the source and hope someone feels inclined to study / try it.

John
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 926
Posted: 08:39pm 07 Feb 2014
Copy link to clipboard 
Print this post

  Geoffg said   By my calculations you would have written to the card a total of 86,000 times over three months and each one would have updated the FAT. My understanding is that most low cost cards have an endurance of 20,000 to 40,000 erase/writes while SanDisk claim 100,000.

Maybe it is a SanDisk counterfeit?

Regardless, writing once a minute is asking for trouble.

Geoff

Is there a counter built into the SD cards to register the amount of writes that have been processed? I currently have a number of cards that have been collecting data from 5-10 variables at a frequency of 10 minutes. It would seem that some of them would be close to END OF LIFE. It would be nice to know if a register can be accessed how much life is left in these cards.
 
greybeard
Senior Member

Joined: 04/01/2010
Location: Australia
Posts: 161
Posted: 09:42pm 07 Feb 2014
Copy link to clipboard 
Print this post

  Graeme Meager said  
  Geoffg said   By my calculations you would have written to the card a total of 86,000 times over three months and each one would have updated the FAT. My understanding is that most low cost cards have an endurance of 20,000 to 40,000 erase/writes while SanDisk claim 100,000.

Maybe it is a SanDisk counterfeit?

Regardless, writing once a minute is asking for trouble.

Geoff

Is there a counter built into the SD cards to register the amount of writes that have been processed? I currently have a number of cards that have been collecting data from 5-10 variables at a frequency of 10 minutes. It would seem that some of them would be close to END OF LIFE. It would be nice to know if a register can be accessed how much life is left in these cards.

Wouldn't the register itself reach end of life before anything else on the card?
 
akashh
Senior Member

Joined: 19/01/2014
Location: India
Posts: 115
Posted: 09:25pm 08 Feb 2014
Copy link to clipboard 
Print this post

It would be interesting to perform an accelerated test. Write a file once a second and read it back, then verify it. It could be as simple as a counter. That should give us an idea within a week (86400 writes a day). I would be ready to set that up and sacrifice a sandisk card, but perhaps someone else could do the same on a maximite. I will post my results once I do so.
Akash
 
akashh
Senior Member

Joined: 19/01/2014
Location: India
Posts: 115
Posted: 06:30pm 09 Feb 2014
Copy link to clipboard 
Print this post

Alright, I have set up a script to open a file, read a counter value, increment and write it back once a second. I have included a couple of pictures of the setup, and the code I am using. This should give us results pretty rapidly, within a couple of days I would guess since this modified the fat and the file 86400 times a day.


This is the Wattmon device I am using and the SanDisk 8GB brand new SD Card



This is the setup (I had to open the cover to get to the serial console)



Here is a view of the console with the output of the script underlined in red, counting once a second.

Here is the code I used:

<?
// this file is executed once a second by the CRON scheduler on Wattmon

// open a file for read/write

$f = fopen("/counter.txt",'r');

// get the contents as a string and convert to an int

$cnt = intval(fgets($f));

// if the value does not match the old value, echo it to the console (serial)

if ($cnt != $_GLOBALS['rwcnt']) {
printf("Mismatch in write, value=%d but expected=%d",$cnt,$_GLOBALS['rwcnt']);
log("Mismatch in write, value=%d but expected=%d",$cnt,$_GLOBALS['rwcnt']);
}

$cnt++;
$_GLOBALS['rwcnt']=$cnt;

// echo the value to the console

print("Write counter: ".$cnt."\r\n");

// reopen the file for writing

fclose($f);
$f = fopen("/counter.txt",'w');

// write the new value back to the SD card

fwrite($f,strval($cnt)."\r\n");

// close file
fclose($f);
?>
 
akashh
Senior Member

Joined: 19/01/2014
Location: India
Posts: 115
Posted: 05:15pm 10 Feb 2014
Copy link to clipboard 
Print this post

The counter is up to 82500 and still going strong!
 
akashh
Senior Member

Joined: 19/01/2014
Location: India
Posts: 115
Posted: 05:04pm 11 Feb 2014
Copy link to clipboard 
Print this post

The SanDisk wear leveling algorithms seem to be working. I am at 168000 writes so far and still going strong!
 
akashh
Senior Member

Joined: 19/01/2014
Location: India
Posts: 115
Posted: 07:53pm 12 Feb 2014
Copy link to clipboard 
Print this post

It's at 264500 writes so far and running smoothly! That's pretty interesting, because it means that there is definitely some wear leveling algorithm running behind the scenes. This script (in the code shown above) re-opens the file for writing (which may effectively scrap the old one, not sure?) but still, it definitely wrote to the FAT table at least 264000 times, which I find impressive - does anyone have any thoughts on what to expect in the coming days? And what is actually happening under the hood?
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 08:00pm 12 Feb 2014
Copy link to clipboard 
Print this post

Akash, it would be good to know the exact product you are using. I use SD cards in my camera and it would be useful to have one with staying power like you have just demonstrated. You must be using only part capacity to be able to use wear levelling?
Bob
 
akashh
Senior Member

Joined: 19/01/2014
Location: India
Posts: 115
Posted: 10:03pm 12 Feb 2014
Copy link to clipboard 
Print this post

I am in fact repeatedly writing a file, it may or may not be using the same sector - hard to tell (I suppose I could trace the MDD code and figure it out) - but the FAT is definitely being written to multiple times. From what I understand, the wear leveling algorithm for SanDisk products will take blocks within the same area and spread out the writes (transparently). So writing to a particular sector will in fact use a different area of the SD card each time. However, there seems to be a limit to the amount of space that is used by each block, it does not span the entire card but only a small part of it - this means that you would have a finite amount of writes allowed to the FAT sector. I'll let it go for some more time and see what it counts to.
It's a Sandisk 8GB class 4 card.
 
akashh
Senior Member

Joined: 19/01/2014
Location: India
Posts: 115
Posted: 05:32pm 14 Feb 2014
Copy link to clipboard 
Print this post

It's at 428,000 writes and no sign of slowing down. That's pretty cool, IMHO.
 
akashh
Senior Member

Joined: 19/01/2014
Location: India
Posts: 115
Posted: 03:58pm 16 Feb 2014
Copy link to clipboard 
Print this post

I am wondering whether anyone is interested in the type of device that I have developed, and whether or not it really makes sense to bring out a duinomite version. I spent considerable time already on starting to port it, but there has so far only been one response of encouragement on this forum.
Is it that nobody here like the PHP language? Or the fact that I am not releasing the source? Or just that people couldn't be bothered with yet another platform?
Any comments would help me better understand, because I would love working with exactly this type of group, who are enthusiastic about what you do.Edited by akashh 2014-02-18
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6103
Posted: 05:38pm 16 Feb 2014
Copy link to clipboard 
Print this post

I am always interested to see what others are doing but in my case, I have enough trouble keeping up with the languages and hardware that I have now.

Jim
VK7JH
MMedit   MMBasic Help
 
psergiu

Regular Member

Joined: 09/02/2013
Location: United States
Posts: 83
Posted: 09:10pm 16 Feb 2014
Copy link to clipboard 
Print this post

I have no problem with the source code being not widely available IF the developer is available and willing to fix reported bugs. :)

If you do release a Duinomite/Maximite/UWB32 version of the uPHP firmware, it would be fantastic if it supported the ENC20J60 ethernet modules, as those are the cheapest and available everywhere.

Thanks.
 
akashh
Senior Member

Joined: 19/01/2014
Location: India
Posts: 115
Posted: 03:52am 17 Feb 2014
Copy link to clipboard 
Print this post

Sergei, it would support the enc28j60, which I think you are referring to. If people are ready to solder on sd and Ethernet using the ubw32 I could get that up pretty quickly, by just using the same pinouts as for the Wattmon. If anyone can confirm they want to try it on UBW let me know.
 
akashh
Senior Member

Joined: 19/01/2014
Location: India
Posts: 115
Posted: 08:03pm 19 Feb 2014
Copy link to clipboard 
Print this post

For those of you following the SD card experiment, the card has already been written to 870,0000 and is still working. I'll just keep it going until it stops and it may help understand what is happening. It's just a single file and single sector, so it may just work forever? Although logically it's busy wearing the FAT out bit by bit.
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 926
Posted: 08:29pm 19 Feb 2014
Copy link to clipboard 
Print this post

I am keen to see how far the experiment will go.
Thanks Akashh
 
akashh
Senior Member

Joined: 19/01/2014
Location: India
Posts: 115
Posted: 07:05pm 23 Feb 2014
Copy link to clipboard 
Print this post

I am not really sure where to post this, so I'll just keep posting in the uPHP thread I started. I was running out of flash and found this great PDF describing ways to optimize flash usage (Many of you will probably know it, but I didn't, and it saved me 30% right off, which is great):
Microchip PIC32 Reducing Code Size

Geoff, I guess you may be using the mips16 option on the micromite, but in case you aren't it may help free up some space.

Akash
 
akashh
Senior Member

Joined: 19/01/2014
Location: India
Posts: 115
Posted: 11:00pm 28 Feb 2014
Copy link to clipboard 
Print this post

I just checked the experiment and the device has counted to 1.5 million writes without showing signs of wear... I am wondering whether since it only affects a single sector if the write to disk is actually taking place. I may need to open a new file in between to ensure that it flushes data out.
 
     Page 2 of 3    
Print this page
© JAQ Software 2024