View previous topic :: View next topic |
Author |
Message |
enniom
Joined: 20 Oct 2009 Posts: 537
|
Posted: Sun Jul 18, 2021 10:16 pm Post subject: |
|
|
Also, you can try 2.8.0.3 to isolate if it is the upgrade causing the problem.
E |
|
Back to top |
|
|
andro
Joined: 12 Mar 2007 Posts: 94 Location: Ljubljana
|
Posted: Wed Jul 21, 2021 6:45 am Post subject: |
|
|
Hi,
1. today I will connect a 'project' with a working bootloader (a xmega256a3u board) and try to flash it with bootloader. There were some Win updates going on a few days ago.... Just to be sure.
2. I never tried with that big $timeout... 1.6Mio? I'will try this too.
Thanks enniom. |
|
Back to top |
|
|
andro
Joined: 12 Mar 2007 Posts: 94 Location: Ljubljana
|
Posted: Wed Jul 21, 2021 6:49 am Post subject: |
|
|
Ok, the $timeot value that You have used is even 16Mio. This is a huge number, compared with my 400000. I hope, this is the solution for my problem.
BR
Andrej |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5914 Location: Holland
|
Posted: Wed Jul 21, 2021 11:44 am Post subject: |
|
|
you do not provide much info. but how did you set the fuses? and share the circuit. that something else works does not mean everything will work. _________________ Mark |
|
Back to top |
|
|
andro
Joined: 12 Mar 2007 Posts: 94 Location: Ljubljana
|
Posted: Mon Jul 26, 2021 10:17 pm Post subject: |
|
|
Hi!
I have checked bootloader app on a same PC and RS232 cabling with an xmega256a3u board. And it works fine, as it always did.
I have increased $timeout but no success.
However, I did not pay any attenton to the fusses. These are the default values:
WDWP = <none selected>
WDP = <none selected>
BOOTRST = APPLICATION
BODPD = DISABLED
RSTDISBL = [ ]
SUT = 0MS
WDLOCK = [ ]
BODACT = CONTINUOUS
EESAVE = [X]
BODLVL = 2V8
FDACT5 = [ ]
FDACT4 = [ ]
VALUE = 0x3F
FUSEBYTE1 = 0xFF (valid)
FUSEBYTE2 = 0xFF (valid)
FUSEBYTE4 = 0xFF (valid)
FUSEBYTE5 = 0xE1 (valid)
FUSEBYTE6 = 0xFF (valid)
BLBB = NOLOCK
BLBA = NOLOCK
BLBAT = NOLOCK
LB = NOLOCK
LOCKBITS = 0xFF (valid)
Bootloader does respond on "!". Then the timeout error.
See attachement.
|
|
Back to top |
|
|
andro
Joined: 12 Mar 2007 Posts: 94 Location: Ljubljana
|
Posted: Mon Jul 26, 2021 10:23 pm Post subject: |
|
|
And again, the bootloader code:
Code: | $crystal = 32000000 ' xmega32e5 is running on 32 MHz
$regfile = "xm32E5def.dat"
$hwstack = 40
$swstack = 40
$framesize = 40
'first enabled the osc of your choice
Config Osc = Enabled , 32mhzosc = Enabled 'internal 2 MHz and 32 MHz enabled
'configure the systemclock
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1 ' we will use 32 MHz and divide by 1 to end up with 32 MHz
$loader = &H4000 ' bootloader starts after the application
'this sample uses 38400 baud. To be able to use the Xplain which has a bootloader working at 9600 baud you need to use 9600 baud
Config Com1 = 115200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8 ' use USART C0
'COM0-USARTC0, COM1-USARTC2, COM2-USARTD0. etc.
Open "COM1:" For Binary As #1
Const Maxwordbit = 6 ' Z7 is maximum bit '
Const Maxword =(2 ^ Maxwordbit) * 2 '128
Const Maxwordshift = Maxwordbit + 1
Const Cdebug = 0 ' leave this to 0
'Dim the used variables
Dim Bstatus As Byte , Bretries As Byte , Bmincount As Byte , Bblock As Byte , Bblocklocal As Byte
Dim Bcsum1 As Byte , Bcsum2 As Byte , Buf(128) As Byte , Csum As Byte
Dim J As Byte , Spmcrval As Byte ' self program command byte value
Dim Z As Long 'this is the Z pointer word
Dim Vl As Byte , Vh As Byte ' these bytes are used for the data values
Dim Wrd As Word , Page As Word 'these vars contain the page and word address
Disable Interrupts 'we do not use ints
Rampz = 0
'We start with receiving a file. The PC must send this binary file
'some constants used in serial com
Const Cnak = &H15
Const Cack = &H06
Const Ccan = &H18
$timeout = 16000000 'we use a timeout
'When you get LOADER errors during the upload, increase the timeout value
'for example at 16 Mhz, use 200000
Bretries = 5 : Bmincount = 3 'we try 10 times and want to get 123 at least 3 times
Do
Bstatus = Waitkey(#1) 'wait for the loader to send a byte
If Bstatus = 123 Then 'did we received value 123 ?
If Bmincount > 0 Then
Decr Bmincount
Else
Print #1 , Chr(bstatus);
Goto Loader ' yes so run bootloader
End If
Else 'we received some other data
If Bretries > 0 Then 'retries left?
Bmincount = 3
Decr Bretries
Else
Goto Proces_reset 'goto the normal reset vector at address 0
End If
End If
Loop
'this is the loader routine. It is a Xmodem-checksum reception routine
Loader:
Do
Bstatus = Waitkey(#1)
Loop Until Bstatus = 0
' Spmcrval = &H20 : Gosub Do_spm ' erase all app pages
'^^^^^^^ THIS LINE REMARKED
Bretries = 10 'number of retries
Do
Csum = 0 'checksum is 0 when we start
Bblocklocal = 1
Print #1 , Chr(cnak); ' firt time send a nack
Do
Bstatus = Waitkey(#1) 'wait for statuse byte
Select Case Bstatus
Case 1: ' start of heading, PC is ready to send
Csum = 1 'checksum is 1
Bblock = Waitkey(#1) : Csum = Csum + Bblock 'get block
Bcsum1 = Waitkey(#1) : Csum = Csum + Bcsum1 'get checksum first byte
For J = 1 To 128 'get 128 bytes
Buf(j) = Waitkey(#1) : Csum = Csum + Buf(j)
Next
Bcsum2 = Waitkey(#1) 'get second checksum byte
If Bblocklocal = Bblock Then 'are the blocks the same?
If Bcsum2 = Csum Then 'is the checksum the same?
Gosub Writepage 'yes go write the page
Print #1 , Chr(cack); 'acknowledge
Incr Bblocklocal 'increase local block count
Else 'no match so send nak
Print #1 , Chr(cnak);
End If
Else
Print #1 , Chr(cnak); 'blocks do not match
End If
Case 4: ' end of transmission , file is transmitted
If Wrd > 0 Then 'if there was something left in the page
Wrd = 0 'Z pointer needs wrd to be 0
Spmcrval = &H25 : Gosub Do_spm 'write page
'^^^^^USE THE NEW ERASE AND PROGRAM COMMAND
End If
Print #1 , Chr(cack); ' send ack and ready
Waitms 20
Goto Proces_reset
Case &H18: ' PC aborts transmission
Goto Proces_reset ' ready
Case 123 : Exit Do 'was probably still in the buffer
Case 124 : Exit Do
Case Else
Exit Do ' no valid data
End Select
Loop
If Bretries > 0 Then 'attempte left?
Waitms 1000
Decr Bretries 'decrease attempts
Else
Goto Proces_reset 'reset chip
End If
Loop
'write one or more pages
Writepage:
For J = 1 To 128 Step 2 'we write 2 bytes into a page
Vl = Buf(j) : Vh = Buf(j + 1) 'get Low and High bytes
R0 = Vl 'store them into r0 and r1 registers
R1 = Vh
Spmcrval = &H23 : Gosub Do_spm 'write value into page at word address
Wrd = Wrd + 2 ' word address increases with 2 because LS bit of Z is not used
If Wrd = Maxword Then ' page is full
Wrd = 0 'Z pointer needs wrd to be 0
Spmcrval = &H25 : Gosub Do_spm 'write page
'^^^^^USE THE NEW ERASE AND PROGRAM COMMAND
Page = Page + 1 'next page
End If
Next
Return
Do_spm:
Z = Page 'make equal to page
Shift Z , Left , Maxwordshift 'shift to proper place
Z = Z + Wrd 'add word
! lds r30,{Z}
! lds r31,{Z+1}
Nvm_cmd = Spmcrval
Cpu_ccp = &H9D
! spm 'this is an asm instruction
Do_spm_busy:
! lds r23, NVM_STATUS
! sbrc r23,7 ;if busy bit is cleared skip next instruc tion
! rjmp do_spm_busy
Return
Proces_reset:
Rampz = 0
Print #1 , "RST"
Goto _reset 'start at address 0
|
Thanks for help in advance to all.
BR
Andrej |
|
Back to top |
|
|
enniom
Joined: 20 Oct 2009 Posts: 537
|
Posted: Tue Jul 27, 2021 1:28 am Post subject: |
|
|
.
Have you tried changing the fuse from:
BOOTRST = APPLICATION
to
BOOTRST = BOOTLOADER
??
E |
|
Back to top |
|
|
andro
Joined: 12 Mar 2007 Posts: 94 Location: Ljubljana
|
Posted: Tue Jul 27, 2021 8:15 am Post subject: |
|
|
Hi,
no, I did not.
Will test in the afternoon.
Sincerely, I have never paid attention to that. And not even yesterday, when I tested bootloader on Xmega256a3u...
BR |
|
Back to top |
|
|
andro
Joined: 12 Mar 2007 Posts: 94 Location: Ljubljana
|
Posted: Tue Jul 27, 2021 9:19 pm Post subject: |
|
|
Hello
setting FUSEBYTE2.BOOTRST = BOOTLOADER did not solve my problem
And I'm sure, COM port is ok. In both directions.
BR
Andrej |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5914 Location: Holland
|
Posted: Wed Jul 28, 2021 9:23 am Post subject: |
|
|
if you call the boot process from the main app there is no need to set the reset vector to the bootloader.
but i would strongly suggest to use the reset vector and use the fuse. when an app is not responding for some reason, there is one thing that will always work : a reset. this can be a simple reset button.
and the idea of the boot loader is that it checks if a character is received and then it starts the process. if not it continue like normal.
an empty chip contains &HFFFF which is also an instruction but does not do a thing. so when you reset the chip it will simply start at address 0000 and then execute this FFFF instruction. then it goes to address 1 etc.
till it runs into the boot loader app.
so when you program a chip the first time with only the loader it will appear to work.
so you always need a test where you load a sample program, and then run the boot loader again.
ok in your case you can not even run the boot loader?
the code you get : possible return codes of the PC bootloader.exe
-6005 Cancel requested
this means the app sends a cancel.
you still did not provide a circuit. just because something else on the port seems to work does not mean it works properly. or that your hardware is ok,
the first test would be testing the hardware without loader. run a test to see if the serial port is properly functioning. you can do this by sending a lot of different data. and echo it back, then test if they are the same.
ideal would be to use the init part of the loader
when that works and there is no problem with the hardware, you compile the loader.
program it and then verify with a complete read of the chip if it is written correctly. and at the right address.
you can also test the loader step by step. for example, let it toggle some led. or send some data to the serial port.
thus in that case it will not loader any code but it is a simple test to see if the loader code works at that address with the fuse set. _________________ Mark |
|
Back to top |
|
|
enniom
Joined: 20 Oct 2009 Posts: 537
|
Posted: Thu Jul 29, 2021 12:19 am Post subject: |
|
|
.
Andro and Mark,
Looking at the output, it does seem as if the Bootloader is responding:
Quote: | Loader returned: 123 |
Therefore it seems, this code is executed correctly:
Code: | Print #1 , Chr(bstatus);
Goto Loader ' yes so run bootloader
|
But fails after entering the Loader: Do Loop
E |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5914 Location: Holland
|
Posted: Thu Jul 29, 2021 8:07 am Post subject: |
|
|
yes it looks that way but there can be many reasons for that. since there is a problem a step by step approach is required to find the problem. it is similar how i developed these loaders in the first place. _________________ Mark |
|
Back to top |
|
|
andro
Joined: 12 Mar 2007 Posts: 94 Location: Ljubljana
|
Posted: Thu Aug 12, 2021 9:44 pm Post subject: |
|
|
Hello,
I was on hollidays last 14 days, hiking in mountains...
Now I took another HW, this time with FT230XS tied to the COM1 port of the Xmega32E5.
Bootloader works fine now! You were right, Mark. I have to admit, that there was a HW issue indeed.
However, I'm not sure what is the problem - but I asume, the problem is in a cheap MAX3232 china board, that I took with the first HW.
I will do some further test with my own RS232 converter ST3232 or MAX3232, bought at well known EU on-line provider, as I usaualy do.
Sorry for waisting Your time. I'm really ashamed.
Best regards
Andrej |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5914 Location: Holland
|
Posted: Fri Aug 13, 2021 6:28 pm Post subject: |
|
|
another mystery solved
actually i gave up using cheap parts after finding wires without connections, connectors that did not connect, etc. But when i got fake parts that was the limit for me. it is nice for hobby but not for professional reliable operation.
And long term availability is important too.
My personal opinion of course. _________________ Mark |
|
Back to top |
|
|
andro
Joined: 12 Mar 2007 Posts: 94 Location: Ljubljana
|
Posted: Mon Aug 16, 2021 8:48 pm Post subject: |
|
|
A totaly agree, Mark.
The PCB and 100nF caps were fine - but the problem was in MAX3232. When I replaced it with one from Farnell, it works.
I had to make 4 prototype boards, therefore I used this cheap option. And I replaced all 4 MAX3232s.
Again - sorry for waisting Your time.
Best regards
Andrej |
|
Back to top |
|
|
|