Author Topic: Bootloader----S-REC format file  (Read 33791 times)

Offline William

  • Newbie
  • *
  • Posts: 4
    • View Profile
Bootloader----S-REC format file
« on: August 13, 2009, 08:05:54 PM »
Hi All,

I just tested the uTaskerSerialBoot (IAR AVR32). It works well with my EVK1100 board. But I can not load my application code. I can not generate the correct S-REC format file by IAR compiler.   What is the PROGRAM_START_OFFSET  ? Is it 0x800000? I am not familiar with S-REC format.  Thanks for your advice.


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3232
    • View Profile
    • uTasker
Re: Bootloader----S-REC format file
« Reply #1 on: August 13, 2009, 11:03:25 PM »
Hi William

First of all I am pleased that the serial loader works on the EVK1100. I assume that this board has an RS232 connector on it.
The reason is that it doesn't work on the EVK1105 board (the one that I have) because it uses a virtual COM port connection via USB. There seems to be a problem with the driver used (probably at the PC side) since it doesn't react to XOFF commands when it is in the process of sending a data file (although it does when it is not actually in the process of sending... strange). The result is that the serial download actually overruns the UART since it has to be stopped for a short time during FLASH programming (every 16k or so).

But back to the question: The application has to be linked at the location defined in the Loader.h file (to match the serial loader configuration).

    #define UTASKER_APP_START         (FLASH_START_ADDRESS + (10*1024))  // application starts at this address

FLASH_START_ADDRESS is 0x80000000 on the UC3A, giving an application link address of 0x80002800

Regards

Mark

Offline William

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Bootloader----S-REC format file
« Reply #2 on: August 14, 2009, 12:20:26 AM »
Hi Mark,

Thanks for your reply.

Where can I set the application link address of  0x80002800? Is it in conf_isp.h file?

#define PROGRAM_START_ADDRESS         (AVR32_FLASH_ADDRESS + PROGRAM_START_OFFSET)

//#define PROGRAM_START_OFFSET          0x00002000 (Original one)

#define PROGRAM_START_OFFSET          0x00002800

I also got an error when I tried to generate the S-REC 19 format file by IAR-Compiler. The error is " Error[e122]: The address 0x80000000 is too large to be represented in the output format 'motorola-s19' "

There is no error if I select "motorola" format file (not S19). But it seems the bootloader does not like it. Any suggestions ? Thanks.

Regards,

William


Offline William

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Bootloader----S-REC format file
« Reply #3 on: August 14, 2009, 12:48:22 AM »
It seems that MOTOROLA-S19 uses 16-bit addresses.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3232
    • View Profile
    • uTasker
Re: Bootloader----S-REC format file
« Reply #4 on: August 14, 2009, 11:18:06 AM »
Hi William

I am a little bit worried that we are not discussing the same thing exactly.

conf_isp.h is not a file in the uTasker project and
#define PROGRAM_START_ADDRESS         (AVR32_FLASH_ADDRESS + PROGRAM_START_OFFSET)
also doesn't exist. These must be in an ATMEL AVR32 loader project (?)

The serial loader in the uTasker project is in the directory \Applications\uTaskerSerialBoot and is configured in the file Loader.h in that directory.

These are the relevant settings:
    #define SERIAL_SPEED              SERIAL_BAUD_115200                 // the Baud rate of the UART
    #define UTASKER_APP_START         (FLASH_START_ADDRESS + (10*1024))  // application starts at this address
    #define UTASKER_APP_END           (unsigned char *)(UTASKER_APP_START + (45*1024))// end of application space - after maximum application size
    #define INTERMEDIATE_PROG_BUFFER  (16*1024)                          // use an intermediate buffer and flow control to avoid character loss during FLASH writes



It may be that you want to load the ATMEL project (as your application). In this case you may need to set the application correspondingly, but that is so that it can do its work correctly and not due to linking. In the IAR project the link address is defined in the linker script file - the reference from the uTasker demo project is in
\Applications\uTaskerV1.4\IAR_AVR32\settings and called lnkuc3a0512_bm.xcl

/************************************************************************/
/*      Reset code is located at address 0x80000000 and up.             */
/************************************************************************/

-Z(CODE)RESET=80000800-8000090f


Here the link address has been set to 0x80000800 for compatibility with the uTasker Ethernet loader (Bare-Minimum loader) but can be set to 0x80002800 to work with the serial loader.

It is true that S19 is not suitable and S28 (motorola-s28 as selected in IAR) needs to be used due the the high address. The uTasker serial loader supports both.

Regards

Mark


Offline William

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Bootloader----S-REC format file
« Reply #5 on: August 14, 2009, 08:35:39 PM »
Hi Mark,

Thank you very much for your help.  I am able to generate the s37 format file. The serial loader loaded it successfully. But my application does not run after reboot and it still enters into the Serial Loader mode. I am testing the  ATMEL sample code ..\drivers\USART_EXAMPLE\usart .

