Professional Documents
Culture Documents
MPC560XPBAM
MPC560XPBAM
MPC560XPBAM
32.1 Overview
The Boot Assist Module is a block of read-only memory containing VLE code that is executed according
to the boot mode of the device.
The BAM allows downloading boot code via the FlexCAN or LINFlex interfaces into internal SRAM and
then executing it.
32.2 Features
The BAM provides the following features:
• MPC5604P in static mode if internal flash is not initialized or invalid
• Programmable 64-bit password protection for serial boot mode
• Serial boot loads the application boot code from a FlexCAN or LINFlex bus into internal SRAM
• Censorship protection for internal flash module
Parameter Address
The RAM location where to download the code can be any 4-byte-aligned location starting from the
address 0x4000_0100.
Y
00 Serial boot (SBL)
FABM = 1 ABS = ? UART
N
01 Serial boot (SBL)
FlexCAN
no Boot-ID
Static mode
Note: The gray blocks in this figure represent hardware actions; white blocks represent software (BAM) actions.
Standby-RAM
FAB ABS[1:0] Boot ID Boot Mode
Boot Flag
When autobaud scan is selected by ABS and FAB pins, an autoscan procedure starts. This procedure
listens to the active bus protocol and automatically selects between:
• FlexCAN with autobaud
• LINFlex with autobaud
NOTE
Autobaud boot code feature is not provided when the device is secured.
Field Description
0-6 Reserved
7 VLE Indicator
VLE This bit configures the MMU for the boot block to execute as either Classic Power Architecture
Book E code or as Freescale VLE code.
0 Boot code executes as Classic Power Architecture Book E code
1 Boot code executes as Freescale VLE code
8-15 Is valid if its value is 0x5A, then the sector is considered bootable.
BOOT_ID[0:7]
0x0002 0000
32K
32K
16K
RCHW
0x0000 0000
0x0000 0000 Boot information
Internal Flash
Figure 32-3. MPC5604P Flash partitioning and RCHW search
Block Address
0 0x0000_0000
1 0x0000_8000
2 0x0000_C000
3 0x0001_0000
4 0x0001_8000
BAM entry
0xFFFF_C000
Save default
configuration
The selected boot mode is verified
by reading the SSCM_STATUS register
(bits BMODE and ABD)
Check
boot mode
Restore
Boot mode
default STATIC mode
valid?
NO configuration
YES
The first action is to save the initial device configuration. In this way is possible to restore the initial
configuration after downloading the new code but before executing it. This allows the new code being
executed as the device was just coming out of reset.
The BMODE and ABD fields of SSCM_STATUS register (see Section 8.2.2.1, “System Status register
(STATUS)”) indicate which boot has to be executed (see Table 32-5).
If the BMODE field shows either a single chip value (011) or a reserved value, the boot mode is not
considered valid and the BAM pushes the device into static mode.
In all other cases the code of the relative boot is called. Data is downloaded and saved into proper SRAM
location.
Field Description
Then, the initial device configuration is restored and the code jumps to the address of downloaded code.
At this point BAM has just finished its task.
If an error occurs, (e.g., communication error, wrong boot selected, etc.), the BAM restores the default
configuration and puts the device into static mode. Static mode means the device enters the low power
mode SAFE and the processor executes a wait instruction. This is needed if the device cannot boot in the
selected mode. During BAM execution and after, the mode reported by the field S_CURRENT_MODE of
the register ME_GS in the module ME Module is “DRUN”.
20 24000 500 K
40 48000 1M
Example 32-1.
=0
=1
Wait
START_ADDRESS[15:0]
VLE CODE_LENGTH[30:16]
CODE_LENGTH[15:0]
Figure 32-6. Start address, VLE bit and download size in bytes
32.5.5.1 Configuration
Boot from UART protocol is implemented by LINFlex_0 module. Pins used are:
• LINFlex_TX corresponds to pin B[2]
• LINFlex_RX corresponds to pin B[3].
When autobaud feature is disabled, the system clock is driven by external oscillator.
LINFlex controller is configured to operate at a baud rate = system clock frequency/833 (see Table 32-6
for baud rate example), using 8-bit data frame without parity bit and 1 stop bit.
Start Stop
D0 D1 D2 D3 D4 D5 D6 D7
bit bit
Protoco
Host sent BAM response
l Action
message message
step
1 64-bit password 64-bit password Password checked for validity and compared against stored
(MSB first) password.
2 32-bit store address 32-bit store address Load address is stored for future use.
3 VLE bit + VLE bit + Size of download is stored for future use.
31-bit number of 31-bit number of Verify if VLE bit is set to 1.
bytes (MSB first) bytes (MSB first)
4 8 bits of raw binary 8 bits of raw binary 8-bit data are packed into 32-bit word. This word is saved
data data into SRAM starting from the “Load address”.
“Load address” increments until the number of data
received and stored matches the size as specified in the
previous step.
5 none none Branch to downloaded code.
32.5.6.1 Configuration
Boot from FlexCAN protocol is implemented by the FlexCAN_0 module. Pins used are:
• CAN_TX corresponds to pin B[0]
• CAN_RX corresponds to pin B[1].
Boot from FlexCAN with autobaud disabled uses system clock driven by the external oscillator.
The FlexCAN controller is configured to operate at a baud rate equal to the system clock frequency/40 (see
Table 32-6 for examples of baud rate).
It uses the standard 11-bit identifier format detailed in the FlexCAN 2.0A specification.
FlexCAN controller bit timing is programmed with 10 time quanta, and the sample point is 2 time quanta
before the end, as shown in Figure 32-8.
1 7 2
time quanta time quanta time quanta
1 Bit Time
Protoco
Host sent BAM response
l Action
message message
step
1 FlexCAN ID 0x011 + FlexCAN ID 0x001 + Password checked for validity and compared against stored
64-bit password 64-bit password password.
2 FlexCAN ID 0x012 + FlexCAN ID 0x002 + Load address is stored for future use.
32-bit store address 32-bit store address Size of download is stored for future use.
+ VLE bit+ 31-bit + VLE bit + 31-bit Verify if VLE bit is set to 1.
number of bytes number of bytes
3 FlexCAN ID 0x013 + FlexCAN ID 0x003 + 8-bit data are packed into 32-bit words. These words are
8 to 64 bits of raw 8 to 64 bits of raw saved into SRAM starting from the “Load address”.
binary data binary data “Load address” increments until the number of data
received and stored matches the size as specified in the
previous step.
Time measurement
Start 0x0
bit
Initially the UART RX pin is configured as GPIO input and it waits in polling for the first falling edge,
then STM starts. UART RX pin waits again for the first rising. Then STM stops and from its measurement
baud rate is computed.
Start
UART_RX
configured as
GPIO input
NO
UART_RX == 0
YES
Start STM
NO
UART_RX == 1
YES
Stop STM
Read elapsed time
Calculate baud rate
UART_RX pin is configured
to work with LINFlex module.
LINFlex module is configured in UART
mode with calculated baud rate.
Baud rate
configuration
Follow normal
UART boot protocol
Eqn. 32-1
F cpu
LDIV = --------------------------------
-
16 baudrate
LDIV is an unsigned fixed point number and its mantissa is coded into 13 bits of the LINFlex’s register
LINIBRR.
From this equation and considering that a single UART transmission contains 9 bits, it is possible to obtain
the connection between time base measured by STM and LINIBB register:
Eqn. 32-2
LINIBRR = timebase
-----------------------
144
To minimize errors in baud rate, a large external oscillator frequency value and low baud rate signal are
preferred.
Example 32-3. Baud rate calculation for 24 kBaud signal
Considering a 24 kbaud signal and the device operating with 20 MHz external frequency.
Over 9 bits the STM will measure: (9 × 20 MHz)/24 kbaud = 7497 cycles.
Error expected to be approximately ± 6 cycles due to polling.
Thus, LINIBB will be set to 52 (rounding required). This results in a baud rate of 24.038 kbaud. Error of
< 0.2%.
To maintain the maximum deviation between host and calculated baud rate, recommendations for the user
are listed Table 32-10.
Table 32-10. Maximum and minimum recommended baud rates
Max baud rate for guaranteed Min baud rate for guaranteed
fsys = fxtal (MHz)
< 2.5% deviation < 2.5% deviation
Max baud rate for guaranteed Min baud rate for guaranteed
fsys = fxtal (MHz)
< 2.5% deviation < 2.5% deviation
Higher baud rates high may be used, but the user will be required to ensure they fall within an acceptable
error range. This is illustrated in Figure 32-11, which shows the effect of quantization error on the baud
rate selection.
Baud rate deviation between host and device
10.00
9.00
8.00
7.00
6.00
5.00
4.00
3.00
2.00
1.00
0.00
0 10000 20000 30000 40000 50000
Host baud rate
Considering reception of a 250kBaud signal from the host and MPC5604P operating with a 4 MHz
oscillator. Over 9 bits the time base will measure: (9 × 4e6)/250e3 = 144 cycles.
Thus, LINIBB is set to 144/144 = 1. This results in a baud rate of exactly 250 kBd.
However, a slower 225 kBd signal operating with 4 MHz XTAL would again result in LINIBB = 1, but
this time with an 11.1% deviation.
Measured Time
In UART boot mode, the FlexCAN RX pin is first configured to work as a GPIO input. In the end of baud
rate measurement, it switches to work with the FlexCAN module.
The baud rate measurement flow is detailed in Figure 32-13.
CAN_0_RX pin
configured as
If CAN is connected, GPIO input
CAN_RX should be at high level
NO
CAN_RX == 1 ERROR
NO
CAN_RX == 0
Start STM
YES
YES
Glitch?
Wait CAN_RX == 1
These steps are
executed 4 times
Wait CAN_RX == 0
Stop STM
Read elapsed time CAN_RX pin is configured
Calculate baud rate to work with FlexCAN module.
FlexCAN:
– is configured with calculated baud
– is enabled on the network
Baud rate configuration
Follow normal
CAN boot protocol
In the BAM, the time base is divided by 726, the remainder is discarded. The result provides the
CAN_CR[PRESDIV] to be selected.
To help compensate for any error in the calculated baud rate, the resynchronization jump width will be
increased from its default value of 1 to a fixed value of 2 time quanta.This is the maximum value allowed
that can accommodate all permissible can baud rates. See Table 32-12.
Timing segment 2 is kept as large as possible to keep sample time within bit time.
Table 32-13. Lookup table for FlexCAN bit timings
8 to 131 2 2 DTq-5
8 to 132 3 2 DTq-6
14 to 15 3 3 DTq-6
16 to 17 4 4 DTq-7
18 to 19 5 5 DTq-8
20 to 21 6 6 DTq-9
22 to 23 7 7 DTq-10
24 to 25 8 8 DTq-11
1 PRESDIV+1 > 1
2 PRESDIV+1 = 1 (to accommodate information processing time IPT of 3 tq) Note: All TSEG1 and
TSEG2 times have been chosen to preserve a sample time between 70% and 85% of the bit time.
32.6.2 Interrupt
No interrupts are generated by or are enabled by the BAM.