View previous topic :: View next topic |
Author |
Message |
george2002
Joined: 23 Nov 2005 Posts: 74 Location: Krakow
|
Posted: Wed Oct 05, 2011 12:13 am Post subject: |
|
|
Quote: |
Hi
The card must be formated in FAT (not FAT32)
These settings should work:
#if Loaderchip = 128 ' Mega128
$loader = &HF000 ' 4096 words (startvektor of the bootloader, you will find the startaddress of the different bootloadersizes in the datasheet page 284 of the M128)
Const Maxwordbit = 7 ' Z7 is maximum bit '
Const LoadSize = &HF000 * 2 ' highest Number of bytes to load
#endif
The rest looks ok.
Tubeampman
|
Woooooow it works ! many many thanks for soo quick response !
PS
Now i can update program only from MMC or when i write main program and autoprogram chip with bascom and USBASP programmer then bootloader persist or not ?
Best Regards
George2002 |
|
Back to top |
|
|
Tubeampman
Joined: 27 Feb 2006 Posts: 100 Location: Bodo
|
Posted: Wed Oct 05, 2011 9:02 am Post subject: |
|
|
Hi
I believe as long as the fusebit for resetvector is set to bootloader, the bootloader will be persist.
Fixmann |
|
Back to top |
|
|
Tubeampman
Joined: 27 Feb 2006 Posts: 100 Location: Bodo
|
Posted: Wed Oct 05, 2011 2:15 pm Post subject: |
|
|
Hi
I was thinking to make a bargraph in the lcd to tell how many percent of
the progran that has been completed/uploaded from the hex on the SD-card.
Is there some variables/information that can be used in the bootloader for this task? (read the total size of the hex minus a counter of some sort?)
regards
Tubeampman |
|
Back to top |
|
|
reinhars
Joined: 29 Nov 2009 Posts: 114
|
|
Back to top |
|
|
njepsen
Joined: 13 Aug 2007 Posts: 469
|
Posted: Sun Dec 18, 2011 6:50 am Post subject: Atmega1284 |
|
|
I have an SD card connected as per the docs ( MOSI,MISO, ck & SS to cs ) to a 1284P.
The bootloader appears to be running and I get an err MSG: BCeE1M which I am at a loss to understand.
The hardware is OK because I have been reading and writing to the SD card for several months, every 15minutes.
I'll post my settings & connections.
I don't seem to be allowed to cut & paste my code ?? Serve meg = post2 not allowed or similar.
What do the code, quote and list icons do?
] _________________ Neil
Last edited by njepsen on Sun Dec 18, 2011 8:29 am; edited 4 times in total |
|
Back to top |
|
|
njepsen
Joined: 13 Aug 2007 Posts: 469
|
Posted: Sun Dec 18, 2011 8:09 am Post subject: my code |
|
|
_________________ Neil |
|
Back to top |
|
|
Ajaxelectronic
Joined: 22 Nov 2009 Posts: 171 Location: Iran
|
Posted: Sun Apr 22, 2012 11:57 am Post subject: |
|
|
Hi
i try DOS_Boot2 project with ATMega128 and all things was ok.
now i want to use INT0 or other INTs for Starting Bootloading but i can't write a correct program that work nice.
how can i use INTs for update my firmware? _________________ www.mrkelectronic.blogfa.com
Best Regards |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Sun Apr 22, 2012 12:33 pm Post subject: |
|
|
Something like this;
Code: |
On Int0 Isr_int0
Enable Int0
Config Int0 = Falling
Enable Interrupts
Isr_int0:
jmp $f000 'here your bootloader start address
Return
|
_________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
Ajaxelectronic
Joined: 22 Nov 2009 Posts: 171 Location: Iran
|
Posted: Sun Apr 22, 2012 4:48 pm Post subject: |
|
|
thanks Evert
i tested it and work nice. _________________ www.mrkelectronic.blogfa.com
Best Regards |
|
Back to top |
|
|
toto
|
Posted: Sat Mar 23, 2013 2:44 pm Post subject: |
|
|
Hello,
I using the Bootloader from Josef to update the firmware trough SD card. I can compile it and works fine if i use $include "Config_MMC.bas"
But now i need to use 4 Gb card, so i changed on the bootloader code to $include "Config_MMCSD_HC.bas"
The compiler show the folling error lines:
Error:344 line: 521 Program will overwrite bootloader [36 to long]
Error: 61 Line: 521 Label not found [_RAMPZ4 ]
This is what i have in the code to define
$regfile = "m2560def.dat"
Const Loaderchip = 2560
#if Loaderchip = 2560 ' Mega2560
$baud = 9600
$loader = &H1F000 ' 4096 words
Const Maxwordbit = 7 'Z7 is maximum bit '
Const Loadsize = &H1F000 * 2 ' <=== modified, it is ok.?? highest Number of bytes to load
#endif
$crystal = 8000000
$hwstack = 128
$swstack = 128
$framesize = 128
Joseph can help? or anyone else know what i make wrong?
Thanks in advance
Best regards
toto |
|
Back to top |
|
|
toto
|
Posted: Mon Mar 25, 2013 5:36 pm Post subject: |
|
|
Hello,
I have shrink the bootloader. Delete a few writeeprom lines that not comes with the bootloader, and it compile fine 99% again
With sd card of 256kb it works great but not with 4gb sd card.
It shows always Gbdriveerror value 233
This is a config_MMCSD_HC.bas that i use for Atmega2560
Const Cmmc_soft = 0
#if Cmmc_soft = 0
' --------- Start of Section for HW-SPI ----------------------------------------
''Portd_pin6ctrl = &B00_011_000
' define Chip-Select Pin
Config Pinf.1 = Output
Mmc_cs Alias Portf.1
Set Mmc_cs
Config Portb.0 = Output
Spi_ss Alias Portb.0
Set Spi_ss
'FOR XMEGA DEVICES
#if _xmega = 1
#else
' HW-SPI is configured to highest Speed
' Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = High , Phase = 1 , Clockrate = 4 , Noss = 1
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = High , Phase = 1 , Clockrate = 16 , Noss = 1
'Spsr = 1 ' Double speed on ATMega128
Spiinit
#endif
' --------- End of Section for HW-SPI ------------------------------------------
#else
#if _xmega
' Portd_pin6ctrl = &B00_011_000
#endif
#endif
'========== End of user definable range
Any idea why not works?
Thanks in advance
toto |
|
Back to top |
|
|
njepsen
Joined: 13 Aug 2007 Posts: 469
|
Posted: Fri May 31, 2013 10:49 am Post subject: |
|
|
Hi Adrian,
you said a long time ago Quote: |
You should set up the processor to boot into the bootloader space on reset, then drop back into normal program if a new bin file is not detected on the card. That way even if your normal program is corrupted, you can always reload a new one from card.
|
which raises an interesting possibility. I'm assuming you mean alter the bootloader so it doesnt change the name of boot.hex to bootdone.hex?? ; which of course would mean that every time the processor got a reset or watchdog, it would bootload from the unchanged .hex file.
I have been playing with sending a new boot.hex file plus 16bit CRC to my sd card via ftp ( and a modem). The update-ee is in the field 100km away so its important that is works. I'm trying to put a fall back into place so if by chance, that even if the new boot.hex file has the correct crc and end of line check sums are correct, it still manages to screw up the operating program. Because if that happens, I'm up for a 100km drive. Even if it watchdogs, it will try and boot from the (faulty) hex file. What I really need is a fall back hex file so if the processor doesn't successfully boot from the new file (the FTP'd one) it falls back to the good one, but I'm blowed if I can think how to do that.
regards _________________ Neil |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Fri May 31, 2013 12:45 pm Post subject: |
|
|
Could you number the image files , you update a eeprom entry to that number and set another eeprom byte to indicate ok for that number so if it fails you can see the number with no ok flag so load present ok file, you will also need an entry for present ok .
Needs a bit more logic but I hope you get my thinking
Regards Paul |
|
Back to top |
|
|
njepsen
Joined: 13 Aug 2007 Posts: 469
|
Posted: Fri May 31, 2013 10:03 pm Post subject: |
|
|
Hi Paul
If it fails, I lose sms contact with the remote unit. If the bootload works OK, I have a raft of sms commands and questions I can ask it ( including starting a bootload) but if the bootload were to fail, then i am blind. But worse than that, the program will also be corrupt, and the only code that would run is the bootloader.
Perhaps ... no that wont work. _________________ Neil |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Sat Jun 01, 2013 12:05 am Post subject: |
|
|
@njepsen
What I originally meant was that you should always go to the bootloader on a reset - eg on power up. That way, if the main program totally fails, you can still activate the bootloader and get a new program to load. Many people just put a jump to the bootloader within the main program, triggered by some event, eg a serial command, or switch closure. But then if the main fails, that jump can never be executed.
That is not the same as your scenario though. I know of no really secure way to load a new program, and recover from a failed load. The problem is that there is nowhere within the processor to hold a full copy of the new code as it comes in, and verify that it is valid, before installing it in Flash. The best I have ever managed is to put a very good checksum on the program, and verify that it is valid before starting the flash load.
I use a SHA1 512 bit hash key for the checking and validation, which seems pretty foolproof. The procedure is to create ( and in my case also encrypt ) the program hex file and append the hash to that. Then the bootloader reads that file from the SD card, decrypts it, and computes its own hash and checks that it matches the embedded hash. If that matches, we go ahead to upload the file to flash. I also change the filename on card, so that we dont reload it again. But much later I realised that can lead to your problem too. What I do now is to save the program file system date in eeprom, and compare any files on the card with that date. If the card contains a later date, I load that program into flash. That way I can just simply issue a new program, and all devices will update themselves with no other intervention. Never had that fail yet. But I can see that if a user screws something up, like remove the card or power down during an upload, bad things could still happen. In that case, the user incurs the cost of a service. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|