prog:mcp560x:20250818-002:index
Boot Assist Module (BAM) with FlexCAN MPC5604P (2025-08-18)
-
-
02-27-2014 04:59 AM
sergiff Contributor II
Hello !
I need to use the Boot Assist Module to boot an application from FlexCan bust to internal SRAM.
Now I'm using the TRK-MPC5604P demo for testing with CodeWarrior 10.5. I set the jumpers (FAB = 1, ABS2 = 1, ABS0 = 0) to set the boot mode to FlexCan autobaud to work above 200kbs (8MHz crystal frequency). But when you restart the MCU and try to send frames to calculate the baud, I can’t establish communication.
What I'm doing wrong? I guess initially prepare the MCU to use the BAM, but using the Reference Manual have not found the way.
Can help me with a example code? Just I have to modify the Linker Files?
Thank you very much for your time!
lukaszadrapa NXP TechSupport
1. The problem is that SBC chip MC33905 must be initialized via SPI to enable the CAN transceiver. CAN transceiver is turned off by default. So, MC33905 is not the best choice if BAM bootloader is used. Here you can find example how to turn on the CAN transceiver:
https://community.freescale.com/docs/DOC-99946
2. How to create RAM image:
Create a project in CodeWarrior and select RAM target. Now it is necessary to move entry point (function __start() ) at the start of RAM image – at address 0x4000_0000.
Find file __start.c in installation directory of CodeWarrior and copy it into your project. Add this files to source files in the project. Change the link order – set this file as a first one.
You will get some warnings because we overloaded the __start function.
Then it is necessary to change the linker file – place “init” section at the start of memory and place init_vle at the start of “init” GROUP:
(This is example for MPC5566 but it is similar for other devices)
MEMORY
{
init: org = 0x40000000, len = 0x00001000
pseudo_rom: org = 0x40001000, len = 0x00011000
exception_handlers: org = 0x40012000, len = 0x00001000
internal_ram: org = 0x40013000, len = 0x0000A000
heap : org = 0x4001D000, len = 0x00001000 /* Heap starts */
stack : org = 0x4001E000, len = 0x00001000 /* Start location for Stack */
}
SECTIONS
{
GROUP : {
.init_vle (VLECODE) : {
*(.init)
*(.init_vle)
}
.init : {}
} > init
….
Then the entry point (function __start() ) will be at 0x4000_0000. You can check it in .map file.
As a next step, just for test purposes, you can write some code in this project – for example toggle a LED diode in endless loop.
Build the program, so you have RAM.mot file. This is our RAM image that will be downloaded to RAM.
Because the downloading of code via SCI/CAN is quite slow, make the image as small as possible – edit the linker file. For example, if you don’t need size of pseudo_rom to be 0x11000, change it to smaller size.
Notice that downloading of code also initializes ECC. Area that is not written by BAM will contain ECC errors. If your application wants to use uninitialized RAM, it must be explicitly initialized by your SW.
The RAM.mot cannot be downloaded by BAM directly. It must be continuous image without gaps. You can either write some program on PC that will create continuous binary file or you can download the project into RAM by debugger, then save the content of RAM memory to binary file.
Detailed procedure how to download the image for both SCI and CAN can be found in reference manual.
Be aware that erratum exists on some devices: the size of image must NOT be equal to size of RAM. Last 16 bytes in RAM should not be written by BAM. But as I already wrote, it is better to make the image as small as possible.
And there are also application note for Qorivva devices:
And RAppID Bootloader utility:
-
lukaszadrapa NXP TechSupport
Hi Sergi,
MCU is initialized by BAM code. This is copied from reference manual:
***
34.5.4.3 BAM resources
BAM uses/initializes the following MCU resources:
• ME and CGM modules to initialize mode and clock sources
• CAN_0, LINFlex_0, and their pads when performing serial boot mode
• SSCM to check the boot mode and during password check (see Table 34-5 and Figure 34-5)
• External oscillator
The following hardware resources are used only when autobaud feature is selected:
• STM to measure the baud rate
• CMU to measure the external clock frequency related to the internal RC clock source
• FMPLL to work with system clock near the maximum allowed frequency (this to have higher resolution during baud rate measurement).
As already mentioned, the initial configuration is restored before executing the downloaded code.
***
If you want to use BAM loader, it would be better to use CAN transceiver that doesn’t require initialization. Otherwise the code that is already programmed in the MCU should initialize the transceiver before executing the BAM. Then you can reset the MCU and start the BAM download procedure.
Regards,
Lukas
NXP TechSupport lukaszadrapa
Hi Sergi,
the BAM is not able to load the code to flash. The BAM is just responsible to load the code to RAM via UART or CAN and then execute this code. So, it must be done by downloaded code. It is usually done in this way: we can develop “secondary bootloader” that will be loaded to RAM by BAM. This secondary bootloader will be responsible to get new firmware from somewhere (probably from the same interface - UART/CAN) and the bootloader has to program this new firmware to flash.
Notice that you can't program the same code that is loaded by BAM to RAM also to flash - it's because it is compiled to be executed from RAM.
Lukas
BAM 無法將程式碼載入到快閃記憶體中。 BAM 只負責透過 UART 或 CAN 將程式碼載入到 RAM,然後執行這些程式碼。因此,必須透過下載代碼來完成。通常的做法是:我們可以開發一個“輔助引導程式”,由 BAM 載入到 RAM。這個輔助引導程式負責從某個地方(可能是同一個介面-UART/CAN)取得新的韌體,然後引導程式必須將這個新韌體燒寫到快閃記憶體中。
請注意,您不能將 BAM 載入到 RAM 中的相同程式碼也編程到快閃記憶體中 - 這是因為它被編譯為從 RAM 執行。
prog/mcp560x/20250818-002/index.txt · Last modified: 2025/08/18 22:31 by jethro