Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Low-level Flash programming (and clearing GPNVM2)


  • Please log in to reply
7 replies to this topic

#1 Sigma7

Sigma7

    Member

  • Members
  • PipPip
  • 15 posts

Posted 19 April 2012 - 01:11 PM

Hi, I'm still relatively new to the Netduino (Mini) and the AT91SAM7X512... I've developed a simple bootloader that (using SAM-BA) I've loaded into flash. It seems fine. It's using PIT and DBGU interrupts. ... But once in a while, I'd like to "reset" it so that it boots from the internal ROM, but *WITHOUT* having to connect Vdd to the ERASE (TP1) pin (and resetting). It seems (?) to me that what I WANT to do is to clear the GPNVM2 bit in EFC0/MC_FSR. I do this via: EFC0/MC_FMR <- 00300100 // FMCN = 0x30 (for 48MHz Master Clock), FWS = 1 EFC0/MC_FSR <- 5a00020d // KEY = 0x5a, PAGEN = 2 (for GPNVM2), FCMD = 0xd (CGPB) THEN IT HANGS! But it seems to have worked. That is, when I cycle power, it comes up in the SAM-BA ROM. Similarly, when I try to write/program flash, I do.. EFC0/MC_FMR <- 00480100 // FMCN = 0x48 (for 48MHz Master Clock), FWS = 1 EFC0/MC_FSR <- 51008001 // KEY = 5a, PAGEN = 0x80 (for page at 0x00108000), CMD = 1 (WP) AND IT HANGS TOO. But when I assert RESET, it boots okay and the flash was in fact written. Any thoughts? What am I missing? Thanks and regards, Tom

#2 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 19 April 2012 - 01:29 PM

Does the flashing routine run from RAM?

#3 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 19 April 2012 - 01:31 PM

Also, you'd probably need to check the status bits after issuing flash command to wait for the completion.

#4 Sigma7

Sigma7

    Member

  • Members
  • PipPip
  • 15 posts

Posted 19 April 2012 - 02:41 PM

(thanks for the fast turnaround!) (1) I WAS running it out of flash. But I downloaded a simple app that does the same thing from SRAM... and it still hangs. (2) My code checks that FRDY is clear before it returns. (p.s. in the original post, when I was trying to write a flash page, I indicated that I set the FSR to 51008001.. the leading 51 was really 5a.)

#5 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 19 April 2012 - 03:48 PM

I have found some information on AT91.com forum, for example Enter SAM-BA with AT91SM7X ? and Can't clear NVM bit 2 in order to boot on Samba at next boot. According to the first one, "Trying to clear GPNVM2 in firmware is a pain. It can be done, but it is full of undocumented gotchas. Basically, clearing the bit makes the program that is doing it crash. Even if interrupts are disabled". Perhaps the watchdog could be used to force reset when the processor gets stuck after flashing (?)

#6 Sigma7

Sigma7

    Member

  • Members
  • PipPip
  • 15 posts

Posted 19 April 2012 - 07:45 PM

Thanks again! I also tried looking at what SAM-BA does with its "applets" when one tries to "Boot from Flash" and "Boot from ROM" scripts.. and I think that they do essentially the same thing that I've been trying. And something about how they do it does NOT cause the chip to crash/hang. I'm still looking.... Tom

#7 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 19 April 2012 - 08:42 PM

I also tried looking at what SAM-BA does with its "applets" when one tries to "Boot from Flash" and "Boot from ROM" scripts..

Brilliant idea! It appears they call a function from ROM (IAP_PerformCommand at CHIP_FLASH_IAP_ADDRESS 0x300008) (?)

#8 Sigma7

Sigma7

    Member

  • Members
  • PipPip
  • 15 posts

Posted 19 April 2012 - 08:49 PM

Update... Even though my "applet" wasn't executing from flash.. the PIT interrupt service routine WAS executing from flash. I tried disabling interrupts from the applet and everything seems fine. (I also got some help from Przemyslaw Baranski on the at91 ARM7TDMI forum.) Thanks and regards, Tom




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.