Just wanted to point out a potential problem when using the sam7s flash programming capability.
I’m using reset_halt in my configuration file. I connect to my target, issue a reset, and then do a flash info. Since the main oscillator has not been enabled, the MAINRDY bit is not yet set, so the clock speed info is not valid. However, cidr in the at91sam7_info structure does get set. Any subsequent attempts to read the part info are blocked by code that tests for a non-zero cidr. This makes it necessary to kill the openocd server and restart it, then allow the processor to run until the clock is configured. At this point the flash commands should operate as expected. I’m not sure what the proper solution is in the case of an erased part. It looks like writing a 0 to FMCN may be okay in this case since the clock period should be greater than 30 us, but I’m not sure.
Also, if I’m interpreting the datasheet correctly, FMCN should be set based on the Master Clock frequency, not the Main Oscillator frequency. I think we need to take the PLL configuration into account.
I’ve got a simple patch that changes the code such that at91sam7_read_part_info always gets called. Should I add it to the openocd patches at berlios, or would you prefer that I email it to you?
Do you want to write the clock speed detection code? I was going to do it, but I will wait if you prefer to do it yourself.
I can do it, I am already working on the GPNVM bits so there will be a patch coming “real soon now” anyway. But you can put it at the berlios patch or just in this forum.
The Main Clock frequency is estimated from MAINF. Do you think it is necessary to
be able to set the precise crystal frequency ? This means some changes must be done
to the configuration command. I think it is nice that we dont have to set it manually.
My patch is very simple. It is likely that you have a better idea of how to fix this.
I don’t think we need to enter the clock frequency manually. I think using MAINF will be close enough. I suspect that’s what the SAM-BA bootloader does. I’m working on the clock frequency stuff now.
I have briefly tested it on my atmel eval board and it appears to work, both after reset when the clock is 32 kHz, and after running when the clock is 48 MHz.
I added a master clock valid flag, but have not yet made use of it. I hope to add this tomorrow.