SD card file write

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
SureshVakati
Posts: 42
Joined: Fri Feb 24, 2017 3:52 pm

Re: SD card file write

Post by SureshVakati » Sat Mar 04, 2017 4:07 am

Yeah.. it's 32 kHz, I need to check with scope on Monday.

Sent from my ONEPLUS A3000 using Tapatalk

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: SD card file write

Post by dhylands » Sat Mar 04, 2017 4:46 am

And make sure that it's actually oscillating while you're experiencing the time returning zero. With this type of circuit the act of testing with the scope can make the circuit work.

User avatar
SureshVakati
Posts: 42
Joined: Fri Feb 24, 2017 3:52 pm

Re: SD card file write

Post by SureshVakati » Thu Mar 09, 2017 10:29 pm

When I run Clock Diagnostics using bootloader, it seems External crystal is running.

Code: Select all

BL>C
ClockDiagnostic
SYS:168000000 H:168000000, P1:42000000, P2:84000000
LSI:31264, LSE:32772
PLL Source

BL>C
ClockDiagnostic
SYS:168000000 H:168000000, P1:42000000, P2:84000000
LSI:31239, LSE:32769
PLL Source
Micropython time module returns 0, I reinstalled the firmware, still it does the same thing.

Code: Select all

>>> import pyb, time, os
>>> rtc = pyb.RTC()
>>> rtc.info()
262147
>>> rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0))
>>> print(rtc.datetime())
(2000, 1, 1, 1, 0, 0, 0, 0)
>>> time.time()
0
>>>
>>>

User avatar
SureshVakati
Posts: 42
Joined: Fri Feb 24, 2017 3:52 pm

Re: SD card file write

Post by SureshVakati » Fri Mar 10, 2017 2:03 pm

Changed this in stmhal/main.c (false>true), seems RTC is running okay now.

Code: Select all

#if MICROPY_HW_ENABLE_RTC
    if (first_soft_reset) {
        rtc_init_start(true);
    }
#endif
rtc.c has some timeout values, is anything timing it out before initialization?

Code: Select all

#define PYB_LSE_TIMEOUT_VALUE 1000  // ST docs spec 2000 ms LSE startup, seems to be too pessimistic
#define PYB_LSI_TIMEOUT_VALUE 500   // this is way too pessimistic, typ. < 1ms


holdenweb
Posts: 9
Joined: Wed Mar 09, 2016 12:40 pm

Re: SD card file write

Post by holdenweb » Sun Apr 30, 2017 2:08 pm

dhylands wrote:If you're writing to the sdcard from pyboard, then you really need to make sure you disable USB Mass Storage, otherwise you will get file corruption from the PC also overwriting the data that the pyboard wrote.
Only just seen this. Perhaps it explains why a couple of times I've had the experience of files being transmogrified to contain all 1s?

Perhaps bozos like me could be reminded somewhere in capital letters ... ;-)

regards
Steve

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: SD card file write

Post by pythoncoder » Mon May 01, 2017 8:16 am

I think the official docs should discourage the use of MSC mode and point users to tools such as rshell. If it were up to me I'd disable it by default on new boards. But I guess people expect a USB device to appear as a disk...

It's a source of needless problems.
Peter Hinch
Index to my micropython libraries.

Post Reply