Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Bootloader
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Mon Sep 23, 2019 7:42 am    Post subject: Reply with quote

AdrianJ wrote:
Compared to that, programming via the bootloader is a minor part of the job.

An unnecessary job, if you can do it at once. Except this is your only test of UART-functionality, then it's a weak one.
Quote:
complex series of tests
does not sound like that.
If your argument however would be to test overall loader functionality, I'd give you a point.
It's up to you how to test your product, but as the issue was:
Quote:
I have been trying unsuccessfully to incorporate a bootloader at the time of programming the chip

discussing your preferences is kind of moot.
It would be more interesting to learn about the outcome of:
Quote:
cut out manually &F000 * 2 bytes = 122880 bytes from start of the bin and save it as your loader.bin
By including this modified bin with the help of $BOOT and $INC at &hF000 you will get a working solution.
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Mon Sep 23, 2019 11:52 pm    Post subject: Reply with quote

@MWS
I will let the OP decide whether what I suggested is useful for what he wants to do.

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Tue Sep 24, 2019 5:17 am    Post subject: Reply with quote

AdrianJ wrote:
I will let the OP decide whether what I suggested is useful for what he wants to do.

The TO will surly appreciate that you allow him to decide about your suggestion.
Back to top
View user's profile
njepsen

Bascom Member



Joined: 13 Aug 2007
Posts: 469

newzealand.gif
PostPosted: Tue Sep 24, 2019 10:53 pm    Post subject: Reply with quote

MWS - my apologies for not replying to you earlier - ive been away for a few days on an installation. A booloader in assembler !!?? I have not done any assembly since playing with a 6502 about 35 yrs ago - and i was struggling then. (In fact i still have Leventhals book on" 6502 assembly programming" and a date in the fly says jan 1985.) So an assembly code bootloader is beyond me in skill, knowledge and time. BUT I do like your great idea
Quote:

Another idea would be - in case the bootloader itelf is seldom altered - to create your loader regularly, then cut out manually &F000 * 2 bytes = 122880 bytes from start of the bin and save it as your loader.bin
By including this modified bin with the help of $BOOT and $INC at &hF000 you will get a working solution.
Using a hex-editor this is done in less than a minute.


I do not change the bootloader. What I have been doing is what Adrian described ( hi Adrian) - I program the BL using hardware then load the main using an Sd or by programming it over the air. That way i know that part of it is working. Then after running function test program which tests all I/O and uarts, i run several boards for 2 weeks fully live. But it would be great to be able to program the BL and the main in one hit. I will try your suggestion and get back to the forum.

_________________
Neil
Back to top
View user's profile
njepsen

Bascom Member



Joined: 13 Aug 2007
Posts: 469

newzealand.gif
PostPosted: Wed Sep 25, 2019 12:57 am    Post subject: Reply with quote

Well - I programmed my normal BL into a chip, and ran it to make sure it was working correctly . On examination with my programmer, the chip was empty except for 1E000 and above as expected. I then pulled off the entire flash using the avr-usb embud programmer and saved it as a hex file. I then deleted everything from 0000 to 1E000 with a hex editor (PSad) and re-saved it as a hex file. I then pulled the file into the buffer in the programmer and saved it as MWSBL.bin
I then attached the following to the end of my main.bas

Code:

lots of code
End

$boot = &HF000
$inc BL , nosize , "j:\Dropbox\projects\MWSBL.bin"


when I ran the compiler i got:
Quote:

Error:344 Line 7713 Program will overwrite bootloader[122880 too long] .... etc


because my bin file is 128k, which is too long.
The problem i am having trouble with is saving the hex file ( with the relative branching in it) to bin for the $inc instruction.

_________________
Neil
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Wed Sep 25, 2019 9:10 am    Post subject: Reply with quote

njepsen wrote:
A booloader in assembler !!??

Open boot.bas from the samples section and tattaaa, there it is, a bootloader in assembler.
I did notice you work with a SD-card loader, so it was clear to me that assembler won't work for you.
But then, if I write something, I think about someone else will read it and thus it's good to have this issue addressed and explained why relocatable ASM code works, while others won't.

Quote:
But it would be great to be able to program the BL and the main in one hit.