I could not find the address 0x80002800 in the Serial loader project.

In the loader.h, I found following:

    #define UTASKER_APP_START         (FLASH_START_ADDRESS + (10*1024))  // application starts at this address
    #define UTASKER_APP_END           (unsigned char *)(UTASKER_APP_START + (45*1024))// end of application space - after maximum application size


In the IAR linker file lnkyc3a0512.xcl,

I replaced  the original address 80000000 with 80002800 in following places.


/************************************************************************/
/*      Reset code is located at address 0x80000000 and up.             */
/************************************************************************/

-Z(CODE)RESET=80002800-8007FFFF


/************************************************************************/
/*      Allocate code and const segments.                               */
/************************************************************************/

-P(CODE)CODE32=80002800-8007FFFF
-P(CONST)DATA32_C=80002800-8007FFFF
-P(CONST)USERDATA32_C=80800000-808001FF

// Initializers
-Z(CONST)INITTAB,DIFUNCT=80002800-8007FFFF
-Z(CONST)CHECKSUM,SWITCH=80002800-8007FFFF
-Z(CONST)DATA21_ID,DATA32_ID=80002800-8007FFFF
-Z(CONST)RAMCODE21_ID,RAMCODE32_ID=80002800-8007FFFF

-Z(CONST)ACTAB,HTAB=80002800-8007FFFF

« Last Edit: August 14, 2009, 08:43:41 PM by William »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3232
    • View Profile
    • uTasker
Re: Bootloader----S-REC format file
« Reply #6 on: August 14, 2009, 08:45:44 PM »
Hi William

The
    #define UTASKER_APP_START         (FLASH_START_ADDRESS + (10*1024))  // application starts at this addr
is the address 0x80002800
Note also that
    #define UTASKER_APP_END           (unsigned char *)(UTASKER_APP_START + (45*1024))// end of application space - after maximum application size
is defining a maximum application size of 45k - if your test application is larger than this you will need to increase it otherwise it will not be accepted.


lnkyc3a0512.xc - make sure that you are changing the one belonging to the application to be loaded any not the serial loader (which must stay at 0x80000000).

If, after a download, the new code is not starting it mean sthat the address 0x80002800 is 0xffffffff (or the force boot input is activated). You can command the application to start using the "go" command: if it then runs it means that the mode is being forced by a hardware input, if it crashes it means that the application hasn't been (fully) loaded. One reason for not fully loading is when the size is too large.

If you have debugging possibilities it is interesting to look at the FLASH content from the address 0x80002800 to see whether it has actually been (partially) written.

Regards

Mark


Offline averan

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Bootloader----S-REC format file
« Reply #7 on: November 10, 2009, 10:49:30 PM »
Hi Mark,
    I read this thread and I want to run the Serial Loader from uTasker in a EVK1101 like William declare, but I'dont have success. Reading the forum and documentation I see that you are implement several ports in other evaluation board (like EVK1105), could you please give me some tips in order to configure the Serial Loader for run in the EVK1101 board?


Thanks in advance for your help

Andrés

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3232
    • View Profile
    • uTasker
Re: Bootloader----S-REC format file
« Reply #8 on: November 11, 2009, 01:50:17 AM »
Hi Andrés

Unfortunately I don't have an EVK1101 myself so I can't do any tests, however the first thing to do is to get the serial loader to compile and run on the board.

I believe that the FLASH in the AT32UC3B as on that board is addresses differently to the FLASH in the AT32UC3A0512, on the EVK1105.
Make sure that you change the liner script to link the code to start at 0xa0000000 rather than 0x80000000. Also add a define _AT32UC3B to the project (eg. in app_hw_avr32.h) so that the define FLASH_START_ADDRESS will also match this.

When the loader operates correctly you should have an LED flashing (you may have to configure this to a different port ?) and you should get output on the USART specified in Loader.h (default USART0):

#define LOADER_UART                   0                                  // the serial interface used by the serial loader

Once this is working download attempts can be started.

Regards

Mark


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3232
    • View Profile
    • uTasker
Re: Bootloader----S-REC format file
« Reply #9 on: November 11, 2009, 06:39:43 PM »
Hi All

Since there are a couple of requests about AVR32 downloaders for the UC3B devices (which I haven’t actually used yet but very similar, without Ethernet) I will be ordering EVK1100 and EVK1101 kits to get on top of this.

However I just made a first attempt at changing the USART on the AVR32 UC3A  (EVK1105) – and realised that the USART above USART0 are not being opened due the following setting in app_hw_avr32.h:

    #define NUMBER_SERIAL        1                                       // use USART0 therefore no need for extra ones to be supported

This needs to be incremented to 2 to allow the USART driver to support channel 1 (or higher to support higher channels).

This may be of interest to anyone trying to run any of the kits from a different USART to USART0...

Regards

Mark


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3232
    • View Profile
    • uTasker
Re: Bootloader----S-REC format file
« Reply #10 on: November 19, 2009, 01:03:39 AM »
Hi All

