Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Nand flash read isuue

Status
Not open for further replies.

oddparity

Newbie level 4
Joined
Oct 16, 2018
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
53
I have a custom made board based on Atmel SAME70Q20 microcontroller. I am having trouble figuring out a strange bug related to external Flash. I have integrated ELM Chan's FATFS in the code and sometimes if I add some code or modify anything even if it doesn't have anything to do with the file system. It gives me FR_NO_FILESYSTEM error. I traced the problem to flash read. Actually during the initialization when it is looking for the FATFS boot record the read on that sector returns all bytes as 0xFF and doesn't give any error either. The call to f_mkfs also completes successfully and I know that the data was written to the flash because if I read the boot sector just after formatting the boot record is there, but later when it initializes further the same sector's read returns 0xFF in the whole sector.

This issue is driving me nuts and I seem to have exhausted all my knowledge and hit a roadblock. If anyone could point to where could the problem lie, or where to investigate, it will be very helpful.

Thanks
 

How we can help you?
Hi,
I just wanted some advice on how to go about debugging this kind of issue as I can't think of where exactly to look or what could cause this kind of behavior. I have been trying to debug with putting debug strings but that only got me so far as to confirm that flash read is returning all bytes as 0xFF but I don't know why.
 

Hi,

I'd use a scope to:
* check waveform (tableau, spikes, risetime falltime...)
* timing
* voltage levels

Post your schematic, and post your PCB layout and wiring.
Maybe you have lengthy wiring, missing a GND plane, missing power supply capacitors...

Klaus
 

A general assumption could be that you don't handle the flash memory correctly. Little information has been yet given about the system, e.g. which flash device is used.

I would expect a flash translation layer between the raw NAND flash memory and FATFS, as it's e.g. implemented in the controller of a memory card.
 

Hi,

I'd use a scope to:
* check waveform (tableau, spikes, risetime falltime...)
* timing
* voltage levels

Post your schematic, and post your PCB layout and wiring.
Maybe you have lengthy wiring, missing a GND plane, missing power supply capacitors...

Klaus

I don't have a scope or logic analyzer currently, I have asked my lead for one and hoping to get it soon.
As for the schematics, the board designing part is handled by separate department, I'll try to get the schematics if you think it could be a hardware problem. Actually I consulted with one of the guy who created the PCB and he said he was pretty sure there is no problem in the hardware.
 

sometimes if I add some code or modify anything even if it doesn't have anything to do with the file system. It gives me FR_NO_FILESYSTEM error.
Have you looked in the firmware for any time-out setup?
Have you disabled interrupts during memory access?
 

Update:- I fixed my issue but I still don't understand what was the exact problem. If anyone could help understand it (just to satisfy the curiosity) would great. Actually it was the gcc optimization that was causing the problem. We were using the O1 optimization and I got a hunch that it might have something to do with the optimization. When I disable the optimization it works fine, furthermore if I disable the optimization specifically for files containing the raw nand access api the code works fine.

Although I think I am wrong but what lead me to look in this direction is that I had read that compilers align or not align the data and code at word boundary depending upon some flag because it is faster to access a word at a time for CPU than say something which starts at fraction of word which causes more CPU cycles. Since my issue appeared or disappeared randomly after some code change, I thought maybe some code or data was getting aligned or dis-aligned which somehow affected the execution but that doesn't seem to be the case.

So if anyone can explain what flags in O1 level optimization could affect the code in such way.

Following are the flags in O1 optimization in gcc for reference:

Code:
-fauto-inc-dec 

-fbranch-count-reg 

-fcombine-stack-adjustments 

-fcompare-elim 

-fcprop-registers 

-fdce 

-fdefer-pop 

-fdelayed-branch 

-fdse 

-fforward-propagate 

-fguess-branch-probability 

-fif-conversion2 

-fif-conversion 

-finline-functions-called-once 

-fipa-pure-const 

-fipa-profile 

-fipa-reference 

-fmerge-constants 

-fmove-loop-invariants 

-fomit-frame-pointer 

-freorder-blocks 

-fshrink-wrap 

-fshrink-wrap-separate 

-fsplit-wide-types 

-fssa-backprop 

-fssa-phiopt 

-ftree-bit-ccp 

-ftree-ccp 

-ftree-ch 

-ftree-coalesce-vars 

-ftree-copy-prop 

-ftree-dce 

-ftree-dominator-opts 

-ftree-dse 

-ftree-forwprop 

-ftree-fre 

-ftree-phiprop 

-ftree-scev-cprop 

-ftree-sink 

-ftree-slsr 

-ftree-sra 

-ftree-pta 

-ftree-ter 

-funit-at-a-time

Thanks
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top