weAut_01 / weAutSys    R 2.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Defines | Functions | Variables
Bootloader operation
+ + Bootloader support + +

Overview

In weAutSys it is intended that the bootloader software is entered on every reset. It may be entered by (CLI) user command out of normal operation also.

Before doing its AVR109 job and before (re-) entering the system/application software this bootloader implementation does a lot of (weAut_01) initialisation. See Bootloader integration for how to utilize that and Bootloader support for an overview and further references.

There are multiple criteria for the bootloader either to go directly to the application software or to enter the AVR109 protocol and waiting for a command or a sync (ESC) character. The most important are:

When the bootloader has entered (and remained in) the AVR109 protocol part it may be used via the serial link by any programming software capable of this protocol, like e.g. the well known avrdude. Use it by:

avrdude -p atmega1284p -c avr109 -b 38400  -P com1  -v  

Use it interactively:

avrdude -p atmega1284p -c avr109 -b 38400  -P com1  -v -t 

Use it to burn an application program by:

avrdude -p atmega1284p -c avr109 -b 38400  -P com1  -v -U flash:w:main.hex

Should this AVR bootloder mode be entered while a person's terminal is serially connected (e.g. by this person's CLI command) only a few AVR109 command letters may be entered without the risc of getting into trouble:
  V, v, p
  S (display bootloader name and set timeout to > 1 minute) and most important in that situation
  E (exit bootloader and start system / application software).
But do not enter (small) e inadvertently — except you want to erase flash except the bootloader itself and hence kill all else system and application software.

If the bootloader is to be build or used for other platforms, like say AurduinoMega2560 / ATmega2560 or for other com-ports make the applicable replacements, like e.g.

avrdude -p atmega2560  -c avr109 -b 38400    -P com6  -v -t 

Defines

#define getFlashByte(addr)
 Read a flash byte also from high addresses.
#define hwCritEntBoot()
 Hardware criterion for entering bootloader after reset.
#define PARTCODE   0x44
 The (outdated) single byte part code.
#define PROG_HW_VER
 The programmerHWver.
#define PROG_SIGN   "AVRBOOT"
 The programmerSign.
#define PROG_SW_VER   "10"
 The programmerSWver.
#define SEC_with_F0   (72-61)
 timeout value for timOutCountPatr
#define SEC_with_F8   (75-56)
 timeout value for timOutCountPatr
#define SEC_with_FF   (72-35)
 timeout value for timOutCountPatr
#define TIMEOUT_LIGHTSHOW
 Time out HMI display.

Functions

ADDR_T blockLoadEE (uint16_t size, ADDR_T address)
 Write a sequence of bytes read from UART(0) to EEPROM.
ADDR_T blockLoadFl (uint16_t size, ADDR_T address)
 Write a sequence of words read from UART(0) to flash memory.
ADDR_T blockReadEE (uint16_t size, ADDR_T address)
 Read a sequence of bytes from EEPROM and send them via UART(0)
ADDR_T blockReadFl (uint16_t size, ADDR_T address)
 Read a sequence of bytes from flash memory and send them via UART(0)
void bootLoaderGreet (void)
 Send the greeting lines for bootloader's start.
uint8_t isFlashCleared (void)
 Flash memory has no program.
void setTheLed (uint8_t state)
 Set the LED.

Variables

char const bootAut []
 The author of weAutSys and its bootloader.
char bootBld []
 The build date and time.
char const bootCop []
 The copyright notice for weAutSys and its bootloader.
char const bootRevDat []
 The bootloader's revision and date.
char const programmerHWver []
 The programmers hardware version.
char const programmerSign []
 Software identifier/programmer signature.
char const programmerSWver []
 The programmers software version.
uint8_t const timOutCountPatr []
 An eight bit count down display pattern.

Define Documentation

#define getFlashByte (   addr)

Read a flash byte also from high addresses.

Depending on the µController having a large flash memory or not this macro just delegates to pgm_read_byte_far or pgm_read_byte_near() respectively.

See also:
ADDR_T
#define hwCritEntBoot ( )

Hardware criterion for entering bootloader after reset.

For weAut_01 this is a pressed enter key while leaving reset (i.e. releasing the reset key or applying supply).


Function Documentation

void setTheLed ( uint8_t  state)

Set the LED.

If no test LED is available on the respective platform, this function does nothing. If more than one LED is available (as with weAut01) the most prominent red one is used. With weAut01 this is the red status LED (setStatusLedRd).