I received an EVK1101 (with AT32UC3B0256) and managed to get the demo project running on it, but I needed to make a few adjustments. The following is a list of the things that I changed - there are a few incompatibilities between the AT32UC3A and AT32UC3B which I didn't expect but they were not difficult to make configurable on the processor type used.

  • Start address is the same as AT32UCA = 0x80000000 (I was convinced it was different when checking the two when first starting the AVR32 project but I obviously misread something then
  • Since the AT32UC3B0256 has 32k RAM I needed to create a new linker script to respect this - the original one was set to use 64k RAM and so can't run as it is
  • I set up a simulation model to display the 48 and 64 pin versions' pins correctly
  • Some of the bits used to control the clocks to the peripherals are at different bit positions. This was not expected since usually there is compatibility at this level, but no big deal - there is simply a set for each chip now...
  • The USARTs' port locations at at different positions, so this needed to be adapted (no surprise since the packages are so different but obviously couldn't work correctly before)
  • The PLL configuration was changed from 66MHz to 60MHz since this is the maximum speed of the AT32UCA types
  • Some port configurations were configured especially to suit the EVK1101 - to get blinking LED and the UART menu interface on USART1 (with DSUB)

That was more or less what was needed and now there is enough support to configure the serial loader (same setup) and check that loading new firmware works correctly.

Note that the chips are delivered from ATMEL with a pre-installed USB loader. In some cases this can be used as boot loader for your own projects (supports USB and not USARTs) but the code is available from ATMEL and can be configured differently if necessary. Supposedly it uses trampoline routines to allows code to be linked to the normal start location but can also be used with an application linked to other location to avoid these. Full details are in the ATMEL document: http://www.atmel.com/dyn/resources/prod_documents/doc7745.pdf

I don't intend actually using this myself (at the moment) since it is the serial loader which is presently what seems to be demanded but it may well be the best solution in some cases.

Regards

Mark

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3232
    • View Profile
    • uTasker
Re: Bootloader----S-REC format file
« Reply #11 on: November 20, 2009, 10:31:53 AM »
Hi All

I managed to get the serial loader operating on the EVK1101. It is not 100% because the menu is not understanding the first command entry - one needs to hit return once and then all is OK (it seems there is a spurious character in the input buffer after reset which I need to solve, but not so bad since the download itself is fine).

If anyone with EVK1101 wants to give it a test run already (before fully validated and added to a new project release) try with the attached files:

- uTaskerEVK1101SerialBoot.bin (load to the board with AVR32 studio or whatever method available - linked to 0x80000000)
- uTaskerV1.4.srec this can be downloaded to the board via terminal emulator 115'200 Baud 8 bit, no parity, one stop with XON/XOFF flow control. It is the uTasker demo project with UART menu on the USART1 (the one connected to the DSUB connector - same as used for download).

To force the serial loader mode with the application loaded, reset the board with the push button PB0 held down.

This was compiled with IAR and a GCC project still needs to be created and tested.

Note that the serial loader uses an intermediate buffer since the FLASH can not be programmed on a byte by byte basis with more data arriving by interrupt at 115'200 - with this option it collects a block of data, stops flow by sending XOFF, programs a block and continues by sending an XON to restart the download - full details are in the new version of the serial loader document including AVR32 details in appendix C: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.PDF

Regards

Mark

Note: I removed the attachments here due to an update as described in the following post

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3232
    • View Profile
    • uTasker
Re: Bootloader----S-REC format file
« Reply #12 on: November 20, 2009, 10:34:40 AM »
Hi All

Update:
I managed to cure the spurious Rx character on start up (I think that it is generally valid for all AVR32 types, but probably I just didn’t look so closely before). It is necessary to first configure the Rx pins and then enable the Rx module – before, the Rx module was enabled and immediately afterward the pin was configured – supposedly the internal Rx input sees a ‘0’ for a short time which triggers the reception of a character, which is then always 0xff. After changing the order this was solved.

The new attachments (see previous post for details) are corrected.

Regards

Mark

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3232
    • View Profile
    • uTasker
Re: Bootloader----S-REC format file
« Reply #13 on: November 21, 2009, 02:29:26 AM »
Hi All

Since I also have a new EVK1100 board I have added configurations for it and verified that the serial loader works correctly.
Attached are example files:
- uTaskerEVK1100SerialBoot.bin (serial loader to be programmed to address 0x80000000)
- uTaskerV1.4_EVK1100.srec (example application which can be downloaded)

Note that the serial loader mode can be forced by holding down the user button PB0 at reset.
Both are configured to use USART1 on the board at 115200 Baud 8 bits no parity and XON/XOFF flow control

The example application doesn't use Ethernet, but just a command menu of USART1 and the LED1 blinking on the board.

Regards

Mark

Offline Rambooka

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Bootloader----S-REC format file
« Reply #14 on: November 24, 2009, 06:00:20 AM »
Can you post the serial boot loader BIN files for the EVK1105

Thanks
Ray