That's what I thought too and it was the original topic.
Adrian's message is surly valid in its own context, but has no connection with the technical question: Can I do it? If yes, how can it be done?
That's what I wanted to discuss here, and not Adrian's message of Do not drive over 40mph within city limits!, while the question was How do I drive my car safely at 140mph on a closed race circuit?

Quote:
I then pulled off the entire flash using the avr-usb embud programmer and saved it as a hex file. I then deleted everything from 0000 to 1E000 with a hex editor (PSad) and re-saved it as a hex file. I then pulled the file into the buffer in the programmer and saved it as MWSBL.bin

You've meant 1E000 bytes, or to address :10E00000 in the hex-file?
For the first, you've created a mess with this approach, for the second the reconversion will again add fill-bytes.
Remember, a bin-file does not contain addresses, if you want to make something start at word address &h100, the void before must be filled with padding bytes.
I do also not understand why you use a hex-editor for editing a hex-file, which is a standard ASCII text file.
This I wrote
Quote:
Using a hex-editor this is done in less than a minute.

because you have to work on a binary file, where a hex-editor is the correct choice.

I suggest to use the bin-file the compiler spits out, which proves working after you've flashed it.
You can also take intermediate steps if you like, but then convert the downloaded bootloader.hex completely into bootloader.bin, do not edit the hex.

Then open the bootloader.bin within your hex-editor and delete &h1E00 bytes.
You'll know exactly where the bootloader starts, as you will notice the sequence:
Code:
FF FF FF FF 8F EF 8D BF

where FF is empty space and 8F EF the first bootloader opcode, which translates to !LDI r24, &hFF.
8F must occupy the first position within the binary, all leading FF's needs to be removed.

Save and include this bin with $INC and it will work as desired.
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Wed Sep 25, 2019 11:50 pm    Post subject: Reply with quote

Ok, another way to achieve the target of being able to load both main and bootloader together is to use AVR Studio. That has the facility to load several hex files, eg bootloader, and main, into one chip. Once you have that, you can use Studio to read the entire flash back into another hex file. This becomes your master.

Saves a lot of fooling around patching bits of hex together.

AVR Studio is a bit of a beast.

Maybe some other programmers offer the facility to do the same thing. Note that many programmers do an auto chip erase before loading a hex file. That will wreck things. You need the facility to do one erase, then load several files separately.

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
njepsen

Bascom Member



Joined: 13 Aug 2007
Posts: 469

newzealand.gif
PostPosted: Wed Sep 25, 2019 11:53 pm    Post subject: SUCCESS !!! Reply with quote

MWS,
thank you for your patience. We (I say we, but really you) got there in the end. My problem was not the editing, which i was doing correctly as it is very easy with PSPad to see where the BL starts, but when & how I saved it. Opening the original .bin file using a 'hex' editor was the secret; I didn't actually try editing a .bin file with a hex editor.
I understand the issue (now) that is due to the BL assembler using relative addressing.
On my first trials, I got an err msg "Wrong Flash Size" when I ran the BL, but this was because I had the $boot & $Inc instructions after the "End" which was easy to diagnose.

So here is a step by step of what worked:

1. Test the bootloader (myBL.bas for example) until it is working when uploaded to the chip normally with the programmer.
2. Pull the myBL.bin file that the programmer generates into a hex editor like PSPad
3. Using edit/cut, delete all the FF from the beginning of the file until the start of the actual bootloader, which is easy to find (it starts at byte addr 1E000 for the atmega1284) being sure to leave the beginning of the BL code, which starts with 8F EF
4. Save as mynewBL.bin or whatever.
5. At the end of the main program before the "end" statement, include this code:
Code:

$boot = &hF000               ' boot reset word addr from data sheet
$inc BL,nosize,"mynewBL.bin"     'the full pathway is needed
End
Thanks again MWS for your help in getting this working.
 

_________________
Neil
Back to top
View user's profile
njepsen

Bascom Member



Joined: 13 Aug 2007
Posts: 469

newzealand.gif
PostPosted: Thu Sep 26, 2019 4:17 am    Post subject: Reply with quote

Addendum

