how to calculate nandflash address?

For SAMA5D2 Xplained, SAMA5D3 Xplained and SAMA5D4 Xplained

Moderator: nferre

leo.ni
Posts: 52
Joined: Mon Jun 06, 2016 4:20 am

how to calculate nandflash address?

Fri Mar 24, 2017 2:21 am

Hi,all。 i used custom board based on sama5d3-xplained,and run ucosii on it.i boot my
application via at91bootstrap directly. i flash my board use sam-ba v2.16. it's work fine. Now, i want to update firmware via usb port, i don't know the address where the new firmware write to. in sam-ba, i set address is 0x40000.Where should i write my new firmware ?Pls help me,Thanks!
blue_z
Location: USA
Posts: 1504
Joined: Thu Apr 19, 2007 10:15 pm

Re: how to calculate nandflash address?

Sat Mar 25, 2017 12:41 am

leo.ni wrote:Where should i write my new firmware ?
Actually you can use any starting address that you please, but alignment to a (flash) page is practical.
But if you plan to do selective updates (i.e. you do not want to erase the entire flash and have to do a complete write), then the (smallest) unit of allocation should be an erase block (whatever that is for your particular NAND chip).
IOW align the firmware image to the start of an erase block, and modify AT91Bootstrap to access this location.

Regards
leo.ni
Posts: 52
Joined: Mon Jun 06, 2016 4:20 am

Re: how to calculate nandflash address?

Sat Mar 25, 2017 3:54 am

Thanks,Blue_z! i send the *.bin file(new firmware) from pc to my board via usb,and write it to nandflash with old firmware and reboot myboard,but the bootloader said "NAND: Failed in the integrity CRC". Perhaps bootload uses the CRC checksum mechanism? If so, how do I make a CRC checksum of my firmware file?
blue_z
Location: USA
Posts: 1504
Joined: Thu Apr 19, 2007 10:15 pm

Re: how to calculate nandflash address?

Mon Mar 27, 2017 12:33 am

leo.ni wrote:i send the *.bin file(new firmware) from pc to my board via usb,and write it to nandflash with old firmware and reboot myboard,
You're doing a poor job of describing what you have done.
"New" firmware, "old" firmware are ambiguous descriptions, and therefore meaningless.
leo.ni wrote:... but the bootloader said "NAND: Failed in the integrity CRC".
You are citing only one line of several from the program's output.
Why are you only providing a restricted description of the problem?
leo.ni wrote:Perhaps bootload uses the CRC checksum mechanism? If so, how do I make a CRC checksum of my firmware file?
You are not using proprietary code. The source code is available; after all, didn't you compile it?
If you had bothered to search the source code for that text string, you would not have come up with such a misguided conclusion, and be asking the wrong questions.


Regards
leo.ni
Posts: 52
Joined: Mon Jun 06, 2016 4:20 am

Re: how to calculate nandflash address?

Mon Mar 27, 2017 3:00 am

First, i'm sorry i didn't make it clear. i received my firmware via usb, and invoked function "write_mainfirmware" to write it to nandflash,and reboot my board.Then, the bootloader said "NAND: Failed in the integrity CRC".Before this,i'm sure it working fine(at91bootstrap+firmware).i want to add firmware update function to my firmware now.Thanks for your advice again!

Code: Select all

static const uint16_t main_firmware = 2;
struct SkipBlockNandFlash g_skipBlockNf;
uint8_t write_mainfirmware( void *buf ,uint32_t len )
{

	uint8_t ret = 0;
        
        assert( ( NULL != buf ) || ( 0 < len ) );
        
        ret = SkipBlockNandFlash_EraseBlock( &g_skipBlockNf, 
                                            main_firmware, 
                                            NORMAL_ERASE );

	if( !ret )
	{
		ret = SkipBlockNandFlash_EraseBlock( &g_skipBlockNf, 
                                                      main_firmware + 1, 
                                                      NORMAL_ERASE );
	}
	
	if( !ret )
	{
		ret = SkipBlockNandFlash_WriteBlock( &g_skipBlockNf, 
                                                      main_firmware,  
                                                      (uint8_t *)buf); 
	}

	if( !ret )
	{
		ret = SkipBlockNandFlash_WriteBlock( &g_skipBlockNf, 
                                                      main_firmware+1,  
                                                      (uint8_t *)buf + (len >> 1)); 
	}
	return ret;
}
blue_z
Location: USA
Posts: 1504
Joined: Thu Apr 19, 2007 10:15 pm

Re: how to calculate nandflash address?

Wed Mar 29, 2017 12:46 am

leo.ni wrote:i received my firmware via usb, and invoked function "write_mainfirmware" to write it to nandflash,and reboot my board.
That's still a vague description (and a minor rephrasing of what you previously wrote) that's on the level of what a non-technical end-user might provide. You haven't even properly described the failure message(s), so maybe it's no wonder that you cannot describe what you're doing.
leo.ni wrote:Then, the bootloader said "NAND: Failed in the integrity CRC".
You're wasting everybody's time by repeating what you already wrote without adding any elaboration and also ignoring my comments and questions.
leo.ni wrote:Before this,i'm sure it working fine(at91bootstrap+firmware).
But what exactly is this previous situation, and how is that different with the situation that "fails"?
Providing a snippet of your code with undefined variables and procedures is of little help to understanding what is going on.

What NAND chip and version of AT91Bootstrap are you using?

Regards
leo.ni
Posts: 52
Joined: Mon Jun 06, 2016 4:20 am

Re: how to calculate nandflash address?

Sat Apr 01, 2017 2:29 am

Thanks,Blue_z! i debugged my code,and find the error occured in function get_ext_onfi_param at at91bootstrap nandflash.c。i think i wrote my firmware directly to 0x40000 only, Maybe I missed something .Give me some advice again,Thanks!
blue_z
Location: USA
Posts: 1504
Joined: Thu Apr 19, 2007 10:15 pm

Re: how to calculate nandflash address?

Tue Apr 04, 2017 3:11 am

leo.ni wrote:Give me some advice again
Instead of only asking questions, respond to comments and questions put to you.
Why are you only providing a restricted description of the problem (i.e. show the full boot log)?
What NAND chip and version of AT91Bootstrap are you using?

Regards

Return to “SAMA5 Xplained”

Who is online

Users browsing this forum: No registered users and 1 guest