Debugging ASCLoader

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
User17219
Level 1
Level 1
Hello

In our Project we would like to use the ASCLoader to flash our application over UART (ASC BSL) to our custom XMC4800-2048 board.

During debugging the source (Infineon-XMC4000_Bootloader_ASC_example_code-AN-v01_03-EN.zip) for XMC4800 we came to the conclusion that the loader
will not erase a Flash sector if the first 4 bytes are blank. In EraseSector the dwSectorAddr is incremented till we hit a memory address with double word != 0.
In the routine this INCREMENTED Adress is then given to XMC4000_PFLASH_EraseSector as sector base adress for erase (see line 106 of xmc4000_flasher.c.
I tried to confirm my hypothesis so I produced a binary file where the first 4 bytes of every sector is 0 and the remaining bytes of the sector are 0xFF.

I programmed this file (attached) with XMCLink (Segger J-Flash-Lite v6.34h) to the device and since then the device shows signs as it is proteced from any debug access.
However I do not know why my device is no bricked! Reading the documentation I am confused what is located at 0x0C00 0000:
- is it the UCB0 content (p8-7, Reference Manual V1.13, PMU v1.13)
- or the Vector Table of the code (p 7-4, Reference Manual V1.3, Memory Organization V2.12)
How can I unbrick my device?
I would be greatful for any hint to resolve my problem with the bricked device, why it is bricked ...

Tobias
0 Likes
4 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

At 0x0C00 0000 should be located the vector table. The first 4 bytes are the stack pointer. According to your vector table the microcontroller will jump to the address stored in the reset vector, 0xFFFFFFFF. This most probably will cause an HardFault exception.
You should be able to recover your device by reprograming (erasing the flash).

Regards,
Jesus
0 Likes
User17219
Level 1
Level 1
Yes I know, that the attached binary is not a programm and will result in a Hard fault. However flashing this binay with XMCLink to the device resulted in a bricked device!
I could not recover the device and the first 8 bytes of each sector can not be read anymore.


Further I would like to propose, that Infineon fixes the Bug in the ASCLoader project:

  • I tried to produce my own ASCLoader.bin by compiling the ASCLoader Project out of the box for XMC4800 in DAVE 4.4.2. However uploading this produced binary by the protocol described in the project pdf resulted NOT in a system answering my requests. However uploading the binary PROVIDED BY INFINEON/INCLUDED IN THE PROJECT worked!
  • In the EraseSector function in main.c we use as input parameter to the function the base address of a sector to erase (attached image). This parameter is incremented if the first (few) uint32 values in a sector are zero. If there is a non zero entry in the sector detected this INCREMETED address is give as parameter to the XMC4000_PFLASH_EraseSector function. In this function this incremeted sector address is used as "SA: Absolute start address of a Flash sector. Allowed are the PFLASH sectors Sx" - which is obvious agains the spec (RefMan V1.3, p8-10/11). Therefore a sector where the first uint32 value is 0 is not erased by the official Infinenon ASCLoader! I tried to modify the Project to fix this issue and check my bug fix which failed due to issue 1.
0 Likes
User17219
Level 1
Level 1
Are there any Actions on this Topic from Infineon?
0 Likes
User18139
Level 1
Level 1
I've contacted Infineon tech support and they have confirmed that there is a bug in EraseSector(). It was originally intended to avoid having to perform
an erase operation on a sector that was already erased (i.e. contains all zeroes). A bug in the code fails to detect the situation where the sector contains
zeroes in the first N long words (N >= 1) but not all bytes in the sector are zero. When this happens, and incorrect sector address gets passed to
XMC4000_PFLASH_EraseSector().

An Infineon tech support engineer has stated that this will be fixed in a new release.
0 Likes