The earlier error "Wrong Flash Size" was due to the fact that in my BL (which is a clone of Vogel Franz Josef's code) there is code on line 280 that checks the size of the "main". Because my "main now includes the length of the bootloader, this will cause an error.
The position of End was a red herring.
This code:

Code:

         Lfilelen = Lfilelen + Blinebytes
         If Lfilelen > Loadsize Then

            Print #1 , " Se"               ' Wrong Flash Size
            Berror = 1
            Exit Do

         End If

should be changed by deleting the first line of code, to:

Code:
 
         ' Lfilelen = Lfilelen + Blinebytes
         If Lfilelen > Loadsize Then

            Print #1 , " Se"               ' Wrong Flash Size
            Berror = 1
            Exit Do

         End If

_________________
Neil
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Thu Sep 26, 2019 6:41 am    Post subject: Reply with quote

njepsen wrote:
that in my BL (which is a clone of Vogel Franz Josef's code) there is code on line 280 that checks the size of the "main".

Does that tell you feed your bootloader via SD-card with the now combined bin?
You should be careful disabling security measures, as you won't like the bootloader trying to overwrite itself.
Back to top
View user's profile
njepsen

Bascom Member



Joined: 13 Aug 2007
Posts: 469

newzealand.gif
PostPosted: Tue Oct 08, 2019 4:43 am    Post subject: Reply with quote

Hi MWS,
sorry - its taken me a week to get back to this and do some more testing.

There is a problem, and it caused by the fact that Josef's bootloader uses filelen(filenamehex) as part of checking that the file is not too big; and of course the main (with $boot = &HF000 and $Inc BL,nosize, name ) is now suddenly very large and the line "flash wrong size" of the bootloader will think that the BL section is being overwritten and stop. (excuse the anthropomorphism)
So - because I have over 70 units in the field with this bootloader installed (copied below), I wont be able to use your new cunning method (that works perfectly in the shop), because they will all stop at &HF000*2.
thinks ----Unless i can bootload the new bootloader using the old bootloader, but I can't because the old bootloader thinks the new BL is 363855 bytes long- that's the hex file length. still thinking ...

Code:


'-------------------------------------------------------------------------------
'                          Bootloading from MMC/SD or CF
'                    (c) Vögel Franz Josef / MCS Electronic
' Bootloader works with HEX or/and BIN files from a Mass storage device
' supported by AVR-DOS (http://members.aon.at/voegel or www.mcselec.com)
' DOSBOOT 3

'-------------------------------------------------------------------------------
' following features are implemented:
' - check a Pin for activating bootloading
' - Check for file "BOOT.BIN" in root directory
'   If Exists
'   - Check File-length to fit in Program-area
'  $prog &HFF , &HCE , &HD6 , &HFF                             ' generated. Take care that the chip supports all fuse bytes.
'   - Program Content of "BOOT.BIN" to Flash
'   - Rename File "BOOT.BIN" to "BOOTDONE.BIN"
'   - Leave Bootloader and start Main Program
' - Check for file "boot.hex" in root directory
'   If Exists:
'   - Check the Hex-File(record-format) with file-length
'   - program flash with content of the Hex-File
'   - Rename File "BOOT.HEX" to "BOOTDONE.HEX"
'   - Leave Bootloader and start Main Program
' In Case that a checked point fails, the main program is started immediately
'
' The program to flash must be stored either in HEX-Format (BOOT.HEX) or in BIN-Format
' (BOOT.BIN), in the root Directory of the card at start time.
' The Bootloader has a size of appr. 7300 Bytes, so Boot-loader size of 8192 Bytes
' has to be set.
' Set bootloader-start to &HF000 at M128 and &H7000 at M64,&HF000 for M1284P
'-------------------------------------------------------------------------------
' Output of bootloader on RS232
' B ... Boot loader started
' C ... Check Card
' D ... Init DOS File System
' d     = error reading DOS file system
' e## . Error occured with errorcode in hex-format(##)
' F ... Checking HEX-File
' I ... DOS-Error during file-opening
 'L      Line error
' M ... Start of Main program
' N ... No boot file found
' P ... Programming Flash
' R ... Renaming file
' S ... Size-Error of Flash-File
'sd     = sd init error

$prog &HFF,&HC7,&HD0,&HFD
Dim Starterr As Byte
Starterr = Peek(0)
Writeeeprom Starterr , 80                                   'save MCUSCR  (Register 0) to eeprom
Starterr = 125
Writeeeprom Starterr , 100                                  'confirm that BL is present

$regfile = "m1284pdef.dat"
Const Loaderchip = 1284

$loader = &HF000                                            ' 4096 words, starts at HF000
Const Maxwordbit = 7                                        ' Z7 is maximum bit                                   '
Const Loadsize = &HF000 * 2                                 ' highest Number of bytes to load

$crystal = 9830400
$hwstack = 128
$swstack = 128
$framesize = 128

' Define here name of Hex-File
Const Filenamehex = "Boot.hex"

Const Filenamehexdone = "BootDone.hex"

Disable Interrupts
Open "comc.3:38400,8,n,1" For Output As #1                   'jepsen debug port
Print #1 , "start BL"                             ' B = Boot-loader Started
Waitms 500                                                  ' Time for Card to settle
'-------------------------------------------------------------------------------

Dim Btemp1 As Byte

Print #1 , "chk SD"               'Checking SD card
                                   'ver boot2
 $include "config_mmcsd_hc.bas"                             'set up the high capacity SD card comms ver boot2.1

' Check success of card initializing
If Gbdriveerror <> 0 Then
   Print #1 , "sd err"  'sd init error
   Print #1 , "e" ; Hex(gbdriveerror)                       ' Error during card initializing
   Goto Startmain
End If


' Include AVR-DOS Configuration and library

$include "Config_AVR-DOS_boot.BAS"

Btemp1 = Initfilesystem(1)
                                                             ' use 0 for drive without Master boot record
If Btemp1 <> 0 Then

   Print #1 , " file sys err" ; Hex(btemp1)                             ' Error at reading file system
   Goto Startmain
End If

Const Maxword =(2 ^ Maxwordbit) * 2                         '128
Const Maxwordshift = Maxwordbit + 1
Const Maxpages = Loadsize / Maxword

Const Fn = 10                                               ' file-number


'Dim the used variables
Dim Strline As String * 80                                  ' input line from file
Dim Blinebytes As Byte                                      ' data bytes in hex-line
Dim Blinedataposition As Byte                               ' first/current position of hex-data in line
Dim Blineendposition As Byte
Dim Blinestatus As Byte
Dim Blinelen As Byte
Dim Strtemp As String * 4
Dim Berror As Byte                                          ' error byte

Dim Strname1 As String * 12
Dim Strname2 As String * 12

Dim J As Byte , Spmcrval As Byte                            ' self program command byte value
Dim Bprog As Byte

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


Dim Bcrc As Byte
Dim Buf(128) As Byte
Dim Bufpointer As Byte
Dim Lfilelen As Long


Disable Interrupts                                          'we do not use ints


'*****************************************************************************
'---- Start Boot loader
'
 'Check if boot.hex is there

   Lfilelen = Filelen(filenamehex)
   If Lfilelen > 0 Then
      Gosub Flashhex
   Else
      Print #1 , "No hex file"                                           'No boot file found
   End If



'***************************************************************************
Startmain:
Print #1 , "Start Main"                                               'start Main
Goto _reset
End
''**************************************************************************
Flashhex:
' 1. check Hex-File
Bprog = 0                                                   ' check Intel Hex File

Print #1 , "chk hex"    '      Checking hex file
Gosub Bootload


' 2. Flash from Hex-File
Bprog = 1                                                   ' program flash

Print #1 , "Prog flash"       'Programing Flash from Hex file
Gosub Bootload

#if Varexist( "FileNameHexDone")
      Strname1 = Filenamehex
      Strname2 = Filenamehexdone
      Kill Strname2
      Print #1 , "Rename hex"                                    'Renaming boot.hex file
      Name Strname1 As Strname2

#endif


Goto Startmain:

'***************************************************************************
' Boot loader part (same for File-Checking and Flashing)
Bootload:

Open Filenamehex For Input As #fn
If Gbdoserror > 0 Then
   Print #1 , "DOS err" ; Hex(gbdoserror)   'I = DOS error during file opening
   Berror = 1
   Goto Here:
End If


Page = 0
Wrd = 0

If Bprog = 1 Then
   Spmcrval = 3 : Gosub Do_spm                              ' erase  the first page
   Spmcrval = 17 : Gosub Do_spm                             ' re-enable page
End If


Berror = 0
Bufpointer = 1
Blinebytes = 0
Lfilelen = 0

Do

   If Blinebytes = 0 Then
      Gosub Loadhexfileline
   End If


   Select Case Blinestatus

      Case 0                                                ' read normal data line

         Lfilelen = Lfilelen + Blinebytes
         If Lfilelen > Loadsize Then

            Print #1 , " wrong flash size"               ' Wrong Flash Size
            Berror = 1
            Exit Do

         End If


         For Blinedataposition = Blinedataposition To Blineendposition Step 2

            Strtemp = Mid(strline , Blinedataposition , 2)
            Btemp1 = Hexval(strtemp)
            Buf(bufpointer) = Btemp1
            Incr Bufpointer
            If Bufpointer > 128 Then
               Gosub Writepage
               Bufpointer = 1
            End If
            Decr Blinebytes
         Next

      Case 1                                                ' address extend record

         Blinebytes = 0                                     ' prepare for reading next line


      Case 2
                                                      ' EOF Line read

         If Bufpointer > 1 Then
            Gosub Writepage
         End If
         If Wrd > 0 Then
            Wrd = 0
            Spmcrval = 5 : Gosub Do_spm
            Spmcrval = 17 : Gosub Do_spm
         End If
         Exit Do

      Case Else                                             ' Error

         Print #1 , "Line err "                                     'Line error
         Berror = 1
         Exit Do

   End Select

Loop


Close #fn
Here:
If Berror > 0 Then

   Goto Startmain                                           ' restart in case of error
End If


Return
'*******************************************************************************
Loadhexfileline:

   If Eof(#fn) <> 0 Then
      Blinestatus = 8                                       ' no regular end of File
      Return
   End If

   Line Input #fn , Strline

   If Gbdoserror <> 0 Then
      Blinestatus = 7                                       'DOS error
      Return
   End If

   Strtemp = Mid(strline , 1 , 1)                           ' check for starting ":"
   If Strtemp <> ":" Then
      Blinestatus = 6
      Return
   End If

   ' Check Checksum
   Blinelen = Len(strline)
   Bcrc = 0
   For Btemp1 = 2 To Blinelen Step 2
      Strtemp = Mid(strline , Btemp1 , 2)
      Bcrc = Bcrc + Hexval(strtemp)
   Next

   If Bcrc <> 0 Then
      Blinestatus = 9                                       'checksum error
      Return
   End If


   ' Number of bytes

   Strtemp = Mid(strline , 2 , 2)
   Blinebytes = Hexval(strtemp)
   If Blinebytes > 0 Then
      Blinedataposition = 10
      Btemp1 = Blinebytes * 2
      Blineendposition = Btemp1 + 8
   End If

   ' Type of Record

   Strtemp = Mid(strline , 8 , 2)

   Select Case Strtemp

      Case "00"                                             ' normal data record

         Blinestatus = 0

      Case "01"                                             ' address extend record (> 64KB)
         Blinestatus = 2

      Case "02"                                             ' EOF record
         Blinestatus = 1

      Case Else                                             ' unknown record type (Error?)
         Blinestatus = 5

   End Select

Return
'*******************************************************************************

'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
      Spmcrval = 1 : 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
          Wrd = 0                                           ' Z pointer needs wrd to be 0
          Spmcrval = 5 : Gosub Do_spm                       ' write page
          Spmcrval = 17 : Gosub Do_spm                      ' re-enable page

          Page = Page + 1                                   ' next page

          If Page <= Maxpages Then                          ' avoid to erase first page of bootlaoder

             Spmcrval = 3 : Gosub Do_spm                    ' erase  next page
             Spmcrval = 17 : Gosub Do_spm                   ' re-enable page

          End If

      End If
   Next
Return



Do_spm:

   Z = Page                                                 'make equal to page
   Shift Z , Left , Maxwordshift                            'shift to proper place
   Z = Z + Wrd

   If Bprog <> 1 Then
      Return
   End If

   Bitwait Spmcsr.0 , Reset                                 ' check for previous SPM complete
   Bitwait Eecr.1 , Reset
                                      'wait for eeprom                                                 'add word
  ! lds r30,{Z}
  ! lds r31,{Z+1}
   #if Loaderchip = 1284
    !  lds r24,{Z+2}
    !  sts rampz,r24                                        ' we need to set rampz also for the M128
   #endif
  ! lds r0, {vl}                                            'store them into r0 and r1 registers
   !lds r1, {vh}
   Spmcsr = Spmcrval                                       'assign register
   !spm                                                     'this is an asm instruction
   nop
   nop
Return

 

_________________
Neil
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Tue Oct 08, 2019 3:51 pm    Post subject: Reply with quote

njepsen wrote:
its taken me a week to get back to this and do some more testing.

No problem.
Quote:
Unless i can bootload the new bootloader using the old bootloader, but I can't because the old bootloader thinks the new BL is 363855 bytes long- that's the hex file length. still thinking ...

If you would have mentioned this info in your entry post, i.e. that you plan to use the combined hex out in the field via existing bootloader, then I would have told you at the start: It won't work.

For sure it is possible to adapt your loader the way it stops before overwriting its bootloader-section, but then you first have to flash this new loader via ISP.

Within this controller architecture - as well it is not completely impossible to update the bootloader by itself - it's rather complicated and needs space for two loaders within the available bootloader range.

Think about how a bootloader works, it does so by overwriting each page by page-erase and then refilling it.
If you have one loader which resides at &hF000 and the loader erases this page, it starts to erase itself, it finally leads to the point, where the lately executed opcode affected by a page erase is erased together with the following opcodes, leaving the program counter in a void with random further behavior.

It would be possible for a loader to replace itself, but then you need a second loader with same capabilities like the first loader, the first loader would hand over code execution to the second loader, which then flashes main code including the then new first loader.

A few options how this second loader can be installed:
- flashed at workshop via ISP
- first loader creates a duplicate of itself, this needs relocatable loader code
- it comes with the hex-file on SD-card, the first loader's first job is then to flash the second loader from hex-file

No matter how the second loader is installed, after it is done successfully the first loader forwards code execution to the second loader, which then will flash the main code and finally replace the first loader.

Is it feasible within your setup? I doubt, your SD-card loader is pretty big in size, you need a double amount of loader space.
Both loaders must reside within the bootloader area, as commands altering flash can be only executed from there.

Does this help you with your current situation? No, as your installations only have the original loader installed, a new loader with capabilities to replace itself needs to be flashed via ISP first.
Is such a new loader advisable? Maybe, maybe not. If the loader has the ability to manipulate itself, it is as well able to commit suicide. I can think of security measures to protect against a dead loader, but this makes it even more complicated.

What was your initial intention? Did you like to create only one hex-file for both production and service?
Or was it what I've described, to also update the loader in one go?
Back to top
View user's profile
sentinel

Bascom Member



Joined: 02 Feb 2009
Posts: 141
Location: Tasmania

australia.gif
PostPosted: Wed Jun 15, 2022 7:24 am    Post subject: Reply with quote

Old thread, but I'm interested to know if any further progress has been made on flashing bootloader and main code at the same time.

Adrian, you mentioned that AVR Studio 7 can do this, and since this is what I use for production programming, I'd love to know more about how it's done. I've looked though the options, but can't see where that's possible.

When you have to flash 300 chips at a time, any time saved mounts up.
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 971

poland.gif
PostPosted: Wed Jun 15, 2022 11:06 am    Post subject: Reply with quote

Im doing this often.
First you must compile your bootloader with "Bootonly" option...



.. then attach generated BIN into main application.



I can simply disable this for new program versions loaded by bootloader USART`s/SDCARD`s.

If you program from BASCOM IDE you can even set fuses (at programming time) like disable CKDIV8/set external crystal and protect your code by setting LOCK BYTE.
Where when you program externally by BIN or HEX you must do this yourself Wink Im lazy Razz

Back to top
View user's profile Visit poster's website
sentinel

Bascom Member



Joined: 02 Feb 2009
Posts: 141
Location: Tasmania

australia.gif
PostPosted: Wed Jun 15, 2022 1:41 pm    Post subject: Reply with quote

Thanks for the quick reply, EDC.

After searching various forums, your method looks almost too straightforward to be true.

I'll give it a try with AVR Studio 7 and an STK500.

Thanks again.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
Jump to:  
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