Parameters:
state0 / false: turn off; != 0: turn on
void bootLoaderGreet ( void  )

Send the greeting lines for bootloader's start.

This function sends some lines of text over the bootloader's serial link. These texts (bootloaderWlc, bootloaderPlatf, bootRevDat etc.) are to introduce the serial bootloader.

See also:
sendSerBytes_P
sendSerBytes
ADDR_T blockLoadFl ( uint16_t  size,
ADDR_T  address 
)

Write a sequence of words read from UART(0) to flash memory.

This is a bootloader support function. It will read size bytes from the UART and transfer them to the program memory starting at address. The address parameter must be a word address. It value incremented by size/2 will be returned.

Parameters:
sizethe number of bytes to write to flash memory. It must be an even number
addressthe start word address to write to in flash memory. (It is an even byte address.)
Returns:
address + size/2. That is the (incremented) address behind the last flash word modified
ADDR_T blockLoadEE ( uint16_t  size,
ADDR_T  address 
)

Write a sequence of bytes read from UART(0) to EEPROM.

This is a bootloader support function. It will read size bytes from the UART and transfer them to the EEPROM memory starting at address. The address parameter is a byte address.

Parameters:
sizethe number of bytes to write to EEPROM
addressthe start address (of the first EEPROM byte to be modified). The parameters's type will fit the flash size even if EEPROMs are much smaller.
Returns:
address + size. That is the (incremented) address behind the last EEPROM byte modified
ADDR_T blockReadFl ( uint16_t  size,
ADDR_T  address 
)

Read a sequence of bytes from flash memory and send them via UART(0)

This is a bootloader support function. It will read size bytes from flash memory starting at address and send them as pure binary values over the UART. The address parameter must be a word address. It value incremented by size/2 will be returned.

Parameters:
sizethe number of bytes to read from flash or program memory
addressthe start word address to read from flash memory. (It is an even byte address.)
Returns:
address + size/2. That is the (incremented) address behind the last flash word read
ADDR_T blockReadEE ( uint16_t  size,
ADDR_T  address 
)

Read a sequence of bytes from EEPROM and send them via UART(0)

This is a bootloader support function. It will read size bytes from EEPROM starting at address and send them over the UART.

Parameters:
sizethe number of bytes to write to EEPROM memory
addresspointer to the source memory's start address. It will be incremented.
Returns:
address + size. That is the (incremented) address behind the last EEPROM byte read
uint8_t isFlashCleared ( void  )

Flash memory has no program.

This function returns true if the flash cannot have been programmed with an application software after an erase.

The criterion is simply flash[0] == 0xFFFF. It is, nevertheless, a good criterion as with this interrupt vector un-programmed there will be no application.


Variable Documentation

char const programmerSWver[]

The programmers software version.

The version is always 2 characters, namely digits. The value is the same for all target platforms.

char const programmerHWver[]

The programmers hardware version.

The version is always 2 characters, namely digits. The value may depend on the target platform.

char const programmerSign[]

Software identifier/programmer signature.

The signature is always 7 characters. To be accepted by avrDude it has t start with AVR. The value is PROG_SIGN.

char const bootRevDat[]

The bootloader's revision and date.

The text starts with blank and ends in a linefeed.

char const bootAut[]

The author of weAutSys and its bootloader.

It is the author's name and his personal domain.

This is a string in (high) flash memory.

See also:
copyChars_P()
char const bootCop[]

The copyright notice for weAutSys and its bootloader.

This is a string in (high) flash memory.

See also:
copyChars_P()
getSomeCharsP(char*, prog_char*, uint8_t)
char bootBld[]

The build date and time.

It is the word "build" followed by the date and time where the C-preprocessor rolled over the (this) file boot109.h. This will be time where the bootloader was build.

This is a string in (high) flash memory.

See also:
copyChars_P()
uint8_t const timOutCountPatr[]

An eight bit count down display pattern.

This is an array in (high!) flash memory. "High" means in the bootloader flash area. That will be above 64K for some µControllers and means having to use pgm_read_byte_far(farAdd) instead of just pgm_read_byte(add16bit) for access.

For every second counted down there is a 8 bit = 8 LED display pattern the last one being 0 / all OFF. The total length is 72 (for 72 seconds. For less than 72 seconds start at pattern &timOutCountPatr[72 -tim]. To start at a certain pattern use SEC_with_FF (all on), SEC_with_F8 (5 LEDs on) or SEC_with_F0 (4 LEDs on) for the timeout value tim.

See also:
bootloaderWlc
FAR_ADD